teiid SVN: r479 - in trunk: build/assembly and 40 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-02-20 19:28:43 -0500 (Fri, 20 Feb 2009)
New Revision: 479
Added:
trunk/build/assembly/embedded/embedded-client-jar.xml
trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionListener.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/LogConfigurationProvider.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java
trunk/embedded/src/main/resources/deploy.properties
trunk/embedded/src/main/resources/jboss-cache-configuration.xml
trunk/embedded/src/test/resources/jboss-cache-configuration.xml
trunk/server/src/main/java/com/metamatrix/server/LogConfigurationProvider.java
trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java
Removed:
trunk/cache-jbosscache/src/main/resources/jboss-cache-configuration.xml
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionTracker.java
trunk/common-internal/src/main/java/com/metamatrix/common/log/config/DefaultLogConfigurationFactory.java
trunk/common-internal/src/main/java/com/metamatrix/common/log/config/LogConfigurationFactory.java
trunk/common-internal/src/main/java/com/metamatrix/common/log/format/DelimitedLogMessageFormat.java
trunk/common-internal/src/main/java/com/metamatrix/common/log/format/LogMessageFormat.java
trunk/common-internal/src/test/java/com/metamatrix/common/log/format/TestLogMessageFormat.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedManager.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPListener.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigUtil.java
trunk/embedded/src/main/resources/mm.properties
trunk/engine/src/main/java/com/metamatrix/dqp/application/
trunk/server/src/main/java/com/metamatrix/platform/config/ConfigurationChangeListener.java
trunk/server/src/main/java/com/metamatrix/platform/vm/util/VMUtils.java
Modified:
trunk/build/assembly/embedded/embedded-dependencies.xml
trunk/build/assembly/embedded/embedded-dist.xml
trunk/build/assembly/embedded/embedded-jar.xml
trunk/build/assembly/src.xml
trunk/build/kit-embedded/examples/portfolio/run.bat
trunk/build/kit-embedded/examples/portfolio/run.sh
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactory.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
trunk/client/src/main/java/com/metamatrix/admin/api/objects/Request.java
trunk/client/src/main/java/com/metamatrix/admin/objects/MMRequest.java
trunk/common-core/src/main/java/com/metamatrix/common/protocol/MMURLConnection.java
trunk/common-core/src/main/java/com/metamatrix/common/protocol/mmfile/MMFileURLConnection.java
trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java
trunk/common-core/src/main/java/com/metamatrix/internal/core/log/PlatformLog.java
trunk/common-internal/pom.xml
trunk/common-internal/src/main/java/com/metamatrix/common/log/LogConfiguration.java
trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java
trunk/common-internal/src/main/java/com/metamatrix/common/log/config/BasicLogConfiguration.java
trunk/common-internal/src/test/java/com/metamatrix/common/log/TestLogManager.java
trunk/connector-sdk/src/main/java/com/metamatrix/core/commandshell/CommandShell.java
trunk/console/src/main/java/com/metamatrix/console/main/AdminConsoleMain.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigSource.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalTransportHandler.java
trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java
trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedConfigurationService.java
trunk/embedded/src/test/java/com/metamatrix/jdbc/TestEmbeddedDriver.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java
trunk/pom.xml
trunk/server/src/main/java/com/metamatrix/common/log/DbLogListener.java
trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java
trunk/server/src/main/java/com/metamatrix/common/log/I18nLogManager.java
trunk/server/src/main/java/com/metamatrix/common/log/reader/DBLogReader.java
trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/ConsoleAuditDestination.java
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/VMController.java
trunk/server/src/main/java/com/metamatrix/server/HostController.java
trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java
trunk/server/src/main/java/com/metamatrix/server/Main.java
trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java
trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java
Log:
TEIID-66, TEIID-361: Embedded can only have one instance running; Guice start-up; Connection listening re-factored; LogManager made configurable. Reviewed By SH.
Added: trunk/build/assembly/embedded/embedded-client-jar.xml
===================================================================
--- trunk/build/assembly/embedded/embedded-client-jar.xml (rev 0)
+++ trunk/build/assembly/embedded/embedded-client-jar.xml 2009-02-21 00:28:43 UTC (rev 479)
@@ -0,0 +1,35 @@
+<!--This script builds a JAR for the Embedded Server Installation -->
+<assembly>
+
+ <id>client</id>
+
+ <formats>
+ <format>jar</format>
+ </formats>
+
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <baseDirectory>teiid-embedded-client</baseDirectory>
+
+ <moduleSets>
+ <moduleSet>
+ <includeSubModules>true</includeSubModules>
+
+ <includes>
+ <include>org.jboss.teiid:teiid-client</include>
+ <include>org.jboss.teiid:teiid-client-jdbc</include>
+ <include>org.jboss.teiid:teiid-common-core</include>
+ </includes>
+
+ <binaries>
+ <includeDependencies>false</includeDependencies>
+ <unpack>true</unpack>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>:jar:*</include>
+ </includes>
+ </binaries>
+
+ </moduleSet>
+ </moduleSets>
+
+</assembly>
\ No newline at end of file
Property changes on: trunk/build/assembly/embedded/embedded-client-jar.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/build/assembly/embedded/embedded-dependencies.xml
===================================================================
--- trunk/build/assembly/embedded/embedded-dependencies.xml 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/build/assembly/embedded/embedded-dependencies.xml 2009-02-21 00:28:43 UTC (rev 479)
@@ -45,7 +45,6 @@
<!-- these should have been excluded by module dependency structure, but until we fix those this will help-->
<exclude>antlr*</exclude>
<exclude>bsh*</exclude>
- <exclude>jgroups*</exclude>
<exclude>netty*</exclude>
<exclude>stringtemplate*</exclude>
</excludes>
Modified: trunk/build/assembly/embedded/embedded-dist.xml
===================================================================
--- trunk/build/assembly/embedded/embedded-dist.xml 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/build/assembly/embedded/embedded-dist.xml 2009-02-21 00:28:43 UTC (rev 479)
@@ -17,10 +17,17 @@
<includes>
<include>teiid-${version}-embedded.jar</include>
</includes>
+ <outputDirectory>lib</outputDirectory>
+ </fileSet>
+
+ <fileSet>
+ <directory>target/distribution</directory>
+ <includes>
+ <include>teiid-${version}-client.jar</include>
+ </includes>
<outputDirectory>/</outputDirectory>
</fileSet>
-
-
+
<fileSet>
<directory>target/distribution/teiid-${version}-embedded-dependencies.dir</directory>
<includes>
Modified: trunk/build/assembly/embedded/embedded-jar.xml
===================================================================
--- trunk/build/assembly/embedded/embedded-jar.xml 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/build/assembly/embedded/embedded-jar.xml 2009-02-21 00:28:43 UTC (rev 479)
@@ -16,9 +16,6 @@
<includes>
<include>org.jboss.teiid:teiid-cache-jbosscache</include>
- <include>org.jboss.teiid:teiid-client</include>
- <include>org.jboss.teiid:teiid-client-jdbc</include>
- <include>org.jboss.teiid:teiid-common-core</include>
<include>org.jboss.teiid:teiid-common-internal</include>
<include>org.jboss.teiid:teiid-connector-api</include>
Modified: trunk/build/assembly/src.xml
===================================================================
--- trunk/build/assembly/src.xml 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/build/assembly/src.xml 2009-02-21 00:28:43 UTC (rev 479)
@@ -36,6 +36,8 @@
<exclude>.classpath</exclude>
<exclude>.project</exclude>
<exclude>**/.settings/**</exclude>
+ <exclude>**/*.log</exclude>
+
</excludes>
</fileSet>
</fileSets>
Modified: trunk/build/kit-embedded/examples/portfolio/run.bat
===================================================================
--- trunk/build/kit-embedded/examples/portfolio/run.bat 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/build/kit-embedded/examples/portfolio/run.bat 2009-02-21 00:28:43 UTC (rev 479)
@@ -2,7 +2,7 @@
set CLIENT_PATH=java/*;PortfolioModel/
rem Second one for the JARs in Teiid embedded
-set TEIID_PATH=../../teiid-6.0.0-SNAPSHOT-embedded.jar;../../lib/*;../../extensions/*
+set TEIID_PATH=../../teiid-6.0.0-SNAPSHOT-client.jar;../../lib/*;../../extensions/*
java -cp %CLIENT_PATH%;%TEIID_PATH% JDBCClient "select * from CustomerAccount"
Modified: trunk/build/kit-embedded/examples/portfolio/run.sh
===================================================================
--- trunk/build/kit-embedded/examples/portfolio/run.sh 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/build/kit-embedded/examples/portfolio/run.sh 2009-02-21 00:28:43 UTC (rev 479)
@@ -4,6 +4,6 @@
CLIENT_PATH=java/*:PortfolioModel/
#Second one for the JARs in Teiid embedded
-TEIID_PATH=../../teiid-6.0.0-SNAPSHOT-embedded.jar:../../lib/*:../../extensions/*
+TEIID_PATH=../../teiid-6.0.0-SNAPSHOT-client.jar:../../lib/*:../../extensions/*
java -cp ${CLIENT_PATH}:${TEIID_PATH} JDBCClient "select * from CustomerAccount"
Deleted: trunk/cache-jbosscache/src/main/resources/jboss-cache-configuration.xml
===================================================================
--- trunk/cache-jbosscache/src/main/resources/jboss-cache-configuration.xml 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/cache-jbosscache/src/main/resources/jboss-cache-configuration.xml 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<server>
- <mbean code="org.jboss.cache.pojo.jmx.CacheJmxWrapper" name="jboss.cache:service=FederateCache">
- <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup</attribute>
- <attribute name="IsolationLevel">READ_COMMITTED</attribute>
- <attribute name="LockParentForChildInsertRemove">true</attribute>
-
- <attribute name="CacheMode">LOCAL</attribute>
- <attribute name="UseLazyDeserialization">true</attribute>
-
- <!--
- The max amount of time (in milliseconds) we wait until the
- initial state (ie. the contents of the cache) are retrieved from
- existing members in a clustered environment
- -->
- <attribute name="StateRetrievalTimeout">20000</attribute>
-
- <!--
- Number of milliseconds to wait until all responses for a
- synchronous call have been received.
- -->
- <attribute name="SyncReplTimeout">20000</attribute>
-
- <!-- Max number of milliseconds to wait for a lock acquisition -->
- <attribute name="LockAcquisitionTimeout">15000</attribute>
-
- <!-- Shutdown hook behavior. Valid choices are: DEFAULT, REGISTER and DONT_REGISTER. this element is omitted, DEFAULT is used. -->
- <attribute name="ShutdownHookBehavior">DEFAULT</attribute>
-
- <attribute name="FetchInMemoryState">true</attribute>
-
- <attribute name="CacheLoaderConfig" replace="false">
- <config>
-
- <!-- are the cache loaders shared in a cluster? -->
- <shared>false</shared>
- <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
- <passivation>true</passivation>
-
- <cacheloader>
- <class>org.jboss.cache.loader.FileCacheLoader</class>
- <properties>location=./target/scratch/federate</properties>
-
- <!--fetch the persistent state of a cache when joining a cluster-->
- <fetchPersistentState>true</fetchPersistentState>
-
- <!-- empties the specified cache loader when cache loader starts up -->
- <purgeOnStartup>true</purgeOnStartup>
-
- <!-- cache loader is shared among different cache instances -->
- <shared>false</shared>
- </cacheloader>
- </config>
- </attribute>
-
- <attribute name="EvictionPolicyConfig">
- <config>
- <attribute name="wakeUpIntervalSeconds">3</attribute>
- <!-- This defaults to 200000 if not specified -->
- <attribute name="eventQueueSize">100000</attribute>
- <!-- Name of the DEFAULT eviction policy class. -->
- <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
- <!-- Cache wide default -->
- <region name="/_default_">
- <attribute name="maxNodes">10000</attribute>
- <attribute name="timeToLiveSeconds">0</attribute>
- </region>
- </config>
- </attribute>
-
- </mbean>
-</server>
\ No newline at end of file
Modified: trunk/client/src/main/java/com/metamatrix/admin/api/objects/Request.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/api/objects/Request.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/client/src/main/java/com/metamatrix/admin/api/objects/Request.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -53,7 +53,7 @@
*
* @return long SessionID
*/
- public long getSessionID();
+ public String getSessionID();
/**
* Get the SQL Command sent to the Server for a Request
Modified: trunk/client/src/main/java/com/metamatrix/admin/objects/MMRequest.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/admin/objects/MMRequest.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/client/src/main/java/com/metamatrix/admin/objects/MMRequest.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -34,7 +34,7 @@
public class MMRequest extends MMAdminObject implements Request{
String userName = ""; //$NON-NLS-1$;
- long sessionID;
+ String sessionID;
String requestID;
Date created;
Date processingDate;
@@ -52,7 +52,7 @@
public MMRequest(String[] identifierParts) {
super(identifierParts);
- this.sessionID = Long.parseLong(identifierParts[0]);
+ this.sessionID = identifierParts[0];
this.requestID = identifierParts[1];
if (identifierParts.length >= 3) {
this.nodeID = identifierParts[2];
@@ -100,7 +100,7 @@
*
* @return long SessionID
*/
- public long getSessionID() {
+ public String getSessionID() {
return sessionID;
}
@@ -167,7 +167,7 @@
* @param sessionID The sessionID to set.
* @since 4.3
*/
- public void setSessionID(long sessionID) {
+ public void setSessionID(String sessionID) {
this.sessionID = sessionID;
}
/**
Added: trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionListener.java
===================================================================
--- trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionListener.java (rev 0)
+++ trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionListener.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -0,0 +1,45 @@
+/*
+ * 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 com.metamatrix.common.comm.api;
+
+import com.metamatrix.common.comm.api.ServerConnection;
+
+
+/**
+ * An implementor of this interface, when registered with the ServerConnection will
+ * receive notifications about the connection life cycle events.
+ */
+public interface ServerConnectionListener {
+ /**
+ * A connection has been added to DQP
+ * @param connection The client connection instance, never null
+ */
+ void connectionAdded(ServerConnection connection);
+
+ /**
+ * A connection has been removed for DQP
+ * @param connection The client connection instance, never null
+ */
+ void connectionRemoved(ServerConnection connection);
+
+}
Property changes on: trunk/client/src/main/java/com/metamatrix/common/comm/api/ServerConnectionListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactory.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactory.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactory.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -41,12 +41,6 @@
public Connection createConnection(Properties properties) throws SQLException;
/**
- * Register a Connection lifecycle listener to the this DQP instance
- * @param listener a listerner for connection related events.
- */
- public void registerConnectionListener(ConnectionListener listener);
-
- /**
* Shutdown the connection factory, including the DQP and all its existing connections
*/
public void shutdown() throws SQLException;
Deleted: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionTracker.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionTracker.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionTracker.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.jdbc;
-
-import java.net.URL;
-import java.sql.Connection;
-import java.util.HashSet;
-import java.util.Set;
-
-
-/**
- * This object keeps track of connections for a given dqp instance which is
- * identified by the "dqpURL". The main responsibility of this listener is to
- * take down the DQP instance when the connection count to the DQP goes down
- * to zero.
- */
-class EmbeddedConnectionTracker implements ConnectionListener {
-
- private URL dqpURL = null;
- private EmbeddedDriver dqpDriver = null;
- private Set connections = new HashSet();
-
-
- public EmbeddedConnectionTracker(URL dqpURL, EmbeddedDriver dqpDriver) {
- this.dqpURL = dqpURL;
- this.dqpDriver = dqpDriver;
- }
-
- public void connectionAdded(String id, Connection connection) {
- synchronized (connections) {
- connections.add(connection);
- }
- }
-
- public void connectionRemoved(String id, Connection connection) {
- synchronized (connections) {
- connections.remove(connection);
- if(connections.size() == 0) {
- dqpDriver.shutdown(dqpURL);
- }
- }
- }
-
- public Set getConnections() {
- Set tempSet = null;
- synchronized (connections) {
- tempSet = new HashSet(connections);
- }
- return tempSet;
- }
-
-}
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/EmbeddedDriver.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -25,7 +25,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
+import java.io.ObjectInputStream;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -34,15 +34,14 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
-import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.metamatrix.common.classloader.NonDelegatingClassLoader;
+import com.metamatrix.common.protocol.MMURLConnection;
import com.metamatrix.common.protocol.MetaMatrixURLStreamHandlerFactory;
import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.jdbc.util.MMJDBCURL;
@@ -76,7 +75,7 @@
static final String DQP_IDENTITY = "dqp.identity"; //$NON-NLS-1$
static final String MM_IO_TMPDIR = "mm.io.tmpdir"; //$NON-NLS-1$
- private static Hashtable transportMap = new Hashtable();
+ private static EmbeddedTransport currentTransport = null;
static Pattern urlPattern = Pattern.compile(URL_PATTERN);
static Pattern basePattern = Pattern.compile(BASE_PATTERN);
@@ -128,29 +127,31 @@
Connection conn = transport.createConnection(info);
- // only upon sucessful creation of the connection, keep the transport
+ // only upon successful creation of the connection, keep the transport
// available for future connections
- transportMap.put(dqpURL, transport);
+ currentTransport = transport;
return conn;
}
/**
- * Get the DQP tranport or build the transport if one not available from the
+ * Get the DQP transport or build the transport if one not available from the
* DQP URL supplied. DQP transport contains all the details about DQP.
- * @param dqpURL - URL to the DQP.proeprties file
+ * @param dqpURL - URL to the DQP.properties file
* @return EmbeddedTransport
* @throws SQLException
* @since 4.4
*/
- private EmbeddedTransport getDQPTransport(URL dqpURL, Properties info) throws SQLException {
- EmbeddedTransport transport = (EmbeddedTransport)transportMap.get(dqpURL);
- if (transport != null) {
+ private static EmbeddedTransport getDQPTransport(URL dqpURL, Properties info) throws SQLException {
+ EmbeddedTransport transport = currentTransport;
+ if (transport != null && currentTransport.getURL().equals(dqpURL)) {
String logMsg = BaseDataSource.getResourceMessage("EmbeddedDriver.use_existing_transport"); //$NON-NLS-1$
DriverManager.println(logMsg);
}
else {
- transport = new EmbeddedTransport(dqpURL, info, this);
+ // shutdown any previous instance; we do encourage single instance in a given VM
+ shutdown();
+ transport = new EmbeddedTransport(dqpURL, info);
String logMsg = BaseDataSource.getResourceMessage("EmbeddedDriver.use_new_transport"); //$NON-NLS-1$
DriverManager.println(logMsg);
}
@@ -226,7 +227,7 @@
* @return default connection URL
*/
String getDefaultConnectionURL() {
- return "classpath:/mm.properties"; //$NON-NLS-1$
+ return "classpath:/deploy.properties"; //$NON-NLS-1$
}
/**
@@ -317,15 +318,14 @@
* Shutdown the DQP instance which has been started using the given URL
* @param dqpURL
*/
- public synchronized void shutdown(URL dqpURL) {
- EmbeddedTransport transport = (EmbeddedTransport) transportMap.get(dqpURL);
- if (transport != null) {
+ public static synchronized void shutdown() {
+ if (currentTransport != null) {
try {
- transport.shutdown();
+ currentTransport.shutdown();
+ currentTransport = null;
} catch (SQLException e) {
DriverManager.println(e.getMessage());
}
- transportMap.remove(dqpURL);
}
}
@@ -335,52 +335,47 @@
*/
static class EmbeddedTransport {
private EmbeddedConnectionFactory connectionFactory;
- private EmbeddedConnectionTracker connectionTracker;
private ClassLoader classLoader;
private String workspaceDirectory;
+ private URL url;
- public EmbeddedTransport(URL dqpURL, Properties info, EmbeddedDriver driver) throws SQLException {
+ public EmbeddedTransport(URL dqpURL, Properties info) throws SQLException {
+ this.url = dqpURL;
+
// Create a temporary workspace directory
this.workspaceDirectory = createWorkspace(getDQPIdentity());
- // create a connection tracker to eep track of number of connections for this
- // dqp instance.
- this.connectionTracker = new EmbeddedConnectionTracker(dqpURL, driver);
-
//Load the properties from dqp.properties file
Properties props = loadDQPProperties(dqpURL);
props.putAll(info);
this.classLoader = this.getClass().getClassLoader();
- // If the dqp.classpath property exists, a non-delagating classloader will be created
- // for the DQP,otherwise the DQP classes will be loaded from the existing classloader
- // (unifiedclassloader scenario)
- String classPath = props.getProperty("dqp.classpath"); //$NON-NLS-1$
- if (classPath != null && classPath.length() > 0) {
- // fully qualify the class path into urls.
- URL[] dqpClassPath = resolveClassPath(classPath, dqpURL);
- this.classLoader = new NonDelegatingClassLoader(dqpClassPath, Thread.currentThread().getContextClassLoader(), new MetaMatrixURLStreamHandlerFactory());
- String logMsg = BaseDataSource.getResourceMessage("EmbeddedDriver.use_classpath"); //$NON-NLS-1$
- DriverManager.println(logMsg);
- for (int i = 0; i < dqpClassPath.length; i++) {
- DriverManager.println(dqpClassPath[i].toString());
- }
- }
+ // a non-delegating class loader will be created from where all third party dependent jars can be loaded
+ ArrayList<URL> runtimeClasspath = new ArrayList<URL>();
- // Now using this classloader create the connection factory to the dqp.
+ // find jars in the "lib" directory; patches is reverse alpaha and not case sensitive so small letters then capitals
+ runtimeClasspath.addAll(libClassPath(dqpURL, "lib/patches/", MMURLConnection.REVERSEALPHA)); //$NON-NLS-1$
+ runtimeClasspath.addAll(libClassPath(dqpURL, "lib/", MMURLConnection.DATE)); //$NON-NLS-1$
+
+ URL[] dqpClassPath = runtimeClasspath.toArray(new URL[runtimeClasspath.size()]);
+ this.classLoader = new NonDelegatingClassLoader(dqpClassPath, Thread.currentThread().getContextClassLoader(), new MetaMatrixURLStreamHandlerFactory());
+ String logMsg = BaseDataSource.getResourceMessage("EmbeddedDriver.use_classpath"); //$NON-NLS-1$
+ DriverManager.println(logMsg);
+ for (int i = 0; i < dqpClassPath.length; i++) {
+ DriverManager.println(dqpClassPath[i].toString());
+ }
+
+
+ // Now using this class loader create the connection factory to the dqp.
ClassLoader current = null;
try {
- // this is turn off shutdown thread hook for logging
- System.setProperty("shutdownHookInstalled", String.valueOf(Boolean.TRUE)); //$NON-NLS-1$
-
current = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(this.classLoader);
String className = "com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl"; //$NON-NLS-1$
Class clazz = this.classLoader.loadClass(className);
this.connectionFactory = (EmbeddedConnectionFactory)clazz.newInstance();
- this.connectionFactory.registerConnectionListener(this.connectionTracker);
} catch (Exception e) {
DriverManager.println(e.getClass() +": "+e.getMessage()); //$NON-NLS-1$
throw new EmbeddedSQLException(e);
@@ -389,43 +384,43 @@
}
}
+ URL getURL() {
+ return this.url;
+ }
+
/**
- * Given dqp.classpath string with relative, absolute paths convert them to
- * URLs to be used by the non delagating classloader.
- * @param classPath - class path given in the properties file
- * @param dqpContext - context URL of the dqp.properties file
- * @return resolved fully qualified url list of class path.
+ * Note that this only works when embedded loaded with "mmfile" protocol in the URL.
+ * @param dqpURL
+ * @return
*/
- URL[] resolveClassPath(String classPath, URL dqpContext) throws SQLException {
-
- //Load and check to make sure that a classpath exists in the properties
- if(classPath == null || classPath.trim().length() == 0) {
- String logMsg = BaseDataSource.getResourceMessage("EmbeddedTransport.no_classpath"); //$NON-NLS-1$
- DriverManager.println(logMsg);
- throw new EmbeddedSQLException(logMsg);
- }
-
+ private List<URL> libClassPath (URL dqpURL, String directory, String sortStyle) {
+ ObjectInputStream in = null;
+ ArrayList<URL> urlList = new ArrayList<URL>();
try {
- // Create URLs out of the classpath string
- List urls = new ArrayList();
- StringTokenizer st = new StringTokenizer(classPath,";"); //$NON-NLS-1$
- while(st.hasMoreTokens()) {
- String path = st.nextToken();
- path = path.trim();
- if (path.length() > 0) {
- // URLHelper is our special URL constructor based on the MM specific
- // protocols like "classpath:" and "mmfile:".
- urls.add(URLHelper.buildURL(dqpContext, path));
+ urlList.add(URLHelper.buildURL(dqpURL, directory));
+ dqpURL = URLHelper.buildURL(dqpURL, directory+"?action=list&filter=.jar&sort="+sortStyle); //$NON-NLS-1$
+ in = new ObjectInputStream(dqpURL.openStream());
+ String[] urls = (String[])in.readObject();
+ for (int i = 0; i < urls.length; i++) {
+
+ boolean add = true;
+ URL jarURL = URLHelper.buildURL(urls[i]);
+ if (add) {
+ urlList.add(jarURL);
}
+ }
+ } catch(IOException e) {
+ //ignore, treat as if lib does not exist
+ } catch(ClassNotFoundException e) {
+ //ignore, treat as if lib does not exist
+ } finally {
+ if (in != null) {
+ try{in.close();}catch(IOException e) {}
}
- return (URL[])urls.toArray(new URL[urls.size()]);
- } catch (MalformedURLException e) {
- DriverManager.println(e.getClass() +": "+e.getMessage()); //$NON-NLS-1$
- DriverManager.println(e.getStackTrace().toString());
- throw new EmbeddedSQLException(e);
- }
- }
-
+ }
+ return urlList;
+ }
+
/**
* Load DQP Properties from the URL supplied.
* @param dqpURL - URL to the "dqp.properties" object
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMConnection.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -119,7 +119,7 @@
* @param info contains properies needed to establish a MetaMatrix connection.
* @throws SQLException if the driver cannot establish connection to metamatrix.
*/
- MMConnection(ServerConnection serverConn, Properties info, String url) {
+ public MMConnection(ServerConnection serverConn, Properties info, String url) {
this.serverConn = serverConn;
this.url = url;
this.dqp = serverConn.getService(ClientSideDQP.class);
Modified: trunk/common-core/src/main/java/com/metamatrix/common/protocol/MMURLConnection.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/protocol/MMURLConnection.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-core/src/main/java/com/metamatrix/common/protocol/MMURLConnection.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -34,10 +34,16 @@
* @since 4.4
*/
public abstract class MMURLConnection extends URLConnection {
- protected static final String READ = "read"; //$NON-NLS-1$
- protected static final String WRITE = "write"; //$NON-NLS-1$
- protected static final String LIST = "list"; //$NON-NLS-1$
- protected static final String DELETE = "delete"; //$NON-NLS-1$
+ protected static final String READ = "read"; //$NON-NLS-1$
+ protected static final String WRITE = "write"; //$NON-NLS-1$
+ protected static final String LIST = "list"; //$NON-NLS-1$
+ protected static final String DELETE = "delete"; //$NON-NLS-1$
+
+ public static final String FILE_LIST_SORT = "sort"; //$NON-NLS-1$
+ public static final String DATE = "date"; //$NON-NLS-1$
+ public static final String ALPHA = "alpha"; //$NON-NLS-1$
+ public static final String REVERSEALPHA = "reversealpha"; //$NON-NLS-1$
+
protected String action = READ;
protected Properties props = null;
Modified: trunk/common-core/src/main/java/com/metamatrix/common/protocol/mmfile/MMFileURLConnection.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/protocol/mmfile/MMFileURLConnection.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-core/src/main/java/com/metamatrix/common/protocol/mmfile/MMFileURLConnection.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -40,6 +40,8 @@
import java.net.URL;
import java.net.URLConnection;
import java.security.Permission;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.StringTokenizer;
import com.metamatrix.common.protocol.MMURLConnection;
@@ -56,8 +58,7 @@
* @since 4.4
*/
public class MMFileURLConnection extends MMURLConnection {
-
- public static String PROTOCOL = "mmfile"; //$NON-NLS-1$
+ public static String PROTOCOL = "mmfile"; //$NON-NLS-1$
File file;
File deleted;
public static String DELETED = ".deleted"; //$NON-NLS-1$
@@ -167,12 +168,39 @@
return false;
}
};
-
+
File[] matchedFiles = file.listFiles(fileFilter);
String[] urls = new String[matchedFiles.length];
+
+ String sort = props.getProperty(FILE_LIST_SORT, DATE);
+ if (sort.equals(DATE)) {
+ Arrays.sort(matchedFiles, new Comparator<File>() {
+ @Override
+ public int compare(File o1, File o2) {
+ return Long.valueOf(o2.lastModified()).compareTo(o1.lastModified()); // latest first.
+ }
+ });
+ } else if (sort.equals(ALPHA)) {
+ Arrays.sort(matchedFiles, new Comparator<File>() {
+ @Override
+ public int compare(File o1, File o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ });
+
+ } else if (sort.equals(REVERSEALPHA)) {
+ Arrays.sort(matchedFiles, new Comparator<File>() {
+ @Override
+ public int compare(File o1, File o2) {
+ return o2.getName().compareTo(o1.getName());
+ }
+ });
+ }
+
for (int i = 0; i < matchedFiles.length; i++) {
urls[i] = URLHelper.buildURL(url, matchedFiles[i].getName()).toString();
}
+
// Build input stream from the object
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(out);
@@ -237,7 +265,7 @@
} catch (IOException e) {
}
}
- } else if (name.equalsIgnoreCase("date")) //$NON-NLS-1$
+ } else if (name.equalsIgnoreCase(DATE))
headerField = String.valueOf(file.lastModified());
else {
// This always returns null currently
Modified: trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-core/src/main/java/com/metamatrix/core/log/LogMessage.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -22,91 +22,28 @@
package com.metamatrix.core.log;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
+import java.io.Serializable;
-import com.metamatrix.core.CorePlugin;
-public class LogMessage implements Externalizable {
+public class LogMessage implements Serializable{
- public static final String VM_NAME = "VMName"; //$NON-NLS-1$
- public static final String HOST_NAME = "HostName"; //$NON-NLS-1$
-
-// public static String VM_NAME = VMNaming.getVMName();
-// public static String HOST_NAME = VMNaming.getLogicalHostName();
-//
-// private static final String DEFAULT_VM_NAME = ""; //$NON-NLS-1$
-
- private static final String NULL_MSG_TEXT = "Null"; //$NON-NLS-1$
-//
-// static {
-// if ( VM_NAME == null || VM_NAME.trim().length() == 0 ) {
-// VM_NAME = VMNaming.getVMIDString();
-// }
-// if ( VM_NAME == null || VM_NAME.trim().length() == 0 ) {
-// VM_NAME = DEFAULT_VM_NAME;
-// }
-// }
-
- private String msgID;
-
private String context;
private int level;
private Object[] msgParts;
private Throwable exception;
private long timestamp;
private String threadName;
- private String hostName;
- private String vmName;
private int errorCode;
public LogMessage() {
}
- public LogMessage(String msgID, String context, int level) {
- this.msgID = msgID;
- this.context = context;
- this.level = level;
- this.msgParts = null;
- this.timestamp = System.currentTimeMillis();
- this.threadName = Thread.currentThread().getName();
- this.hostName = HOST_NAME;
- this.vmName = VM_NAME;
- }
-
- public LogMessage(String msgID, String context, int level, Throwable e) {
- this(msgID, context, level);
- this.exception = e;
- }
-
-
- public LogMessage(String msgID, String context, int level, Object[] msgParts ) {
- this.msgID = msgID;
- this.context = context;
- this.level = level;
- this.msgParts = convertMsgParts(msgParts);
- this.timestamp = System.currentTimeMillis();
- this.threadName = Thread.currentThread().getName();
- this.hostName = HOST_NAME;
- this.vmName = VM_NAME;
- }
-
- public LogMessage(String msgID, String context, int level, Throwable e, Object[] msgParts ) {
- this(msgID, context, level, msgParts);
- this.exception = e;
- }
-
public LogMessage(String context, int level, Object[] msgParts ) {
- this.msgID= null;
this.context = context;
this.level = level;
this.msgParts = convertMsgParts(msgParts);
this.timestamp = System.currentTimeMillis();
this.threadName = Thread.currentThread().getName();
- this.hostName = HOST_NAME;
- this.vmName = VM_NAME;
}
public LogMessage(String context, int level, Throwable e, Object[] msgParts) {
@@ -139,14 +76,6 @@
return this.threadName;
}
- public String getVMName() {
- return this.vmName;
- }
-
- public String getHostName() {
- return this.hostName;
- }
-
public long getTimestamp() {
return this.timestamp;
}
@@ -155,74 +84,8 @@
return this.exception;
}
- public String getText() {
- String msg = null;
- if (msgID != null) {
- if (msgParts == null) {
- msg = CorePlugin.Util.getString(msgID);
- } else {
- msg = CorePlugin.Util.getString(msgID, msgParts);
-
- }
-
- } else {
-
- StringBuffer text = null;
- if(msgParts != null) {
- text = new StringBuffer();
- for(int i=0; i<msgParts.length; i++) {
- if (i>0) text.append(" "); //$NON-NLS-1$
- Object omsg = msgParts[i];
- if ( omsg != null ) {
- text.append(omsg.toString());
- }
- }
- }
-
- if (text == null) {
- msg = NULL_MSG_TEXT;
- } else {
- msg = text.toString();
- }
-
-
- }
-
- if (msg == null || msg.length() == 0) {
- msg = NULL_MSG_TEXT;
- }
-
-
- return msg;
- }
-
- // implements Externalizable
- public void writeExternal(ObjectOutput out) throws IOException {
- out.writeObject(context);
- out.writeInt(level);
- out.writeObject(msgParts);
- out.writeObject(exception);
- out.writeLong(timestamp);
- out.writeObject(threadName);
- out.writeObject(vmName);
- out.writeInt(this.errorCode);
- }
-
- // implements Externalizable
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
- this.context = (String) in.readObject();
- this.level = in.readInt();
- this.msgParts = (Object[]) in.readObject();
- this.exception = (Throwable) in.readObject();
- this.timestamp = in.readLong();
- this.threadName = (String) in.readObject();
- this.vmName = (String) in.readObject();
- this.errorCode = in.readInt();
- }
-
-
//do a toString() to the object array before adding to the worker
//to make sure the current state is recorded
private Object[] convertMsgParts(Object[] oriMsgParts){
@@ -237,6 +100,25 @@
return oriMsgParts;
}
+ public String getText() {
+ StringBuffer text = null;
+ if(msgParts != null) {
+ text = new StringBuffer();
+ for(int i=0; i<msgParts.length; i++) {
+ if (i>0) text.append(" "); //$NON-NLS-1$
+ Object omsg = msgParts[i];
+ if ( omsg != null ) {
+ text.append(omsg.toString());
+ }
+ }
+ }
+
+ if (text == null) {
+ return "NULL"; //$NON-NLS-1$
+ } else {
+ return text.toString();
+ }
+ }
/**
* @return Returns the errorCode.
Modified: trunk/common-core/src/main/java/com/metamatrix/internal/core/log/PlatformLog.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/internal/core/log/PlatformLog.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-core/src/main/java/com/metamatrix/internal/core/log/PlatformLog.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -34,7 +34,6 @@
import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.log.LogMessage;
import com.metamatrix.core.log.Logger;
-import com.metamatrix.core.log.SystemLogWriter;
/**
* The PlatformLog class is designed to be extended by any {@link Logger} implementation that is to
@@ -83,42 +82,10 @@
*/
public class PlatformLog implements LogListener {
- // =========================================================================
- // Static Members
- // =========================================================================
- private static final PlatformLog INSTANCE = new PlatformLog();
- private static ShutdownThread SHUTDOWNTHREAD = null;
- private static final String SHUTDOWN_HOOK_INSTALLED_PROPERTY = "shutdownHookInstalled"; //$NON-NLS-1$
-
- static {
- String hook = System.getProperty(SHUTDOWN_HOOK_INSTALLED_PROPERTY);
- if ( hook == null || hook.equalsIgnoreCase(String.valueOf(Boolean.FALSE))) {
- /**
- * By default, add a listener to write to System.out and System.err,
- * and that is automatically shutdown upon VM termination.
- */
- SHUTDOWNTHREAD = new ShutdownThread(INSTANCE);
- INSTANCE.addListener( new SystemLogWriter() );
- try {
- Runtime.getRuntime().addShutdownHook(SHUTDOWNTHREAD);
- System.setProperty(SHUTDOWN_HOOK_INSTALLED_PROPERTY, Boolean.TRUE.toString());
- } catch (IllegalStateException e) {
- //ignore: this happens if we try to register the shutdown hook after the system
- //is already shutting down. there's nothing we can do about it.
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
- }
-
- public static PlatformLog getInstance() {
- return INSTANCE;
- }
-
private static final String DEFAULT_LOG_WORKER_THREAD_NAME = "LogWorker"; //$NON-NLS-1$
private static final long DEFAULT_TIMEOUT = 60000; // time to wait for a message
- private static final long SHUTDOWN_TIMEOUT = 20000; // max time to wait for shutdown
+ private static final long SHUTDOWN_TIMEOUT = 20000; // max time to wait for shutdown
/**
* Flag specifying whether to write debugging statements to {@link #DEBUG_STREAM}.
@@ -182,24 +149,6 @@
}
/**
- * Used by the DQP to ensure that the shutdown thread is removed from the VM
- * in which the DQP is embedded.
- * @since 4.2
- */
- public static void deregisterShutdownHook() {
- try {
- if (SHUTDOWNTHREAD != null) {
- Runtime.getRuntime().removeShutdownHook(SHUTDOWNTHREAD);
- }
- } catch (IllegalStateException e) {
- //ignore: this happens if we try to register the shutdown hook after the system
- //is already shutting down. there's nothing we can do about it.
- } catch (Throwable t) {
- t.printStackTrace();
- }
- }
-
- /**
* Shut down and process all content. This method is equivalent to calling
* {@link #shutdown(boolean)} with a parameter value of <code>true</code>.
*/
@@ -258,6 +207,8 @@
}
this.logListeners.clear();
}
+
+ this.executor = null;
}
public synchronized void start() {
@@ -342,20 +293,4 @@
}
}
-
-class ShutdownThread extends Thread {
- private static final String SHUTDOWN_THREAD_NAME = "Shutdown"; //$NON-NLS-1$
- private PlatformLog log;
-
- ShutdownThread(final PlatformLog platformLog) {
- super(SHUTDOWN_THREAD_NAME);
- this.log = platformLog;
- }
-
- public void run() {
- final boolean processRemainingContent = true;
- this.log.shutdown(processRemainingContent);
- }
-
-}
Modified: trunk/common-internal/pom.xml
===================================================================
--- trunk/common-internal/pom.xml 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-internal/pom.xml 2009-02-21 00:28:43 UTC (rev 479)
@@ -64,6 +64,11 @@
<artifactId>stringtemplate</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.google.code.guice</groupId>
+ <artifactId>guice</artifactId>
+ </dependency>
+
</dependencies>
</project>
\ No newline at end of file
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/log/LogConfiguration.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/LogConfiguration.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/LogConfiguration.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -27,10 +27,6 @@
public interface LogConfiguration extends Comparable, Cloneable {
- boolean isContextDiscarded( String context );
-
- boolean isLevelDiscarded( int level );
-
/**
* Obtain the set of contexts for messages that are to be discarded.
* If this method returns an empty set, then messages in all contexts
@@ -55,45 +51,17 @@
int getMessageLevel();
/**
- * Compares this object to another. If the specified object is an instance of
- * the MetadataID class, then this method compares the name; otherwise, it throws a
- * ClassCastException (as instances are comparable only to instances of the same
- * class).
- * Note: this method <i>is</i> consistent with <code>equals()</code>, meaning
- * that <code>(compare(x, y)==0) == (x.equals(y))</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return a negative integer, zero, or a positive integer as this object
- * is less than, equal to, or greater than the specified object, respectively.
- * @throws IllegalArgumentException if the specified object reference is null
- * @throws ClassCastException if the specified object's type prevents it
- * from being compared to this instance.
+ * Direct the log configuration to record all known logging contexts.
*/
- int compareTo(Object obj);
+ void recordAllContexts();
/**
- * Returns true if the specified object is semantically equal to this instance.
- * Note: this method is consistent with <code>compareTo()</code>.
- * <p>
- * @param obj the object that this instance is to be compared to.
- * @return whether the object is equal to this object.
+ * Clone the object.
+ * @return
*/
- boolean equals(Object obj);
-
- /**
- * String representation of logging configuration.
- * @return String representation
- */
- String toString();
-
Object clone();
-
+
/**
- * Direct the log configuration to record all known logging contexts.
- */
- void recordAllContexts();
-
- /**
* Direct the log configuration to discard the given contexts and
* not record them.
* @param contexts the collection of contexts that should be discarded.
@@ -112,4 +80,7 @@
* @param level the lowest level to record.
*/
void setMessageLevel(int level);
+
+
+ boolean isMessageToBeRecorded(String context, int msgLevel);
}
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/LogManager.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -27,18 +27,15 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import com.google.inject.Inject;
import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.log.config.BasicLogConfiguration;
-import com.metamatrix.common.log.config.DefaultLogConfigurationFactory;
-import com.metamatrix.common.log.config.LogConfigurationException;
-import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.log.LogMessage;
import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.internal.core.log.PlatformLog;
+import com.metamatrix.core.log.NullLogWriter;
/**
@@ -92,86 +89,13 @@
*/
public final class LogManager {
- /**
- * The name of the System property that contains the set of comma-separated
- * context names for messages <i>not</i> to be recorded. A message context is simply
- * some string that identifies something about the component that generates
- * the message. The value for the contexts is application specific.
- * <p>
- * This is an optional property that defaults to no contexts (i.e., messages
- * with any context are recorded).
- */
- public static final String SYSTEM_LOG_CONTEXT_PROPERTY_NAME = DefaultLogConfigurationFactory.LOG_CONTEXT_PROPERTY_NAME;
-
- /**
- * The name of the System property that contains 'true' if the log messages
- * are to be sent to System.out, or 'false' otherwise. This is an optional
- * property that defaults to 'true'. Note, however, that if the message
- * level for the logger is specified to be something other than NONE but
- * no file destination is specified, the value for this propery is
- * always assumed to be 'true'.
- * <p>
- * If the System.out is captured by the LogManager, the LogManager always
- * treats this property value as 'false'.
- */
- public static final String SYSTEM_LOG_CONSOLE_PROPERTY_NAME = "metamatrix.log.console"; //$NON-NLS-1$
-
- /**
- * The name of the System property that should be 'true' if System.out is to
- * be captured by the LogManager, or false if System.out is not be be captured.
- * This is an optional property that defaults to 'false'.
- */
- public static final String SYSTEM_LOG_CAPTURE_SYSTEM_OUT = "metamatrix.log.captureSystemOut"; //$NON-NLS-1$
-
- /**
- * The name of the System property that should be 'true' if System.err is to
- * be captured by the LogManager, or false if System.err is not be be captured.
- * This is an optional property that defaults to 'false'.
- */
- public static final String SYSTEM_LOG_CAPTURE_SYSTEM_ERR = "metamatrix.log.captureSystemErr"; //$NON-NLS-1$
-
- /**
- * The name of the System property that should be set to the name of the file
- * to which System.out is sent only if also captured by the LogManager.
- * This is an optional property. If set to the same value as
- * #SYSTEM_ERR_FILENAME (case insensitive comparison), then the same file will be used for both.
- */
- public static final String SYSTEM_OUT_FILENAME = "metamatrix.log.systemOutFilename"; //$NON-NLS-1$
-
- /**
- * The name of the System property that should be set to the name of the file
- * to which System.err is sent only if also captured by the LogManager.
- * This is an optional property. If set to the same value as
- * #SYSTEM_OUT_FILENAME (case insensitive comparison), then the same file will be used for both.
- */
- public static final String SYSTEM_ERR_FILENAME = "metamatrix.log.systemErrFilename"; //$NON-NLS-1$
-
- private static LogManager INSTANCE = new LogManager(PlatformLog.getInstance());
-
- private LogConfiguration configuration;
- private PlatformLog platformLog;
+ @Inject
+ static LogConfiguration configuration = new BasicLogConfiguration(); // either injected or manually set using the set methods
- protected LogManager(PlatformLog platformLog) {
- this.platformLog = platformLog;
- // Get the preferred LogConfiguration ...
- try {
- configuration = (LogConfiguration)CurrentConfiguration.getInstance().getConfiguration().getLogConfiguration().clone();
- } catch ( ConfigurationException e ) {
+ @Inject
+ static LogListener logListener = new NullLogWriter(); // either injected or manually set using the set methods
- // Get the initial LogConfiguration from the System properties ...
- try {
- configuration = BasicLogConfiguration.createLogConfiguration(System.getProperties());
- } catch ( LogConfigurationException le ) {
- throw new MetaMatrixRuntimeException(le, ErrorMessageKeys.LOG_ERR_0005, CommonPlugin.Util.getString( ErrorMessageKeys.LOG_ERR_0005) );
- }
- }
- }
-
- static LogManager getInstance() {
- return INSTANCE;
- }
-
/**
* Send a critical message to the log. This level of message is generally
* used to record an event or error that must be recorded (if any logging
@@ -187,7 +111,7 @@
* not logged if this parameter is null
*/
public static void logCritical(String context, String message) {
- LogManager.getInstance().logMessage(MessageLevel.CRITICAL, context, message);
+ logMessage(MessageLevel.CRITICAL, context, message);
}
/**
@@ -206,7 +130,7 @@
* @param message the log message (may be null)
*/
public static void logCritical(String context, Throwable e, String message) {
- LogManager.getInstance().logMessage(MessageLevel.CRITICAL,context,e,message);
+ logMessage(MessageLevel.CRITICAL,context,e,message);
}
/**
@@ -222,7 +146,7 @@
* not logged if this parameter is null
*/
public static void logError(String context, String message) {
- LogManager.getInstance().logMessage(MessageLevel.ERROR, context,message);
+ logMessage(MessageLevel.ERROR, context,message);
}
/**
@@ -239,7 +163,7 @@
* @param message the log message (may be null)
*/
public static void logError(String context, Throwable e, String message) {
- LogManager.getInstance().logMessage(MessageLevel.ERROR,context,e,message);
+ logMessage(MessageLevel.ERROR,context,e,message);
}
/**
@@ -255,7 +179,7 @@
* not logged if this parameter is null
*/
public static void logWarning(String context, String message) {
- LogManager.getInstance().logMessage(MessageLevel.WARNING, context,message);
+ logMessage(MessageLevel.WARNING, context,message);
}
/**
@@ -272,7 +196,7 @@
* @param message the log message (may be null)
*/
public static void logWarning(String context, Throwable e, String message) {
- LogManager.getInstance().logMessage(MessageLevel.WARNING,context,e,message);
+ logMessage(MessageLevel.WARNING,context,e,message);
}
/**
@@ -289,7 +213,7 @@
* not logged if this parameter is null
*/
public static void logInfo(String context, String message) {
- LogManager.getInstance().logMessage(MessageLevel.INFO, context,message);
+ logMessage(MessageLevel.INFO, context,message);
}
/**
@@ -305,7 +229,7 @@
* not logged if this parameter is null
*/
public static void logDetail(String context, Object ... msgParts) {
- LogManager.getInstance().logMessage(MessageLevel.DETAIL, context, msgParts);
+ logMessage(MessageLevel.DETAIL, context, msgParts);
}
/**
@@ -322,7 +246,7 @@
* @param message the log message (may be null)
*/
public static void logDetail(String context, Throwable e, String message) {
- LogManager.getInstance().logMessage(MessageLevel.DETAIL,context,e,message);
+ logMessage(MessageLevel.DETAIL,context,e,message);
}
/**
@@ -339,7 +263,7 @@
* not logged if this parameter is null
*/
public static void logTrace(String context, Object ... msgParts) {
- LogManager.getInstance().logMessage(MessageLevel.TRACE, context, msgParts);
+ logMessage(MessageLevel.TRACE, context, msgParts);
}
/**
@@ -357,7 +281,7 @@
* @param msgParts the individual parts of the log message (may be null)
*/
public static void logTrace(String context, Throwable e, Object ... msgParts) {
- LogManager.getInstance().logMessage(MessageLevel.TRACE,context,e,msgParts);
+ logMessage(MessageLevel.TRACE,context,e,msgParts);
}
/**
@@ -372,7 +296,7 @@
* not logged if this parameter is null
*/
public static void log(int msgLevel, String context, String message) {
- LogManager.getInstance().logMessage(msgLevel, context, message);
+ logMessage(msgLevel, context, message);
}
/**
@@ -388,7 +312,7 @@
* not logged if this parameter is null
*/
public static void log(int msgLevel, String context, Throwable e, String message) {
- LogManager.getInstance().logMessage(msgLevel, context, e, message);
+ logMessage(msgLevel, context, e, message);
}
/**
@@ -398,24 +322,29 @@
* @return a modifiable copy of the current log configuration
*/
public static LogConfiguration getLogConfigurationCopy() {
- return getInstance().getConfigurationCopy();
+ if (configuration == null) {
+ throw new MetaMatrixRuntimeException(CommonPlugin.Util.getString("LogManager_not_configured")); //$NON-NLS-1$
+ }
+ return (LogConfiguration)configuration.clone();
}
public static void setLogConfiguration( LogConfiguration config ) {
- getInstance().setConfiguration(config);
- }
-
- public LogConfiguration getConfigurationCopy() {
- return (LogConfiguration)configuration.clone();
- }
-
- public void setConfiguration(LogConfiguration config) {
if ( config != null ) {
logMessage(MessageLevel.INFO, LogCommonConstants.CTX_LOGGING, CommonPlugin.Util.getString("MSG.003.014.0015", config)); //$NON-NLS-1$
configuration = (LogConfiguration) config.clone();
}
- }
-
+ }
+
+ public static void setLogListener(LogListener listener) {
+ logListener.shutdown();
+ if (listener != null) {
+ logListener = listener;
+ }
+ else {
+ logListener = new NullLogWriter();
+ }
+ }
+
/**
* Utility method to identify whether a log message with the specified
* context and level will be recorded in the LogManager's destinations.
@@ -425,42 +354,23 @@
* or false if it would be discarded by the LogManager.
*/
public static boolean isMessageToBeRecorded(String context, int msgLevel) {
- return getInstance().isLoggingEnabled(context, msgLevel);
+ return configuration.isMessageToBeRecorded(context, msgLevel);
}
-
- public boolean isLoggingEnabled(String context, int msgLevel) {
- if ( context == null ) {
- return false;
- }
-
- // If the messsage's level is greater than the logging level,
- // then the message should NOT be recorded ...
- if ( configuration.getMessageLevel() == MessageLevel.NONE || msgLevel <= MessageLevel.NONE ||
- configuration.isLevelDiscarded( msgLevel ) || configuration.isContextDiscarded( context )) {
- return false;
- }
- return true;
- }
-
- protected void logMessage(int level, String context, Object ... msgParts) {
+ private static void logMessage(int level, String context, Object ... msgParts) {
logMessage(level, context, null, msgParts);
}
- protected void logMessage(int level, String context, Throwable e, Object ... msgParts) {
- if (msgParts == null || msgParts.length == 0 || !isLoggingEnabled(context, level)) {
+ private static void logMessage(int level, String context, Throwable e, Object ... msgParts) {
+ if (msgParts == null || msgParts.length == 0 || !isMessageToBeRecorded(context, level)) {
return;
}
-
- LogMessage msg = new LogMessage( context, level, e, msgParts);
- forwardMessage(msg);
+
+ LogMessage msg = new LogMessage( context, level, e, msgParts);
+ logListener.logMessage(msg);
}
- protected void forwardMessage(LogMessage msg) {
- platformLog.logMessage(msg);
- }
-
public static Object createLoggingProxy(final String loggingContext,
final Object instance,
final Class[] interfaces,
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/log/config/BasicLogConfiguration.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/config/BasicLogConfiguration.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/config/BasicLogConfiguration.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -39,7 +39,7 @@
* LogConfiguration, plus static utility methods for converting a
* LogConfiguration object to and from a Properties object representation.
*/
-public class BasicLogConfiguration implements LogConfiguration, Serializable {
+public class BasicLogConfiguration implements LogConfiguration, Serializable, Cloneable {
//************************************************************
// static constants, members, methods
@@ -216,13 +216,12 @@
this.unmodifiableContexts = Collections.unmodifiableSet(this.discardedContexts);
}
- public boolean isContextDiscarded( String context ) {
- boolean discarded = ((context != null) &&
- this.discardedContexts.contains(context));
+ boolean isContextDiscarded( String context ) {
+ boolean discarded = ((context != null) && this.discardedContexts.contains(context));
return discarded;
}
- public boolean isLevelDiscarded( int level ) {
+ boolean isLevelDiscarded( int level ) {
return ( level > msgLevel );
}
@@ -406,4 +405,19 @@
public void setMessageLevel(int level) {
this.msgLevel = level;
}
+
+
+ @Override
+ public boolean isMessageToBeRecorded(String context, int msgLevel) {
+ if ( context == null ) {
+ return false;
+ }
+
+ // If the messsage's level is greater than the logging level,
+ // then the message should NOT be recorded ...
+ if ( getMessageLevel() == MessageLevel.NONE || msgLevel <= MessageLevel.NONE || isLevelDiscarded( msgLevel ) || isContextDiscarded( context )) {
+ return false;
+ }
+ return true;
+ }
}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/log/config/DefaultLogConfigurationFactory.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/config/DefaultLogConfigurationFactory.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/config/DefaultLogConfigurationFactory.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.log.config;
-
-
-
-public class DefaultLogConfigurationFactory implements LogConfigurationFactory {
-
- /**
- * The name of the System property that contains the set of comma-separated
- * context names for messages <i>not</i> to be recorded. A message context is simply
- * some string that identifies something about the component that generates
- * the message. The value for the contexts is application specific.
- * <p>
- * This is an optional property that defaults to no contexts (i.e., messages
- * with any context are recorded).
- */
- public static final String LOG_CONTEXT_PROPERTY_NAME = "metamatrix.log.contexts"; //$NON-NLS-1$
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/log/config/LogConfigurationFactory.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/config/LogConfigurationFactory.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/config/LogConfigurationFactory.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,29 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.log.config;
-
-
-
-public interface LogConfigurationFactory {
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/log/format/DelimitedLogMessageFormat.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/format/DelimitedLogMessageFormat.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/format/DelimitedLogMessageFormat.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.log.format;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import com.metamatrix.core.log.LogMessage;
-import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.core.util.MetaMatrixExceptionUtil;
-import com.metamatrix.core.util.StringUtil;
-
-/**
- * This class formats LogMessages using a format with delimiters that is easily parsed.
- * The format is:
- * <p><pre>
- * yyyy.MM.dd HH:mm:ss
- * </pre></p>
- * For example, <pre>"1952.01.12 13:30:32"</pre>.
- */
-public class DelimitedLogMessageFormat implements LogMessageFormat {
- public static final String TIMESTAMP_FORMAT = "yyyy.MM.dd HH:mm:ss.SSS"; //$NON-NLS-1$
-
-
- // Cache date formatter which is expensive to create
- private static DateFormat DATE_FORMATTER = new SimpleDateFormat(TIMESTAMP_FORMAT);
- private static final String DEFAULT_FORMATTED_MESSAGE = ""; //$NON-NLS-1$
-// private static final String DELIMITER_STRING = "|";
- private static final char DELIMITER_CHAR = '|';
-
- /**
- * Format the specified message and return the String representation.
- * @param message the log message to be formated.
- * @return the String representation of the log message.
- */
- public String formatMessage( LogMessage message ) {
- if ( message == null ) {
- return DEFAULT_FORMATTED_MESSAGE;
- }
- StringBuffer msg = new StringBuffer();
- msg.append( DATE_FORMATTER.format( new Date(message.getTimestamp()) ) );
- msg.append( DELIMITER_CHAR );
- msg.append( message.getHostName() );
- msg.append( DELIMITER_CHAR );
- msg.append( message.getVMName() );
- msg.append( DELIMITER_CHAR );
- msg.append( message.getThreadName() );
- msg.append( DELIMITER_CHAR );
- msg.append( message.getContext() );
- msg.append( DELIMITER_CHAR );
- msg.append( MessageLevel.getLabelForLevel(message.getLevel()) );
- msg.append( DELIMITER_CHAR );
- msg.append( message.getText() );
-
- Throwable e = message.getException();
- if ( e != null) {
- StringWriter strWriter = new StringWriter();
- PrintWriter strPrinter = new PrintWriter(strWriter, true);
-
- // Get the stack trace into a string writer we can access
- e.printStackTrace(strPrinter);
- msg.append(StringUtil.getLineSeparator());
- msg.append(strWriter);
-
- java.util.Iterator children = MetaMatrixExceptionUtil.getChildrenIterator(e);
- while (children.hasNext()){
- e = (Throwable)children.next();
- strWriter = new StringWriter();
- strPrinter = new PrintWriter(strWriter, true);
- e.printStackTrace(strPrinter);
- msg.append(StringUtil.getLineSeparator());
- msg.append(strWriter);
- }
-
- }
-
- return msg.toString();
- }
-
-}
Deleted: trunk/common-internal/src/main/java/com/metamatrix/common/log/format/LogMessageFormat.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/log/format/LogMessageFormat.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/log/format/LogMessageFormat.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.log.format;
-
-import com.metamatrix.core.log.LogMessage;
-
-public interface LogMessageFormat {
-
- /**
- * Format the specified message and return the String representation.
- * @param message the log message to be formated.
- * @return the String representation of the log message.
- */
- public String formatMessage( LogMessage message );
-}
Modified: trunk/common-internal/src/test/java/com/metamatrix/common/log/TestLogManager.java
===================================================================
--- trunk/common-internal/src/test/java/com/metamatrix/common/log/TestLogManager.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-internal/src/test/java/com/metamatrix/common/log/TestLogManager.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -28,6 +28,7 @@
import junit.framework.TestCase;
+import com.metamatrix.common.log.config.BasicLogConfiguration;
import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.log.LogMessage;
import com.metamatrix.core.log.MessageLevel;
@@ -46,6 +47,13 @@
super(name);
}
+ @Override
+ protected void setUp() throws Exception {
+ LogManager.configuration = new BasicLogConfiguration();
+ LogManager.logListener = new PlatformLog();
+
+ }
+
// =========================================================================
// T E S T C A S E S
// =========================================================================
@@ -55,26 +63,26 @@
*/
public void testIsMessageToBeRecordedStringI() {
String context = "SomeContext"; //$NON-NLS-1$
- LogManager manager = new LogManager(null);
- assertTrue(manager.isLoggingEnabled(context, MessageLevel.CRITICAL) );
- LogConfiguration cfg = LogManager.getInstance().getConfigurationCopy();
+
+ assertTrue(LogManager.isMessageToBeRecorded(context, MessageLevel.CRITICAL) );
+
+ LogConfiguration cfg = LogManager.getLogConfigurationCopy();
cfg.discardContext(context);
- manager.setConfiguration(cfg);
- assertFalse(manager.isLoggingEnabled(context, MessageLevel.CRITICAL) );
+ LogManager.setLogConfiguration(cfg);
+ assertFalse(LogManager.isMessageToBeRecorded(context, MessageLevel.CRITICAL) );
}
/**
* Test that all msgs logged are equal and output in same order.
*/
public void testLogMessage() throws Exception {
- PlatformLog log = new PlatformLog();
- LogManager manager = new LogManager(log);
- LogConfiguration cfg = manager.getConfigurationCopy();
+
+ LogConfiguration cfg = LogManager.getLogConfigurationCopy();
cfg.setMessageLevel( MessageLevel.INFO );
- manager.setConfiguration(cfg);
-
+ LogManager.setLogConfiguration(cfg);
+
ListLogger listener = new ListLogger(6);
- log.addListener(listener);
+ LogManager.logListener = listener;
List<String> sentMsgList = new ArrayList<String>();
sentMsgList.add("A message 1"); //$NON-NLS-1$
@@ -86,12 +94,11 @@
for (Iterator iter = sentMsgList.iterator(); iter.hasNext();) {
String msg = (String) iter.next();
- manager.logMessage(MessageLevel.INFO, "SomeContext", msg); //$NON-NLS-1$
+ LogManager.logInfo("SomeContext", msg); //$NON-NLS-1$
}
List recevedMsgList = listener.getLoggedMessages();
assertEquals(sentMsgList, recevedMsgList);
- log.shutdown();
}
/**
@@ -139,4 +146,6 @@
}
+
+
}
Deleted: trunk/common-internal/src/test/java/com/metamatrix/common/log/format/TestLogMessageFormat.java
===================================================================
--- trunk/common-internal/src/test/java/com/metamatrix/common/log/format/TestLogMessageFormat.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/common-internal/src/test/java/com/metamatrix/common/log/format/TestLogMessageFormat.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.log.format;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.log.LogMessage;
-
-/**
- *
- */
-public class TestLogMessageFormat extends TestCase {
-
- // ################################## FRAMEWORK ################################
-
- public TestLogMessageFormat(String name) {
- super(name);
- }
-
- // ################################## TEST HELPERS ################################
-
- private static Throwable generateThrowable(){
- Exception e2 = new Exception("Test0"); //$NON-NLS-1$
- MetaMatrixException e = new ComponentNotFoundException(e2, "Test1"); //$NON-NLS-1$
- //e = new MetaMatrixException(e, "Test2");
- MetaMatrixRuntimeException ee = new MetaMatrixRuntimeException(e, "Test3"); //$NON-NLS-1$
- e = new MetaMatrixProcessingException(ee, "Test4"); //$NON-NLS-1$
- return e;
- }
-
- private static LogMessageFormat getLogMessageFormat(){
-// return new ReadableLogMessageFormat();
- return new DelimitedLogMessageFormat();
- }
-
- // ################################## ACTUAL TESTS ################################
-
- /**
- */
- public void testLogFormat(){
- String context = "FAKE_CONTEXT"; //$NON-NLS-1$
- int level = 2;
- Throwable e = generateThrowable();
- Object[] msgParts = new Object[]{ "This is a fake log message for testing."}; //$NON-NLS-1$
- LogMessage logMessage = new LogMessage(context, level, e, msgParts);
- LogMessageFormat format = getLogMessageFormat();
-
- String firstLine = format.formatMessage(logMessage).split("\\n")[0]; //$NON-NLS-1$
- assertTrue(firstLine.endsWith("|HostName|VMName|main|FAKE_CONTEXT|ERROR|This is a fake log message for testing.")); //$NON-NLS-1$
- }
-
-}
Modified: trunk/connector-sdk/src/main/java/com/metamatrix/core/commandshell/CommandShell.java
===================================================================
--- trunk/connector-sdk/src/main/java/com/metamatrix/core/commandshell/CommandShell.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/connector-sdk/src/main/java/com/metamatrix/core/commandshell/CommandShell.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -36,6 +36,7 @@
import java.util.Set;
import java.util.Stack;
+import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.CorePlugin;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.FileLogWriter;
@@ -146,25 +147,13 @@
private void redirectLogging() {
- //get the java System property: redirect if "false", not if "true" or null
- String logConsoleString = System.getProperty(PROPERTY_LOG_CONSOLE);
- String FALSE = Boolean.toString(false);
- boolean redirect = FALSE.equalsIgnoreCase(logConsoleString);
-
- if (redirect) {
- //remove the listener that writes to System.out and System.err
- Collection listeners = PlatformLog.getInstance().getLogListeners();
- for (Iterator it = listeners.iterator(); it.hasNext();) {
- LogListener ll = (LogListener) it.next();
- if (ll instanceof SystemLogWriter) {
- PlatformLog.getInstance().removeListener(ll);
- }
- }
-
- //add a listener that writes to a file
- File file = new File(DEFAULT_LOG_FILE);
- PlatformLog.getInstance().addListener(new FileLogWriter(file));
- }
+ //add a listener that writes to a file
+ File file = new File(DEFAULT_LOG_FILE);
+ FileLogWriter flw = new FileLogWriter(file);
+
+ PlatformLog logger = new PlatformLog();
+ logger.addListener(flw);
+ LogManager.setLogListener(logger);
}
Modified: trunk/console/src/main/java/com/metamatrix/console/main/AdminConsoleMain.java
===================================================================
--- trunk/console/src/main/java/com/metamatrix/console/main/AdminConsoleMain.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/console/src/main/java/com/metamatrix/console/main/AdminConsoleMain.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -254,7 +254,9 @@
System.setErr(log);
}
FileLogWriter flw = new FileLogWriter(tmpFile);
- PlatformLog.getInstance().addListener(flw);
+ PlatformLog logger = new PlatformLog();
+ logger.addListener(flw);
+ LogManager.setLogListener(logger);
} catch (Exception ex) {
ex.printStackTrace();
}
Deleted: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedManager.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedManager.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedManager.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,148 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- * Date: Jun 24, 2003
- * Time: 1:13:49 PM
- */
-package com.metamatrix.dqp.embedded;
-
-import java.net.URL;
-import java.util.Date;
-import java.util.Properties;
-
-import com.metamatrix.common.application.DQPConfigSource;
-import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.dqp.internal.process.DQPCore;
-import com.metamatrix.dqp.service.ConfigurationService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-
-/**
- * Manages the life cycle of the embedded DQP. Like handling the creation and deletion
- * of the DQP. Knows about configuration elements and connection management to the
- * Embedded DQP. All direct operations to the DQP must go though the manager object
- * (other than what goes on Connection object requests), there should not be any
- * referecnes to DQP instance directly manuplulating the API. If such case arises
- * implement as methods on DQP interface.
- */
-public class DQPEmbeddedManager {
-
- private DQPConfigSource configSource;
- private DQPCore dqpInstance;
- private long dqpStarttime = -1;
- DQPListener dqpListener = null;
-
- /**
- * Construct DQPEmbeddedManager.
- */
- public DQPEmbeddedManager(URL dqpURL, Properties connectionProperties, DQPListener listener) throws ApplicationInitializationException {
- this.configSource = new EmbeddedConfigSource(dqpURL, connectionProperties);
- this.dqpListener = listener;
- }
-
- /**
- * Main access method to DQP. Will either find the DQP or
- * start and initialize as necessary.
- * @return The DQP to use.
- * @throws ApplicationInitializationException when an error occurs
- * during DQP initialization.
- */
- public synchronized DQPCore createDQP() throws ApplicationInitializationException {
- if ( dqpInstance == null ) {
- dqpInstance = new DQPCore();
- dqpInstance.start(configSource);
- dqpStarttime = System.currentTimeMillis();
- DQPEmbeddedPlugin.logInfo("DQPEmbeddedManager.start_dqp", new Object[] {new Date(System.currentTimeMillis()).toString()}); //$NON-NLS-1$
-
- // Notify the listener that DQP started
- if (dqpListener != null) {
- dqpListener.onStart();
- }
- }
- return dqpInstance;
- }
-
- /**
- * Get the DQP instance holded by this manager
- * @return DQP instance if has been created;null otherwise
- */
- public DQPCore getDQP() {
- return dqpInstance;
- }
-
- /**
- * Shutdown the DQP and its connections.
- * @throws ApplicationLifecycleException
- */
- public synchronized void shutdown() throws ApplicationLifecycleException {
- if (dqpInstance != null) {
-
- // stop the DQP
- dqpInstance.stop();
- dqpInstance = null;
- configSource = null;
- dqpStarttime = -1;
-
- // Notify the listener that DQP being stopped
- if (dqpListener != null) {
- dqpListener.onShutdown();
- dqpListener = null;
- }
-
- DQPEmbeddedPlugin.logInfo("DQPEmbeddedManager.shutdown_dqp", new Object[] {new Date(System.currentTimeMillis()).toString()}); //$NON-NLS-1$
-
- // shutdown the logger
- EmbeddedConfigUtil.shutdownLogger();
- }
- }
-
- /**
- * Returns the long defining the time in milliseconds when it started.
- * @return -1 if the DQP not started.
- * @since 4.3
- */
- public long getDQPStartTime() {
- return dqpStarttime;
- }
-
- /**
- * Check if the DQP has been started.
- * @return
- * @since 4.3
- */
- public boolean isDQPAlive() {
- return dqpInstance != null;
- }
-
- /**
- * Get the properties of the DQP.
- * @return null if the DQP not started. properties started with otherwise.
- * @since 4.3
- */
- public Properties getDQPProperties() {
- if (isDQPAlive()) {
- return ((ConfigurationService)dqpInstance.getEnvironment().findService(DQPServiceNames.CONFIGURATION_SERVICE)).getSystemProperties();
- }
- return null;
- }
-}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPEmbeddedProperties.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -28,10 +28,8 @@
public static final String DQP_LOGFILE = "dqp.logFile"; //$NON-NLS-1$
public static final String DQP_LOGLEVEL = "dqp.logLevel"; //$NON-NLS-1$
- public static final String DQP_CAPTURE_SYSTEM_PRINTSTREAMS = "dqp.captureSystemStreams"; //$NON-NLS-1$
public static final String DQP_SERVICE_METADATA = "dqp.service.metadata"; //$NON-NLS-1$
public static final String DQP_SERVICE_DATA = "dqp.service.data"; //$NON-NLS-1$
- public static final String DQP_CLASSPATH = "dqp.classpath"; //$NON-NLS-1$
public static final String DQP_EXTENSIONS = "dqp.extensions"; //$NON-NLS-1$
public static final String DQP_CONFIGFILE = "dqp.configFile"; //$NON-NLS-1$
public static final String DQP_METADATA_SYSTEMURL = "dqp.metadata.systemURL"; //$NON-NLS-1$
Deleted: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPListener.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPListener.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/DQPListener.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.embedded;
-
-
-/**
- * When registered with the DQP manager, the registar wil notified about the
- * life cycle events of the DQP.
- * @since 4.3
- */
-public interface DQPListener {
- /**
- * This event gets notified as soon as the DQP is Started
- */
- void onStart();
-
- /**
- * Upon the shutdown of the dqp this method gets called
- */
- void onShutdown();
-}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigSource.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigSource.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigSource.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -24,19 +24,18 @@
import java.io.IOException;
import java.io.InputStream;
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import com.google.inject.Binder;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.application.DQPConfigSource;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.embedded.services.EmbeddedBufferService;
import com.metamatrix.dqp.embedded.services.EmbeddedConfigurationService;
import com.metamatrix.dqp.embedded.services.EmbeddedDataService;
@@ -45,16 +44,19 @@
import com.metamatrix.dqp.embedded.services.EmbeddedTransactionService;
import com.metamatrix.dqp.embedded.services.EmbeddedVDBService;
import com.metamatrix.dqp.service.DQPServiceNames;
+import com.metamatrix.jdbc.EmbeddedDataSource;
+import com.metamatrix.jdbc.JDBCPlugin;
/**
* This class is main hook point for the Embedded DQP configuration. This classe's
- * responsibility is to encapsulate the knowedge of creating of the various application
+ * responsibility is to encapsulate the knowledge of creating of the various application
* services used the DQP.
*
*/
public class EmbeddedConfigSource implements DQPConfigSource {
+ private static final String SERVER_CONFIG_FILE_EXTENSION = ".properties"; //$NON-NLS-1$
- private Properties props;
+ private Properties props;
private boolean useTxn;
/**
@@ -62,13 +64,24 @@
* @param configFile
* @throws ApplicationInitializationException
*/
- public EmbeddedConfigSource(URL dqpURL, Properties connectionProperties) throws ApplicationInitializationException {
+ public EmbeddedConfigSource(Properties connectionProperties) {
+
+ URL dqpURL = (URL)connectionProperties.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE);
+ if(dqpURL == null) {
+ throw new MetaMatrixRuntimeException(JDBCPlugin.Util.getString("LocalTransportHandler.No_configuration_file_set_in_property", DQPEmbeddedProperties.DQP_BOOTSTRAP_PROPERTIES_FILE)); //$NON-NLS-1$
+ }
+
+ String dqpFileName = dqpURL.toString().toLowerCase();
+ if (!dqpFileName.endsWith(SERVER_CONFIG_FILE_EXTENSION)) {
+ throw new MetaMatrixRuntimeException(JDBCPlugin.Util.getString("LocalTransportHandler.Invalid_config_file_extension", dqpFileName) ); //$NON-NLS-1$
+ }
+
String dqpURLString = dqpURL.toString();
try {
dqpURL = URLHelper.buildURL(dqpURLString);
InputStream in = dqpURL.openStream();
if (in == null) {
- throw new ApplicationInitializationException(DQPEmbeddedPlugin.Util.getString("EmbeddedConfigSource.Can_not_load_config_file_2", dqpURL)); //$NON-NLS-1$
+ throw new MetaMatrixRuntimeException(DQPEmbeddedPlugin.Util.getString("EmbeddedConfigSource.Can_not_load_config_file_2", dqpURL)); //$NON-NLS-1$
}
// Load the "dqp.properties" file.
@@ -95,12 +108,9 @@
// this path.
props.put(DQPEmbeddedProperties.DQP_BOOTSTRAP_PROPERTIES_FILE, dqpURL);
- // First configure logging..
- configureLogging(dqpURL);
-
useTxn = PropertiesUtils.getBooleanProperty(props, EmbeddedTransactionService.TRANSACTIONS_ENABLED, true);
} catch (IOException e) {
- throw new ApplicationInitializationException(e);
+ throw new MetaMatrixRuntimeException(e);
}
}
@@ -124,44 +134,6 @@
return this.props;
}
- /**
- * Configure the logging for the DQP
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- void configureLogging(URL dqpURL) throws ApplicationInitializationException{
- boolean captureSystemStreams = Boolean.valueOf(props.getProperty(DQPEmbeddedProperties.DQP_CAPTURE_SYSTEM_PRINTSTREAMS, "false")).booleanValue(); //$NON-NLS-1$
- String logLevel = props.getProperty(DQPEmbeddedProperties.DQP_LOGLEVEL);
- String logFile = props.getProperty(DQPEmbeddedProperties.DQP_LOGFILE);
- String classpath = props.getProperty(DQPEmbeddedProperties.DQP_CLASSPATH);
- boolean unifiedClassLoader = !(classpath != null && classpath.length()>0);
- String instanceId = props.getProperty(DQPEmbeddedProperties.DQP_IDENTITY);
-
- try {
- // Configure Logging
- try {
- if (logFile != null && !logFile.equalsIgnoreCase(EmbeddedConfigUtil.STDOUT)) {
- String modifiedLogFileName = logFile;
- int dotIndex = logFile.lastIndexOf('.');
- if (dotIndex != -1) {
- modifiedLogFileName = logFile.substring(0,dotIndex)+"_"+instanceId+"."+logFile.substring(dotIndex+1); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- modifiedLogFileName = logFile+"_"+instanceId; //$NON-NLS-1$
- }
- URL logURL = URLHelper.buildURL(dqpURL, modifiedLogFileName);
- logFile = logURL.getPath();
- }
- } catch (MalformedURLException e) {
- // we may have absolute source, this is just for notification to somewhere.
- e.printStackTrace();
- }
- EmbeddedConfigUtil.configureLogger(logFile, logLevel, captureSystemStreams, unifiedClassLoader);
- } catch (MetaMatrixComponentException e) {
- throw new ApplicationInitializationException(e);
- }
- }
-
@Override
public void updateBindings(Binder binder) {
Deleted: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigUtil.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigUtil.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/EmbeddedConfigUtil.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,186 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.embedded;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.log.LogConfiguration;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.log.config.BasicLogConfiguration;
-import com.metamatrix.core.log.FileLimitSizeLogWriter;
-import com.metamatrix.core.log.LogListener;
-import com.metamatrix.core.log.NullLogWriter;
-import com.metamatrix.core.log.SystemLogWriter;
-import com.metamatrix.internal.core.log.PlatformLog;
-
-/**
- * DQPConfigUtil
- */
-public class EmbeddedConfigUtil {
- static final String STDOUT = "STDOUT"; //$NON-NLS-1$
- private static Object lock = new Object();
- private static int count = 0;
-
- static {
- System.setProperty("shutdownHookInstalled", String.valueOf(Boolean.TRUE)); //$NON-NLS-1$
- }
-
- private EmbeddedConfigUtil() {
- }
-
- /**
- * Set the log level to tehe specified level
- * @param logLevel the new log level
- * @throws MetaMatrixComponentException if the logLevel String cannot be parsed as an integer
- * @since 4.3
- */
- public static void setLogLevel(String logLevel) throws MetaMatrixComponentException {
- // Set up log level (default to none)
- int level = 0;
- if(logLevel != null && logLevel.trim().length() > 0) {
- try {
- level = Integer.parseInt(logLevel);
- } catch(NumberFormatException e) {
- throw new MetaMatrixComponentException(DQPEmbeddedPlugin.Util.getString("DQPComponent.Unable_to_parse_level") + logLevel); //$NON-NLS-1$
- }
- }
- LogConfiguration config = LogManager.getLogConfigurationCopy();
- config.setMessageLevel(level);
- LogManager.setLogConfiguration(config);
- LogManager.logInfo("DQP", "LogManager configured with level = " + level); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Replaces the old set of discarded contexts with those provided.
- * @param contexts the new set of contexts to be discarded.
- * @since 4.3
- */
- public static void setDiscardedContexts(Collection contexts) {
- LogManager.setLogConfiguration(new BasicLogConfiguration(contexts, LogManager.getLogConfigurationCopy().getMessageLevel()));
- LogManager.logInfo("DQP", "LogManager discarded contexts " + contexts); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Installs a new log listener for the DQP, if a log listener of the same type does not already exist.
- * @param newListener The LogListener to be installed
- * @throws MetaMatrixComponentException
- * @since 4.3
- */
- public static void installLogListener(LogListener newListener) throws MetaMatrixComponentException {
- if (newListener == null) {
- // Make no changes to the current listeners
- return;
- }
-
- PlatformLog log = PlatformLog.getInstance();
- List listeners = new ArrayList(log.getLogListeners());
- if (listeners.size() == 1 && listeners.get(0).getClass().equals(newListener.getClass())) {
- // if the platform log writer is already established, dont do anything else
- return;
- }
-
- // remove all existing listeners from the platform logger - we will add one back later if needed
- removeListeners(listeners);
-
- // Set up log listener
- log.addListener(newListener);
- }
-
- private static void removeListeners(List listeners) {
- // Walk through the listeners and remove them
- for(int i=0; i<listeners.size(); i++) {
- PlatformLog.getInstance().removeListener((LogListener)listeners.get(i));
- }
- }
-
- /**
- * Configures the PlatformLog to work correctly with the DQP. The
- * PlatformLog is configured to NOT log to System.out (as this is frowned upon
- * in a user's environment). If a logFile and logLevel are specified,
- * a file log is configured and LogManager is set up to pay attention to the
- * log level.
- *
- * @param logFile Log file name or null if no logging should occur
- * @param logLevel Log level or null for default level
- */
- public static void configureLogger(String logFile, String logLevel, boolean captureSystemStreams, boolean useSingleLogger)
- throws MetaMatrixComponentException {
-
- PlatformLog log = PlatformLog.getInstance();
- List previousListeners = new ArrayList(log.getLogListeners());
- if (previousListeners.size() == 0 || !useSingleLogger) {
- if(logFile != null && logFile.trim().length() > 0) {
- if (logFile.equalsIgnoreCase(STDOUT)) {
- SystemLogWriter logWriter = new SystemLogWriter();
- installLogListener(logWriter);
- }
- else {
- File file = new File(logFile);
- FileLimitSizeLogWriter logWriter = new FileLimitSizeLogWriter(file, captureSystemStreams);
- installLogListener(logWriter);
- }
- } else {
- // Pass a safe copy of listeners to be removed.
- removeListeners(previousListeners);
- NullLogWriter logNull = new NullLogWriter();
- installLogListener(logNull);
- }
-
- // now set the log level
- if(logLevel != null) {
- setLogLevel(logLevel);
- }else {
- setLogLevel("3"); //$NON-NLS-1$
- }
- }
- // Increment counter to keep count of number of DQPs which are using this
- // logger object. In the case of unifiedClassLoader we would like to have
- // single logger.
- synchronized(lock) {
- count++;
- }
- }
-
- /**
- *
- * @since 4.3
- */
- public static void shutdownLogger() {
- // decrement the counter and when it reaches zero then only shutdown the logger
- // becuase in the case of the unified class laoder we have only one logger and we
- // would like to close at the end of last dqp shutdown.
- synchronized(lock) {
- count--;
- }
-
- if (count == 0) {
- PlatformLog.getInstance().shutdown(false);
- PlatformLog.getInstance().start();
- //LogManager.stop();
- }
- }
-}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -62,12 +62,12 @@
import com.metamatrix.common.util.crypto.CryptoException;
import com.metamatrix.common.util.crypto.CryptoUtil;
import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.dqp.embedded.DQPEmbeddedManager;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.DataService;
import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
import com.metamatrix.platform.util.ProductInfoConstants;
import com.metamatrix.server.serverapi.RequestInfo;
@@ -96,9 +96,9 @@
Cache.QUERY_SERVICE_RESULT_SET_CACHE
};
- DQPEmbeddedManager manager = null;
+ EmbeddedConnectionFactoryImpl manager = null;
- BaseAdmin(DQPEmbeddedManager manager){
+ BaseAdmin(EmbeddedConnectionFactoryImpl manager){
this.manager = manager;
}
@@ -135,20 +135,20 @@
* @return Returns the manager.
* @since 4.3
*/
- public DQPEmbeddedManager getManager() {
+ public EmbeddedConnectionFactoryImpl getManager() {
return this.manager;
}
VDBService getVDBService() {
- return (VDBService)getManager().getDQP().getEnvironment().findService(DQPServiceNames.VDB_SERVICE);
+ return (VDBService)getManager().findService(DQPServiceNames.VDB_SERVICE);
}
DataService getDataService() {
- return (DataService)getManager().getDQP().getEnvironment().findService(DQPServiceNames.DATA_SERVICE);
+ return (DataService)getManager().findService(DQPServiceNames.DATA_SERVICE);
}
ConfigurationService getConfigurationService() {
- return (ConfigurationService)getManager().getDQP().getEnvironment().findService(DQPServiceNames.CONFIGURATION_SERVICE);
+ return (ConfigurationService)getManager().findService(DQPServiceNames.CONFIGURATION_SERVICE);
}
protected Object convertToAdminObjects(Object src) {
@@ -511,9 +511,9 @@
*/
public SystemObject getSystem() {
MMSystem system = new MMSystem();
- system.setStartTime(new Date(manager.getDQPStartTime()));
- system.setStarted(manager.isDQPAlive());
- system.setProperties(manager.getDQPProperties());
+ system.setStartTime(new Date(manager.getStartTime()));
+ system.setStarted(manager.isAlive());
+ system.setProperties(manager.getProperties());
return system;
}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -59,7 +59,6 @@
import com.metamatrix.common.vdb.api.VDBArchive;
import com.metamatrix.common.vdb.api.VDBDefn;
import com.metamatrix.core.vdb.VDBStatus;
-import com.metamatrix.dqp.embedded.DQPEmbeddedManager;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.embedded.configuration.ConnectorConfigurationReader;
@@ -67,6 +66,7 @@
import com.metamatrix.dqp.embedded.configuration.ServerConfigFileWriter;
import com.metamatrix.dqp.embedded.configuration.VDBConfigurationReader;
import com.metamatrix.dqp.service.ConfigurationService;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
/**
@@ -75,7 +75,7 @@
*/
public class DQPConfigAdminImpl extends BaseAdmin implements EmbeddedConfigAdmin {
- public DQPConfigAdminImpl(DQPEmbeddedManager manager) {
+ public DQPConfigAdminImpl(EmbeddedConnectionFactoryImpl manager) {
super(manager);
}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -44,8 +44,8 @@
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.dqp.embedded.DQPEmbeddedManager;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
import com.metamatrix.server.serverapi.RequestInfo;
@@ -55,7 +55,7 @@
*/
public class DQPMonitoringAdminImpl extends BaseAdmin implements EmbeddedMonitoringAdmin {
- public DQPMonitoringAdminImpl(DQPEmbeddedManager manager) {
+ public DQPMonitoringAdminImpl(EmbeddedConnectionFactoryImpl manager) {
super(manager);
}
@@ -328,7 +328,7 @@
switch(type) {
case MMAdminObject.OBJECT_TYPE_SYSTEM_OBJECT:
- Properties properties = manager.getDQPProperties();
+ Properties properties = manager.getProperties();
return convertPropertyDefinitions(properties);
case MMAdminObject.OBJECT_TYPE_CONNECTOR_BINDING:
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -22,6 +22,7 @@
package com.metamatrix.dqp.embedded.admin;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -40,10 +41,10 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.dqp.embedded.DQPEmbeddedManager;
+import com.metamatrix.common.log.LogManager;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.embedded.EmbeddedConfigUtil;
import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
/**
@@ -51,7 +52,7 @@
*/
public class DQPRuntimeStateAdminImpl extends BaseAdmin implements EmbeddedRuntimeStateAdmin {
- public DQPRuntimeStateAdminImpl(DQPEmbeddedManager manager) {
+ public DQPRuntimeStateAdminImpl(EmbeddedConnectionFactoryImpl manager) {
super(manager);
}
@@ -66,7 +67,7 @@
terminateSession(AdminObject.WILDCARD);
getManager().shutdown();
- } catch (ApplicationLifecycleException e) {
+ } catch (SQLException e) {
throw new AdminComponentException(e);
}
}
@@ -83,7 +84,7 @@
// Now shutdown the DQP, it will automatically start next timea new connection is
// requested.
getManager().shutdown();
- } catch (ApplicationLifecycleException e) {
+ } catch (SQLException e) {
throw new AdminComponentException(e);
}
}
@@ -211,21 +212,17 @@
public void terminateSession(String identifier)
throws AdminException {
- if (identifier == null || (!identifier.equals(AdminObject.WILDCARD) && !identifier.matches("\\d+"))) { //$NON-NLS-1$
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
-
Set<ServerConnection> connections = getClientConnections();
ArrayList matchedConnections = new ArrayList();
- for (Iterator i = connections.iterator(); i.hasNext();) {
- ServerConnection clientConnection = (ServerConnection)i.next();
+
+ for (ServerConnection clientConnection:connections) {
String id = clientConnection.getLogonResult().getSessionID().toString();
if (matches(identifier, id)) {
matchedConnections.add(clientConnection);
}
}
- // Double iteration because to avoid concurrent modification of underlaying map.
+ // Double iteration because to avoid concurrent modification of underlying map.
for (Iterator i = matchedConnections.iterator(); i.hasNext();) {
ServerConnection clientConnection = (ServerConnection)i.next();
@@ -323,11 +320,7 @@
public void setLogListener(EmbeddedLogger listener)
throws AdminException {
if(listener != null) {
- try{
- EmbeddedConfigUtil.installLogListener(new DQPLogListener(listener));
- }catch(MetaMatrixComponentException e) {
- throw new AdminProcessingException(e);
- }
+ LogManager.setLogListener(new DQPLogListener(listener));
}
else {
throw new AdminProcessingException("Admin_invalid_log_listener"); //$NON-NLS-1$
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -23,7 +23,7 @@
package com.metamatrix.dqp.embedded.admin;
import com.metamatrix.admin.api.embedded.EmbeddedSecurityAdmin;
-import com.metamatrix.dqp.embedded.DQPEmbeddedManager;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
/**
@@ -31,7 +31,7 @@
*/
public class DQPSecurityAdminImpl extends BaseAdmin implements EmbeddedSecurityAdmin {
- public DQPSecurityAdminImpl(DQPEmbeddedManager manager) {
+ public DQPSecurityAdminImpl(EmbeddedConnectionFactoryImpl manager) {
super(manager);
}
}
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -43,6 +43,7 @@
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.api.ServerConnectionListener;
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ComponentTypeID;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
@@ -60,7 +61,6 @@
import com.metamatrix.common.vdb.api.VDBDefn;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.vdb.VDBStatus;
-import com.metamatrix.dqp.application.ClientConnectionListener;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.embedded.configuration.ExtensionModuleReader;
@@ -278,14 +278,6 @@
}
/**
- * @see com.metamatrix.dqp.service.ConfigurationService#getResetSystemStreams()
- * @since 4.3
- */
- public String captureSystemStreams() throws MetaMatrixComponentException {
- return userPreferences.getProperty(DQPEmbeddedProperties.DQP_CAPTURE_SYSTEM_PRINTSTREAMS);
- }
-
- /**
* @see com.metamatrix.dqp.service.ConfigurationService#getVDBs()
* @since 4.3
*/
@@ -1267,8 +1259,8 @@
* @see com.metamatrix.dqp.service.ConfigurationService#getConnectionListener()
* @since 4.3.2
*/
- public ClientConnectionListener getConnectionListener() throws MetaMatrixComponentException {
- return new ClientConnectionListener() {
+ public ServerConnectionListener getConnectionListener() {
+ return new ServerConnectionListener() {
/**
* A Client Connection to DQP has been added
*/
@@ -1498,16 +1490,6 @@
return userPreferences.getProperty(DQPEmbeddedProperties.DQP_IDENTITY);
}
- /**
- * @see com.metamatrix.dqp.service.ConfigurationService#useUnifiedClassLoader()
- */
- public boolean useUnifiedClassLoader() {
- String val = userPreferences.getProperty(DQPEmbeddedProperties.DQP_CLASSPATH);
- if (val == null || val.length() == 0) {
- return true;
- }
- return false;
- }
public String getProcessorBatchSize() {
return userPreferences.getProperty(DQPEmbeddedProperties.BufferService.DQP_PROCESSOR_BATCH_SIZE, "2000"); //$NON-NLS-1$
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnection.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -35,7 +35,6 @@
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.admin.api.exception.AdminProcessingException;
import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.dqp.embedded.DQPEmbeddedManager;
import com.metamatrix.dqp.embedded.admin.DQPConfigAdminImpl;
import com.metamatrix.dqp.embedded.admin.DQPMonitoringAdminImpl;
import com.metamatrix.dqp.embedded.admin.DQPRuntimeStateAdminImpl;
@@ -55,26 +54,21 @@
// constant value giving product name
private final static String SERVER_NAME = "MetaMatrix Query"; //$NON-NLS-1$
- DQPEmbeddedManager manager = null;
+ EmbeddedConnectionFactoryImpl manager = null;
ConnectionListener listener = null;
- public static EmbeddedConnection newInstance(DQPEmbeddedManager manager, ServerConnection serverConn, Properties info, ConnectionListener listner) {
- return new EmbeddedConnection(manager, serverConn, info, listner);
- }
-
/**
* ctor
*/
- public EmbeddedConnection(DQPEmbeddedManager manager,
- ServerConnection serverConn,
- Properties info,
- ConnectionListener listner) {
+ public EmbeddedConnection(EmbeddedConnectionFactoryImpl manager, ServerConnection serverConn, Properties info, ConnectionListener listener) {
super(serverConn, info, null);
this.manager = manager;
- this.listener = listner;
+ this.listener = listener;
// tell the listener that connection has been created
- this.listener.connectionAdded(getConnectionId(), this);
+ if (listener != null) {
+ this.listener.connectionAdded(getConnectionId(), this);
+ }
}
/**
@@ -98,7 +92,7 @@
Exception ex = null;
// We we perform any DQP functions check if the DQP is still alive
- if (!manager.isDQPAlive()) {
+ if (!manager.isAlive()) {
throw new AdminProcessingException(JDBCPlugin.Util.getString("EmbeddedConnection.DQP_shutDown")); //$NON-NLS-1$
}
@@ -159,4 +153,12 @@
boolean isSameProcess(MMConnection conn) {
return (conn instanceof EmbeddedConnection);
}
+
+ @Override
+ public void close() throws SQLException {
+ if (this.listener != null) {
+ this.listener.connectionRemoved(getConnectionId(), this);
+ }
+ super.close();
+ }
}
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -23,9 +23,8 @@
package com.metamatrix.jdbc;
import java.sql.Connection;
-import java.sql.DriverManager;
import java.sql.SQLException;
-import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -34,15 +33,22 @@
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.application.ApplicationService;
+import com.metamatrix.common.application.DQPConfigSource;
+import com.metamatrix.common.application.exception.ApplicationInitializationException;
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.comm.api.ServerConnection;
-import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
+import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.vdb.api.VDBArchive;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.ResourceFinder;
-import com.metamatrix.dqp.application.ClientConnectionListener;
-import com.metamatrix.dqp.embedded.DQPListener;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.internal.process.DQPCore;
+import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.jdbc.transport.LocalTransportHandler;
@@ -55,46 +61,34 @@
private static final int ACTIVE = 3;
private boolean initialized = false;
private LocalTransportHandler handler = null;
- private boolean shutdownInProgress = false;
-
- // List of Connection Listeners for the DQP
- private ArrayList connectionListeners = new ArrayList();
-
+ private volatile boolean shutdownInProgress = false;
+ private DQPCore dqp;
+ private long starttime = -1L;
+ private Thread shutdownThread;
+
private EmbeddedConnectionListener listener = new EmbeddedConnectionListener();
- /**
- * Factory Constructor
- */
- static EmbeddedConnectionFactoryImpl newInstance() {
- return new EmbeddedConnectionFactoryImpl();
- }
-
/**
* @see com.metamatrix.jdbc.EmbeddedConnectionFactory#createConnection()
*/
public Connection createConnection(Properties props) throws SQLException {
- Injector injector = Guice.createInjector(new EmbeddedGuiceModule());
- ResourceFinder.setInjector(injector);
-
- // Initialize the transport
- initialize(props);
- try {
- // create a server connection. If the VDB_VERSION used as "UseLatest" the client
- // connection is based on String "UseLatest"
- this.handler.initManager(props);
- // check for the valid connection properties
+ try {
+ // Initialize the transport
+ initialize(props);
+
+ // check for the valid connection properties
checkConnectionProperties (props);
ServerConnection serverConn = this.handler.createConnection(props);
- // Should occur every time in classloader using existing attributes
- return EmbeddedConnection.newInstance(this.handler.getManager(), serverConn, props, listener);
+ // Should occur every time in class loader using existing attributes
+ return new EmbeddedConnection(this, serverConn, props, listener);
} catch (ConnectionException e) {
throw new EmbeddedSQLException(e);
- } catch (CommunicationException e) {
- throw new EmbeddedSQLException(e);
- }
+ } catch (ApplicationInitializationException e) {
+ throw new EmbeddedSQLException(e);
+ }
}
/**
@@ -106,40 +100,72 @@
* @throws SQLException
* @since 4.3
*/
- private void initialize(Properties props) throws SQLException {
- if (!initialized || !this.handler.isAlive()) {
+ private synchronized void initialize(Properties props) throws ApplicationInitializationException {
+ if (!initialized) {
- // This monitors the life cycle events for the DQP
- DQPListener dqpListener = new DQPListener() {
- public void onStart() {
- }
- public void onShutdown() {
- try {
- shutdown();
- }catch (SQLException e) {
- DriverManager.println(e.getMessage());
- }
- }
- };
+ Injector injector = Guice.createInjector(new EmbeddedGuiceModule(props));
+ ResourceFinder.setInjector(injector);
+ DQPConfigSource configSource = injector.getInstance(DQPConfigSource.class);
+
+ // start the DQP
+ this.dqp = new DQPCore();
+ this.dqp.start(configSource);
+
+ // make the configuration service listen for the connection life-cycle events
+ // used during VDB delete
+ ConfigurationService configService = (ConfigurationService)findService(DQPServiceNames.CONFIGURATION_SERVICE);
+
+ //in new class loader - all of these should be created lazily and held locally
+ this.handler = new LocalTransportHandler(this.dqp);
+ this.handler.registerListener(configService.getConnectionListener());
+ this.shutdownThread = new ShutdownWork();
+ Runtime.getRuntime().addShutdownHook(this.shutdownThread);
- // This monitors the lifecyle events for the connections inside a DQP
- // these are DQP side connections.
- ClientConnectionListener connectionListener = new ClientConnectionListener() {
- public void connectionAdded(ServerConnection connection) {
- }
- public void connectionRemoved(ServerConnection connection) {
- listener.connectionTerminated(connection.getLogonResult().getSessionID().toString());
- }
- };
-
- //in new classloader - all of these should be created lazily and held locally
- this.handler = new LocalTransportHandler(dqpListener, connectionListener);
- this.initialized = true;
+ this.initialized = true;
+ this.starttime = System.currentTimeMillis();
+ DQPEmbeddedPlugin.logInfo("DQPEmbeddedManager.start_dqp", new Object[] {new Date(System.currentTimeMillis()).toString()}); //$NON-NLS-1$
}
}
+
+ class ShutdownWork extends Thread {
+ ShutdownWork(){
+ super("embedded-shudown-thread"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void run() {
+ try {
+ shutdown(false);
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
+ }
+
+ public synchronized boolean isAlive() {
+ return (dqp != null);
+ }
+
+ public long getStartTime() {
+ return this.starttime;
+ }
+
+ public Properties getProperties() {
+ if (isAlive()) {
+ return ((ConfigurationService)findService(DQPServiceNames.CONFIGURATION_SERVICE)).getSystemProperties();
+ }
+ return null;
+ }
- public void registerConnectionListener(ConnectionListener listener) {
- connectionListeners.add(listener);
+ public synchronized DQPCore getDQP() {
+ if (!isAlive()) {
+ throw new MetaMatrixRuntimeException(JDBCPlugin.Util.getString("LocalTransportHandler.Transport_shutdown")); //$NON-NLS-1$
+ }
+ return this.dqp;
+ }
+
+ public ApplicationService findService(String type) {
+ return this.dqp.getEnvironment().findService(type);
}
/**
@@ -149,11 +175,20 @@
*
* @see com.metamatrix.jdbc.EmbeddedConnectionFactory#shutdown()
*/
- public void shutdown() throws SQLException{
+ public void shutdown() throws SQLException {
+ shutdown(true);
+ }
+
+ private void shutdown(boolean undoShutdownHook) throws SQLException {
+
+ if (undoShutdownHook) {
+ Runtime.getRuntime().removeShutdownHook(this.shutdownThread);
+ }
+
// Make sure shutdown is not already in progress; as call to shutdown will close
// connections; and after the last connection closes, the listener also calls shutdown
// for normal route.
- if (!shutdownInProgress) {
+ if (!this.shutdownInProgress && this.initialized) {
// this will by pass, and only let shutdown called once.
shutdownInProgress = true;
@@ -162,14 +197,25 @@
// connections are not properly closed; or somebody called shutdown.
listener.closeConnections();
- // then close the dqp handler it self, which root for the factory.
- this.handler.shutdown();
+ try {
+ this.dqp.stop();
+ } catch (ApplicationLifecycleException e) {
+ LogManager.logWarning(LogConstants.CTX_DQP, e, e.getMessage());
+ }
+ this.dqp = null;
+
+ this.handler = null;
+
+ this.initialized = false;
+
// shutdown the cache.
ResourceFinder.getCacheFactory().destroy();
- }
+
+ shutdownInProgress = false;
+ }
}
-
+
/**
* Are the connection properties supplied for connection match with those of the
* DQP
@@ -182,7 +228,7 @@
String vdbVersion = props.getProperty(BaseDataSource.VDB_VERSION, EmbeddedDataSource.USE_LATEST_VDB_VERSION);
try {
- VDBService service = (VDBService)handler.getManager().getDQP().getEnvironment().findService(DQPServiceNames.VDB_SERVICE);
+ VDBService service = (VDBService)findService(DQPServiceNames.VDB_SERVICE);
List<VDBArchive> vdbs = service.getAvailableVDBs();
// We are looking for the latest version find that now
@@ -226,29 +272,6 @@
}
/**
- * Notify all the connection listeners that a connection is added
- * @param connection
- */
- void notifyConnectionAdded(String id, Connection connection) {
- for (Iterator i = connectionListeners.iterator(); i.hasNext();) {
- ConnectionListener listner = (ConnectionListener)i.next();
- listner.connectionAdded(id, connection);
- }
- }
-
- /**
- * Notify all the connection listeners that a connection is added
- * @param connection
- */
- void notifyConnectionRemoved(String id, Connection connection) {
- for (Iterator i = connectionListeners.iterator(); i.hasNext();) {
- ConnectionListener listner = (ConnectionListener)i.next();
- listner.connectionRemoved(id, connection);
- }
- }
-
-
- /**
* A internal connection listener for the connections; based on this
* it manages the DQP instance. These are client side (JDBC) connections
*/
@@ -260,17 +283,11 @@
public void connectionAdded(String id, Connection connection) {
// Add the connection to locol count
connections.put(id, connection);
-
- // then also notify all the listeners
- notifyConnectionAdded(id, connection);
}
public void connectionRemoved(String id, Connection connection) {
// remove from local count
connections.remove(id);
-
- // also notify all the listeners
- notifyConnectionRemoved(id, connection);
}
/**
@@ -300,18 +317,6 @@
if (firstException != null) {
throw new EmbeddedSQLException(firstException);
}
- }
-
- /**
- * A hook which notifies the client connections that a server connection
- * has been terminated
- * @param connection
- */
- private void connectionTerminated(String id) {
- // remove from local count
- Connection connection = (Connection)connections.remove(id);
-
- notifyConnectionRemoved(id, connection);
- }
+ }
}
}
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,23 +1,64 @@
+/*
+ * 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 com.metamatrix.jdbc;
+import java.util.Properties;
+
import org.jboss.cache.Cache;
import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
import com.metamatrix.cache.CacheFactory;
import com.metamatrix.cache.jboss.JBossCacheFactory;
+import com.metamatrix.common.application.DQPConfigSource;
+import com.metamatrix.common.log.LogConfiguration;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.core.log.LogListener;
+import com.metamatrix.dqp.embedded.EmbeddedConfigSource;
public class EmbeddedGuiceModule extends AbstractModule {
-
+
+ private Properties props;
+
+ public EmbeddedGuiceModule(Properties props) {
+ this.props = props;
+ }
+
@Override
protected void configure() {
-
+
bind(Cache.class).toProvider(CacheProvider.class).in(Scopes.SINGLETON);
bind(CacheFactory.class).to(JBossCacheFactory.class).in(Scopes.SINGLETON);
+ bind(DQPConfigSource.class).toInstance(new EmbeddedConfigSource(this.props));
- // currently this is setup in embedded buffer service - needs to move in here.
- //bind(BufferManager.class).toProvider(BufferManagerProvider.class).in(Scopes.SINGLETON);
+ bind(LogConfiguration.class).toProvider(LogConfigurationProvider.class).in(Scopes.SINGLETON);
+ bind(LogListener.class).toProvider(LogListernerProvider.class).in(Scopes.SINGLETON);
+
+
+ // this needs to be removed.
+ binder().requestStaticInjection(LogManager.class);
}
+
}
Added: trunk/embedded/src/main/java/com/metamatrix/jdbc/LogConfigurationProvider.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/LogConfigurationProvider.java (rev 0)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/LogConfigurationProvider.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -0,0 +1,54 @@
+/*
+ * 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 com.metamatrix.jdbc;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import com.metamatrix.common.application.DQPConfigSource;
+import com.metamatrix.common.log.LogConfiguration;
+import com.metamatrix.common.log.config.BasicLogConfiguration;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
+
+@Singleton
+class LogConfigurationProvider implements Provider<LogConfiguration> {
+
+ @Inject
+ DQPConfigSource configSource;
+
+ @Override
+ public LogConfiguration get() {
+ String logLevel = configSource.getProperties().getProperty(DQPEmbeddedProperties.DQP_LOGLEVEL);
+ int level = 0;
+ if(logLevel != null && logLevel.trim().length() > 0) {
+ try {
+ level = Integer.parseInt(logLevel);
+ } catch(NumberFormatException e) {
+ throw new MetaMatrixRuntimeException(DQPEmbeddedPlugin.Util.getString("DQPComponent.Unable_to_parse_level") + logLevel); //$NON-NLS-1$
+ }
+ }
+ return new BasicLogConfiguration(level);
+ }
+
+}
Property changes on: trunk/embedded/src/main/java/com/metamatrix/jdbc/LogConfigurationProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java (rev 0)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -0,0 +1,89 @@
+/*
+ * 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 com.metamatrix.jdbc;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import com.metamatrix.common.application.DQPConfigSource;
+import com.metamatrix.common.protocol.URLHelper;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.log.FileLimitSizeLogWriter;
+import com.metamatrix.core.log.LogListener;
+import com.metamatrix.core.log.NullLogWriter;
+import com.metamatrix.core.log.SystemLogWriter;
+import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
+import com.metamatrix.internal.core.log.PlatformLog;
+
+@Singleton
+class LogListernerProvider implements Provider<LogListener> {
+ private static final String STDOUT = "STDOUT"; //$NON-NLS-1$
+
+ @Inject
+ DQPConfigSource configSource;
+
+ @Override
+ public LogListener get() {
+ URL dqpURL = (URL)configSource.getProperties().get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE);
+ String logFile = configSource.getProperties().getProperty(DQPEmbeddedProperties.DQP_LOGFILE);
+ String instanceId = configSource.getProperties().getProperty(DQPEmbeddedProperties.DQP_IDENTITY, "0"); //$NON-NLS-1$
+
+ // Configure Logging
+ try {
+ String dqpURLString = dqpURL.toString();
+ dqpURL = URLHelper.buildURL(dqpURLString);
+ if (logFile != null) {
+ if (logFile.equalsIgnoreCase(STDOUT)) {
+ PlatformLog log = new PlatformLog();
+ log.addListener(new SystemLogWriter());
+ return log;
+ }
+ else {
+ String modifiedLogFileName = logFile;
+ int dotIndex = logFile.lastIndexOf('.');
+ if (dotIndex != -1) {
+ modifiedLogFileName = logFile.substring(0,dotIndex)+"_"+instanceId+"."+logFile.substring(dotIndex+1); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ else {
+ modifiedLogFileName = logFile+"_"+instanceId; //$NON-NLS-1$
+ }
+ URL logURL = URLHelper.buildURL(dqpURL, modifiedLogFileName);
+ File file = new File(logURL.getPath());
+ PlatformLog log = new PlatformLog();
+ log.addListener(new FileLimitSizeLogWriter(file));
+ return log;
+ }
+ }
+ else {
+ return new NullLogWriter();
+ }
+ } catch (MalformedURLException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ }
+
+}
Property changes on: trunk/embedded/src/main/java/com/metamatrix/jdbc/LogListernerProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java (rev 0)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -0,0 +1,108 @@
+/*
+ * 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 com.metamatrix.jdbc.transport;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Properties;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.client.ExceptionUtil;
+import com.metamatrix.common.api.MMURL;
+import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.api.ServerConnectionListener;
+import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.internal.process.DQPWorkContext;
+import com.metamatrix.jdbc.JDBCPlugin;
+import com.metamatrix.platform.security.api.LogonResult;
+import com.metamatrix.platform.security.api.MetaMatrixSessionID;
+
+public class LocalServerConnection implements ServerConnection {
+
+ private final LogonResult result;
+ private boolean shutdown;
+ private DQPWorkContext workContext;
+ private ClientSideDQP dqp;
+ private ServerConnectionListener listener;
+
+ public LocalServerConnection(MetaMatrixSessionID sessionId, Properties connectionProperties, ClientSideDQP dqp, ServerConnectionListener listener) {
+ result = new LogonResult(sessionId, connectionProperties.getProperty(MMURL.CONNECTION.USER_NAME), connectionProperties, -1, "local"); //$NON-NLS-1$
+
+ //Initialize the workContext
+ workContext = new DQPWorkContext();
+ workContext.setSessionId(result.getSessionID());
+ workContext.setVdbName(connectionProperties.getProperty(MMURL.JDBC.VDB_NAME));
+ workContext.setVdbVersion(connectionProperties.getProperty(MMURL.JDBC.VDB_VERSION));
+ DQPWorkContext.setWorkContext(workContext);
+
+ this.dqp = dqp;
+ this.listener = listener;
+
+ if (this.listener != null) {
+ this.listener.connectionAdded(this);
+ }
+ }
+
+ public <T> T getService(Class<T> iface) {
+ if (iface != ClientSideDQP.class) {
+ throw new IllegalArgumentException("unknown service"); //$NON-NLS-1$
+ }
+ return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ClientSideDQP.class}, new InvocationHandler() {
+
+ public Object invoke(Object arg0, Method arg1, Object[] arg2)
+ throws Throwable {
+
+ if (!isOpen()) {
+ throw ExceptionUtil.convertException(arg1, new MetaMatrixComponentException(JDBCPlugin.Util.getString("LocalTransportHandler.session_inactive"))); //$NON-NLS-1$
+ }
+
+ DQPWorkContext.setWorkContext(workContext);
+ try {
+ return arg1.invoke(dqp, arg2);
+ } catch (InvocationTargetException e) {
+ throw e.getTargetException();
+ }
+ }
+ });
+ }
+
+ public boolean isOpen() {
+ return !shutdown;
+ }
+
+ public void shutdown() {
+ if (shutdown) {
+ return;
+ }
+ if (this.listener != null) {
+ this.listener.connectionRemoved(this);
+ }
+ this.shutdown = true;
+ }
+
+ public LogonResult getLogonResult() {
+ return result;
+ }
+}
Property changes on: trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalServerConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalTransportHandler.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalTransportHandler.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/java/com/metamatrix/jdbc/transport/LocalTransportHandler.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -22,204 +22,54 @@
package com.metamatrix.jdbc.transport;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.net.URL;
+import java.util.ArrayList;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicLong;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.client.ExceptionUtil;
-import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.comm.api.ServerConnection;
import com.metamatrix.common.comm.api.ServerConnectionFactory;
-import com.metamatrix.common.comm.exception.CommunicationException;
+import com.metamatrix.common.comm.api.ServerConnectionListener;
import com.metamatrix.common.comm.exception.ConnectionException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.application.ClientConnectionListener;
import com.metamatrix.dqp.client.ClientSideDQP;
-import com.metamatrix.dqp.embedded.DQPEmbeddedManager;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.embedded.DQPListener;
-import com.metamatrix.dqp.internal.process.DQPWorkContext;
-import com.metamatrix.dqp.service.ConfigurationService;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.jdbc.EmbeddedDataSource;
-import com.metamatrix.jdbc.JDBCPlugin;
-import com.metamatrix.platform.security.api.LogonResult;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
public class LocalTransportHandler implements ServerConnectionFactory {
-
- private final class LocalServerConnection implements ServerConnection {
- private final LogonResult result;
- private boolean shutdown;
- private DQPWorkContext workContext;
-
- private LocalServerConnection(Properties connectionProperties) {
- result = new LogonResult(new MetaMatrixSessionID(SESSION_ID
- .getAndIncrement()), connectionProperties
- .getProperty(MMURL.CONNECTION.USER_NAME), connectionProperties, -1, "local"); //$NON-NLS-1$
-
- //Initialize the workContext
- workContext = new DQPWorkContext();
- workContext.setSessionId(result.getSessionID());
- workContext.setVdbName(connectionProperties.getProperty(MMURL.JDBC.VDB_NAME));
- workContext.setVdbVersion(connectionProperties.getProperty(MMURL.JDBC.VDB_VERSION));
- DQPWorkContext.setWorkContext(workContext);
- if (configurationConnectionListener != null) {
- configurationConnectionListener.connectionAdded(this);
- }
- }
-
- public <T> T getService(Class<T> iface) {
- if (iface != ClientSideDQP.class) {
- throw new IllegalArgumentException("unknown service"); //$NON-NLS-1$
- }
- final ClientSideDQP dqp = getManager().getDQP();
- return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ClientSideDQP.class}, new InvocationHandler() {
-
- public Object invoke(Object arg0, Method arg1, Object[] arg2)
- throws Throwable {
-
- if (!isOpen()) {
- throw ExceptionUtil.convertException(arg1, new MetaMatrixComponentException(JDBCPlugin.Util.getString("LocalTransportHandler.session_inactive"))); //$NON-NLS-1$
- }
-
- DQPWorkContext.setWorkContext(workContext);
- try {
- return arg1.invoke(dqp, arg2);
- } catch (InvocationTargetException e) {
- throw e.getTargetException();
- }
- }
- });
- }
-
- public boolean isOpen() {
- return !shutdown && isAlive();
- }
-
- public void shutdown() {
- if (shutdown) {
- return;
- }
- if (configurationConnectionListener != null) {
- configurationConnectionListener.connectionRemoved(this);
- }
- if (connectionListener != null) {
- connectionListener.connectionRemoved(this);
- }
- this.shutdown = true;
- }
-
- public LogonResult getLogonResult() {
- return result;
- }
- }
-
- private static final String SERVER_CONFIG_FILE_EXTENSION = ".properties"; //$NON-NLS-1$
private AtomicLong SESSION_ID = new AtomicLong(1);
- private ClientConnectionListener configurationConnectionListener;
- private DQPEmbeddedManager dqpManager;
- private DQPListener dqpListener = null;
- private ClientConnectionListener connectionListener = null;
+ private ConnectionListenerList listenerList = new ConnectionListenerList();
+ private ClientSideDQP dqp;
- // Keeps track of whether this transport has been shutdown.
- // After it is shutdown connections may still have a reference to it.
- private boolean alive = true;
-
- public LocalTransportHandler() {
- this(null,null);
- }
-
/**
* Default constructor - used by reflection to create a new instance.
*/
- public LocalTransportHandler(DQPListener dqpListener, ClientConnectionListener connListener) {
- this.dqpListener = dqpListener;
- this.connectionListener = connListener;
+ public LocalTransportHandler(ClientSideDQP dqp) throws ApplicationInitializationException {
+ this.dqp = dqp;
}
- public synchronized boolean isAlive() {
- return alive && (dqpManager != null && dqpManager.isDQPAlive());
- }
-
- private void checkAlive() {
- if (!isAlive()) {
- throw new MetaMatrixRuntimeException(JDBCPlugin.Util.getString("LocalTransportHandler.Transport_shutdown")); //$NON-NLS-1$
- }
- }
-
- private synchronized void initManager(URL dqpURL, Properties connProperties) throws ApplicationInitializationException {
- if(dqpManager != null) {
- return;
- }
-
- if(dqpURL == null) {
- throw new ApplicationInitializationException(JDBCPlugin.Util.getString("LocalTransportHandler.No_configuration_file_set_in_property", DQPEmbeddedProperties.DQP_BOOTSTRAP_PROPERTIES_FILE)); //$NON-NLS-1$
- }
+ public ServerConnection createConnection(final Properties connectionProperties) throws ConnectionException {
+ return new LocalServerConnection(new MetaMatrixSessionID(SESSION_ID.getAndIncrement()), connectionProperties, dqp, listenerList);
+ }
- String dqpFileName = dqpURL.toString().toLowerCase();
- if (!dqpFileName.endsWith(SERVER_CONFIG_FILE_EXTENSION)) {
- throw new ApplicationInitializationException(JDBCPlugin.Util.getString("LocalTransportHandler.Invalid_config_file_extension", dqpFileName) ); //$NON-NLS-1$
- }
-
- dqpManager = new DQPEmbeddedManager(dqpURL, connProperties, this.dqpListener);
- dqpManager.createDQP();
- ConfigurationService configService = (ConfigurationService)dqpManager.getDQP().getEnvironment().findService(DQPServiceNames.CONFIGURATION_SERVICE);
- if (configService != null) {
- try {
- configurationConnectionListener = configService.getConnectionListener();
- }catch(MetaMatrixComponentException e) {
- configurationConnectionListener = null;
- }
- }
- }
+ public synchronized void registerListener(ServerConnectionListener listener) {
+ this.listenerList.add(listener);
+ }
+
+
+ private final class ConnectionListenerList extends ArrayList<ServerConnectionListener> implements ServerConnectionListener{
- /**
- * @see com.metamatrix.jdbc.transport.TransportHandler#shutdown()
- */
- public synchronized void shutdown() {
- alive = false;
- if (dqpManager != null) {
- try {
- dqpManager.shutdown();
- } catch (ApplicationLifecycleException e) {
- // TODO ignore?
- }
- dqpManager = null;
- }
- }
-
- public synchronized DQPEmbeddedManager getManager() {
- checkAlive();
- return dqpManager;
- }
-
- synchronized void setManager(DQPEmbeddedManager manager) {
- dqpManager = manager;
- }
+ @Override
+ public void connectionAdded(ServerConnection connection) {
+ for (ServerConnectionListener l: this) {
+ l.connectionAdded(connection);
+ }
+ }
- public ServerConnection createConnection(final Properties connectionProperties) throws CommunicationException,
- ConnectionException {
- initManager(connectionProperties);
-
- return new LocalServerConnection(connectionProperties);
+ @Override
+ public void connectionRemoved(ServerConnection connection) {
+ for (ServerConnectionListener l: this) {
+ l.connectionRemoved(connection);
+ }
+ }
}
-
- public void initManager(final Properties connectionProperties)
- throws ConnectionException {
- try {
- URL dqpURL = (URL)connectionProperties.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE);
- initManager(dqpURL, connectionProperties);
- } catch(ApplicationInitializationException e) {
- throw new ConnectionException(e);
- }
- }
}
Copied: trunk/embedded/src/main/resources/deploy.properties (from rev 466, trunk/embedded/src/main/resources/mm.properties)
===================================================================
--- trunk/embedded/src/main/resources/deploy.properties (rev 0)
+++ trunk/embedded/src/main/resources/deploy.properties 2009-02-21 00:28:43 UTC (rev 479)
@@ -0,0 +1,6 @@
+#default properties file for Teiid Embedded
+mm.io.tmpdir=${user.dir}/teiid-workspace/temp
+dqp.extensions=mmfile://${user.dir}/teiid-workspace/extensions
+dqp.logFile=mmfile://${user.dir}/teiid-workspace/teiid-embedded.log
+dqp.logLevel=2
+metamatrix.xatxnmgr.txnstore_dir=${user.dir}/teiid-workspace
\ No newline at end of file
Property changes on: trunk/embedded/src/main/resources/deploy.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/embedded/src/main/resources/jboss-cache-configuration.xml
===================================================================
--- trunk/embedded/src/main/resources/jboss-cache-configuration.xml (rev 0)
+++ trunk/embedded/src/main/resources/jboss-cache-configuration.xml 2009-02-21 00:28:43 UTC (rev 479)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.cache.pojo.jmx.CacheJmxWrapper" name="jboss.cache:service=FederateCache">
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup</attribute>
+ <attribute name="IsolationLevel">READ_COMMITTED</attribute>
+ <attribute name="LockParentForChildInsertRemove">true</attribute>
+
+ <attribute name="CacheMode">LOCAL</attribute>
+ <attribute name="UseLazyDeserialization">true</attribute>
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ initial state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">20000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+ <!-- Shutdown hook behavior. Valid choices are: DEFAULT, REGISTER and DONT_REGISTER. this element is omitted, DEFAULT is used. -->
+ <attribute name="ShutdownHookBehavior">DEFAULT</attribute>
+
+ <attribute name="FetchInMemoryState">true</attribute>
+
+ <attribute name="CacheLoaderConfig" replace="false">
+ <config>
+
+ <!-- are the cache loaders shared in a cluster? -->
+ <shared>false</shared>
+ <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
+ <passivation>true</passivation>
+
+ <cacheloader>
+ <class>org.jboss.cache.loader.FileCacheLoader</class>
+ <properties>location=./teiid/cache</properties>
+
+ <!--fetch the persistent state of a cache when joining a cluster-->
+ <fetchPersistentState>true</fetchPersistentState>
+
+ <!-- empties the specified cache loader when cache loader starts up -->
+ <purgeOnStartup>true</purgeOnStartup>
+
+ <!-- cache loader is shared among different cache instances -->
+ <shared>false</shared>
+ </cacheloader>
+ </config>
+ </attribute>
+
+ <attribute name="EvictionPolicyConfig">
+ <config>
+ <attribute name="wakeUpIntervalSeconds">3</attribute>
+ <!-- This defaults to 200000 if not specified -->
+ <attribute name="eventQueueSize">100000</attribute>
+ <!-- Name of the DEFAULT eviction policy class. -->
+ <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
+ <!-- Cache wide default -->
+ <region name="/_default_">
+ <attribute name="maxNodes">10000</attribute>
+ <attribute name="timeToLiveSeconds">0</attribute>
+ </region>
+ </config>
+ </attribute>
+
+ </mbean>
+</server>
\ No newline at end of file
Property changes on: trunk/embedded/src/main/resources/jboss-cache-configuration.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/embedded/src/main/resources/mm.properties
===================================================================
--- trunk/embedded/src/main/resources/mm.properties 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/main/resources/mm.properties 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,6 +0,0 @@
-#default properties file for Federate Embedded
-mm.io.tmpdir=${user.dir}/federate-workspace/temp
-dqp.extensions=mmfile://${user.dir}/federate-workspace/extensions
-dqp.logFile=mmfile://${user.dir}/federate-workspace/federate-embedded.log
-dqp.logLevel=2
-metamatrix.xatxnmgr.txnstore_dir=${user.dir}/federate-workspace
\ No newline at end of file
Modified: trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java
===================================================================
--- trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -24,6 +24,7 @@
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Properties;
import junit.framework.TestCase;
@@ -33,6 +34,7 @@
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.FakeAbstractService;
import com.metamatrix.dqp.service.FakeVDBService;
+import com.metamatrix.jdbc.EmbeddedDataSource;
public class TestEmbeddedConfigSource extends TestCase {
@@ -45,7 +47,10 @@
}
public void testServiceLoading() throws Exception {
- EmbeddedConfigSource source = new EmbeddedConfigSource(buildDQPUrl(UnitTestUtil.getTestDataPath() + "/bqt/fakebqt.properties"), null);//$NON-NLS-1$
+ Properties p = new Properties();
+ p.put(EmbeddedDataSource.DQP_BOOTSTRAP_FILE, buildDQPUrl(UnitTestUtil.getTestDataPath() + "/bqt/fakebqt.properties")); //$NON-NLS-1$
+
+ EmbeddedConfigSource source = new EmbeddedConfigSource(p);
Application application = new Application();
application.start(source);
assertTrue(application.getEnvironment().findService(DQPServiceNames.VDB_SERVICE) instanceof FakeVDBService);
Modified: trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedConfigurationService.java
===================================================================
--- trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedConfigurationService.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/test/java/com/metamatrix/dqp/embedded/services/TestEmbeddedConfigurationService.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -73,19 +73,19 @@
}
public void testUseExtensionPath() throws Exception {
- service.userPreferences = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ service.userPreferences = EmbeddedTestUtil.getProperties();
assertTrue(service.useExtensionClasspath());
}
public void testUseExtensionPathFalse() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
p.remove("dqp.extensions"); //$NON-NLS-1$
service.userPreferences = p;
assertFalse(service.useExtensionClasspath());
}
public void testGetAvailableVDBFiles() throws Exception {
- service.userPreferences = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ service.userPreferences = EmbeddedTestUtil.getProperties();
HashMap vdbFiles = VDBConfigurationReader.loadVDBS(service.getVDBLocations());
int count = vdbFiles.keySet().size();
assertEquals(2, count);
@@ -100,7 +100,7 @@
}
public void testGetConfigFileURL() throws Exception {
- service.userPreferences = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ service.userPreferences = EmbeddedTestUtil.getProperties();
assertTrue(service.getConfigFile().toString().endsWith("dqp/config/ServerConfig.xml")); //$NON-NLS-1$
}
@@ -108,7 +108,7 @@
BasicConnectorBinding binding = new BasicConnectorBinding(new ConfigurationID("foo"), new ConnectorBindingID(new ConfigurationID("foo"), "foo"), new ComponentTypeID("foo type")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
BasicConnectorBinding alternatebinding = new BasicConnectorBinding(new ConfigurationID("foo"), new ConnectorBindingID(new ConfigurationID("foo"), "foo"), new ComponentTypeID("foo type")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.loadedConnectorBindings.put("foo", alternatebinding); //$NON-NLS-1$
@@ -117,7 +117,7 @@
}
public void defer_testInitializeEncryption() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
p.setProperty(DQPEmbeddedProperties.DQP_KEYSTORE, "Cluster.key"); //$NON-NLS-1$
service.userPreferences = p;
service.initializeEncryption();
@@ -125,20 +125,20 @@
}
public void testGetDefaultExtensionPath() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
p.remove(DQPEmbeddedProperties.DQP_EXTENSIONS);
service.userPreferences = p;
assertTrue(service.getDefaultExtensionPath().toString().endsWith("dqp/extensions/")); //$NON-NLS-1$
}
public void testGetDirectoryToStoreVDBS() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
assertTrue(service.getVDBSaveLocation().toString().endsWith("dqp/config/")); //$NON-NLS-1$
}
public void testGetDirectoryToStoreVDBSByVDBName() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
p.setProperty(DQPEmbeddedProperties.VDB_DEFINITION, "./config/QT_Ora9DS.vdb"); //$NON-NLS-1$
service.userPreferences = p;
service.initializeService(p);
@@ -150,7 +150,7 @@
}
public void testGetFileToSaveNewFile() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
p.setProperty(DQPEmbeddedProperties.VDB_DEFINITION, "./config/QT_Ora9DS.vdb"); //$NON-NLS-1$
service.initializeService(p);
@@ -163,7 +163,7 @@
}
public void testGetFileAlreadyExisting() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -174,7 +174,7 @@
}
public void testGetFullyQualifiedPath() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
assertTrue(service.getFullyQualifiedPath("http://lib/foo.txt").toString().endsWith("http://lib/foo.txt")); //$NON-NLS-1$ //$NON-NLS-2$
assertTrue(service.getFullyQualifiedPath("file:/c:/lib/foo.txt").toString().endsWith("file:/c:/lib/foo.txt"));//$NON-NLS-1$ //$NON-NLS-2$
@@ -187,14 +187,14 @@
}
public void testGetNextVdbVersion() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
assertEquals(2, service.getNextVdbVersion("QT_Ora9DS")); //$NON-NLS-1$
}
public void testDeleteInUseConnectorBinding() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
try {
@@ -206,7 +206,7 @@
}
public void testDeleteNonExistingConnectorBinding() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
try {
@@ -218,7 +218,7 @@
}
public void testDeleteConnectorBinding() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -234,7 +234,7 @@
public void testDeleteConnectorType() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -255,7 +255,7 @@
}
public void testDeleteConnectorTypeInUse() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -270,7 +270,7 @@
}
public void testDeleteVDB() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -283,7 +283,7 @@
}
public void testGetLogFile() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
p.setProperty(DQPEmbeddedProperties.DQP_LOGFILE, "./log/dqp.log"); //$NON-NLS-1$
p.setProperty(DQPEmbeddedProperties.DQP_LOGLEVEL, "1"); //$NON-NLS-1$
service.userPreferences = p;
@@ -293,7 +293,7 @@
}
public void testGetSystemProperties() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -304,17 +304,8 @@
assertEquals("20000", sp.getProperty("MaxFetchSize")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testGetResetSystemPrintStreams() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
- p.setProperty(DQPEmbeddedProperties.DQP_CAPTURE_SYSTEM_PRINTSTREAMS, "true"); //$NON-NLS-1$
- service.userPreferences = p;
- service.initializeService(p);
-
- assertTrue(Boolean.valueOf(service.captureSystemStreams()).booleanValue());
- }
-
public void testGetSystemConfiguration() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
assertNull(service.configurationModel);
@@ -323,28 +314,28 @@
}
public void testGetSystemVDB() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
assertNotNull(service.getSystemVdb());
}
public void testGetUDFFileName() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
p.setProperty(DQPEmbeddedProperties.USER_DEFINED_FUNCTIONS, "./lib/foo.txt"); //$NON-NLS-1$
service.userPreferences = p;
assertTrue(service.getUDFFile().toString().endsWith(UnitTestUtil.getTestScratchPath()+"/dqp/lib/foo.txt")); //$NON-NLS-1$
}
public void testGetVDBs() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
assertTrue(service.getVDBs().size() == 2);
}
public void testSaveConnectorBinding() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -375,7 +366,7 @@
public void testSaveConnectorType() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -400,7 +391,7 @@
public void testSaveVDB() throws Exception{
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -413,7 +404,7 @@
}
public void testGetProcessorBatchSize() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -421,7 +412,7 @@
}
public void testGetConnectorBatchSize() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -429,7 +420,7 @@
}
public void testLoadedConnectorBindings() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -451,7 +442,7 @@
}
public void testAddConnectorBinding() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
@@ -463,7 +454,7 @@
}
public void testGetConnectorTypes() throws Exception {
- Properties p = EmbeddedTestUtil.getProperties(); //$NON-NLS-1$;
+ Properties p = EmbeddedTestUtil.getProperties();
service.userPreferences = p;
service.initializeService(p);
Modified: trunk/embedded/src/test/java/com/metamatrix/jdbc/TestEmbeddedDriver.java
===================================================================
--- trunk/embedded/src/test/java/com/metamatrix/jdbc/TestEmbeddedDriver.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/embedded/src/test/java/com/metamatrix/jdbc/TestEmbeddedDriver.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -50,105 +50,105 @@
*/
public void testAcceptsURL() throws SQLException {
// Windows Path
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES"));
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties")); //$NON-NLS-1$
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1")); //$NON-NLS-1$
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
// Alternative windows path
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES"));
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@c:/metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
// Abosolute path (Unix or windows)
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES"));
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
// relative path
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES"));
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1")); //$NON-NLS-1$
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@../../metamatrix/dqp/dqp.properties;version=1;txnAutoWrap=ON;partialResultsMode=YES")); //$NON-NLS-1$
// File URL should be supported (not sure)
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@file:///c:/metamatrix/dqp/dqp.properties"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@testdata/dqp/dqp.properties;partialResultsMode=true"));
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@file:///c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@testdata/dqp/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
// ClassPath based URL
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@classpath:/dqp.properties;partialResultsMode=true"));
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT@classpath:/dqp.properties;partialResultsMode=true")); //$NON-NLS-1$
// These are specific to the MMDriver and should not be suported
- assertFalse(driver.acceptsURL("jdbc:metamatrix:BQT@mm://host:7001;version=1"));
- assertFalse(driver.acceptsURL("jdbc:metamatrix:BQT@mms://host:7001;version=1"));
+ assertFalse(driver.acceptsURL("jdbc:metamatrix:BQT@mm://host:7001;version=1")); //$NON-NLS-1$
+ assertFalse(driver.acceptsURL("jdbc:metamatrix:BQT@mms://host:7001;version=1")); //$NON-NLS-1$
//assertFalse(driver.acceptsURL("jdbc:metamatrix:BQT@http://host:7001;version=1"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT"));
- assertFalse(driver.acceptsURL("jdbc:metamatrix:BQT!/path/foo.properties"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT;"));
- assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT;version=1;logFile=foo.txt"));
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT")); //$NON-NLS-1$
+ assertFalse(driver.acceptsURL("jdbc:metamatrix:BQT!/path/foo.properties")); //$NON-NLS-1$
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT;")); //$NON-NLS-1$
+ assertTrue(driver.acceptsURL("jdbc:metamatrix:BQT;version=1;logFile=foo.txt")); //$NON-NLS-1$
}
public void testParseURL() throws SQLException{
Properties p = new Properties();
- driver.parseURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties", p);
- assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT"));
- assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("mmfile:/c:/metamatrix/dqp/dqp.properties"));
+ driver.parseURL("jdbc:metamatrix:BQT@c:\\metamatrix\\dqp\\dqp.properties", p); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+ assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("mmfile:/c:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
assertEquals(2, p.size());
}
public void testParseURL2() throws SQLException {
Properties p = new Properties();
- driver.parseURL("jdbc:metamatrix:BQT@\\metamatrix\\dqp\\dqp.properties;version=3", p);
- assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT"));
- assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("mmfile:/metamatrix/dqp/dqp.properties"));
- assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3"));
- assertTrue(p.getProperty(BaseDataSource.VERSION).equals("3"));
+ driver.parseURL("jdbc:metamatrix:BQT@\\metamatrix\\dqp\\dqp.properties;version=3", p); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+ assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("mmfile:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("3")); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VERSION).equals("3")); //$NON-NLS-1$
assertEquals(4, p.size());
}
public void testParseURL3() throws SQLException{
Properties p = new Properties();
- driver.parseURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=4;txnAutoWrap=ON;partialResultsMode=YES;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log", p);
- assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT"));
- assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("mmfile:/metamatrix/dqp/dqp.properties"));
- assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4"));
- assertTrue(p.getProperty(BaseDataSource.VERSION).equals("4"));
- assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON"));
- assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("YES"));
- assertTrue(p.getProperty(BaseDataSource.LOG_FILE).equals("D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log"));
+ driver.parseURL("jdbc:metamatrix:BQT@/metamatrix/dqp/dqp.properties;version=4;txnAutoWrap=ON;partialResultsMode=YES;logFile=D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log", p); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+ assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("mmfile:/metamatrix/dqp/dqp.properties")); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("4")); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VERSION).equals("4")); //$NON-NLS-1$
+ assertTrue(p.getProperty(ExecutionProperties.PROP_TXN_AUTO_WRAP).equals("ON")); //$NON-NLS-1$
+ assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("YES")); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.LOG_FILE).equals("D:\\metamatrix\\work\\DQP\\log\\jdbcLogFile.log")); //$NON-NLS-1$
assertEquals(7, p.size());
}
public void testParseURL4() throws SQLException{
Properties p = new Properties();
- driver.parseURL("jdbc:metamatrix:BQT@testdata/dqp/dqp.properties;partialResultsMode=true", p);
- assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT"));
- assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("mmfile:testdata/dqp/dqp.properties"));
- assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true"));
+ driver.parseURL("jdbc:metamatrix:BQT@testdata/dqp/dqp.properties;partialResultsMode=true", p); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+ assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("mmfile:testdata/dqp/dqp.properties")); //$NON-NLS-1$
+ assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
assertEquals(3, p.size());
}
public void testParseURL5() throws SQLException{
Properties p = new Properties();
- driver.parseURL("jdbc:metamatrix:BQT", p);
- assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT"));
- assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("classpath:/mm.properties"));
+ driver.parseURL("jdbc:metamatrix:BQT", p); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+ assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("classpath:/deploy.properties")); //$NON-NLS-1$
}
public void testParseURL55() throws SQLException{
Properties p = new Properties();
- driver.parseURL("jdbc:metamatrix:BQT;", p);
- assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT"));
- assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("classpath:/mm.properties"));
+ driver.parseURL("jdbc:metamatrix:BQT;", p); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+ assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("classpath:/deploy.properties")); //$NON-NLS-1$
}
public void testParseURL6() throws SQLException{
Properties p = new Properties();
- driver.parseURL("jdbc:metamatrix:BQT;partialResultsMode=true;version=1", p);
- assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT"));
- assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("classpath:/mm.properties"));
- assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true"));
- assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("1"));
- assertTrue(p.getProperty("vdb.definition").equals("BQT.vdb"));
+ driver.parseURL("jdbc:metamatrix:BQT;partialResultsMode=true;version=1", p); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_NAME).equals("BQT")); //$NON-NLS-1$
+ assertTrue(p.get(EmbeddedDataSource.DQP_BOOTSTRAP_FILE).toString().equals("classpath:/deploy.properties")); //$NON-NLS-1$
+ assertTrue(p.getProperty(ExecutionProperties.PROP_PARTIAL_RESULTS_MODE).equals("true")); //$NON-NLS-1$
+ assertTrue(p.getProperty(BaseDataSource.VDB_VERSION).equals("1")); //$NON-NLS-1$
+ assertTrue(p.getProperty("vdb.definition").equals("BQT.vdb")); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(6, p.size());
}
Added: trunk/embedded/src/test/resources/jboss-cache-configuration.xml
===================================================================
--- trunk/embedded/src/test/resources/jboss-cache-configuration.xml (rev 0)
+++ trunk/embedded/src/test/resources/jboss-cache-configuration.xml 2009-02-21 00:28:43 UTC (rev 479)
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.cache.pojo.jmx.CacheJmxWrapper" name="jboss.cache:service=FederateCache">
+ <attribute name="TransactionManagerLookupClass">org.jboss.cache.transaction.GenericTransactionManagerLookup</attribute>
+ <attribute name="IsolationLevel">READ_COMMITTED</attribute>
+ <attribute name="LockParentForChildInsertRemove">true</attribute>
+
+ <attribute name="CacheMode">LOCAL</attribute>
+ <attribute name="UseLazyDeserialization">true</attribute>
+
+ <!--
+ The max amount of time (in milliseconds) we wait until the
+ initial state (ie. the contents of the cache) are retrieved from
+ existing members in a clustered environment
+ -->
+ <attribute name="StateRetrievalTimeout">20000</attribute>
+
+ <!--
+ Number of milliseconds to wait until all responses for a
+ synchronous call have been received.
+ -->
+ <attribute name="SyncReplTimeout">20000</attribute>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <attribute name="LockAcquisitionTimeout">15000</attribute>
+
+ <!-- Shutdown hook behavior. Valid choices are: DEFAULT, REGISTER and DONT_REGISTER. this element is omitted, DEFAULT is used. -->
+ <attribute name="ShutdownHookBehavior">DEFAULT</attribute>
+
+ <attribute name="FetchInMemoryState">true</attribute>
+
+ <attribute name="CacheLoaderConfig" replace="false">
+ <config>
+
+ <!-- are the cache loaders shared in a cluster? -->
+ <shared>false</shared>
+ <!-- if passivation is true, only the first cache loader is used; the rest are ignored -->
+ <passivation>true</passivation>
+
+ <cacheloader>
+ <class>org.jboss.cache.loader.FileCacheLoader</class>
+ <properties>location=./target/scratch/federate</properties>
+
+ <!--fetch the persistent state of a cache when joining a cluster-->
+ <fetchPersistentState>true</fetchPersistentState>
+
+ <!-- empties the specified cache loader when cache loader starts up -->
+ <purgeOnStartup>true</purgeOnStartup>
+
+ <!-- cache loader is shared among different cache instances -->
+ <shared>false</shared>
+ </cacheloader>
+ </config>
+ </attribute>
+
+ <attribute name="EvictionPolicyConfig">
+ <config>
+ <attribute name="wakeUpIntervalSeconds">3</attribute>
+ <!-- This defaults to 200000 if not specified -->
+ <attribute name="eventQueueSize">100000</attribute>
+ <!-- Name of the DEFAULT eviction policy class. -->
+ <attribute name="policyClass">org.jboss.cache.eviction.LRUPolicy</attribute>
+ <!-- Cache wide default -->
+ <region name="/_default_">
+ <attribute name="maxNodes">10000</attribute>
+ <attribute name="timeToLiveSeconds">0</attribute>
+ </region>
+ </config>
+ </attribute>
+
+ </mbean>
+</server>
\ No newline at end of file
Property changes on: trunk/embedded/src/test/resources/jboss-cache-configuration.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -31,13 +31,13 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.comm.api.ServerConnectionListener;
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ConfigurationModelContainer;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.config.api.ConnectorBindingType;
import com.metamatrix.common.config.api.ExtensionModule;
import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.dqp.application.ClientConnectionListener;
@@ -117,14 +117,6 @@
public String getLogLevel();
/**
- * Capture the System.out and System.err streams and direct them to the
- * log file.
- * @return true if yes; false otherwise
- * @throws MetaMatrixComponentException
- */
- public String captureSystemStreams() throws MetaMatrixComponentException;
-
- /**
* Save the given vdb file into underlying persistent mechanism used by
* this configuration service
* @param vdb - VDB to be saved
@@ -312,8 +304,7 @@
* @throws MetaMatrixComponentException
* @since 4.3.2
*/
- public ClientConnectionListener getConnectionListener()
- throws MetaMatrixComponentException;
+ public ServerConnectionListener getConnectionListener();
/**
@@ -393,13 +384,8 @@
*/
public String getInstanceIdenifier();
+
/**
- * Should DQP use the unified class loader?
- * @return true if yes; false otherwise
- */
- public boolean useUnifiedClassLoader();
-
- /**
* This returns the active client connections that have been made to the DQP
* @return list of connections which are currently available;never null
*/
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/config/TestDQPLauncher.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -66,7 +66,7 @@
DQPCore dqpCore = new DQPCore();
dqpCore.start(configSource);
- PlatformLog log = PlatformLog.getInstance();
+ PlatformLog log = new PlatformLog();
List<LogListener> list = log.getLogListeners();
for(LogListener l: list) {
log.removeListener(l);
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/pom.xml 2009-02-21 00:28:43 UTC (rev 479)
@@ -127,9 +127,10 @@
<descriptors>
<descriptor>build/assembly/src.xml</descriptor>
<descriptor>build/assembly/bin.xml</descriptor>
- <descriptor>build/assembly/embedded/embedded-jar.xml</descriptor>
+ <descriptor>build/assembly/embedded/embedded-client-jar.xml</descriptor>
<descriptor>build/assembly/embedded/embedded-dependencies.xml</descriptor>
<descriptor>build/assembly/embedded/embedded-connector-dependencies.xml</descriptor>
+ <descriptor>build/assembly/embedded/embedded-jar.xml</descriptor>
<descriptor>build/assembly/embedded/embedded-dist.xml</descriptor>
<descriptor>build/assembly/cdk/cdk-dependencies.xml</descriptor>
<descriptor>build/assembly/cdk/cdk-dist.xml</descriptor>
Modified: trunk/server/src/main/java/com/metamatrix/common/log/DbLogListener.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/log/DbLogListener.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/common/log/DbLogListener.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -42,7 +42,7 @@
/**
* Listen for log messages and write them to a database.
*/
- public DbLogListener(Properties prop) throws DbWriterException {
+ public DbLogListener(Properties prop){
if (prop == null) {
final String msg = CommonPlugin.Util.getString("DbLogListener.The_Properties_reference_may_not_be_null"); //$NON-NLS-1$
throw new IllegalArgumentException(msg);
@@ -50,13 +50,9 @@
writer = new DbLogWriter(prop);
writer.initialize();
enabled = PropertiesUtils.getBooleanProperty(prop, LOG_DB_ENABLED, true);
-
}
- protected void init(Properties props) throws DbWriterException {
- }
-
public void logMessage(LogMessage msg) {
if (enabled) {
@@ -64,9 +60,6 @@
}
}
- /* (non-Javadoc)
- * @see com.metamatrix.core.log.LogListener#shutdown()
- */
public void shutdown() {
writer.shutdown();
}
@@ -77,7 +70,7 @@
}
- public void enableDBLogging(boolean enable) {
+ void enableDBLogging(boolean enable) {
enabled = enable;
}
Modified: trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/common/log/DbLogWriter.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -32,6 +32,7 @@
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.config.JDBCConnectionPoolHelper;
import com.metamatrix.common.util.ErrorMessageKeys;
+import com.metamatrix.common.util.VMNaming;
import com.metamatrix.core.log.LogMessage;
import com.metamatrix.core.util.DateUtil;
import com.metamatrix.core.util.StringUtil;
@@ -46,7 +47,7 @@
*/
public class DbLogWriter {
- /**
+ /**
* Static String to use as the user name when checking out connections from the pool
*/
static final String LOGGING = "LOGGING";//$NON-NLS-1$
@@ -55,8 +56,7 @@
* The name of the System property that contains the name of the LogMessageFormat
* class that is used to format messages sent to the file destination.
* This is an optional property; if not specified and the file destination
- * is used, then the {@link com.metamatrix.common.logging.format.DelimitedLogMessageFormat DelimitedLogMessageFormat}
- * is used.
+ * is used
*/
static final String PROPERTY_PREFIX = "metamatrix.log."; //$NON-NLS-1$
@@ -193,7 +193,7 @@
* itself.
* @throws LogDestinationInitFailedException if there was an error during initialization.
*/
- public void initialize() throws DbWriterException {
+ public void initialize() {
sequenceNumber = 0;
lastSequenceStart = 0;
@@ -309,10 +309,10 @@
stmt.setString(5, StringUtil.truncString(message.getText(), maxMsgLength));
// Message hostname column
- stmt.setString(6, StringUtil.truncString(message.getHostName(), maxGeneralLength));
+ stmt.setString(6, StringUtil.truncString(VMNaming.getConfigName(), maxGeneralLength));
// Message VM ID column
- stmt.setString(7, StringUtil.truncString(message.getVMName(), maxGeneralLength));
+ stmt.setString(7, StringUtil.truncString(VMNaming.getVMName(), maxGeneralLength));
// Message thread name column
stmt.setString(8, StringUtil.truncString(message.getThreadName(), maxGeneralLength));
Modified: trunk/server/src/main/java/com/metamatrix/common/log/I18nLogManager.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/log/I18nLogManager.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/common/log/I18nLogManager.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -22,7 +22,7 @@
package com.metamatrix.common.log;
-import com.metamatrix.core.log.LogMessage;
+import com.metamatrix.core.CorePlugin;
import com.metamatrix.core.log.MessageLevel;
/**
@@ -31,7 +31,8 @@
*/
public final class I18nLogManager {
private static I18nLogManager INSTANCE = new I18nLogManager();
-
+ private static final String NULL_MSG_TEXT = "Null"; //$NON-NLS-1$
+
private I18nLogManager() {
}
@@ -114,46 +115,56 @@
}
private void logMessage(int level, String msgID, String context, Object[] msgParts) {
- // Check quickly the level of the message:
- // If the messsage's level is greater than the logging level,
- // then the message should NOT be recorded ...
if (!LogManager.isMessageToBeRecorded(context, level)) {
return;
}
-
- LogMessage msg = new LogMessage(msgID, context, level, msgParts);
- LogManager.getInstance().forwardMessage(msg);
-// System.out.println("Enqueuing message: " + msg.getText() );
+ LogManager.log(level, context, geti18nMsg(msgID, msgParts));
}
+ private String geti18nMsg(String msgID, Object[] msgParts) {
+ if (msgID != null) {
+ if (msgParts == null) {
+ return CorePlugin.Util.getString(msgID);
+ } else {
+
+ return CorePlugin.Util.getString(msgID, msgParts);
+
+ }
+ }
+ else {
+ StringBuffer text = null;
+ if(msgParts != null) {
+ text = new StringBuffer();
+ for(int i=0; i<msgParts.length; i++) {
+ if (i>0) text.append(" "); //$NON-NLS-1$
+ Object omsg = msgParts[i];
+ if ( omsg != null ) {
+ text.append(omsg.toString());
+ }
+ }
+ }
+
+ if (text == null) {
+ return NULL_MSG_TEXT;
+ } else {
+ return text.toString();
+ }
+ }
+ }
+
private void logMessage(int level, String msgID, String context, Throwable e) {
- // Check quickly the level of the message:
- // If the messsage's level is greater than the logging level,
- // then the message should NOT be recorded ...
if (!LogManager.isMessageToBeRecorded(context, level)) {
return;
}
-
-
- LogMessage msg = new LogMessage(msgID, context, level, e);
-// System.out.println("Enqueuing message: " + msg.getText() );
- LogManager.getInstance().forwardMessage(msg);
+ LogManager.log(level, context, e, geti18nMsg(msgID, null));
}
private void logMessage(int level, String msgID, String context, Throwable e, Object[] msgParts) {
- // Check quickly the level of the message:
- // If the messsage's level is greater than the logging level,
- // then the message should NOT be recorded ...
if (!LogManager.isMessageToBeRecorded(context, level)) {
return;
}
-
-
- LogMessage msg = new LogMessage(msgID, context, level, e, msgParts);
-// System.out.println("Enqueuing message: " + msg.getText() );
- LogManager.getInstance().forwardMessage(msg);
+ LogManager.log(level, context, e, geti18nMsg(msgID, msgParts));
}
-
}
Modified: trunk/server/src/main/java/com/metamatrix/common/log/reader/DBLogReader.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/log/reader/DBLogReader.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/common/log/reader/DBLogReader.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -38,15 +38,9 @@
import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.JDBCConnectionPoolHelper;
-import com.metamatrix.common.config.ResourceNames;
-import com.metamatrix.common.config.api.ResourceDescriptor;
import com.metamatrix.common.connection.ManagedConnectionException;
-import com.metamatrix.common.jdbc.JDBCUtil;
-import com.metamatrix.common.properties.UnmodifiableProperties;
import com.metamatrix.common.util.ErrorMessageKeys;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.common.util.crypto.CryptoException;
-import com.metamatrix.common.util.crypto.CryptoUtil;
import com.metamatrix.core.util.DateUtil;
@@ -58,7 +52,7 @@
* The name of the System property that contains the name of the LogMessageFormat
* class that is used to format messages sent to the file destination.
* This is an optional property; if not specified and the file destination
- * is used, then the {@link com.metamatrix.common.logging.format.DelimitedLogMessageFormat DelimitedLogMessageFormat}
+ * is used
* is used.
*/
static final String PROPERTY_PREFIX = "metamatrix.log."; //$NON-NLS-1$
Deleted: trunk/server/src/main/java/com/metamatrix/platform/config/ConfigurationChangeListener.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/config/ConfigurationChangeListener.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/platform/config/ConfigurationChangeListener.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config;
-
-import java.util.EventObject;
-
-import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.config.api.Configuration;
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.log.DbLogListener;
-import com.metamatrix.core.event.EventObjectListener;
-import com.metamatrix.platform.config.event.ConfigurationChangeEvent;
-
-/**
- * This class will listen for Changes to Configuration and
- */
-public class ConfigurationChangeListener implements EventObjectListener {
-
- /**
- * The name of the System property that contains the set of comma-separated
- * context names for messages <i>not</i> to be recorded. A message context is simply
- * some string that identifies something about the component that generates
- * the message. The value for the contexts is application specific.
- * <p>
- * This is an optional property that defaults to no contexts (i.e., messages
- * with any context are recorded).
- */
- public static final String LOG_CONTEXT_PROPERTY_NAME = "metamatrix.log.contexts"; //$NON-NLS-1$
-
- public static final String LOG_LEVEL_PROPERTY_NAME = "metamatrix.log"; //$NON-NLS-1$
-
- public static final String LOG_DB_ENABLED = "metamatrix.log.jdbcDatabase.enabled"; //$NON-NLS-1$
-
- Configuration currentConfig = null;
-
- private DbLogListener logger = null;
-
- public ConfigurationChangeListener() {
-
- }
-
- public ConfigurationChangeListener(DbLogListener dblogger) {
- logger = dblogger;
- }
-
- /* (non-Javadoc)
- * @see com.metamatrix.core.event.EventObjectListener#processEvent(java.util.EventObject)
- */
- public void processEvent(EventObject obj) {
- if(obj instanceof ConfigurationChangeEvent){
- try {
- currentConfig = CurrentConfiguration.getInstance().getConfiguration();
-
- if (logger != null) {
- logger.determineIfEnabled(currentConfig.getProperties());
- }
-
- } catch( ConfigurationException ce ) {
- ce.printStackTrace();
- System.out.println(ce);
- }
- }
- }
-
- public void shutdown() {
- }
-
-}
Modified: trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/ConsoleAuditDestination.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/ConsoleAuditDestination.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/platform/security/audit/destination/ConsoleAuditDestination.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -39,9 +39,6 @@
/**
* The name of the property that contains the name of the LogMessageFormat
* class that is used to format messages sent to the console.
- * This is an optional property; if not specified then the
- * {@link com.metamatrix.common.logging.format.DelimitedLogMessageFormat DelimitedLogMessageFormat}
- * is used.
*/
public static final String MESSAGE_FORMAT_PROPERTY_NAME = AuditDestination.PROPERTY_PREFIX + "consoleFormat"; //$NON-NLS-1$
Modified: trunk/server/src/main/java/com/metamatrix/platform/vm/controller/VMController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/vm/controller/VMController.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/platform/vm/controller/VMController.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -517,24 +517,18 @@
return;
}
- // Create a thread that will actually kill the vm so that this method can (the stub anyway) return.
- Thread stopper = new Thread() {
-
+ this.startServicePool.execute(new Runnable() {
public void run() {
// Wait before killing the VM.
try {
- sleep(force_shutdown_time * 1000);
+ Thread.sleep(force_shutdown_time * 1000);
} catch (Exception e) {}
-
// And exit.
System.exit(1);
}
- };
-
- stopper.start();
+ });
}
-
private synchronized void stop(boolean now, boolean shutdown) {
try {
stopServices(now, shutdown);
@@ -616,9 +610,11 @@
* Shut down all services without waiting for work to complete.
* Essential services will also be shutdown.
*/
- public void shutdownNow() {
+ public synchronized void shutdownNow() {
logMessage(PlatformPlugin.Util.getString(LogMessageKeys.VM_0041));
doStopVM(true, true);
+ this.shuttingDown = true;
+ notifyAll();
}
public void shutdownService(ServiceID serviceID) {
@@ -687,7 +683,7 @@
public void ping() {
}
- public boolean isShuttingDown() {
+ public synchronized boolean isShuttingDown() {
return shuttingDown;
}
Deleted: trunk/server/src/main/java/com/metamatrix/platform/vm/util/VMUtils.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/vm/util/VMUtils.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/platform/vm/util/VMUtils.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.vm.util;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.Properties;
-
-import com.metamatrix.common.config.CurrentConfiguration;
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.core.log.FileLimitSizeLogWriter;
-import com.metamatrix.internal.core.log.PlatformLog;
-
-public class VMUtils {
-
- /**
- * initializeVMLogFile is called by the different controllers (i.e., SocketVMController, HostController, etc)
- * to setup the log file using the LimitSize log file writer.
- * @param fileName
- * @throws Exception
- * @since 4.2
- */
- public static void startLogFile(String path, String logFile) throws ConfigurationException, IOException{
- File tmpFile = new File(path, logFile);
- tmpFile.getParentFile().mkdirs();
-
- // if log file exists then create a archive
- if (tmpFile.exists()) {
- int index = logFile.lastIndexOf("."); //$NON-NLS-1$
- String archiveName = FileLimitSizeLogWriter.buildArchiveFileName(logFile.substring(0, index), logFile.substring(index));
- tmpFile.renameTo(new File(path, archiveName));
- }
-
- FileOutputStream fos = new FileOutputStream(tmpFile);
- PrintStream ps = new PrintStream(fos);
-
- System.setOut(ps);
- System.setErr(ps);
-
- Properties logProps = new Properties();
- Properties configProps = CurrentConfiguration.getInstance().getProperties();
- if (configProps.containsKey(FileLimitSizeLogWriter.FILE_SIZE_LIMIT)) {
- logProps.setProperty(FileLimitSizeLogWriter.FILE_SIZE_LIMIT,configProps.getProperty(FileLimitSizeLogWriter.FILE_SIZE_LIMIT));
- }
- if (configProps.containsKey(FileLimitSizeLogWriter.FILE_SIZE_MONITOR_TIME)) {
- logProps.setProperty(FileLimitSizeLogWriter.FILE_SIZE_MONITOR_TIME,configProps.getProperty(FileLimitSizeLogWriter.FILE_SIZE_MONITOR_TIME));
- }
-
- FileLimitSizeLogWriter flw = new FileLimitSizeLogWriter(tmpFile, logProps, false);
-
- PlatformLog.getInstance().addListener(flw);
-
- }
-
-}
Modified: trunk/server/src/main/java/com/metamatrix/server/HostController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -49,9 +49,7 @@
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.common.util.VMNaming;
-import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.StringUtil;
import com.metamatrix.dqp.ResourceFinder;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.registry.ClusteredRegistryState;
@@ -60,7 +58,6 @@
import com.metamatrix.platform.registry.VMRegistryBinding;
import com.metamatrix.platform.util.ErrorMessageKeys;
import com.metamatrix.platform.util.LogMessageKeys;
-import com.metamatrix.platform.vm.util.VMUtils;
@Singleton
public class HostController implements HostManagement {
@@ -95,7 +92,7 @@
// normal startup.
StartupStateController.performSystemInitialization(true);
- startLogging();
+ createTempDirectories();
Runtime.getRuntime().addShutdownHook(new ShutdownThread());
@@ -149,13 +146,7 @@
return null;
}
- private void startLogging() throws ConfigurationException, IOException {
-
- // setup the log file
- String hostFileName = StringUtil.replaceAll(host.getFullName(), ".", "_"); //$NON-NLS-1$ //$NON-NLS-2$
-
- VMUtils.startLogFile(host.getLogDirectory(), hostFileName + "_hc.log"); //$NON-NLS-1$
-
+ private void createTempDirectories() throws ConfigurationException, IOException {
// If the java-i-tmp directory doesn't exist, it needs to be created
// because extension jars class loading will fail because
// java internals can' write to a non-existent directory.
Modified: trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -33,8 +33,12 @@
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
+import com.metamatrix.common.log.LogConfiguration;
+import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.messaging.VMMessageBus;
+import com.metamatrix.core.log.LogListener;
+import com.metamatrix.core.util.StringUtil;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.registry.HostMonitor;
@@ -70,6 +74,14 @@
bind(ClusteredRegistryState.class).in(Scopes.SINGLETON);
bind(MessageBus.class).to(VMMessageBus.class).in(Scopes.SINGLETON); // VM Message bus is in common-internal
bind(HostMonitor.class).in(Scopes.SINGLETON);
+
+ bind(LogConfiguration.class).toProvider(LogConfigurationProvider.class).in(Scopes.SINGLETON);
+
+ String logFileName = StringUtil.replaceAll(host.getFullName(), ".", "_")+"_hc.log"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ bind(LogListener.class).toProvider(new ServerLogListernerProvider(host.getLogDirectory(), logFileName, false)).in(Scopes.SINGLETON);
+
+ // this needs to be removed.
+ binder().requestStaticInjection(LogManager.class);
}
}
Added: trunk/server/src/main/java/com/metamatrix/server/LogConfigurationProvider.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/LogConfigurationProvider.java (rev 0)
+++ trunk/server/src/main/java/com/metamatrix/server/LogConfigurationProvider.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -0,0 +1,116 @@
+/*
+ * 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 com.metamatrix.server;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.EventObject;
+import java.util.HashSet;
+import java.util.Set;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import com.metamatrix.common.config.CurrentConfiguration;
+import com.metamatrix.common.config.api.Configuration;
+import com.metamatrix.common.config.api.exceptions.ConfigurationException;
+import com.metamatrix.common.log.LogConfiguration;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.log.config.BasicLogConfiguration;
+import com.metamatrix.common.log.config.LogConfigurationException;
+import com.metamatrix.common.messaging.MessageBus;
+import com.metamatrix.common.messaging.MessagingException;
+import com.metamatrix.common.util.LogContextsUtil;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.event.EventObjectListener;
+import com.metamatrix.core.util.StringUtil;
+import com.metamatrix.platform.config.event.ConfigurationChangeEvent;
+
+@Singleton
+class LogConfigurationProvider implements Provider<LogConfiguration> {
+
+ private static final String LOG_CONTEXT_PROPERTY_NAME = "metamatrix.log.contexts"; //$NON-NLS-1$
+ private static final String LOG_LEVEL_PROPERTY_NAME = "metamatrix.log"; //$NON-NLS-1$
+
+ @Inject
+ MessageBus messsgeBus;
+
+
+ @Override
+ public LogConfiguration get() {
+
+ try {
+ final LogConfiguration orig = (LogConfiguration)CurrentConfiguration.getInstance().getConfiguration().getLogConfiguration().clone();
+
+ try {
+ this.messsgeBus.addListener(ConfigurationChangeEvent.class, new EventObjectListener() {
+ public void processEvent(EventObject obj) {
+ if(obj instanceof ConfigurationChangeEvent){
+ try {
+ Configuration currentConfig = CurrentConfiguration.getInstance().getConfiguration();
+ int level = Integer.parseInt(currentConfig.getProperty(LOG_LEVEL_PROPERTY_NAME));
+ String[] contexts = getContext();
+
+ BasicLogConfiguration newConfig = new BasicLogConfiguration(Arrays.asList(contexts), level);
+ if (!newConfig.equals(LogManager.getLogConfigurationCopy())) {
+ LogManager.setLogConfiguration(newConfig);
+ }
+ } catch( ConfigurationException ce ) {
+ LogManager.logError(LogContextsUtil.CommonConstants.CTX_MESSAGE_BUS, ce, ce.getMessage());
+ }
+ }
+ }
+
+ private String[] getContext() {
+ String[] result = null;
+ Collection discardedContexts = null;
+ String discardedContextsString = CurrentConfiguration.getInstance().getProperties().getProperty(LOG_CONTEXT_PROPERTY_NAME);
+ if (discardedContextsString != null){
+ discardedContexts = StringUtil.split(discardedContextsString,","); //$NON-NLS-1$
+ }
+
+ //get the Set of all contexts, remove the ones which are
+ //currently "discarded"
+ Set contextsSet = new HashSet(LogContextsUtil.ALL_CONTEXTS);
+ if (discardedContexts != null){
+ contextsSet.removeAll(discardedContexts);
+ }
+ result = new String[contextsSet.size()];
+ result = (String[]) contextsSet.toArray(result);
+ return result;
+ }
+ });
+ } catch (MessagingException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ return orig;
+
+ } catch ( ConfigurationException e ) {
+ try {
+ return BasicLogConfiguration.createLogConfiguration(System.getProperties());
+ } catch ( LogConfigurationException e1) {
+ throw new MetaMatrixRuntimeException(e1);
+ }
+ }
+
+ }
+}
Property changes on: trunk/server/src/main/java/com/metamatrix/server/LogConfigurationProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/server/src/main/java/com/metamatrix/server/Main.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/Main.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/server/Main.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -23,7 +23,6 @@
package com.metamatrix.server;
import java.io.File;
-import java.util.Properties;
import com.google.inject.Guice;
import com.google.inject.Inject;
@@ -32,23 +31,15 @@
import com.metamatrix.common.config.api.Host;
import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-import com.metamatrix.common.log.DbLogListener;
-import com.metamatrix.common.log.DbWriterException;
-import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
-import com.metamatrix.common.util.LogCommonConstants;
-import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.common.messaging.MessagingException;
import com.metamatrix.common.util.VMNaming;
+import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.util.FileUtils;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.dqp.ResourceFinder;
-import com.metamatrix.internal.core.log.PlatformLog;
import com.metamatrix.platform.PlatformPlugin;
-import com.metamatrix.platform.config.ConfigurationChangeListener;
-import com.metamatrix.platform.config.event.ConfigurationChangeEvent;
-import com.metamatrix.platform.util.LogMessageKeys;
import com.metamatrix.platform.vm.api.controller.VMControllerInterface;
-import com.metamatrix.platform.vm.util.VMUtils;
/**
* This is main server starter class.
@@ -61,6 +52,9 @@
@Inject
VMControllerInterface vmController;
+ @Inject
+ LogListener logListener;
+
public static void main(String[] args) throws Exception{
if (args.length < 2 || args.length > 4) {
@@ -90,10 +84,7 @@
// write info log
writeInfoLog(host, vmName);
-
- // Start the log file
- VMUtils.startLogFile(host.getLogDirectory(), buildPrefix(host.getName(), vmName) + ".log"); //$NON-NLS-1$
-
+
createTempDirectory();
// wire up guice modules
@@ -116,23 +107,17 @@
private void launchServer() {
try {
- DbLogListener dbListener = startDbLogging();
- ConfigurationChangeListener configListener = new ConfigurationChangeListener(dbListener);
- this.messageBus.addListener(ConfigurationChangeEvent.class, configListener);
-
+ Runtime.getRuntime().addShutdownHook(new ShutdownWork());
+
// start the VM
this.vmController.startVM();
- while(!this.vmController.isShuttingDown()) {
- Thread.sleep(1000);
- }
+ synchronized (this.vmController) {
+ while(!this.vmController.isShuttingDown()) {
+ this.vmController.wait(1000);
+ }
+ }
- configListener.shutdown();
-
- this.messageBus.shutdown();
-
- // shutdown cache
- ResourceFinder.getCacheFactory().destroy();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
@@ -159,25 +144,33 @@
String hostFileName = StringUtil.replaceAll(hostName, ".", "_"); //$NON-NLS-1$ //$NON-NLS-2$
return hostFileName + "_" + vmName; //$NON-NLS-1$
}
-
- private static DbLogListener startDbLogging() throws Exception, DbWriterException {
- Properties currentProps = CurrentConfiguration.getInstance().getProperties();
- Properties resultsProps = PropertiesUtils.clone(currentProps, null, true, false);
-
- // write a db log listener
- DbLogListener dll = new DbLogListener(resultsProps);
-
- // start the logger
- PlatformLog.getInstance().addListener(dll);
- LogManager.logInfo(LogCommonConstants.CTX_CONTROLLER, PlatformPlugin.Util.getString(LogMessageKeys.VM_0052));
-
- return dll;
- }
-
+
private static void writeInfoLog(Host host, String vmName) {
// trigger the logging of the current application info to a log file for debugging
LogApplicationInfo logApplInfo = new LogApplicationInfo(host.getFullName(), vmName, host.getLogDirectory(), buildPrefix(host.getFullName(), vmName) + "_info.log"); //$NON-NLS-1$
logApplInfo.start();
}
+
+ /**
+ * All work to be done during shutdown
+ */
+ class ShutdownWork extends Thread {
+
+ @Override
+ public void run() {
+
+ try {
+ messageBus.shutdown();
+ } catch (MessagingException e) {
+ e.printStackTrace();
+ }
+
+ // shutdown cache
+ ResourceFinder.getCacheFactory().destroy();
+
+ // shutdown logging
+ logListener.shutdown();
+ }
+ }
}
Modified: trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -36,9 +36,13 @@
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.id.dbid.DBIDGenerator;
import com.metamatrix.common.id.dbid.DBIDGeneratorException;
+import com.metamatrix.common.log.LogConfiguration;
+import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.messaging.VMMessageBus;
import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.log.LogListener;
+import com.metamatrix.core.util.StringUtil;
import com.metamatrix.platform.registry.ClusteredRegistryState;
import com.metamatrix.platform.registry.VMMonitor;
import com.metamatrix.platform.service.proxy.ProxyManager;
@@ -96,6 +100,18 @@
// this needs to be removed.
binder().requestStaticInjection(PlatformProxyHelper.class);
+
+ bind(LogConfiguration.class).toProvider(LogConfigurationProvider.class).in(Scopes.SINGLETON);
+ bind(LogListener.class).toProvider(ServerLogListernerProvider.class).in(Scopes.SINGLETON);
+
+ // Start the log file
+ String logFileName = StringUtil.replaceAll(host.getFullName(), ".", "_")+".log"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ bind(LogListener.class).toProvider(new ServerLogListernerProvider(host.getLogDirectory(), logFileName, true)).in(Scopes.SINGLETON);
+
+
+ // this needs to be removed.
+ binder().requestStaticInjection(LogManager.class);
+
}
}
Added: trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java (rev 0)
+++ trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -0,0 +1,149 @@
+/*
+ * 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 com.metamatrix.server;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.util.EventObject;
+import java.util.Properties;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+import com.metamatrix.common.config.CurrentConfiguration;
+import com.metamatrix.common.config.api.Configuration;
+import com.metamatrix.common.config.api.exceptions.ConfigurationException;
+import com.metamatrix.common.log.DbLogListener;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.messaging.MessageBus;
+import com.metamatrix.common.messaging.MessagingException;
+import com.metamatrix.common.util.LogContextsUtil;
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.event.EventObjectListener;
+import com.metamatrix.core.log.FileLimitSizeLogWriter;
+import com.metamatrix.core.log.LogListener;
+import com.metamatrix.internal.core.log.PlatformLog;
+import com.metamatrix.platform.config.event.ConfigurationChangeEvent;
+
+@Singleton
+class ServerLogListernerProvider implements Provider<LogListener> {
+
+ String logFile;
+ String path;
+ boolean addDBLogger;
+ DbLogListener dbLogger;
+
+ @Inject
+ MessageBus messsgeBus;
+
+ public ServerLogListernerProvider(String path, String fileName, boolean addDbLogger) {
+ this.path = path;
+ this.logFile = fileName;
+ this.addDBLogger = addDbLogger;
+ }
+
+ @Override
+ public LogListener get() {
+
+ final PlatformLog realLog = new PlatformLog();
+
+ try {
+ FileLimitSizeLogWriter flw = buildFileLogger();
+ realLog.addListener(flw);
+
+ } catch (FileNotFoundException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+
+ if (this.addDBLogger) {
+ this.dbLogger = buildDBLogger();
+ realLog.addListener(this.dbLogger);
+
+ try {
+
+ this.messsgeBus.addListener(ConfigurationChangeEvent.class, new EventObjectListener() {
+
+ public void processEvent(EventObject obj) {
+ if(obj instanceof ConfigurationChangeEvent){
+ if(obj instanceof ConfigurationChangeEvent){
+ try {
+ Configuration currentConfig = CurrentConfiguration.getInstance().getConfiguration();
+ dbLogger.determineIfEnabled(currentConfig.getProperties());
+ } catch( ConfigurationException ce ) {
+ LogManager.logError(LogContextsUtil.CommonConstants.CTX_MESSAGE_BUS, ce, ce.getMessage());
+ }
+ }
+ }
+ }
+ });
+
+ } catch (MessagingException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ }
+ return realLog;
+ }
+
+ private DbLogListener buildDBLogger() {
+ Properties currentProps = CurrentConfiguration.getInstance().getProperties();
+ Properties resultsProps = PropertiesUtils.clone(currentProps, null, true, false);
+ return new DbLogListener(resultsProps);
+ }
+
+ private FileLimitSizeLogWriter buildFileLogger()
+ throws FileNotFoundException {
+ File tmpFile = new File(path, logFile);
+ tmpFile.getParentFile().mkdirs();
+
+ // if log file exists then create a archive
+ if (tmpFile.exists()) {
+ int index = logFile.lastIndexOf("."); //$NON-NLS-1$
+ String archiveName = FileLimitSizeLogWriter.buildArchiveFileName(logFile.substring(0, index), logFile.substring(index));
+ tmpFile.renameTo(new File(path, archiveName));
+ }
+
+ FileOutputStream fos = new FileOutputStream(tmpFile);
+ PrintStream ps = new PrintStream(fos);
+
+ System.setOut(ps);
+ System.setErr(ps);
+
+ Properties logProps = new Properties();
+ Properties configProps = CurrentConfiguration.getInstance().getProperties();
+ if (configProps.containsKey(FileLimitSizeLogWriter.FILE_SIZE_LIMIT)) {
+ logProps.setProperty(FileLimitSizeLogWriter.FILE_SIZE_LIMIT,configProps.getProperty(FileLimitSizeLogWriter.FILE_SIZE_LIMIT));
+ }
+ if (configProps.containsKey(FileLimitSizeLogWriter.FILE_SIZE_MONITOR_TIME)) {
+ logProps.setProperty(FileLimitSizeLogWriter.FILE_SIZE_MONITOR_TIME,configProps.getProperty(FileLimitSizeLogWriter.FILE_SIZE_MONITOR_TIME));
+ }
+
+ FileLimitSizeLogWriter flw = new FileLimitSizeLogWriter(tmpFile,logProps, false);
+ return flw;
+ }
+
+
+
+}
Property changes on: trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java 2009-02-20 21:08:28 UTC (rev 478)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java 2009-02-21 00:28:43 UTC (rev 479)
@@ -396,7 +396,7 @@
MMRequest request = (MMRequest) results.iterator().next();
assertEquals(REQUEST_1_1, request.getIdentifier());
- assertEquals(1, request.getSessionID());
+ assertEquals("1", request.getSessionID()); //$NON-NLS-1$
assertEquals("1", request.getRequestID()); //$NON-NLS-1$
assertEquals("user1", request.getUserName()); //$NON-NLS-1$
@@ -443,7 +443,7 @@
MMSourceRequest request = (MMSourceRequest) results.iterator().next();
assertEquals(REQUEST_1_1_1, request.getIdentifier());
- assertEquals(1, request.getSessionID());
+ assertEquals("1", request.getSessionID()); //$NON-NLS-1$
assertEquals(REQUEST_1_1, request.getRequestID());
assertEquals("connectorBinding1", request.getConnectorBindingName()); //$NON-NLS-1$
assertEquals("user1", request.getUserName()); //$NON-NLS-1$
15 years, 10 months
teiid SVN: r478 - trunk/connectors/connector-xml-common.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-02-20 16:08:28 -0500 (Fri, 20 Feb 2009)
New Revision: 478
Modified:
trunk/connectors/connector-xml-common/
Log:
Adding the .classpath ignores
Property changes on: trunk/connectors/connector-xml-common
___________________________________________________________________
Name: svn:ignore
- target
.project
bin
+ target
.project
bin
.classpath
.settings
15 years, 10 months
teiid SVN: r477 - trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-02-19 12:59:14 -0500 (Thu, 19 Feb 2009)
New Revision: 477
Removed:
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/db2/
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/informix/
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/oracle/
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/sqlserver/
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/sybase/
Log:
TEIID-360 TEIID-359 TEIID-357 TEIID-356 TEIID-354 TEIID-353 TEIID-352 TEIID-164 jdbc connector api cleanup. created canonical push-down function list, changed the SQLTranslator to handle the tasks that were previously in specific SQLConversionVisitors.
15 years, 10 months
teiid SVN: r476 - in trunk: connector-api/src/main/java/com/metamatrix/connector/language and 58 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-02-19 12:59:09 -0500 (Thu, 19 Feb 2009)
New Revision: 476
Added:
trunk/connector-api/src/main/java/com/metamatrix/connector/api/SourceSystemFunctions.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LeftOrRightFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/ModFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleTranslator.java
Removed:
trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICaseExpression.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2ResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLModificationVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2UserIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyTimestampFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyUserIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixUserIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLSingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLUserIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/FormatFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/HourFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LeftOrRightFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ParseFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLSingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLUserIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/SubstringFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerConvertModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerModModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerUserIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/FormatTimestampModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/ModFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseUserIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestFormatFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestHourFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestParseFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConvertModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestFormatTimestampModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestModFunctionModifier.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialConversionVisitor.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/SpatialHint.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/SpatialSelectProxy.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CaseExpressionImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCaseExpressionImpl.java
Modified:
trunk/connector-api/src/main/java/com/metamatrix/connector/api/TypeFacility.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IJoin.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILanguageFactory.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILimit.java
trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataID.java
trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/AbstractLanguageVisitor.java
trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/DelegatingHierarchyVisitor.java
trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/HierarchyVisitor.java
trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/LanguageObjectVisitor.java
trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/CollectorVisitor.java
trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/SQLStringVisitor.java
trunk/connector-api/src/test/java/com/metamatrix/data/transform/TestBasicValueTranslator.java
trunk/connector-sdk/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCProcedureExecution.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCQueryExecution.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUpdateExecution.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2Capabilities.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyCapabilities.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/BindValueVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/TranslatedCommand.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ValueRetriever.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicValueRetriever.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLCapabilities.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLConvertModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleCapabilities.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleConvertModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLCapabilities.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLConvertModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerCapabilities.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ssl/JDBCSequeLinkSingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseConvertModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/util/FunctionReplacementVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSourceXAConnection.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/TestJDBCSourceConnection.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/access/TestAccessSQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2ConvertModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2SqlTranslator.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/derby/TestDerbyConvertModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/mysql/TestMySQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestExtractFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLeftOrRightFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLocateFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLog10FunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleConvertModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestSubstringFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseConvertModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
trunk/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
trunk/connectors/connector-xml-common/
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialSQLTranslator.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/TypeFacilityImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/BaseLanguageObject.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageBridgeFactory.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageFactoryImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataFactory.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataIDImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataObjectImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterIDImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureIDImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java
trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java
trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Function.java
trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestElementImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestInsertImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/metadata/TestMetadataFactory.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestLimit.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java
trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java
trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataID.java
trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestParams.java
trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestProcedure.java
trunk/test-integration/src/test/java/com/metamatrix/data/visitor/util/TestSQLStringVisitor.java
Log:
TEIID-360 TEIID-359 TEIID-357 TEIID-356 TEIID-354 TEIID-353 TEIID-352 TEIID-164 jdbc connector api cleanup. created canonical push-down function list, changed the SQLTranslator to handle the tasks that were previously in specific SQLConversionVisitors.
Added: trunk/connector-api/src/main/java/com/metamatrix/connector/api/SourceSystemFunctions.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/SourceSystemFunctions.java (rev 0)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/SourceSystemFunctions.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -0,0 +1,144 @@
+/*
+ * 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 com.metamatrix.connector.api;
+
+/**
+ * Constants for all the possible standard system push down functions.
+ * The names and function forms follow the Open Group CLI functions, with a few exceptions
+ * (such as lpad, rpad, bitand, bitor, etc. which are most notably supported by Oracle).
+ *
+ */
+public class SourceSystemFunctions {
+
+ //arithmetic
+ public static final String MULTIPLY_OP = "*";
+ public static final String ADD_OP = "+";
+ public static final String SUBTRACT_OP = "-";
+ public static final String DIVIDE_OP = "/";
+
+ //String
+ public static final String ASCII = "ascii";
+ public static final String CHAR = "char";
+ public static final String CONCAT = "concat";
+ //public static final String DIFFERENCE = "difference";
+ public static final String INITCAP = "initcap";
+ public static final String INSERT = "insert";
+ public static final String LCASE = "lcase";
+ public static final String LPAD = "lpad";
+ public static final String LEFT = "left";
+ public static final String LENGTH = "length";
+ public static final String LOCATE = "locate";
+ public static final String LTRIM = "ltrim";
+ public static final String REPEAT = "repeat";
+ public static final String REPLACE = "replace";
+ public static final String RIGHT = "right";
+ public static final String RPAD = "rpad";
+ public static final String RTRIM = "rtrim";
+ //public static final String SOUNDEX = "soundex";
+ public static final String SUBSTRING = "substring";
+ public static final String UCASE = "ucase";
+
+ //numeric
+ public static final String ABS = "abs";
+ public static final String ACOS = "acos";
+ public static final String ASIN = "asin";
+ public static final String ATAN = "atan";
+ public static final String ATAN2 = "atan2";
+ public static final String CEILING = "ceiling";
+ public static final String COS = "cos";
+ public static final String COT = "cot";
+ public static final String DEGREES = "degrees";
+ public static final String EXP = "exp";
+ public static final String FLOOR = "floor";
+ public static final String FORMATINTEGER = "formatinteger";
+ public static final String FORMATLONG = "formatlong";
+ public static final String FORMATDOUBLE = "formatdouble";
+ public static final String FORMATFLOAT = "formatfloat";
+ public static final String FORMATBIGINTEGER = "formatbiginteger";
+ public static final String FORMATBIGDECIMAL = "formatbigdecimal";
+ public static final String LOG = "log";
+ public static final String LOG10 = "log10";
+ public static final String MOD = "mod";
+ public static final String PARSEINTEGER = "parseinteger";
+ public static final String PARSELONG = "parselong";
+ public static final String PARSEDOUBLE = "parsedouble";
+ public static final String PARSEFLOAT = "parsefloat";
+ public static final String PARSEBIGINTEGER = "parsebiginteger";
+ public static final String PARSEBIGDECIMAL = "parsebigdecimal";
+ public static final String PI = "pi";
+ public static final String POWER = "power";
+ public static final String RADIANS = "radians";
+ public static final String RAND = "rand";
+ public static final String ROUND = "round";
+ public static final String SIGN = "sign";
+ public static final String SIN = "sin";
+ public static final String SQRT = "sqrt";
+ public static final String TAN = "tan";
+ public static final String TRANSLATE = "translate";
+ public static final String TRUNCATE = "truncate";
+
+ //bit
+ public static final String BITAND = "bitand";
+ public static final String BITOR = "bitor";
+ public static final String BITNOT = "bitnot";
+ public static final String BITXOR = "bitxor";
+
+ //date functions
+ public static final String CURDATE = "curdate";
+ public static final String CURTIME = "curtime";
+ public static final String DAYNAME = "dayname";
+ public static final String DAYOFMONTH = "dayofmonth";
+ public static final String DAYOFWEEK = "dayofweek";
+ public static final String DAYOFYEAR = "dayofyear";
+ public static final String FORMATDATE = "formatdate";
+ public static final String FORMATTIME = "formattime";
+ public static final String FORMATTIMESTAMP = "formattimestamp";
+ public static final String HOUR = "hour";
+ public static final String MINUTE = "minute";
+ public static final String MODIFYTIMEZONE = "modifytimezone";
+ public static final String MONTH = "month";
+ public static final String MONTHNAME = "monthname";
+ public static final String NOW = "now";
+ public static final String PARSEDATE = "parsedate";
+ public static final String PARSETIME = "parsetime";
+ public static final String PARSETIMESTAMP = "parsetimestamp";
+ public static final String QUARTER = "quarter";
+ public static final String SECOND = "second";
+ public static final String TIMESTAMPADD = "timestampadd";
+ public static final String TIMESTAMPCREATE = "timestampcreate";
+ public static final String TIMESTAMPDIFF = "timestampdiff";
+ public static final String WEEK = "week";
+ public static final String YEAR = "year";
+
+ //system functions
+ public static final String IFNULL = "ifnull";
+ public static final String COALESCE = "coalesce";
+ public static final String NULLIF = "nullif";
+
+ //conversion functions
+ public static final String CONVERT = "convert";
+
+ //xml
+ public static final String XPATHVALUE = "xpathvalue";
+
+}
Property changes on: trunk/connector-api/src/main/java/com/metamatrix/connector/api/SourceSystemFunctions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/TypeFacility.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/TypeFacility.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/TypeFacility.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,6 +22,9 @@
package com.metamatrix.connector.api;
+import java.util.Calendar;
+import java.util.TimeZone;
+
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.MMJDBCSQLTypeInfo;
@@ -72,18 +75,61 @@
public static final String XML = DataTypeManager.DefaultDataTypes.XML;
}
- public static Class getDataTypeClass(String type) {
+ /**
+ * Get the Class constant for the given String type name
+ */
+ public static Class<?> getDataTypeClass(String type) {
return DataTypeManager.getDataTypeClass(type);
}
- public static final int getSQLTypeFromRuntimeType(Class type) {
+ /**
+ * Get the SQL type for the given runtime type Class constant
+ * @param type
+ * @return
+ */
+ public static final int getSQLTypeFromRuntimeType(Class<?> type) {
return MMJDBCSQLTypeInfo.getSQLTypeFromRuntimeType(type);
}
- public abstract boolean hasTransformation(Class sourceClass, Class targetClass);
+ /**
+ * Checks if the given transformation exists.
+ * @param <S>
+ * @param <T>
+ * @param sourceClass
+ * @param targetClass
+ * @return
+ */
+ public abstract <S, T> boolean hasTransformation(Class<S> sourceClass, Class<T> targetClass);
- public abstract <T> T transformValue(Object value, Class sourceClass, Class<T> targetClass) throws ConnectorException;
+ /**
+ * Transform the given value into the target type, or throw an exception if this is not
+ * possible.
+ * @param <S>
+ * @param <T>
+ * @param value
+ * @param sourceClass
+ * @param targetClass
+ * @return
+ * @throws ConnectorException
+ */
+ public abstract <S, T> T transformValue(S value, Class<S> sourceClass, Class<T> targetClass) throws ConnectorException;
+ /**
+ * Convert the given value to the closest runtime type see {@link RUNTIME_TYPES}
+ * @param value
+ * @return
+ */
public abstract Object convertToRuntimeType(Object value);
+ /**
+ * Convert the given date to a target type, optionally adjusting its display
+ * for a given target Calendar.
+ * @param date
+ * @param initial
+ * @param target
+ * @param targetType
+ * @return
+ */
+ public abstract Object convertDate(java.util.Date date, TimeZone initial, Calendar target, Class targetType);
+
}
Deleted: trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICaseExpression.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICaseExpression.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICaseExpression.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,89 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.language;
-
-/**
- * Represents a non-searched CASE expression:
- * <br/> CASE expression WHEN expression THEN expression ... END
- */
-public interface ICaseExpression extends IExpression {
-
- /**
- * Gets the expression whose evaluation is tested against the WHEN expressions
- * @return the expression
- */
- IExpression getExpression();
-
- /**
- * Sets the expression whose evaluation is tested against the WHEN expressions
- * @param expression The expression
- */
- void setExpression(IExpression expression);
-
- /**
- * Gets the number of WHEN and THEN clauses in the CASE expression
- * @return the number of WHEN ... THEN ... parts
- */
- int getWhenCount();
-
- /**
- * Gets the WHEN expression at the specified index
- * @param index the 0-based index
- * @return the WHEN expression at the index
- */
- IExpression getWhenExpression(int index);
-
- /**
- * Sets the WHEN expression at the specified index
- * @param index the 0-based index
- * @param expression The new WHEN expression at the index
- */
- void setWhenExpression(int index, IExpression expression);
-
- /**
- * Gets the THEN expression at the specified index
- * @param index the 0-based index
- * @return the THEN expression at the index
- */
- IExpression getThenExpression(int index);
-
- /**
- * Sets the THEN expression at the specified index
- * @param index the 0-based index
- * @param expression The new THEN expression at the index
- */
- void setThenExpression(int index, IExpression expression);
-
- /**
- * Gets the ELSE expression, if defined. Can be null.
- * @return the ELSE expression.
- */
- IExpression getElseExpression();
-
- /**
- * Sets the ELSE expression
- * @param expression The new ELSE expression
- */
- void setElseExpression(IExpression expression);
-
-}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IJoin.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IJoin.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IJoin.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -94,5 +94,5 @@
* Set List of CompareCriteria specifying join criteria.
* @param criteria List of Criteria
*/
- void setCriteria(List<ICriteria> criteria);
+ void setCriteria(List<? extends ICriteria> criteria);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILanguageFactory.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILanguageFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILanguageFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -46,17 +46,6 @@
IAggregate createAggregate(String name, boolean isDistinct, IExpression expression, Class type);
/**
- * Create case expression.
- * @param mainExpression First expression in the case, used to choose WHEN clause
- * @param whenExpressions List of when expressions, should match thenExpressions
- * @param thenExpressions List of then expressions, should match whenExpressions
- * @param elseExpression Else expression, may be null
- * @param type Data type
- * @return New ICaseExpression
- */
- ICaseExpression createCaseExpression(IExpression mainExpression, List<IExpression> whenExpressions, List<IExpression> thenExpressions, IExpression elseExpression, Class type);
-
- /**
* Create compare criteria.
* @param operator Operator, as defined in constants in {@link ICompareCriteria}
* @param leftExpression Left expression
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILimit.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILimit.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILimit.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -37,8 +37,8 @@
int getRowLimit();
/**
- * Gets the offset (relative to the sarting row of the produced resultset) of the
- * first row returned by the connector.
+ * Gets the offset (relative to the starting row of the produced resultset) of the
+ * first row returned by the connector. 0 or less indicates no offset.
* @return
* @since 5.0 SP1
*/
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataID.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataID.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataID.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -31,11 +31,12 @@
*/
public interface MetadataID {
- public static final int TYPE_ELEMENT = 0;
- public static final int TYPE_GROUP = 1;
- public static final int TYPE_PROCEDURE = 2;
- public static final int TYPE_PARAMETER = 3;
-
+ public enum Type {
+ TYPE_ELEMENT,
+ TYPE_GROUP,
+ TYPE_PARAMETER,
+ TYPE_PROCEDURE
+ }
/**
* Get the type of metadataID
* @return ID type
@@ -44,7 +45,7 @@
* @see #TYPE_PROCEDURE
* @see #TYPE_PARAMETER
*/
- int getType();
+ Type getType();
/**
* Get a list of child IDs from this ID. A group metadata ID will
@@ -71,4 +72,10 @@
* @return String fullName
*/
String getFullName();
+
+ /**
+ * Get the {@link MetadataObject} for this id
+ * @return
+ */
+ MetadataObject getMetadataObject() throws ConnectorException;
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/AbstractLanguageVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/AbstractLanguageVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/AbstractLanguageVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -27,7 +27,6 @@
import com.metamatrix.connector.language.IAggregate;
import com.metamatrix.connector.language.IBatchedUpdates;
import com.metamatrix.connector.language.IBulkInsert;
-import com.metamatrix.connector.language.ICaseExpression;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICompoundCriteria;
import com.metamatrix.connector.language.IDelete;
@@ -116,7 +115,6 @@
public void visit(IAggregate obj) {}
public void visit(IBatchedUpdates obj) {}
- public void visit(ICaseExpression obj) {}
public void visit(ICompareCriteria obj) {}
public void visit(ICompoundCriteria obj) {}
public void visit(IDelete obj) {}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/DelegatingHierarchyVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/DelegatingHierarchyVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/DelegatingHierarchyVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -23,7 +23,42 @@
package com.metamatrix.connector.visitor.framework;
import com.metamatrix.connector.DataPlugin;
-import com.metamatrix.connector.language.*;
+import com.metamatrix.connector.language.IAggregate;
+import com.metamatrix.connector.language.IBatchedUpdates;
+import com.metamatrix.connector.language.ICompareCriteria;
+import com.metamatrix.connector.language.ICompoundCriteria;
+import com.metamatrix.connector.language.IDelete;
+import com.metamatrix.connector.language.IElement;
+import com.metamatrix.connector.language.IExistsCriteria;
+import com.metamatrix.connector.language.IFrom;
+import com.metamatrix.connector.language.IFunction;
+import com.metamatrix.connector.language.IGroup;
+import com.metamatrix.connector.language.IGroupBy;
+import com.metamatrix.connector.language.IInCriteria;
+import com.metamatrix.connector.language.IInlineView;
+import com.metamatrix.connector.language.IInsert;
+import com.metamatrix.connector.language.IIsNullCriteria;
+import com.metamatrix.connector.language.IJoin;
+import com.metamatrix.connector.language.ILanguageObject;
+import com.metamatrix.connector.language.ILikeCriteria;
+import com.metamatrix.connector.language.ILimit;
+import com.metamatrix.connector.language.ILiteral;
+import com.metamatrix.connector.language.INotCriteria;
+import com.metamatrix.connector.language.IOrderBy;
+import com.metamatrix.connector.language.IOrderByItem;
+import com.metamatrix.connector.language.IParameter;
+import com.metamatrix.connector.language.IProcedure;
+import com.metamatrix.connector.language.IQuery;
+import com.metamatrix.connector.language.IScalarSubquery;
+import com.metamatrix.connector.language.ISearchedCaseExpression;
+import com.metamatrix.connector.language.ISelect;
+import com.metamatrix.connector.language.ISelectSymbol;
+import com.metamatrix.connector.language.ISetClause;
+import com.metamatrix.connector.language.ISetClauseList;
+import com.metamatrix.connector.language.ISetQuery;
+import com.metamatrix.connector.language.ISubqueryCompareCriteria;
+import com.metamatrix.connector.language.ISubqueryInCriteria;
+import com.metamatrix.connector.language.IUpdate;
/**
* Delegates pre- and post-processing for each node in the hierarchy to
@@ -70,15 +105,7 @@
postVisitor.visit(obj);
}
}
- public void visit(ICaseExpression obj) {
- if (preVisitor != null) {
- preVisitor.visit(obj);
- }
- super.visit(obj);
- if (postVisitor != null) {
- postVisitor.visit(obj);
- }
- }
+
public void visit(ICompareCriteria obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/HierarchyVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/HierarchyVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/HierarchyVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -24,7 +24,6 @@
import com.metamatrix.connector.language.IAggregate;
import com.metamatrix.connector.language.IBatchedUpdates;
-import com.metamatrix.connector.language.ICaseExpression;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICompoundCriteria;
import com.metamatrix.connector.language.IDelete;
@@ -82,16 +81,6 @@
visitNodes(obj.getUpdateCommands());
}
- public void visit(ICaseExpression obj) {
- visitNode(obj.getExpression());
- int whenCount = obj.getWhenCount();
- for (int i = 0; i < whenCount; i++) {
- visitNode(obj.getWhenExpression(i));
- visitNode(obj.getThenExpression(i));
- }
- visitNode(obj.getElseExpression());
- }
-
public void visit(ICompareCriteria obj) {
visitNode(obj.getLeftExpression());
visitNode(obj.getRightExpression());
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/LanguageObjectVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/LanguageObjectVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/LanguageObjectVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -30,7 +30,6 @@
public void visit(IAggregate obj);
public void visit(IBatchedUpdates obj);
public void visit(IBulkInsert obj);
- public void visit(ICaseExpression obj);
public void visit(ICompareCriteria obj);
public void visit(ICompoundCriteria obj);
public void visit(IDelete obj);
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/CollectorVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/CollectorVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/CollectorVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -68,13 +68,6 @@
}
/*
- * @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ICaseExpression)
- */
- public void visit(ICaseExpression obj) {
- checkInstance(obj);
- }
-
- /*
* @see com.metamatrix.data.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.data.language.ICompareCriteria)
*/
public void visit(ICompareCriteria obj) {
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/SQLStringVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/SQLStringVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/SQLStringVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -29,7 +29,7 @@
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IAggregate;
import com.metamatrix.connector.language.IBulkInsert;
-import com.metamatrix.connector.language.ICaseExpression;
+import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICompoundCriteria;
import com.metamatrix.connector.language.ICriteria;
@@ -72,7 +72,6 @@
import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.visitor.framework.AbstractLanguageVisitor;
import com.metamatrix.core.util.StringUtil;
@@ -87,7 +86,6 @@
protected static final String UNDEFINED = "<undefined>"; //$NON-NLS-1$
protected static final String UNDEFINED_PARAM = "?"; //$NON-NLS-1$
- protected RuntimeMetadata metadata;
protected StringBuffer buffer = new StringBuffer();
/**
@@ -96,12 +94,8 @@
* @return the name of that element or group as defined in the source
*/
protected String getName(MetadataID id) {
- if (metadata == null) {
- return id.getName();
- }
-
try {
- MetadataObject obj = metadata.getObject(id);
+ MetadataObject obj = id.getMetadataObject();
if (obj == null) {
return id.getName();
}
@@ -193,84 +187,6 @@
}
/**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.connector.language.ICaseExpression)
- */
- public void visit(ICaseExpression obj) {
- final IElement element = obj.getExpression() instanceof IElement ? (IElement)obj.getExpression() : null;
- final IFunction function = obj.getExpression() instanceof IFunction ? (IFunction)obj.getExpression() : null ;
-
- buffer.append(CASE);
- buffer.append(SPACE);
-
- // checking for null compare in decode string case 2969 GCSS
- for (int i =0; i < obj.getWhenCount(); i++) {
- if (NULL.equalsIgnoreCase(obj.getWhenExpression(i).toString() ) ) {
- buffer.append(WHEN);
- buffer.append(SPACE);
-
- if(element != null) {
- visit(element);
- }else if(function != null) {
- visit(function);
- }else {
- append(obj.getExpression() );
- }
-
- buffer.append(SPACE);
- buffer.append(IS);
- buffer.append(SPACE);
- buffer.append(NULL);
- buffer.append(SPACE);
- buffer.append(THEN);
- buffer.append(SPACE);
- append(obj.getThenExpression(i));
- buffer.append(SPACE);
- }
- }
-
- for (int i = 0; i < obj.getWhenCount(); i++) {
- if(!NULL.equalsIgnoreCase(obj.getWhenExpression(i).toString() ) ) {
- buffer.append(WHEN);
- buffer.append(SPACE);
-
- if(element != null) {
- visit(element);
- }else if(function != null) {
- visit(function);
- }else {
- append(obj.getExpression() );
- }
-
- buffer.append(EQ);
- append(obj.getWhenExpression(i));
- buffer.append(SPACE);
- buffer.append(THEN);
- buffer.append(SPACE);
- append(obj.getThenExpression(i));
- buffer.append(SPACE);
- }
- }
-
- if (obj.getElseExpression() != null) {
- buffer.append(ELSE);
- buffer.append(SPACE);
- if(obj.getElseExpression() instanceof IElement || obj.getElseExpression() instanceof IFunction) {
- if(element != null) {
- visit(element);
- }else if(function != null) {
- visit(function);
- }else {
- append(obj.getExpression() );
- }
- }else {
- append(obj.getElseExpression());
- }
- buffer.append(SPACE);
- }
- buffer.append(END);
- }
-
- /**
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.connector.language.ICompareCriteria)
*/
public void visit(ICompareCriteria obj) {
@@ -329,7 +245,7 @@
public void visit(IDelete obj) {
buffer.append(DELETE)
.append(SPACE);
- buffer.append(addProcessComment());
+ buffer.append(getSourceComment(obj));
buffer.append(FROM)
.append(SPACE);
append(obj.getGroup());
@@ -365,9 +281,13 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.connector.language.IElement)
*/
public void visit(IElement obj) {
- String groupName = null;
+ buffer.append(getElementName(obj, true));
+ }
+
+ private String getElementName(IElement obj, boolean qualify) {
+ String groupName = null;
IGroup group = obj.getGroup();
- if (group != null) {
+ if (group != null && qualify) {
if(group.getDefinition() != null) {
groupName = group.getContext();
} else {
@@ -380,24 +300,6 @@
}
}
- String elemShortName = getElementShortName(obj);
-
- // Check whether a subclass wants to replace the element name to use in special circumstances
- String replacementElement = replaceElementName(groupName, elemShortName);
- if(replacementElement != null) {
- // If so, use it as is
- buffer.append(replacementElement);
- } else {
- // If not, do normal logic: [group + "."] + element
- if(groupName != null) {
- buffer.append(groupName);
- buffer.append(DOT);
- }
- buffer.append(elemShortName);
- }
- }
-
- public String getElementShortName(IElement obj) {
String elemShortName = null;
MetadataID elementID = obj.getMetadataID();
if(elementID != null) {
@@ -406,19 +308,29 @@
String elementName = obj.getName();
elemShortName = getShortName(elementName);
}
- return elemShortName;
- }
+ // Check whether a subclass wants to replace the element name to use in special circumstances
+ String replacementElement = replaceElementName(groupName, elemShortName);
+ if(replacementElement != null) {
+ // If so, use it as is
+ return replacementElement;
+ }
+ StringBuffer elementName = new StringBuffer(elemShortName.length());
+ // If not, do normal logic: [group + "."] + element
+ if(groupName != null) {
+ elementName.append(groupName);
+ elementName.append(DOT);
+ }
+ elementName.append(elemShortName);
+ return elementName.toString();
+ }
+
/**
* @param elementName
* @return
* @since 4.3
*/
- public String getShortName(String elementName) {
- return getElementShortName(elementName);
- }
-
- public static String getElementShortName(String elementName) {
+ public static String getShortName(String elementName) {
int lastDot = elementName.lastIndexOf("."); //$NON-NLS-1$
if(lastDot >= 0) {
elementName = elementName.substring(lastDot+1);
@@ -490,30 +402,12 @@
IExpression[] args = obj.getParameters();
if(name.equalsIgnoreCase(CONVERT) || name.equalsIgnoreCase(CAST)) {
- // Need to support both Oracle style convert - convert(expression, type)
- // and SQL Server style convert - convert(type, expression)
- Object firstArg = null;
- Object secondArg = null;
- if (args[1] instanceof IElement) {
- Object typeValue = ((ILiteral)args[0]).getValue();
- Object expression = args[1];
- firstArg = typeValue;
- secondArg = expression;
- } else {
- Object typeValue = ((ILiteral)args[1]).getValue();
- Object expression = args[0];
- firstArg = expression;
- secondArg = typeValue;
- }
+ Object typeValue = ((ILiteral)args[1]).getValue();
buffer.append(name);
buffer.append(LPAREN);
- if(firstArg instanceof IExpression) {
- this.append( (IExpression)firstArg);
- }else {
- buffer.append(firstArg);
- }
+ append(args[0]);
if(name.equalsIgnoreCase(CONVERT)) {
buffer.append(COMMA);
@@ -523,15 +417,9 @@
buffer.append(AS);
buffer.append(SPACE);
}
-
- if(secondArg instanceof IExpression) {
- this.append( (IExpression)secondArg);
- }else {
- buffer.append(secondArg);
- }
+ buffer.append(typeValue);
buffer.append(RPAREN);
-
- } else if(name.equals("+") || name.equals("-") || name.equals("*") || name.equals("/") || name.equals("||")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ } else if(name.equals("%") || name.equals("+") || name.equals("-") || name.equals("*") || name.equals("/") || name.equals("||")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
buffer.append(LPAREN);
if(args != null) {
@@ -669,7 +557,7 @@
private void formatBasicInsert(IInsert obj) {
buffer.append(INSERT)
.append(SPACE);
- buffer.append(addProcessComment());
+ buffer.append(getSourceComment(obj));
buffer.append(INTO)
.append(SPACE);
append(obj.getGroup());
@@ -679,13 +567,7 @@
int elementCount= obj.getElements().size();
for(int i=0; i<elementCount; i++) {
- String elementShortNmae = getElementShortName((IElement)obj.getElements().get( i ));
- String replacedEmentShortNmae = getElementTrueName(elementShortNmae);
- if(replacedEmentShortNmae != null){
- buffer.append(replacedEmentShortNmae);
- }else{
- buffer.append(elementShortNmae);
- }
+ buffer.append(getElementName(obj.getElements().get(i), false));
if (i<elementCount-1) {
buffer.append(COMMA);
buffer.append(SPACE);
@@ -696,10 +578,6 @@
}
}
- protected String getElementTrueName(String element) {
- return null;
- }
-
public void visit(IBulkInsert obj) {
formatBasicInsert(obj);
buffer.append(SPACE)
@@ -934,11 +812,7 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.connector.language.IQuery)
*/
public void visit(IQuery obj) {
- appendQuery(obj);
- }
-
- protected void appendQuery(IQuery obj) {
- append(obj.getSelect());
+ visitSelect(obj.getSelect(), obj);
if (obj.getFrom() != null) {
buffer.append(SPACE);
append(obj.getFrom());
@@ -999,29 +873,23 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.connector.language.ISelect)
*/
public void visit(ISelect obj) {
- visitSelect(obj);
+ visitSelect(obj, null);
}
-
- protected String addProcessComment() {
- return ""; //$NON-NLS-1$
- }
-
- /**
- * This method outputs the 'SELECT' keyword and select symbols. Subclasses
- * should override to change/add behavior.
- * @param obj ISelect object
- * @since 4.3
- */
- protected void visitSelect(ISelect obj) {
- buffer.append(SELECT).append(SPACE);
- buffer.append(addProcessComment());
+ private void visitSelect(ISelect obj, ICommand command) {
+ buffer.append(SELECT).append(SPACE);
+ buffer.append(getSourceComment(command));
if (obj.isDistinct()) {
buffer.append(DISTINCT).append(SPACE);
}
append(obj.getSelectSymbols());
- }
+ }
+
+ protected String getSourceComment(ICommand command) {
+ return ""; //$NON-NLS-1$
+ }
+
/*
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IScalarSubquery)
*/
@@ -1095,7 +963,7 @@
public void visit(IUpdate obj) {
buffer.append(UPDATE)
.append(SPACE);
- buffer.append(addProcessComment());
+ buffer.append(getSourceComment(obj));
append(obj.getGroup());
buffer.append(SPACE)
.append(SET)
@@ -1114,7 +982,7 @@
}
public void visit(ISetClause clause) {
- buffer.append(getElementShortName(clause.getSymbol()));
+ buffer.append(getElementName(clause.getSymbol(), false));
buffer.append(SPACE).append(EQ).append(SPACE);
append(clause.getValue());
}
@@ -1123,6 +991,7 @@
appendSetQuery(obj.getLeftQuery());
buffer.append(SPACE);
+
appendSetOperation(obj.getOperation());
if(obj.isAll()) {
@@ -1149,14 +1018,18 @@
protected void appendSetOperation(ISetQuery.Operation operation) {
buffer.append(operation);
}
+
+ protected boolean useParensForSetQueries() {
+ return false;
+ }
protected void appendSetQuery(IQueryCommand obj) {
- if(obj instanceof ISetQuery) {
+ if(obj instanceof ISetQuery || useParensForSetQueries()) {
buffer.append(LPAREN);
append(obj);
buffer.append(RPAREN);
} else {
- appendQuery((IQuery)obj);
+ append(obj);
}
}
@@ -1167,15 +1040,10 @@
* command
* @return the SQL representation of that ILanguageObject hierarchy
*/
- public static String getSQLString(ILanguageObject obj, RuntimeMetadata metadata) {
+ public static String getSQLString(ILanguageObject obj) {
SQLStringVisitor visitor = new SQLStringVisitor();
- visitor.setRuntimeMetadata(metadata);
visitor.append(obj);
return visitor.toString();
}
- public void setRuntimeMetadata(RuntimeMetadata metadata) {
- this.metadata = metadata;
- }
-
}
Modified: trunk/connector-api/src/test/java/com/metamatrix/data/transform/TestBasicValueTranslator.java
===================================================================
--- trunk/connector-api/src/test/java/com/metamatrix/data/transform/TestBasicValueTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/test/java/com/metamatrix/data/transform/TestBasicValueTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -37,9 +37,8 @@
*/
public class TestBasicValueTranslator extends TestCase {
-
public void testExceptionFromTransform() throws Exception {
- BasicValueTranslator<String, Short> adaptor = BasicValueTranslator.createTranslator(String.class, Short.class, new FakeTypeFacility());
+ BasicValueTranslator<String, Short> adaptor = BasicValueTranslator.createTranslator(String.class, Short.class, Mockito.mock(TypeFacility.class));
try {
adaptor.translate("mmuuid:blah", Mockito.mock(ExecutionContext.class)); //$NON-NLS-1$
fail("exceptoin expected"); //$NON-NLS-1$
@@ -48,22 +47,4 @@
}
}
- static class FakeTypeFacility extends TypeFacility{
-
- @Override
- public boolean hasTransformation(Class sourceClass, Class targetClass) {
- return false;
- }
-
- @Override
- public Object transformValue(Object value, Class sourceClass, Class targetClass) throws ConnectorException {
- throw new ConnectorException("not supported");
- }
-
- @Override
- public Object convertToRuntimeType(Object value) {
- return value;
- }
- }
-
}
Modified: trunk/connector-sdk/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java
===================================================================
--- trunk/connector-sdk/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-sdk/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -24,6 +24,7 @@
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.query.unittest.FakeMetadataFactory;
+import com.metamatrix.query.validator.TestValidator;
public class FakeTranslationFactory {
@@ -45,4 +46,8 @@
return new TranslationUtility(FakeMetadataFactory.exampleText());
}
+ public TranslationUtility getAutoIncrementTranslationUtility() {
+ return new TranslationUtility(TestValidator.exampleMetadata3());
+ }
+
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -43,7 +43,6 @@
protected ConnectorEnvironment environment;
private ConnectorLogger logger;
private JDBCSourceConnectionFactory factory;
-
private ConnectorCapabilities capabilities;
static ConnectorCapabilities createCapabilities(ConnectorEnvironment environment, ClassLoader loader)
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCProcedureExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCProcedureExecution.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCProcedureExecution.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -50,7 +50,6 @@
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.core.util.StringUtil;
/**
*/
@@ -90,9 +89,6 @@
//create statement or CallableStatement and execute
String sql = translatedComm.getSql();
try{
- if(translatedComm.getStatementType() != TranslatedCommand.STMT_TYPE_CALLABLE_STATEMENT){
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSynchExecution.Statement_type_not_support_for_command_1", new Integer(translatedComm.getStatementType()), sql)); //$NON-NLS-1$
- }
//create parameter index map
parameterIndexMap = createParameterIndexMap(procedure.getParameters(), sql);
CallableStatement cstmt = getCallableStatement(sql);
@@ -200,7 +196,7 @@
if(value == null){
return null;
}
- Object result = JDBCExecutionHelper.convertValue(value, parameter.getType(), this.resultsTranslator.getValueTranslators(), this.resultsTranslator.getTypefacility(), trimString, context);
+ Object result = JDBCExecutionHelper.convertValue(value, parameter.getType(), this.resultsTranslator.getValueTranslators(), this.resultsTranslator.getTypeFacility(), trimString, context);
return result;
} catch (SQLException e) {
throw new ConnectorException(e);
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCQueryExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCQueryExecution.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCQueryExecution.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -107,16 +107,13 @@
try {
- if (translatedComm.getStatementType() == TranslatedCommand.STMT_TYPE_STATEMENT) {
+ if (!translatedComm.isPrepared()) {
results = getStatement().executeQuery(sql);
- } else if (translatedComm.getStatementType() == TranslatedCommand.STMT_TYPE_PREPARED_STATEMENT) {
- PreparedStatement pstatement = getPreparedStatement(sql);
+ } else {
+ PreparedStatement pstatement = getPreparedStatement(sql);
resultsTranslator.bindPreparedStatementValues(this.connection, pstatement, translatedComm);
results = pstatement.executeQuery();
- } else {
- throw new ConnectorException(
- JDBCPlugin.Util.getString("JDBCSynchExecution.Statement_type_not_support_for_command_1", new Integer(translatedComm.getStatementType()), sql)); //$NON-NLS-1$
- }
+ }
addStatementWarnings();
initResultSetInfo();
@@ -157,13 +154,13 @@
for (int i = 0; i < columnDataTypes.length; i++) {
// Convert from 0-based to 1-based
- Object value = resultsTranslator.getValueRetriever().retrieveValue(results, i+1, columnDataTypes[i], nativeTypes[i], calendar, env.getTypeFacility());
+ Object value = resultsTranslator.getValueRetriever().retrieveValue(results, i+1, columnDataTypes[i], calendar, env.getTypeFacility());
if(value != null) {
// Determine transformation if unknown
if(! transformKnown[i]) {
Class valueType = value.getClass();
if(!columnDataTypes[i].isAssignableFrom(valueType)) {
- transforms[i] = JDBCExecutionHelper.determineTransformation(valueType, columnDataTypes[i], resultsTranslator.getValueTranslators(), resultsTranslator.getTypefacility());
+ transforms[i] = JDBCExecutionHelper.determineTransformation(valueType, columnDataTypes[i], resultsTranslator.getValueTranslators(), resultsTranslator.getTypeFacility());
}
transformKnown[i] = true;
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -25,7 +25,6 @@
package com.metamatrix.connector.jdbc;
import java.sql.SQLException;
-import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
@@ -50,87 +49,51 @@
protected java.sql.Connection physicalConnection;
protected ConnectorEnvironment environment;
private ConnectorLogger logger;
- private ResultsTranslator resultsTranslator;
private ConnectionStrategy connectionStrategy;
private ConnectionListener connectionListener;
- private Class sqlTransClass;
+ private SQLTranslator sqlTranslator;
+ private ResultsTranslator resultsTranslator;
+
/**
* @param connection
*/
- public JDBCSourceConnection(java.sql.Connection connection, ConnectorEnvironment environment, ConnectionStrategy connectionStrategy) throws ConnectorException{
- this(connection, environment, connectionStrategy, null);
+ public JDBCSourceConnection(java.sql.Connection connection, ConnectorEnvironment environment, ConnectionStrategy connectionStrategy, ResultsTranslator resultsTranslator, SQLTranslator sqlTranslator) throws ConnectorException{
+ this(connection, environment, connectionStrategy, null, resultsTranslator, sqlTranslator);
}
- public JDBCSourceConnection(java.sql.Connection connection, ConnectorEnvironment environment, ConnectionStrategy connectionStrategy, ConnectionListener connectionListener) throws ConnectorException {
+ public JDBCSourceConnection(java.sql.Connection connection, ConnectorEnvironment environment, ConnectionStrategy connectionStrategy, ConnectionListener connectionListener, ResultsTranslator resultsTranslator, SQLTranslator sqlTranslator) throws ConnectorException {
physicalConnection = connection;
this.environment = environment;
this.logger = environment.getLogger();
this.connectionStrategy = connectionStrategy;
this.connectionListener = connectionListener;
- try {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
- Properties connectorProps = environment.getProperties();
- //create SQLTranslator
- String className = connectorProps.getProperty(JDBCPropertyNames.EXT_SQL_TRANSLATOR_CLASS);
- if(className == null){
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnection.Property_{0}_is_required,_but_not_defined_1", JDBCPropertyNames.EXT_SQL_TRANSLATOR_CLASS)); //$NON-NLS-1$
- }
- sqlTransClass = Thread.currentThread().getContextClassLoader().loadClass(className);
-
- //create ResultsTranslator
- className = connectorProps.getProperty(JDBCPropertyNames.EXT_RESULTS_TRANSLATOR_CLASS);
- if(className == null){
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnection.Property_{0}_is_required,_but_not_defined_1", JDBCPropertyNames.EXT_RESULTS_TRANSLATOR_CLASS)); //$NON-NLS-1$
- }
- Class resultsTransClass = loader.loadClass(className);
- resultsTranslator = (ResultsTranslator) resultsTransClass.newInstance();
- resultsTranslator.initialize(environment);
- } catch (ClassNotFoundException e1) {
- throw new ConnectorException(e1);
- } catch (InstantiationException e2) {
- throw new ConnectorException(e2);
- } catch (IllegalAccessException e3) {
- throw new ConnectorException(e3);
- }
-
// notify the listner that coneection created
if (this.connectionListener != null) {
this.connectionListener.afterConnectionCreation(this.physicalConnection, this.environment);
}
}
- private SQLTranslator getSQLTranslator(RuntimeMetadata metadata) throws ConnectorException {
- try {
- SQLTranslator sqlTranslator = (SQLTranslator) sqlTransClass.newInstance();
- sqlTranslator.initialize(environment, metadata);
- return sqlTranslator;
- } catch (InstantiationException e) {
- throw new ConnectorException(e);
- } catch (IllegalAccessException e) {
- throw new ConnectorException(e);
- }
- }
-
@Override
public ResultSetExecution createResultSetExecution(IQueryCommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new JDBCQueryExecution(command, this.physicalConnection, getSQLTranslator(metadata), resultsTranslator, logger, this.environment.getProperties(), executionContext, this.environment);
+ return new JDBCQueryExecution(command, this.physicalConnection, sqlTranslator, resultsTranslator, logger, this.environment.getProperties(), executionContext, this.environment);
}
@Override
public ProcedureExecution createProcedureExecution(IProcedure command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new JDBCProcedureExecution(command, this.physicalConnection, getSQLTranslator(metadata), resultsTranslator, logger, this.environment.getProperties(), metadata, executionContext, this.environment);
+ return new JDBCProcedureExecution(command, this.physicalConnection, sqlTranslator, resultsTranslator, logger, this.environment.getProperties(), metadata, executionContext, this.environment);
}
@Override
public UpdateExecution createUpdateExecution(ICommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new JDBCUpdateExecution(command, this.physicalConnection, getSQLTranslator(metadata), resultsTranslator, logger, this.environment.getProperties(), executionContext);
+ return new JDBCUpdateExecution(command, this.physicalConnection, sqlTranslator, resultsTranslator, logger, this.environment.getProperties(), executionContext);
}
@Override
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -35,6 +35,8 @@
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.internal.ConnectorPropertyNames;
+import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.pool.ConnectorIdentity;
import com.metamatrix.connector.pool.ConnectorIdentityFactory;
@@ -53,6 +55,8 @@
private String deregisterType;
private ConnectorIdentityFactory connectorIdentityFactory;
+ private SQLTranslator sqlTranslator;
+ private ResultsTranslator resultsTranslator;
/**
*
@@ -65,6 +69,34 @@
this.environment = env;
Properties props = env.getProperties();
this.deregisterType = props.getProperty(ConnectorPropertyNames.DEREGISTER_DRIVER, ConnectorPropertyNames.DEREGISTER_BY_CLASSLOADER);
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+ Properties connectorProps = environment.getProperties();
+ //create SQLTranslator
+ String className = connectorProps.getProperty(JDBCPropertyNames.EXT_SQL_TRANSLATOR_CLASS);
+ if(className == null){
+ throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnection.Property_{0}_is_required,_but_not_defined_1", JDBCPropertyNames.EXT_SQL_TRANSLATOR_CLASS)); //$NON-NLS-1$
+ }
+ try {
+ Class sqlTransClass = Thread.currentThread().getContextClassLoader().loadClass(className);
+ sqlTranslator = (SQLTranslator) sqlTransClass.newInstance();
+ sqlTranslator.initialize(environment);
+
+ //create ResultsTranslator
+ className = connectorProps.getProperty(JDBCPropertyNames.EXT_RESULTS_TRANSLATOR_CLASS);
+ if(className == null){
+ throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnection.Property_{0}_is_required,_but_not_defined_1", JDBCPropertyNames.EXT_RESULTS_TRANSLATOR_CLASS)); //$NON-NLS-1$
+ }
+ Class resultsTransClass = loader.loadClass(className);
+ resultsTranslator = (ResultsTranslator) resultsTransClass.newInstance();
+ resultsTranslator.initialize(environment);
+ } catch (ClassNotFoundException e) {
+ throw new ConnectorException(e);
+ } catch (InstantiationException e) {
+ throw new ConnectorException(e);
+ } catch (IllegalAccessException e) {
+ throw new ConnectorException(e);
+ }
}
protected ConnectorEnvironment getConnectorEnvironment() {
@@ -117,7 +149,7 @@
throw new ConnectorException(e);
}
- return new JDBCSourceConnection(connection, this.environment, createConnectionStrategy(), getConnectionListener());
+ return new JDBCSourceConnection(connection, this.environment, createConnectionStrategy(), getConnectionListener(), resultsTranslator, sqlTranslator);
}
/**
@@ -187,4 +219,12 @@
return this.connectorIdentityFactory.createIdentity(context);
}
+ public ResultsTranslator getResultsTranslator() {
+ return resultsTranslator;
+ }
+
+ public SQLTranslator getSqlTranslator() {
+ return sqlTranslator;
+ }
+
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUpdateExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUpdateExecution.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUpdateExecution.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -109,16 +109,9 @@
for (int i = 0; i < commands.length; i++) {
TranslatedCommand command = translateCommand(commands[i]);
- if (command.getStatementType() == TranslatedCommand.STMT_TYPE_CALLABLE_STATEMENT) {
- throw new ConnectorException(
- JDBCPlugin.Util.getString("JDBCSynchExecution.Statement_type_not_support_for_command_1", //$NON-NLS-1$
- new Integer(command.getStatementType()),
- command.getSql()));
- }
- if (command.getStatementType() == TranslatedCommand.STMT_TYPE_PREPARED_STATEMENT) {
+ if (command.isPrepared()) {
PreparedStatement pstmt = null;
- if (previousCommand != null && previousCommand.getStatementType() == TranslatedCommand.STMT_TYPE_PREPARED_STATEMENT
- && previousCommand.getSql().equals(command.getSql())) {
+ if (previousCommand != null && previousCommand.isPrepared() && previousCommand.getSql().equals(command.getSql())) {
pstmt = (PreparedStatement)statement;
} else {
if (!executedCmds.isEmpty()) {
@@ -129,7 +122,7 @@
resultsTranslator.bindPreparedStatementValues(this.connection, pstmt, command);
pstmt.addBatch();
} else {
- if (previousCommand != null && previousCommand.getStatementType() == TranslatedCommand.STMT_TYPE_PREPARED_STATEMENT) {
+ if (previousCommand != null && previousCommand.isPrepared()) {
executeBatch(i, results, executedCmds);
getStatement();
}
@@ -220,18 +213,13 @@
try {
int updateCount;
- if (translatedComm.getStatementType() == TranslatedCommand.STMT_TYPE_STATEMENT) {
+ if (!translatedComm.isPrepared()) {
updateCount = getStatement().executeUpdate(sql);
- } else if (translatedComm.getStatementType() == TranslatedCommand.STMT_TYPE_PREPARED_STATEMENT) {
- PreparedStatement pstatement = getPreparedStatement(sql);
+ } else {
+ PreparedStatement pstatement = getPreparedStatement(sql);
resultsTranslator.bindPreparedStatementValues(this.connection, pstatement, translatedComm);
updateCount = pstatement.executeUpdate();
- } else {
- throw new ConnectorException(
- JDBCPlugin.Util.getString("JDBCSynchExecution.Statement_type_not_support_for_command_1", //$NON-NLS-1$
- new Integer(translatedComm.getStatementType()),
- sql));
- }
+ }
addStatementWarnings();
return updateCount;
} catch (SQLException err) {
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,99 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.access;
-
-import java.sql.Time;
-
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.language.IQuery;
-import com.metamatrix.connector.language.ISelect;
-
-public class AccessSQLConversionVisitor extends SQLConversionVisitor{
-
- private int limit = 0;
- /*
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#translateLiteralTime(java.sql.Time)
- */
- protected String translateLiteralTime(Time timeValue) {
- return "{ts'1900-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- protected String translateLiteralBoolean(Boolean booleanValue) {
- if(booleanValue.booleanValue()) {
- return "-1"; //$NON-NLS-1$
- }
- return "0"; //$NON-NLS-1$
- }
-
- protected void appendQuery(IQuery obj) {
- if (obj.getLimit() != null) {
- limit = obj.getLimit().getRowLimit();
- }
- append(obj.getSelect());
- if (obj.getFrom() != null) {
- buffer.append(SPACE);
- append(obj.getFrom());
- }
- if (obj.getWhere() != null) {
- buffer.append(SPACE)
- .append(WHERE)
- .append(SPACE);
- append(obj.getWhere());
- }
- if (obj.getGroupBy() != null) {
- buffer.append(SPACE);
- append(obj.getGroupBy());
- }
- if (obj.getHaving() != null) {
- buffer.append(SPACE)
- .append(HAVING)
- .append(SPACE);
- append(obj.getHaving());
- }
- if (obj.getOrderBy() != null) {
- buffer.append(SPACE);
- append(obj.getOrderBy());
- }
- }
-
- protected void visitSelect(ISelect obj) {
- buffer.append(SELECT).append(SPACE);
- if (limit > 0) {
- buffer.append("TOP") //$NON-NLS-1$
- .append(SPACE)
- .append(limit)
- .append(SPACE);
- limit = 0;
- }
- if (obj.isDistinct()) {
- buffer.append(DISTINCT).append(SPACE);
- }
- append(obj.getSelectSymbols());
- }
-
- protected boolean supportsComments() {
- return false;
- }
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.access;
-
-import java.util.Properties;
-
-import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-
-public class AccessSQLTranslator extends BasicSQLTranslator {
- private Properties connectorProperties;
- private ILanguageFactory languageFactory;
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getTranslationVisitor()
- */
- public SQLConversionVisitor getTranslationVisitor() {
- SQLConversionVisitor visitor = new AccessSQLConversionVisitor();
- visitor.setRuntimeMetadata(getRuntimeMetadata());
- visitor.setFunctionModifiers(getFunctionModifiers());
- visitor.setProperties(connectorProperties);
- visitor.setLanguageFactory(languageFactory);
- visitor.setDatabaseTimeZone(getDatabaseTimeZone());
- return visitor;
- }
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#initialize(com.metamatrix.data.api.ConnectorEnvironment, com.metamatrix.data.metadata.runtime.RuntimeMetadata)
- */
- public void initialize(ConnectorEnvironment env, RuntimeMetadata metadata) throws ConnectorException {
- super.initialize(env, metadata);
- connectorProperties = getConnectorEnvironment().getProperties();
- languageFactory = getConnectorEnvironment().getLanguageFactory();
- }
-}
Added: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -0,0 +1,57 @@
+/*
+ * 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 com.metamatrix.connector.jdbc.access;
+
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
+import com.metamatrix.connector.language.ILimit;
+
+public class AccessSQLTranslator extends SQLTranslator {
+
+ @Override
+ public boolean hasTimeType() {
+ return false;
+ }
+
+ @Override
+ public String translateLiteralBoolean(Boolean booleanValue) {
+ if(booleanValue.booleanValue()) {
+ return "-1"; //$NON-NLS-1$
+ }
+ return "0"; //$NON-NLS-1$
+ }
+
+ @Override
+ public String addLimitString(String queryCommand, ILimit limit) {
+ int index = queryCommand.startsWith("SELECT DISTINCT")?15:6;
+ return new StringBuffer(queryCommand.length() + 8).append(queryCommand)
+ .insert(index, " TOP " + limit.getRowLimit()).toString();
+ }
+
+ @Override
+ public boolean addSourceComment() {
+ return false;
+ }
+
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2Capabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2Capabilities.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2Capabilities.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -104,7 +104,7 @@
supportedFunctions.add("CONVERT"); //$NON-NLS-1$
supportedFunctions.add("IFNULL"); //$NON-NLS-1$
supportedFunctions.add("NVL"); //$NON-NLS-1$
-
+ supportedFunctions.add("COALESCE"); //$NON-NLS-1$
return supportedFunctions;
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2ResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2ResultsTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2ResultsTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.db2;
-
-import com.metamatrix.connector.jdbc.extension.impl.BasicResultsTranslator;
-
-/**
- */
-public class DB2ResultsTranslator extends BasicResultsTranslator {
- //TODO
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.db2;
-
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.language.IFromItem;
-import com.metamatrix.connector.language.IJoin;
-import com.metamatrix.connector.language.ILimit;
-import com.metamatrix.connector.language.IJoin.JoinType;
-
-/**
- * @since 4.3
- */
-public class DB2SQLConversionVisitor extends SQLConversionVisitor {
-
- private final int MAX_SELECT_ALIAS_LENGTH = 30;
-
- private final int MAX_TABLE_ALIAS_LENGTH = 128;
-
- /**
- * Convert limit clause to DB2 ...FETCH FIRST rowlimit ROWS ONLY syntax
- * @see com.metamatrix.connector.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.connector.language.IQuery)
- * @since 5.0 SP1
- */
- public void visit(ILimit obj) {
- buffer.append("FETCH") //$NON-NLS-1$
- .append(SPACE)
- .append("FIRST") //$NON-NLS-1$
- .append(SPACE)
- .append(obj.getRowLimit())
- .append(SPACE)
- .append("ROWS") //$NON-NLS-1$
- .append(SPACE)
- .append("ONLY"); //$NON-NLS-1$
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#getMaxSelectAliasLength()
- * @since 4.3
- */
- protected int getMaxSelectAliasLength() {
- return MAX_SELECT_ALIAS_LENGTH;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#getMaxTableAliasLength()
- * @since 4.3
- */
- protected int getMaxTableAliasLength() {
- return MAX_TABLE_ALIAS_LENGTH;
- }
-
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.connector.language.IJoin)
- */
- public void visit(IJoin obj) {
- if(obj.getJoinType() != JoinType.CROSS_JOIN) {
- super.visit(obj);
- return;
- }
-
- IFromItem leftItem = obj.getLeftItem();
- if(leftItem instanceof IJoin) {
- buffer.append(LPAREN);
- append(leftItem);
- buffer.append(RPAREN);
- } else {
- append(leftItem);
- }
- buffer.append(SPACE)
- .append(INNER)
- .append(SPACE)
- .append(JOIN)
- .append(SPACE);
-
- IFromItem rightItem = obj.getRightItem();
- if(rightItem instanceof IJoin) {
- buffer.append(LPAREN);
- append(rightItem);
- buffer.append(RPAREN);
- } else {
- append(rightItem);
- }
-
- buffer.append(SPACE)
- .append(ON).append(SPACE)
- .append("1=1");//$NON-NLS-1$
- }
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLModificationVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLModificationVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLModificationVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,39 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.db2;
-
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.connector.visitor.framework.HierarchyVisitor;
-
-
-/**
- */
-public class DB2SQLModificationVisitor extends HierarchyVisitor {
-
- private ILanguageFactory languageFactory;
-
- public DB2SQLModificationVisitor(ILanguageFactory languageFactory) {
- this.languageFactory = languageFactory;
- }
-
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -24,75 +24,64 @@
*/
package com.metamatrix.connector.jdbc.db2;
-import java.util.HashMap;
-import java.util.Map;
-
+import java.util.Arrays;
+
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
+import com.metamatrix.connector.api.SourceSystemFunctions;
+import com.metamatrix.connector.api.TypeFacility;
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
+import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
import com.metamatrix.connector.language.ICommand;
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.language.IJoin;
+import com.metamatrix.connector.language.ILimit;
+import com.metamatrix.connector.language.ILiteral;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
+import com.metamatrix.connector.language.IJoin.JoinType;
+import com.metamatrix.connector.visitor.framework.HierarchyVisitor;
/**
*/
-public class DB2SQLTranslator extends BasicSQLTranslator {
-
- private Map functionModifiers;
- private ILanguageFactory languageFactory;
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#initialize(com.metamatrix.data.api.ConnectorEnvironment, com.metamatrix.data.metadata.runtime.RuntimeMetadata)
- */
- public void initialize(ConnectorEnvironment env, RuntimeMetadata metadata) throws ConnectorException {
- super.initialize(env, metadata);
- languageFactory = getConnectorEnvironment().getLanguageFactory();
- initializeFunctionModifiers();
- }
-
- private void initializeFunctionModifiers() {
- functionModifiers = new HashMap();
- functionModifiers.putAll(super.getFunctionModifiers());
- functionModifiers.put("cast", new DB2ConvertModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("char", new AliasModifier("chr")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("convert", new DB2ConvertModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("dayofmonth", new AliasModifier("day")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("ifnull", new AliasModifier("coalesce")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("nvl", new AliasModifier("coalesce")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("substring", new AliasModifier("substr")); //$NON-NLS-1$ //$NON-NLS-2$
- }
+public class DB2SQLTranslator extends SQLTranslator {
+
+ @Override
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, new DB2ConvertModifier(getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public String addLimitString(String queryCommand, ILimit limit) {
+ return queryCommand + " FETCH FIRST " + limit.getRowLimit() + " ROWS ONLY"; //$NON-NLS-1$
+ }
+
+ @Override
+ public ICommand modifyCommand(ICommand command, ExecutionContext context)
+ throws ConnectorException {
+ HierarchyVisitor hierarchyVisitor = new HierarchyVisitor() {
+ @Override
+ public void visit(IJoin obj) {
+ if (obj.getJoinType() != JoinType.CROSS_JOIN) {
+ return;
+ }
+ ILiteral one = getLanguageFactory().createLiteral(1, TypeFacility.RUNTIME_TYPES.INTEGER);
+ obj.setCriteria(Arrays.asList(getLanguageFactory().createCompareCriteria(Operator.EQ, one, one)));
+ obj.setJoinType(JoinType.INNER_JOIN);
+ }
+ };
+
+ command.acceptVisitor(hierarchyVisitor);
+ return command;
+ }
+
+ @Override
+ public String getConnectionTestQuery() {
+ return "Select 'x' from sysibm.systables where 1 = 2"; //$NON-NLS-1$
+ }
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getFunctionModifiers()
- */
- public Map getFunctionModifiers() {
- return functionModifiers;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#modifyCommand(com.metamatrix.connector.language.ICommand, com.metamatrix.data.SecurityContext)
- */
- public ICommand modifyCommand(ICommand command, ExecutionContext context) throws ConnectorException {
- // DB2-specific modification
- DB2SQLModificationVisitor visitor = new DB2SQLModificationVisitor(getConnectorEnvironment().getLanguageFactory());
- command.acceptVisitor(visitor);
- return command;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getTranslationVisitor()
- */
- public SQLConversionVisitor getTranslationVisitor() {
- SQLConversionVisitor visitor = new DB2SQLConversionVisitor();
- visitor.setRuntimeMetadata(getRuntimeMetadata());
- visitor.setFunctionModifiers(functionModifiers);
- visitor.setProperties(super.getConnectorEnvironment().getProperties());
- visitor.setLanguageFactory(languageFactory);
- visitor.setDatabaseTimeZone(getDatabaseTimeZone());
- return visitor;
- }
-
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SingleIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SingleIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.db2;
-
-import com.metamatrix.connector.jdbc.*;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
-
-public class DB2SingleIdentityConnectionFactory extends JDBCSingleIdentityConnectionFactory{
- private String queryTest = "Select 'x' from sysibm.systables where 1 = 2"; //$NON-NLS-1$
-
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2UserIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2UserIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2UserIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.db2;
-
-import com.metamatrix.connector.jdbc.*;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCUserIdentityConnectionFactory;
-
-public class DB2UserIdentityConnectionFactory extends JDBCUserIdentityConnectionFactory{
- private String queryTest = "Select 'x' from sysibm.systables where 1 = 2"; //$NON-NLS-1$
-
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyCapabilities.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyCapabilities.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -120,7 +120,7 @@
supportedFunctions.add("CONVERT"); //$NON-NLS-1$
supportedFunctions.add("IFNULL"); //$NON-NLS-1$
supportedFunctions.add("NVL"); //$NON-NLS-1$
-
+ supportedFunctions.add("COALESCE"); //$NON-NLS-1$
return supportedFunctions;
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.derby;
-
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-
-/**
- */
-class DerbyConversionVisitor extends SQLConversionVisitor {
-
- private final int MAX_TABLE_ALIAS_LENGTH = 128;
-
- /**
- * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#getMaxTableAliasLength()
- */
- protected int getMaxTableAliasLength() {
- return MAX_TABLE_ALIAS_LENGTH;
- }
-
- protected boolean supportsComments() {
- return false;
- }
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyResultsTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyResultsTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.derby;
-
-import com.metamatrix.connector.jdbc.extension.impl.BasicResultsTranslator;
-
-
-/**
- * @since 4.3
- */
-public class DerbyResultsTranslator extends BasicResultsTranslator {
-
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,66 +22,40 @@
package com.metamatrix.connector.jdbc.derby;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
-import com.metamatrix.connector.jdbc.extension.impl.EscapeSyntaxModifier;
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.api.SourceSystemFunctions;
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
+import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
+import com.metamatrix.connector.jdbc.extension.impl.EscapeSyntaxModifier;
/**
* @since 4.3
*/
-public class DerbySQLTranslator extends BasicSQLTranslator {
-
- private Map functionModifiers;
- private Properties connectorProperties;
- private ILanguageFactory languageFactory;
-
- public void initialize(ConnectorEnvironment env,
- RuntimeMetadata metadata) throws ConnectorException {
-
- super.initialize(env, metadata);
- ConnectorEnvironment connEnv = getConnectorEnvironment();
- this.connectorProperties = connEnv.getProperties();
- this.languageFactory = connEnv.getLanguageFactory();
- initializeFunctionModifiers();
-
- }
-
- private void initializeFunctionModifiers() {
- functionModifiers = new HashMap();
- functionModifiers.putAll(super.getFunctionModifiers());
-
- functionModifiers.put("concat", new EscapeSyntaxModifier()); //$NON-NLS-1$
- functionModifiers.put("substring", new AliasModifier("substr")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("dayofmonth", new AliasModifier("day")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("timestampadd", new DerbyTimestampFunctionModifier()); //$NON-NLS-1$
- functionModifiers.put("timestampdiff", new DerbyTimestampFunctionModifier()); //$NON-NLS-1$
- functionModifiers.put("cast", new DerbyConvertModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("convert", new DerbyConvertModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("ifnull", new AliasModifier("coalesce")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("nvl", new AliasModifier("coalesce")); //$NON-NLS-1$ //$NON-NLS-2$
+public class DerbySQLTranslator extends SQLTranslator {
+
+ @Override
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new EscapeSyntaxModifier()); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier()); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier()); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, new DerbyConvertModifier(getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.COALESCE, new AliasModifier("coalesce")); //$NON-NLS-1$ //$NON-NLS-2$
}
-
- public Map getFunctionModifiers() {
- return functionModifiers;
+
+ @Override
+ public boolean addSourceComment() {
+ return false;
+ }
+
+ @Override
+ public String getConnectionTestQuery() {
+ return "Select 0 from sys.systables where 1 = 2"; //$NON-NLS-1$
}
- public SQLConversionVisitor getTranslationVisitor() {
- SQLConversionVisitor visitor = new DerbyConversionVisitor();
- visitor.setRuntimeMetadata(getRuntimeMetadata());
- visitor.setFunctionModifiers(functionModifiers);
- visitor.setProperties(connectorProperties);
- visitor.setLanguageFactory(languageFactory);
- visitor.setDatabaseTimeZone(getDatabaseTimeZone());
- return visitor;
- }
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySingleIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySingleIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.derby;
-
-import com.metamatrix.connector.jdbc.ConnectionQueryStrategy;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
-
-
-/**
- * @since 4.3
- */
-public class DerbySingleIdentityConnectionFactory extends JDBCSingleIdentityConnectionFactory {
- private String queryTest = "Select 0 from sys.systables where 1 = 2"; //$NON-NLS-1$
-
- /**
- * @see com.metamatrix.connector.jdbc.JDBCSourceConnectionFactory#createConnectionStrategy()
- * @since 4.3
- */
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyTimestampFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyTimestampFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyTimestampFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,62 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.derby;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.language.IFunction;
-import com.metamatrix.connector.language.ILiteral;
-
-
-public class DerbyTimestampFunctionModifier extends BasicFunctionModifier {
-
- public DerbyTimestampFunctionModifier() {
- super();
- }
-
-/**
- * @see com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier#translate(com.metamatrix.connector.language.IFunction)
- * @since 4.3
- */
- public List translate(IFunction function) {
- List objs = new ArrayList();
- objs.add("{fn "); //$NON-NLS-1$
- objs.add(function.getName());
- objs.add("("); //$NON-NLS-1$
-
- IExpression[] args = function.getParameters();
- if(args != null && args.length > 0) {
- objs.add(((ILiteral)args[0]).getValue());
-
- for(int i=1; i<args.length; i++) {
- objs.add(", "); //$NON-NLS-1$
- objs.add(args[i]);
- }
- }
- objs.add(")}"); //$NON-NLS-1$
- return objs;
- }
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyUserIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyUserIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyUserIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.derby;
-
-import com.metamatrix.connector.jdbc.ConnectionQueryStrategy;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCUserIdentityConnectionFactory;
-
-
-/**
- * @since 4.3
- */
-public class DerbyUserIdentityConnectionFactory extends JDBCUserIdentityConnectionFactory {
- private String queryTest = "Select 0 from sys.systables where 1 = 2"; //$NON-NLS-1$
-
- /**
- * @see com.metamatrix.connector.jdbc.JDBCSourceConnectionFactory#createConnectionStrategy()
- * @since 4.3
- */
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/BindValueVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/BindValueVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/BindValueVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,7 +22,6 @@
package com.metamatrix.connector.jdbc.extension;
-import com.metamatrix.connector.language.ICaseExpression;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.IExistsCriteria;
import com.metamatrix.connector.language.IFunction;
@@ -101,20 +100,8 @@
}
/**
- * Will look for bind values in the when expressions.
- * The actual restriction for case statements seems to be that at least on branch must
- * not contain a bind variable.
- */
- public void visit(ICaseExpression obj) {
- replaceWithBinding = true;
- for (int i = 0; i < obj.getWhenCount(); i++) {
- visitNode(obj.getWhenExpression(i));
- }
- }
-
- /**
* Will look for bind values in the when criteria.
- * The actual restriction for case statements seems to be that at least on branch must
+ * The actual restriction for case statements seems to be that at least one branch must
* not contain a bind variable.
*/
public void visit(ISearchedCaseExpression obj) {
@@ -122,7 +109,8 @@
visitNode(obj.getWhenCriteria(i));
}
}
-
+
+ @Override
public void visit(IInsert obj) {
replaceWithBinding = true;
visitNodes(obj.getValues());
@@ -139,7 +127,7 @@
obj.setBindValue(true);
}
}
-
+
public void visitNode(ILanguageObject obj) {
boolean replacementMode = replaceWithBinding;
super.visitNode(obj);
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ResultsTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ResultsTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -122,5 +122,5 @@
int getMaxResultRows();
- TypeFacility getTypefacility();
+ TypeFacility getTypeFacility();
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -27,74 +27,67 @@
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DecimalFormat;
-import java.text.FieldPosition;
-import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.TimeZone;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.jdbc.JDBCPropertyNames;
import com.metamatrix.connector.language.IBulkInsert;
-import com.metamatrix.connector.language.IDelete;
+import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IFunction;
-import com.metamatrix.connector.language.IInsert;
-import com.metamatrix.connector.language.ILanguageFactory;
import com.metamatrix.connector.language.ILanguageObject;
+import com.metamatrix.connector.language.ILimit;
import com.metamatrix.connector.language.ILiteral;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.language.IQuery;
-import com.metamatrix.connector.language.IUpdate;
+import com.metamatrix.connector.language.IQueryCommand;
+import com.metamatrix.connector.language.ISetQuery;
import com.metamatrix.connector.language.IParameter.Direction;
+import com.metamatrix.connector.language.ISetQuery.Operation;
+import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.visitor.util.SQLStringVisitor;
/**
* This visitor takes an ICommand and does DBMS-specific conversion on it
* to produce a SQL String. This class is expected to be subclassed.
* Specialized instances of this class can be gotten from a SQL Translator
- * {@link SQLTranslator#getTranslationVisitor() using this method}.
+ * {@link SQLTranslator#getTranslationVisitor(RuntimeMetadata) using this method}.
*/
public class SQLConversionVisitor extends SQLStringVisitor{
- private static DecimalFormat decimalFormatter =
+ private static DecimalFormat DECIMAL_FORMAT =
new DecimalFormat("#############################0.0#############################"); //$NON-NLS-1$
private static double SCIENTIC_LOW = Math.pow(10, -3);
private static double SCIENTIC_HIGH = Math.pow(10, 7);
- private static final MessageFormat COMMENT = new MessageFormat("/*metamatrix sessionid:{0}, requestid:{1}.{2}*/ "); //$NON-NLS-1$
- private boolean useComment = false;
- private Map modifiers;
+ private Map<String, FunctionModifier> modifiers;
private ExecutionContext context;
- private ILanguageFactory languageFactory;
- private TimeZone databaseTimeZone;
+ private SQLTranslator translator;
+ private Calendar cal;
- private int execType = TranslatedCommand.EXEC_TYPE_QUERY;
- private int stmtType = TranslatedCommand.STMT_TYPE_STATEMENT;
+ private boolean prepared;
private List preparedValues = new ArrayList();
private List preparedTypes = new ArrayList();
- public SQLConversionVisitor() {
- super();
+ public SQLConversionVisitor(SQLTranslator translator) {
+ this.translator = translator;
+ this.prepared = translator.usePreparedStatements();
+ this.modifiers = translator.getFunctionModifiers();
+ TimeZone tz = translator.getDatabaseTimeZone();
+ if (tz != null) {
+ this.cal = Calendar.getInstance(tz);
+ }
}
- /**
- * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.IInsert)
- */
- public void visit(IInsert obj) {
- this.execType = TranslatedCommand.EXEC_TYPE_UPDATE;
- super.visit(obj);
- }
-
public void visit(IBulkInsert obj) {
- this.stmtType = TranslatedCommand.STMT_TYPE_PREPARED_STATEMENT;
+ this.prepared = true;
super.visit(obj);
@@ -130,19 +123,21 @@
// where toString will use for numbers greater than 10p7 and
// less than 10p-3, where database may not understand.
if (useFormatting) {
- valuesbuffer.append(decimalFormatter.format(obj));
+ synchronized (DECIMAL_FORMAT) {
+ valuesbuffer.append(DECIMAL_FORMAT.format(obj));
+ }
}
else {
valuesbuffer.append(obj);
}
} else if(type.equals(TypeFacility.RUNTIME_TYPES.BOOLEAN)) {
- valuesbuffer.append(translateLiteralBoolean((Boolean)obj));
+ valuesbuffer.append(translator.translateLiteralBoolean((Boolean)obj));
} else if(type.equals(TypeFacility.RUNTIME_TYPES.TIMESTAMP)) {
- valuesbuffer.append(translateLiteralTimestamp((Timestamp)obj));
+ valuesbuffer.append(translator.translateLiteralTimestamp((Timestamp)obj, cal));
} else if(type.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
- valuesbuffer.append(translateLiteralTime((Time)obj));
+ valuesbuffer.append(translator.translateLiteralTime((Time)obj, cal));
} else if(type.equals(TypeFacility.RUNTIME_TYPES.DATE)) {
- valuesbuffer.append(translateLiteralDate((java.sql.Date)obj));
+ valuesbuffer.append(translator.translateLiteralDate((java.sql.Date)obj, cal));
} else {
// If obj is string, toSting() will not create a new String
// object, it returns it self, so new object creation.
@@ -154,27 +149,10 @@
}
/**
- * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.IUpdate)
- */
- public void visit(IUpdate obj) {
- this.execType = TranslatedCommand.EXEC_TYPE_UPDATE;
- super.visit(obj);
- }
-
- /**
- * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.IQuery)
- */
- public void visit(IQuery obj) {
- this.execType = TranslatedCommand.EXEC_TYPE_QUERY;
- super.visit(obj);
- }
-
- /**
* @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.IProcedure)
*/
public void visit(IProcedure obj) {
- this.execType = TranslatedCommand.EXEC_TYPE_EXECUTE;
- this.stmtType = TranslatedCommand.STMT_TYPE_CALLABLE_STATEMENT;
+ this.prepared = true;
/*
* preparedValues is now a list of procedure params instead of just values
*/
@@ -183,14 +161,6 @@
}
/**
- * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.IDelete)
- */
- public void visit(IDelete obj) {
- this.execType = TranslatedCommand.EXEC_TYPE_UPDATE;
- super.visit(obj);
- }
-
- /**
* @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.IFunction)
*/
public void visit(IFunction obj) {
@@ -221,7 +191,7 @@
* @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.ILiteral)
*/
public void visit(ILiteral obj) {
- if (this.stmtType == TranslatedCommand.STMT_TYPE_PREPARED_STATEMENT && obj.isBindValue()) {
+ if (this.prepared && obj.isBindValue()) {
buffer.append(UNDEFINED_PARAM);
preparedValues.add(obj.getValue());
preparedTypes.add(obj.getType());
@@ -231,102 +201,6 @@
}
/**
- * Subclasses should override this method to provide a different sql translation
- * of the literal boolean value. By default, a boolean literal is represented as:
- * <code>'0'</code> or <code>'1'</code>.
- * @param booleanValue Boolean value, never null
- * @return Translated string
- */
- protected String translateLiteralBoolean(Boolean booleanValue) {
- if(booleanValue.booleanValue()) {
- return "1"; //$NON-NLS-1$
- }
- return "0"; //$NON-NLS-1$
- }
-
- /**
- * Subclasses should override this method to provide a different sql translation
- * of the literal date value. By default, a date literal is represented as:
- * <code>{d'2002-12-31'}</code>
- * @param dateValue Date value, never null
- * @return Translated string
- */
- protected String translateLiteralDate(java.sql.Date dateValue) {
- return "{d'" + formatDateValue(dateValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Subclasses should override this method to provide a different sql translation
- * of the literal time value. By default, a time literal is represented as:
- * <code>{t'23:59:59'}</code>
- * @param timeValue Time value, never null
- * @return Translated string
- */
- protected String translateLiteralTime(Time timeValue) {
- return "{t'" + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Subclasses should override this method to provide a different sql translation
- * of the literal timestamp value. By default, a timestamp literal is
- * represented as: <code>{ts'2002-12-31 23:59:59'}</code>.
- * @param timestampValue Timestamp value, never null
- * @return Translated string
- */
- protected String translateLiteralTimestamp(Timestamp timestampValue) {
- return "{ts'" + formatDateValue(timestampValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Format the dateObject (of type date, time, or timestamp) into a string
- * using the DatabaseTimeZone format.
- * @param dateObject
- * @return Formatted string
- */
- protected String formatDateValue(Object dateObject) {
- if(this.databaseTimeZone == null) {
- return dateObject.toString();
- }
-
-//System.out.println("!!! translating timestamp value " + dateObject + " (" + ((java.util.Date)dateObject).getTime() + " in " + this.databaseTimeZone);
-
- if(dateObject instanceof Timestamp) {
- SimpleDateFormat timestampFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
- timestampFormatter.setTimeZone(this.databaseTimeZone);
-
- Timestamp ts = (Timestamp) dateObject;
- String nanoStr = "" + (1000000000L + ts.getNanos()); //$NON-NLS-1$
- while(nanoStr.length() > 2 && nanoStr.charAt(nanoStr.length()-1) == '0') {
- nanoStr = nanoStr.substring(0, nanoStr.length()-1);
- }
- String tsStr = timestampFormatter.format(ts) + "." + nanoStr.substring(1); //$NON-NLS-1$
-
-//System.out.println("!!! returning " + tsStr);
-
- return tsStr;
-
- } else if(dateObject instanceof java.sql.Date) {
- SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd"); //$NON-NLS-1$
- dateFormatter.setTimeZone(this.databaseTimeZone);
- return dateFormatter.format((java.sql.Date)dateObject);
-
- } else if(dateObject instanceof Time) {
- SimpleDateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss"); //$NON-NLS-1$
- timeFormatter.setTimeZone(this.databaseTimeZone);
- return timeFormatter.format((java.sql.Time)dateObject);
-
- } else {
- return dateObject.toString();
- }
- }
-
- /**
- */
- public void setFunctionModifiers(Map modifiers) {
- this.modifiers = modifiers;
- }
-
- /**
* Set the per-command execution context on this visitor.
* @param context ExecutionContext
* @since 4.3
@@ -345,39 +219,11 @@
return this.context;
}
- public void setProperties(Properties props) {
- String useBindVariables = props.getProperty(JDBCPropertyNames.USE_BIND_VARIABLES, Boolean.FALSE.toString());
- if (useBindVariables.equals(Boolean.TRUE.toString())) {
- this.stmtType = TranslatedCommand.STMT_TYPE_PREPARED_STATEMENT;
- }
-
- String useCommentInSource = props.getProperty(JDBCPropertyNames.USE_COMMENTS_SOURCE_QUERY);
- if (useCommentInSource != null) {
- this.useComment = Boolean.valueOf(useCommentInSource).booleanValue();
- }
+ protected String getSourceComment(ICommand command) {
+ return this.translator.getSourceComment(this.context, command);
}
/**
- * inserting the comments is the source SQL supported or not by the
- * source data source. By default it is turned on; user has choice to
- * turn off by setting the connector property; the data base source has
- * option to turn off by overloading this.
- * @return true if yes; false otherwise.
- */
- protected boolean supportsComments() {
- return this.useComment;
- }
-
- static final FieldPosition FIELD_ZERO = new FieldPosition(0);
- protected String addProcessComment() {
- if (supportsComments() && this.context != null) {
- return COMMENT.format(new Object[] {this.context.getConnectionIdentifier(), this.context.getRequestIdentifier(), this.context.getPartIdentifier()});
- }
- return super.addProcessComment();
- }
-
-
- /**
* This is a generic implementation. Subclass should override this method
* if necessary.
* @param exec The command for the stored procedure.
@@ -400,7 +246,7 @@
}
}
- prepareCallBuffer.append(addProcessComment());
+ prepareCallBuffer.append(getSourceComment(exec));
if(needQuestionMark){
prepareCallBuffer.append("?="); //$NON-NLS-1$
@@ -427,36 +273,7 @@
return prepareCallBuffer.toString();
}
- /**
- * @param factory
- */
- public void setLanguageFactory(ILanguageFactory factory) {
- languageFactory = factory;
- }
-
- /**
- * @return
- */
- public ILanguageFactory getLanguageFactory() {
- return languageFactory;
- }
-
- public void setDatabaseTimeZone(TimeZone zone) {
- databaseTimeZone = zone;
- }
-
- protected TimeZone getDatabaseTimeZone() {
- return databaseTimeZone;
- }
-
/**
- * @return the execType
- */
- protected int getExecType() {
- return this.execType;
- }
-
- /**
* @return the preparedValues
*/
List getPreparedValues() {
@@ -470,15 +287,61 @@
return this.preparedTypes;
}
- /**
- * @return the stmtType
- */
- int getStmtType() {
- return this.stmtType;
+ public boolean isPrepared() {
+ return prepared;
+ }
+
+ public void setPrepared(boolean prepared) {
+ this.prepared = prepared;
+ }
+
+ @Override
+ protected boolean useAsInGroupAlias() {
+ return this.translator.useAsInGroupAlias();
}
- protected void setStmtType(int stmtType) {
- this.stmtType = stmtType;
+ @Override
+ public void visit(IQuery obj) {
+ if (obj.getLimit() != null) {
+ handleLimit(obj);
+ } else {
+ super.visit(obj);
+ }
}
-
+
+ @Override
+ public void visit(ISetQuery obj) {
+ if (obj.getLimit() != null) {
+ handleLimit(obj);
+ } else {
+ super.visit(obj);
+ }
+ }
+
+ @Override
+ protected boolean useParensForSetQueries() {
+ return translator.useParensForSetQueries();
+ }
+
+ private void handleLimit(IQueryCommand obj) {
+ ILimit limit = obj.getLimit();
+ obj.setLimit(null);
+ StringBuffer current = this.buffer;
+ this.buffer = new StringBuffer();
+ append(obj);
+ current.append(this.translator.addLimitString(this.buffer.toString(), limit));
+ this.buffer = current;
+ obj.setLimit(limit);
+ }
+
+ @Override
+ protected String replaceElementName(String group, String element) {
+ return translator.replaceElementName(group, element);
+ }
+
+ @Override
+ protected void appendSetOperation(Operation operation) {
+ buffer.append(translator.getSetOperationString(operation));
+ }
+
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -20,48 +20,229 @@
* 02110-1301 USA.
*/
-/*
- */
package com.metamatrix.connector.jdbc.extension;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.text.MessageFormat;
+import java.util.Calendar;
+import java.util.HashMap;
import java.util.Map;
+import java.util.TimeZone;
+import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
+import com.metamatrix.connector.jdbc.JDBCPropertyNames;
import com.metamatrix.connector.language.ICommand;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.language.ILanguageFactory;
+import com.metamatrix.connector.language.ILimit;
+import com.metamatrix.connector.language.ISetQuery;
/**
+ * Base class for creating source SQL queries and retrieving results.
+ * Specific databases should override as necessary.
*/
-public interface SQLTranslator {
+public class SQLTranslator {
+
+ private static final MessageFormat COMMENT = new MessageFormat("/*teiid sessionid:{0}, requestid:{1}.{2}*/ "); //$NON-NLS-1$
+
+ public final static TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault();
+
+ private Map<String, FunctionModifier> functionModifiers = new HashMap<String, FunctionModifier>();
+ private TimeZone databaseTimeZone;
+ private ConnectorEnvironment environment;
+ private boolean useComments;
+ private boolean usePreparedStatements;
+
/**
* Initialize the SQLTranslator.
* @param env
* @param metadata
* @throws ConnectorException
*/
- void initialize(ConnectorEnvironment env, RuntimeMetadata metadata) throws ConnectorException;
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ this.environment = env;
+
+ String timeZone = env.getProperties().getProperty(JDBCPropertyNames.DATABASE_TIME_ZONE);
+ if(timeZone != null && timeZone.trim().length() > 0) {
+ TimeZone tz = TimeZone.getTimeZone(timeZone);
+ // Check that the dbms time zone is really different than the local time zone
+ if(!DEFAULT_TIME_ZONE.hasSameRules(tz)) {
+ this.databaseTimeZone = tz;
+ }
+ }
+
+ this.useComments = PropertiesUtils.getBooleanProperty(env.getProperties(), JDBCPropertyNames.USE_COMMENTS_SOURCE_QUERY, false);
+ this.usePreparedStatements = PropertiesUtils.getBooleanProperty(env.getProperties(), JDBCPropertyNames.USE_BIND_VARIABLES, false);
+ }
+ public TimeZone getDatabaseTimeZone() {
+ return databaseTimeZone;
+ }
+
+ public ConnectorEnvironment getEnvironment() {
+ return environment;
+ }
+
+ public ILanguageFactory getLanguageFactory() {
+ return environment.getLanguageFactory();
+ }
+
/**
* Modify the command.
* @param command
* @param context
* @return
*/
- ICommand modifyCommand(ICommand command, ExecutionContext context) throws ConnectorException;
+ public ICommand modifyCommand(ICommand command, ExecutionContext context) throws ConnectorException {
+ return command;
+ }
/**
- * Return the SQLConversionVisitor used for converting the command objects to
- * a sql string.
- * @return
+ * Return a map of function name in lower case to FunctionModifier.
+ * @return Map of function name to FunctionModifier.
*/
- SQLConversionVisitor getTranslationVisitor();
+ public Map<String, FunctionModifier> getFunctionModifiers() {
+ return functionModifiers;
+ }
+ public void registerFunctionModifier(String name, FunctionModifier modifier) {
+ this.functionModifiers.put(name, modifier);
+ }
+
/**
- * Return a map of function name in lower case to FunctionModifier.
- * @return Map of function name to FunctionModifier.
+ * Subclasses should override this method to provide a different sql translation
+ * of the literal boolean value. By default, a boolean literal is represented as:
+ * <code>'0'</code> or <code>'1'</code>.
+ * @param booleanValue Boolean value, never null
+ * @return Translated string
*/
- Map getFunctionModifiers();
+ public String translateLiteralBoolean(Boolean booleanValue) {
+ if(booleanValue.booleanValue()) {
+ return "1"; //$NON-NLS-1$
+ }
+ return "0"; //$NON-NLS-1$
+ }
+
+ /**
+ * Subclasses should override this method to provide a different sql translation
+ * of the literal date value. By default, a date literal is represented as:
+ * <code>{d'2002-12-31'}</code>
+ * @param dateValue Date value, never null
+ * @return Translated string
+ */
+ public String translateLiteralDate(java.sql.Date dateValue, Calendar cal) {
+ return "{d'" + formatDateValue(dateValue, cal) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Subclasses should override this method to provide a different sql translation
+ * of the literal time value. By default, a time literal is represented as:
+ * <code>{t'23:59:59'}</code>
+ * @param timeValue Time value, never null
+ * @return Translated string
+ */
+ public String translateLiteralTime(Time timeValue, Calendar cal) {
+ if (!hasTimeType()) {
+ return "{ts'1970-01-01 " + formatDateValue(timeValue, cal) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return "{t'" + formatDateValue(timeValue, cal) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Subclasses should override this method to provide a different sql translation
+ * of the literal timestamp value. By default, a timestamp literal is
+ * represented as: <code>{ts'2002-12-31 23:59:59'}</code>.
+ * @param timestampValue Timestamp value, never null
+ * @return Translated string
+ */
+ public String translateLiteralTimestamp(Timestamp timestampValue, Calendar cal) {
+ return "{ts'" + formatDateValue(timestampValue, cal) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Format the dateObject (of type date, time, or timestamp) into a string
+ * using the DatabaseTimeZone format.
+ * @param dateObject
+ * @param cal
+ * @return Formatted string
+ */
+ public String formatDateValue(java.util.Date dateObject, Calendar cal) {
+ if (dateObject instanceof Timestamp && getTimestampNanoSecondPrecision() < 9) {
+ Timestamp ts = (Timestamp)dateObject;
+ Timestamp newTs = new Timestamp(ts.getTime());
+ if (getTimestampNanoSecondPrecision() > 0) {
+ int mask = 10^(9-getTimestampNanoSecondPrecision());
+ newTs.setNanos(ts.getNanos()/mask*mask);
+ }
+ dateObject = newTs;
+ }
+
+ if(cal == null) {
+ return dateObject.toString();
+ }
+
+ return getEnvironment().getTypeFacility().convertDate(dateObject,
+ DEFAULT_TIME_ZONE, cal, dateObject.getClass()).toString();
+ }
+
+ public boolean addSourceComment() {
+ return useComments;
+ }
+
+ public String addLimitString(String queryCommand, ILimit limit) {
+ return queryCommand + " " + limit.toString(); //$NON-NLS-1$
+ }
+
+ /**
+ * Indicates whether group alias should be of the form
+ * "...FROM groupA AS X" or "...FROM groupA X". Certain
+ * data sources (such as Oracle) may not support the first
+ * form.
+ * @return boolean
+ */
+ public boolean useAsInGroupAlias(){
+ return true;
+ }
+
+ public boolean usePreparedStatements() {
+ return this.usePreparedStatements;
+ }
+
+ public boolean useParensForSetQueries() {
+ return false;
+ }
+
+ public boolean hasTimeType() {
+ return true;
+ }
+
+ public String getSetOperationString(ISetQuery.Operation operation) {
+ return operation.toString();
+ }
+
+ public String getSourceComment(ExecutionContext context, ICommand command) {
+ if (addSourceComment() && context != null) {
+ synchronized (COMMENT) {
+ return COMMENT.format(new Object[] {context.getConnectionIdentifier(), context.getRequestIdentifier(), context.getPartIdentifier()});
+ }
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ public String replaceElementName(String group, String element) {
+ return null;
+ }
+
+ public int getTimestampNanoSecondPrecision() {
+ return 9;
+ }
+
+ public String getConnectionTestQuery() {
+ return "select 1"; //$NON-NLS-1$
+ }
+
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/TranslatedCommand.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/TranslatedCommand.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/TranslatedCommand.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -42,27 +42,8 @@
*/
public class TranslatedCommand {
- /** the translated command is a query */
- public static final int EXEC_TYPE_QUERY = 0;
-
- /** the translated command is an insert, update, or delete */
- public static final int EXEC_TYPE_UPDATE = 1;
-
- /** the translated command is an execute-type command */
- public static final int EXEC_TYPE_EXECUTE = 2;
-
- /** execution of translated command requires a jdbc Statement */
- public static final int STMT_TYPE_STATEMENT = 0;
-
- /** execution of translated command requires a jdbc Prepared Statement */
- public static final int STMT_TYPE_PREPARED_STATEMENT = 1;
-
- /** execution of translated command requires a jdbc Callable Statement */
- public static final int STMT_TYPE_CALLABLE_STATEMENT = 2;
-
private String sql;
- private int executionType;
- private int statementType;
+ private boolean prepared;
private List preparedValues;
private List preparedTypes;
@@ -79,9 +60,8 @@
this.context = context;
this.sqlTranslator = sqlTranslator;
- Map modifiers = sqlTranslator.getFunctionModifiers();
- this.sqlConversionVisitor = sqlTranslator.getTranslationVisitor();
- sqlConversionVisitor.setFunctionModifiers(modifiers);
+ Map<String, FunctionModifier> modifiers = sqlTranslator.getFunctionModifiers();
+ this.sqlConversionVisitor = new SQLConversionVisitor(sqlTranslator);
sqlConversionVisitor.setExecutionContext(context);
this.functionVisitor = new FunctionReplacementVisitor(modifiers);
}
@@ -102,18 +82,17 @@
*/
public void translateCommand(ICommand command) throws ConnectorException {
this.sql = getSQL(command);
- this.statementType = this.sqlConversionVisitor.getStmtType();
- this.executionType = this.sqlConversionVisitor.getExecType();
this.preparedValues = this.sqlConversionVisitor.getPreparedValues();
this.preparedTypes = this.sqlConversionVisitor.getPreparedTypes();
+ this.prepared = this.sqlConversionVisitor.isPrepared();
}
private String getSQL(ICommand command) throws ConnectorException {
command = sqlTranslator.modifyCommand(command, context);
command.acceptVisitor(functionVisitor);
- if (this.sqlConversionVisitor.getStmtType() == STMT_TYPE_PREPARED_STATEMENT || hasBindValue(command)) {
- this.sqlConversionVisitor.setStmtType(STMT_TYPE_PREPARED_STATEMENT);
+ if (sqlTranslator.usePreparedStatements() || hasBindValue(command)) {
+ this.sqlConversionVisitor.setPrepared(true);
command.acceptVisitor(new BindValueVisitor());
}
@@ -151,16 +130,6 @@
}
/**
- * Return the execution type, one of {@link #EXEC_TYPE_QUERY},
- * {@link #EXEC_TYPE_UPDATE}, or
- * {@link #EXEC_TYPE_EXECUTE}
- * @return execution type of translated command
- */
- public int getExecutionType() {
- return executionType;
- }
-
- /**
* Return List of values to set on a prepared statement, if
* necessary (see {@link #getStatementType})
* @return List of values to be set on a prepared statement
@@ -195,8 +164,8 @@
* {@link #STMT_TYPE_CALLABLE_STATEMENT}
* @return statement type of translated command
*/
- public int getStatementType() {
- return statementType;
+ public boolean isPrepared() {
+ return prepared;
}
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ValueRetriever.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ValueRetriever.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ValueRetriever.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -47,7 +47,7 @@
* @return The object that was retrieved
* @throws SQLException If an error occurred retrieving the value
*/
- Object retrieveValue(ResultSet results, int columnIndex, Class expectedType, int nativeSQLType, Calendar cal, TypeFacility typeFacility) throws SQLException;
+ Object retrieveValue(ResultSet results, int columnIndex, Class expectedType, Calendar cal, TypeFacility typeFacility) throws SQLException;
/**
* Retrieve the value at <code>parameterIndex</code> from the callable statement
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicResultsTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicResultsTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -93,8 +93,7 @@
}
}
-
- public TypeFacility getTypefacility() {
+ public TypeFacility getTypeFacility() {
return typeFacility;
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicSQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicSQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,109 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.extension.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TimeZone;
-
-import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.jdbc.JDBCPropertyNames;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
-import com.metamatrix.connector.language.ICommand;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-
-/**
- */
-public class BasicSQLTranslator implements SQLTranslator {
- public final static TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault();
-
- private RuntimeMetadata metadata;
- private ConnectorEnvironment environment;
- private Map functionModifiers = new HashMap();
- private TimeZone databaseTimeZone;
-
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#initialize(com.metamatrix.data.ConnectorEnvironment)
- */
- public void initialize(ConnectorEnvironment env, RuntimeMetadata metadata) throws ConnectorException {
- this.metadata = metadata;
- this.environment = env;
-
- String timeZone = env.getProperties().getProperty(JDBCPropertyNames.DATABASE_TIME_ZONE);
- if(timeZone != null && timeZone.trim().length() > 0) {
- TimeZone tz = TimeZone.getTimeZone(timeZone);
- // Check that the dbms time zone is really different than the local time zone
- if(!DEFAULT_TIME_ZONE.hasSameRules(tz)) {
- this.databaseTimeZone = tz;
- }
- }
-
- }
-
- /**
- * Subclass should override this methods to modify the command if necessary.
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#modifyCommand(com.metamatrix.connector.language.ICommand, com.metamatrix.data.ExecutionContext)
- */
- public ICommand modifyCommand(ICommand command, ExecutionContext context) throws ConnectorException {
- return command;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getTranslationVisitor()
- */
- public SQLConversionVisitor getTranslationVisitor() {
- SQLConversionVisitor visitor = new SQLConversionVisitor();
- visitor.setRuntimeMetadata(metadata);
- visitor.setFunctionModifiers(getFunctionModifiers());
- visitor.setProperties(environment.getProperties());
- visitor.setLanguageFactory(environment.getLanguageFactory());
- visitor.setDatabaseTimeZone(databaseTimeZone);
-
- return visitor;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getFunctionModifiers()
- */
- public Map getFunctionModifiers() {
- return functionModifiers;
- }
-
- protected RuntimeMetadata getRuntimeMetadata(){
- return this.metadata;
- }
-
- protected ConnectorEnvironment getConnectorEnvironment(){
- return this.environment;
- }
-
- protected TimeZone getDatabaseTimeZone() {
- return this.databaseTimeZone;
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicValueRetriever.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicValueRetriever.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicValueRetriever.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -25,7 +25,6 @@
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Types;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
@@ -78,7 +77,7 @@
/*
* @see com.metamatrix.connector.jdbc.extension.ValueRetriever#retrieveValue(java.sql.ResultSet, int, java.lang.Class, java.util.Calendar)
*/
- public Object retrieveValue(ResultSet results, int columnIndex, Class expectedType, int nativeSQLType, Calendar cal, TypeFacility typeFacility) throws SQLException {
+ public Object retrieveValue(ResultSet results, int columnIndex, Class expectedType, Calendar cal, TypeFacility typeFacility) throws SQLException {
Integer code = (Integer) TYPE_CODE_MAP.get(expectedType);
if(code != null) {
// Calling the specific methods here is more likely to get uniform (and fast) results from different
@@ -153,20 +152,7 @@
}
}
- // otherwise fall through and call getObject() and rely on the normal translation routines
- switch(nativeSQLType) {
- case Types.BLOB:
- return typeFacility.convertToRuntimeType(results.getBlob(columnIndex));
- case Types.CLOB:
- return typeFacility.convertToRuntimeType(results.getClob(columnIndex));
- case Types.BINARY:
- case Types.VARBINARY:
- case Types.LONGVARBINARY:
- return typeFacility.convertToRuntimeType(results.getBytes(columnIndex));
- }
-
return typeFacility.convertToRuntimeType(results.getObject(columnIndex));
-
}
public Object retrieveValue(CallableStatement results, int parameterIndex, Class expectedType, Calendar cal, TypeFacility typeFacility) throws SQLException{
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixResultsTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixResultsTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.informix;
-
-import com.metamatrix.connector.jdbc.extension.impl.BasicResultsTranslator;
-
-/**
- */
-public class InformixResultsTranslator extends BasicResultsTranslator {
- //TODO
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -24,37 +24,25 @@
*/
package com.metamatrix.connector.jdbc.informix;
-import java.util.*;
-
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.extension.impl.*;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.api.SourceSystemFunctions;
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
+import com.metamatrix.connector.jdbc.extension.impl.DropFunctionModifier;
/**
*/
-public class InformixSQLTranslator extends BasicSQLTranslator {
+public class InformixSQLTranslator extends SQLTranslator {
- private Map functionModifiers;
-
- public void initialize(ConnectorEnvironment env,
- RuntimeMetadata metadata) throws ConnectorException {
-
- super.initialize(env, metadata);
- initializeFunctionModifiers();
+ @Override
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, new DropFunctionModifier()); //$NON-NLS-1$
}
-
- private void initializeFunctionModifiers() {
- functionModifiers = new HashMap();
- functionModifiers.putAll(super.getFunctionModifiers());
- functionModifiers.put("cast", new DropFunctionModifier()); //$NON-NLS-1$
- functionModifiers.put("convert", new DropFunctionModifier()); //$NON-NLS-1$
- }
+
+ @Override
+ public String getConnectionTestQuery() {
+ return "select 'x' from informix.sysusers where 1=0"; //$NON-NLS-1$
+ }
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getFunctionModifiers()
- */
- public Map getFunctionModifiers() {
- return this.functionModifiers;
- }
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSingleIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSingleIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.informix;
-
-import com.metamatrix.connector.jdbc.*;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
-
-public class InformixSingleIdentityConnectionFactory extends JDBCSingleIdentityConnectionFactory{
- private String queryTest = "select 'x' from informix.sysusers where 1=0"; //$NON-NLS-1$
-
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixUserIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixUserIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixUserIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.informix;
-
-import com.metamatrix.connector.jdbc.*;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCUserIdentityConnectionFactory;
-
-public class InformixUserIdentityConnectionFactory extends JDBCUserIdentityConnectionFactory{
- private String queryTest = "select 'x' from informix.sysusers where 1=0"; //$NON-NLS-1$
-
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLCapabilities.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLCapabilities.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -124,7 +124,7 @@
// ADDITIONAL functions supported by MySQL
// // Comparison
-// supportedFunctions.add("COALESCE"); //$NON-NLS-1$
+ supportedFunctions.add("COALESCE"); //$NON-NLS-1$
// supportedFunctions.add("GREATEST"); //$NON-NLS-1$
// supportedFunctions.add("ISNULL"); //$NON-NLS-1$
// supportedFunctions.add("LEAST"); //$NON-NLS-1$
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,90 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.mysql;
-
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.language.ILimit;
-import com.metamatrix.connector.language.IQueryCommand;
-
-/**
- */
-class MySQLConversionVisitor extends SQLConversionVisitor {
-
- /**
- * Some very large row count. This number is from the mysql documentation for the LIMIT clause
- */
- static final String NO_LIMIT = "18446744073709551615"; //$NON-NLS-1$
-
- protected String translateLiteralDate(Date dateValue) {
- return "DATE('" + formatDateValue(dateValue) + "')"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- protected String translateLiteralTime(Time timeValue) {
- return "TIME('" + formatDateValue(timeValue) + "')"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- protected String translateLiteralTimestamp(Timestamp timestampValue) {
- return "TIMESTAMP('" + formatDateValue(timestampValue) + "')"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- protected String formatDateValue(Object dateObject) {
- if(dateObject instanceof Timestamp) {
- SimpleDateFormat timestampFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
- if (getDatabaseTimeZone() != null) {
- timestampFormatter.setTimeZone(getDatabaseTimeZone());
- }
-
- Timestamp ts = (Timestamp) dateObject;
- int nanos = ts.getNanos();
- int micros = nanos/1000; // truncate for microseconds
- String microsStr = "" + (1000000 + micros); //$NON-NLS-1$ // Add a number at the beginning, so that we can print leading zeros
-
- return timestampFormatter.format(ts) + "." + microsStr.substring(1); //$NON-NLS-1$ // show all digits except the number we just added
- }
- return super.formatDateValue(dateObject);
- }
-
- protected void appendSetQuery(IQueryCommand obj) {
- buffer.append(LPAREN);
- append(obj);
- buffer.append(RPAREN);
- }
-
- public void visit(ILimit obj) {
- buffer.append(LIMIT)
- .append(SPACE);
- if (obj.getRowOffset() > 0) {
- buffer.append(obj.getRowOffset())
- .append(COMMA)
- .append(SPACE);
- }
- buffer.append(obj.getRowLimit());
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLConvertModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLConvertModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -31,6 +31,7 @@
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
import com.metamatrix.connector.language.ILiteral;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
/**
@@ -94,11 +95,11 @@
int srcCode = getSrcCode(function);
switch(srcCode) {
case BOOLEAN:
- // convert(booleanSrc, string) --> CASE booleanSrc WHEN 1 THEN '1' ELSE '0' END
- List when = Arrays.asList(new IExpression[] {langFactory.createLiteral(new Integer(1), Integer.class)});
+ // convert(booleanSrc, string) --> CASE WHEN booleanSrc THEN '1' ELSE '0' END
+ List when = Arrays.asList(langFactory.createCompareCriteria(Operator.EQ, function.getParameters()[0], langFactory.createLiteral(Boolean.TRUE, Boolean.class)));
List then = Arrays.asList(new IExpression[] {langFactory.createLiteral("1", String.class)}); //$NON-NLS-1$
IExpression elseExpr = langFactory.createLiteral("0", String.class); //$NON-NLS-1$
- return langFactory.createCaseExpression(function.getParameters()[0], when, then, elseExpr, String.class);
+ return langFactory.createSearchedCaseExpression(when, then, elseExpr, String.class);
case BYTE:
case SHORT:
case INTEGER:
@@ -156,10 +157,11 @@
switch(srcCode) {
case STRING:
// convert(src, boolean) --> CASE src WHEN 'true' THEN 1 ELSE 0 END
- List when = Arrays.asList(new IExpression[] {langFactory.createLiteral("true", String.class)}); //$NON-NLS-1$
- List then = Arrays.asList(new IExpression[] {langFactory.createLiteral(new Integer(1), Integer.class)});
- IExpression elseExpr = langFactory.createLiteral(new Integer(0), Integer.class);
- return langFactory.createCaseExpression(function.getParameters()[0], when, then, elseExpr, Integer.class);
+ // convert(booleanSrc, string) --> CASE WHEN booleanSrc THEN '1' ELSE '0' END
+ List when = Arrays.asList(langFactory.createCompareCriteria(Operator.EQ, function.getParameters()[0], langFactory.createLiteral("true", String.class)));
+ List then = Arrays.asList(new IExpression[] {langFactory.createLiteral(Integer.valueOf(1), Integer.class)}); //$NON-NLS-1$
+ IExpression elseExpr = langFactory.createLiteral(Integer.valueOf(0), Integer.class); //$NON-NLS-1$
+ return langFactory.createSearchedCaseExpression(when, then, elseExpr, String.class);
default:
return DROP_MODIFIER.modify(function);
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLResultsTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLResultsTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.mysql;
-
-import com.metamatrix.connector.jdbc.extension.impl.BasicResultsTranslator;
-
-
-/**
- * @since 4.3
- */
-public class MySQLResultsTranslator extends BasicResultsTranslator {
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLSingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLSingleIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLSingleIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.mysql;
-
-import com.metamatrix.connector.jdbc.ConnectionQueryStrategy;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
-
-
-/**
- * @since 4.3
- */
-public class MySQLSingleIdentityConnectionFactory extends JDBCSingleIdentityConnectionFactory {
- private String queryTest = "Select 1"; //$NON-NLS-1$
-
- /**
- * @see com.metamatrix.connector.jdbc.JDBCSourceConnectionFactory#createConnectionStrategy()
- * @since 4.3
- */
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,59 +22,51 @@
package com.metamatrix.connector.jdbc.mysql;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.api.SourceSystemFunctions;
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
/**
* @since 4.3
*/
-public class MySQLTranslator extends BasicSQLTranslator {
-
- private Map functionModifiers;
- private Properties connectorProperties;
- private ILanguageFactory languageFactory;
-
- public void initialize(ConnectorEnvironment env,
- RuntimeMetadata metadata) throws ConnectorException {
-
- super.initialize(env, metadata);
- ConnectorEnvironment connEnv = getConnectorEnvironment();
- this.connectorProperties = connEnv.getProperties();
- this.languageFactory = connEnv.getLanguageFactory();
- initializeFunctionModifiers();
-
- }
-
- private void initializeFunctionModifiers() {
- functionModifiers = new HashMap();
- functionModifiers.putAll(super.getFunctionModifiers());
-
- functionModifiers.put("cast", new MySQLConvertModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("convert", new MySQLConvertModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("nvl", new AliasModifier("ifnull")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public Map getFunctionModifiers() {
- return functionModifiers;
- }
-
- public SQLConversionVisitor getTranslationVisitor() {
- SQLConversionVisitor visitor = new MySQLConversionVisitor();
- visitor.setRuntimeMetadata(getRuntimeMetadata());
- visitor.setFunctionModifiers(functionModifiers);
- visitor.setProperties(connectorProperties);
- visitor.setLanguageFactory(languageFactory);
- visitor.setDatabaseTimeZone(getDatabaseTimeZone());
- return visitor;
- }
+public class MySQLTranslator extends SQLTranslator {
+
+ @Override
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, new MySQLConvertModifier(getLanguageFactory())); //$NON-NLS-1$
+ }
+
+ @Override
+ public String translateLiteralDate(Date dateValue, Calendar cal) {
+ return "DATE('" + formatDateValue(dateValue, cal) + "')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue, Calendar cal) {
+ return "TIME('" + formatDateValue(timeValue, cal) + "')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue, Calendar cal) {
+ return "TIMESTAMP('" + formatDateValue(timestampValue, cal) + "')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public boolean useParensForSetQueries() {
+ return true;
+ }
+
+ @Override
+ public int getTimestampNanoSecondPrecision() {
+ return 6;
+ }
+
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLUserIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLUserIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLUserIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.mysql;
-
-import com.metamatrix.connector.jdbc.ConnectionQueryStrategy;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCUserIdentityConnectionFactory;
-
-
-/**
- * @since 4.3
- */
-public class MySQLUserIdentityConnectionFactory extends JDBCUserIdentityConnectionFactory {
- private String queryTest = "Select 1"; //$NON-NLS-1$
-
- /**
- * @see com.metamatrix.connector.jdbc.JDBCSourceConnectionFactory#createConnectionStrategy()
- * @since 4.3
- */
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/FormatFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/FormatFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/FormatFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.oracle;
-
-import com.metamatrix.connector.jdbc.extension.FunctionModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
-import com.metamatrix.connector.language.*;
-/**
- */
-public class FormatFunctionModifier extends BasicFunctionModifier implements FunctionModifier {
- private ILanguageFactory langFactory;
-
- public FormatFunctionModifier(ILanguageFactory langFactory) {
- this.langFactory = langFactory;
- }
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
- */
- public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
- String format = (String) ((ILiteral)args[1]).getValue();
-
- IFunction func = langFactory.createFunction("to_char", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- langFactory.createLiteral(format, String.class),
- },
- String.class);
-
- return func;
- }
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/HourFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/HourFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/HourFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.oracle;
-
-import com.metamatrix.connector.jdbc.extension.FunctionModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
-import com.metamatrix.connector.language.*;
-
-/**
- * Convert the HOUR function into an equivalent Oracle function.
- * HOUR(ts) --> TO_NUMBER(TO_CHAR(ts, 'HH24'))
- */
-public class HourFunctionModifier extends BasicFunctionModifier implements FunctionModifier {
-
- private ILanguageFactory langFactory;
-
- public HourFunctionModifier(ILanguageFactory langFactory) {
- this.langFactory = langFactory;
- }
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
- */
- public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
-
- IFunction innerFunction = langFactory.createFunction("TO_CHAR", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- langFactory.createLiteral("HH24", String.class)}, //$NON-NLS-1$
- String.class);
-
- IFunction outerFunction = langFactory.createFunction("TO_NUMBER", //$NON-NLS-1$
- new IExpression[] { innerFunction },
- Integer.class);
-
- return outerFunction;
- }
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LeftOrRightFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LeftOrRightFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LeftOrRightFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,74 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.oracle;
-
-import com.metamatrix.connector.jdbc.extension.FunctionModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
-import com.metamatrix.connector.language.*;
-
-/**
- * Convert left(string, count) --> substr(string, 0, count)
- * or right(string, count) --> substr(string, length(string) - count)
- */
-public class LeftOrRightFunctionModifier extends BasicFunctionModifier implements FunctionModifier {
- private ILanguageFactory langFactory;
- private String target;
-
- public LeftOrRightFunctionModifier(ILanguageFactory langFactory, String target) {
- this.langFactory = langFactory;
- this.target = target;
- }
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
- */
- public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
- IFunction func = null;
-
- if (target.equalsIgnoreCase("left")) { //$NON-NLS-1$
- func = langFactory.createFunction("SUBSTR", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- langFactory.createLiteral(new Integer(0), Integer.class),
- args[1]},
- String.class);
- } else if (target.equalsIgnoreCase("right")) { //$NON-NLS-1$
- IFunction inner = langFactory.createFunction("LENGTH", //$NON-NLS-1$
- new IExpression[] {args[0]},
- Integer.class);
-
- IExpression substrArgs = langFactory.createFunction("-", //$NON-NLS-1$
- new IExpression[] {inner, args[1] },
- Integer.class);
-
- func = langFactory.createFunction("SUBSTR", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- substrArgs},
- String.class);
- }
-
- return func;
- }
-}
Added: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LeftOrRightFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LeftOrRightFunctionModifier.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LeftOrRightFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -0,0 +1,69 @@
+/*
+ * 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 com.metamatrix.connector.jdbc.oracle;
+
+import com.metamatrix.connector.api.TypeFacility;
+import com.metamatrix.connector.jdbc.extension.FunctionModifier;
+import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
+import com.metamatrix.connector.language.*;
+
+/**
+ * Convert left(string, count) --> substr(string, 1, count)
+ * or right(string, count) --> substr(string, -1 * count) - we lack a way to express a unary negation
+ */
+public class LeftOrRightFunctionModifier extends BasicFunctionModifier implements FunctionModifier {
+ private ILanguageFactory langFactory;
+
+ public LeftOrRightFunctionModifier(ILanguageFactory langFactory) {
+ this.langFactory = langFactory;
+ }
+
+ /*
+ * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
+ */
+ public IExpression modify(IFunction function) {
+ IExpression[] args = function.getParameters();
+ IFunction func = null;
+
+ if (function.getName().equalsIgnoreCase("left")) { //$NON-NLS-1$
+ func = langFactory.createFunction("SUBSTR", //$NON-NLS-1$
+ new IExpression[] {
+ args[0],
+ langFactory.createLiteral(Integer.valueOf(1), TypeFacility.RUNTIME_TYPES.INTEGER),
+ args[1]},
+ String.class);
+ } else if (function.getName().equalsIgnoreCase("right")) { //$NON-NLS-1$
+ IFunction negIndex = langFactory.createFunction("*", //$NON-NLS-1$
+ new IExpression[] {langFactory.createLiteral(Integer.valueOf(-1), TypeFacility.RUNTIME_TYPES.INTEGER), args[1]},
+ Integer.class);
+
+ func = langFactory.createFunction("SUBSTR", //$NON-NLS-1$
+ new IExpression[] {
+ args[0],
+ negIndex},
+ String.class);
+ }
+
+ return func;
+ }
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LeftOrRightFunctionModifier.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleCapabilities.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleCapabilities.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -106,7 +106,7 @@
supportedFunctions.add("CONVERT"); //$NON-NLS-1$
supportedFunctions.add("IFNULL"); //$NON-NLS-1$
supportedFunctions.add("NVL"); //$NON-NLS-1$
-
+ supportedFunctions.add("COALESCE"); //$NON-NLS-1$
return supportedFunctions;
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleConvertModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleConvertModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,42 +22,29 @@
package com.metamatrix.connector.jdbc.oracle;
-import java.util.Iterator;
import java.util.List;
-import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.jdbc.extension.FunctionModifier;
import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
import com.metamatrix.connector.jdbc.extension.impl.DropFunctionModifier;
-import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
import com.metamatrix.connector.language.ILiteral;
-import com.metamatrix.connector.language.IScalarSubquery;
-import com.metamatrix.connector.language.ISelectSymbol;
-import com.metamatrix.connector.metadata.runtime.Element;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
/**
*/
public class OracleConvertModifier extends BasicFunctionModifier implements FunctionModifier {
private static DropFunctionModifier DROP_MODIFIER = new DropFunctionModifier();
private ILanguageFactory langFactory;
- private RuntimeMetadata metadata;
- private ConnectorLogger logger;
- public OracleConvertModifier(ILanguageFactory langFactory, RuntimeMetadata metadata, ConnectorLogger logger) {
+ public OracleConvertModifier(ILanguageFactory langFactory, ConnectorLogger logger) {
this.langFactory = langFactory;
- this.metadata = metadata;
- this.logger = logger;
}
/**
- * Intentially return null, rely on the SQLStringVisitor being used by caller
+ * Intentionally return null, rely on the SQLStringVisitor being used by caller
* (Oracle or Oracle8 SQLConversionVisitor (SQLConversionVisitor))
* @see com.metamatrix.connector.jdbc.extension.FunctionModifier#translate(com.metamatrix.connector.language.IFunction)
*/
@@ -69,140 +56,41 @@
IExpression[] args = function.getParameters();
IExpression modified = null;
- if (args[0] != null && args[0] instanceof ILiteral && ((ILiteral)args[0]).getValue() == null ) {
- if (args[1] != null && args[1] instanceof ILiteral) {
- // This is a convert(null, ...) or cast(null as ...)
- modified = convertNull(function);
- return modified;
- }
- }
-
- if (args[1] != null && args[1] instanceof ILiteral) {
- String target = ((String)((ILiteral)args[1]).getValue()).toLowerCase();
- if (target.equals("string")) { //$NON-NLS-1$
- modified = convertToString(function);
- } else if (target.equals("short")) { //$NON-NLS-1$
- modified = convertToShort(function);
- } else if (target.equals("integer")) { //$NON-NLS-1$
- modified = convertToInteger(function);
- } else if (target.equals("long")) { //$NON-NLS-1$
- modified = convertToLong(function);
- } else if (target.equals("biginteger")) { //$NON-NLS-1$
- modified = convertToBigInteger(function);
- } else if (target.equals("float")) { //$NON-NLS-1$
- modified = convertToFloat(function);
- } else if (target.equals("double")) { //$NON-NLS-1$
- modified = convertToDouble(function);
- } else if (target.equals("bigdecimal")) { //$NON-NLS-1$
- modified = convertToBigDecimal(function);
- } else if (target.equals("date")) { //$NON-NLS-1$
- modified = convertToDate(function);
- } else if (target.equals("time")) { //$NON-NLS-1$
- modified = convertToTime(function);
- } else if (target.equals("timestamp")) { //$NON-NLS-1$
- modified = convertToTimestamp(function);
- } else if (target.equals("char")) { //$NON-NLS-1$
- modified = convertToChar(function);
- } else if (target.equals("boolean")) { //$NON-NLS-1$
- modified = convertToBoolean(function);
- } else if (target.equals("byte")) { //$NON-NLS-1$
- modified = convertToByte(function);
- } else {
- modified = DROP_MODIFIER.modify(function);
- }
- return modified;
-
- }
- return DROP_MODIFIER.modify(function);
- }
-
- /**
- * In Oracle 8i only, there are cases where a null in the select clause
- * must be wrapped by a cast function, casting to the appropriate type.
- * This happens when a Union is submitted to Oracle 8i. A null must
- * be explicitly casted to the type of it's corresponding symbol in
- * another branch of the Union.
- *
- * For example, the following query would fail in 8i:
- *
- * <code>select null from TableX Union select dateColumn from TableY</code>
- *
- * The above query would have to be rewritten as
- *
- * <code>select cast(null as date) from TableX Union select dateColumn from TableY</code>
- *
- * This isn't necessary, though, for textual types (string, char, etc.) so the
- * cast/convert function will be dropped.
- *
- * (Date is Oracle type for timestamps and dates.)
- *
- * @param function IFunction to be converted
- */
- private IExpression convertNull(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- String typeName = null;
- Class functionClass = null;
-
String target = ((String)((ILiteral)args[1]).getValue()).toLowerCase();
if (target.equals("string")) { //$NON-NLS-1$
- convert = DROP_MODIFIER.modify(function);
+ modified = convertToString(function);
} else if (target.equals("short")) { //$NON-NLS-1$
- typeName = "Number"; //$NON-NLS-1$
- functionClass = Integer.class;
+ modified = convertToShort(function);
} else if (target.equals("integer")) { //$NON-NLS-1$
- typeName = "Number"; //$NON-NLS-1$
- functionClass = Integer.class;
+ modified = convertToInteger(function);
} else if (target.equals("long")) { //$NON-NLS-1$
- typeName = "Number"; //$NON-NLS-1$
- functionClass = Integer.class;
+ modified = convertToLong(function);
} else if (target.equals("biginteger")) { //$NON-NLS-1$
- typeName = "Number"; //$NON-NLS-1$
- functionClass = Integer.class;
+ modified = convertToBigInteger(function);
} else if (target.equals("float")) { //$NON-NLS-1$
- typeName = "float"; //$NON-NLS-1$
- functionClass = Float.class;
+ modified = convertToFloat(function);
} else if (target.equals("double")) { //$NON-NLS-1$
- typeName = "Number"; //$NON-NLS-1$
- functionClass = Integer.class;
+ modified = convertToDouble(function);
} else if (target.equals("bigdecimal")) { //$NON-NLS-1$
- typeName = "float"; //$NON-NLS-1$
- functionClass = Float.class;
+ modified = convertToBigDecimal(function);
} else if (target.equals("date")) { //$NON-NLS-1$
- typeName = TypeFacility.RUNTIME_NAMES.DATE;
- functionClass = java.sql.Date.class;
+ modified = convertToDate(function);
} else if (target.equals("time")) { //$NON-NLS-1$
- typeName = TypeFacility.RUNTIME_NAMES.DATE;
- functionClass = java.sql.Time.class;
+ modified = convertToTime(function);
} else if (target.equals("timestamp")) { //$NON-NLS-1$
- typeName = TypeFacility.RUNTIME_NAMES.DATE;
- functionClass = java.sql.Timestamp.class;
+ modified = convertToTimestamp(function);
} else if (target.equals("char")) { //$NON-NLS-1$
- convert = DROP_MODIFIER.modify(function);
+ modified = convertToChar(function);
} else if (target.equals("boolean")) { //$NON-NLS-1$
- typeName = "Number"; //$NON-NLS-1$
- functionClass = Integer.class;
+ modified = convertToBoolean(function);
} else if (target.equals("byte")) { //$NON-NLS-1$
- typeName = "Number"; //$NON-NLS-1$
- functionClass = Integer.class;
+ modified = convertToByte(function);
} else {
- convert = DROP_MODIFIER.modify(function);
+ modified = DROP_MODIFIER.modify(function);
}
-
- if (convert == null) {
- // cast (NULL as ...) -- > cast(NULL as ...)
- // or
- // convert (NULL, ...) -- > cast(NULL as ...)
- convert = langFactory.createFunction("cast", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- langFactory.createLiteral(typeName, String.class)},
- functionClass);
- }
-
- return convert;
+ return modified;
}
-
+
private IExpression convertToDate(IFunction function) {
IExpression convert = null;
IExpression[] args = function.getParameters();
@@ -262,24 +150,18 @@
break;
case TIMESTAMP:
// convert(timestamp, time)
- // --> to_date(('1970-01-01 ' ||substr(to_char(timestampvalue, 'YYYY-MM-DD HH24:MI:SS'), 12)),
+ // --> to_date(('1970-01-01 ' || to_char(timestampvalue, 'HH24:MI:SS'))),
// 'YYYY-MM-DD HH24:MI:SS')
IFunction inner = langFactory.createFunction("to_char", //$NON-NLS-1$
new IExpression[] {
args[0],
- langFactory.createLiteral("FXYYYY-MM-DD HH24:MI:SS", String.class)}, //$NON-NLS-1$
+ langFactory.createLiteral("HH24:MI:SS", String.class)}, //$NON-NLS-1$
String.class);
- IFunction intermediate = langFactory.createFunction("substr", //$NON-NLS-1$
- new IExpression[] {
- inner,
- langFactory.createLiteral(new Integer(12), Integer.class)},
- String.class);
-
IExpression prependedPart = langFactory.createFunction("||", //$NON-NLS-1$
new IExpression[] {
langFactory.createLiteral("1970-01-01 ", String.class), //$NON-NLS-1$
- intermediate},
+ inner},
String.class);
convert = langFactory.createFunction("to_date", //$NON-NLS-1$
@@ -295,40 +177,22 @@
return convert;
}
- /**
- * This works only for Oracle 9i.
- * @param src
- * @return IFunction
- */
private IExpression convertToTimestamp(IFunction function) {
IExpression convert = null;
IExpression[] args = function.getParameters();
Class srcType = args[0].getType();
int srcCode = getSrcCode(srcType);
- //TODO: what is the best format for timestamp
- //String format = "YYYY-MM-DD HH24:MI:SS.fffffffff"; //$NON-NLS-1$
- String format = "YYYY-MM-DD HH24:MI:SS"; //$NON-NLS-1$
switch(srcCode) {
case STRING:
- // convert(STRING, timestamp) --> to_date(timestampvalue, 'YYYY-MM-DD HH24:MI:SS'))) from smalla
- format = "YYYY-MM-DD HH24:MI:SS.FF"; //$NON-NLS-1$
+ // convert(STRING, timestamp) --> to_date(timestampvalue, 'YYYY-MM-DD HH24:MI:SS.FF')))
+ String format = "YYYY-MM-DD HH24:MI:SS.FF"; //$NON-NLS-1$
convert = dateTypeHelper("to_timestamp", new IExpression[] {args[0], //$NON-NLS-1$
langFactory.createLiteral(format, String.class)}, java.sql.Timestamp.class);
break;
case TIME:
case DATE:
- // convert(DATE, timestamp) --> to_date(to_char(DATE, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS')
- IFunction inner = langFactory.createFunction("to_char", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- langFactory.createLiteral(format, String.class)},
- String.class);
-
- convert = langFactory.createFunction("to_date", //$NON-NLS-1$
- new IExpression[] {
- inner,
- langFactory.createLiteral(format, String.class)},
- java.sql.Timestamp.class);
+ convert = dateTypeHelper("cast", new IExpression[] {args[0], //$NON-NLS-1$
+ langFactory.createLiteral("timestamp", String.class)}, java.sql.Timestamp.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -350,7 +214,6 @@
IExpression convert = null;
IExpression[] args = function.getParameters();
String format = null;
- boolean dateTypeFound = false;
int srcCode = getSrcCode(function);
switch(srcCode) { // convert(input, string) --> to_char(input)
@@ -384,56 +247,7 @@
convert = createStringFunction(args[0], format);
break;
case TIMESTAMP:
- if (args[0] instanceof IElement) {
- IElement element = (IElement) args[0];
- MetadataID id = element.getMetadataID();
- RuntimeMetadata rmd = this.metadata;
- try {
- Element elemMetadata = (Element)rmd.getObject(id);
- String nativeType = elemMetadata.getNativeType();
- if (nativeType != null && nativeType.equalsIgnoreCase("DATE")) { //$NON-NLS-1$
- dateTypeFound = true;
- }
- }
- catch (ConnectorException e) {
- logger.logError(e.getMessage());
- }
- }
- else if (args[0] instanceof IScalarSubquery) {
- IScalarSubquery scalar = (IScalarSubquery) args[0];
- List symList = scalar.getQuery().getProjectedQuery().getSelect().getSelectSymbols();
- Iterator iter = symList.iterator();
- while(iter.hasNext()) {
- ISelectSymbol symObj = (ISelectSymbol)iter.next();
- IExpression expObj = symObj.getExpression();
- if (expObj instanceof IElement) {
- IElement element = (IElement)expObj;
- MetadataID id = element.getMetadataID();
- RuntimeMetadata rmd = this.metadata;
- try {
- Element elemMetadata = (Element)rmd.getObject(id);
- String nativeType = elemMetadata.getNativeType();
- if (nativeType != null && nativeType.equalsIgnoreCase("DATE")) { //$NON-NLS-1$
- dateTypeFound = true;
- }
- }
- catch (ConnectorException e) {
- logger.logError(e.getMessage());
-
- }
- }
- }
-
- }
-
- if (dateTypeFound) {
- format = "YYYY-MM-DD HH24:MI:SS"; //$NON-NLS-1$
- }
- else {
- format = "YYYY-MM-DD HH24:MI:SS.FF"; //$NON-NLS-1$
- }
-
- convert = createStringFunction(args[0], format);
+ convert = createStringFunction(args[0], "YYYY-MM-DD HH24:MI:SS.FF"); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,282 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.oracle;
-
-import java.sql.Time;
-import java.util.Iterator;
-
-import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.language.ICompareCriteria;
-import com.metamatrix.connector.language.IElement;
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.language.IGroup;
-import com.metamatrix.connector.language.IInsert;
-import com.metamatrix.connector.language.ILanguageObject;
-import com.metamatrix.connector.language.ILimit;
-import com.metamatrix.connector.language.ILiteral;
-import com.metamatrix.connector.language.ISelect;
-import com.metamatrix.connector.language.ISetQuery.Operation;
-import com.metamatrix.connector.metadata.runtime.Element;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
-
-/**
- */
-public class OracleSQLConversionVisitor extends SQLConversionVisitor {
-
- private final int MAX_SELECT_ALIAS_LENGTH = 30;
-
- private final int MAX_TABLE_ALIAS_LENGTH = 30;
-
- protected final static String DUAL = "DUAL"; //$NON-NLS-1$
- protected final static String ROWNUM = "ROWNUM"; //$NON-NLS-1$
- protected final static String SEQUENCE = ":SEQUENCE="; //$NON-NLS-1$
- protected final static String HINT_PREFIX = "/*+"; //$NON-NLS-1$
-
-
- /**
- * Overriden to check for Oracle SQL hints
- * @param obj ISelect object
- * @since 4.3
- */
- protected void visitSelect(ISelect obj) {
- buffer.append(SELECT).append(SPACE);
- buffer.append(addProcessComment());
-
- // Check for db hints
- Object payload = this.getExecutionContext().getExecutionPayload();
- if (payload instanceof String) {
- String payloadString = (String)payload;
- if (payloadString.startsWith(HINT_PREFIX)) {
- buffer.append(payloadString).append(SPACE);
- }
- }
-
- if (obj.isDistinct()) {
- buffer.append(DISTINCT).append(SPACE);
- }
- append(obj.getSelectSymbols());
- }
-
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.connector.language.IGroup)
- */
- protected boolean useAsInGroupAlias(){
- return false;
- }
-
- /**
- * Don't fully qualify elements if table = DUAL or element = ROWNUM or special stuff is packed into name in source value.
- *
- * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#skipGroupInElement(java.lang.String, java.lang.String)
- * @since 5.0
- */
- protected String replaceElementName(String group, String element) {
-
- // Check if the element was modeled as using a Sequence
- String elementTrueName = getElementTrueName(element);
- if (elementTrueName != null) {
- return group + DOT + elementTrueName;
- }
-
- // Check if the group name should be discarded
- if((group != null && group.equalsIgnoreCase(DUAL)) || element.equalsIgnoreCase(ROWNUM)) {
- // Strip group if group or element are pseudo-columns
- return element;
- }
-
- return null;
- }
-
- /**
- * Check if the element was modeled as using a Sequence to
- * generate a unique value for Inserting - strip off everything
- * except the element name. Otherwise return null.
- * @param element
- * @return
- * @since 4.3
- */
- protected String getElementTrueName(String element) {
-
- int useIndex = element.indexOf(SEQUENCE);
- if (useIndex >= 0) {
- return element.substring(0, useIndex);
- }
-
- return null;
- }
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#translateLiteralTime(java.sql.Time)
- */
- protected String translateLiteralTime(Time timeValue) {
- return "{ts'1970-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private static final String DATE_TYPE = "DATE"; //$NON-NLS-1$
-
- public void visit(ICompareCriteria obj) {
- IExpression leftExpression = obj.getLeftExpression();
- append(leftExpression);
- buffer.append(SPACE);
-
- switch(obj.getOperator()) {
- case EQ: buffer.append(EQ); break;
- case GE: buffer.append(GE); break;
- case GT: buffer.append(GT); break;
- case LE: buffer.append(LE); break;
- case LT: buffer.append(LT); break;
- case NE: buffer.append(NE); break;
- }
- buffer.append(SPACE);
-
- IExpression rightExpression = obj.getRightExpression();
- if(leftExpression instanceof IElement && rightExpression instanceof ILiteral && ((ILiteral)rightExpression).getType().equals(TypeFacility.RUNTIME_TYPES.TIMESTAMP) && ((ILiteral)rightExpression).getValue() != null) {
- translateStringToTimestampConversion(leftExpression, rightExpression);
-
- } else {
- append(rightExpression);
- }
- }
-
- /**
- * If a column is modeled with name in source indicating that an Oracle Sequence should
- * be used to generate the value to insert, then pull the Sequence name out of the name
- * in source of the column, discard the (dummy) literal value from the user-entered value list,
- * and replace with the Sequence (as an IElement).
- * Implementation note: An IGroup will be used for the Sequence name, and an IElement will be used
- * for the Sequence operation (i.e. "nextVal").
- * This nasty kludge is brought to you by Tier 3.
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#visit(com.metamatrix.connector.language.IInsert)
- * @since 4.3
- */
- public void visit(IInsert obj) {
-
- Iterator iter = obj.getElements().iterator();
- for (int i=0; i<obj.getElements().size(); i++) {
-
- IElement element = (IElement)iter.next();
- MetadataID metadataID = element.getMetadataID();
- if (metadataID != null) {
- String name = getName(metadataID);
-
- //Check whether a Sequence should be used to insert value for this column
- String upperName = name.toUpperCase();
- int index = upperName.indexOf(SEQUENCE);
- if (index >= 0) {
-
- String sequence = name.substring(index + SEQUENCE.length());
-
- int delimiterIndex = sequence.indexOf(DOT);
- if (delimiterIndex >= 0) {
- String sequenceGroupName = sequence.substring(0, delimiterIndex);
- String sequenceElementName = sequence.substring(delimiterIndex + 1);
-
- ILanguageObject previousValue = (ILanguageObject)obj.getValues().get(i);
- IGroup sequenceGroup = this.getLanguageFactory().createGroup(sequenceGroupName, null, null);
- IElement sequenceElement = this.getLanguageFactory().createElement(sequenceElementName, sequenceGroup, null, previousValue.getClass());
-
- obj.getValues().set(i, sequenceElement);
-
- }
- }
-
- }
-
- }
-
- super.visit(obj);
- }
-
- protected void translateStringToTimestampConversion(IExpression leftExpression,
- IExpression rightExpression) {
- String nativeType = DATE_TYPE;
-
- try {
- // Determine native type of left element
- IElement element = (IElement) leftExpression;
- MetadataID metadataID = element.getMetadataID();
- Element elem = (Element) super.metadata.getObject(metadataID);
- nativeType = elem.getNativeType();
- } catch(ConnectorException e) {
- // ignore, use default
- }
-
- // Translate timestamp based on native type of compared element - Oracle will
- // only use an index for date or timestamp type columns if the proper function
- // is used. The importer will import date types as type=DATE and timestamp types
- // as type=TIMESTAMP(0), etc.
- ILiteral timestamp = (ILiteral) rightExpression;
- if(nativeType != null && nativeType.equalsIgnoreCase(DATE_TYPE)) {
- buffer.append("to_date('"); //$NON-NLS-1$
-
- String tsValue = formatDateValue(timestamp.getValue());
- int decimalIndex = tsValue.lastIndexOf("."); //$NON-NLS-1$
- if(decimalIndex >= 0) {
- buffer.append(tsValue.substring(0, decimalIndex));
- } else {
- buffer.append(tsValue);
- }
- buffer.append("','YYYY-MM-DD HH24:MI:SS')");//$NON-NLS-1$
- } else {
- buffer.append("to_timestamp('"); //$NON-NLS-1$
- buffer.append(formatDateValue(timestamp.getValue()));
- buffer.append("','YYYY-MM-DD HH24:MI:SS.FF')");//$NON-NLS-1$
- }
- }
-
- public void visit(ILimit obj) {
- //limits should be removed by the translator
- }
-
- /**
- * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#appendSetOperation(com.metamatrix.connector.language.ISetQuery.Operation)
- */
- @Override
- protected void appendSetOperation(Operation operation) {
- if (operation.equals(Operation.EXCEPT)) {
- buffer.append("MINUS"); //$NON-NLS-1$
- } else {
- super.appendSetOperation(operation);
- }
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#getMaxSelectAliasLength()
- * @since 4.3
- */
- protected int getMaxSelectAliasLength() {
- return MAX_SELECT_ALIAS_LENGTH;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#getMaxTableAliasLength()
- * @since 4.3
- */
- protected int getMaxTableAliasLength() {
- return MAX_TABLE_ALIAS_LENGTH;
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -24,272 +24,207 @@
*/
package com.metamatrix.connector.jdbc.oracle;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
+import com.metamatrix.connector.api.SourceSystemFunctions;
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
import com.metamatrix.connector.language.ICommand;
-import com.metamatrix.connector.language.ICriteria;
import com.metamatrix.connector.language.IElement;
-import com.metamatrix.connector.language.IFrom;
-import com.metamatrix.connector.language.IFromItem;
import com.metamatrix.connector.language.IGroup;
-import com.metamatrix.connector.language.IInlineView;
-import com.metamatrix.connector.language.ILanguageFactory;
+import com.metamatrix.connector.language.IInsert;
import com.metamatrix.connector.language.ILimit;
-import com.metamatrix.connector.language.ILiteral;
-import com.metamatrix.connector.language.IOrderBy;
-import com.metamatrix.connector.language.IOrderByItem;
-import com.metamatrix.connector.language.IQuery;
-import com.metamatrix.connector.language.IQueryCommand;
-import com.metamatrix.connector.language.ISelect;
-import com.metamatrix.connector.language.ISelectSymbol;
-import com.metamatrix.connector.language.ISetQuery;
-import com.metamatrix.connector.language.ICompareCriteria.Operator;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.visitor.util.CollectorVisitor;
-import com.metamatrix.connector.visitor.util.SQLStringVisitor;
+import com.metamatrix.connector.language.ISetQuery.Operation;
+import com.metamatrix.connector.metadata.runtime.Element;
+import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.visitor.util.SQLReservedWords;
/**
*/
-public class OracleSQLTranslator extends BasicSQLTranslator {
-
- protected final static String ROWNUM = "ROWNUM"; //$NON-NLS-1$
- protected final static String ROWNUM_ALIAS = "MM_ROWNUM"; //$NON-NLS-1$
- protected final static String INLINE_VIEW_ALIAS = "MM_VIEW_FOR_LIMIT"; //$NON-NLS-1$
- protected final static String ROOT_EXPRESSION_NAME = "expr"; //$NON-NLS-1$
-
-
-
- private Map functionModifiers;
- private Properties connectorProperties;
- private ILanguageFactory languageFactory;
-
- public void initialize(ConnectorEnvironment env,
- RuntimeMetadata metadata) throws ConnectorException {
-
- super.initialize(env, metadata);
- ConnectorEnvironment connEnv = getConnectorEnvironment();
- this.connectorProperties = connEnv.getProperties();
- this.languageFactory = connEnv.getLanguageFactory();
- initializeFunctionModifiers();
-
+public class OracleSQLTranslator extends SQLTranslator {
+
+ public final static String HINT_PREFIX = "/*+"; //$NON-NLS-1$
+ public final static String DUAL = "DUAL"; //$NON-NLS-1$
+ public final static String ROWNUM = "ROWNUM"; //$NON-NLS-1$
+ public final static String SEQUENCE = ":SEQUENCE="; //$NON-NLS-1$
+
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+ registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("nvl")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("ln")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.CEILING, new AliasModifier("ceil")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.LOG10, new Log10FunctionModifier(getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, new OracleConvertModifier(getLanguageFactory(), getEnvironment().getLogger())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractFunctionModifier("HOUR"));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractFunctionModifier("YEAR"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractFunctionModifier("MINUTE"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractFunctionModifier("SECOND"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractFunctionModifier("MONTH"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractFunctionModifier("DAY"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Month"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.DAYNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Day"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.WEEK, new DayWeekQuarterFunctionModifier(getLanguageFactory(), "WW"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.QUARTER, new DayWeekQuarterFunctionModifier(getLanguageFactory(), "Q"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new DayWeekQuarterFunctionModifier(getLanguageFactory(), "D"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new DayWeekQuarterFunctionModifier(getLanguageFactory(), "DDD"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory()));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new ConcatFunctionModifier(getLanguageFactory())); //$NON-NLS-1$
+ }
+
+ @Override
+ public ICommand modifyCommand(ICommand command, ExecutionContext context)
+ throws ConnectorException {
+ if (!(command instanceof IInsert)) {
+ return command;
+ }
+
+ /*
+ * If a missing auto_increment column is modeled with name in source indicating that an Oracle Sequence
+ * then pull the Sequence name out of the name in source of the column.
+ */
+ IInsert insert = (IInsert)command;
+ List<MetadataID> allElements = insert.getGroup().getMetadataID().getChildIDs();
+ if (allElements.size() == insert.getValues().size()) {
+ return command;
+ }
+
+ int index = 0;
+ List<IElement> elements = insert.getElements();
+
+ for (MetadataID metadataID : allElements) {
+ Element element = (Element)metadataID.getMetadataObject();
+ if (!element.isAutoIncremented()) {
+ continue;
+ }
+ String name = element.getNameInSource();
+ int seqIndex = name.indexOf(SEQUENCE);
+ if (seqIndex == -1) {
+ continue;
+ }
+ boolean found = false;
+ while (index < elements.size()) {
+ if (metadataID.equals(elements.get(index).getMetadataID())) {
+ found = true;
+ break;
+ }
+ index++;
+ }
+ if (found) {
+ continue;
+ }
+
+ String sequence = name.substring(seqIndex + SEQUENCE.length());
+
+ int delimiterIndex = sequence.indexOf(SQLReservedWords.DOT);
+ if (delimiterIndex == -1) {
+ throw new ConnectorException("Invalid name in source sequence format. Expected <element name>" + SEQUENCE + "<sequence name>.<sequence value>, but was " + name);
+ }
+ String sequenceGroupName = sequence.substring(0, delimiterIndex);
+ String sequenceElementName = sequence.substring(delimiterIndex + 1);
+
+ IGroup sequenceGroup = this.getLanguageFactory().createGroup(sequenceGroupName, null, null);
+ IElement sequenceElement = this.getLanguageFactory().createElement(sequenceElementName, sequenceGroup, null, element.getJavaType());
+ insert.getElements().add(index, this.getLanguageFactory().createElement(element.getMetadataID().getName(), insert.getGroup(), metadataID, element.getJavaType()));
+ insert.getValues().add(index, sequenceElement);
+ }
+ return command;
}
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator#modifyCommand(com.metamatrix.connector.language.ICommand, com.metamatrix.connector.api.ExecutionContext)
- * @since 5.0
- */
- public ICommand modifyCommand(ICommand command, ExecutionContext context) throws ConnectorException {
- command = super.modifyCommand(command, context);
- Collection subCommands = CollectorVisitor.collectObjects(IInlineView.class, command);
- for (Iterator i = subCommands.iterator(); i.hasNext();) {
- IInlineView inlineView = (IInlineView)i.next();
- inlineView.setQuery((IQueryCommand)modifyCommand(inlineView.getQuery(), context));
- }
-
- if (!(command instanceof IQueryCommand)) {
- return command;
- }
-
- return modifySingleCommand((IQueryCommand)command, context);
- }
-
- protected IQueryCommand modifySingleCommand(IQueryCommand command, ExecutionContext context) {
- if (command instanceof ISetQuery) {
- ISetQuery union = (ISetQuery)command;
- union.setLeftQuery(modifySingleCommand(union.getLeftQuery(), context));
- union.setRightQuery(modifySingleCommand(union.getRightQuery(), context));
- return union;
- }
-
- if (command.getLimit() == null) {
- return command;
- }
-
- ILimit limit = command.getLimit();
- command.setLimit(null);
-
- List<ICriteria> lstCriteria = new ArrayList<ICriteria>();
-
- if (limit.getRowOffset() > 0) {
- IGroup group = languageFactory.createGroup(INLINE_VIEW_ALIAS, null, null);
- IElement eleRowNum = languageFactory.createElement(ROWNUM_ALIAS, group, null, TypeFacility.RUNTIME_TYPES.INTEGER);
- ILiteral litOffset = languageFactory.createLiteral(new Integer( limit.getRowOffset() ), TypeFacility.RUNTIME_TYPES.INTEGER);
- ICriteria criteria = languageFactory.createCompareCriteria(Operator.GT, eleRowNum, litOffset);
- lstCriteria.add( criteria );
- }
-
- IGroup group = languageFactory.createGroup(INLINE_VIEW_ALIAS, null, null);
- IElement eleRowNum = languageFactory.createElement(ROWNUM_ALIAS, group, null, TypeFacility.RUNTIME_TYPES.INTEGER);
- ILiteral litLimit = languageFactory.createLiteral(new Integer( limit.getRowOffset() + limit.getRowLimit() ),TypeFacility.RUNTIME_TYPES.INTEGER);
- ICriteria criteria = languageFactory.createCompareCriteria(Operator.LE, eleRowNum, litLimit);
- lstCriteria.add( criteria );
-
- if ( lstCriteria.size() == 1 ) {
- criteria = lstCriteria.get( 0 );
- } else {
- criteria = languageFactory.createCompoundCriteria(com.metamatrix.connector.language.ICompoundCriteria.Operator.AND, lstCriteria );
- }
-
- IQuery intermediate = createLimitQuery(command, null, true);
-
- IQuery result = createLimitQuery(intermediate, criteria, false);
-
- eleRowNum = languageFactory.createElement(OracleSQLConversionVisitor.ROWNUM, null, null, TypeFacility.RUNTIME_TYPES.INTEGER);
- ISelectSymbol newSelectSymbol = languageFactory.createSelectSymbol(ROWNUM_ALIAS, eleRowNum);
- newSelectSymbol.setAlias(true);
- intermediate.getSelect().getSelectSymbols().add(newSelectSymbol);
-
- return result;
- }
-
- /**
- * @param query
- * @param criteria
- * @return
- * @since 5.0
- */
- private IQuery createLimitQuery(IQueryCommand query,
- ICriteria criteria, boolean alias) {
- IInlineView view = languageFactory.createInlineView(query, INLINE_VIEW_ALIAS);
-
- IFrom from = languageFactory.createFrom(Arrays.asList(new IFromItem[] {view}));
-
- LinkedHashMap<String, Class<?>> names = new LinkedHashMap<String, Class<?>>();
-
- List symbols = query.getProjectedQuery().getSelect().getSelectSymbols();
- IOrderBy orderBy = query.getOrderBy();
- HashMap<String, IOrderByItem> orderByNames = null;
- if (orderBy != null) {
- orderByNames = new HashMap<String, IOrderByItem>();
- for (IOrderByItem item : (List<IOrderByItem>)orderBy.getItems()) {
- if (item.getName() != null) {
- orderByNames.put(item.getName().toLowerCase(), item);
- }
+
+ @Override
+ public String addLimitString(String queryCommand, ILimit limit) {
+ StringBuffer limitQuery = new StringBuffer(queryCommand.length());
+ if (limit.getRowOffset() > 0) {
+ limitQuery.append("SELECT * FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (");
+ } else {
+ limitQuery.append("SELECT * FROM (");
+ }
+ limitQuery.append(queryCommand);
+ if (limit.getRowOffset() > 0) {
+ limitQuery.append(") VIEW_FOR_LIMIT WHERE ROWNUM <= ").append(
+ limit.getRowLimit()).append(") WHERE ROWNUM_ > ").append(
+ limit.getRowOffset());
+ } else {
+ limitQuery.append(") WHERE ROWNUM <= ").append(
+ limit.getRowLimit());
+ }
+ return limitQuery.toString();
+ }
+
+ @Override
+ public boolean useAsInGroupAlias(){
+ return false;
+ }
+
+ @Override
+ public String getSetOperationString(Operation operation) {
+ if (operation == Operation.EXCEPT) {
+ return "MINUS"; //$NON-NLS-1$
+ }
+ return super.getSetOperationString(operation);
+ }
+
+ @Override
+ public String getSourceComment(ExecutionContext context, ICommand command) {
+ String comment = super.getSourceComment(context, command);
+
+ if (context != null) {
+ // Check for db hints
+ Object payload = context.getExecutionPayload();
+ if (payload instanceof String) {
+ String payloadString = (String)payload;
+ if (payloadString.startsWith(HINT_PREFIX)) {
+ comment += payloadString + " "; //$NON-NLS-1$
+ }
+ }
+ }
+ return comment;
+ }
+
+ /**
+ * Don't fully qualify elements if table = DUAL or element = ROWNUM or special stuff is packed into name in source value.
+ *
+ * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#skipGroupInElement(java.lang.String, java.lang.String)
+ * @since 5.0
+ */
+ @Override
+ public String replaceElementName(String group, String element) {
+
+ // Check if the element was modeled as using a Sequence
+ int useIndex = element.indexOf(SEQUENCE);
+ if (useIndex >= 0) {
+ String name = element.substring(0, useIndex);
+ if (group != null) {
+ return group + SQLReservedWords.DOT + name;
}
+ return name;
}
-
- for (int i = 0; i < symbols.size(); i++) {
- ISelectSymbol symbol = (ISelectSymbol)symbols.get(i);
-
- String originalName = null;
-
- if (symbol.getExpression() instanceof IElement || symbol.hasAlias()) {
- originalName = SQLStringVisitor.getElementShortName(symbol.getOutputName()).toLowerCase();
- } else if (alias) {
- originalName = ROOT_EXPRESSION_NAME;
- }
-
- String name = originalName;
-
- int j = 0;
- while (names.containsKey(name)) {
- name = originalName + j++;
- }
-
- if (alias) {
- symbol.setAlias(true);
- symbol.setOutputName(name);
- if (orderByNames != null) {
- IOrderByItem item = orderByNames.get(originalName);
- if (item != null) {
- item.setName(name);
- }
- }
- }
- names.put(name, symbol.getExpression().getType());
- }
- List<ISelectSymbol> lstSelect = new ArrayList<ISelectSymbol>();
-
- for (Map.Entry<String, Class<?>> entry : names.entrySet()) {
- IGroup group = languageFactory.createGroup(INLINE_VIEW_ALIAS, null, null);
- IElement expression = languageFactory.createElement(entry.getKey(), group, null, entry.getValue());
- ISelectSymbol newSymbol = languageFactory.createSelectSymbol(entry.getKey(), expression);
- lstSelect.add(newSymbol);
- }
-
- ISelect select = languageFactory.createSelect(false, lstSelect);
-
- IQuery result = languageFactory.createQuery(select, from, criteria, null, null, null);
- return result;
- }
-
- /**
- * @param modifier
- * @since 4.2
- */
- private void initializeFunctionModifiers() {
- functionModifiers = new HashMap();
- functionModifiers.putAll(super.getFunctionModifiers());
- functionModifiers.put("char", new AliasModifier("chr")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("lcase", new AliasModifier("lower")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("ucase", new AliasModifier("upper")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("ifnull", new AliasModifier("nvl")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("log", new AliasModifier("ln")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("ceiling", new AliasModifier("ceil")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("log10", new Log10FunctionModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("convert", new OracleConvertModifier(languageFactory, getRuntimeMetadata(), getConnectorEnvironment().getLogger())); //$NON-NLS-1$
- functionModifiers.put("cast", new OracleConvertModifier(languageFactory, getRuntimeMetadata(), getConnectorEnvironment().getLogger())); //$NON-NLS-1$
- functionModifiers.put("hour", new HourFunctionModifier(languageFactory));//$NON-NLS-1$
- functionModifiers.put("month", new ExtractFunctionModifier("MONTH"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("year", new ExtractFunctionModifier("YEAR"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("day", new ExtractFunctionModifier("DAY"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("minute", new DayWeekQuarterFunctionModifier(languageFactory, "MI"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("second", new DayWeekQuarterFunctionModifier(languageFactory, "SS"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("monthname", new MonthOrDayNameFunctionModifier(languageFactory, "Month"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("dayname", new MonthOrDayNameFunctionModifier(languageFactory, "Day"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("week", new DayWeekQuarterFunctionModifier(languageFactory, "WW"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("quarter", new DayWeekQuarterFunctionModifier(languageFactory, "Q"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("dayofweek", new DayWeekQuarterFunctionModifier(languageFactory, "D"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("dayofmonth", new DayWeekQuarterFunctionModifier(languageFactory, "DD"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("dayofyear", new DayWeekQuarterFunctionModifier(languageFactory, "DDD"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("formatdate", new FormatFunctionModifier(languageFactory));//$NON-NLS-1$
- functionModifiers.put("formattime", new FormatFunctionModifier(languageFactory));//$NON-NLS-1$
- functionModifiers.put("formattimestamp", new FormatFunctionModifier(languageFactory));//$NON-NLS-1$
- functionModifiers.put("parsedate", new ParseFunctionModifier(languageFactory, java.sql.Date.class));//$NON-NLS-1$
- functionModifiers.put("parsetime", new ParseFunctionModifier(languageFactory, java.sql.Time.class));//$NON-NLS-1$
- functionModifiers.put("parsetimestamp", new ParseFunctionModifier(languageFactory, java.sql.Timestamp.class));//$NON-NLS-1$
- functionModifiers.put("locate", new LocateFunctionModifier(languageFactory));//$NON-NLS-1$
- functionModifiers.put("substring", new AliasModifier("substr"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("left", new LeftOrRightFunctionModifier(languageFactory, "left"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("right", new LeftOrRightFunctionModifier(languageFactory, "right"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("concat", new ConcatFunctionModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("||", new ConcatFunctionModifier(languageFactory)); //$NON-NLS-1$
- }
-
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getTranslationVisitor()
- */
- public SQLConversionVisitor getTranslationVisitor() {
- SQLConversionVisitor visitor = new OracleSQLConversionVisitor();
- visitor.setRuntimeMetadata(getRuntimeMetadata());
- visitor.setFunctionModifiers(functionModifiers);
- visitor.setProperties(connectorProperties);
- visitor.setLanguageFactory(languageFactory);
- visitor.setDatabaseTimeZone(getDatabaseTimeZone());
- return visitor;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getFunctionModifiers()
- */
- public Map getFunctionModifiers() {
- return functionModifiers;
- }
-
+
+ // Check if the group name should be discarded
+ if((group != null && group.equalsIgnoreCase(DUAL)) || element.equalsIgnoreCase(ROWNUM)) {
+ // Strip group if group or element are pseudo-columns
+ return element;
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean hasTimeType() {
+ return false;
+ }
+
+ @Override
+ public String getConnectionTestQuery() {
+ return "Select 'x' from DUAL"; //$NON-NLS-1$
+ }
+
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ParseFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ParseFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ParseFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.oracle;
-
-import com.metamatrix.connector.jdbc.extension.FunctionModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
-import com.metamatrix.connector.language.*;
-/**
- */
-public class ParseFunctionModifier extends BasicFunctionModifier implements FunctionModifier {
- private ILanguageFactory langFactory;
- private Class targetClass;
-
- public ParseFunctionModifier(ILanguageFactory langFactory, Class targetClass) {
- this.langFactory = langFactory;
- this.targetClass = targetClass;
- }
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
- */
- public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
- String format = (String) ((ILiteral)args[1]).getValue();
-
- IFunction func = langFactory.createFunction("to_date", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- langFactory.createLiteral(format, String.class),
- },
- targetClass);
-
- return func;
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLCapabilities.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLCapabilities.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -200,7 +200,7 @@
// supportedFunctions.add("TIMEOFDAY"); //$NON-NLS-1$
//
// // Conditional
-// supportedFunctions.add("COALESCE"); //$NON-NLS-1$
+ supportedFunctions.add("COALESCE"); //$NON-NLS-1$
// supportedFunctions.add("NULLIF"); //$NON-NLS-1$
// supportedFunctions.add("GREATEST"); //$NON-NLS-1$
// supportedFunctions.add("LEAST"); //$NON-NLS-1$
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,123 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.postgresql;
-
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
-
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.language.IAggregate;
-import com.metamatrix.connector.language.ILimit;
-
-/**
- */
-class PostgreSQLConversionVisitor extends SQLConversionVisitor {
-
- protected String translateLiteralBoolean(Boolean booleanValue) {
- if(booleanValue.booleanValue()) {
- return "TRUE"; //$NON-NLS-1$
- }
- return "FALSE"; //$NON-NLS-1$
- }
-
- protected String translateLiteralDate(Date dateValue) {
- return "DATE '" + dateValue.toString() + "'"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- protected String translateLiteralTime(Time timeValue) {
- return "TIME '" + timeValue.toString() + "'"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- protected String translateLiteralTimestamp(Timestamp timestampValue) {
- SimpleDateFormat timestampFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //$NON-NLS-1$
- if (getDatabaseTimeZone() != null) {
- timestampFormatter.setTimeZone(getDatabaseTimeZone());
- }
- int nanos = timestampValue.getNanos();
- int micros = nanos/1000; // truncate for microseconds
- String microsStr = "" + (1000000 + micros); //$NON-NLS-1$ // Add a number at the beginning, so that we can print leading zeros
-
- return "to_timestamp('" + timestampFormatter.format(timestampValue) + "." + microsStr.substring(1) + "', 'YYYY-MM-DD HH24:MI:SS.UF')"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /**
- * Postgres doesn't provide min/max(boolean), so this conversion writes a min(booleanval) as
- * CASE MIN(CASE B.BooleanValue WHEN TRUE THEN 1 ELSE 0 END) WHEN 1 THEN TRUE ELSE FALSE END
- * TODO: This conversion implementation does not handle null values in the boolean column.
- * @see com.metamatrix.connector.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.connector.language.IAggregate)
- * @since 4.3
- */
- public void visit(IAggregate obj) {
- if ((obj.getName().equalsIgnoreCase("min") || obj.getName().equalsIgnoreCase("max")) //$NON-NLS-1$//$NON-NLS-2$
- && obj.getExpression().getType().equals(Boolean.class)) {
- buffer.append(CASE)
- .append(SPACE).append(obj.getName())
- // Inner case
- .append(LPAREN).append(CASE)
- .append(SPACE);
- append(obj.getExpression());
- buffer.append(SPACE).append(WHEN)
- .append(SPACE).append(TRUE)
- .append(SPACE).append(THEN)
- .append(SPACE).append(1)
- .append(SPACE).append(ELSE)
- .append(SPACE).append(0)
- .append(SPACE).append(END)
- .append(RPAREN)
-
- .append(SPACE).append(WHEN)
- .append(SPACE).append(1)
- .append(SPACE).append(THEN)
- .append(SPACE).append(TRUE)
- .append(SPACE).append(ELSE)
- .append(SPACE).append(FALSE)
- .append(SPACE).append(END);
- } else {
- super.visit(obj);
- }
- }
-
- /**
- * Convert limit clause to PostgreSQL ...[LIMIT rowlimit] [OFFSET offset] syntax
- * @see com.metamatrix.connector.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.connector.language.IQuery)
- * @since 5.0 SP1
- */
- public void visit(ILimit obj) {
- buffer.append(LIMIT)
- .append(SPACE)
- .append(obj.getRowLimit());
-
- if (obj.getRowOffset() > 0) {
- if (obj.getRowLimit() > 0) {
- buffer.append(SPACE);
- }
- buffer.append("OFFSET") //$NON-NLS-1$
- .append(SPACE)
- .append(obj.getRowOffset());
- }
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLConvertModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLConvertModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -34,6 +34,7 @@
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
import com.metamatrix.connector.language.ILiteral;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
/**
*/
@@ -157,10 +158,10 @@
switch(srcCode) {
case BOOLEAN:
// convert(booleanSrc, string) --> CASE WHEN booleanSrc THEN '1' ELSE '0' END
- List when = Arrays.asList(new IExpression[] {langFactory.createLiteral(Boolean.TRUE, Boolean.class)});
+ List when = Arrays.asList(langFactory.createCompareCriteria(Operator.EQ, function.getParameters()[0], langFactory.createLiteral(Boolean.TRUE, Boolean.class)));
List then = Arrays.asList(new IExpression[] {langFactory.createLiteral("1", String.class)}); //$NON-NLS-1$
IExpression elseExpr = langFactory.createLiteral("0", String.class); //$NON-NLS-1$
- return langFactory.createCaseExpression(function.getParameters()[0], when, then, elseExpr, String.class);
+ return langFactory.createSearchedCaseExpression(when, then, elseExpr, String.class);
case BYTE:
case SHORT:
case INTEGER:
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLResultsTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLResultsTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.postgresql;
-
-import com.metamatrix.connector.jdbc.extension.impl.BasicResultsTranslator;
-
-
-/**
- * @since 4.3
- */
-public class PostgreSQLResultsTranslator extends BasicResultsTranslator {
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLSingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLSingleIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLSingleIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.postgresql;
-
-import com.metamatrix.connector.jdbc.ConnectionQueryStrategy;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
-
-
-/**
- * @since 4.3
- */
-public class PostgreSQLSingleIdentityConnectionFactory extends JDBCSingleIdentityConnectionFactory {
- private String queryTest = "Select 1"; //$NON-NLS-1$
-
- /**
- * @see com.metamatrix.connector.jdbc.JDBCSourceConnectionFactory#createConnectionStrategy()
- * @since 4.3
- */
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,96 +22,125 @@
package com.metamatrix.connector.jdbc.postgresql;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
-import com.metamatrix.connector.jdbc.oracle.MonthOrDayNameFunctionModifier;
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.api.ExecutionContext;
+import com.metamatrix.connector.api.SourceSystemFunctions;
+import com.metamatrix.connector.api.TypeFacility;
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
+import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
+import com.metamatrix.connector.jdbc.oracle.LeftOrRightFunctionModifier;
+import com.metamatrix.connector.jdbc.oracle.MonthOrDayNameFunctionModifier;
+import com.metamatrix.connector.language.IAggregate;
+import com.metamatrix.connector.language.ICommand;
+import com.metamatrix.connector.language.ILimit;
+import com.metamatrix.connector.visitor.framework.HierarchyVisitor;
+import com.metamatrix.connector.visitor.util.SQLReservedWords;
/**
* @since 4.3
*/
-public class PostgreSQLTranslator extends BasicSQLTranslator {
+public class PostgreSQLTranslator extends SQLTranslator {
- private Map functionModifiers;
- private Properties connectorProperties;
- private ILanguageFactory languageFactory;
-
- public void initialize(ConnectorEnvironment env,
- RuntimeMetadata metadata) throws ConnectorException {
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
- super.initialize(env, metadata);
- ConnectorEnvironment connEnv = getConnectorEnvironment();
- this.connectorProperties = connEnv.getProperties();
- this.languageFactory = connEnv.getLanguageFactory();
- initializeFunctionModifiers();
-
- }
-
- /**
- * @param modifier
- * @since 4.2
- */
- private void initializeFunctionModifiers() {
- functionModifiers = new HashMap();
- functionModifiers.putAll(super.getFunctionModifiers());
- functionModifiers.put("log", new AliasModifier("ln")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("log10", new AliasModifier("log")); //$NON-NLS-1$ //$NON-NLS-2$
+ super.initialize(env);
+ registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("ln")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.LOG10, new AliasModifier("log")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("char", new AliasModifier("chr")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("concat", new AliasModifier("||")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("lcase", new AliasModifier("lower")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("left", new SubstringFunctionModifier(languageFactory, true));//$NON-NLS-1$
- functionModifiers.put("right", new SubstringFunctionModifier(languageFactory, false));//$NON-NLS-1$
- functionModifiers.put("substring", new AliasModifier("substr")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("ucase", new AliasModifier("upper")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new AliasModifier("||")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory()));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("dayname", new MonthOrDayNameFunctionModifier(languageFactory, "Day"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("dayofweek", new ModifiedDatePartFunctionModifier(languageFactory, "dow", "+", new Integer(1)));//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- functionModifiers.put("dayofmonth", new DatePartFunctionModifier(languageFactory, "day"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("dayofyear", new DatePartFunctionModifier(languageFactory, "doy"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("hour", new DatePartFunctionModifier(languageFactory, "hour"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("minute", new DatePartFunctionModifier(languageFactory, "minute"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("month", new DatePartFunctionModifier(languageFactory, "month"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("monthname", new MonthOrDayNameFunctionModifier(languageFactory, "Month"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("quarter", new DatePartFunctionModifier(languageFactory, "quarter"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("second", new DatePartFunctionModifier(languageFactory, "second"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("week", new DatePartFunctionModifier(languageFactory, "week"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("year", new DatePartFunctionModifier(languageFactory, "year"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.DAYNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Day"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new ModifiedDatePartFunctionModifier(getLanguageFactory(), "dow", "+", new Integer(1)));//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new DatePartFunctionModifier(getLanguageFactory(), "day"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new DatePartFunctionModifier(getLanguageFactory(), "doy"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.HOUR, new DatePartFunctionModifier(getLanguageFactory(), "hour"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.MINUTE, new DatePartFunctionModifier(getLanguageFactory(), "minute"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.MONTH, new DatePartFunctionModifier(getLanguageFactory(), "month"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Month"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.QUARTER, new DatePartFunctionModifier(getLanguageFactory(), "quarter"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.SECOND, new DatePartFunctionModifier(getLanguageFactory(), "second"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.WEEK, new DatePartFunctionModifier(getLanguageFactory(), "week"));//$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.YEAR, new DatePartFunctionModifier(getLanguageFactory(), "year"));//$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("ifnull", new AliasModifier("coalesce")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("nvl", new AliasModifier("coalesce")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("convert", new PostgreSQLConvertModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("cast", new PostgreSQLConvertModifier(languageFactory)); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, new PostgreSQLConvertModifier(getLanguageFactory())); //$NON-NLS-1$
}
-
+
+ @Override
+ public String translateLiteralBoolean(Boolean booleanValue) {
+ if(booleanValue.booleanValue()) {
+ return "TRUE"; //$NON-NLS-1$
+ }
+ return "FALSE"; //$NON-NLS-1$
+ }
+
+ @Override
+ public String translateLiteralDate(Date dateValue, Calendar cal) {
+ return "DATE '" + formatDateValue(dateValue, cal) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue, Calendar cal) {
+ return "TIME '" + formatDateValue(timeValue, cal) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue, Calendar cal) {
+ return "to_timestamp('" + formatDateValue(timestampValue, cal) + "', 'YYYY-MM-DD HH24:MI:SS.US')"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Override
+ public int getTimestampNanoSecondPrecision() {
+ return 6;
+ }
+
+ @Override
+ public String addLimitString(String queryCommand, ILimit limit) {
+ StringBuffer sb = new StringBuffer(queryCommand);
+ sb.append(" LIMIT ").append(limit.getRowLimit());
+ if (limit.getRowOffset() > 0) {
+ sb.append(" OFFSET ").append(limit.getRowOffset());
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Postgres doesn't provide min/max(boolean), so this conversion writes a min(BooleanValue) as
+ * bool_and(BooleanValue)
+ * @see com.metamatrix.connector.visitor.framework.LanguageObjectVisitor#visit(com.metamatrix.connector.language.IAggregate)
+ * @since 4.3
+ */
+ @Override
+ public ICommand modifyCommand(ICommand command, ExecutionContext context)
+ throws ConnectorException {
+ HierarchyVisitor visitor = new HierarchyVisitor() {
+ @Override
+ public void visit(IAggregate obj) {
+ if (TypeFacility.RUNTIME_TYPES.BOOLEAN.equals(obj.getExpression().getType())) {
+ if (obj.getName().equalsIgnoreCase(SQLReservedWords.MIN)) {
+ obj.setName("bool_and"); //$NON-NLS-1$
+ } else if (obj.getName().equalsIgnoreCase(SQLReservedWords.MAX)) {
+ obj.setName("bool_or"); //$NON-NLS-1$
+ }
+ }
+ }
+ };
+
+ command.acceptVisitor(visitor);
+ return command;
+ }
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getTranslationVisitor()
- */
- public SQLConversionVisitor getTranslationVisitor() {
- SQLConversionVisitor visitor = new PostgreSQLConversionVisitor();
- visitor.setRuntimeMetadata(getRuntimeMetadata());
- visitor.setFunctionModifiers(functionModifiers);
- visitor.setProperties(connectorProperties);
- visitor.setLanguageFactory(languageFactory);
- visitor.setDatabaseTimeZone(getDatabaseTimeZone());
- return visitor;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getFunctionModifiers()
- */
- public Map getFunctionModifiers() {
- return functionModifiers;
- }
-
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLUserIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLUserIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLUserIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.postgresql;
-
-import com.metamatrix.connector.jdbc.ConnectionQueryStrategy;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCUserIdentityConnectionFactory;
-
-
-/**
- * @since 4.3
- */
-public class PostgreSQLUserIdentityConnectionFactory extends JDBCUserIdentityConnectionFactory {
- private String queryTest = "Select 1"; //$NON-NLS-1$
-
- /**
- * @see com.metamatrix.connector.jdbc.JDBCSourceConnectionFactory#createConnectionStrategy()
- * @since 4.3
- */
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/SubstringFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/SubstringFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/SubstringFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.postgresql;
-
-import com.metamatrix.connector.jdbc.extension.FunctionModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
-import com.metamatrix.connector.language.*;
-
-/**
- * Convert left(string, count) --> substr(string, 0, count)
- * or right(string, count) --> substr(string, length(string) - count)
- */
-class SubstringFunctionModifier extends BasicFunctionModifier implements FunctionModifier {
- private ILanguageFactory langFactory;
- private boolean isLeft;
-
- SubstringFunctionModifier(ILanguageFactory langFactory, boolean isLeft) {
- this.langFactory = langFactory;
- this.isLeft = isLeft;
- }
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
- */
- public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
- IFunction func = null;
-
- if (isLeft) {
- func = langFactory.createFunction("substr", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- langFactory.createLiteral(new Integer(1), Integer.class),
- args[1]},
- String.class);
- } else {
- IFunction inner = langFactory.createFunction("LENGTH", //$NON-NLS-1$
- new IExpression[] {args[0]},
- Integer.class);
-
- IExpression addOne = langFactory.createFunction("+", new IExpression[] {inner, langFactory.createLiteral(new Integer(1), Integer.class)}, Integer.class); //$NON-NLS-1$
- IExpression substrArgs = langFactory.createFunction("-", //$NON-NLS-1$
- new IExpression[] {addOne, args[1] },
- Integer.class);
-
- func = langFactory.createFunction("substr", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- substrArgs},
- String.class);
- }
-
- return func;
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerCapabilities.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerCapabilities.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -77,7 +77,7 @@
supportedFunctions.add("LOWER"); //$NON-NLS-1$
//supportedFunctons.add("LPAD"); //$NON-NLS-1$
supportedFunctions.add("LTRIM"); //$NON-NLS-1$
- //supportedFunctons.add("REPEAT"); //$NON-NLS-1$
+ supportedFunctions.add("REPEAT"); //$NON-NLS-1$
//supportedFunctions.add("RAND"); //$NON-NLS-1$
supportedFunctions.add("REPLACE"); //$NON-NLS-1$
supportedFunctions.add("RIGHT"); //$NON-NLS-1$
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerConvertModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerConvertModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,516 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.sqlserver;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.metamatrix.connector.jdbc.extension.FunctionModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
-import com.metamatrix.connector.jdbc.extension.impl.DropFunctionModifier;
-import com.metamatrix.connector.language.*;
-
-/**
- * Sql Server based Convert modifier, taken from Sybase, so far they are same
- * classes.
- */
-public class SqlServerConvertModifier extends BasicFunctionModifier implements FunctionModifier {
-
- private static DropFunctionModifier DROP_MODIFIER = new DropFunctionModifier();
- static {
- // index of expressions in convert functions in SQL Server is one, not zero
- DROP_MODIFIER.setReplaceIndex(1);
- }
-
- private ILanguageFactory langFactory;
-
- public SqlServerConvertModifier(ILanguageFactory langFactory) {
- this.langFactory = langFactory;
- }
-
- public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
- IExpression modified = null;
-
- if (args[1] != null && args[1] instanceof ILiteral) {
- String target = ((String)((ILiteral)args[1]).getValue()).toLowerCase();
- if (target.equals("string")) { //$NON-NLS-1$
- modified = convertToString(function);
- } else if (target.equals("short")) { //$NON-NLS-1$
- modified = convertToShort(function);
- } else if (target.equals("integer")) { //$NON-NLS-1$
- modified = convertToInteger(function);
- } else if (target.equals("long")) { //$NON-NLS-1$
- modified = convertToLong(function);
- } else if (target.equals("biginteger")) { //$NON-NLS-1$
- modified = convertToBigInteger(function);
- } else if (target.equals("float")) { //$NON-NLS-1$
- modified = convertToFloat(function);
- } else if (target.equals("double")) { //$NON-NLS-1$
- modified = convertToDouble(function);
- } else if (target.equals("bigdecimal")) { //$NON-NLS-1$
- modified = convertToBigDecimal(function);
- } else if (target.equals("date")) { //$NON-NLS-1$
- modified = convertToDate(function);
- } else if (target.equals("time")) { //$NON-NLS-1$
- modified = convertToTime(function);
- } else if (target.equals("timestamp")) { //$NON-NLS-1$
- modified = convertToTimestamp(function);
- } else if (target.equals("char")) { //$NON-NLS-1$
- modified = convertToChar(function);
- } else if (target.equals("boolean")) { //$NON-NLS-1$
- modified = convertToBoolean(function);
- } else if (target.equals("byte")) { //$NON-NLS-1$
- modified = convertToByte(function);
- } else {
- modified = DROP_MODIFIER.modify(function);
- }
- return modified;
-
- }
- return DROP_MODIFIER.modify(function);
- }
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#translate(com.metamatrix.data.language.IFunction)
- */
- public List translate(IFunction function) {
- List parts = new ArrayList();
- parts.add("convert("); //$NON-NLS-1$
-
- IExpression[] args = function.getParameters();
-
- if(args != null && args.length > 0) {
- ILiteral type = (ILiteral) args[0];
- String typeStr = type.getValue().toString();
-
- parts.add(typeStr);
-
- for(int i=1; i<args.length; i++) {
- parts.add(", "); //$NON-NLS-1$
- parts.add(args[i]);
- }
- }
- parts.add(")"); //$NON-NLS-1$
- return parts;
- }
-
- private IExpression convertToBoolean(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
- int srcCode = getSrcCode(src);
-
- switch(srcCode) {
- case STRING:
- //TODO: how to map the 'true' to '1' before it is translated to bit
- case BYTE:
- case SHORT:
- case INTEGER:
- case LONG:
- case BIGINTEGER:
- case FLOAT:
- case DOUBLE:
- case BIGDECIMAL:
- convert = createFunction(args[0], "bit", Boolean.class); //$NON-NLS-1$
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IExpression convertToByte(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
- int srcCode = getSrcCode(src);
-
- switch(srcCode) {
- case STRING:
- case BOOLEAN:
- case SHORT:
- case INTEGER:
- case LONG:
- case BIGINTEGER:
- case FLOAT:
- case DOUBLE:
- case BIGDECIMAL:
- convert = createFunction(args[0], "tinyint", String.class); //$NON-NLS-1$
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- /**
- * Target type to String.
- * @param function
- * @return
- */
- private IExpression convertToString(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
- int srcCode = getSrcCode(src);
-
- switch(srcCode) {
- case CHAR:
- case BOOLEAN:
- case BYTE:
- case SHORT:
- case INTEGER:
- case LONG:
- case BIGINTEGER:
- case FLOAT:
- case DOUBLE:
- case BIGDECIMAL:
- convert = createFunction(args[0], "varchar", String.class); //$NON-NLS-1$
- break;
- case DATE: // convert(date, string) --> convert(varchar, date, 112)
- //TODO: what is the best format 111/110/101?
- convert = createFunction(args[0], 101, String.class);
- break;
- case TIME: // convert(time, string) --> convert(varchar, time, 108)
- convert = createFunction(args[0], 108, String.class);
- break;
- case TIMESTAMP: // convert(time, string) --> convert(varchar, timestamp, 109)
- convert = createFunction(args[0], 109, String.class);
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IExpression convertToShort(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
- int srcCode = getSrcCode(src);
-
- switch(srcCode) {
- case STRING:
- case BOOLEAN:
- case BYTE:
- case INTEGER:
- case LONG:
- case BIGINTEGER:
- case FLOAT:
- case DOUBLE:
- case BIGDECIMAL:
- convert = createFunction(args[0], "smallint", Short.class); //$NON-NLS-1$
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IExpression convertToInteger(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
- int srcCode = getSrcCode(src);
-
- switch(srcCode) {
- case STRING:
- case BOOLEAN:
- case BYTE:
- case SHORT:
- case LONG:
- case BIGINTEGER:
- case FLOAT:
- case DOUBLE:
- case BIGDECIMAL:
- convert = createFunction(args[0], "int", Integer.class); //$NON-NLS-1$
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IExpression convertToLong(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
- int srcCode = getSrcCode(src);
-
- switch(srcCode) {
- case STRING:
- case BOOLEAN:
- case BYTE:
- case SHORT:
- case INTEGER:
- case BIGINTEGER:
- case FLOAT:
- case DOUBLE:
- case BIGDECIMAL:
- convert = createFunction(args[0], "numeric", Long.class); //$NON-NLS-1$
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IExpression convertToBigInteger(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
- int srcCode = getSrcCode(src);
-
- switch(srcCode) {
- case STRING:
- case BOOLEAN:
- case BYTE:
- case SHORT:
- case INTEGER:
- case LONG:
- case FLOAT:
- case DOUBLE:
- case BIGDECIMAL:
- convert = createFunction(args[0], "numeric", java.math.BigInteger.class); //$NON-NLS-1$
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IExpression convertToFloat(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
- int srcCode = getSrcCode(src);
-
- switch(srcCode) {
- case STRING:
- case BOOLEAN:
- case BYTE:
- case SHORT:
- case INTEGER:
- case LONG:
- case BIGINTEGER:
- case DOUBLE:
- case BIGDECIMAL:
- convert = createFunction(args[0], "real", Float.class); //$NON-NLS-1$
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IExpression convertToDouble(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
- int srcCode = getSrcCode(src);
-
- switch(srcCode) {
- case STRING:
- case BOOLEAN:
- case BYTE:
- case SHORT:
- case INTEGER:
- case LONG:
- case BIGINTEGER:
- case FLOAT:
- case BIGDECIMAL:
- convert = createFunction(args[0], "float", Double.class); //$NON-NLS-1$
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IExpression convertToBigDecimal(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
- int srcCode = getSrcCode(src);
-
- switch(srcCode) {
- case STRING:
- case BOOLEAN:
- case BYTE:
- case SHORT:
- case INTEGER:
- case LONG:
- case BIGINTEGER:
- case FLOAT:
- case DOUBLE:
- convert = createFunction(args[0], "float", java.math.BigDecimal.class); //$NON-NLS-1$
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IExpression convertToChar(IFunction function) {
- IExpression[] args = function.getParameters();
- return createFunction(args[0], "char", Character.class); //$NON-NLS-1$
- }
-
- private IExpression convertToDate(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
- int srcCode = getSrcCode(srcType);
-
- switch(srcCode) {
- case STRING:
- // convert(STRING, date) --> convert(datetime, STRING)
- convert = createFunction(args[0], "datetime", java.sql.Date.class); //$NON-NLS-1$
- break;
- case TIMESTAMP:
- // convert(TIMESTAMP, date) --> convert(datetime, convert(varchar, TIMESTAMP, 1/101))
- // Build inner convert
- IFunction innerConvert = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
- langFactory.createLiteral("varchar", String.class), //$NON-NLS-1$
- args[0],
- langFactory.createLiteral(new Integer(109), Integer.class) },
- String.class);
-
- // Build outer convert
- convert = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
- langFactory.createLiteral("datetime", String.class), //$NON-NLS-1$
- innerConvert },
- java.sql.Timestamp.class);
-
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IExpression convertToTime(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
-
- int srcCode = getSrcCode(srcType);
- switch(srcCode) {
- case STRING:
- //convert(STRING, time) --> convert(datetime, STRING)
- convert = createFunction(args[0], "datetime", java.sql.Time.class); //$NON-NLS-1$
- break;
- case TIMESTAMP:
- // convert(TIMESTAMP, time) --> convert(datetime, convert(varchar, TIMESTAMP, 108/8)
- // Build inner convert
- IFunction innerConvert = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
- langFactory.createLiteral("varchar", String.class), //$NON-NLS-1$
- args[0],
- langFactory.createLiteral(new Integer(108), Integer.class) },
- String.class);
-
- // Build outer convert
- convert = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
- langFactory.createLiteral("datetime", String.class), //$NON-NLS-1$
- innerConvert },
- java.sql.Time.class);
-
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IExpression convertToTimestamp(IFunction function) {
- IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
- int srcCode = getSrcCode(srcType);
- switch(srcCode) {
- case STRING:
- case TIME:
- case DATE:
- // convert(DATE/TIME/STRING, timestamp) --> convert(datetime, DATE)
- convert = createFunction(args[0], "datetime", java.sql.Timestamp.class); //$NON-NLS-1$
- break;
- default:
- convert = DROP_MODIFIER.modify(function);
- break;
- }
-
- return convert;
- }
-
- private IFunction createFunction(IExpression args0, String targetType, Class targetClass) {
- IFunction created = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
- langFactory.createLiteral(targetType, String.class),
- args0},
- targetClass);
- return created;
- }
-
- private IFunction createFunction(IExpression args0, int formatNumber, Class targetClass) {
- IFunction created = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] { langFactory.createLiteral("varchar", String.class), //$NON-NLS-1$
- args0,
- langFactory.createLiteral(new Integer(formatNumber), Integer.class) },
- targetClass);
- return created;
- }
-
- private int getSrcCode(Class source) {
- return ((Integer) typeMap.get(source)).intValue();
- }
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerModModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerModModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerModModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.sqlserver;
-
-import com.metamatrix.connector.api.TypeFacility.RUNTIME_TYPES;
-import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.language.IFunction;
-import com.metamatrix.connector.language.ILanguageFactory;
-
-public class SqlServerModModifier extends AliasModifier {
-
- private ILanguageFactory langFactory;
-
- public SqlServerModModifier(ILanguageFactory langFactory) {
- super("%"); //$NON-NLS-1$
- this.langFactory = langFactory;
- }
-
- @Override
- public IExpression modify(IFunction function) {
- IExpression[] expressions = function.getParameters();
- if (RUNTIME_TYPES.INTEGER.equals(expressions[0].getType())) {
- return super.modify(function);
- }
- //x % y => x - floor(x / y) * y
- IExpression[] divideArgs = new IExpression[2];
- System.arraycopy(expressions, 0, divideArgs, 0, 2);
- IFunction divide = langFactory.createFunction("/", divideArgs, divideArgs[0].getType()); //$NON-NLS-1$
-
- IFunction floor = langFactory.createFunction("floor", new IExpression[] {divide}, divide.getType()); //$NON-NLS-1$
-
- IExpression[] multArgs = new IExpression[] {
- floor, expressions[1]
- };
- IFunction mult = langFactory.createFunction("*", multArgs, multArgs[1].getType()); //$NON-NLS-1$
-
- IExpression[] minusArgs = new IExpression[] {
- expressions[0], mult
- };
- return langFactory.createFunction("-", minusArgs, minusArgs[0].getType()); //$NON-NLS-1$
- }
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerResultsTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerResultsTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.sqlserver;
-
-import com.metamatrix.connector.jdbc.extension.impl.BasicResultsTranslator;
-
-
-public class SqlServerResultsTranslator extends BasicResultsTranslator {
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,117 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.sqlserver;
-
-import java.sql.Time;
-
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.language.*;
-
-/**
- */
-public class SqlServerSQLConversionVisitor extends SQLConversionVisitor {
-
- private final int MAX_SELECT_ALIAS_LENGTH = 30;
-
- private final int MAX_TABLE_ALIAS_LENGTH = 128;
-
- private int limit = 0;
- /**
- * Override to handle % operator.
- */
- public void visit(IFunction obj) {
- if(obj.getName().equals("%")) { //$NON-NLS-1$
- String name = obj.getName();
- IExpression[] args = obj.getParameters();
-
- buffer.append(LPAREN);
-
- if(args != null) {
- for(int i=0; i<args.length; i++) {
- append(args[i]);
- if(i < (args.length-1)) {
- buffer.append(SPACE);
- buffer.append(name);
- buffer.append(SPACE);
- }
- }
- }
- buffer.append(RPAREN);
- } else {
- super.visit(obj);
- }
- }
-
- public void visit(ILimit obj) {
- // Don't attach limit at the end
- // See appendQuery() below
- }
-
- protected void appendQuery(IQuery obj) {
- if (obj.getLimit() != null) {
- limit = obj.getLimit().getRowLimit();
- }
- super.appendQuery(obj);
- }
-
- protected void visitSelect(ISelect obj) {
- buffer.append(SELECT).append(SPACE);
- buffer.append(addProcessComment());
- if (limit > 0) {
- buffer.append("TOP") //$NON-NLS-1$
- .append(SPACE)
- .append(limit)
- .append(SPACE);
- limit = 0;
- }
- if (obj.isDistinct()) {
- buffer.append(DISTINCT).append(SPACE);
- }
- append(obj.getSelectSymbols());
- }
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#translateLiteralTime(java.sql.Time)
- */
- protected String translateLiteralTime(Time timeValue) {
- return "{ts'1900-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#getMaxSelectAliasLength()
- * @since 4.3
- */
- protected int getMaxSelectAliasLength() {
- return MAX_SELECT_ALIAS_LENGTH;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#getMaxTableAliasLength()
- * @since 4.3
- */
- protected int getMaxTableAliasLength() {
- return MAX_TABLE_ALIAS_LENGTH;
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -24,75 +24,32 @@
*/
package com.metamatrix.connector.jdbc.sqlserver;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
-import com.metamatrix.connector.jdbc.extension.impl.SubstringFunctionModifier;
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.api.SourceSystemFunctions;
+import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
+import com.metamatrix.connector.jdbc.sybase.SybaseSQLTranslator;
+import com.metamatrix.connector.language.ILimit;
/**
*/
-public class SqlServerSQLTranslator extends BasicSQLTranslator {
+public class SqlServerSQLTranslator extends SybaseSQLTranslator {
- private Map functionModifiers;
- private Properties connectorProperties;
- private ILanguageFactory languageFactory;
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+ //FEDERATE-168 remove mod modifier for SQL Server 2008
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.REPEAT, new AliasModifier("replicate")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public String getLengthFunctionName() {
+ return "len"; //$NON-NLS-1$
+ }
+
+ @Override
+ public String addLimitString(String queryCommand, ILimit limit) {
+ return "SELECT TOP " + limit.getRowLimit() + " * FROM (" + queryCommand + ") AS X"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
- public void initialize(ConnectorEnvironment env,
- RuntimeMetadata metadata) throws ConnectorException {
-
- super.initialize(env, metadata);
- ConnectorEnvironment connEnv = getConnectorEnvironment();
- this.connectorProperties = connEnv.getProperties();
- this.languageFactory = connEnv.getLanguageFactory();
- initializeFunctionModifiers();
- }
-
- private void initializeFunctionModifiers() {
- functionModifiers = new HashMap();
- functionModifiers.putAll(super.getFunctionModifiers());
- //FEDERATE-168 this is not necessary for SQL Server 2008
- functionModifiers.put("mod", new SqlServerModModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("chr", new AliasModifier("char")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("concat", new AliasModifier("+")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("||", new AliasModifier("+")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("ifnull", new AliasModifier("isnull")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("nvl", new AliasModifier("isnull")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("lcase", new AliasModifier("lower")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("length", new AliasModifier("len")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("dayofmonth", new AliasModifier("day")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("ucase", new AliasModifier("upper")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("substring", new SubstringFunctionModifier(languageFactory, "substring", "len")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- functionModifiers.put("cast", new SqlServerConvertModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("convert", new SqlServerConvertModifier(languageFactory)); //$NON-NLS-1$
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getFunctionModifiers()
- */
- public Map getFunctionModifiers() {
- return functionModifiers;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getTranslationVisitor()
- */
- public SQLConversionVisitor getTranslationVisitor() {
- SQLConversionVisitor visitor = new SqlServerSQLConversionVisitor();
- visitor.setRuntimeMetadata(getRuntimeMetadata());
- visitor.setFunctionModifiers(functionModifiers);
- visitor.setProperties(connectorProperties);
- visitor.setLanguageFactory(languageFactory);
- visitor.setDatabaseTimeZone(getDatabaseTimeZone());
- return visitor;
- }
-
-
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSingleIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSingleIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.sqlserver;
-
-import com.metamatrix.connector.jdbc.*;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
-
-public class SqlServerSingleIdentityConnectionFactory extends JDBCSingleIdentityConnectionFactory{
- private String queryTest = "Select 'x'"; //$NON-NLS-1$
-
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerUserIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerUserIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerUserIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.sqlserver;
-
-import com.metamatrix.connector.jdbc.*;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCUserIdentityConnectionFactory;
-
-public class SqlServerUserIdentityConnectionFactory extends JDBCUserIdentityConnectionFactory{
- private String queryTest = "Select 'x'"; //$NON-NLS-1$
-
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ssl/JDBCSequeLinkSingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ssl/JDBCSequeLinkSingleIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ssl/JDBCSequeLinkSingleIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -92,6 +92,6 @@
throw new ConnectorException(e);
}
- return new JDBCSourceConnection(connection, getConnectorEnvironment(), createConnectionStrategy(), getConnectionListener());
+ return new JDBCSourceConnection(connection, getConnectorEnvironment(), createConnectionStrategy(), getConnectionListener(), getResultsTranslator(), getSqlTranslator());
}
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/FormatTimestampModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/FormatTimestampModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/FormatTimestampModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.sybase;
-
-import java.util.*;
-
-import com.metamatrix.connector.jdbc.extension.FunctionModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
-import com.metamatrix.connector.language.*;
-
-/**
- */
-public class FormatTimestampModifier extends BasicFunctionModifier implements FunctionModifier {
-
- private Map styleMappings;
- private ILanguageFactory langFactory;
-
- public FormatTimestampModifier(ILanguageFactory langFactory) {
- this.langFactory = langFactory;
- loadStyleMappings();
- }
-
- private void loadStyleMappings() {
- styleMappings = new HashMap();
- styleMappings.put("yyyy-MM-dd", new Integer(1)); // standard SQL format //$NON-NLS-1$
- styleMappings.put("MM/dd/yyyy", new Integer(1)); //$NON-NLS-1$
- styleMappings.put("yy/MM/dd", new Integer(2)); //$NON-NLS-1$
- styleMappings.put("dd/MM/yy", new Integer(3)); //$NON-NLS-1$
- styleMappings.put("dd.mm.yy", new Integer(4)); //$NON-NLS-1$
- styleMappings.put("dd-mm-yy", new Integer(5)); //$NON-NLS-1$
- styleMappings.put("dd mm yy", new Integer(6)); //$NON-NLS-1$
- styleMappings.put("MMM dd, yy", new Integer(7)); //$NON-NLS-1$
- styleMappings.put("HH:mm:ss", new Integer(8)); //$NON-NLS-1$
- styleMappings.put("MM dd yy hh:mm:ss:zzza", new Integer(9)); //$NON-NLS-1$
- styleMappings.put("MM-dd-yy", new Integer(10)); //$NON-NLS-1$
- styleMappings.put("yy/MM/dd", new Integer(11)); //$NON-NLS-1$
- styleMappings.put("yyMMdd", new Integer(12)); //$NON-NLS-1$
- styleMappings.put("yy/dd/MM", new Integer(13)); //$NON-NLS-1$
- styleMappings.put("MM/yy/dd", new Integer(14)); //$NON-NLS-1$
- styleMappings.put("dd/yy/MM", new Integer(15)); //$NON-NLS-1$
- styleMappings.put("MMM dd yy HH:mm:ss", new Integer(16)); //$NON-NLS-1$
- styleMappings.put("hh:mma", new Integer(17)); //$NON-NLS-1$
- styleMappings.put("HH:mm", new Integer(18)); //$NON-NLS-1$
- styleMappings.put("hh:mm:ss:zzza", new Integer(19)); //$NON-NLS-1$
- styleMappings.put("HH:mm:ss:zzz", new Integer(20)); //$NON-NLS-1$
- }
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
- */
- public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
-
- String format = (String) ((ILiteral)args[1]).getValue();
-
- Integer styleCode = (Integer) styleMappings.get(format);
- IFunction func = null;
- if(styleCode != null) {
- func = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
- langFactory.createLiteral("varchar", String.class),//$NON-NLS-1$
- args[0],
- langFactory.createLiteral(styleCode, Integer.class)
- },
- String.class);
-
- } else {
- func = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
- langFactory.createLiteral("varchar", String.class),//$NON-NLS-1$
- args[0]
- },
- String.class);
- }
- return func;
- }
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/ModFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/ModFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/ModFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.sybase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.metamatrix.connector.jdbc.extension.FunctionModifier;
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.language.IFunction;
-
-/**
- */
-public class ModFunctionModifier implements FunctionModifier {
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
- */
- public IExpression modify(IFunction function) {
- return function;
- }
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.FunctionModifier#translate(com.metamatrix.data.language.IFunction)
- */
- public List translate(IFunction function) {
- List parts = new ArrayList();
- parts.add("(");//$NON-NLS-1$
-
- IExpression[] args = function.getParameters();
- parts.add(args[0]);
- parts.add(" % "); //$NON-NLS-1$
- parts.add(args[1]);
- parts.add(")"); //$NON-NLS-1$
-
- return parts;
- }
-
-}
Copied: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/ModFunctionModifier.java (from rev 472, trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerModModifier.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/ModFunctionModifier.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/ModFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -0,0 +1,71 @@
+/*
+ * 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 com.metamatrix.connector.jdbc.sybase;
+
+import java.util.List;
+
+import com.metamatrix.connector.api.TypeFacility.RUNTIME_TYPES;
+import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
+import com.metamatrix.connector.language.IExpression;
+import com.metamatrix.connector.language.IFunction;
+import com.metamatrix.connector.language.ILanguageFactory;
+
+public class ModFunctionModifier extends AliasModifier {
+
+ private ILanguageFactory langFactory;
+
+ public ModFunctionModifier(ILanguageFactory langFactory) {
+ super("%"); //$NON-NLS-1$
+ this.langFactory = langFactory;
+ }
+
+ @Override
+ public IExpression modify(IFunction function) {
+ IExpression[] expressions = function.getParameters();
+ if (RUNTIME_TYPES.INTEGER.equals(expressions[0].getType())) {
+ return super.modify(function);
+ }
+ //x % y => x - floor(x / y) * y
+ IExpression[] divideArgs = new IExpression[2];
+ System.arraycopy(expressions, 0, divideArgs, 0, 2);
+ IFunction divide = langFactory.createFunction("/", divideArgs, divideArgs[0].getType()); //$NON-NLS-1$
+
+ IFunction floor = langFactory.createFunction("floor", new IExpression[] {divide}, divide.getType()); //$NON-NLS-1$
+
+ IExpression[] multArgs = new IExpression[] {
+ floor, expressions[1]
+ };
+ IFunction mult = langFactory.createFunction("*", multArgs, multArgs[1].getType()); //$NON-NLS-1$
+
+ IExpression[] minusArgs = new IExpression[] {
+ expressions[0], mult
+ };
+ return langFactory.createFunction("-", minusArgs, minusArgs[0].getType()); //$NON-NLS-1$
+ }
+
+ @Override
+ public List translate(IFunction function) {
+ return null;
+ }
+
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/ModFunctionModifier.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:mergeinfo
+
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseConvertModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseConvertModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -408,7 +408,7 @@
new IExpression[] {
langFactory.createLiteral("varchar", String.class), //$NON-NLS-1$
args[0],
- langFactory.createLiteral(new Integer(1), Integer.class) },
+ langFactory.createLiteral(new Integer(109), Integer.class) },
String.class);
// Build outer convert
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseResultsTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseResultsTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,33 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.sybase;
-
-import com.metamatrix.connector.jdbc.extension.impl.BasicResultsTranslator;
-
-/**
- */
-public class SybaseResultsTranslator extends BasicResultsTranslator {
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.sybase;
-
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-
-/**
- */
-public class SybaseSQLConversionVisitor extends SQLConversionVisitor {
-
- private static final int MAX_SELECT_ALIAS_LENGTH = 30;
-
- private static final int MAX_TABLE_ALIAS_LENGTH = 30;
-
- /*
- * @see com.metamatrix.data.visitor.util.SQLStringVisitor#useAsInGroupAlias()
- */
- protected boolean useAsInGroupAlias() {
- return false;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#getMaxSelectAliasLength()
- * @since 4.3
- */
- protected int getMaxSelectAliasLength() {
- return MAX_SELECT_ALIAS_LENGTH;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLConversionVisitor#getMaxTableAliasLength()
- * @since 4.3
- */
- protected int getMaxTableAliasLength() {
- return MAX_TABLE_ALIAS_LENGTH;
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -24,76 +24,44 @@
*/
package com.metamatrix.connector.jdbc.sybase;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
-import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
-import com.metamatrix.connector.jdbc.extension.impl.SubstringFunctionModifier;
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.api.SourceSystemFunctions;
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
+import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
+import com.metamatrix.connector.jdbc.extension.impl.SubstringFunctionModifier;
/**
*/
-public class SybaseSQLTranslator extends BasicSQLTranslator {
+public class SybaseSQLTranslator extends SQLTranslator {
- private Map functionModifiers;
- private Properties connectorProperties;
- private ILanguageFactory languageFactory;
-
- public SybaseSQLTranslator() {
- }
-
/*
* @see com.metamatrix.connector.jdbc.extension.SQLTranslator#initialize(com.metamatrix.data.api.ConnectorEnvironment, com.metamatrix.data.metadata.runtime.RuntimeMetadata)
*/
- public void initialize(ConnectorEnvironment env, RuntimeMetadata metadata) throws ConnectorException {
- super.initialize(env, metadata);
- connectorProperties = getConnectorEnvironment().getProperties();
- languageFactory = getConnectorEnvironment().getLanguageFactory();
- initializeFunctionModifiers();
- }
-
- private void initializeFunctionModifiers() {
- functionModifiers = new HashMap();
- functionModifiers.putAll(super.getFunctionModifiers());
- functionModifiers.put("mod", new ModFunctionModifier()); //$NON-NLS-1$
- functionModifiers.put("chr", new AliasModifier("char")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("concat", new AliasModifier("+")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("||", new AliasModifier("+")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("lcase", new AliasModifier("lower")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("length", new AliasModifier("char_length")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("ifnull", new AliasModifier("isnull")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("ucase", new AliasModifier("upper")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("nvl", new AliasModifier("isnull")); //$NON-NLS-1$ //$NON-NLS-2$
- functionModifiers.put("substring", new SubstringFunctionModifier(languageFactory, "substring", "char_length")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- functionModifiers.put("cast", new SybaseConvertModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("convert", new SybaseConvertModifier(languageFactory)); //$NON-NLS-1$
- functionModifiers.put("formattimestamp", new FormatTimestampModifier(languageFactory)); //$NON-NLS-1$
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ super.initialize(env);
+ registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new AliasModifier("+")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.LENGTH, new AliasModifier(getLengthFunctionName())); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("isnull")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper")); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstringFunctionModifier(getLanguageFactory(), "substring", getLengthFunctionName())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, new SybaseConvertModifier(getLanguageFactory())); //$NON-NLS-1$
+ }
+
+ public String getLengthFunctionName() {
+ return "char_length"; //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean useAsInGroupAlias() {
+ return false;
+ }
+
+ @Override
+ public boolean hasTimeType() {
+ return false;
}
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getFunctionModifiers()
- */
- public Map getFunctionModifiers() {
- return functionModifiers;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#getTranslationVisitor()
- */
- public SQLConversionVisitor getTranslationVisitor() {
- SQLConversionVisitor visitor = new SybaseSQLConversionVisitor();
- visitor.setRuntimeMetadata(getRuntimeMetadata());
- visitor.setFunctionModifiers(functionModifiers);
- visitor.setProperties(connectorProperties);
- visitor.setLanguageFactory(languageFactory);
- visitor.setDatabaseTimeZone(getDatabaseTimeZone());
- return visitor;
- }
-
+
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSingleIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSingleIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.sybase;
-
-import com.metamatrix.connector.jdbc.*;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
-
-public class SybaseSingleIdentityConnectionFactory extends JDBCSingleIdentityConnectionFactory{
- private String queryTest = "Select 'x'"; //$NON-NLS-1$
-
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseUserIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseUserIdentityConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseUserIdentityConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package com.metamatrix.connector.jdbc.sybase;
-
-import com.metamatrix.connector.jdbc.*;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCUserIdentityConnectionFactory;
-
-public class SybaseUserIdentityConnectionFactory extends JDBCUserIdentityConnectionFactory{
- private String queryTest = "Select 'x'"; //$NON-NLS-1$
-
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/util/FunctionReplacementVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/util/FunctionReplacementVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/util/FunctionReplacementVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,10 +22,25 @@
package com.metamatrix.connector.jdbc.util;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import com.metamatrix.connector.jdbc.extension.FunctionModifier;
-import com.metamatrix.connector.language.*;
+import com.metamatrix.connector.language.IAggregate;
+import com.metamatrix.connector.language.ICompareCriteria;
+import com.metamatrix.connector.language.IExpression;
+import com.metamatrix.connector.language.IFunction;
+import com.metamatrix.connector.language.IGroupBy;
+import com.metamatrix.connector.language.IInCriteria;
+import com.metamatrix.connector.language.IInlineView;
+import com.metamatrix.connector.language.IInsert;
+import com.metamatrix.connector.language.IIsNullCriteria;
+import com.metamatrix.connector.language.ILikeCriteria;
+import com.metamatrix.connector.language.ISearchedCaseExpression;
+import com.metamatrix.connector.language.ISelectSymbol;
+import com.metamatrix.connector.language.ISubqueryCompareCriteria;
+import com.metamatrix.connector.language.ISubqueryInCriteria;
import com.metamatrix.connector.visitor.framework.HierarchyVisitor;
/**
@@ -56,22 +71,6 @@
}
/*
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.ICaseExpression)
- */
- public void visit(ICaseExpression obj) {
- super.visit(obj);
- obj.setExpression(replaceFunction(obj.getExpression()));
- int whenCount = obj.getWhenCount();
- for(int i=0; i<whenCount; i++) {
- obj.setWhenExpression(i, replaceFunction(obj.getWhenExpression(i)));
- }
- for(int i=0; i<whenCount; i++) {
- obj.setThenExpression(i, replaceFunction(obj.getThenExpression(i)));
- }
- obj.setElseExpression(replaceFunction(obj.getElseExpression()));
- }
-
- /*
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.ICompareCriteria)
*/
public void visit(ICompareCriteria obj) {
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -111,7 +111,7 @@
if(getTransactionIsolation() != NO_ISOLATION_LEVEL_SET && getTransactionIsolation() != Connection.TRANSACTION_NONE){
sqlConn.setTransactionIsolation(getTransactionIsolation());
}
- return new JDBCSourceXAConnection(sqlConn, conn, getConnectorEnvironment(), createConnectionStrategy(), getConnectionListener());
+ return new JDBCSourceXAConnection(sqlConn, conn, getConnectorEnvironment(), createConnectionStrategy(), getConnectionListener(), getResultsTranslator(), getSqlTranslator());
}catch(SQLException se){
throw new ConnectorException(se);
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSourceXAConnection.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSourceXAConnection.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSourceXAConnection.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -36,6 +36,8 @@
import com.metamatrix.connector.jdbc.ConnectionListener;
import com.metamatrix.connector.jdbc.ConnectionStrategy;
import com.metamatrix.connector.jdbc.JDBCSourceConnection;
+import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.xa.api.XAConnection;
public class JDBCSourceXAConnection extends JDBCSourceConnection implements XAConnection {
@@ -43,8 +45,8 @@
private XAResource resource;
private boolean errorOccurred;
- public JDBCSourceXAConnection(Connection conn, javax.sql.XAConnection xaConn, ConnectorEnvironment environment, ConnectionStrategy connectionStrategy, ConnectionListener connectionListener) throws ConnectorException, SQLException {
- super(conn, environment, connectionStrategy, connectionListener);
+ public JDBCSourceXAConnection(Connection conn, javax.sql.XAConnection xaConn, ConnectorEnvironment environment, ConnectionStrategy connectionStrategy, ConnectionListener connectionListener, ResultsTranslator resultsTranslator, SQLTranslator sqlTranslator) throws ConnectorException, SQLException {
+ super(conn, environment, connectionStrategy, connectionListener, resultsTranslator, sqlTranslator);
this.xaConn = xaConn;
this.xaConn.addConnectionEventListener(new ConnectionEventListener() {
@Override
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/TestJDBCSourceConnection.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/TestJDBCSourceConnection.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/TestJDBCSourceConnection.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -27,17 +27,11 @@
import junit.framework.TestCase;
-import org.mockito.Mockito;
-
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.basic.BasicConnectorCapabilities;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.jdbc.extension.impl.BasicResultsTranslator;
import com.metamatrix.connector.jdbc.oracle.OracleSQLTranslator;
-import com.metamatrix.connector.language.IQuery;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.core.util.SimpleMock;
@@ -81,7 +75,7 @@
* @since 4.3
*/
public void testIsAlive() throws Exception {
- JDBCSourceConnection sourceConnection = new JDBCSourceConnection(connection, environment, strategy);
+ JDBCSourceConnection sourceConnection = new JDBCSourceConnection(connection, environment, strategy, null, null);
//closed connections should not be 'alive'
fakeConnection.closed = true;
@@ -102,7 +96,7 @@
* @since 4.3
*/
public void testIsAliveNullStrategy() throws Exception {
- JDBCSourceConnection sourceConnection = new JDBCSourceConnection(connection, environment, null);
+ JDBCSourceConnection sourceConnection = new JDBCSourceConnection(connection, environment, null, null, null);
//closed connections should not be 'alive'
fakeConnection.closed = true;
@@ -118,11 +112,4 @@
}
- public void testSqlTranslatorInit() throws Exception {
- JDBCSourceConnection sourceConnection = new JDBCSourceConnection(connection, environment, null);
- JDBCQueryExecution exec = (JDBCQueryExecution)sourceConnection.createExecution(Mockito.mock(IQuery.class), Mockito.mock(ExecutionContext.class), Mockito.mock(RuntimeMetadata.class));
- SQLTranslator trans = exec.getSqlTranslator();
- assertTrue(trans.getFunctionModifiers().size() > 0);
- }
-
}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/access/TestAccessSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/access/TestAccessSQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/access/TestAccessSQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -44,13 +44,13 @@
static {
try {
TRANSLATOR = new AccessSQLTranslator();
- TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
} catch(ConnectorException e) {
e.printStackTrace();
}
}
- public void helpTestVisitor(String input, int expectedType, String expectedOutput) throws ConnectorException {
+ public void helpTestVisitor(String input, String expectedOutput) throws ConnectorException {
// Convert from sql to objects
ICommand obj = FakeTranslationFactory.getInstance().getBQTTranslationUtility().parseCommand(input);
@@ -60,7 +60,6 @@
// Check stuff
assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
- assertEquals("Did not get expected command type", expectedType, tc.getExecutionType()); //$NON-NLS-1$
}
public void testRowLimit() throws Exception {
@@ -69,8 +68,17 @@
helpTestVisitor(
input,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
+
+ public void testRowLimit1() throws Exception {
+ String input = "select distinct intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
+ String output = "SELECT DISTINCT TOP 100 SmallA.IntKey FROM SmallA"; //$NON-NLS-1$
+
+ helpTestVisitor(
+ input,
+ output);
+
+ }
}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2ConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2ConvertModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2ConvertModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -54,11 +54,9 @@
public String helpGetString(IExpression expr) throws Exception {
DB2SQLTranslator trans = new DB2SQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
- SQLConversionVisitor sqlVisitor = new SQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
sqlVisitor.append(expr);
return sqlVisitor.toString();
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2SqlTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2SqlTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -32,7 +32,6 @@
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.core.util.UnitTestUtil;
@@ -42,12 +41,12 @@
public class TestDB2SqlTranslator extends TestCase {
private static Map MODIFIERS;
- private static SQLTranslator TRANSLATOR;
+ private static DB2SQLTranslator TRANSLATOR;
static {
try {
TRANSLATOR = new DB2SQLTranslator();
- TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
MODIFIERS = TRANSLATOR.getFunctionModifiers();
} catch(ConnectorException e) {
e.printStackTrace();
@@ -66,7 +65,7 @@
return UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb"; //$NON-NLS-1$
}
- public void helpTestVisitor(TranslationUtility util, String input, Map modifiers, int expectedType, String expectedOutput) throws ConnectorException {
+ public void helpTestVisitor(TranslationUtility util, String input, Map modifiers, String expectedOutput) throws ConnectorException {
// Convert from sql to objects
ICommand obj = util.parseCommand(input);
@@ -76,7 +75,6 @@
tc.translateCommand(obj);
assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
- assertEquals("Did not get expected command type", expectedType, tc.getExecutionType()); //$NON-NLS-1$
}
public void testRowLimit() throws Exception {
@@ -86,18 +84,16 @@
helpTestVisitor(FakeTranslationFactory.getInstance().getBQTTranslationUtility(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testCrossJoin() throws Exception{
String input = "SELECT bqt1.smalla.stringkey FROM bqt1.smalla cross join bqt1.smallb"; //$NON-NLS-1$
- String output = "SELECT SmallA.StringKey FROM SmallA INNER JOIN SmallB ON 1=1"; //$NON-NLS-1$
+ String output = "SELECT SmallA.StringKey FROM SmallA INNER JOIN SmallB ON 1 = 1"; //$NON-NLS-1$
helpTestVisitor(FakeTranslationFactory.getInstance().getBQTTranslationUtility(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/derby/TestDerbyConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/derby/TestDerbyConvertModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/derby/TestDerbyConvertModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -54,11 +54,9 @@
public String helpGetString(IExpression expr) throws Exception {
DerbySQLTranslator trans = new DerbySQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
- SQLConversionVisitor sqlVisitor = new SQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
sqlVisitor.append(expr);
return sqlVisitor.toString();
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/mysql/TestMySQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/mysql/TestMySQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,16 +22,15 @@
package com.metamatrix.connector.jdbc.mysql;
-import java.util.Map;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.api.EnvironmentUtility;
+import java.util.Map;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.MetadataFactory;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
-import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
+import com.metamatrix.connector.jdbc.MetadataFactory;
+import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
import com.metamatrix.connector.language.ICommand;
/**
@@ -39,12 +38,12 @@
public class TestMySQLTranslator extends TestCase {
private static Map MODIFIERS;
- private static SQLTranslator TRANSLATOR;
+ private static MySQLTranslator TRANSLATOR;
static {
try {
TRANSLATOR = new MySQLTranslator();
- TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
MODIFIERS = TRANSLATOR.getFunctionModifiers();
} catch(ConnectorException e) {
e.printStackTrace();
@@ -63,7 +62,7 @@
return MetadataFactory.BQT_VDB;
}
- public void helpTestVisitor(String vdb, String input, Map modifiers, int expectedType, String expectedOutput) throws ConnectorException {
+ public void helpTestVisitor(String vdb, String input, Map modifiers, String expectedOutput) throws ConnectorException {
// Convert from sql to objects
ICommand obj = MetadataFactory.helpTranslate(vdb, input);
@@ -73,7 +72,6 @@
// Check stuff
assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
- assertEquals("Did not get expected command type", expectedType, tc.getExecutionType()); //$NON-NLS-1$
}
public void testRewriteConversion1() throws Exception {
@@ -83,7 +81,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -94,7 +91,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -105,7 +101,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -116,7 +111,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion5() throws Exception {
@@ -126,7 +120,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion6() throws Exception {
@@ -136,17 +129,15 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion8() throws Exception {
- String input = "SELECT nvl(PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
+ String input = "SELECT ifnull(PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
String output = "SELECT ifnull(PARTS.PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion7() throws Exception {
@@ -156,7 +147,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteInsert() throws Exception {
@@ -166,7 +156,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteLocate() throws Exception {
@@ -176,7 +165,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteSubstring1() throws Exception {
@@ -186,7 +174,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteSubstring2() throws Exception {
@@ -196,7 +183,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteUnionWithOrderBy() throws Exception {
@@ -206,7 +192,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -217,7 +202,7 @@
helpTestVisitor(getTestBQTVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testRowLimit3() throws Exception {
String input = "select intkey from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
@@ -226,7 +211,7 @@
helpTestVisitor(getTestBQTVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -29,6 +29,7 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
+import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
@@ -58,13 +59,10 @@
IExpression expr = mod.modify(func);
OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
- OracleSQLConversionVisitor sqlVisitor = new OracleSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
sqlVisitor.append(expr);
- //System.out.println(" expected: " + expectedStr + " \t actual: " + sqlVisitor.toString());
assertEquals(expectedStr, sqlVisitor.toString());
return expr;
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestExtractFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestExtractFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestExtractFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -23,7 +23,6 @@
package com.metamatrix.connector.jdbc.oracle;
import java.sql.Timestamp;
-import java.util.Map;
import java.util.Properties;
import junit.framework.TestCase;
@@ -31,6 +30,7 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.TypeFacility;
+import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
@@ -62,17 +62,12 @@
IExpression expr = mod.modify(func);
OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ trans.registerFunctionModifier("extract", mod);
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
- OracleSQLConversionVisitor sqlVisitor = new OracleSQLConversionVisitor();
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
- // register this ExtractFunctionModifier with the OracleSQLConversionVisitor
- Map modifier = trans.getFunctionModifiers();
- modifier.put("extract", mod); //$NON-NLS-1$
- sqlVisitor.setFunctionModifiers(modifier);
-
//sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
sqlVisitor.append(expr);
//System.out.println(" expected: " + expectedStr + " \t actual: " + sqlVisitor.toString());
assertEquals(expectedStr, sqlVisitor.toString());
@@ -101,18 +96,18 @@
public void test5() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
- helpTestMod(arg1, "EXTRACT(DAY FROM {d'2004-01-21'})", "day"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(DAY FROM {d'2004-01-21'})", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test6() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 17, 5, 0, 0), Timestamp.class);
- helpTestMod(arg1, "EXTRACT(DAY FROM {ts'2004-01-21 17:05:00.0'})", "day"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(arg1, "EXTRACT(DAY FROM {ts'2004-01-21 17:05:00.0'})", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void test11() throws Exception {
IGroup group = LANG_FACTORY.createGroup(null, "group", null); //$NON-NLS-1$
IElement elem = LANG_FACTORY.createElement("col", group, null, TypeFacility.RUNTIME_TYPES.DATE); //$NON-NLS-1$
- helpTestMod(elem, "EXTRACT(DAY FROM col)", "day"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestMod(elem, "EXTRACT(DAY FROM col)", "dayofmonth"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Deleted: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestFormatFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestFormatFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestFormatFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.oracle;
-
-import java.sql.Timestamp;
-import java.util.Map;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.language.IFunction;
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.connector.language.ILiteral;
-import com.metamatrix.query.unittest.TimestampUtil;
-
-/**
- */
-public class TestFormatFunctionModifier extends TestCase {
-
- private static final ILanguageFactory LANG_FACTORY = CommandBuilder.getLanuageFactory();
-
- /**
- * Constructor for TestMonthFunctionModifier.
- * @param name
- */
- public TestFormatFunctionModifier(String name) {
- super(name);
- }
-
- public IExpression helpTestMod(ILiteral datetime, ILiteral format, String expectedStr) throws Exception {
- IFunction func = LANG_FACTORY.createFunction("format", //$NON-NLS-1$
- new IExpression[] { datetime, format },
- String.class);
-
- FormatFunctionModifier mod = new FormatFunctionModifier (LANG_FACTORY);
- IExpression expr = mod.modify(func);
-
- OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
-
- OracleSQLConversionVisitor sqlVisitor = new OracleSQLConversionVisitor();
-
- // register this ExtractFunctionModifier with the OracleSQLConversionVisitor
- Map modifier = trans.getFunctionModifiers();
- modifier.put("format", mod); //$NON-NLS-1$
- sqlVisitor.setFunctionModifiers(modifier);
-
- //sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
- sqlVisitor.append(expr);
- //System.out.println(" expected: " + expectedStr + " \t actual: " + sqlVisitor.toString());
- assertEquals(expectedStr, sqlVisitor.toString());
-
- return expr;
- }
- public void test1() throws Exception {
- ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createDate(104, 0, 21), java.sql.Date.class);
- ILiteral arg2 = LANG_FACTORY.createLiteral("YYYY-MM-DD", String.class); //$NON-NLS-1$
- helpTestMod(arg1, arg2, "to_char({d'2004-01-21'}, 'YYYY-MM-DD')" ); //$NON-NLS-1$
- }
-
- public void test2() throws Exception {
- ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 17, 5, 0, 0), Timestamp.class);
- ILiteral arg2 = LANG_FACTORY.createLiteral("YYYY-MM-DD HH24:MI:SS.fffffffff", String.class); //$NON-NLS-1$
- helpTestMod(arg1, arg2, "to_char({ts'2004-01-21 17:05:00.0'}, 'YYYY-MM-DD HH24:MI:SS.fffffffff')"); //$NON-NLS-1$
- }
-
- public void test3() throws Exception {
- ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTime(12, 1, 21), java.sql.Time.class);
- ILiteral arg2 = LANG_FACTORY.createLiteral("HH24:MI:SS", String.class); //$NON-NLS-1$
- helpTestMod(arg1, arg2, "to_char({ts'1970-01-01 12:01:21'}, 'HH24:MI:SS')"); //$NON-NLS-1$
- }
-
-}
-
Deleted: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestHourFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestHourFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestHourFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.oracle;
-
-import java.sql.Timestamp;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.language.IFunction;
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.connector.language.ILiteral;
-import com.metamatrix.query.unittest.TimestampUtil;
-
-/**
- */
-public class TestHourFunctionModifier extends TestCase {
-
- private static final ILanguageFactory LANG_FACTORY = CommandBuilder.getLanuageFactory();
-
- /**
- * Constructor for TestHourFunctionModifier.
- * @param name
- */
- public TestHourFunctionModifier(String name) {
- super(name);
- }
-
- public IExpression helpTestMod(ILiteral c, String expectedStr) throws Exception {
- IFunction func = LANG_FACTORY.createFunction("hour", //$NON-NLS-1$
- new IExpression[] { c },
- Integer.class);
-
- HourFunctionModifier mod = new HourFunctionModifier (LANG_FACTORY);
- IExpression expr = mod.modify(func);
-
- OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
-
- OracleSQLConversionVisitor sqlVisitor = new OracleSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
- sqlVisitor.append(expr);
-
- assertEquals(expectedStr, sqlVisitor.toString());
-
- return expr;
- }
-
- public void test1() throws Exception {
- ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 10, 5, 0, 0), Timestamp.class);
- helpTestMod(arg1, "TO_NUMBER(TO_CHAR({ts'2004-01-21 10:05:00.0'}, 'HH24'))"); //$NON-NLS-1$
- }
-
- public void test2() throws Exception {
- ILiteral arg1 = LANG_FACTORY.createLiteral(TimestampUtil.createTimestamp(104, 0, 21, 17, 5, 0, 0), Timestamp.class);
- helpTestMod(arg1, "TO_NUMBER(TO_CHAR({ts'2004-01-21 17:05:00.0'}, 'HH24'))"); //$NON-NLS-1$
- }
-}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLeftOrRightFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLeftOrRightFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLeftOrRightFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -28,6 +28,7 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
+import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
@@ -52,15 +53,13 @@
new IExpression[] { c, d },
String.class);
- LeftOrRightFunctionModifier mod = new LeftOrRightFunctionModifier (LANG_FACTORY, target);
+ LeftOrRightFunctionModifier mod = new LeftOrRightFunctionModifier (LANG_FACTORY);
IExpression expr = mod.modify(func);
OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
- OracleSQLConversionVisitor sqlVisitor = new OracleSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
sqlVisitor.append(expr);
//System.out.println(" expected: " + expectedStr + " \t actual: " + sqlVisitor.toString());
assertEquals(expectedStr, sqlVisitor.toString());
@@ -72,13 +71,13 @@
ILiteral arg1 = LANG_FACTORY.createLiteral("1234214", String.class); //$NON-NLS-1$
ILiteral count = LANG_FACTORY.createLiteral(new Integer(11), Integer.class);
helpTestMod(arg1, count, "left", //$NON-NLS-1$
- "SUBSTR('1234214', 0, 11)"); //$NON-NLS-1$
+ "SUBSTR('1234214', 1, 11)"); //$NON-NLS-1$
}
public void test2() throws Exception {
ILiteral arg1 = LANG_FACTORY.createLiteral("1234214", String.class); //$NON-NLS-1$
ILiteral count = LANG_FACTORY.createLiteral(new Integer(2), Integer.class);
helpTestMod(arg1, count, "right", //$NON-NLS-1$
- "SUBSTR('1234214', (LENGTH('1234214') - 2))"); //$NON-NLS-1$
+ "SUBSTR('1234214', (-1 * 2))"); //$NON-NLS-1$
}
}
\ No newline at end of file
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLocateFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLocateFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLocateFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -28,6 +28,7 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
+import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
@@ -55,11 +56,9 @@
IExpression expr = mod.modify(func);
OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
- OracleSQLConversionVisitor sqlVisitor = new OracleSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
sqlVisitor.append(expr);
assertEquals(expectedStr, sqlVisitor.toString());
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLog10FunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLog10FunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLog10FunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -64,6 +64,6 @@
assertEquals(Integer.class, newArg.getType());
assertEquals(new Integer(10), newArg.getValue());
- assertEquals("log(10, 5.2)", SQLStringVisitor.getSQLString(outFunc, null)); //$NON-NLS-1$
+ assertEquals("log(10, 5.2)", SQLStringVisitor.getSQLString(outFunc)); //$NON-NLS-1$
}
}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -29,6 +29,7 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
+import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
@@ -58,15 +59,11 @@
IExpression expr = mod.modify(func);
OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
- OracleSQLConversionVisitor sqlVisitor = new OracleSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
sqlVisitor.append(expr);
- //System.out.println(" expected: " + expectedStr + " \t actual: " + sqlVisitor.toString());
assertEquals(expectedStr, sqlVisitor.toString());
-
return expr;
}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleConvertModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleConvertModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -54,11 +54,9 @@
public String helpGetString(IExpression expr) throws Exception {
OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
- SQLConversionVisitor sqlVisitor = trans.getTranslationVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
sqlVisitor.append(expr);
return sqlVisitor.toString();
@@ -71,7 +69,7 @@
LANG_FACTORY.createLiteral(tgtType, String.class)},
TypeFacility.getDataTypeClass(tgtType));
- OracleConvertModifier mod = new OracleConvertModifier(LANG_FACTORY, null, null);
+ OracleConvertModifier mod = new OracleConvertModifier(LANG_FACTORY, null);
IExpression expr = mod.modify(func);
assertEquals("Error converting from " + srcExpression.getType() + " to " + tgtType, //$NON-NLS-1$ //$NON-NLS-2$
@@ -487,7 +485,7 @@
}
public void testDateToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "to_date(to_char({d'2003-11-01'}, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "cast({d'2003-11-01'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Source = TIME
@@ -497,7 +495,7 @@
}
public void testTimeToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "to_date(to_char({ts'1970-01-01 23:59:59'}, 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "cast({ts'1970-01-01 23:59:59'} AS timestamp)"); //$NON-NLS-1$ //$NON-NLS-2$
}
// Source = TIMESTAMP
@@ -514,7 +512,7 @@
public void testTimestampToTime() throws Exception {
Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "to_date(('1970-01-01 ' || substr(to_char({ts'2003-11-01 12:05:02.0'}, 'FXYYYY-MM-DD HH24:MI:SS'), 12)), 'YYYY-MM-DD HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "to_date(('1970-01-01 ' || to_char({ts'2003-11-01 12:05:02.0'}, 'HH24:MI:SS')), 'YYYY-MM-DD HH24:MI:SS')"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Added: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleTranslator.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.connector.jdbc.oracle;
+
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.cdk.api.EnvironmentUtility;
+import com.metamatrix.cdk.unittest.FakeTranslationFactory;
+import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.jdbc.access.AccessSQLTranslator;
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
+import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
+import com.metamatrix.connector.language.ICommand;
+
+public class TestOracleTranslator extends TestCase {
+
+ private static SQLTranslator TRANSLATOR;
+
+ static {
+ try {
+ TRANSLATOR = new OracleSQLTranslator();
+ TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
+ } catch(ConnectorException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void helpTestVisitor(String input, String expectedOutput) throws ConnectorException {
+ // Convert from sql to objects
+ ICommand obj = FakeTranslationFactory.getInstance().getAutoIncrementTranslationUtility().parseCommand(input);
+
+ TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), TRANSLATOR);
+ tc.translateCommand(obj);
+
+ // Check stuff
+ assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
+ }
+
+ public void testInsertWithSequnce() throws Exception {
+ helpTestVisitor("insert into test.group (e0) values (1)", "INSERT INTO group (e0, e1) VALUES (1, MYSEQUENCE.nextVal)");
+ }
+
+ public void testInsertWithSequnce1() throws Exception {
+ helpTestVisitor("insert into test.group (e0, e1) values (1, 'x')", "INSERT INTO group (e0, e1) VALUES (1, 'x')");
+ }
+}
Property changes on: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleTranslator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestParseFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestParseFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestParseFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.oracle;
-
-import java.util.Map;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.language.IFunction;
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.connector.language.ILiteral;
-
-/**
- */
-public class TestParseFunctionModifier extends TestCase {
-
- private static final ILanguageFactory LANG_FACTORY = CommandBuilder.getLanuageFactory();
-
- /**
- * Constructor for TestMonthFunctionModifier.
- * @param name
- */
- public TestParseFunctionModifier(String name) {
- super(name);
- }
-
- public IExpression helpTestMod(ILiteral datetime, ILiteral format, Class targetClass, String expectedStr) throws Exception {
- IFunction func = LANG_FACTORY.createFunction("parse", //$NON-NLS-1$
- new IExpression[] { datetime, format },
- targetClass);
-
- ParseFunctionModifier mod = new ParseFunctionModifier (LANG_FACTORY, targetClass);
- IExpression expr = mod.modify(func);
-
- OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
-
- OracleSQLConversionVisitor sqlVisitor = new OracleSQLConversionVisitor();
-
- // register this ExtractFunctionModifier with the OracleSQLConversionVisitor
- Map modifier = trans.getFunctionModifiers();
- modifier.put("parse", mod); //$NON-NLS-1$
- sqlVisitor.setFunctionModifiers(modifier);
-
- //sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
- sqlVisitor.append(expr);
- //System.out.println(" expected: " + expectedStr + " \t actual: " + sqlVisitor.toString());
- assertEquals(expectedStr, sqlVisitor.toString());
-
- return expr;
- }
- public void test1() throws Exception {
- ILiteral arg1 = LANG_FACTORY.createLiteral("2004-01-21", String.class); //$NON-NLS-1$
- ILiteral arg2 = LANG_FACTORY.createLiteral("YYYY-MM-DD", String.class); //$NON-NLS-1$
- helpTestMod(arg1, arg2, java.sql.Date.class, "to_date('2004-01-21', 'YYYY-MM-DD')" ); //$NON-NLS-1$
- }
-
- public void test2() throws Exception {
- ILiteral arg1 = LANG_FACTORY.createLiteral("2004-01-21 17:05:00.0", String.class); //$NON-NLS-1$
- ILiteral arg2 = LANG_FACTORY.createLiteral("YYYY-MM-DD HH24:MI:SS.fffffffff", String.class); //$NON-NLS-1$
- helpTestMod(arg1, arg2, java.sql.Timestamp.class, "to_date('2004-01-21 17:05:00.0', 'YYYY-MM-DD HH24:MI:SS.fffffffff')"); //$NON-NLS-1$
- }
-
- public void test3() throws Exception {
- ILiteral arg1 = LANG_FACTORY.createLiteral("12:01:21", String.class); //$NON-NLS-1$
- ILiteral arg2 = LANG_FACTORY.createLiteral("HH24:MI:SS", String.class); //$NON-NLS-1$
- helpTestMod(arg1, arg2, java.sql.Time.class, "to_date('12:01:21', 'HH24:MI:SS')"); //$NON-NLS-1$
- }
-
-}
-
-
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestSubstringFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestSubstringFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestSubstringFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -30,6 +30,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.jdbc.extension.FunctionModifier;
+import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
@@ -54,13 +55,11 @@
args, TypeFacility.RUNTIME_TYPES.STRING);
OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
IExpression expr = ((FunctionModifier)trans.getFunctionModifiers().get("substring")).modify(func); //$NON-NLS-1$
- OracleSQLConversionVisitor sqlVisitor = new OracleSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
sqlVisitor.append(expr);
assertEquals(expectedStr, sqlVisitor.toString());
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/postgresql/TestPostgreSQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/postgresql/TestPostgreSQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,16 +22,15 @@
package com.metamatrix.connector.jdbc.postgresql;
-import java.util.Map;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.api.EnvironmentUtility;
+import java.util.Map;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.MetadataFactory;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
-import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
+import com.metamatrix.connector.jdbc.MetadataFactory;
+import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
import com.metamatrix.connector.language.ICommand;
/**
@@ -39,12 +38,12 @@
public class TestPostgreSQLTranslator extends TestCase {
private static Map MODIFIERS;
- private static SQLTranslator TRANSLATOR;
+ private static PostgreSQLTranslator TRANSLATOR;
static {
try {
TRANSLATOR = new PostgreSQLTranslator();
- TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ TRANSLATOR.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
MODIFIERS = TRANSLATOR.getFunctionModifiers();
} catch(ConnectorException e) {
e.printStackTrace();
@@ -63,7 +62,7 @@
return MetadataFactory.BQT_VDB;
}
- public void helpTestVisitor(String vdb, String input, Map modifiers, int expectedType, String expectedOutput) throws ConnectorException {
+ public void helpTestVisitor(String vdb, String input, Map modifiers, String expectedOutput) throws ConnectorException {
// Convert from sql to objects
ICommand obj = MetadataFactory.helpTranslate(vdb, input);
@@ -73,7 +72,6 @@
// Check stuff
assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
- assertEquals("Did not get expected command type", expectedType, tc.getExecutionType()); //$NON-NLS-1$
}
public void testRewriteConversion1() throws Exception {
@@ -83,7 +81,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -94,7 +91,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -105,7 +101,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -116,7 +111,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion5() throws Exception {
@@ -126,7 +120,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion6() throws Exception {
@@ -136,7 +129,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion7() throws Exception {
@@ -146,7 +138,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion8() throws Exception {
@@ -156,7 +147,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion9() throws Exception {
@@ -166,7 +156,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion10() throws Exception {
@@ -176,7 +165,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion11() throws Exception {
@@ -186,7 +174,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion12() throws Exception {
@@ -196,7 +183,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion13() throws Exception {
@@ -206,7 +192,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion14() throws Exception {
@@ -216,7 +201,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion15() throws Exception {
@@ -226,7 +210,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion16() throws Exception {
@@ -236,7 +219,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion17() throws Exception {
@@ -246,7 +228,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion18() throws Exception {
@@ -256,17 +237,15 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteConversion19() throws Exception {
String input = "SELECT convert(convert(PART_WEIGHT, boolean), string) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT CASE WHEN cast(PARTS.PART_WEIGHT AS boolean)=TRUE THEN '1' ELSE '0' END FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT CASE WHEN cast(PARTS.PART_WEIGHT AS boolean) = TRUE THEN '1' ELSE '0' END FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -277,7 +256,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
input = "SELECT log10(convert(PART_WEIGHT, double)) FROM PARTS"; //$NON-NLS-1$
output = "SELECT log(cast(PARTS.PART_WEIGHT AS float8)) FROM PARTS"; //$NON-NLS-1$
@@ -285,28 +263,25 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteLeft() throws Exception {
String input = "SELECT left(PART_WEIGHT, 2) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT substr(PARTS.PART_WEIGHT, 1, 2) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT SUBSTR(PARTS.PART_WEIGHT, 1, 2) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRewriteRight() throws Exception {
String input = "SELECT right(PART_WEIGHT, 2) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT substr(PARTS.PART_WEIGHT, ((LENGTH(PARTS.PART_WEIGHT) + 1) - 2)) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT SUBSTR(PARTS.PART_WEIGHT, (-1 * 2)) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -317,7 +292,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testDayOfMonth() throws Exception {
@@ -327,7 +301,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testDayOfYear() throws Exception {
@@ -337,7 +310,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testHour() throws Exception {
@@ -347,7 +319,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testMinute() throws Exception {
@@ -357,7 +328,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testMonth() throws Exception {
@@ -367,7 +337,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testQuarter() throws Exception {
@@ -377,7 +346,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testSecond() throws Exception {
@@ -387,7 +355,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testWeek() throws Exception {
@@ -397,7 +364,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testYear() throws Exception {
@@ -407,7 +373,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testDayName() throws Exception {
@@ -417,7 +382,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testMonthName() throws Exception {
@@ -427,17 +391,15 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
- public void testNVL() throws Exception {
- String input = "SELECT nvl(PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
+ public void testIfnull() throws Exception {
+ String input = "SELECT ifnull(PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
String output = "SELECT coalesce(PARTS.PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testSubstring1() throws Exception {
@@ -447,7 +409,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testSubstring2() throws Exception {
@@ -457,17 +418,15 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testBooleanAggregate() throws Exception {
String input = "SELECT MIN(convert(PART_WEIGHT, boolean)) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT CASE MIN(CASE cast(PARTS.PART_WEIGHT AS boolean) WHEN TRUE THEN 1 ELSE 0 END) WHEN 1 THEN TRUE ELSE FALSE END FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT bool_and(cast(PARTS.PART_WEIGHT AS boolean)) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRowLimit2() throws Exception {
@@ -477,7 +436,7 @@
helpTestVisitor(getTestBQTVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testRowLimit3() throws Exception {
String input = "select intkey from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
@@ -486,7 +445,7 @@
helpTestVisitor(getTestBQTVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -27,10 +27,10 @@
import junit.framework.TestCase;
-import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.MetadataFactory;
+import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
import com.metamatrix.connector.language.ICommand;
@@ -46,7 +46,7 @@
SqlServerSQLTranslator trans = new SqlServerSQLTranslator();
try {
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
} catch(ConnectorException e) {
e.printStackTrace();
}
@@ -70,30 +70,28 @@
return MetadataFactory.BQT_VDB;
}
- public void helpTestVisitor(String vdb, String input, Map modifiers, int expectedType, String expectedOutput) throws ConnectorException {
- helpTestVisitor(vdb, input, modifiers, expectedType, new String[] {expectedOutput}, EMPTY_PROPERTIES);
+ public void helpTestVisitor(String vdb, String input, Map modifiers, String expectedOutput) throws ConnectorException {
+ helpTestVisitor(vdb, input, modifiers, new String[] {expectedOutput}, EMPTY_PROPERTIES);
}
- public void helpTestVisitor(String vdb, String input, Map modifiers, int expectedType, String[] expectedOutputs, Properties props) throws ConnectorException {
+ public void helpTestVisitor(String vdb, String input, Map modifiers, String[] expectedOutputs, Properties props) throws ConnectorException {
// Convert from sql to objects
ICommand obj = MetadataFactory.helpTranslate(vdb, input);
// Apply function replacement
FunctionReplacementVisitor funcVisitor = new FunctionReplacementVisitor(modifiers);
+ SqlServerSQLTranslator trans = new SqlServerSQLTranslator();
+ trans.initialize(EnvironmentUtility.createEnvironment(props, false));
// Convert back to SQL
- SqlServerSQLConversionVisitor sqlVisitor = new SqlServerSQLConversionVisitor();
- sqlVisitor.setProperties(props);
- sqlVisitor.setLanguageFactory(CommandBuilder.getLanuageFactory());
- sqlVisitor.setFunctionModifiers(modifiers);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
- TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), new SqlServerSQLTranslator(), sqlVisitor, funcVisitor); //$NON-NLS-1$
+ TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), trans, sqlVisitor, funcVisitor); //$NON-NLS-1$
tc.translateCommand(obj);
// Check stuff
assertEquals("Did not get correct sql", expectedOutputs[0], tc.getSql()); //$NON-NLS-1$
- assertEquals("Did not get expected command type", expectedType, tc.getExecutionType()); //$NON-NLS-1$
}
public void testModFunction() throws Exception {
@@ -103,7 +101,6 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -114,64 +111,9 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
- public void testConcatOperatorFunction() throws Exception {
- String input = "SELECT PART_NAME || 'b' FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT (PARTS.PART_NAME + 'b') FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testChrFunction() throws Exception {
- String input = "SELECT chr(CONVERT(PART_ID, INTEGER)) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT char(convert(int, PARTS.PART_ID)) FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testLcaseFunction() throws Exception {
- String input = "SELECT lcase(PART_NAME) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT lower(PARTS.PART_NAME) FROM PARTS"; //$NON-NLS-1$
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testUcaseFunction() throws Exception {
- String input = "SELECT ucase(PART_NAME) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT upper(PARTS.PART_NAME) FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testLengthFunction() throws Exception {
- String input = "SELECT length(PART_NAME) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT len(PARTS.PART_NAME) FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
public void testDayOfMonthFunction() throws Exception {
String input = "SELECT dayofmonth(convert(PARTS.PART_ID, date)) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT day(convert(datetime, PARTS.PART_ID)) FROM PARTS"; //$NON-NLS-1$
@@ -179,110 +121,17 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
- public void testSubstring2ArgFunction() throws Exception {
- String input = "SELECT substring(PART_NAME, 3) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT substring(PARTS.PART_NAME, 3, len(PARTS.PART_NAME)) FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testSubstring3ArgFunction() throws Exception {
- String input = "SELECT substring(PART_NAME, 3, 5) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT substring(PARTS.PART_NAME, 3, 5) FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testConvertFunctionString() throws Exception {
- String input = "SELECT convert(PARTS.PART_ID, integer) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT convert(int, PARTS.PART_ID) FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testConvertFunctionChar() throws Exception {
- String input = "SELECT convert(PART_NAME, char) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT convert(char, PARTS.PART_NAME) FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testConvertFunctionBoolean() throws Exception {
- String input = "SELECT convert(PART_ID, boolean) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT convert(bit, PARTS.PART_ID) FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testDateLiteral() throws Exception {
- helpTestVisitor(getTestVDB(),
- "select {d'2002-12-31'} FROM parts", //$NON-NLS-1$
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT {d'2002-12-31'} FROM PARTS"); //$NON-NLS-1$
- }
-
- public void testTimeLiteral() throws Exception {
- helpTestVisitor(getTestVDB(),
- "select {t'13:59:59'} FROM parts", //$NON-NLS-1$
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT {ts'1900-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
- }
-
- public void testTimestampLiteral() throws Exception {
- helpTestVisitor(getTestVDB(),
- "select {ts'2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT {ts'2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
- }
-
- public void helpTestVisitor(String vdb, String input, String expectedOutput) throws ConnectorException {
- helpTestVisitor(vdb, input, MODIFIERS, TranslatedCommand.EXEC_TYPE_QUERY, expectedOutput);
- }
-
public void testRowLimit() throws Exception {
String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
- String output = "SELECT TOP 100 SmallA.IntKey FROM SmallA "; //$NON-NLS-1$
+ String output = "SELECT TOP 100 * FROM (SELECT SmallA.IntKey FROM SmallA) AS X"; //$NON-NLS-1$
helpTestVisitor(getBQTVDB(),
input,
MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
- public void testNonIntMod() throws Exception {
- String input = "select mod(intkey/1.5, 3) from bqt1.smalla"; //$NON-NLS-1$
- String output = "SELECT ((convert(float, SmallA.IntKey) / 1.5) - (floor(((convert(float, SmallA.IntKey) / 1.5) / 3.0)) * 3.0)) FROM SmallA"; //$NON-NLS-1$
-
- helpTestVisitor(getBQTVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
- }
}
Deleted: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConvertModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConvertModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,520 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.sqlserver;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Timestamp;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.language.IFunction;
-import com.metamatrix.connector.language.ILanguageFactory;
-import com.metamatrix.query.unittest.TimestampUtil;
-
-/**
- */
-public class TestSqlServerConvertModifier extends TestCase {
-
- private static final ILanguageFactory LANG_FACTORY = CommandBuilder.getLanuageFactory();
-
- /**
- * Constructor for TestSybaseConvertModifier.
- * @param name
- */
- public TestSqlServerConvertModifier(String name) {
- super(name);
- }
-
- public String helpGetString(IExpression expr) throws Exception {
- SqlServerSQLTranslator trans = new SqlServerSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
-
- SQLConversionVisitor sqlVisitor = trans.getTranslationVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
- sqlVisitor.append(expr);
-
- return sqlVisitor.toString();
- }
-
- public void helpTest(IExpression srcExpression, String tgtType, String expectedExpression) throws Exception {
- IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
- srcExpression,
- LANG_FACTORY.createLiteral(tgtType, String.class)},
- DataTypeManager.getDataTypeClass(tgtType));
-
- SqlServerConvertModifier mod = new SqlServerConvertModifier(LANG_FACTORY);
- IExpression expr = mod.modify(func);
-
- assertEquals("Error converting from " + DataTypeManager.getDataTypeName(srcExpression.getType()) + " to " + tgtType, //$NON-NLS-1$ //$NON-NLS-2$
- expectedExpression, helpGetString(expr));
- }
-
- // Source = STRING
-
- public void testStringToChar() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("5", String.class), "char", "convert(char, '5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToBoolean() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("5", String.class), "boolean", "convert(bit, '5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToByte() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("5", String.class), "byte", "convert(tinyint, '5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToShort() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("5", String.class), "short", "convert(smallint, '5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("5", String.class), "integer", "convert(int, '5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToLong() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("5", String.class), "long", "convert(numeric, '5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToBigInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("5", String.class), "biginteger", "convert(numeric, '5')"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToFloat() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("5", String.class), "float", "convert(real, '5')");//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToDouble() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("5", String.class), "double", "convert(float, '5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToDate() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("2004-06-29", String.class), "date", "convert(datetime, '2004-06-29')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToTime() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("23:59:59", String.class), "time", "convert(datetime, '23:59:59')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("2004-06-29 23:59:59.987", String.class), "timestamp", "convert(datetime, '2004-06-29 23:59:59.987')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testStringToBigDecimal() throws Exception {
- helpTest(LANG_FACTORY.createLiteral("5", String.class), "bigdecimal", "convert(float, '5')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- // Source = CHAR
-
- public void testCharToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Character('5'), Character.class), "string", "convert(varchar, '5')"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = BOOLEAN
-
- public void testBooleanToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBooleanToByte() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "byte", "convert(tinyint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBooleanToShort() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "short", "convert(smallint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBooleanToInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "integer", "convert(int, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBooleanToLong() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBooleanToBigInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBooleanToFloat() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBooleanToDouble() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testBooleanToBigDecimal() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = BYTE
-
- public void testByteToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testByteToBoolean() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "boolean", "convert(bit, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testByteToShort() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "short", "convert(smallint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testByteToInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "integer", "convert(int, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testByteToLong() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testByteToBigInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testByteToFloat() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testByteToDouble() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testByteToBigDecimal() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = SHORT
-
- public void testShortToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testShortToBoolean() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "boolean", "convert(bit, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testShortToByte() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "byte", "convert(tinyint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testShortToInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "integer", "convert(int, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testShortToLong() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testShortToBigInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testShortToFloat() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testShortToDouble() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testShortToBigDecimal() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = INTEGER
-
- public void testIntegerToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testIntegerToBoolean() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "boolean", "convert(bit, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testIntegerToByte() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "byte", "convert(tinyint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testIntegerToShort() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "short", "convert(smallint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testIntegerToLong() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testIntegerToBigInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testIntegerToFloat() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testIntegerToDouble() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testIntegerToBigDecimal() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = LONG
-
- public void testLongToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testLongToBoolean() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "boolean", "convert(bit, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testLongToByte() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "byte", "convert(tinyint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testLongToShort() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "short", "convert(smallint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testLongToInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "integer", "convert(int, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testLongToBigInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testLongToFloat() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testLongToDouble() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testLongToBigDecimal() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = BIGINTEGER
-
- public void testBigIntegerToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigIntegerToBoolean() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "boolean", "convert(bit, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigIntegerToByte() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "byte", "convert(tinyint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigIntegerToShort() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "short", "convert(smallint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigIntegerToInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "integer", "convert(int, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigIntegerToLong() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigIntegerToFloat() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigIntegerToDouble() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigIntegerToBigDecimal() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- // Source = FLOAT
-
- public void testFloatToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "string", "convert(varchar, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testFloatToBoolean() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "boolean", "convert(bit, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testFloatToByte() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "byte", "convert(tinyint, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testFloatToShort() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "short", "convert(smallint, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testFloatToInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "integer", "convert(int, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testFloatToLong() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "long", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testFloatToBigInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "biginteger", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testFloatToDouble() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "double", "convert(float, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testFloatToBigDecimal() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "bigdecimal", "convert(float, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = DOUBLE
-
- public void testDoubleToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "string", "convert(varchar, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testDoubleToBoolean() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "boolean", "convert(bit, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testDoubleToByte() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "byte", "convert(tinyint, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testDoubleToShort() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "short", "convert(smallint, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testDoubleToInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "integer", "convert(int, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testDoubleToLong() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "long", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testDoubleToBigInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "biginteger", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testDoubleToFloat() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "float", "convert(real, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testDoubleToBigDecimal() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "bigdecimal", "convert(float, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = BIGDECIMAL
-
- public void testBigDecimalToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "string", "convert(varchar, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigDecimalToBoolean() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "boolean", "convert(bit, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigDecimalToByte() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "byte", "convert(tinyint, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigDecimalToShort() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "short", "convert(smallint, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigDecimalToInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "integer", "convert(int, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigDecimalToLong() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "long", "convert(numeric, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigDecimalToBigInteger() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "biginteger", "convert(numeric, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigDecimalToFloat() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "float", "convert(real, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testBigDecimalToDoublel() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "double", "convert(float, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- // Source = DATE
-
- public void testDateToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "string", "convert(varchar, {d'2003-11-01'}, 101)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testDateToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createDate(103, 10, 1), java.sql.Date.class), "timestamp", "convert(datetime, {d'2003-11-01'})"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = TIME
-
- public void testTimeToString() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "string", "convert(varchar, {ts'1900-01-01 23:59:59'}, 108)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testTimeToTimestamp() throws Exception {
- helpTest(LANG_FACTORY.createLiteral(TimestampUtil.createTime(23, 59, 59), java.sql.Time.class), "timestamp", "convert(datetime, {ts'1900-01-01 23:59:59'})"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Source = TIMESTAMP
-
- public void testTimestampToString() throws Exception {
- Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "string", "convert(varchar, {ts'2003-11-01 12:05:02.0'}, 109)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testTimestampToDate() throws Exception {
- Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "date", "convert(datetime, convert(varchar, {ts'2003-11-01 12:05:02.0'}, 109))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testTimestampToTime() throws Exception {
- Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- helpTest(LANG_FACTORY.createLiteral(ts, Timestamp.class), "time", "convert(datetime, convert(varchar, {ts'2003-11-01 12:05:02.0'}, 108))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
Deleted: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestFormatTimestampModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestFormatTimestampModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestFormatTimestampModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.sybase;
-
-import java.sql.Timestamp;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.language.IFunction;
-import com.metamatrix.connector.language.ILanguageFactory;
-
-/**
- */
-public class TestFormatTimestampModifier extends TestCase {
-
- private static final ILanguageFactory LANG_FACTORY = CommandBuilder.getLanuageFactory();
-
- /**
- * Constructor for TestFormatTimestampModifier.
- * @param name
- */
- public TestFormatTimestampModifier(String name) {
- super(name);
- }
-
- public void helpTestMod(String format, String expectedStr) throws Exception {
- Timestamp ts = new Timestamp(103, 10, 1, 12, 5, 2, 0);
- IFunction func = LANG_FACTORY.createFunction("formattimestamp", //$NON-NLS-1$
- new IExpression[] { LANG_FACTORY.createLiteral(ts, Timestamp.class),
- LANG_FACTORY.createLiteral(format, String.class) },
- String.class);
-
- FormatTimestampModifier mod = new FormatTimestampModifier(LANG_FACTORY);
- IExpression expr = mod.modify(func);
-
- SybaseSQLTranslator trans = new SybaseSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
-
- SybaseSQLConversionVisitor sqlVisitor = new SybaseSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
- sqlVisitor.append(expr);
- assertEquals(expectedStr, sqlVisitor.toString());
- }
-
- public void testModStyle1() throws Exception {
- helpTestMod("MM/dd/yyyy", "convert(varchar, {ts'2003-11-01 12:05:02.0'}, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testModUnknownFormat() throws Exception {
- helpTestMod("MM:yyy", "convert(varchar, {ts'2003-11-01 12:05:02.0'})"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
Deleted: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestModFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestModFunctionModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestModFunctionModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.jdbc.sybase;
-
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.language.IFunction;
-import com.metamatrix.connector.language.ILanguageFactory;
-
-/**
- */
-public class TestModFunctionModifier extends TestCase {
-
- private static final ILanguageFactory LANG_FACTORY = CommandBuilder.getLanuageFactory();
-
-
- /**
- * Constructor for TestModFunctionModifier.
- * @param name
- */
- public TestModFunctionModifier(String name) {
- super(name);
- }
-
- public void helpTestMod(int first, int second, String expectedStr) throws Exception {
- IFunction func = LANG_FACTORY.createFunction("mod", //$NON-NLS-1$
- new IExpression[] { LANG_FACTORY.createLiteral(new Integer(first), Integer.class),
- LANG_FACTORY.createLiteral(new Integer(second), Integer.class) },
- String.class);
-
- ModFunctionModifier mod = new ModFunctionModifier();
- IExpression expr = mod.modify(func);
-
- SybaseSQLTranslator trans = new SybaseSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
-
- SybaseSQLConversionVisitor sqlVisitor = new SybaseSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
- sqlVisitor.append(expr);
- assertEquals(expectedStr, sqlVisitor.toString());
- }
-
- public void testMod1() throws Exception {
- helpTestMod(5, 5, "(5 % 5)"); //$NON-NLS-1$
- }
-
-}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseConvertModifier.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseConvertModifier.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,6 +22,8 @@
package com.metamatrix.connector.jdbc.sybase;
+import java.math.BigDecimal;
+import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Properties;
@@ -29,12 +31,12 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
import com.metamatrix.connector.language.ILiteral;
-import com.metamatrix.connector.language.ISelectSymbol;
import com.metamatrix.query.unittest.TimestampUtil;
/**
@@ -53,11 +55,9 @@
public String helpGetString(IExpression expr) throws Exception {
SybaseSQLTranslator trans = new SybaseSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
- SybaseSQLConversionVisitor sqlVisitor = new SybaseSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
sqlVisitor.append(expr);
return sqlVisitor.toString();
@@ -67,15 +67,21 @@
SybaseConvertModifier mod = new SybaseConvertModifier(LANG_FACTORY);
IExpression expr = mod.modify(func);
- SybaseSQLTranslator trans = new SybaseSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
+ assertEquals(expectedStr, helpGetString(expr));
+ }
+
+ public void helpTest(IExpression srcExpression, String tgtType, String expectedExpression) throws Exception {
+ IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
+ new IExpression[] {
+ srcExpression,
+ LANG_FACTORY.createLiteral(tgtType, String.class)},
+ DataTypeManager.getDataTypeClass(tgtType));
- SybaseSQLConversionVisitor sqlVisitor = new SybaseSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(trans.getFunctionModifiers());
- sqlVisitor.setLanguageFactory(LANG_FACTORY);
- sqlVisitor.append(expr);
-
- assertEquals(expectedStr, sqlVisitor.toString());
+ SybaseConvertModifier mod = new SybaseConvertModifier(LANG_FACTORY);
+ IExpression expr = mod.modify(func);
+
+ assertEquals("Error converting from " + DataTypeManager.getDataTypeName(srcExpression.getType()) + " to " + tgtType, //$NON-NLS-1$ //$NON-NLS-2$
+ expectedExpression, helpGetString(expr));
}
// original test -- this is not a drop one anymore
@@ -115,35 +121,9 @@
LANG_FACTORY.createLiteral("date", String.class)}, //$NON-NLS-1$
java.sql.Date.class);
- helpGetString1(func, "convert(datetime, convert(varchar, {ts'1989-03-03 07:08:12.000099999'}, 1))"); //$NON-NLS-1$
+ helpGetString1(func, "convert(datetime, convert(varchar, {ts'1989-03-03 07:08:12.000099999'}, 109))"); //$NON-NLS-1$
}
- public void testConvertFormat() throws Exception {
-
- Timestamp ts = TimestampUtil.createTimestamp(103, 10, 1, 12, 5, 2, 0);
- IFunction func1 = LANG_FACTORY.createFunction("formattimestamp", //$NON-NLS-1$
- new IExpression[] {
- LANG_FACTORY.createLiteral(ts, Timestamp.class),
- LANG_FACTORY.createLiteral("MM/dd/yyyy", String.class)}, //$NON-NLS-1$
- String.class);
-
- IFunction func2 = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
- func1,
- LANG_FACTORY.createLiteral("date", String.class)}, //$NON-NLS-1$
- java.sql.Date.class);
-
- SybaseSQLTranslator trans = new SybaseSQLTranslator();
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
-
- // Perform function replacement, per standard function modifiers
- FunctionReplacementVisitor functionVisitor = new FunctionReplacementVisitor(trans.getFunctionModifiers());
- ISelectSymbol holder = LANG_FACTORY.createSelectSymbol("holder", func2); //$NON-NLS-1$
- holder.acceptVisitor(functionVisitor);
- IExpression expr = holder.getExpression();
-
- assertEquals("convert(datetime, convert(varchar, {ts'2003-11-01 12:05:02.0'}, 1))", helpGetString(expr)); //$NON-NLS-1$
- }
/********************END of convert(INPUT, date) ******************/
/********************Beginning of convert(INPUT, time) ******************/
public void testStringToTime() throws Exception {
@@ -188,7 +168,7 @@
LANG_FACTORY.createLiteral("timestamp", String.class)}, //$NON-NLS-1$
java.sql.Timestamp.class);
- helpGetString1(func, "convert(datetime, {t'12:02:03'})"); //$NON-NLS-1$
+ helpGetString1(func, "convert(datetime, {ts'1970-01-01 12:02:03'})"); //$NON-NLS-1$
}
public void testDateToTimestamp() throws Exception {
@@ -253,7 +233,7 @@
LANG_FACTORY.createLiteral("string", String.class)}, //$NON-NLS-1$
String.class);
- helpGetString1(func, "convert(varchar, {t'03:10:01'}, 108)"); //$NON-NLS-1$
+ helpGetString1(func, "convert(varchar, {ts'1970-01-01 03:10:01'}, 108)"); //$NON-NLS-1$
}
public void testBigDecimalToString() throws Exception {
@@ -829,6 +809,233 @@
java.math.BigDecimal.class);
helpGetString1(func, "convert(float, 0)"); //$NON-NLS-1$
+ }
+
+ // Source = CHAR
+
+ public void testCharToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Character('5'), Character.class), "string", "convert(varchar, '5')"); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ // Source = BOOLEAN
+
+ public void testBooleanToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBooleanToByte() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "byte", "convert(tinyint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBooleanToShort() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "short", "convert(smallint, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBooleanToInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "integer", "convert(int, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBooleanToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBooleanToBigInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBooleanToFloat() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBooleanToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBooleanToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(Boolean.TRUE, Boolean.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = BYTE
+
+ public void testByteToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testByteToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testByteToBigInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testByteToFloat() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testByteToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testByteToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Byte((byte)1), Byte.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = SHORT
+
+ public void testShortToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testShortToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testShortToBigInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testShortToFloat() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testShortToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testShortToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Short((short)1), Short.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = INTEGER
+
+ public void testIntegerToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testIntegerToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testIntegerToBigInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testIntegerToFloat() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testIntegerToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testIntegerToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Integer(1), Integer.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = LONG
+
+ public void testLongToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testLongToBigInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "biginteger", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testLongToFloat() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testLongToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testLongToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Long(1), Long.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = BIGINTEGER
+
+ public void testBigIntegerToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "string", "convert(varchar, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public void testBigIntegerToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "long", "convert(numeric, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public void testBigIntegerToFloat() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "float", "convert(real, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public void testBigIntegerToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "double", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public void testBigIntegerToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigInteger("1"), BigInteger.class), "bigdecimal", "convert(float, 1)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ // Source = FLOAT
+
+ public void testFloatToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "string", "convert(varchar, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testFloatToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "long", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testFloatToBigInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "biginteger", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testFloatToDouble() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "double", "convert(float, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testFloatToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Float(1.2f), Float.class), "bigdecimal", "convert(float, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Source = DOUBLE
+
+ public void testDoubleToString() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "string", "convert(varchar, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testDoubleToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "long", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testDoubleToBigInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "biginteger", "convert(numeric, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testDoubleToFloat() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "float", "convert(real, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testDoubleToBigDecimal() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new Double(1.2), Double.class), "bigdecimal", "convert(float, 1.2)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testBigDecimalToLong() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "long", "convert(numeric, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public void testBigDecimalToBigInteger() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "biginteger", "convert(numeric, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public void testBigDecimalToFloat() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "float", "convert(real, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public void testBigDecimalToDoublel() throws Exception {
+ helpTest(LANG_FACTORY.createLiteral(new BigDecimal("1.0"), BigDecimal.class), "double", "convert(float, 1.0)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,7 +22,6 @@
package com.metamatrix.connector.jdbc.sybase;
-import java.util.Map;
import java.util.Properties;
import junit.framework.TestCase;
@@ -30,6 +29,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.MetadataFactory;
+import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
import com.metamatrix.connector.language.ICommand;
@@ -38,19 +38,6 @@
*/
public class TestSybaseSQLConversionVisitor extends TestCase {
- private static Map MODIFIERS;
-
- static {
- SybaseSQLTranslator trans = new SybaseSQLTranslator();
-
- try {
- trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), null);
- } catch(ConnectorException e) {
- e.printStackTrace();
- }
-
- MODIFIERS = trans.getFunctionModifiers();
- }
/**
* Constructor for TestSqlServerConversionVisitor.
* @param name
@@ -67,17 +54,22 @@
return MetadataFactory.BQT_VDB;
}
- public void helpTestVisitor(String vdb, String input, Map modifiers, int expectedType, String expectedOutput) {
+ public void helpTestVisitor(String vdb, String input, String expectedOutput) {
// Convert from sql to objects
ICommand obj = MetadataFactory.helpTranslate(vdb, input);
// Apply function replacement
- FunctionReplacementVisitor funcVisitor = new FunctionReplacementVisitor(modifiers);
-
+ SybaseSQLTranslator trans = new SybaseSQLTranslator();
+ try {
+ trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
+ } catch (ConnectorException e1) {
+ throw new RuntimeException(e1);
+ }
+ FunctionReplacementVisitor funcVisitor = new FunctionReplacementVisitor(trans.getFunctionModifiers());
+
// Convert back to SQL
- SybaseSQLConversionVisitor sqlVisitor = new SybaseSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(modifiers);
- TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), new SybaseSQLTranslator(), sqlVisitor, funcVisitor);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
+ TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), trans, sqlVisitor, funcVisitor);
try {
tc.translateCommand(obj);
} catch (ConnectorException e) {
@@ -88,7 +80,6 @@
// System.out.println("in: " + input); //$NON-NLS-1$
//System.out.println("out: " + tc.getSql()); //$NON-NLS-1$
assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
- assertEquals("Did not get expected command type", expectedType, tc.getExecutionType()); //$NON-NLS-1$
}
public void testModFunction() {
@@ -98,8 +89,6 @@
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -109,40 +98,14 @@
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
- public void testConcatOperatorFunction() {
- String input = "SELECT PART_NAME || 'b' FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT (PARTS.PART_NAME + 'b') FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testChrFunction() {
- String input = "SELECT chr(CONVERT(PART_ID, INTEGER)) FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT char(convert(int, PARTS.PART_ID)) FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
public void testLcaseFunction() {
String input = "SELECT lcase(PART_NAME) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT lower(PARTS.PART_NAME) FROM PARTS"; //$NON-NLS-1$
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -152,8 +115,6 @@
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -163,8 +124,6 @@
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -174,8 +133,6 @@
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -185,8 +142,6 @@
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -197,8 +152,6 @@
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -208,8 +161,6 @@
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -219,8 +170,6 @@
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -230,57 +179,50 @@
helpTestVisitor(getTestVDB(),
input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
- public void testNvlFunction() {
- String input = "SELECT nvl(PART_NAME, 'abc') FROM PARTS"; //$NON-NLS-1$
- String output = "SELECT isnull(PARTS.PART_NAME, 'abc') FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
public void testDateLiteral() {
helpTestVisitor(getTestVDB(),
"select {d'2002-12-31'} FROM parts", //$NON-NLS-1$
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT {d'2002-12-31'} FROM PARTS"); //$NON-NLS-1$
}
public void testTimeLiteral() {
helpTestVisitor(getTestVDB(),
"select {t'13:59:59'} FROM parts", //$NON-NLS-1$
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT {t'13:59:59'} FROM PARTS"); //$NON-NLS-1$
+ "SELECT {ts'1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
}
public void testTimestampLiteral() {
helpTestVisitor(getTestVDB(),
"select {ts'2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT {ts'2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
}
public void testDefect12120() {
helpTestVisitor(getBQTVDB(),
"SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE BQT1.SmallA.BooleanValue IN ({b'false'}, {b'true'}) ORDER BY IntKey", //$NON-NLS-1$
- MODIFIERS,
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT SmallA.IntKey FROM SmallA WHERE SmallA.BooleanValue IN (0, 1) ORDER BY IntKey"); //$NON-NLS-1$
}
+
+ public void testConvertFunctionString() throws Exception {
+ String input = "SELECT convert(PARTS.PART_ID, integer) FROM PARTS"; //$NON-NLS-1$
+ String output = "SELECT convert(int, PARTS.PART_ID) FROM PARTS"; //$NON-NLS-1$
+
+ helpTestVisitor(getTestVDB(),
+ input,
+ output);
+ }
+
+ public void testNonIntMod() throws Exception {
+ String input = "select mod(intkey/1.5, 3) from bqt1.smalla"; //$NON-NLS-1$
+ String output = "SELECT ((convert(float, SmallA.IntKey) / 1.5) - (floor(((convert(float, SmallA.IntKey) / 1.5) / 3.0)) * 3.0)) FROM SmallA"; //$NON-NLS-1$
+
+ helpTestVisitor(getBQTVDB(),
+ input,
+ output);
+ }
- public void helpTestVisitor(String vdb, String input, String expectedOutput) throws ConnectorException {
- helpTestVisitor(vdb, input, MODIFIERS, TranslatedCommand.EXEC_TYPE_QUERY, expectedOutput);
-
- }
}
Modified: trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -45,15 +45,14 @@
import java.util.ListIterator;
import java.util.Properties;
+import javax.naming.NamingException;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.SearchControls;
import javax.naming.ldap.SortKey;
-import javax.naming.NamingException;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.language.IAggregate;
-import com.metamatrix.connector.language.ICaseExpression;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICompoundCriteria;
import com.metamatrix.connector.language.ICriteria;
@@ -412,8 +411,6 @@
} else {
if(e instanceof IAggregate) {
logger.logError("Received IAggregate, but it is not supported. Check capabilities."); //$NON-NLS-1$
- } else if(e instanceof ICaseExpression) {
- logger.logError("Received ICaseExpression, but it is not supported. Check capabilties."); //$NON-NLS-1$
} else if(e instanceof IFunction) {
logger.logError("Received IFunction, but it is not supported. Check capabilties."); //$NON-NLS-1$
} else if(e instanceof IScalarSubquery) {
Modified: trunk/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -203,7 +203,7 @@
private LDAPSearchDetails helpGetSearchDetails(String queryString) throws ConnectorException {
ConnectorLogger logger = new SysLogger(false);
QueryMetadataInterface metadata = exampleLdap();
- RuntimeMetadata rm = new MetadataFactory(metadata).createRuntimeMetadata();
+ RuntimeMetadata rm = new MetadataFactory(metadata).getRuntimeMetadata();
Properties props = new Properties();
IQueryToLdapSearchParser searchParser = new IQueryToLdapSearchParser(logger,rm,props);
Property changes on: trunk/connectors/connector-xml-common
___________________________________________________________________
Name: svn:ignore
- target
+ target
.project
bin
Deleted: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialConversionVisitor.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- * Created on Mar 23, 2004
- */
-package com.metamatrix.connector.jdbc.oracle.spatial;
-
-import java.util.Iterator;
-
-import com.metamatrix.connector.jdbc.oracle.OracleSQLConversionVisitor;
-import com.metamatrix.connector.language.ISelect;
-import com.metamatrix.connector.language.ISelectSymbol;
-
-public class OracleSpatialConversionVisitor extends OracleSQLConversionVisitor {
-
- public void visit(ISelect obj) {
- buffer.append(SELECT);
- buffer.append(SPACE);
-
- // Add a hint here if one is in the SELECT
- if (obj instanceof SpatialHint) {
- SpatialHint hint = (SpatialHint)obj;
- buffer.append(hint.getHint());
- buffer.append(SPACE);
- }
-
- // Add DISTINCT if necessary
- if (obj.isDistinct()) {
- buffer.append(DISTINCT).append(SPACE);
- }
-
- // Add select symbols
- Iterator iter = obj.getSelectSymbols().iterator();
- while (iter.hasNext()) {
- ISelectSymbol sSymbol = (ISelectSymbol)iter.next();
- if (sSymbol.getExpression().getType().equals(Object.class)) {
- buffer.append(NULL).append(SPACE);
- buffer.append(AS).append(SPACE);
- String outName = sSymbol.getOutputName();
- int lIndx = outName.lastIndexOf("."); //$NON-NLS-1$
- buffer.append(outName.substring(lIndx + 1)).append(SPACE);
- } else {
- append(sSymbol);
- }
- if (iter.hasNext())
- buffer.append(COMMA).append(SPACE);
- }
- }
-
-}
\ No newline at end of file
Modified: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialSQLTranslator.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialSQLTranslator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialSQLTranslator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -25,132 +25,113 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
+import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
-import com.metamatrix.connector.jdbc.oracle.OracleSQLTranslator;
+import com.metamatrix.connector.api.TypeFacility;
+import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.ICriteria;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.ISelect;
+import com.metamatrix.connector.language.ISelectSymbol;
import com.metamatrix.connector.visitor.util.CollectorVisitor;
-public class OracleSpatialSQLTranslator extends OracleSQLTranslator {
+public class OracleSpatialSQLTranslator extends SQLTranslator {
- /**
- * This method is overridden to find function modifiers that modify functions in the incoming command.
- */
- public Map getFunctionModifiers() {
- Map modifiers = super.getFunctionModifiers();
- Iterator iter = OracleSpatialFunctions.relateFunctions.iterator();
+ @Override
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ Iterator<String> iter = OracleSpatialFunctions.relateFunctions.iterator();
while (iter.hasNext()) {
- modifiers.put(iter.next(), new RelateFunctionModifier());
+ registerFunctionModifier(iter.next(), new RelateFunctionModifier());
}
iter = OracleSpatialFunctions.nearestNeighborFunctions.iterator();
while (iter.hasNext()) {
- modifiers.put(iter.next(), new NearestNeighborFunctionModifier());
+ registerFunctionModifier(iter.next(), new NearestNeighborFunctionModifier());
}
iter = OracleSpatialFunctions.filterFunctions.iterator();
while (iter.hasNext()) {
- modifiers.put(iter.next(), new FilterFunctionModifier());
+ registerFunctionModifier(iter.next(), new FilterFunctionModifier());
}
iter = OracleSpatialFunctions.withinDistanceFunctions.iterator();
while (iter.hasNext()) {
- modifiers.put(iter.next(), new WithinDistanceFunctionModifier());
+ registerFunctionModifier(iter.next(), new WithinDistanceFunctionModifier());
}
iter = OracleSpatialFunctions.nnDistanceFunctions.iterator();
while (iter.hasNext()) {
- modifiers.put(iter.next(), new NnDistanceFunctionModifier());
+ registerFunctionModifier(iter.next(), new NnDistanceFunctionModifier());
}
- return modifiers;
}
/**
* This method is overridden to modify the incoming command to add the hint to the ISelect in the command.
*/
-public ICommand modifyCommand(ICommand command, ExecutionContext context) throws ConnectorException {
+ @Override
+ public ICommand modifyCommand(ICommand command, com.metamatrix.connector.api.ExecutionContext context) throws ConnectorException {
if (command instanceof IQuery) {
IQuery query = (IQuery)command;
- String hint = getHint(query);
ISelect select = ((IQuery)command).getSelect();
- List symbols = select.getSelectSymbols();
- if(symbols.toString().indexOf("SDO_NN_DISTANCE") != -1){ //$NON-NLS-1$
- ICriteria criteria = query.getWhere();
- if(criteria != null && criteria.toString().indexOf("SDO_NN") == -1){ //$NON-NLS-1$
- throw(new ConnectorException(
- Messages.getString("OracleSpatialSQLTranslator.SDO_NN_DEPENDENCY_ERROR"))); //$NON-NLS-1$
- }
- }
- /*Iterator iter = symbols.iterator();
- while(iter.hasNext()){
- if(((ISelectSymbol)iter.next()).getExpression().compareToIgnoreCase("SDO_NN_DISTANCE") != 0){ //$NON-NLS-1$
+ List<ISelectSymbol> symbols = select.getSelectSymbols();
+
+ Collection<IFunction> functions = CollectorVisitor.collectObjects(IFunction.class, select);
+ for (IFunction function : functions) {
+ if (function.getName().equalsIgnoreCase("SDO_NN_DISTANCE")) {//$NON-NLS-1$
ICriteria criteria = query.getWhere();
- if(criteria != null && criteria.toString().compareToIgnoreCase("SDO_NN") != 0){ //$NON-NLS-1$
- break;
- } else{
+ if(criteria == null || criteria.toString().indexOf("SDO_NN") == -1){ //$NON-NLS-1$
throw(new ConnectorException(
Messages.getString("OracleSpatialSQLTranslator.SDO_NN_DEPENDENCY_ERROR"))); //$NON-NLS-1$
}
- }
+ break;
+ }
+ }
+
+ for (int i = 0; i < symbols.size(); i++) {
+ ISelectSymbol symbol = symbols.get(i);
+ if (symbol.getExpression().getType().equals(Object.class)) {
+ String outName = symbol.getOutputName();
+ int lIndx = outName.lastIndexOf("."); //$NON-NLS-1$
+ symbol.setOutputName(outName.substring(lIndx + 1));
+ symbol.setExpression(getLanguageFactory().createLiteral(null, TypeFacility.RUNTIME_TYPES.OBJECT));
+ symbol.setAlias(true);
+ }
}
- */
- if (hint != null) {
- SpatialSelectProxy proxy = new SpatialSelectProxy(select, hint);
- query.setSelect(proxy);
- }
}
return command;
}
- /**
- * This method is overridden to use a special variant of the SQL conversion visitor so that the hint can be inserted into the
- * SQL.
- */
- public SQLConversionVisitor getTranslationVisitor() {
- OracleSpatialConversionVisitor visitor = new OracleSpatialConversionVisitor();
- visitor.setRuntimeMetadata(getRuntimeMetadata());
- visitor.setFunctionModifiers(getFunctionModifiers());
- visitor.setProperties(getConnectorEnvironment().getProperties());
- visitor.setLanguageFactory(getConnectorEnvironment().getLanguageFactory());
- return visitor;
- }
/**
* This method figures out what the hint is by looking at the query and returns it.
- *
* @param query
+ *
* @return The hint or null for no hint
*/
- private String getHint(IQuery query) {
- //
- // This simple algorithm determines the hint which will be added to the
- // query.
- // Right now, we look through all functions passed in the query
- // (returned as a collection)
- // Then we check if any of those functions contain the strings 'sdo' and
- // 'relate'
- // If so, the ORDERED hint is added, if not, it isn't
- Class iFunction = null;
- try {
- iFunction = Class.forName("com.metamatrix.data.language.IFunction"); //$NON-NLS-1$
- } catch (ClassNotFoundException cex) {
- System.err.println("BML: IFunction Class Missing"); //$NON-NLS-1$
- }
- Collection col = CollectorVisitor.collectObjects(iFunction, query);
- Iterator it = col.iterator();
- while (it.hasNext()) {
- IFunction func = (IFunction)it.next();
- String funcName = func.getName().toUpperCase();
- int indx1 = funcName.indexOf("SDO"); //$NON-NLS-1$
- int indx2 = funcName.indexOf("RELATE"); //$NON-NLS-1$
- if (indx1 >= 0 && indx2 > indx1)
- return "/* + ORDERED */"; //$NON-NLS-1$
- }
- return " "; //$NON-NLS-1$
+ @Override
+ public String getSourceComment(ExecutionContext context, ICommand command) {
+ String comment = super.getSourceComment(context, command);
+
+ if (command instanceof IQuery) {
+ //
+ // This simple algorithm determines the hint which will be added to the
+ // query.
+ // Right now, we look through all functions passed in the query
+ // (returned as a collection)
+ // Then we check if any of those functions contain the strings 'sdo' and
+ // 'relate'
+ // If so, the ORDERED hint is added, if not, it isn't
+ Collection<IFunction> col = CollectorVisitor.collectObjects(IFunction.class, command);
+ for (IFunction func : col) {
+ String funcName = func.getName().toUpperCase();
+ int indx1 = funcName.indexOf("SDO"); //$NON-NLS-1$
+ int indx2 = funcName.indexOf("RELATE"); //$NON-NLS-1$
+ if (indx1 >= 0 && indx2 > indx1)
+ return comment + " /* + ORDERED */"; //$NON-NLS-1$
+ }
+ }
+ return comment; //$NON-NLS-1$
}
}
\ No newline at end of file
Deleted: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/SpatialHint.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/SpatialHint.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/SpatialHint.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- * Created on Mar 23, 2004
- */
-package com.metamatrix.connector.jdbc.oracle.spatial;
-
-public interface SpatialHint {
-
- String getHint();
-}
\ No newline at end of file
Deleted: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/SpatialSelectProxy.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/SpatialSelectProxy.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/SpatialSelectProxy.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- * Created on Mar 23, 2004
- */
-package com.metamatrix.connector.jdbc.oracle.spatial;
-
-import java.util.List;
-
-import com.metamatrix.connector.language.ISelect;
-import com.metamatrix.connector.visitor.framework.LanguageObjectVisitor;
-
-public class SpatialSelectProxy implements
- ISelect,
- SpatialHint {
-
- private ISelect delegate;
-
- private String hint;
-
- public SpatialSelectProxy(ISelect delegate,
- String hint) {
- this.delegate = delegate;
- this.hint = hint;
- }
-
- public List getSelectSymbols() {
- return this.delegate.getSelectSymbols();
- }
-
- public boolean isDistinct() {
- return this.delegate.isDistinct();
- }
-
- public void setSelectSymbols(List symbols) {
- this.delegate.setSelectSymbols(symbols);
- }
-
- public void setDistinct(boolean distinct) {
- this.setDistinct(distinct);
- }
-
- public String getHint() {
- return this.hint;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.metamatrix.data.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.framework.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
-}
\ No newline at end of file
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/TypeFacilityImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/TypeFacilityImpl.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/TypeFacilityImpl.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,7 +22,12 @@
package com.metamatrix.dqp.internal.datamgr.impl;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.TimeZone;
+
import com.metamatrix.common.types.*;
+import com.metamatrix.common.util.TimestampWithTimezone;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.TypeFacility;
@@ -49,5 +54,11 @@
public Object convertToRuntimeType(Object value) {
return DataTypeManager.convertToRuntimeType(value);
}
+
+ @Override
+ public Object convertDate(Date date, TimeZone initial, Calendar target,
+ Class targetType) {
+ return TimestampWithTimezone.create(date, initial, target, targetType);
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/BaseLanguageObject.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/BaseLanguageObject.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/BaseLanguageObject.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -36,7 +36,7 @@
}
public String toString() {
- return SQLStringVisitor.getSQLString(this, null);
+ return SQLStringVisitor.getSQLString(this);
}
}
Deleted: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CaseExpressionImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CaseExpressionImpl.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CaseExpressionImpl.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,130 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.internal.datamgr.language;
-
-import java.util.List;
-
-import com.metamatrix.connector.language.ICaseExpression;
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.visitor.framework.LanguageObjectVisitor;
-
-public class CaseExpressionImpl extends BaseLanguageObject implements ICaseExpression {
-
- private IExpression expression = null;
- private List whenExpressions = null;
- private List thenExpressions = null;
- private IExpression elseExpression = null;
- private Class type = null;
-
- public CaseExpressionImpl(IExpression expression,
- List whens, List thens, IExpression elseExpression,
- Class type) {
-
- this.expression = expression;
- this.whenExpressions = whens;
- this.thenExpressions = thens;
- this.elseExpression = elseExpression;
- this.type = type;
- }
- /**
- * @see com.metamatrix.connector.language.ICaseExpression#getElseExpression()
- */
- public IExpression getElseExpression() {
- return elseExpression;
- }
-
- /**
- * @see com.metamatrix.connector.language.ICaseExpression#getExpression()
- */
- public IExpression getExpression() {
- return expression;
- }
-
- /**
- * @see com.metamatrix.connector.language.ICaseExpression#getThenExpression(int)
- */
- public IExpression getThenExpression(int index) {
- return (IExpression)thenExpressions.get(index);
- }
-
- /**
- * @see com.metamatrix.connector.language.ICaseExpression#getWhenCount()
- */
- public int getWhenCount() {
- return whenExpressions.size();
- }
-
- /**
- * @see com.metamatrix.connector.language.ICaseExpression#getWhenExpression(int)
- */
- public IExpression getWhenExpression(int index) {
- return (IExpression)whenExpressions.get(index);
- }
-
- /**
- * @see com.metamatrix.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
- */
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
- /*
- * @see com.metamatrix.data.language.ICaseExpression#setExpression(com.metamatrix.data.language.IExpression)
- */
- public void setExpression(IExpression expression) {
- this.expression = expression;
- }
- /*
- * @see com.metamatrix.data.language.ICaseExpression#setWhenExpression(int, com.metamatrix.data.language.IExpression)
- */
- public void setWhenExpression(int index, IExpression expression) {
- this.whenExpressions.set(index, expression);
- }
-
- /*
- * @see com.metamatrix.data.language.ICaseExpression#setThenExpression(int, com.metamatrix.data.language.IExpression)
- */
- public void setThenExpression(int index, IExpression expression) {
- this.thenExpressions.set(index, expression);
- }
-
- /*
- * @see com.metamatrix.data.language.ICaseExpression#setElseExpression(com.metamatrix.data.language.IExpression)
- */
- public void setElseExpression(IExpression expression) {
- this.elseExpression = expression;
- }
-
- /*
- * @see com.metamatrix.data.language.IExpression#getType()
- */
- public Class getType() {
- return this.type;
- }
- /*
- * @see com.metamatrix.data.language.IExpression#setType(java.lang.Class)
- */
- public void setType(Class type) {
- this.type = type;
- }
-
-}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -31,7 +31,6 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.connector.language.IAggregate;
import com.metamatrix.connector.language.IBatchedUpdates;
-import com.metamatrix.connector.language.ICaseExpression;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICompoundCriteria;
@@ -71,6 +70,7 @@
import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.language.ISubqueryCompareCriteria.Quantifier;
import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.metadata.runtime.MetadataID.Type;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.internal.datamgr.metadata.MetadataFactory;
import com.metamatrix.dqp.internal.datamgr.metadata.ProcedureIDImpl;
@@ -483,19 +483,6 @@
return null;
}
- ICaseExpression translate(CaseExpression expr) throws MetaMatrixComponentException {
- ArrayList whens = new ArrayList();
- ArrayList thens = new ArrayList();
- for (int i = 0; i < expr.getWhenCount(); i++) {
- whens.add(translate(expr.getWhenExpression(i)));
- thens.add(translate(expr.getThenExpression(i)));
- }
- return new CaseExpressionImpl(translate(expr.getExpression()),
- whens,
- thens,
- translate(expr.getElseExpression()), expr.getType());
- }
-
ILiteral translate(Constant constant) {
return new LiteralImpl(constant.getValue(), constant.getType());
}
@@ -563,7 +550,7 @@
if(! (mid instanceof TempMetadataID)) {
try {
- element.setMetadataID(metadataFactory.createMetadataID(mid, MetadataID.TYPE_ELEMENT));
+ element.setMetadataID(metadataFactory.createMetadataID(mid, Type.TYPE_ELEMENT));
} catch(QueryMetadataException e) {
LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, DQPPlugin.Util.getString("LanguageBridgeFactory.Unable_to_set_the_metadata_ID_for_element_{0}._10", symbol.getName())); //$NON-NLS-1$
throw new MetaMatrixComponentException(e);
@@ -700,7 +687,7 @@
return group;
}
try {
- group.setMetadataID(metadataFactory.createMetadataID(symbol.getMetadataID(), MetadataID.TYPE_GROUP));
+ group.setMetadataID(metadataFactory.createMetadataID(symbol.getMetadataID(), Type.TYPE_GROUP));
} catch(Exception e) {
LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, DQPPlugin.Util.getString("LanguageBridgeFactory.Unable_to_set_the_metadata_ID_for_group_{0}._11", symbol.getName())); //$NON-NLS-1$
throw new MetaMatrixComponentException(e);
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageFactoryImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageFactoryImpl.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageFactoryImpl.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -46,18 +46,6 @@
}
/*
- * @see com.metamatrix.data.language.ILanguageFactory#createCaseExpression(com.metamatrix.data.language.IExpression, java.util.List, java.util.List, com.metamatrix.data.language.IExpression, java.lang.Class)
- */
- public ICaseExpression createCaseExpression(
- IExpression mainExpression,
- List whenExpressions,
- List thenExpressions,
- IExpression elseExpression,
- Class type) {
- return new CaseExpressionImpl(mainExpression, whenExpressions, thenExpressions, elseExpression, type);
- }
-
- /*
* @see com.metamatrix.data.language.ILanguageFactory#createCompareCriteria(int, com.metamatrix.data.language.IExpression, com.metamatrix.data.language.IExpression)
*/
public ICompareCriteria createCompareCriteria(
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataFactory.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -30,6 +30,7 @@
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.*;
+import com.metamatrix.connector.metadata.runtime.MetadataID.Type;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.StoredProcedureInfo;
@@ -38,14 +39,16 @@
*/
public class MetadataFactory {
private QueryMetadataInterface metadata;
+ private RuntimeMetadataImpl runtimeMetadata;
public MetadataFactory (QueryMetadataInterface metadata){
ArgCheck.isNotNull(metadata);
this.metadata = metadata;
+ this.runtimeMetadata = new RuntimeMetadataImpl(this);
}
- public RuntimeMetadata createRuntimeMetadata(){
- return new RuntimeMetadataImpl(this);
+ public RuntimeMetadataImpl getRuntimeMetadata(){
+ return this.runtimeMetadata;
}
/**
@@ -56,11 +59,11 @@
* @throws QueryMetadataException
* @throws MetaMatrixComponentException
*/
- public MetadataID createMetadataID(Object metadataID, int type) throws QueryMetadataException, MetaMatrixComponentException{
- if (type == MetadataID.TYPE_GROUP && metadata.isVirtualGroup(metadataID)) {
+ public MetadataID createMetadataID(Object metadataID, Type type) throws QueryMetadataException, MetaMatrixComponentException{
+ if (type == Type.TYPE_GROUP && metadata.isVirtualGroup(metadataID)) {
return null;
}
- MetadataIDImpl id = new MetadataIDImpl(metadataID, metadata);
+ MetadataIDImpl id = new MetadataIDImpl(metadataID, getRuntimeMetadata());
id.setType(type);
return id;
}
@@ -75,8 +78,8 @@
public MetadataID createProcedureID(Object metadataID) throws QueryMetadataException, MetaMatrixComponentException{
String procName = metadata.getFullName(metadataID);
StoredProcedureInfo info = metadata.getStoredProcedureInfoForProcedure(procName);
- MetadataIDImpl id = new ProcedureIDImpl(metadataID, info, this, metadata);
- id.setType(MetadataID.TYPE_PROCEDURE);
+ MetadataIDImpl id = new ProcedureIDImpl(metadataID, info, this);
+ id.setType(Type.TYPE_PROCEDURE);
return id;
}
@@ -88,8 +91,8 @@
* @throws MetaMatrixComponentException
*/
public MetadataID createParameterID(ProcedureIDImpl procedureID, Object metadataID) throws QueryMetadataException, MetaMatrixComponentException{
- ParameterIDImpl id = new ParameterIDImpl(metadataID, procedureID, metadata);
- id.setType(MetadataID.TYPE_PARAMETER);
+ ParameterIDImpl id = new ParameterIDImpl(metadataID, procedureID, getRuntimeMetadata());
+ id.setType(Type.TYPE_PARAMETER);
return id;
}
@@ -101,25 +104,25 @@
* @throws MetaMatrixComponentException
*/
public MetadataID createResultSetID(ProcedureIDImpl procedureID, Object metadataID, List resultSetColumns) throws QueryMetadataException, MetaMatrixComponentException{
- ParameterIDImpl id = new ParameterIDImpl(metadataID, procedureID, metadata, resultSetColumns);
- id.setType(MetadataID.TYPE_PARAMETER);
+ ParameterIDImpl id = new ParameterIDImpl(metadataID, procedureID, getRuntimeMetadata(), resultSetColumns);
+ id.setType(Type.TYPE_PARAMETER);
return id;
}
public MetadataObject createMetadataObject(MetadataID id) throws QueryMetadataException, MetaMatrixComponentException, ConnectorException {
- int type = id.getType();
+ Type type = id.getType();
MetadataIDImpl idImpl = (MetadataIDImpl) id;
MetadataObject mObj = null;
- if(type == MetadataID.TYPE_GROUP){
+ if(type == Type.TYPE_GROUP){
mObj = new GroupImpl(idImpl);
- } else if(type == MetadataID.TYPE_ELEMENT){
+ } else if(type == Type.TYPE_ELEMENT){
mObj = new ElementImpl(idImpl);
- } else if(type == MetadataID.TYPE_PROCEDURE){
+ } else if(type == Type.TYPE_PROCEDURE){
mObj = new ProcedureImpl(idImpl);
- } else if(type == MetadataID.TYPE_PARAMETER) {
+ } else if(type == Type.TYPE_PARAMETER) {
mObj = new ParameterImpl(idImpl);
} else{
@@ -139,4 +142,8 @@
public String[] getVDBResourcePaths() throws MetaMatrixComponentException, QueryMetadataException {
return metadata.getVDBResourcePaths();
}
+
+ public QueryMetadataInterface getMetadata() {
+ return metadata;
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataIDImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataIDImpl.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataIDImpl.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -24,50 +24,55 @@
*/
package com.metamatrix.dqp.internal.datamgr.metadata;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.MetadataID;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.connector.metadata.runtime.MetadataObject;
/**
*/
public class MetadataIDImpl implements MetadataID {
- private int type;
+ private Type type;
private Object actualMetadataID;
private String fullName;
- private QueryMetadataInterface metadata;
+ private RuntimeMetadataImpl metadata;
- MetadataIDImpl(Object actualMetadataID, QueryMetadataInterface metadata) throws MetaMatrixComponentException {
+ MetadataIDImpl(Object actualMetadataID, RuntimeMetadataImpl metadata) throws MetaMatrixComponentException {
this.actualMetadataID = actualMetadataID;
this.metadata = metadata;
- try {
- fullName = metadata.getFullName(getActualMetadataID());
- } catch (QueryMetadataException ex) {
- throw new MetaMatrixComponentException(ex, ex.getMessage());
+ if (actualMetadataID != null) {
+ try {
+ fullName = metadata.getMetadata().getFullName(actualMetadataID);
+ } catch (QueryMetadataException ex) {
+ throw new MetaMatrixComponentException(ex, ex.getMessage());
+ }
}
}
- QueryMetadataInterface getMetadata() {
+ RuntimeMetadataImpl getMetadata() {
return this.metadata;
}
- public int getType() {
+ public Type getType() {
return type;
}
public List getChildIDs() throws ConnectorException {
- if(type == MetadataID.TYPE_GROUP){
+ if(type == Type.TYPE_GROUP && actualMetadataID != null){
try {
- List children = metadata.getElementIDsInGroupID(actualMetadataID);
+ List children = metadata.getMetadata().getElementIDsInGroupID(actualMetadataID);
List childIDs = new ArrayList(children.size());
Iterator iter = children.iterator();
while(iter.hasNext()){
MetadataIDImpl id = new MetadataIDImpl(iter.next(), metadata);
- id.setType(MetadataID.TYPE_ELEMENT);
+ id.setType(Type.TYPE_ELEMENT);
childIDs.add(id);
}
return childIDs;
@@ -81,10 +86,10 @@
}
public MetadataID getParentID() throws ConnectorException {
- if(type == MetadataID.TYPE_ELEMENT) {
+ if(type == Type.TYPE_ELEMENT && actualMetadataID != null) {
try {
- MetadataIDImpl id = new MetadataIDImpl(metadata.getGroupIDForElementID(actualMetadataID), metadata);
- id.setType(MetadataID.TYPE_GROUP);
+ MetadataIDImpl id = new MetadataIDImpl(metadata.getMetadata().getGroupIDForElementID(actualMetadataID), metadata);
+ id.setType(Type.TYPE_GROUP);
return id;
} catch(QueryMetadataException e) {
throw new ConnectorException(e);
@@ -113,7 +118,7 @@
return actualMetadataID.hashCode();
}
- void setType(int type){
+ void setType(Type type){
this.type = type;
}
@@ -142,4 +147,9 @@
}
return shortName;
}
+
+ @Override
+ public MetadataObject getMetadataObject() throws ConnectorException {
+ return this.metadata.getObject(this);
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataObjectImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataObjectImpl.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataObjectImpl.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -51,7 +51,7 @@
}
QueryMetadataInterface getMetadata() {
- return metadataID.getMetadata();
+ return metadataID.getMetadata().getMetadata();
}
public String getNameInSource() throws ConnectorException {
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterIDImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterIDImpl.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterIDImpl.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,12 +22,14 @@
package com.metamatrix.dqp.internal.datamgr.metadata;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.MetadataID;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
/**
*/
@@ -36,14 +38,14 @@
private ProcedureIDImpl procID;
private List resultSetColumns;
- public ParameterIDImpl(Object actualMetadataID, ProcedureIDImpl procedureID, QueryMetadataInterface metadata)
+ public ParameterIDImpl(Object actualMetadataID, ProcedureIDImpl procedureID, RuntimeMetadataImpl metadata)
throws MetaMatrixComponentException {
super(actualMetadataID, metadata);
this.procID = procedureID;
}
- public ParameterIDImpl(Object actualMetadataID, ProcedureIDImpl procedureID, QueryMetadataInterface metadata, List resultSetColumns)
+ public ParameterIDImpl(Object actualMetadataID, ProcedureIDImpl procedureID, RuntimeMetadataImpl metadata, List resultSetColumns)
throws MetaMatrixComponentException {
super(actualMetadataID, metadata);
@@ -67,7 +69,7 @@
while(iter.hasNext()){
Object colID = iter.next();
MetadataIDImpl id = new MetadataIDImpl(colID, getMetadata());
- id.setType(MetadataID.TYPE_ELEMENT);
+ id.setType(Type.TYPE_ELEMENT);
childIDs.add(id);
}
return childIDs;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureIDImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureIDImpl.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureIDImpl.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,13 +22,14 @@
package com.metamatrix.dqp.internal.datamgr.metadata;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.dqp.message.ParameterInfo;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.StoredProcedureInfo;
import com.metamatrix.query.sql.lang.SPParameter;
@@ -44,10 +45,10 @@
* @param metadata
* @throws MetaMatrixComponentException
*/
- public ProcedureIDImpl(Object actualMetadataID, StoredProcedureInfo procInfo, MetadataFactory factory, QueryMetadataInterface metadata)
+ public ProcedureIDImpl(Object actualMetadataID, StoredProcedureInfo procInfo, MetadataFactory factory)
throws MetaMatrixComponentException {
- super(actualMetadataID, metadata);
+ super(actualMetadataID, factory.getRuntimeMetadata());
this.procInfo = procInfo;
this.factory = factory;
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -28,6 +28,7 @@
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.*;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
/**
*/
@@ -78,4 +79,9 @@
throw new ConnectorException(e);
}
}
+
+ QueryMetadataInterface getMetadata() {
+ return this.factory.getMetadata();
+ }
+
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -83,6 +83,8 @@
public static final String NULLIF = "nullif"; //$NON-NLS-1$
public static final String COALESCE = "coalesce"; //$NON-NLS-1$
+ public static final String SPACE = "space"; //$NON-NLS-1$
+
// Function tree for system functions (never reloaded)
private FunctionTree systemFunctions;
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -33,13 +33,11 @@
import java.util.Calendar;
import java.util.Date;
import java.util.Properties;
-import java.util.StringTokenizer;
import java.util.TimeZone;
import com.metamatrix.api.exception.query.ExpressionEvaluationException;
import com.metamatrix.api.exception.query.FunctionExecutionException;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.Transform;
import com.metamatrix.common.types.TransformationException;
import com.metamatrix.common.util.TimestampWithTimezone;
import com.metamatrix.query.QueryPlugin;
@@ -49,8 +47,6 @@
public final class FunctionMethods {
- private static final String DEFAULT_DECODE_STRING_DELIMITER = ","; //$NON-NLS-1$
-
// ================== Function = plus =====================
public static Object plus(Object x, Object y) throws FunctionExecutionException {
@@ -1206,10 +1202,12 @@
int repeatCount = ((Integer) count).intValue();
StringBuffer result = new StringBuffer();
- for (int i = 0; i < repeatCount; i++) {
+ for (int i = 0; i < repeatCount && result.length() <= DataTypeManager.MAX_STRING_LENGTH; i++) {
result.append((String)str);
}
-
+ if (result.length() > DataTypeManager.MAX_STRING_LENGTH) {
+ return result.substring(0, DataTypeManager.MAX_STRING_LENGTH);
+ }
return result.toString();
}
@@ -1217,26 +1215,6 @@
new Object[] {"repeat", str.getClass().getName(), count.getClass().getName()})); //$NON-NLS-1$
}
- // ================== Function = space =====================
- public static Object space(Object count)
- throws FunctionExecutionException {
- if (count == null) {
- return null;
- } else if (count instanceof Integer) {
- int repeatCount = ((Integer) count).intValue();
- StringBuffer result = new StringBuffer();
-
- for (int i = 0; i < repeatCount; i++) {
- result.append(" "); //$NON-NLS-1$
- }
-
- return result.toString();
- }
-
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0066, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0066,
- new Object[] {"space", count.getClass().getName()})); //$NON-NLS-1$
- }
-
// ================== Function = ascii =====================
public static Object ascii(Object ch)
@@ -1309,46 +1287,53 @@
// ================== Function = lpad =====================
- public static Object lpad(Object inputString, Object padLength, Object padChar)
+ public static Object lpad(Object inputString, Object padLength, Object padStr)
throws FunctionExecutionException {
- if(inputString == null || padLength == null || padChar == null) {
- return null;
- }
+ return pad(inputString, padLength, padStr, true);
+ }
- String str = (String) inputString;
- int length = ((Integer)padLength).intValue();
- if(length < 1) {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0025, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0025));
- }
+ public static Object pad(Object inputString, Object padLength, Object padStr, boolean left)
+ throws FunctionExecutionException {
- int numPadChar = length - str.length();
- if(numPadChar <= 0) {
- return str;
- }
- // Get pad character
- char ch = 0;
- if(padChar instanceof String) {
- String charStr = (String) padChar;
- if(charStr.length() != 1) {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0027, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0027));
- }
- ch = charStr.charAt(0);
- } else {
- ch = ((Character)padChar).charValue();
- }
+ if(inputString == null || padLength == null || padStr == null) {
+ return null;
+ }
+
+ String str = (String) inputString;
+ int length = ((Integer)padLength).intValue();
+ if(length < 1) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0025, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0025));
+ }
+ if(length < str.length()) {
+ return str.substring(0, length);
+ }
+ if(length > DataTypeManager.MAX_STRING_LENGTH) {
+ length = DataTypeManager.MAX_STRING_LENGTH;
+ }
+ // Get pad character
+ String pad = (String) padStr;
+ if(pad.length() == 0) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0027, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0027));
+ }
+ // Pad string
+ StringBuffer outStr = new StringBuffer(str);
+ while(outStr.length() < length) {
+ if (left) {
+ outStr.insert(0, pad);
+ } else {
+ outStr.append(pad);
+ }
+ }
+ if (left) {
+ return outStr.substring(outStr.length() - length);
+ }
+ return outStr.substring(0, length);
+ }
- // Pad string
- StringBuffer outStr = new StringBuffer();
- for(int i=0; i<numPadChar; i++) {
- outStr.append(ch);
- }
- outStr.append(str);
- return outStr.toString();
- }
+
+ public static final String SPACE_CHAR = " "; //$NON-NLS-1$
- public static final Character SPACE_CHAR = new Character(' ');
-
public static Object lpad(Object inputString, Object padLength)
throws FunctionExecutionException {
@@ -1357,42 +1342,10 @@
// ================== Function = rpad =====================
- public static Object rpad(Object inputString, Object padLength, Object padChar)
+ public static Object rpad(Object inputString, Object padLength, Object padStr)
throws FunctionExecutionException {
- if(inputString == null || padLength == null || padChar == null) {
- return null;
- }
-
- String str = (String) inputString;
- int length = ((Integer)padLength).intValue();
- if(length < 1) {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0025, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0025));
- }
-
- int numPadChar = length - str.length();
- if(numPadChar <= 0) {
- return str;
- }
- // Get pad character
- char ch = 0;
- if(padChar instanceof String) {
- String charStr = (String) padChar;
- if(charStr.length() != 1) {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0029, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0029));
- }
- ch = charStr.charAt(0);
- } else {
- ch = ((Character)padChar).charValue();
- }
-
- // Pad string
- StringBuffer outStr = new StringBuffer();
- outStr.append(str);
- for(int i=0; i<numPadChar; i++) {
- outStr.append(ch);
- }
- return outStr.toString();
+ return pad(inputString, padLength, padStr, false);
}
public static Object rpad(Object inputString, Object padLength)
@@ -1520,246 +1473,9 @@
throw new UnsupportedOperationException("This method should never be called."); //$NON-NLS-1$
}
- // ================== Function = decodeInteger =====================
-
- public static Object decodeInteger(
- Object columnValue,
- Object decodeObject)
- throws FunctionExecutionException {
- return decode(
- columnValue,
- decodeObject,
- DEFAULT_DECODE_STRING_DELIMITER,
- Integer.class);
- }
-
- public static Object decodeString(
- Object columnValue,
- Object decodeObject)
- throws FunctionExecutionException {
- return decode(
- columnValue,
- decodeObject,
- DEFAULT_DECODE_STRING_DELIMITER,
- String.class);
- }
-
- public static Object decodeInteger(
- Object columnValue,
- Object decodeObject,
- Object decodeDelimiter)
- throws FunctionExecutionException {
- return decode(
- columnValue,
- decodeObject,
- decodeDelimiter,
- Integer.class);
- }
-
- public static Object decodeString(
- Object columnValue,
- Object decodeObject,
- Object decodeDelimiter)
- throws FunctionExecutionException {
-
- return decode(columnValue, decodeObject, decodeDelimiter, String.class);
-
- }
-
- private static Object decode(
- Object columnValue,
- Object decodeObject,
- Object decodeDelimiter,
- Class returnType)
- throws FunctionExecutionException {
-
- Object returnObject = null;
-
- if (decodeObject == null) {
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0036, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0036));
- }
-
- if(decodeDelimiter==null){
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0037, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0037));
- }
-
- if (decodeObject instanceof String
- && decodeDelimiter instanceof String) {
-
- String decodeDelimiterString = (String) decodeDelimiter;
- String decodeString = (String) decodeObject;
- StringTokenizer tokenizer =
- new StringTokenizer(decodeString, decodeDelimiterString);
-
- while (tokenizer.hasMoreTokens()) {
- String resultString;
- String compareString =
- convertString(tokenizer.nextToken().trim());
- if (tokenizer.hasMoreTokens()) {
- resultString = convertString(tokenizer.nextToken().trim());
- } else {
- /*
- * if there are no more tokens in the decode string, the last token in
- * the String is considered to be the 'default' value for the
- * return from this function. If we reach this point in this loop, then
- * we just return this string as the return value from this function as
- * there are no more decode compare strings to be processed.
- */
- try {
- returnObject =
- convertType(returnType, compareString);
- } catch (TransformationException e) {
- throw new FunctionExecutionException(e, ErrorMessageKeys.FUNCTION_0038, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0038, compareString, returnType!=null?returnType.getName():"null")); //$NON-NLS-1$
- }
-
- // we break out of the while if we find an endpoint.
- break;
-
- }
-
- boolean match;
-
- match = areSemanticallyEqual(columnValue, compareString);
-
- if (match) {
- try {
- returnObject = convertType(returnType, resultString);
- } catch (TransformationException e) {
- throw new FunctionExecutionException(e, ErrorMessageKeys.FUNCTION_0038, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0038, resultString, returnType!=null?returnType.getName():"null")); //$NON-NLS-1$
- }
- break;
- }else if (!tokenizer.hasMoreTokens()) {
- /*
- * if we get to this point and there are no more tokens in the
- * decode string, this means that we have run out of strings to
- * compare against the column value. In this case we simply return
- * the column value itself. We are safe doing that here because
- * this loop will be exited and the specified default value will have
- * already been returned if there is one.
- */
- try {
- returnObject = convertType(returnType, columnValue);
- } catch (TransformationException e) {
- throw new FunctionExecutionException(e, ErrorMessageKeys.FUNCTION_0039, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0039, columnValue ));
- }
- }
-
- }
-
- return returnObject;
-
- }
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0040, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0040));
- }
-
- private static boolean areSemanticallyEqual(Object object1, String string){
- if(object1==null) {
- if(string==null) {
- return true;
- }
- return false;
- }
- if(string == null) {
- return false;
- } else if(object1.equals(string)) {
- return true;
- }
-
- Class targetClass = object1.getClass();
-
- if(DataTypeManager.isTransformable(String.class, targetClass)){
- Transform transform =
- DataTypeManager.getPreferredTransform(String.class, targetClass);
- Object result = null;
- try {
- if (transform.getSourceType().equals(String.class)) {
- result = transform.transform(string);
- } else {
- result = transform.transform(object1);
- }
- } catch (TransformationException e) {
- /* if the attempt to convert the types to be compatible so that
- * they can be propertly compared fails, then we consider these
- * two objects to be not semantically equal.
- */
- return false;
- }
- return result.equals(object1);
- }
- return false;
- }
-
- private static Object convertType(Class targetType, Object objectToConvert)
- throws TransformationException, FunctionExecutionException {
-
- if(objectToConvert==null){
- return null;
- }
-
- if(targetType==objectToConvert.getClass()){
- return objectToConvert;
- }
-
- Transform transform = null;
- if(DataTypeManager.isTransformable(targetType, objectToConvert.getClass())){
- transform =
- DataTypeManager.getTransform(
- objectToConvert.getClass(),
- targetType);
- }else{
- throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0041, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0041, new Object[]{objectToConvert, objectToConvert.getClass().getName(), targetType.getName()}));
- }
- return transform.transform(objectToConvert);
- }
-
- public static String convertString(String string) {
- /*
- * if there are no characters in the compare string we designate that as
- * an indication of null. ie if the decode string looks like this:
- *
- * "'this', 1,,'null'"
- *
- * Then if the value in the first argument is null then the String 'null' is
- * returned from the function.
- */
- if (string.equals("")) { //$NON-NLS-1$
- return null;
- }
-
- /*
- * we also allow the use of the keyword null in the decode string. if it
- * wished to match on the string 'null' then the string must be qualified by
- * ' designators.
- */
- if(string.equalsIgnoreCase("null")){ //$NON-NLS-1$
- return null;
- }
-
- /*
- * Here we check to see if the String in the decode String submitted
- * was surrounded by String literal characters. In this case we strip
- * these literal characters from the String.
- */
- if ((string.startsWith("\"") && string.endsWith("\"")) //$NON-NLS-1$ //$NON-NLS-2$
- || (string.startsWith("'") && string.endsWith("'"))) { //$NON-NLS-1$ //$NON-NLS-2$
- if (string.length() == 2) {
- /*
- * This is an indication that the desired string to be compared is
- * the "" empty string, so we return it as such.
- */
- string = ""; //$NON-NLS-1$
- } else if (!string.equalsIgnoreCase("'") && !string.equalsIgnoreCase("\"")){ //$NON-NLS-1$ //$NON-NLS-2$
- string = string.substring(1);
- string = string.substring(0, string.length()-1);
- }
- }
-
- return string;
- }
-
// ================== Function = nvl =====================
- public static Object nvl(Object value, Object valueIfNull) {
+ public static Object ifnull(Object value, Object valueIfNull) {
if(value == null) {
return valueIfNull;
Modified: trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -29,6 +29,7 @@
import java.util.List;
import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.connector.api.SourceSystemFunctions;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.function.FunctionMetadataSource;
@@ -56,10 +57,10 @@
*/
public SystemSource() {
// +, -, *, /
- addArithmeticFunction("+", QueryPlugin.Util.getString("SystemSource.Add_desc"), "plus", QueryPlugin.Util.getString("SystemSource.Add_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addArithmeticFunction("-", QueryPlugin.Util.getString("SystemSource.Subtract_desc"), "minus", QueryPlugin.Util.getString("SystemSource.Subtract_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addArithmeticFunction("*", QueryPlugin.Util.getString("SystemSource.Multiply_desc"), "multiply", QueryPlugin.Util.getString("SystemSource.Multiply_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addArithmeticFunction("/", QueryPlugin.Util.getString("SystemSource.Divide_desc"), "divide", QueryPlugin.Util.getString("SystemSource.Divide_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addArithmeticFunction(SourceSystemFunctions.ADD_OP, QueryPlugin.Util.getString("SystemSource.Add_desc"), "plus", QueryPlugin.Util.getString("SystemSource.Add_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addArithmeticFunction(SourceSystemFunctions.SUBTRACT_OP, QueryPlugin.Util.getString("SystemSource.Subtract_desc"), "minus", QueryPlugin.Util.getString("SystemSource.Subtract_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addArithmeticFunction(SourceSystemFunctions.MULTIPLY_OP, QueryPlugin.Util.getString("SystemSource.Multiply_desc"), "multiply", QueryPlugin.Util.getString("SystemSource.Multiply_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addArithmeticFunction(SourceSystemFunctions.DIVIDE_OP, QueryPlugin.Util.getString("SystemSource.Divide_desc"), "divide", QueryPlugin.Util.getString("SystemSource.Divide_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
// numeric
addAbsFunction();
@@ -69,45 +70,45 @@
addRoundFunction();
addSignFunction();
addSqrtFunction();
- addDoubleFunction("acos", QueryPlugin.Util.getString("SystemSource.Acos_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("asin", QueryPlugin.Util.getString("SystemSource.Asin_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("atan", QueryPlugin.Util.getString("SystemSource.Atan_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addAtan2Function("atan2", QueryPlugin.Util.getString("SystemSource.Atan2_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("cos", QueryPlugin.Util.getString("SystemSource.Cos_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("cot", QueryPlugin.Util.getString("SystemSource.Cot_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("degrees", QueryPlugin.Util.getString("SystemSource.Degrees_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addPiFunction("pi", QueryPlugin.Util.getString("SystemSource.Pi_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("radians", QueryPlugin.Util.getString("SystemSource.Radians_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("sin", QueryPlugin.Util.getString("SystemSource.Sin_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("tan", QueryPlugin.Util.getString("SystemSource.Tan_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("log", QueryPlugin.Util.getString("SystemSource.Log_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("log10", QueryPlugin.Util.getString("SystemSource.Log10_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("ceiling", QueryPlugin.Util.getString("SystemSource.Ceiling_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("exp", QueryPlugin.Util.getString("SystemSource.Exp_desc")); //$NON-NLS-1$ //$NON-NLS-2$
- addDoubleFunction("floor", QueryPlugin.Util.getString("SystemSource.Floor_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.ACOS, QueryPlugin.Util.getString("SystemSource.Acos_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.ASIN, QueryPlugin.Util.getString("SystemSource.Asin_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.ATAN, QueryPlugin.Util.getString("SystemSource.Atan_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addAtan2Function(SourceSystemFunctions.ATAN2, QueryPlugin.Util.getString("SystemSource.Atan2_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.COS, QueryPlugin.Util.getString("SystemSource.Cos_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.COT, QueryPlugin.Util.getString("SystemSource.Cot_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.DEGREES, QueryPlugin.Util.getString("SystemSource.Degrees_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addPiFunction(SourceSystemFunctions.PI, QueryPlugin.Util.getString("SystemSource.Pi_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.RADIANS, QueryPlugin.Util.getString("SystemSource.Radians_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.SIN, QueryPlugin.Util.getString("SystemSource.Sin_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.TAN, QueryPlugin.Util.getString("SystemSource.Tan_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.LOG, QueryPlugin.Util.getString("SystemSource.Log_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.LOG10, QueryPlugin.Util.getString("SystemSource.Log10_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.CEILING, QueryPlugin.Util.getString("SystemSource.Ceiling_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.EXP, QueryPlugin.Util.getString("SystemSource.Exp_desc")); //$NON-NLS-1$ //$NON-NLS-2$
+ addDoubleFunction(SourceSystemFunctions.FLOOR, QueryPlugin.Util.getString("SystemSource.Floor_desc")); //$NON-NLS-1$ //$NON-NLS-2$
// bit
- addBitFunction("bitand", QueryPlugin.Util.getString("SystemSource.Bitand_desc"), "bitand", 2, QueryPlugin.Util.getString("SystemSource.Bitand_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addBitFunction("bitor", QueryPlugin.Util.getString("SystemSource.Bitor_desc"), "bitor", 2, QueryPlugin.Util.getString("SystemSource.Bitor_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addBitFunction("bitxor", QueryPlugin.Util.getString("SystemSource.Bitxor_desc"), "bitxor", 2, QueryPlugin.Util.getString("SystemSource.Bitxor_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addBitFunction("bitnot", QueryPlugin.Util.getString("SystemSource.Bitnot_desc"), "bitnot", 1, QueryPlugin.Util.getString("SystemSource.Bitnot_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addBitFunction(SourceSystemFunctions.BITAND, QueryPlugin.Util.getString("SystemSource.Bitand_desc"), "bitand", 2, QueryPlugin.Util.getString("SystemSource.Bitand_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addBitFunction(SourceSystemFunctions.BITOR, QueryPlugin.Util.getString("SystemSource.Bitor_desc"), "bitor", 2, QueryPlugin.Util.getString("SystemSource.Bitor_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addBitFunction(SourceSystemFunctions.BITXOR, QueryPlugin.Util.getString("SystemSource.Bitxor_desc"), "bitxor", 2, QueryPlugin.Util.getString("SystemSource.Bitxor_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addBitFunction(SourceSystemFunctions.BITNOT, QueryPlugin.Util.getString("SystemSource.Bitnot_desc"), "bitnot", 1, QueryPlugin.Util.getString("SystemSource.Bitnot_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
// date
- addConstantDateFunction("curdate", QueryPlugin.Util.getString("SystemSource.Curdate_desc"), "currentDate", DataTypeManager.DefaultDataTypes.DATE); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- addConstantDateFunction("curtime", QueryPlugin.Util.getString("SystemSource.Curtime_desc"), "currentTime", DataTypeManager.DefaultDataTypes.TIME); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- addConstantDateFunction("now", QueryPlugin.Util.getString("SystemSource.Now_desc"), "currentTimestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- addDateFunction("dayname", "dayName", QueryPlugin.Util.getString("SystemSource.Dayname_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayname_result_ts_desc"), DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addDateFunction("dayofmonth", "dayOfMonth", QueryPlugin.Util.getString("SystemSource.Dayofmonth_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofmonth_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addDateFunction("dayofweek", "dayOfWeek", QueryPlugin.Util.getString("SystemSource.Dayofweek_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofweek_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addDateFunction("dayofyear", "dayOfYear", QueryPlugin.Util.getString("SystemSource.Dayofyear_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofyear_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addDateFunction("month", "month", QueryPlugin.Util.getString("SystemSource.Month_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Month_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addDateFunction("monthname", "monthName", QueryPlugin.Util.getString("SystemSource.Monthname_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Monthname_result_ts_desc"), DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addDateFunction("week", "week", QueryPlugin.Util.getString("SystemSource.Week_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Week_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addDateFunction("year", "year", QueryPlugin.Util.getString("SystemSource.Year_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Year_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addTimeFunction("hour", "hour", QueryPlugin.Util.getString("SystemSource.Hour_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Hour_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addTimeFunction("minute", "minute", QueryPlugin.Util.getString("SystemSource.Minute_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Minute_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addTimeFunction("second", "second", QueryPlugin.Util.getString("SystemSource.Second_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Second_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addQuarterFunction("quarter", "quarter", QueryPlugin.Util.getString("SystemSource.Quarter_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Quarter_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addConstantDateFunction(SourceSystemFunctions.CURDATE, QueryPlugin.Util.getString("SystemSource.Curdate_desc"), "currentDate", DataTypeManager.DefaultDataTypes.DATE); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addConstantDateFunction(SourceSystemFunctions.CURTIME, QueryPlugin.Util.getString("SystemSource.Curtime_desc"), "currentTime", DataTypeManager.DefaultDataTypes.TIME); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addConstantDateFunction(SourceSystemFunctions.NOW, QueryPlugin.Util.getString("SystemSource.Now_desc"), "currentTimestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addDateFunction(SourceSystemFunctions.DAYNAME, "dayName", QueryPlugin.Util.getString("SystemSource.Dayname_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayname_result_ts_desc"), DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addDateFunction(SourceSystemFunctions.DAYOFMONTH, "dayOfMonth", QueryPlugin.Util.getString("SystemSource.Dayofmonth_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofmonth_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addDateFunction(SourceSystemFunctions.DAYOFWEEK, "dayOfWeek", QueryPlugin.Util.getString("SystemSource.Dayofweek_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofweek_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addDateFunction(SourceSystemFunctions.DAYOFYEAR, "dayOfYear", QueryPlugin.Util.getString("SystemSource.Dayofyear_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Dayofyear_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addDateFunction(SourceSystemFunctions.MONTH, "month", QueryPlugin.Util.getString("SystemSource.Month_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Month_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addDateFunction(SourceSystemFunctions.MONTHNAME, "monthName", QueryPlugin.Util.getString("SystemSource.Monthname_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Monthname_result_ts_desc"), DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addDateFunction(SourceSystemFunctions.WEEK, "week", QueryPlugin.Util.getString("SystemSource.Week_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Week_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addDateFunction(SourceSystemFunctions.YEAR, "year", QueryPlugin.Util.getString("SystemSource.Year_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Year_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addTimeFunction(SourceSystemFunctions.HOUR, "hour", QueryPlugin.Util.getString("SystemSource.Hour_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Hour_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addTimeFunction(SourceSystemFunctions.MINUTE, "minute", QueryPlugin.Util.getString("SystemSource.Minute_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Minute_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addTimeFunction(SourceSystemFunctions.SECOND, "second", QueryPlugin.Util.getString("SystemSource.Second_result_t_desc"), QueryPlugin.Util.getString("SystemSource.Second_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addQuarterFunction(SourceSystemFunctions.QUARTER, "quarter", QueryPlugin.Util.getString("SystemSource.Quarter_result_d_desc"), QueryPlugin.Util.getString("SystemSource.Quarter_result_ts_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
addTimestampAddFunction();
addTimestampDiffFunction();
addTimeZoneFunctions();
@@ -115,20 +116,19 @@
addUnixTimeFunctions();
// string
- addStringFunction("length", QueryPlugin.Util.getString("SystemSource.Length_result"), "length", DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- addStringFunction("ucase", QueryPlugin.Util.getString("SystemSource.Ucase_result"), "upperCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- addStringFunction("lcase", QueryPlugin.Util.getString("SystemSource.Lcase_result"), "lowerCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addStringFunction(SourceSystemFunctions.LENGTH, QueryPlugin.Util.getString("SystemSource.Length_result"), "length", DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addStringFunction(SourceSystemFunctions.UCASE, QueryPlugin.Util.getString("SystemSource.Ucase_result"), "upperCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addStringFunction(SourceSystemFunctions.LCASE, QueryPlugin.Util.getString("SystemSource.Lcase_result"), "lowerCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
addStringFunction("lower", QueryPlugin.Util.getString("SystemSource.Lower_result"), "lowerCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
addStringFunction("upper", QueryPlugin.Util.getString("SystemSource.Upper_result"), "upperCase", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- addStringFunction("ltrim", QueryPlugin.Util.getString("SystemSource.Left_result"), "leftTrim", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- addStringFunction("rtrim", QueryPlugin.Util.getString("SystemSource.Right_result"), "rightTrim", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addStringFunction(SourceSystemFunctions.LTRIM, QueryPlugin.Util.getString("SystemSource.Left_result"), "leftTrim", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addStringFunction(SourceSystemFunctions.RTRIM, QueryPlugin.Util.getString("SystemSource.Right_result"), "rightTrim", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
addConcatFunction();
addSubstringFunction();
addLeftRightFunctions();
addLocateFunction();
addReplaceFunction();
addAsciiFunction();
- addChrFunction();
addCharFunction();
addInitCapFunction();
addLpadFunction();
@@ -139,8 +139,8 @@
addInsertFunction();
// clob
- addClobFunction("ucase", QueryPlugin.Util.getString("SystemSource.UcaseClob_result"), "upperCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- addClobFunction("lcase", QueryPlugin.Util.getString("SystemSource.LcaseClob_result"), "lowerCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addClobFunction(SourceSystemFunctions.UCASE, QueryPlugin.Util.getString("SystemSource.UcaseClob_result"), "upperCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addClobFunction(SourceSystemFunctions.LCASE, QueryPlugin.Util.getString("SystemSource.LcaseClob_result"), "lowerCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
addClobFunction("lower", QueryPlugin.Util.getString("SystemSource.LowerClob_result"), "lowerCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
addClobFunction("upper", QueryPlugin.Util.getString("SystemSource.UpperClob_result"), "upperCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -156,20 +156,19 @@
addUserFunction();
addEnvFunction();
addCommandPayloadFunctions();
- addNvlFunctions();
addIfNullFunctions();
// format
- addFormatTimeFunction("formatTime", QueryPlugin.Util.getString("SystemSource.Formattime_desc"), "formatTime", QueryPlugin.Util.getString("SystemSource.Formattime_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addFormatDateFunction("formatDate", QueryPlugin.Util.getString("SystemSource.Formatdate_desc"), "formatDate", QueryPlugin.Util.getString("SystemSource.Formatdate_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addFormatTimestampFunction("formatTimestamp", QueryPlugin.Util.getString("SystemSource.Formattimestamp_desc"), "formatTimestamp", QueryPlugin.Util.getString("SystemSource.Formattimestamp_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addFormatTimeFunction(SourceSystemFunctions.FORMATTIME, QueryPlugin.Util.getString("SystemSource.Formattime_desc"), "formatTime", QueryPlugin.Util.getString("SystemSource.Formattime_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addFormatDateFunction(SourceSystemFunctions.FORMATDATE, QueryPlugin.Util.getString("SystemSource.Formatdate_desc"), "formatDate", QueryPlugin.Util.getString("SystemSource.Formatdate_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addFormatTimestampFunction(SourceSystemFunctions.FORMATTIMESTAMP, QueryPlugin.Util.getString("SystemSource.Formattimestamp_desc"), "formatTimestamp", QueryPlugin.Util.getString("SystemSource.Formattimestamp_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
addFormatNumberFunctions();
// parse
- addParseTimeFunction("parseTime", QueryPlugin.Util.getString("SystemSource.Parsetime_desc"), "parseTime", QueryPlugin.Util.getString("SystemSource.Parsetime_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addParseDateFunction("parseDate", QueryPlugin.Util.getString("SystemSource.Parsedate_desc"), "parseDate", QueryPlugin.Util.getString("SystemSource.Parsedate_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addParseTimestampFunction("parseTimestamp", QueryPlugin.Util.getString("SystemSource.Parsetimestamp_desc"), "parseTimestamp", QueryPlugin.Util.getString("SystemSource.Parsetimestamp_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addParseTimeFunction(SourceSystemFunctions.PARSETIME, QueryPlugin.Util.getString("SystemSource.Parsetime_desc"), "parseTime", QueryPlugin.Util.getString("SystemSource.Parsetime_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addParseDateFunction(SourceSystemFunctions.PARSEDATE, QueryPlugin.Util.getString("SystemSource.Parsedate_desc"), "parseDate", QueryPlugin.Util.getString("SystemSource.Parsedate_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addParseTimestampFunction(SourceSystemFunctions.PARSETIMESTAMP, QueryPlugin.Util.getString("SystemSource.Parsetimestamp_desc"), "parseTimestamp", QueryPlugin.Util.getString("SystemSource.Parsetimestamp_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
addParseNumberFunctions();
@@ -195,21 +194,21 @@
}
private void addFormatNumberFunctions() {
- addFormatNumberFunction("formatInteger", QueryPlugin.Util.getString("SystemSource.Formatinteger_desc"), "formatInteger", "integer", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Formatinteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- addFormatNumberFunction("formatLong", QueryPlugin.Util.getString("SystemSource.Formatlong_desc"), "formatLong", "long", DataTypeManager.DefaultDataTypes.LONG, QueryPlugin.Util.getString("SystemSource.Formatlong_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- addFormatNumberFunction("formatDouble", QueryPlugin.Util.getString("SystemSource.Formatdouble_desc"), "formatDouble", "double", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Formatdouble_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- addFormatNumberFunction("formatFloat", QueryPlugin.Util.getString("SystemSource.Formatfloat_desc"), "formatFloat", "float", DataTypeManager.DefaultDataTypes.FLOAT, QueryPlugin.Util.getString("SystemSource.Formatfloat_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- addFormatNumberFunction("formatBigInteger", QueryPlugin.Util.getString("SystemSource.Formatbiginteger_desc"), "formatBigInteger", "biginteger", DataTypeManager.DefaultDataTypes.BIG_INTEGER, QueryPlugin.Util.getString("SystemSource.Formatbiginteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- addFormatNumberFunction("formatBigDecimal", QueryPlugin.Util.getString("SystemSource.Formatbigdecimal_desc"), "formatBigDecimal", "bigdecimal", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Formatbigdecimal_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addFormatNumberFunction(SourceSystemFunctions.FORMATINTEGER, QueryPlugin.Util.getString("SystemSource.Formatinteger_desc"), "formatInteger", "integer", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Formatinteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addFormatNumberFunction(SourceSystemFunctions.FORMATLONG, QueryPlugin.Util.getString("SystemSource.Formatlong_desc"), "formatLong", "long", DataTypeManager.DefaultDataTypes.LONG, QueryPlugin.Util.getString("SystemSource.Formatlong_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addFormatNumberFunction(SourceSystemFunctions.FORMATDOUBLE, QueryPlugin.Util.getString("SystemSource.Formatdouble_desc"), "formatDouble", "double", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Formatdouble_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addFormatNumberFunction(SourceSystemFunctions.FORMATFLOAT, QueryPlugin.Util.getString("SystemSource.Formatfloat_desc"), "formatFloat", "float", DataTypeManager.DefaultDataTypes.FLOAT, QueryPlugin.Util.getString("SystemSource.Formatfloat_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addFormatNumberFunction(SourceSystemFunctions.FORMATBIGINTEGER, QueryPlugin.Util.getString("SystemSource.Formatbiginteger_desc"), "formatBigInteger", "biginteger", DataTypeManager.DefaultDataTypes.BIG_INTEGER, QueryPlugin.Util.getString("SystemSource.Formatbiginteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addFormatNumberFunction(SourceSystemFunctions.FORMATBIGDECIMAL, QueryPlugin.Util.getString("SystemSource.Formatbigdecimal_desc"), "formatBigDecimal", "bigdecimal", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Formatbigdecimal_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
private void addParseNumberFunctions() {
- addParseNumberFunction("parseInteger", QueryPlugin.Util.getString("SystemSource.Parseinteger_desc"), "parseInteger", "integer", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Parseinteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- addParseNumberFunction("parseLong", QueryPlugin.Util.getString("SystemSource.Parselong_desc"), "parseLong", "long", DataTypeManager.DefaultDataTypes.LONG, QueryPlugin.Util.getString("SystemSource.Parselong_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- addParseNumberFunction("parseDouble", QueryPlugin.Util.getString("SystemSource.Parsedouble_desc"), "parseDouble", "double", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Parsedouble_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- addParseNumberFunction("parseFloat", QueryPlugin.Util.getString("SystemSource.Parsefloat_desc"), "parseFloat", "float", DataTypeManager.DefaultDataTypes.FLOAT, QueryPlugin.Util.getString("SystemSource.Parsefloat_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- addParseNumberFunction("parseBigInteger", QueryPlugin.Util.getString("SystemSource.Parsebiginteger_desc"), "parseBigInteger", "biginteger", DataTypeManager.DefaultDataTypes.BIG_INTEGER, QueryPlugin.Util.getString("SystemSource.Parsebiginteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- addParseNumberFunction("parseBigDecimal", QueryPlugin.Util.getString("SystemSource.Parsebigdecimal_desc"), "parseBigDecimal", "bigdecimal", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Parsebigdecimal_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addParseNumberFunction(SourceSystemFunctions.PARSEINTEGER, QueryPlugin.Util.getString("SystemSource.Parseinteger_desc"), "parseInteger", "integer", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Parseinteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addParseNumberFunction(SourceSystemFunctions.PARSELONG, QueryPlugin.Util.getString("SystemSource.Parselong_desc"), "parseLong", "long", DataTypeManager.DefaultDataTypes.LONG, QueryPlugin.Util.getString("SystemSource.Parselong_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addParseNumberFunction(SourceSystemFunctions.PARSEDOUBLE, QueryPlugin.Util.getString("SystemSource.Parsedouble_desc"), "parseDouble", "double", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Parsedouble_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addParseNumberFunction(SourceSystemFunctions.PARSEFLOAT, QueryPlugin.Util.getString("SystemSource.Parsefloat_desc"), "parseFloat", "float", DataTypeManager.DefaultDataTypes.FLOAT, QueryPlugin.Util.getString("SystemSource.Parsefloat_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addParseNumberFunction(SourceSystemFunctions.PARSEBIGINTEGER, QueryPlugin.Util.getString("SystemSource.Parsebiginteger_desc"), "parseBigInteger", "biginteger", DataTypeManager.DefaultDataTypes.BIG_INTEGER, QueryPlugin.Util.getString("SystemSource.Parsebiginteger_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ addParseNumberFunction(SourceSystemFunctions.PARSEBIGDECIMAL, QueryPlugin.Util.getString("SystemSource.Parsebigdecimal_desc"), "parseBigDecimal", "bigdecimal", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, QueryPlugin.Util.getString("SystemSource.Parsebigdecimal_result_desc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
private void addArithmeticFunction(String functionName, String description, String methodName, String resultsDescription) {
@@ -241,7 +240,7 @@
private void addTypedAbsFunction(String type) {
functions.add(
- new FunctionMethod("abs", QueryPlugin.Util.getString("SystemSource.Abs_desc"), NUMERIC, FUNCTION_CLASS, "abs", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.ABS, QueryPlugin.Util.getString("SystemSource.Abs_desc"), NUMERIC, FUNCTION_CLASS, "abs", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("number", type, QueryPlugin.Util.getString("SystemSource.Abs_arg")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.Abs_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -249,13 +248,13 @@
private void addRandFunction() {
// With Seed
- FunctionMethod rand = new FunctionMethod("rand", QueryPlugin.Util.getString("SystemSource.Rand_desc"), NUMERIC, FUNCTION_CLASS, "rand", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ FunctionMethod rand = new FunctionMethod(SourceSystemFunctions.RAND, QueryPlugin.Util.getString("SystemSource.Rand_desc"), NUMERIC, FUNCTION_CLASS, "rand", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {new FunctionParameter("seed", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Rand_arg")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")), FunctionMethod.NONDETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
rand.setNullDependent(true);
functions.add(rand);
// Without Seed
- functions.add( new FunctionMethod("rand", QueryPlugin.Util.getString("SystemSource.Rand_desc"), NUMERIC, FUNCTION_CLASS, "rand", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ functions.add( new FunctionMethod(SourceSystemFunctions.RAND, QueryPlugin.Util.getString("SystemSource.Rand_desc"), NUMERIC, FUNCTION_CLASS, "rand", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {},
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Rand_result_desc")), FunctionMethod.NONDETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -285,11 +284,11 @@
}
private void addModFunction() {
- addTypedArithmeticFunction("mod", QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- addTypedArithmeticFunction("mod", QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.LONG); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
- addTypedArithmeticFunction("mod", QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.FLOAT); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
- addTypedArithmeticFunction("mod", QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.DOUBLE); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
- addTypedArithmeticFunction("mod", QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.BIG_INTEGER); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
+ addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.LONG); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
+ addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.FLOAT); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
+ addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.DOUBLE); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
+ addTypedArithmeticFunction(SourceSystemFunctions.MOD, QueryPlugin.Util.getString("SystemSource.Mod_desc"), "mod", QueryPlugin.Util.getString("SystemSource.Mod_result_desc"), DataTypeManager.DefaultDataTypes.BIG_INTEGER); //$NON-NLS-1$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-4$
}
private void addPowerFunction() {
@@ -299,7 +298,7 @@
private void addTypedPowerFunction(String baseType, String powerType) {
functions.add(
- new FunctionMethod("power", QueryPlugin.Util.getString("SystemSource.Power_desc"), NUMERIC, FUNCTION_CLASS, "power", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.POWER, QueryPlugin.Util.getString("SystemSource.Power_desc"), NUMERIC, FUNCTION_CLASS, "power", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("base", baseType, QueryPlugin.Util.getString("SystemSource.Power_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("power", powerType, QueryPlugin.Util.getString("SystemSource.Power_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -315,7 +314,7 @@
private void addTypedRoundFunction(String roundType) {
functions.add(
- new FunctionMethod("round", QueryPlugin.Util.getString("SystemSource.Round_desc"), NUMERIC, FUNCTION_CLASS, "round", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.ROUND, QueryPlugin.Util.getString("SystemSource.Round_desc"), NUMERIC, FUNCTION_CLASS, "round", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("number", roundType, QueryPlugin.Util.getString("SystemSource.Round_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("places", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Round_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -333,7 +332,7 @@
private void addTypedSignFunction(String type) {
functions.add(
- new FunctionMethod("sign", QueryPlugin.Util.getString("SystemSource.Sign_desc"), NUMERIC, FUNCTION_CLASS, "sign", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.SIGN, QueryPlugin.Util.getString("SystemSource.Sign_desc"), NUMERIC, FUNCTION_CLASS, "sign", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("number", type, QueryPlugin.Util.getString("SystemSource.Sign_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Sign_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -348,7 +347,7 @@
private void addTypedSqrtFunction(String type) {
functions.add(
- new FunctionMethod("sqrt", QueryPlugin.Util.getString("SystemSource.Sqrt_desc"), NUMERIC, FUNCTION_CLASS, "sqrt", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.SQRT, QueryPlugin.Util.getString("SystemSource.Sqrt_desc"), NUMERIC, FUNCTION_CLASS, "sqrt", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("number", type, QueryPlugin.Util.getString("SystemSource.Sqrt_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, QueryPlugin.Util.getString("SystemSource.Sqrt_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -393,21 +392,21 @@
private void addTimestampAddFunction() {
functions.add(
- new FunctionMethod("timestampAdd", QueryPlugin.Util.getString("SystemSource.Timestampadd_d_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg3"))}, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod("timestampAdd", QueryPlugin.Util.getString("SystemSource.Timestampadd_t_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg3"))}, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod("timestampAdd", QueryPlugin.Util.getString("SystemSource.Timestampadd_ts_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_ts_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampadd_ts_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Timestampadd_ts_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -417,14 +416,14 @@
private void addTimestampDiffFunction() {
functions.add(
- new FunctionMethod("timestampDiff", QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_desc"), DATETIME, FUNCTION_CLASS, "timestampDiff", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.TIMESTAMPDIFF, QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_desc"), DATETIME, FUNCTION_CLASS, "timestampDiff", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("time1", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("time2", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_arg3"))}, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.LONG, QueryPlugin.Util.getString("SystemSource.Timestampdiff_t_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod("timestampDiff", QueryPlugin.Util.getString("SystemSource.Timestampdiff_ts_desc"), DATETIME, FUNCTION_CLASS, "timestampDiff", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.TIMESTAMPDIFF, QueryPlugin.Util.getString("SystemSource.Timestampdiff_ts_desc"), DATETIME, FUNCTION_CLASS, "timestampDiff", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampdiff_ts_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("timestamp1", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.Timestampdiff_ts_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -434,7 +433,7 @@
private void addTimestampCreateFunction() {
functions.add(
- new FunctionMethod("timestampCreate", QueryPlugin.Util.getString("SystemSource.TimestampCreate_desc"), DATETIME, FUNCTION_CLASS, "timestampCreate", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.TIMESTAMPCREATE, QueryPlugin.Util.getString("SystemSource.TimestampCreate_desc"), DATETIME, FUNCTION_CLASS, "timestampCreate", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("date", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.TimestampCreate_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("time", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.TimestampCreate_arg2"))}, //$NON-NLS-1$ //$NON-NLS-2$
@@ -472,7 +471,7 @@
private void addConcatFunction() {
functions.add(
- new FunctionMethod("concat", QueryPlugin.Util.getString("SystemSource.Concat_desc"), STRING, FUNCTION_CLASS, "concat", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.CONCAT, QueryPlugin.Util.getString("SystemSource.Concat_desc"), STRING, FUNCTION_CLASS, "concat", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -494,14 +493,14 @@
private void addSubstringFunction() {
functions.add(
- new FunctionMethod("substring", QueryPlugin.Util.getString("SystemSource.Substring_desc"), STRING, FUNCTION_CLASS, "substring", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.SUBSTRING, QueryPlugin.Util.getString("SystemSource.Substring_desc"), STRING, FUNCTION_CLASS, "substring", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Substring_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("index", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Substring_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Substring_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Substring_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod("substring", QueryPlugin.Util.getString("SystemSource.Susbstring2_desc"), STRING, FUNCTION_CLASS, "substring", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.SUBSTRING, QueryPlugin.Util.getString("SystemSource.Susbstring2_desc"), STRING, FUNCTION_CLASS, "substring", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Substring2_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("index", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Substring2_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -510,13 +509,13 @@
private void addLeftRightFunctions() {
functions.add(
- new FunctionMethod("left", QueryPlugin.Util.getString("SystemSource.Left_desc"), STRING, FUNCTION_CLASS, "left", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.LEFT, QueryPlugin.Util.getString("SystemSource.Left_desc"), STRING, FUNCTION_CLASS, "left", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Left_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Left_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Left2_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod("right", QueryPlugin.Util.getString("SystemSource.Right_desc"), STRING, FUNCTION_CLASS, "right", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.RIGHT, QueryPlugin.Util.getString("SystemSource.Right_desc"), STRING, FUNCTION_CLASS, "right", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Right_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Right_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -525,14 +524,14 @@
private void addLocateFunction() {
functions.add(
- new FunctionMethod("locate", QueryPlugin.Util.getString("SystemSource.Locate_desc"), STRING, FUNCTION_CLASS, "locate", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.LOCATE, QueryPlugin.Util.getString("SystemSource.Locate_desc"), STRING, FUNCTION_CLASS, "locate", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("substring", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("index", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Locate_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Locate_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod("locate", QueryPlugin.Util.getString("SystemSource.Locate2_desc"), STRING, FUNCTION_CLASS, "locate", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.LOCATE, QueryPlugin.Util.getString("SystemSource.Locate2_desc"), STRING, FUNCTION_CLASS, "locate", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("substring", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate2_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Locate2_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -541,7 +540,7 @@
private void addReplaceFunction() {
functions.add(
- new FunctionMethod("replace", QueryPlugin.Util.getString("SystemSource.Replace_desc"), STRING, FUNCTION_CLASS, "replace", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.REPLACE, QueryPlugin.Util.getString("SystemSource.Replace_desc"), STRING, FUNCTION_CLASS, "replace", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Replace_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("substring", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Replace_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -551,7 +550,7 @@
private void addRepeatFunction() {
functions.add(
- new FunctionMethod("repeat", QueryPlugin.Util.getString("SystemSource.Repeat_desc"), STRING, FUNCTION_CLASS, "repeat", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.REPEAT, QueryPlugin.Util.getString("SystemSource.Repeat_desc"), STRING, FUNCTION_CLASS, "repeat", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Repeat_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Repeat_arg2"))}, //$NON-NLS-1$ //$NON-NLS-2$
@@ -560,7 +559,7 @@
private void addSpaceFunction() {
functions.add(
- new FunctionMethod("space", QueryPlugin.Util.getString("SystemSource.Space_desc"), STRING, FUNCTION_CLASS, "space", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(FunctionLibrary.SPACE, QueryPlugin.Util.getString("SystemSource.Space_desc"), STRING, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Space_arg1"))}, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Space_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -568,7 +567,7 @@
private void addInsertFunction() {
functions.add(
- new FunctionMethod("insert", QueryPlugin.Util.getString("SystemSource.Insert_desc"), STRING, FUNCTION_CLASS, "insert", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.INSERT, QueryPlugin.Util.getString("SystemSource.Insert_desc"), STRING, FUNCTION_CLASS, "insert", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("str1", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Insert_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("start", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Insert_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -579,36 +578,33 @@
private void addAsciiFunction() {
functions.add(
- new FunctionMethod("ascii", QueryPlugin.Util.getString("SystemSource.Ascii_desc"), STRING, FUNCTION_CLASS, "ascii", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.ASCII, QueryPlugin.Util.getString("SystemSource.Ascii_desc"), STRING, FUNCTION_CLASS, "ascii", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Ascii_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Ascii_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod("ascii", QueryPlugin.Util.getString("SystemSource.Ascii2_desc"), STRING, FUNCTION_CLASS, "ascii", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.ASCII, QueryPlugin.Util.getString("SystemSource.Ascii2_desc"), STRING, FUNCTION_CLASS, "ascii", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("char", DataTypeManager.DefaultDataTypes.CHAR, QueryPlugin.Util.getString("SystemSource.Ascii2_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Ascii2_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
- private void addChrFunction() {
- functions.add(
- new FunctionMethod("chr", QueryPlugin.Util.getString("SystemSource.Chr_desc"), STRING, FUNCTION_CLASS, "chr", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {
- new FunctionParameter("code", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Chr_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.CHAR, QueryPlugin.Util.getString("SystemSource.Chr_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
private void addCharFunction() {
functions.add(
- new FunctionMethod("char", QueryPlugin.Util.getString("SystemSource.Char_desc"), STRING, FUNCTION_CLASS, "chr", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.CHAR, QueryPlugin.Util.getString("SystemSource.Char_desc"), STRING, FUNCTION_CLASS, "chr", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("code", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Char_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.CHAR, QueryPlugin.Util.getString("SystemSource.Char_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ functions.add(
+ new FunctionMethod("chr", QueryPlugin.Util.getString("SystemSource.Chr_desc"), STRING, FUNCTION_CLASS, "chr", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionParameter[] {
+ new FunctionParameter("code", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Chr_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.CHAR, QueryPlugin.Util.getString("SystemSource.Chr_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addInitCapFunction() {
functions.add(
- new FunctionMethod("initcap", QueryPlugin.Util.getString("SystemSource.Initcap_desc"), STRING, FUNCTION_CLASS, "initCap", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.INITCAP, QueryPlugin.Util.getString("SystemSource.Initcap_desc"), STRING, FUNCTION_CLASS, "initCap", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Initcap_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Initcap_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -616,21 +612,14 @@
private void addLpadFunction() {
functions.add(
- new FunctionMethod("lpad", QueryPlugin.Util.getString("SystemSource.Lpad_desc"), STRING, FUNCTION_CLASS, "lpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.LPAD, QueryPlugin.Util.getString("SystemSource.Lpad_desc"), STRING, FUNCTION_CLASS, "lpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lpad_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Lpad_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lpad_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod("lpad", QueryPlugin.Util.getString("SystemSource.Lpad2_desc"), STRING, FUNCTION_CLASS, "lpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.LPAD, QueryPlugin.Util.getString("SystemSource.Lpad3_desc"), STRING, FUNCTION_CLASS, "lpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
- new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lpad2_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Lpad2_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("char", DataTypeManager.DefaultDataTypes.CHAR, QueryPlugin.Util.getString("SystemSource.Lpad2_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lpad2_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
- functions.add(
- new FunctionMethod("lpad", QueryPlugin.Util.getString("SystemSource.Lpad3_desc"), STRING, FUNCTION_CLASS, "lpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lpad3_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Lpad3_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("char", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lpad3_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -639,21 +628,14 @@
private void addRpadFunction() {
functions.add(
- new FunctionMethod("rpad", QueryPlugin.Util.getString("SystemSource.Rpad1_desc"), STRING, FUNCTION_CLASS, "rpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.RPAD, QueryPlugin.Util.getString("SystemSource.Rpad1_desc"), STRING, FUNCTION_CLASS, "rpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Rpad1_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Rpad1_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Rpad1_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod("rpad", QueryPlugin.Util.getString("SystemSource.Rpad2_desc"), STRING, FUNCTION_CLASS, "rpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.RPAD, QueryPlugin.Util.getString("SystemSource.Rpad3_desc"), STRING, FUNCTION_CLASS, "rpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
- new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Rpad2_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Rpad2_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("char", DataTypeManager.DefaultDataTypes.CHAR, QueryPlugin.Util.getString("SystemSource.Rpad2_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Rpad2_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
- functions.add(
- new FunctionMethod("rpad", QueryPlugin.Util.getString("SystemSource.Rpad3_desc"), STRING, FUNCTION_CLASS, "rpad", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Rpad3_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("length", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Rpad3_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("char", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Rpad3_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -662,7 +644,7 @@
private void addTranslateFunction() {
functions.add(
- new FunctionMethod("translate", QueryPlugin.Util.getString("SystemSource.Translate_desc"), STRING, FUNCTION_CLASS, "translate", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod(SourceSystemFunctions.TRANSLATE, QueryPlugin.Util.getString("SystemSource.Translate_desc"), STRING, FUNCTION_CLASS, "translate", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Translate_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("source", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Translate_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -672,7 +654,7 @@
private void addConversionFunctions() {
for (String type : DataTypeManager.getAllDataTypeNames()) {
- addTypedConversionFunction("convert", type); //$NON-NLS-1$
+ addTypedConversionFunction(SourceSystemFunctions.CONVERT, type); //$NON-NLS-1$
addTypedConversionFunction("cast", type); //$NON-NLS-1$
}
}
@@ -725,21 +707,20 @@
}
private void addDecodeFunctions(){
-
addDecodeFunction("decodeInteger", DataTypeManager.DefaultDataTypes.INTEGER); //$NON-NLS-1$
addDecodeFunction("decodeString", DataTypeManager.DefaultDataTypes.STRING); //$NON-NLS-1$
}
private void addDecodeFunction(String functionName, String resultType) {
functions.add(
- new FunctionMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode1_desc"), MISCELLANEOUS, FUNCTION_CLASS, functionName, //$NON-NLS-1$
+ new FunctionMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode1_desc"), MISCELLANEOUS, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$
new FunctionParameter[] {
new FunctionParameter("input", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode1_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("decodeString", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode1_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", resultType, QueryPlugin.Util.getString("SystemSource.Decode1_result") ) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode2_desc"), MISCELLANEOUS, FUNCTION_CLASS, functionName, //$NON-NLS-1$
+ new FunctionMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode2_desc"), MISCELLANEOUS, FunctionMethod.SYNTHETIC, null, null, //$NON-NLS-1$
new FunctionParameter[] {
new FunctionParameter("input", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode2_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("decodeString", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode2_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
@@ -790,21 +771,16 @@
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_result")), false, FunctionMethod.COMMAND_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
- private void addNvlFunctions() {
+ private void addIfNullFunctions() {
for (String type : DataTypeManager.getAllDataTypeNames()) {
- addNvlFunction(type);
+ addNvlFunction(type);
+ addIfNullFunction(type);
}
}
-
- private void addIfNullFunctions() {
- for (String type : DataTypeManager.getAllDataTypeNames()) {
- addIfNullFunction(type);
- }
- }
private void addNvlFunction(String valueType) {
FunctionMethod nvl =
- new FunctionMethod("nvl", QueryPlugin.Util.getString("SystemSource.Nvl_desc"), MISCELLANEOUS, FUNCTION_CLASS, "nvl", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod("nvl", QueryPlugin.Util.getString("SystemSource.Nvl_desc"), MISCELLANEOUS, FUNCTION_CLASS, "ifnull", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("value", valueType, QueryPlugin.Util.getString("SystemSource.Nvl_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("valueIfNull", valueType, QueryPlugin.Util.getString("SystemSource.Nvl_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -815,7 +791,7 @@
private void addIfNullFunction(String valueType) {
FunctionMethod nvl =
- new FunctionMethod("ifnull", QueryPlugin.Util.getString("SystemSource.Ifnull_desc"), MISCELLANEOUS, FUNCTION_CLASS, "nvl", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionMethod("ifnull", QueryPlugin.Util.getString("SystemSource.Ifnull_desc"), MISCELLANEOUS, FUNCTION_CLASS, "ifnull", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("value", valueType, QueryPlugin.Util.getString("SystemSource.Ifnull_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("valueIfNull", valueType, QueryPlugin.Util.getString("SystemSource.Ifnull_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
@@ -921,13 +897,13 @@
* @since 4.2
*/
private void addXpathFunction() {
- functions.add(new FunctionMethod("xpathValue", QueryPlugin.Util.getString("SystemSource.xpath_description"), XML, XML_FUNCTION_CLASS, "xpathValue", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ functions.add(new FunctionMethod(SourceSystemFunctions.XPATHVALUE, QueryPlugin.Util.getString("SystemSource.xpath_description"), XML, XML_FUNCTION_CLASS, "xpathValue", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("document", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.xpath_param1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("xpath", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.xpath_param2"))}, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.xpath_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
- functions.add(new FunctionMethod("xpathValue", QueryPlugin.Util.getString("SystemSource.xpath_description"), XML, XML_FUNCTION_CLASS, "xpathValue", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ functions.add(new FunctionMethod(SourceSystemFunctions.XPATHVALUE, QueryPlugin.Util.getString("SystemSource.xpath_description"), XML, XML_FUNCTION_CLASS, "xpathValue", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("document", DataTypeManager.DefaultDataTypes.XML, QueryPlugin.Util.getString("SystemSource.xpath_param1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("xpath", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.xpath_param2"))}, //$NON-NLS-1$ //$NON-NLS-2$
@@ -936,14 +912,14 @@
}
private void addTimeZoneFunctions() {
- functions.add(new FunctionMethod("modifyTimeZone", QueryPlugin.Util.getString("SystemSource.modifyTimeZone_description"), DATETIME, FUNCTION_CLASS, "modifyTimeZone", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ functions.add(new FunctionMethod(SourceSystemFunctions.MODIFYTIMEZONE, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_description"), DATETIME, FUNCTION_CLASS, "modifyTimeZone", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_param1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("startTimeZone", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_param2")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("endTimeZone", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_param3"))}, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
- functions.add(new FunctionMethod("modifyTimeZone", QueryPlugin.Util.getString("SystemSource.modifyTimeZone_description"), DATETIME, FUNCTION_CLASS, "modifyTimeZone", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ functions.add(new FunctionMethod(SourceSystemFunctions.MODIFYTIMEZONE, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_description"), DATETIME, FUNCTION_CLASS, "modifyTimeZone", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
new FunctionParameter[] {
new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_param1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("endTimeZone", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.modifyTimeZone_param3"))}, //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -253,7 +253,7 @@
* visit the query in definition order
*/
public void visit(Query obj) {
- if (obj.getOrderBy() != null) {
+ if (obj.getOrderBy() != null || obj.getLimit() != null) {
visitor.namingContext.aliasColumns = true;
}
visitNode(obj.getFrom());
Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -53,6 +53,7 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.Transform;
import com.metamatrix.common.util.TimestampWithTimezone;
+import com.metamatrix.connector.api.SourceSystemFunctions;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.Assertion;
import com.metamatrix.query.eval.Evaluator;
@@ -60,7 +61,6 @@
import com.metamatrix.query.function.FunctionDescriptor;
import com.metamatrix.query.function.FunctionLibrary;
import com.metamatrix.query.function.FunctionLibraryManager;
-import com.metamatrix.query.function.FunctionMethods;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.TempMetadataAdapter;
import com.metamatrix.query.metadata.TempMetadataID;
@@ -121,7 +121,6 @@
import com.metamatrix.query.sql.proc.Statement;
import com.metamatrix.query.sql.proc.TranslateCriteria;
import com.metamatrix.query.sql.proc.WhileStatement;
-import com.metamatrix.query.sql.symbol.AbstractCaseExpression;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.CaseExpression;
@@ -159,6 +158,17 @@
private final static Timestamp EXAMPLE_TIMESTAMP = Timestamp.valueOf("2001-02-03 13:04:05.01"); //$NON-NLS-1$
private final static Time EXAMPLE_TIME = Time.valueOf("13:04:05"); //$NON-NLS-1$
private final static Date EXAMPLE_DATE = Date.valueOf("2001-02-03"); //$NON-NLS-1$
+
+ private static final Map<String, String> ALIASED_FUNCTIONS = new HashMap<String, String>();
+
+ static {
+ ALIASED_FUNCTIONS.put("lower", SourceSystemFunctions.LCASE);
+ ALIASED_FUNCTIONS.put("upper", SourceSystemFunctions.UCASE);
+ ALIASED_FUNCTIONS.put("cast", SourceSystemFunctions.CONVERT);
+ ALIASED_FUNCTIONS.put("nvl", SourceSystemFunctions.IFNULL);
+ ALIASED_FUNCTIONS.put("||", SourceSystemFunctions.CONCAT);
+ ALIASED_FUNCTIONS.put("chr", SourceSystemFunctions.CHAR);
+ }
private QueryRewriter() { }
@@ -1981,15 +1991,26 @@
return expression;
}
- /**
- * <p>Do 2 things:
- * <ol>
- * <li> If function is a type conversion of type X to type X - eliminate it</li>
- * <li> If this is a function totally based on constants, execute it now
- * rather than many times in the processor, and return the equivalent constant</li>
- * </ol></p>
- */
private static Expression rewriteFunction(Function function, Command procCommand, CommandContext context, QueryMetadataInterface metadata) throws QueryValidatorException {
+ //rewrite alias functions
+ String actualName =ALIASED_FUNCTIONS.get(function.getName().toLowerCase());
+ if (actualName != null) {
+ function.setName(actualName);
+ }
+
+ //space(x) => repeat(' ', x)
+ if (function.getName().equalsIgnoreCase(FunctionLibrary.SPACE)) {
+ //change the function into timestampadd
+ Function result = new Function(SourceSystemFunctions.REPEAT,
+ new Expression[] {new Constant(" "), function.getArg(0)});
+ //resolve the function
+ FunctionDescriptor descriptor =
+ FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.REPEAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.INTEGER});
+ result.setFunctionDescriptor(descriptor);
+ result.setType(DataTypeManager.DefaultDataClasses.STRING);
+ return rewriteFunction(result, procCommand, context, metadata);
+ }
+
//from_unixtime(a) => timestampadd(SQL_TSI_SECOND, a, new Timestamp(0))
if (function.getName().equalsIgnoreCase(FunctionLibrary.FROM_UNIXTIME)) {
//change the function into timestampadd
@@ -2018,11 +2039,11 @@
if (function.getName().equalsIgnoreCase(FunctionLibrary.COALESCE)) {
Expression[] args = function.getArgs();
if (args.length == 2) {
- Function result = new Function(FunctionLibrary.IFNULL,
+ Function result = new Function(SourceSystemFunctions.IFNULL,
new Expression[] {function.getArg(0), function.getArg(1) });
//resolve the function
FunctionDescriptor descriptor =
- FunctionLibraryManager.getFunctionLibrary().findFunction(FunctionLibrary.IFNULL, new Class[] { function.getType(), function.getType() });
+ FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.IFNULL, new Class[] { function.getType(), function.getType() });
result.setFunctionDescriptor(descriptor);
result.setType(function.getType());
return rewriteFunction(result, procCommand, context, metadata);
@@ -2051,18 +2072,18 @@
Function[] newArgs = new Function[args.length];
for(int i=0; i<args.length; i++) {
- newArgs[i] = new Function(FunctionLibrary.NVL, new Expression[] {args[i], new Constant("")}); //$NON-NLS-1$
+ newArgs[i] = new Function(SourceSystemFunctions.IFNULL, new Expression[] {args[i], new Constant("")}); //$NON-NLS-1$
newArgs[i].setType(args[i].getType());
Assertion.assertTrue(args[i].getType() == DataTypeManager.DefaultDataClasses.STRING);
FunctionDescriptor descriptor =
- FunctionLibraryManager.getFunctionLibrary().findFunction(FunctionLibrary.NVL, new Class[] { args[i].getType(), DataTypeManager.DefaultDataClasses.STRING });
+ FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.IFNULL, new Class[] { args[i].getType(), DataTypeManager.DefaultDataClasses.STRING });
newArgs[i].setFunctionDescriptor(descriptor);
}
- Function concat = new Function(FunctionLibrary.CONCAT, newArgs);
+ Function concat = new Function(SourceSystemFunctions.CONCAT, newArgs);
concat.setType(DataTypeManager.DefaultDataClasses.STRING);
FunctionDescriptor descriptor =
- FunctionLibraryManager.getFunctionLibrary().findFunction(FunctionLibrary.CONCAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
+ FunctionLibraryManager.getFunctionLibrary().findFunction(SourceSystemFunctions.CONCAT, new Class[] { DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING });
concat.setFunctionDescriptor(descriptor);
List when = Arrays.asList(new Criteria[] {new CompoundCriteria(CompoundCriteria.AND, new IsNullCriteria(args[0]), new IsNullCriteria(args[1]))});
@@ -2142,16 +2163,22 @@
while (tokenizer.hasMoreTokens()) {
String resultString;
String compareString =
- FunctionMethods.convertString(tokenizer.nextToken().trim());
+ convertString(tokenizer.nextToken().trim());
if (tokenizer.hasMoreTokens()) {
- resultString = FunctionMethods.convertString(tokenizer.nextToken().trim());
- newWhens.add(new Constant(compareString));
+ resultString = convertString(tokenizer.nextToken().trim());
+ Criteria crit;
+ if (compareString == null) {
+ crit = new IsNullCriteria((Expression) exprs[0].clone());
+ } else {
+ crit = new CompareCriteria((Expression) exprs[0].clone(), CompareCriteria.EQ, new Constant(compareString));
+ }
+ newWhens.add(crit);
newThens.add(new Constant(resultString));
}else {
elseConst = new Constant(compareString);
}
}
- CaseExpression newCaseExpr = new CaseExpression(exprs[0], newWhens, newThens);
+ SearchedCaseExpression newCaseExpr = new SearchedCaseExpression(newWhens, newThens);
if(elseConst != null) {
newCaseExpr.setElseExpression(elseConst);
}else {
@@ -2162,52 +2189,92 @@
return newCaseExpr;
}
+ public static String convertString(String string) {
+ /*
+ * if there are no characters in the compare string we designate that as
+ * an indication of null. ie if the decode string looks like this:
+ *
+ * "'this', 1,,'null'"
+ *
+ * Then if the value in the first argument is null then the String 'null' is
+ * returned from the function.
+ */
+ if (string.equals("")) { //$NON-NLS-1$
+ return null;
+ }
+
+ /*
+ * we also allow the use of the keyword null in the decode string. if it
+ * wished to match on the string 'null' then the string must be qualified by
+ * ' designators.
+ */
+ if(string.equalsIgnoreCase("null")){ //$NON-NLS-1$
+ return null;
+ }
+
+ /*
+ * Here we check to see if the String in the decode String submitted
+ * was surrounded by String literal characters. In this case we strip
+ * these literal characters from the String.
+ */
+ if ((string.startsWith("\"") && string.endsWith("\"")) //$NON-NLS-1$ //$NON-NLS-2$
+ || (string.startsWith("'") && string.endsWith("'"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ if (string.length() == 2) {
+ /*
+ * This is an indication that the desired string to be compared is
+ * the "" empty string, so we return it as such.
+ */
+ string = ""; //$NON-NLS-1$
+ } else if (!string.equalsIgnoreCase("'") && !string.equalsIgnoreCase("\"")){ //$NON-NLS-1$ //$NON-NLS-2$
+ string = string.substring(1);
+ string = string.substring(0, string.length()-1);
+ }
+ }
+
+ return string;
+ }
+
private static Expression rewriteCaseExpression(CaseExpression expr, Command procCommand, CommandContext context, QueryMetadataInterface metadata)
throws QueryValidatorException {
- Expression rewrittenExpr = rewriteExpression(expr.getExpression(), procCommand, context, metadata);
- expr.setExpression(rewrittenExpr);
-
+ List<CompareCriteria> whens = new ArrayList<CompareCriteria>(expr.getWhenCount());
+ for (Expression expression: (List<Expression>)expr.getWhen()) {
+ whens.add(new CompareCriteria((Expression)expr.getExpression().clone(), CompareCriteria.EQ, expression));
+ }
+ SearchedCaseExpression sce = new SearchedCaseExpression(whens, expr.getThen());
+ sce.setElseExpression(expr.getElseExpression());
+ sce.setType(expr.getType());
+ return rewriteCaseExpression(sce, procCommand, context, metadata);
+ }
+
+ private static Expression rewriteCaseExpression(SearchedCaseExpression expr, Command procCommand, CommandContext context, QueryMetadataInterface metadata)
+ throws QueryValidatorException {
int whenCount = expr.getWhenCount();
ArrayList whens = new ArrayList(whenCount);
ArrayList thens = new ArrayList(whenCount);
-
- boolean tryToSimplify = EvaluateExpressionVisitor.isFullyEvaluatable(rewrittenExpr, true);
+
for (int i = 0; i < whenCount; i++) {
- Expression rewrittenWhen = rewriteExpression(expr.getWhenExpression(i), procCommand, context, metadata);
- if(tryToSimplify && EvaluateExpressionVisitor.isFullyEvaluatable(rewrittenWhen, true)) {
- CompareCriteria crit = new CompareCriteria(rewrittenExpr, CompareCriteria.EQ, rewrittenWhen);
+
+ // Check the when to see if this CASE can be rewritten due to an always true/false when
+ Criteria rewrittenWhen = rewriteCriteria(expr.getWhenCriteria(i), procCommand, context, metadata);
+ if(EvaluateExpressionVisitor.isFullyEvaluatable(rewrittenWhen, true)) {
try {
- boolean eval = Evaluator.evaluate(crit);
+ boolean eval = Evaluator.evaluate(rewrittenWhen);
if(eval) {
- // This WHEN will always match, so return the THEN expression
+ // WHEN is always true, so just return the THEN
return rewriteExpression(expr.getThenExpression(i), procCommand, context, metadata);
}
-
- // This WHEN will never match, so remove it from the CASE
+
+ // WHEN is never true, so just skip this WHEN/THEN pair in the lists
continue;
} catch(Exception e) {
// ignore and don't simplify - shouldn't happen
- tryToSimplify = false;
- }
- } else {
- tryToSimplify = false;
- }
-
+ }
+ }
+
whens.add(rewrittenWhen);
thens.add(rewriteExpression(expr.getThenExpression(i), procCommand, context, metadata));
}
-
- return simplifyCaseExpression(expr, procCommand,context, whenCount, whens, thens, metadata);
- }
- private static Expression simplifyCaseExpression(AbstractCaseExpression expr,
- Command procCommand,
- CommandContext context,
- int whenCount,
- ArrayList whens,
- ArrayList thens,
- QueryMetadataInterface metadata) throws QueryValidatorException {
-
expr.setElseExpression(rewriteExpression(expr.getElseExpression(), procCommand, context, metadata));
Expression elseExpr = expr.getElseExpression();
@@ -2246,42 +2313,6 @@
return expr;
}
-
- private static Expression rewriteCaseExpression(SearchedCaseExpression expr, Command procCommand, CommandContext context, QueryMetadataInterface metadata)
- throws QueryValidatorException {
- int whenCount = expr.getWhenCount();
- ArrayList whens = new ArrayList(whenCount);
- ArrayList thens = new ArrayList(whenCount);
-
- boolean tryToSimplify = true;
- for (int i = 0; i < whenCount; i++) {
-
- // Check the when to see if this CASE can be rewritten due to an always true/false when
- Criteria rewrittenWhen = rewriteCriteria(expr.getWhenCriteria(i), procCommand, context, metadata);
- if(tryToSimplify && EvaluateExpressionVisitor.isFullyEvaluatable(rewrittenWhen, true)) {
- try {
- boolean eval = Evaluator.evaluate(rewrittenWhen);
- if(eval) {
- // WHEN is always true, so just return the THEN
- return rewriteExpression(expr.getThenExpression(i), procCommand, context, metadata);
- }
-
- // WHEN is never true, so just skip this WHEN/THEN pair in the lists
- continue;
- } catch(Exception e) {
- // ignore and don't simplify - shouldn't happen
- tryToSimplify = false;
- }
- } else {
- tryToSimplify = false;
- }
-
- whens.add(rewrittenWhen);
- thens.add(rewriteExpression(expr.getThenExpression(i), procCommand, context, metadata));
- }
-
- return simplifyCaseExpression(expr, procCommand,context, whenCount, whens, thens, metadata);
- }
private static Command rewriteExec(StoredProcedure storedProcedure, Command procCommand, QueryMetadataInterface metadata, CommandContext context) throws QueryValidatorException {
//After this method, no longer need to display named parameters
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Function.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Function.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Function.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -62,6 +62,10 @@
return this.name;
}
+ public void setName(String name) {
+ this.name = name;
+ }
+
/**
* Get function arguments
* @return Get function arguments
Modified: trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -193,38 +193,18 @@
public void visit(CaseExpression obj) {
parts.add(ReservedWords.CASE);
parts.add(SPACE);
+ parts.add(registerNode(obj.getExpression()) );
+ parts.add(SPACE);
- // checking for null compare in decode string case 2969 GCSS
- for (int i =0; i < obj.getWhenCount(); i++) {
- if (ReservedWords.NULL.equalsIgnoreCase(obj.getWhenExpression(i).toString() ) ) {
- parts.add(ReservedWords.WHEN);
- parts.add(SPACE);
- parts.add(registerNode(obj.getExpression()) );
- parts.add(SPACE);
- parts.add(ReservedWords.IS);
- parts.add(SPACE);
- parts.add(ReservedWords.NULL);
- parts.add(SPACE);
- parts.add(ReservedWords.THEN);
- parts.add(SPACE);
- parts.add(registerNode(obj.getThenExpression(i)));
- parts.add(SPACE);
- }
- }
-
for (int i = 0; i < obj.getWhenCount(); i++) {
- if(!ReservedWords.NULL.equalsIgnoreCase(obj.getWhenExpression(i).toString() ) ) {
- parts.add(ReservedWords.WHEN);
- parts.add(SPACE);
- parts.add(registerNode(obj.getExpression()) );
- parts.add("="); //$NON-NLS-1$
- parts.add(registerNode(obj.getWhenExpression(i)) );
- parts.add(SPACE);
- parts.add(ReservedWords.THEN);
- parts.add(SPACE);
- parts.add(registerNode(obj.getThenExpression(i)));
- parts.add(SPACE);
- }
+ parts.add(ReservedWords.WHEN);
+ parts.add(SPACE);
+ parts.add(registerNode(obj.getWhenExpression(i)) );
+ parts.add(SPACE);
+ parts.add(ReservedWords.THEN);
+ parts.add(SPACE);
+ parts.add(registerNode(obj.getThenExpression(i)));
+ parts.add(SPACE);
}
if (obj.getElseExpression() != null) {
Modified: trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties 2009-02-19 17:59:09 UTC (rev 476)
@@ -51,9 +51,9 @@
ERR.015.001.0024 = Error occurred while taking log10 of {0}
ERR.015.001.0025 = Pad length must be > 0.
ERR.015.001.0026 = Error occurred while doing {0} mod {1}
-ERR.015.001.0027 = Pad character for lpad must be a single character.
+ERR.015.001.0027 = Pad string for lpad/rpad must have length greater than 0.
ERR.015.001.0028 = Error occurred while doing {0} ^ {1}
-ERR.015.001.0029 = Pad character for rpad must be a single character.
+ERR.015.001.0029 = Pad string for rpad must have length greater than 1.
ERR.015.001.0030 = Error occurred while taking sign({0})
ERR.015.001.0031 = Source and destination character lists must be the same length.
ERR.015.001.0032 = Error occurred while taking sqrt of {0}
Deleted: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCaseExpressionImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCaseExpressionImpl.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCaseExpressionImpl.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1,152 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.internal.datamgr.language;
-
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.TestCaseExpression;
-
-import junit.framework.TestCase;
-
-public class TestCaseExpressionImpl extends TestCase {
-
- /**
- * Constructor for TestCaseExpressionImpl.
- * @param name
- */
- public TestCaseExpressionImpl(String name) {
- super(name);
- }
-
- public static CaseExpression helpExample() {
- ElementSymbol x = TestElementImpl.helpExample("vm1.g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- CaseExpression caseExpr = new CaseExpression(x, TestCaseExpression.getWhenExpressions(3), TestCaseExpression.getThenExpressions(3));
- caseExpr.setElseExpression(new Constant(new Integer(9999)));
- return caseExpr;
- }
-
- public static CaseExpression helpExampleElementElse() {
- ElementSymbol x = TestElementImpl.helpExample("vm1.g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- CaseExpression caseExpr = new CaseExpression(x, TestCaseExpression.getWhenExpressions(3), TestCaseExpression.getThenExpressions(3));
- caseExpr.setElseExpression(x);
- return caseExpr;
- }
-
- public static CaseExpression helpIntExample() {
- ElementSymbol x = TestElementImpl.helpIntExample("vm1.g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- CaseExpression caseExpr = new CaseExpression(x, TestCaseExpression.getWhenExpressions(3), TestCaseExpression.getThenExpressions(3));
- caseExpr.setElseExpression(x);
- return caseExpr;
- }
-
- public static CaseExpression helpExampleNullFirst() {
- ElementSymbol x = TestElementImpl.helpExample("vm1.g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- CaseExpression caseExpr = new CaseExpression(x, TestCaseExpression.getWhenExpressions(3, 0, true), TestCaseExpression.getThenExpressions(3));
- caseExpr.setElseExpression(new Constant(new Integer(9999)));
- return caseExpr;
- }
-
- public static CaseExpression helpExampleNullMiddle() {
- ElementSymbol x = TestElementImpl.helpExample("vm1.g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- CaseExpression caseExpr = new CaseExpression(x, TestCaseExpression.getWhenExpressions(3, 1, true), TestCaseExpression.getThenExpressions(3));
- caseExpr.setElseExpression(new Constant(new Integer(9999)));
- return caseExpr;
- }
-
- public static CaseExpression helpExampleNullLast() {
- ElementSymbol x = TestElementImpl.helpExample("vm1.g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- CaseExpression caseExpr = new CaseExpression(x, TestCaseExpression.getWhenExpressions(3, 2, true), TestCaseExpression.getThenExpressions(3));
- caseExpr.setElseExpression(new Constant(new Integer(9999)));
- return caseExpr;
- }
-
- public static CaseExpressionImpl example() throws Exception {
- return (CaseExpressionImpl)TstLanguageBridgeFactory.factory.translate(helpExample());
- }
-
- public static CaseExpressionImpl exampleElementElse() throws Exception {
- return (CaseExpressionImpl)TstLanguageBridgeFactory.factory.translate(helpExampleElementElse());
- }
-
- public static CaseExpressionImpl exampleInteger() throws Exception {
- return (CaseExpressionImpl)TstLanguageBridgeFactory.factory.translate(helpIntExample());
- }
-
- public static CaseExpressionImpl exampleNullFirst() throws Exception {
- return (CaseExpressionImpl)TstLanguageBridgeFactory.factory.translate(helpExampleNullFirst());
- }
-
- public static CaseExpressionImpl exampleNullMiddle() throws Exception {
- return (CaseExpressionImpl)TstLanguageBridgeFactory.factory.translate(helpExampleNullMiddle());
- }
-
- public static CaseExpressionImpl exampleNullLast() throws Exception {
- return (CaseExpressionImpl)TstLanguageBridgeFactory.factory.translate(helpExampleNullLast());
- }
-
- public void testGetElseExpression() throws Exception {
- assertNotNull(example().getElseExpression());
- CaseExpression expr = helpExample();
- expr.setElseExpression(null);
- assertNull(TstLanguageBridgeFactory.factory.translate(expr).getElseExpression());
- }
-
- public void testGetExpression() throws Exception {
- assertNotNull(example().getExpression());
- }
-
- public void testGetThenExpression() throws Exception {
- assertNotNull(example().getThenExpression(0));
- assertNotNull(example().getThenExpression(1));
- assertNotNull(example().getThenExpression(2));
- }
-
- public void testGetWhenCount() throws Exception {
- assertEquals(3, example().getWhenCount());
- }
-
- public void testGetWhenExpression() throws Exception {
- assertNotNull(example().getWhenExpression(0));
- assertNotNull(example().getWhenExpression(1));
- assertNotNull(example().getWhenExpression(2));
- }
-
- public void testGetWhenExpressionNullFirst() throws Exception {
- assertNotNull(exampleNullFirst().getWhenExpression(0));
- assertNotNull(exampleNullFirst().getWhenExpression(1));
- assertNotNull(exampleNullFirst().getWhenExpression(2));
-}
- public void testGetWhenExpressionNullMiddle() throws Exception {
- assertNotNull(exampleNullMiddle().getWhenExpression(0));
- assertNotNull(exampleNullMiddle().getWhenExpression(1));
- assertNotNull(exampleNullMiddle().getWhenExpression(2));
- }
-
- public void testGetWhenExpressionNullLast() throws Exception {
- assertNotNull(exampleNullLast().getWhenExpression(0));
- assertNotNull(exampleNullLast().getWhenExpression(1));
- assertNotNull(exampleNullLast().getWhenExpression(2));
- }
-
-}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestElementImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestElementImpl.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestElementImpl.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -28,6 +28,7 @@
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IGroup;
import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.metadata.runtime.MetadataID.Type;
import com.metamatrix.dqp.internal.datamgr.metadata.TestMetadataFactory;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.unittest.FakeMetadataObject;
@@ -106,7 +107,7 @@
public void testSetMetadataID() throws Exception {
Object metadataID = TstLanguageBridgeFactory.metadata.getElementID("pm1.g1.e1"); //$NON-NLS-1$
ElementImpl element = example("pm1.g1", "e1", metadataID); //$NON-NLS-1$ //$NON-NLS-2$
- MetadataID connID = TstLanguageBridgeFactory.metadataFactory.createMetadataID(metadataID, MetadataID.TYPE_ELEMENT);
+ MetadataID connID = TstLanguageBridgeFactory.metadataFactory.createMetadataID(metadataID, Type.TYPE_ELEMENT);
element.setMetadataID(connID);
assertNotNull(element.getMetadataID());
assertEquals(connID, element.getMetadataID());
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestInsertImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestInsertImpl.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestInsertImpl.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -67,7 +67,7 @@
elements.add(TestElementImpl.helpExample(groupName, "e1")); //$NON-NLS-1$
ArrayList values = new ArrayList();
- values.add(TestCaseExpressionImpl.helpExample());
+ values.add(TestSearchedCaseExpressionImpl.helpExample());
return new Insert(group,
elements,
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/metadata/TestMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/metadata/TestMetadataFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/metadata/TestMetadataFactory.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -30,8 +30,8 @@
import junit.framework.TestCase;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.metadata.runtime.MetadataID.Type;
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataObject;
import com.metamatrix.query.unittest.FakeMetadataStore;
@@ -108,12 +108,12 @@
public void testCreateMetadataID(){
try{
//test create MetadataID for Group
- MetadataIDImpl gID = (MetadataIDImpl)metadataFactory.createMetadataID(pm1g1, MetadataID.TYPE_GROUP);
+ MetadataIDImpl gID = (MetadataIDImpl)metadataFactory.createMetadataID(pm1g1, Type.TYPE_GROUP);
assertEquals(gID.getActualMetadataID(), pm1g1);
assertEquals(((MetadataIDImpl)gID.getChildIDs().get(0)).getActualMetadataID(), pm1g1e1);
//test create MetadataID for Element
- MetadataIDImpl eID = (MetadataIDImpl)metadataFactory.createMetadataID(pm1g1e1, MetadataID.TYPE_ELEMENT);
+ MetadataIDImpl eID = (MetadataIDImpl)metadataFactory.createMetadataID(pm1g1e1, Type.TYPE_ELEMENT);
assertEquals(eID.getActualMetadataID(), pm1g1e1);
assertEquals(((MetadataIDImpl)eID.getParentID()).getActualMetadataID(), pm1g1);
}catch(Exception e){
@@ -124,13 +124,13 @@
public void testRuntimeMetadata(){
try{
- RuntimeMetadata runtimeMetadata = metadataFactory.createRuntimeMetadata();
- MetadataIDImpl gID = (MetadataIDImpl)metadataFactory.createMetadataID(pm1g1, MetadataID.TYPE_GROUP);
+ RuntimeMetadata runtimeMetadata = metadataFactory.getRuntimeMetadata();
+ MetadataIDImpl gID = (MetadataIDImpl)metadataFactory.createMetadataID(pm1g1, Type.TYPE_GROUP);
GroupImpl group = (GroupImpl)runtimeMetadata.getObject(gID);
assertEquals(group.getNameInSource(), "g1"); //$NON-NLS-1$
assertEquals(((MetadataIDImpl)group.getMetadataID()).getActualMetadataID(), pm1g1);
- MetadataIDImpl eID = (MetadataIDImpl)metadataFactory.createMetadataID(pm1g1e1, MetadataID.TYPE_ELEMENT);
+ MetadataIDImpl eID = (MetadataIDImpl)metadataFactory.createMetadataID(pm1g1e1, Type.TYPE_ELEMENT);
ElementImpl element = (ElementImpl)runtimeMetadata.getObject(eID);
assertEquals(element.getLength(), 100);
assertEquals(element.getJavaType(), DataTypeManager.DefaultDataClasses.STRING);
@@ -145,7 +145,7 @@
public void testGetVDBResourcePaths() {
String[] expectedPaths = new String[] {"my/resource/path"}; //$NON-NLS-1$
try {
- RuntimeMetadata runtimeMetadata = metadataFactory.createRuntimeMetadata();
+ RuntimeMetadata runtimeMetadata = metadataFactory.getRuntimeMetadata();
String[] mfPaths = metadataFactory.getVDBResourcePaths();
String[] rtmdPaths = runtimeMetadata.getVDBResourcePaths();
assertEquals(expectedPaths.length, mfPaths.length);
@@ -162,7 +162,7 @@
public void testGetBinaryVDBResource() {
try {
- RuntimeMetadata runtimeMetadata = metadataFactory.createRuntimeMetadata();
+ RuntimeMetadata runtimeMetadata = metadataFactory.getRuntimeMetadata();
byte[] expectedBytes = "ResourceContents".getBytes(); //$NON-NLS-1$
byte[] mfBytes = metadataFactory.getBinaryVDBResource(null);
byte[] rtmdBytes = runtimeMetadata.getBinaryVDBResource(null);
@@ -180,7 +180,7 @@
public void testGetCharacterVDBResource() {
try {
- RuntimeMetadata runtimeMetadata = metadataFactory.createRuntimeMetadata();
+ RuntimeMetadata runtimeMetadata = metadataFactory.getRuntimeMetadata();
assertEquals("ResourceContents", metadataFactory.getCharacterVDBResource(null)); //$NON-NLS-1$
assertEquals("ResourceContents", runtimeMetadata.getCharacterVDBResource(null)); //$NON-NLS-1$
} catch (Exception e) {
Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -112,8 +112,8 @@
assertEquals("Didn't get expected result from lpad", expected, actual); //$NON-NLS-1$
}
- public static void helpTestLpad(String input, int length, char c, String expected) throws FunctionExecutionException {
- String actual = (String) FunctionMethods.lpad(input, new Integer(length), new Character(c));
+ public static void helpTestLpad(String input, int length, String pad, String expected) throws FunctionExecutionException {
+ String actual = (String) FunctionMethods.lpad(input, new Integer(length), pad);
assertEquals("Didn't get expected result from lpad", expected, actual); //$NON-NLS-1$
}
@@ -122,8 +122,8 @@
assertEquals("Didn't get expected result from rpad", expected, actual); //$NON-NLS-1$
}
- public static void helpTestRpad(String input, int length, char c, String expected) throws FunctionExecutionException {
- String actual = (String) FunctionMethods.rpad(input, new Integer(length), new Character(c));
+ public static void helpTestRpad(String input, int length, String c, String expected) throws FunctionExecutionException {
+ String actual = (String) FunctionMethods.rpad(input, new Integer(length), c);
assertEquals("Didn't get expected result from rpad", expected, actual); //$NON-NLS-1$
}
@@ -519,152 +519,6 @@
helpConvert(ts, "string", "2003-08-22 22:43:53.003333333"); //$NON-NLS-1$ //$NON-NLS-2$
}
- /*
- * Test for Object decodeInteger(Object, Object)
- */
- public void testDecodeIntegerObjectObject() throws FunctionExecutionException {
- decodeIntegerTests(null);
- }
-
-
- /*
- * Test for Object decodeString(Object, Object)
- */
- public void testDecodeStringObjectObject() throws FunctionExecutionException {
- decodeStringTests(null);
- }
-
- /*
- * Test for Object decodeInteger(Object, Object, Object)
- */
- public void testDecodeIntegerObjectObjectObject() throws FunctionExecutionException {
- decodeIntegerTests(","); //$NON-NLS-1$
-
- }
-
- /*
- * Test for Object decodeString(Object, Object, Object)
- */
- public void testDecodeStringObjectObjectObject() throws FunctionExecutionException {
- decodeStringTests(","); //$NON-NLS-1$
- }
-
- private void decodeStringTests(String delimiter) throws FunctionExecutionException {
- String decodeString = "a,1,b,2,c, 3, 8"; //$NON-NLS-1$
-
- String columnValue = "a"; //$NON-NLS-1$
- String expectedResult = "1"; //$NON-NLS-1$
- runDecodeStringTest(columnValue, decodeString, expectedResult, delimiter);
-
- columnValue = "b"; //$NON-NLS-1$
- expectedResult = "2"; //$NON-NLS-1$
- runDecodeStringTest(columnValue, decodeString, expectedResult, delimiter);
-
- columnValue = "g"; //$NON-NLS-1$
- expectedResult = "8"; //$NON-NLS-1$
- runDecodeStringTest(columnValue, decodeString, expectedResult, delimiter);
-
- decodeString = decodeString.substring(0, decodeString.length() - 3);
- columnValue = "6"; //$NON-NLS-1$
- expectedResult = "6"; //$NON-NLS-1$
- runDecodeStringTest(columnValue, decodeString, expectedResult, delimiter);
-
- decodeString = "a,1,null,2, g,5"; //$NON-NLS-1$
- columnValue = null;
- expectedResult = "2"; //$NON-NLS-1$
- runDecodeStringTest(columnValue, decodeString, expectedResult, delimiter);
-
- columnValue = "8"; //$NON-NLS-1$
- expectedResult = "8"; //$NON-NLS-1$
- runDecodeStringTest(columnValue, decodeString, expectedResult, delimiter);
-
- decodeString = "'a', 1, ' b', 2, 'c', '3'"; //$NON-NLS-1$
- columnValue = "c"; //$NON-NLS-1$
- expectedResult = "3"; //$NON-NLS-1$
- runDecodeStringTest(columnValue, decodeString, expectedResult, delimiter);
-
- decodeString = "' ', 1, 'b', 2, 'c', '3'"; //$NON-NLS-1$
- columnValue = " "; //$NON-NLS-1$
- expectedResult = "1"; //$NON-NLS-1$
- runDecodeStringTest(columnValue, decodeString, expectedResult, delimiter);
- }
-
- private void decodeIntegerTests(String delimiter) throws FunctionExecutionException {
-
- String decodeString = "a,1,b,2,c, 3, 8"; //$NON-NLS-1$
-
- String columnValue = "a"; //$NON-NLS-1$
- Integer expectedResult = new Integer(1);
- runDecodeIntegerTest(columnValue, decodeString, expectedResult, delimiter);
-
- columnValue = "b"; //$NON-NLS-1$
- expectedResult = new Integer(2);
- runDecodeIntegerTest(columnValue, decodeString, expectedResult, delimiter);
-
- columnValue = "g"; //$NON-NLS-1$
- expectedResult = new Integer(8);
- runDecodeIntegerTest(columnValue, decodeString, expectedResult, delimiter);
-
- decodeString = decodeString.substring(0, decodeString.length() - 3);
- columnValue = "6"; //$NON-NLS-1$
- expectedResult = new Integer(6);
- runDecodeIntegerTest(columnValue, decodeString, expectedResult, delimiter);
-
- decodeString = "a,1,null,2, g,5"; //$NON-NLS-1$
- columnValue = null;
- expectedResult = new Integer(2);
- runDecodeIntegerTest(columnValue, decodeString, expectedResult, delimiter);
-
- columnValue = "8"; //$NON-NLS-1$
- expectedResult = new Integer(8);
- runDecodeIntegerTest(columnValue, decodeString, expectedResult, delimiter);
-
- decodeString = "'a', 1, ' b', 2, 'c', '3'"; //$NON-NLS-1$
- columnValue = "c"; //$NON-NLS-1$
- expectedResult = new Integer(3);
- runDecodeIntegerTest(columnValue, decodeString, expectedResult, delimiter);
-
- Integer intColumnValue = new Integer(12);
- expectedResult = new Integer(12);
- runDecodeIntegerTest(intColumnValue, decodeString, expectedResult, delimiter);
-
-
- }
-
- private void runDecodeIntegerTest(Object columnValue,
- String decodeString,
- Object expectedResult,
- String delimiter) throws FunctionExecutionException {
- Object result = null;
- if (delimiter == null) {
- result = FunctionMethods.decodeInteger(columnValue, decodeString);
- } else {
- result = FunctionMethods.decodeInteger(columnValue, decodeString, delimiter);
- }
-
- assertEquals("Decode did not properly translate column value: " + columnValue, //$NON-NLS-1$
- expectedResult,
- result);
-
- }
-
- private void runDecodeStringTest(Object columnValue,
- String decodeString,
- Object expectedResult,
- String delimiter) throws FunctionExecutionException {
- Object result = null;
- if (delimiter == null) {
- result = FunctionMethods.decodeString(columnValue, decodeString);
- } else {
- result = FunctionMethods.decodeString(columnValue, decodeString, delimiter);
- }
-
- assertEquals("Decode did not properly translate column value: " + columnValue, //$NON-NLS-1$
- expectedResult,
- result);
-
- }
-
public void testAscii1() throws FunctionExecutionException {
Integer code = (Integer) FunctionMethods.ascii(new Character(' '));
assertEquals("Didn't get expected code", 32, code.intValue()); //$NON-NLS-1$
@@ -704,17 +558,17 @@
}
public void testNvl1() {
- String ret = (String) FunctionMethods.nvl("x", "y"); //$NON-NLS-1$ //$NON-NLS-2$
+ String ret = (String) FunctionMethods.ifnull("x", "y"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Didn't get expected value", "x", ret); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testNvl2() {
- String ret = (String) FunctionMethods.nvl(null, "y"); //$NON-NLS-1$
+ String ret = (String) FunctionMethods.ifnull(null, "y"); //$NON-NLS-1$
assertEquals("Didn't get expected value", "y", ret); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testNvl3() {
- String ret = (String) FunctionMethods.nvl(null, null);
+ String ret = (String) FunctionMethods.ifnull(null, null);
assertEquals("Didn't get expected value", null, ret); //$NON-NLS-1$
}
@@ -751,16 +605,20 @@
}
public void testLpad4() throws FunctionExecutionException {
- helpTestLpad("xx", 1, "xx"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestLpad("xx", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testLpad5() throws FunctionExecutionException {
- helpTestLpad("", 4, 'x', "xxxx"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestLpad("", 4, "x", "xxxx"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testLpad6() throws FunctionExecutionException {
- helpTestLpad("10", 6, '0', "000010"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestLpad("10", 6, "0", "000010"); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ public void testLpad7() throws FunctionExecutionException {
+ helpTestLpad("x", 4, "yq", "qyqx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
public void testRpad1() throws FunctionExecutionException {
helpTestRpad("x", 4, "x "); //$NON-NLS-1$ //$NON-NLS-2$
@@ -775,15 +633,15 @@
}
public void testRpad4() throws FunctionExecutionException {
- helpTestRpad("xx", 1, "xx"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRpad("xx", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRpad5() throws FunctionExecutionException {
- helpTestRpad("", 4, 'x', "xxxx"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRpad("", 4, "x", "xxxx"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRpad6() throws FunctionExecutionException {
- helpTestRpad("10", 6, '0', "100000"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRpad("10", 6, "0", "100000"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testTranslate1() throws FunctionExecutionException {
Modified: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -123,7 +123,7 @@
private void helpFindFunction(String fname, Class[] types, FunctionDescriptor expected) {
FunctionDescriptor actual = library.findFunction(fname, types);
- assertEquals("Function names do not match: ", expected.getName(), actual.getName()); //$NON-NLS-1$
+ assertEquals("Function names do not match: ", expected.getName().toLowerCase(), actual.getName().toLowerCase()); //$NON-NLS-1$
assertEquals("Arg lengths do not match: ", expected.getTypes().length, actual.getTypes().length); //$NON-NLS-1$
}
@@ -731,24 +731,17 @@
}
public void testInvokeLpad2() {
- helpInvokeMethod("lpad", new Object[] { "x", new Integer(3), new Character('y') }, "yyx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ helpInvokeMethod("lpad", new Object[] { "x", new Integer(3), "y" }, "yyx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
-
- public void testInvokeLpad3() {
- helpInvokeMethod("lpad", new Object[] { "x", new Integer(3), "y" }, "yyx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
+
public void testInvokeRpad1() {
helpInvokeMethod("rpad", new Object[] { "x", new Integer(3) }, "x " ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
public void testInvokeRpad2() {
- helpInvokeMethod("rpad", new Object[] { "x", new Integer(3), new Character('y') }, "xyy" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ helpInvokeMethod("rpad", new Object[] { "x", new Integer(3), "y" }, "xyy" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testInvokeRpad3() {
- helpInvokeMethod("rpad", new Object[] { "x", new Integer(3), "y" }, "xyy" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
public void testInvokeTranslate() {
helpInvokeMethod("translate", new Object[] { "ababcd", "ad", "da" }, "dbdbca" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
}
@@ -1021,10 +1014,6 @@
helpInvokeMethod("repeat", new Object[] {new String("cat"), new Integer(3)}, new String("catcatcat")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testInvokeSpace() {
- helpInvokeMethod("space", new Object[] {new Integer(3)}, new String(" ")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
public void testInvokeChar() {
helpInvokeMethod("char", new Object[] {new Integer(32) }, new Character(' ')); //$NON-NLS-1$
}
@@ -1207,51 +1196,7 @@
tsUtil.createTime(23, 59, 59)},
tsUtil.createTimestamp(103, 4, 15, 23, 59, 59, 0));
}
-
- /** decodeInteger */
- public void testInvokeDecode1() {
- helpInvokeMethod("decodeInteger", new Object[] {"integer", "integer, 4", ","}, new Integer(4)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- public void testInvokeDecode2() {
- helpInvokeMethod("decodeString", new Object[] {"string", "string, 12, integer, 4", ","}, "12"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
- public void testInvokeDecode3() {
- helpInvokeMethod("decodeString", new Object[] {"Not Nullable", "Not Nullable, 1, Nullable, 2, Unknown, 3", ","}, "1"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- helpInvokeMethod("convert", new Object[] {"1", "integer"}, new Integer(1)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testInvokeDecode4() {
- helpInvokeMethod("decodeString", new Object[] {"Unknown", "Not Nullable, YES, Nullable, NO, Unknown, ' '", ","}, " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
-
- public void testInvokeDecode5() {
- helpInvokeMethod("decodeString", new Object[] {"true", "true, 2, false, 1"}, new String("2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- helpInvokeMethod("convert", new Object[] {"2", "short"}, new Short((short)2)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testInvokeDecode6() {
- helpInvokeMethod("decodeString", new Object[] {"string", "char, \', string, \""}, "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- public void testInvokeDecode7() {
- helpInvokeMethod("decodeString", new Object[] {"Searchable", "Searchable, 3, All Except Like, 2, Like Only, 1, Unsearchable, 0"}, new String("3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- helpInvokeMethod("convert", new Object[] {"3", "short"}, new Short((short)3)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testInvokeDecode8() {
- helpInvokeMethod("decodeString", new Object[] {"true", "true, 2, false, 1"}, new String("2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- helpInvokeMethod("decodeString", new Object[] {"2", "2, false, 1, true"}, new String("false")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- helpInvokeMethod("convert", new Object[] {"false", "boolean"}, new Boolean(false)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- helpInvokeMethod("convert", new Object[] {"true", "boolean"}, new Boolean(true)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public void testInvokeDecode9() {
- helpInvokeMethod("decodeString", new Object[] {"JAVA_OBJECT", "JAVA_OBJECT,2000 , DISTINCT, 2001, STRUCT, 2002"}, new String("2000")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- helpInvokeMethod("convert", new Object[] {"2000", "integer"}, new Integer(2000)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
public void testInvokeBitand() {
helpInvokeMethod("bitand", new Object[] {new Integer(0xFFF), new Integer(0x0F0)}, new Integer(0x0F0)); //$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -31,6 +31,7 @@
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.api.exception.query.QueryParserException;
import com.metamatrix.api.exception.query.QueryResolverException;
+import com.metamatrix.connector.api.SourceSystemFunctions;
import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
@@ -936,7 +937,7 @@
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setFunctionSupport("nvl", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.IFNULL, true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
@@ -944,7 +945,7 @@
ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
null, capFinder,
new String[] {
- "SELECT v_0.c_0 FROM pm1.g1 AS g_0 LEFT OUTER JOIN (SELECT nvl(g_1.e2, 1) AS c_0 FROM pm1.g2 AS g_1) AS v_0 ON g_0.e2 = v_0.c_0" }, //$NON-NLS-1$
+ "SELECT v_0.c_0 FROM pm1.g1 AS g_0 LEFT OUTER JOIN (SELECT ifnull(g_1.e2, 1) AS c_0 FROM pm1.g2 AS g_1) AS v_0 ON g_0.e2 = v_0.c_0" }, //$NON-NLS-1$
TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestLimit.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestLimit.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestLimit.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -266,7 +266,7 @@
String sql = "SELECT * FROM pm1.g1 limit 50, 100";//$NON-NLS-1$
String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$
+ "SELECT pm1.g1.e1 AS c_0, pm1.g1.e2 AS c_1, pm1.g1.e3 AS c_2, pm1.g1.e4 AS c_3 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$
};
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
@@ -532,7 +532,7 @@
String sql = "SELECT * FROM pm1.g1 UNION SELECT * FROM PM1.g2 LIMIT 50, 100";//$NON-NLS-1$
String[] expectedSql = new String[] {
- "SELECT PM1.g2.e1, PM1.g2.e2, PM1.g2.e3, PM1.g2.e4 FROM PM1.g2 LIMIT (100 + 50)", "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$ //$NON-NLS-2$
+ "SELECT PM1.g2.e1 AS c_0, PM1.g2.e2 AS c_1, PM1.g2.e3 AS c_2, PM1.g2.e4 AS c_3 FROM PM1.g2 LIMIT (100 + 50)", "SELECT pm1.g1.e1 AS c_0, pm1.g1.e2 AS c_1, pm1.g1.e3 AS c_2, pm1.g1.e4 AS c_3 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$ //$NON-NLS-2$
};
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
@@ -598,7 +598,7 @@
String sql = "SELECT * from (SELECT pm1.g1.e1 FROM pm1.g1 LIMIT 10, 100) x LIMIT 20, 75";//$NON-NLS-1$
String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1 FROM pm1.g1 LIMIT CASE WHEN (75 + (20 + 10)) < (100 + 10) THEN (75 + (20 + 10)) ELSE (100 + 10) END" //$NON-NLS-1$
+ "SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT CASE WHEN (75 + (20 + 10)) < (100 + 10) THEN (75 + (20 + 10)) ELSE (100 + 10) END" //$NON-NLS-1$
};
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
@@ -632,7 +632,7 @@
String sql = "SELECT * from (SELECT pm1.g1.e1 FROM pm1.g1 LIMIT 10, 100) x LIMIT 20, 75";//$NON-NLS-1$
String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1 FROM pm1.g1 LIMIT (20 + 10), CASE WHEN 75 < 100 THEN 75 ELSE 100 END" //$NON-NLS-1$
+ "SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT (20 + 10), CASE WHEN 75 < 100 THEN 75 ELSE 100 END" //$NON-NLS-1$
};
ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -39,6 +39,7 @@
import com.metamatrix.api.exception.query.QueryResolverException;
import com.metamatrix.api.exception.query.QueryValidatorException;
import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.connector.api.SourceSystemFunctions;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.query.analysis.AnalysisRecord;
import com.metamatrix.query.mapping.relational.QueryNode;
@@ -2505,7 +2506,7 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE, true);
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
// Add join capability to pm1
@@ -2515,7 +2516,7 @@
"SELECT e1 FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1 WHERE upper(e1) = 'X'"}, //$NON-NLS-1$
+ new String[] {"SELECT e1 FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
SHOULD_SUCCEED );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -2528,8 +2529,8 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE, true);
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
- caps.setFunctionSupport("lower", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
// Add join capability to pm1
@@ -2539,7 +2540,7 @@
"SELECT lower(e1) FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT lower(e1) FROM pm1.g1 WHERE upper(e1) = 'X'"}, //$NON-NLS-1$
+ new String[] {"SELECT lower(e1) FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
SHOULD_SUCCEED );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -2552,8 +2553,8 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE, true);
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
- caps.setFunctionSupport("lower", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
// Add join capability to pm1
@@ -2563,7 +2564,7 @@
"SELECT lower(e1), upper(e1), e2 FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT lower(e1), upper(e1), e2 FROM pm1.g1 WHERE upper(e1) = 'X'"}, //$NON-NLS-1$
+ new String[] {"SELECT lower(e1), upper(e1), e2 FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
SHOULD_SUCCEED );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -2576,8 +2577,8 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE, true);
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
- caps.setFunctionSupport("lower", false); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, false); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
// Add join capability to pm1
@@ -2587,7 +2588,7 @@
"SELECT lower(e1), upper(e1) FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1 WHERE upper(e1) = 'X'"}, //$NON-NLS-1$
+ new String[] {"SELECT e1 FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
SHOULD_SUCCEED );
checkNodeTypes(plan, new int[] {
@@ -2615,8 +2616,8 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE, true);
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
- caps.setFunctionSupport("lower", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
// Add join capability to pm1
@@ -2626,7 +2627,7 @@
"SELECT x FROM (SELECT lower(e1) AS x, upper(e1) AS y FROM pm1.g1 WHERE upper(e1) = 'X') AS z", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT lower(e1) FROM pm1.g1 WHERE upper(e1) = 'X'"}, //$NON-NLS-1$
+ new String[] {"SELECT lcase(e1) FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
SHOULD_SUCCEED );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -2639,8 +2640,8 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE, true);
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
- caps.setFunctionSupport("lower", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
// Add join capability to pm1
@@ -2650,7 +2651,7 @@
"SELECT y, e, x FROM (SELECT lower(e1) AS x, upper(e1) AS y, 5 as z, e1 AS e FROM pm1.g1 WHERE upper(e1) = 'X') AS w", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT upper(e1), e1, lower(e1) FROM pm1.g1 WHERE upper(e1) = 'X'"}, //$NON-NLS-1$
+ new String[] {"SELECT ucase(e1), e1, lcase(e1) FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
SHOULD_SUCCEED );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -2700,8 +2701,8 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
- caps.setFunctionSupport("lower", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
// Add join capability to pm1
@@ -2711,7 +2712,7 @@
"SELECT e1, lower(e1) FROM pm1.g1 WHERE upper(e1) = 'X' ORDER BY e1", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT e1, lower(e1) FROM pm1.g1 WHERE upper(e1) = 'X' ORDER BY e1"}, //$NON-NLS-1$
+ new String[] {"SELECT e1, lcase(e1) FROM pm1.g1 WHERE ucase(e1) = 'X' ORDER BY e1"}, //$NON-NLS-1$
SHOULD_SUCCEED );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -2726,8 +2727,8 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
- caps.setFunctionSupport("lower", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
// Add join capability to pm1
@@ -2737,7 +2738,7 @@
"SELECT e1, lower(e1) AS x FROM pm1.g1 WHERE upper(e1) = 'X' ORDER BY x", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT e1, lower(e1) AS x FROM pm1.g1 WHERE upper(e1) = 'X' ORDER BY x"}, //$NON-NLS-1$
+ new String[] {"SELECT e1, lcase(e1) AS x FROM pm1.g1 WHERE ucase(e1) = 'X' ORDER BY x"}, //$NON-NLS-1$
SHOULD_SUCCEED );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -2752,8 +2753,8 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
- caps.setFunctionSupport("lower", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
// Add join capability to pm1
@@ -2763,7 +2764,7 @@
"SELECT e1, x FROM (SELECT e1, lower(e1) AS x FROM pm1.g1 WHERE upper(e1) = 'X') AS z ORDER BY x", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT e1, lower(e1) AS EXPR FROM pm1.g1 WHERE upper(e1) = 'X' ORDER BY EXPR"}, //$NON-NLS-1$
+ new String[] {"SELECT e1, lcase(e1) AS EXPR FROM pm1.g1 WHERE ucase(e1) = 'X' ORDER BY EXPR"}, //$NON-NLS-1$
SHOULD_SUCCEED );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -2777,7 +2778,7 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
caps.setFunctionSupport("convert", true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
@@ -2788,7 +2789,7 @@
"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = convert(pm1.g2.e2, string) AND upper(pm1.g1.e1) = 'X'", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (upper(pm1.g1.e1) = 'X') AND (upper(convert(pm1.g2.e2, string)) = 'X')"}, //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (ucase(pm1.g1.e1) = 'X') AND (ucase(convert(pm1.g2.e2, string)) = 'X')"}, //$NON-NLS-1$
SHOULD_SUCCEED );
checkNodeTypes(plan, FULL_PUSHDOWN);
@@ -2802,7 +2803,7 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
caps.setFunctionSupport("convert", true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
@@ -2813,7 +2814,7 @@
"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2, pm1.g3 WHERE pm1.g1.e1 = convert(pm1.g2.e2, string) AND pm1.g1.e1 = concat(pm1.g3.e1, 'a') AND upper(pm1.g1.e1) = 'X'", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (upper(pm1.g1.e1) = 'X') AND (upper(convert(pm1.g2.e2, string)) = 'X')", //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (ucase(pm1.g1.e1) = 'X') AND (ucase(convert(pm1.g2.e2, string)) = 'X')", //$NON-NLS-1$
"SELECT pm1.g3.e1 FROM pm1.g3"}, //$NON-NLS-1$
SHOULD_SUCCEED );
@@ -2843,7 +2844,7 @@
caps.setCapabilitySupport(Capability.QUERY_WHERE_COMPARE_EQ, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true); //$NON-NLS-1$
caps.setFunctionSupport("convert", true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
@@ -2854,7 +2855,7 @@
"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2, (SELECT e1 AS x FROM pm1.g3) AS g WHERE pm1.g1.e1 = convert(pm1.g2.e2, string) AND pm1.g1.e1 = concat(g.x, 'a') AND upper(pm1.g1.e1) = 'X'", //$NON-NLS-1$
metadata,
null, capFinder,
- new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (upper(pm1.g1.e1) = 'X') AND (upper(convert(pm1.g2.e2, string)) = 'X')", //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (ucase(pm1.g1.e1) = 'X') AND (ucase(convert(pm1.g2.e2, string)) = 'X')", //$NON-NLS-1$
"SELECT e1 FROM pm1.g3"}, //$NON-NLS-1$
SHOULD_SUCCEED );
@@ -3508,7 +3509,7 @@
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN, true);
caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
caps.setCapabilitySupport(Capability.FUNCTION, true);
- caps.setFunctionSupport("||", true); //$NON-NLS-1$
+ caps.setFunctionSupport(SourceSystemFunctions.CONCAT, true); //$NON-NLS-1$
caps.setFunctionSupport("convert", true); //$NON-NLS-1$
capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
@@ -7156,7 +7157,7 @@
ProcessorPlan plan = helpPlan("select * from (select v1.e1, v2.e1 as e1_1, v1.e2, v2.e2 as e2_2 from (select * from vm1.g7 where vm1.g7.e2 = 1) v1 left outer join (select * from vm1.g7 where vm1.g7.e2 = 1) v2 on v1.e2 = v2.e2) as v3 where v3.e2 = 1", metadata, //$NON-NLS-1$
null, capFinder,
- new String[] { "SELECT CASE WHEN g_0.e1='S' THEN 'Pay' WHEN g_0.e1='P' THEN 'Rec' ELSE g_0.e1 END, CASE WHEN g_1.e1='S' THEN 'Pay' WHEN g_1.e1='P' THEN 'Rec' ELSE g_1.e1 END, g_0.e2, g_1.e2 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g1 AS g_1 ON g_1.e2 = 1 WHERE g_0.e2 = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ new String[] { "SELECT CASE WHEN g_0.e1 = 'S' THEN 'Pay' WHEN g_0.e1 = 'P' THEN 'Rec' ELSE g_0.e1 END, CASE WHEN g_1.e1 = 'S' THEN 'Pay' WHEN g_1.e1 = 'P' THEN 'Rec' ELSE g_1.e1 END, g_0.e2, g_1.e2 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g1 AS g_1 ON g_1.e2 = 1 WHERE g_0.e2 = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
checkNodeTypes(plan, FULL_PUSHDOWN);
checkSubPlanCount(plan, 0);
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -62,7 +62,7 @@
public void testLongOrderByAlias() throws Exception {
String sql = "select pm1.g1.e1 || pm1.g1.e2 as asfasdfadfasdfasdfadfasdfadsfasdfasdfasdfasdfasdfadfa, pm1.g1.e2 from pm1.g1 order by asfasdfadfasdfasdfadfasdfadsfasdfasdfasdfasdfasdfadfa"; //$NON-NLS-1$
- String expected = "SELECT (g_0.e1 || g_0.e2) AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
+ String expected = "SELECT concat(g_0.e1, g_0.e2) AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
}
@@ -112,13 +112,13 @@
public void testCorrelatedRefernce() throws Exception {
String sql = "select intnum, stringnum from (select intnum, stringnum from bqt1.smallb) b where intnum in (select b.stringnum || b.intnum from (select intnum from bqt1.smalla) b) "; //$NON-NLS-1$
- String expected = "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intnum AS c_0, g_0.stringnum AS c_1 FROM bqt1.smallb AS g_0) AS v_0 WHERE v_0.c_0 IN (SELECT (v_0.c_1 || v_1.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_1)"; //$NON-NLS-1$
+ String expected = "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intnum AS c_0, g_0.stringnum AS c_1 FROM bqt1.smallb AS g_0) AS v_0 WHERE v_0.c_0 IN (SELECT concat(v_0.c_1, v_1.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_1)"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
}
public void testCorrelatedRefernce1() throws Exception {
String sql = "select intnum, stringnum from bqt1.smallb where intnum in (select stringnum || b.intnum from (select intnum from bqt1.smalla) b) "; //$NON-NLS-1$
- String expected = "SELECT g_0.intnum, g_0.stringnum FROM bqt1.smallb AS g_0 WHERE g_0.intnum IN (SELECT (g_0.stringnum || v_0.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_0)"; //$NON-NLS-1$
+ String expected = "SELECT g_0.intnum, g_0.stringnum FROM bqt1.smallb AS g_0 WHERE g_0.intnum IN (SELECT concat(g_0.stringnum, v_0.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_0)"; //$NON-NLS-1$
helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -6059,17 +6059,8 @@
.append(" ELSE 9999") //$NON-NLS-1$
.append(" END") //$NON-NLS-1$
.append(" FROM m.g").toString(); //$NON-NLS-1$
- String expected = new StringBuffer("SELECT y, z, ") //$NON-NLS-1$
- .append("CASE") //$NON-NLS-1$
- .append(" WHEN x='a' THEN 0") //$NON-NLS-1$
- .append(" WHEN x='b' THEN 1") //$NON-NLS-1$
- .append(" WHEN x='c' THEN 2") //$NON-NLS-1$
- .append(" WHEN x='d' THEN 3") //$NON-NLS-1$
- .append(" ELSE 9999") //$NON-NLS-1$
- .append(" END") //$NON-NLS-1$
- .append(" FROM m.g").toString(); //$NON-NLS-1$
- helpTest(query, expected, q);
+ helpTest(query, query, q);
}
public void testCaseExpression2() {
@@ -6094,15 +6085,8 @@
.append(" WHEN 'd' THEN 3") //$NON-NLS-1$
.append(" END") //$NON-NLS-1$
.append(" FROM m.g").toString(); //$NON-NLS-1$
- String expected = new StringBuffer("SELECT y, z, ") //$NON-NLS-1$
- .append("CASE") //$NON-NLS-1$
- .append(" WHEN x='a' THEN 0") //$NON-NLS-1$
- .append(" WHEN x='b' THEN 1") //$NON-NLS-1$
- .append(" WHEN x='c' THEN 2") //$NON-NLS-1$
- .append(" WHEN x='d' THEN 3") //$NON-NLS-1$
- .append(" END") //$NON-NLS-1$
- .append(" FROM m.g").toString(); //$NON-NLS-1$
- helpTest(query, expected, q);
+
+ helpTest(query, query, q);
}
public void testCaseExpression3() {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -7940,7 +7940,7 @@
FakeDataManager dataManager = new FakeDataManager();
sampleData2(dataManager);
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, new String[] {"SELECT pm1.g1.e1 FROM pm1.g1 LIMIT (5 + 1)"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, new String[] {"SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT (5 + 1)"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
helpProcess(plan, dataManager, expected);
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1691,9 +1691,8 @@
helpTestRewriteCriteria("case 0 when 1 then 1 else 2 end = 1", "1 = 0"); //$NON-NLS-1$ //$NON-NLS-2$
}
- // First WHEN can't be rewritten, so no changes
public void testRewriteSearchedCaseExpr3() {
- helpTestRewriteCriteria("case 0 when pm1.g1.e2 then 1 else 2 end = 1", "CASE 0 WHEN pm1.g1.e2 THEN 1 ELSE 2 END = 1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCriteria("case 0 when pm1.g1.e2 then 1 else 2 end = 1", "CASE WHEN pm1.g1.e2 = 0 THEN 1 ELSE 2 END = 1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRewriteSearchedCaseExpr4() {
@@ -1704,35 +1703,35 @@
// First WHEN always false, so remove it
public void testRewriteSearchedCaseExpr5() {
- helpTestRewriteCriteria("case 0 when 1 then 1 when pm1.g1.e2 then 2 else 3 end = 1", "CASE 0 WHEN pm1.g1.e2 THEN 2 ELSE 3 END = 1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCriteria("case 0 when 1 then 1 when pm1.g1.e2 then 2 else 3 end = 1", "CASE WHEN pm1.g1.e2 = 0 THEN 2 ELSE 3 END = 1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testDefect16879_1(){
- helpTestRewriteCommand("SELECT decodestring(e1, 'a, b') FROM pm1.g1", "SELECT CASE WHEN e1='a' THEN 'b' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodestring(e1, 'a, b') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testDefect16879_2(){
- helpTestRewriteCommand("SELECT decodestring(e1, 'a, b, c, d') FROM pm1.g1", "SELECT CASE WHEN e1='a' THEN 'b' WHEN e1='c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodestring(e1, 'a, b, c, d') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 = 'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testDefect16879_3(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b') FROM pm1.g1", "SELECT CASE WHEN e1='a' THEN 'b' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testDefect16879_4(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, c, d') FROM pm1.g1", "SELECT CASE WHEN e1='a' THEN 'b' WHEN e1='c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, c, d') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 = 'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testDefect16879_5(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'null, b, c, d') FROM pm1.g1", "SELECT CASE WHEN e1 IS NULL THEN 'b' WHEN e1='c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'null, b, c, d') FROM pm1.g1", "SELECT CASE WHEN e1 IS NULL THEN 'b' WHEN e1 = 'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testDefect16879_6(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d') FROM pm1.g1", "SELECT CASE WHEN e1 IS NULL THEN 'd' WHEN e1='a' THEN 'b' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS NULL THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testDefect16879_7(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d, e') FROM pm1.g1", "SELECT CASE WHEN e1 IS NULL THEN 'd' WHEN e1='a' THEN 'b' ELSE 'e' END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d, e') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS NULL THEN 'd' ELSE 'e' END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
//note that the env is now treated as deterministic, however it is really only deterministic within a session
@@ -1770,7 +1769,7 @@
}
public void testRewriteWithReference() {
- helpTestRewriteCommand("SELECT e1 FROM pm1.g1 where parsetimestamp(e1, 'yyyy-MM-dd') != ?", "SELECT e1 FROM pm1.g1 WHERE e1 <> formatTimestamp(?, 'yyyy-MM-dd')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT e1 FROM pm1.g1 where parsetimestamp(e1, 'yyyy-MM-dd') != ?", "SELECT e1 FROM pm1.g1 WHERE e1 <> formattimestamp(?, 'yyyy-MM-dd')"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRewiteJoinCriteria() {
@@ -2067,15 +2066,15 @@
}
public void testRewriteConcat2_2() throws Exception {
- helpTestRewriteCriteria("concat2(pm1.g1.e1, null) = 'xyz'", "CASE WHEN pm1.g1.e1 IS NULL THEN null ELSE CONCAT(NVL(pm1.g1.e1, ''), '') END = 'xyz'", true); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCriteria("concat2(pm1.g1.e1, null) = 'xyz'", "CASE WHEN pm1.g1.e1 IS NULL THEN null ELSE concat(ifnull(pm1.g1.e1, ''), '') END = 'xyz'", true); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRewriteConcat2_3() throws Exception {
- helpTestRewriteCriteria("concat2(pm1.g1.e1, convert(pm1.g1.e2, string)) = 'xyz'", "CASE WHEN (pm1.g1.e1 IS NULL) AND (convert(pm1.g1.e2, string) IS NULL) THEN null ELSE CONCAT(NVL(pm1.g1.e1, ''), NVL(convert(pm1.g1.e2, string), '')) END = 'xyz'", true); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCriteria("concat2(pm1.g1.e1, convert(pm1.g1.e2, string)) = 'xyz'", "CASE WHEN (pm1.g1.e1 IS NULL) AND (convert(pm1.g1.e2, string) IS NULL) THEN null ELSE concat(ifnull(pm1.g1.e1, ''), ifnull(convert(pm1.g1.e2, string), '')) END = 'xyz'", true); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRewriteConcat2_4() throws Exception {
- helpTestRewriteCriteria("concat2('a', pm1.g1.e1) = 'xyz'", "CONCAT('a', NVL(pm1.g1.e1, '')) = 'xyz'"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCriteria("concat2('a', pm1.g1.e1) = 'xyz'", "concat('a', ifnull(pm1.g1.e1, '')) = 'xyz'"); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testRewiteEvaluatableAggregate() {
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -68,8 +68,12 @@
throw new RuntimeException(e);
}
}
-
+
public static FakeMetadataFacade example1() {
+ return example1(true);
+ }
+
+ public static FakeMetadataFacade example1(boolean allUpdatable) {
// Create models
FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
FakeMetadataObject vm1 = FakeMetadataFactory.createVirtualModel("vm1"); //$NON-NLS-1$
@@ -83,6 +87,9 @@
List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ if (!allUpdatable) {
+ ((FakeMetadataObject)pm1g1e.get(0)).putProperty(FakeMetadataObject.Props.UPDATE, Boolean.FALSE);
+ }
List pm1g2e = FakeMetadataFactory.createElements(pm1g2,
new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -163,105 +170,8 @@
// Create the facade from the store
return new FakeMetadataFacade(store);
- }
-
- public static FakeMetadataFacade example2() {
- // Create models
- FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
- FakeMetadataObject vm1 = FakeMetadataFactory.createVirtualModel("vm1"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g2 = FakeMetadataFactory.createPhysicalGroup("pm1.g2", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g3 = FakeMetadataFactory.createPhysicalGroup("pm1.g3", pm1); //$NON-NLS-1$
-
- // Create physical elements
- List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- ((FakeMetadataObject)pm1g1e.get(0)).putProperty(FakeMetadataObject.Props.UPDATE, Boolean.FALSE);
-
- List pm1g2e = FakeMetadataFactory.createElements(pm1g2,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
-
- List pm1g3e = FakeMetadataFactory.createElements(pm1g3,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- ((FakeMetadataObject)pm1g3e.get(0)).putProperty(FakeMetadataObject.Props.NULL, Boolean.FALSE);
- ((FakeMetadataObject)pm1g3e.get(0)).putProperty(FakeMetadataObject.Props.DEFAULT_VALUE, null);
-
- ((FakeMetadataObject)pm1g3e.get(1)).putProperty(FakeMetadataObject.Props.NULL, Boolean.FALSE);
- ((FakeMetadataObject)pm1g3e.get(1)).putProperty(FakeMetadataObject.Props.AUTO_INCREMENT, Boolean.TRUE);
- ((FakeMetadataObject)pm1g3e.get(1)).putProperty(FakeMetadataObject.Props.DEFAULT_VALUE, null);
-
- ((FakeMetadataObject)pm1g3e.get(2)).putProperty(FakeMetadataObject.Props.NULL, Boolean.FALSE);
- ((FakeMetadataObject)pm1g3e.get(2)).putProperty(FakeMetadataObject.Props.DEFAULT_VALUE, "xyz"); //$NON-NLS-1$
-
- // Create virtual groups
- QueryNode vm1g1n1 = new QueryNode("vm1.g1", "SELECT e1 as a, e2 FROM pm1.g1 WHERE e3 > 5"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g1 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g1", vm1, vm1g1n1); //$NON-NLS-1$
- QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT e1, e2, e3, e4 FROM pm1.g2 WHERE e3 > 5"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g2 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g2", vm1, vm1g2n1); //$NON-NLS-1$
- QueryNode vm1g3n1 = new QueryNode("vm1.g3", "SELECT e1, e3 FROM pm1.g3"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g3 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g3", vm1, vm1g3n1); //$NON-NLS-1$
- QueryNode vm1g4n1 = new QueryNode("vm1.g4", "SELECT e1, e2 FROM pm1.g3"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g4 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g4", vm1, vm1g4n1); //$NON-NLS-1$
- QueryNode vm1g5n1 = new QueryNode("vm1.g5", "SELECT e2, e3 FROM pm1.g3"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g5 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g5", vm1, vm1g5n1); //$NON-NLS-1$
-
- // Create virtual elements
- List vm1g1e = FakeMetadataFactory.createElements(vm1g1,
- new String[] { "a", "e2"}, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER});
- List vm1g2e = FakeMetadataFactory.createElements(vm1g2,
- new String[] { "e1", "e2","e3", "e4"}, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List vm1g3e = FakeMetadataFactory.createElements(vm1g3,
- new String[] { "e1", "e2"}, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, });
- List vm1g4e = FakeMetadataFactory.createElements(vm1g4,
- new String[] { "e1", "e3"}, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.BOOLEAN });
- List vm1g5e = FakeMetadataFactory.createElements(vm1g5,
- new String[] { "e2","e3"}, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN });
-
- // Stored queries
- FakeMetadataObject rs1 = FakeMetadataFactory.createResultSet("pm1.rs1", pm1, new String[] { "e1", "e2" }, new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- FakeMetadataObject rs1p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs1); //$NON-NLS-1$
- QueryNode sq1n1 = new QueryNode("pm1.sq1", "CREATE VIRTUAL PROCEDURE BEGIN SELECT e1, e2 FROM pm1.g1; END"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject sq1 = FakeMetadataFactory.createVirtualProcedure("pm1.sq1", pm1, Arrays.asList(new FakeMetadataObject[] { rs1p1 }), sq1n1); //$NON-NLS-1$
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(pm1);
- store.addObject(pm1g1);
- store.addObjects(pm1g1e);
- store.addObject(pm1g2);
- store.addObjects(pm1g2e);
- store.addObject(pm1g3);
- store.addObjects(pm1g3e);
-
- store.addObject(vm1);
- store.addObject(vm1g1);
- store.addObjects(vm1g1e);
- store.addObject(vm1g2);
- store.addObjects(vm1g2e);
- store.addObject(vm1g3);
- store.addObjects(vm1g3e);
- store.addObject(vm1g4);
- store.addObjects(vm1g4e);
- store.addObject(vm1g5);
- store.addObjects(vm1g5e);
-
- store.addObject(rs1);
- store.addObject(sq1);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
+ }
+
//actual tests
public void testCreateInsertCommand(){
helpTest(UpdateProcedureGenerator.INSERT_PROCEDURE,
@@ -455,7 +365,7 @@
helpTest(UpdateProcedureGenerator.UPDATE_PROCEDURE,
"vm1.g1", //$NON-NLS-1$
"select e1 as a, e2 from pm1.g1 where e4 > 5", //$NON-NLS-1$
- TestUpdateProcedureGenerator.example2(),
+ TestUpdateProcedureGenerator.example1(false),
"CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = UPDATE pm1.g1 SET e2 = INPUT.e2 WHERE TRANSLATE CRITERIA;\nEND"); //$NON-NLS-1$
}
@@ -464,7 +374,7 @@
helpTest(UpdateProcedureGenerator.INSERT_PROCEDURE,
"vm1.g1", //$NON-NLS-1$
"SELECT e1, e2 FROM pm1.g1", //$NON-NLS-1$
- TestUpdateProcedureGenerator.example2(),
+ TestUpdateProcedureGenerator.example1(false),
"CREATE PROCEDURE\nBEGIN\nROWS_UPDATED = INSERT INTO pm1.g1 (pm1.g1.e2) VALUES (INPUT.e2);\nEND"); //$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -1840,24 +1840,24 @@
public void testCaseExpression1() {
helpTest(TestCaseExpression.example(2),
- "CASE WHEN x='a' THEN 0 WHEN x='b' THEN 1 ELSE 9999 END"); //$NON-NLS-1$
+ "CASE x WHEN 'a' THEN 0 WHEN 'b' THEN 1 ELSE 9999 END"); //$NON-NLS-1$
}
public void testCaseExpression2() {
CaseExpression example = TestCaseExpression.example(2);
example.setElseExpression(null);
- helpTest(example, "CASE WHEN x='a' THEN 0 WHEN x='b' THEN 1 END"); //$NON-NLS-1$
+ helpTest(example, "CASE x WHEN 'a' THEN 0 WHEN 'b' THEN 1 END"); //$NON-NLS-1$
}
public void testCaseExpression3() {
CaseExpression example = TestCaseExpression.example(3, 0, true);
- helpTest(example, "CASE WHEN x IS NULL THEN 0 WHEN x='b' THEN 1 WHEN x='c' THEN 2 ELSE 9999 END"); //$NON-NLS-1$
+ helpTest(example, "CASE x WHEN null THEN 0 WHEN 'b' THEN 1 WHEN 'c' THEN 2 ELSE 9999 END"); //$NON-NLS-1$
}
public void testCaseExpression4() {
CaseExpression example = TestCaseExpression.example(3, 2, true);
example.setElseExpression(null);
- helpTest(example, "CASE WHEN x IS NULL THEN 2 WHEN x='a' THEN 0 WHEN x='b' THEN 1 END"); //$NON-NLS-1$
+ helpTest(example, "CASE x WHEN 'a' THEN 0 WHEN 'b' THEN 1 WHEN null THEN 2 END"); //$NON-NLS-1$
}
public void testSearchedCaseExpression1() {
Modified: trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -255,7 +255,7 @@
return new FakeMetadataFacade(store);
}
- public FakeMetadataFacade exampleMetadata3() {
+ public static FakeMetadataFacade exampleMetadata3() {
// Create metadata objects
FakeMetadataObject modelObj = FakeMetadataFactory.createPhysicalModel("test"); //$NON-NLS-1$
FakeMetadataObject groupObj = FakeMetadataFactory.createPhysicalGroup("test.group", modelObj); //$NON-NLS-1$
@@ -266,6 +266,7 @@
elemObj1.putProperty(FakeMetadataObject.Props.NULL, Boolean.FALSE);
elemObj1.putProperty(FakeMetadataObject.Props.DEFAULT_VALUE, Boolean.FALSE);
elemObj1.putProperty(FakeMetadataObject.Props.AUTO_INCREMENT, Boolean.TRUE);
+ elemObj1.putProperty(FakeMetadataObject.Props.NAME_IN_SOURCE, "e1:SEQUENCE=MYSEQUENCE.nextVal"); //$NON-NLS-1$
// set up validator metadata
FakeMetadataStore store = new FakeMetadataStore();
@@ -905,7 +906,7 @@
}
public void testXMLQueryRowLimitInvalidCriteria6a() {
- helpValidate("SELECT * FROM vm1.doc1 where 2 = CASE rowlimit(a2) WHEN 2 THEN 2 END", new String[] {"2 = CASE WHEN rowlimit(a2)=2 THEN 2 END"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpValidate("SELECT * FROM vm1.doc1 where 2 = CASE rowlimit(a2) WHEN 2 THEN 2 END", new String[] {"2 = CASE rowlimit(a2) WHEN 2 THEN 2 END"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testXMLQueryRowLimitInvalidCriteria7() {
@@ -1025,7 +1026,7 @@
}
public void testXMLQueryRowLimitExceptionInvalidCriteria6a() {
- helpValidate("SELECT * FROM vm1.doc1 where 2 = CASE rowlimitexception(a2) WHEN 2 THEN 2 END", new String[] {"2 = CASE WHEN rowlimitexception(a2)=2 THEN 2 END"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpValidate("SELECT * FROM vm1.doc1 where 2 = CASE rowlimitexception(a2) WHEN 2 THEN 2 END", new String[] {"2 = CASE rowlimitexception(a2) WHEN 2 THEN 2 END"}, exampleMetadata()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testXMLQueryRowLimitExceptionInvalidCriteria7() {
Modified: trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -22,48 +22,45 @@
package com.metamatrix.connector.jdbc.extension;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.connector.api.ConnectorEnvironment;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.cdk.api.EnvironmentUtility;
+import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.jdbc.JDBCPropertyNames;
-import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
+import com.metamatrix.connector.jdbc.JDBCPropertyNames;
+import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.ILanguageObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.dqp.internal.datamgr.impl.ExecutionContextImpl;
-import com.metamatrix.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
-import com.metamatrix.dqp.internal.datamgr.language.LanguageBridgeFactory;
-import com.metamatrix.dqp.internal.datamgr.language.LanguageFactoryImpl;
-import com.metamatrix.dqp.internal.datamgr.language.TestDeleteImpl;
-import com.metamatrix.dqp.internal.datamgr.language.TestInsertImpl;
-import com.metamatrix.dqp.internal.datamgr.language.TestProcedureImpl;
-import com.metamatrix.dqp.internal.datamgr.language.TestSelectImpl;
-import com.metamatrix.dqp.internal.datamgr.language.TestUpdateImpl;
-import com.metamatrix.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
-import com.metamatrix.dqp.internal.datamgr.metadata.MetadataFactory;
-import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
-import com.metamatrix.metadata.runtime.VDBMetadataFactory;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import com.metamatrix.core.util.UnitTestUtil;
+import com.metamatrix.dqp.internal.datamgr.impl.ExecutionContextImpl;
+import com.metamatrix.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
+import com.metamatrix.dqp.internal.datamgr.language.LanguageBridgeFactory;
+import com.metamatrix.dqp.internal.datamgr.language.TestDeleteImpl;
+import com.metamatrix.dqp.internal.datamgr.language.TestInsertImpl;
+import com.metamatrix.dqp.internal.datamgr.language.TestProcedureImpl;
+import com.metamatrix.dqp.internal.datamgr.language.TestSelectImpl;
+import com.metamatrix.dqp.internal.datamgr.language.TestUpdateImpl;
+import com.metamatrix.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
+import com.metamatrix.metadata.runtime.VDBMetadataFactory;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.resolver.QueryResolver;
+import com.metamatrix.query.rewriter.QueryRewriter;
+import com.metamatrix.query.sql.lang.Command;
+import com.metamatrix.query.sql.lang.From;
+import com.metamatrix.query.sql.lang.GroupBy;
+import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.lang.Select;
+import com.metamatrix.query.sql.symbol.Constant;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
+import com.metamatrix.query.sql.symbol.Expression;
+import com.metamatrix.query.sql.symbol.Function;
+import com.metamatrix.query.sql.symbol.GroupSymbol;
/**
*/
@@ -95,103 +92,69 @@
return util.parseCommand(sql);
}
- public void helpTestVisitor(String vdb, String input, Map modifiers, int expectedType, String expectedOutput) {
- helpTestVisitor(vdb, input, modifiers, expectedType, expectedOutput, false);
+ public void helpTestVisitor(String vdb, String input, Map modifiers, String expectedOutput) {
+ helpTestVisitor(vdb, input, modifiers, expectedOutput, false);
}
- public void helpTestVisitor(String vdb, String input, Map modifiers, int expectedType, String expectedOutput, boolean useMetadata) {
- helpTestVisitor(vdb, input, modifiers, expectedType, expectedOutput, useMetadata, false);
+ public void helpTestVisitor(String vdb, String input, Map modifiers, String expectedOutput, boolean useMetadata) {
+ helpTestVisitor(vdb, input, modifiers, expectedOutput, useMetadata, false);
}
- public void helpTestVisitor(String vdb, String input, Map modifiers, int expectedType, String expectedOutput, boolean useMetadata, boolean usePreparedStatement) {
+ public void helpTestVisitor(String vdb, String input, Map modifiers, String expectedOutput, boolean useMetadata, boolean usePreparedStatement) {
// Convert from sql to objects
ICommand obj = helpTranslate(vdb, input);
try {
- helpTestVisitorWithCommand(modifiers, expectedType, expectedOutput, obj, useMetadata, usePreparedStatement);
+ helpTestVisitorWithCommand(modifiers, expectedOutput, obj, useMetadata, usePreparedStatement);
} catch (ConnectorException e) {
throw new RuntimeException(e);
}
}
- public static final RuntimeMetadata metadata = TstLanguageBridgeFactory.metadataFactory.createRuntimeMetadata();
+ public static final RuntimeMetadata metadata = TstLanguageBridgeFactory.metadataFactory.getRuntimeMetadata();
- private String getStringWithContext(ILanguageObject obj) {
+ private String getStringWithContext(ILanguageObject obj) throws ConnectorException {
Properties props = new Properties();
- props.setProperty(JDBCPropertyNames.USE_COMMENTS_SOURCE_QUERY, "true");
-
- SQLConversionVisitor visitor = new SQLConversionVisitor();
- visitor.setRuntimeMetadata(metadata);
+ props.setProperty(JDBCPropertyNames.USE_COMMENTS_SOURCE_QUERY, Boolean.TRUE.toString());
+ SQLTranslator trans = new SQLTranslator();
+ trans.initialize(EnvironmentUtility.createEnvironment(props, false));
+ SQLConversionVisitor visitor = new SQLConversionVisitor(trans);
visitor.setExecutionContext(context);
- visitor.setProperties(props);
visitor.append(obj);
return visitor.toString();
}
/**
- * @param modifiers
- * @param expectedType
- * @param expectedOutput
+ * @param modifiers
+ * @param expectedOutput
* @param obj
* @throws ConnectorException
* @since 4.2
*/
private void helpTestVisitorWithCommand(Map modifiers,
- int expectedType,
String expectedOutput,
- ICommand obj, boolean useMetadata, boolean usePreparedStatement) throws ConnectorException {
+ ICommand obj,
+ boolean useMetadata, boolean usePreparedStatement) throws ConnectorException {
// Apply function replacement
FunctionReplacementVisitor funcVisitor = new FunctionReplacementVisitor(modifiers);
-
+ SQLTranslator trans = new SQLTranslator();
+ Properties p = new Properties();
+ if (usePreparedStatement) {
+ p.setProperty(JDBCPropertyNames.USE_BIND_VARIABLES, Boolean.TRUE.toString());
+ }
+ trans.initialize(EnvironmentUtility.createEnvironment(p, false));
// Convert back to SQL
- SQLConversionVisitor sqlVisitor = new SQLConversionVisitor() {
- //set the max alias lengths to test alias truncation
- protected int getMaxSelectAliasLength() {
- return 30;
- }
-
- protected int getMaxTableAliasLength() {
- return 30;
- }
- };
- if (usePreparedStatement) {
- sqlVisitor.setStmtType(TranslatedCommand.STMT_TYPE_PREPARED_STATEMENT);
- }
- sqlVisitor.setLanguageFactory(LanguageFactoryImpl.INSTANCE);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(trans);
- if (useMetadata) {
- QueryMetadataInterface metadata = VDBMetadataFactory.getVDBMetadata(getTestVDB());
- sqlVisitor.setRuntimeMetadata(new RuntimeMetadataImpl(new MetadataFactory(metadata)));
- }
- TranslatedCommand tc = new TranslatedCommand(new FakeExecutionContextImpl(), new SQLTranslator() {
-
- public void initialize(ConnectorEnvironment env, RuntimeMetadata metadata) throws ConnectorException {}
-
- public ICommand modifyCommand(ICommand command, ExecutionContext context) throws ConnectorException {
- return command;
- }
-
- public SQLConversionVisitor getTranslationVisitor() {
- return null;
- }
-
- public Map getFunctionModifiers() {
- return null;
- }}, sqlVisitor, funcVisitor);
+ TranslatedCommand tc = new TranslatedCommand(new FakeExecutionContextImpl(), trans, sqlVisitor, funcVisitor);
tc.translateCommand(obj);
- // Check stuff
-// System.out.println("in: " + input); //$NON-NLS-1$
-// System.out.println("out: " + tc.getSql()); //$NON-NLS-1$
assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
- assertEquals("Did not get expected command type", expectedType, tc.getExecutionType()); //$NON-NLS-1$
-
}
public void testSimple() {
helpTestVisitor(getTestVDB(),
"select part_name from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS"); //$NON-NLS-1$
}
@@ -199,7 +162,6 @@
helpTestVisitor(getTestVDB(),
"select part_name as x from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME AS x FROM PARTS"); //$NON-NLS-1$
}
@@ -207,7 +169,6 @@
helpTestVisitor(getTestVDB(),
"select y.part_name from parts y", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT y.PART_NAME FROM PARTS AS y"); //$NON-NLS-1$
}
@@ -215,7 +176,6 @@
helpTestVisitor(getTestVDB(),
"select y.part_name AS z from parts y", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT y.PART_NAME AS z FROM PARTS AS y"); //$NON-NLS-1$
}
@@ -223,7 +183,6 @@
helpTestVisitor(getTestVDB(),
"select 'x' from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT 'x' FROM PARTS"); //$NON-NLS-1$
}
@@ -231,7 +190,6 @@
helpTestVisitor(getTestVDB(),
"select 5 from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT 5 FROM PARTS"); //$NON-NLS-1$
}
@@ -239,7 +197,6 @@
helpTestVisitor(getTestVDB(),
"select 5.2 from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT 5.2 FROM PARTS"); //$NON-NLS-1$
}
@@ -247,7 +204,6 @@
helpTestVisitor(getTestVDB(),
"select 0.012 from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT 0.012 FROM PARTS"); //$NON-NLS-1$
}
@@ -255,7 +211,6 @@
helpTestVisitor(getTestVDB(),
"select 0.00012 from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT 0.00012 FROM PARTS"); //$NON-NLS-1$
}
@@ -263,7 +218,6 @@
helpTestVisitor(getTestVDB(),
"select 12345.123 from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT 12345.123 FROM PARTS"); //$NON-NLS-1$
}
@@ -271,7 +225,6 @@
helpTestVisitor(getTestVDB(),
"select 1234567890.1234567 from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT 1234567890.1234567 FROM PARTS"); //$NON-NLS-1$
}
@@ -279,7 +232,6 @@
helpTestVisitor(getTestVDB(),
"select {b'true'}, {b'false'} from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT 1, 0 FROM PARTS"); //$NON-NLS-1$
}
@@ -287,7 +239,6 @@
helpTestVisitor(getTestVDB(),
"select {d'2003-12-31'} from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT {d'2003-12-31'} FROM PARTS"); //$NON-NLS-1$
}
@@ -295,7 +246,6 @@
helpTestVisitor(getTestVDB(),
"select {t'23:59:59'} from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT {t'23:59:59'} FROM PARTS"); //$NON-NLS-1$
}
@@ -303,7 +253,6 @@
helpTestVisitor(getTestVDB(),
"select null from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT NULL FROM PARTS"); //$NON-NLS-1$
}
@@ -311,7 +260,6 @@
helpTestVisitor(getTestVDB(),
"select {ts'2003-12-31 23:59:59.123'} from parts", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT {ts'2003-12-31 23:59:59.123'} FROM PARTS"); //$NON-NLS-1$
}
@@ -319,7 +267,6 @@
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p, supplier_parts s where p.part_id = s.part_id", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT p.PART_NAME FROM PARTS AS p, SUPPLIER_PARTS AS s WHERE p.PART_ID = s.PART_ID"); //$NON-NLS-1$
}
@@ -327,7 +274,6 @@
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p join supplier_parts s on p.part_id = s.part_id", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT p.PART_NAME FROM PARTS AS p INNER JOIN SUPPLIER_PARTS AS s ON p.PART_ID = s.PART_ID"); //$NON-NLS-1$
}
@@ -335,7 +281,6 @@
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p join parts p2 on p.part_id = p2.part_id", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT p.PART_NAME FROM PARTS AS p INNER JOIN PARTS AS p2 ON p.PART_ID = p2.PART_ID"); //$NON-NLS-1$
}
@@ -343,7 +288,6 @@
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p right join supplier_parts s on p.part_id = s.part_id", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT p.PART_NAME FROM SUPPLIER_PARTS AS s LEFT OUTER JOIN PARTS AS p ON p.PART_ID = s.PART_ID"); //$NON-NLS-1$
}
@@ -351,7 +295,6 @@
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p left join supplier_parts s on p.part_id = s.part_id", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT p.PART_NAME FROM PARTS AS p LEFT OUTER JOIN SUPPLIER_PARTS AS s ON p.PART_ID = s.PART_ID"); //$NON-NLS-1$
}
@@ -359,7 +302,6 @@
helpTestVisitor(getTestVDB(),
"select p.part_name from parts p full join supplier_parts s on p.part_id = s.part_id", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT p.PART_NAME FROM PARTS AS p FULL OUTER JOIN SUPPLIER_PARTS AS s ON p.PART_ID = s.PART_ID"); //$NON-NLS-1$
}
@@ -367,7 +309,6 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id = 'x'", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID = 'x'"); //$NON-NLS-1$
}
@@ -375,7 +316,6 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id <> 'x'", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID <> 'x'"); //$NON-NLS-1$
}
@@ -383,7 +323,6 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id < 'x'", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID < 'x'"); //$NON-NLS-1$
}
@@ -391,7 +330,6 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id <= 'x'", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID <= 'x'"); //$NON-NLS-1$
}
@@ -399,7 +337,6 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id > 'x'", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID > 'x'"); //$NON-NLS-1$
}
@@ -407,7 +344,6 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id >= 'x'", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID >= 'x'"); //$NON-NLS-1$
}
@@ -415,7 +351,6 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id in ('x')", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID = 'x'"); //$NON-NLS-1$
}
@@ -423,7 +358,6 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id in ('x', 'y')", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID IN ('x', 'y')"); //$NON-NLS-1$
}
@@ -431,7 +365,6 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id not in ('x', 'y')", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID NOT IN ('x', 'y')"); //$NON-NLS-1$
}
@@ -439,7 +372,6 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id is null", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID IS NULL"); //$NON-NLS-1$
}
@@ -447,7 +379,6 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id is not null", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_ID IS NOT NULL"); //$NON-NLS-1$
}
@@ -455,7 +386,6 @@
helpTestVisitor(getTestVDB(),
"insert into parts (part_id, part_name, part_color, part_weight) values ('a', null, 'c', 'd')", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_UPDATE,
"INSERT INTO PARTS (PART_ID, PART_NAME, PART_COLOR, PART_WEIGHT) VALUES ('a', NULL, 'c', 'd')"); //$NON-NLS-1$
}
@@ -463,7 +393,6 @@
helpTestVisitor(getTestVDB(),
"update parts set part_weight = null where part_color = 'b'", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_UPDATE,
"UPDATE PARTS SET PART_WEIGHT = NULL WHERE PARTS.PART_COLOR = 'b'"); //$NON-NLS-1$
}
@@ -471,7 +400,6 @@
helpTestVisitor(getTestVDB(),
"update parts set part_weight = 'a' where part_weight = null", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_UPDATE,
"UPDATE PARTS SET PART_WEIGHT = 'a' WHERE NULL <> NULL"); //$NON-NLS-1$
}
@@ -495,41 +423,41 @@
ICommand result = new LanguageBridgeFactory(metadata).translate(command);
- helpTestVisitorWithCommand(new HashMap(), TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT PARTS.PART_NAME FROM PARTS GROUP BY concat(PARTS.PART_ID, 'a')", //$NON-NLS-1$
- result, false, false);
+ helpTestVisitorWithCommand(new HashMap(), "SELECT PARTS.PART_NAME FROM PARTS GROUP BY concat(PARTS.PART_ID, 'a')",
+ result, //$NON-NLS-1$
+ false, false);
}
public void testPreparedStatementCreationWithUpdate() {
helpTestVisitor(getTestVDB(),
"update parts set part_weight = 'a' where part_weight < 5", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_UPDATE,
- "UPDATE PARTS SET PART_WEIGHT = ? WHERE PARTS.PART_WEIGHT < ?", false, true); //$NON-NLS-1$
+ "UPDATE PARTS SET PART_WEIGHT = ? WHERE PARTS.PART_WEIGHT < ?",
+ false, true); //$NON-NLS-1$
}
public void testPreparedStatementCreationWithInsert() {
helpTestVisitor(getTestVDB(),
"insert into parts (part_weight) values (5)", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_UPDATE,
- "INSERT INTO PARTS (PART_WEIGHT) VALUES (?)", false, true); //$NON-NLS-1$
+ "INSERT INTO PARTS (PART_WEIGHT) VALUES (?)",
+ false, true); //$NON-NLS-1$
}
public void testPreparedStatementCreationWithSelect() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_id not in ('x', 'y') and part_weight < 6", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT PARTS.PART_NAME FROM PARTS WHERE (PARTS.PART_ID NOT IN (?, ?)) AND (PARTS.PART_WEIGHT < ?)", false, true); //$NON-NLS-1$
+ "SELECT PARTS.PART_NAME FROM PARTS WHERE (PARTS.PART_ID NOT IN (?, ?)) AND (PARTS.PART_WEIGHT < ?)",
+ false, true); //$NON-NLS-1$
}
public void testPreparedStatementCreationWithLike() {
helpTestVisitor(getTestVDB(),
"select part_name from parts where part_name like '%foo'", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_NAME LIKE ?", false, true); //$NON-NLS-1$
+ "SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_NAME LIKE ?",
+ false, true); //$NON-NLS-1$
}
/**
@@ -540,8 +468,8 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where 'x' = 'y'", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT PARTS.PART_NAME FROM PARTS WHERE 1 = ?", false, true); //$NON-NLS-1$
+ "SELECT PARTS.PART_NAME FROM PARTS WHERE 1 = ?",
+ false, true); //$NON-NLS-1$
}
/**
@@ -552,42 +480,42 @@
helpTestVisitor(getTestVDB(),
"select part_name from parts where concat(part_name, 'x') = concat('y', part_weight)", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT PARTS.PART_NAME FROM PARTS WHERE concat(PARTS.PART_NAME, 'x') = concat('y', PARTS.PART_WEIGHT)", false, true); //$NON-NLS-1$
+ "SELECT PARTS.PART_NAME FROM PARTS WHERE concat(PARTS.PART_NAME, 'x') = concat('y', PARTS.PART_WEIGHT)",
+ false, true); //$NON-NLS-1$
}
public void testPreparedStatementCreationWithCase() {
helpTestVisitor(getTestVDB(),
"SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_WEIGHT = CASE WHEN PARTS.PART_NAME='a' THEN 'b' ELSE 'c' END", //$NON-NLS-1$
new HashMap(),
- TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_WEIGHT = CASE WHEN PARTS.PART_NAME = ? THEN 'b' ELSE 'c' END", false, true); //$NON-NLS-1$
+ "SELECT PARTS.PART_NAME FROM PARTS WHERE PARTS.PART_WEIGHT = CASE WHEN PARTS.PART_NAME = ? THEN 'b' ELSE 'c' END",
+ false, true); //$NON-NLS-1$
}
public void testVisitIDeleteWithComment() throws Exception {
- String expected = "DELETE /*metamatrix sessionid:ConnectionID, requestid:RequestID.PartID*/ FROM g1 WHERE (100 >= 200) AND (500 < 600)"; //$NON-NLS-1$
+ String expected = "DELETE /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ FROM g1 WHERE (100 >= 200) AND (500 < 600)"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestDeleteImpl.example()));
}
public void testVisitIInsertWithComment() throws Exception {
- String expected = "INSERT /*metamatrix sessionid:ConnectionID, requestid:RequestID.PartID*/ INTO g1 (e1, e2, e3, e4) VALUES (1, 2, 3, 4)"; //$NON-NLS-1$
+ String expected = "INSERT /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ INTO g1 (e1, e2, e3, e4) VALUES (1, 2, 3, 4)"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestInsertImpl.example("g1"))); //$NON-NLS-1$
}
public void testVisitISelectWithComment() throws Exception {
- String expected = "SELECT /*metamatrix sessionid:ConnectionID, requestid:RequestID.PartID*/ g1.e1, g1.e2, g1.e3, g1.e4"; //$NON-NLS-1$
+ String expected = "SELECT /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ g1.e1, g1.e2, g1.e3, g1.e4"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestSelectImpl.example(false)));
- expected = "SELECT /*metamatrix sessionid:ConnectionID, requestid:RequestID.PartID*/ DISTINCT g1.e1, g1.e2, g1.e3, g1.e4"; //$NON-NLS-1$
+ expected = "SELECT /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ DISTINCT g1.e1, g1.e2, g1.e3, g1.e4"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestSelectImpl.example(true)));
}
public void testVisitIUpdateWithComment() throws Exception {
- String expected = "UPDATE /*metamatrix sessionid:ConnectionID, requestid:RequestID.PartID*/ g1 SET e1 = 1, e2 = 1, e3 = 1, e4 = 1 WHERE 1 = 1"; //$NON-NLS-1$
+ String expected = "UPDATE /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ g1 SET e1 = 1, e2 = 1, e3 = 1, e4 = 1 WHERE 1 = 1"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestUpdateImpl.example()));
}
public void testVisitIProcedureWithComment() throws Exception {
- String expected = "{ /*metamatrix sessionid:ConnectionID, requestid:RequestID.PartID*/ call sq3(?,?)}"; //$NON-NLS-1$
+ String expected = "{ /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ call sq3(?,?)}"; //$NON-NLS-1$
assertEquals(expected, getStringWithContext(TestProcedureImpl.example()));
}
}
Modified: trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -24,7 +24,6 @@
import java.util.Map;
import java.util.Properties;
-import java.util.TimeZone;
import junit.framework.TestCase;
@@ -34,6 +33,8 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
+import com.metamatrix.connector.jdbc.JDBCPropertyNames;
+import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
import com.metamatrix.connector.language.ICommand;
@@ -42,7 +43,6 @@
import com.metamatrix.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
import com.metamatrix.dqp.internal.datamgr.impl.ExecutionContextImpl;
import com.metamatrix.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
-import com.metamatrix.dqp.internal.datamgr.language.LanguageFactoryImpl;
import com.metamatrix.dqp.internal.datamgr.metadata.MetadataFactory;
import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -61,7 +61,7 @@
OracleSQLTranslator trans = new OracleSQLTranslator();
try {
- trans.initialize(new ConnectorEnvironmentImpl(new Properties(), null, null), null);
+ trans.initialize(new ConnectorEnvironmentImpl(new Properties(), null, null));
} catch(ConnectorException e) {
e.printStackTrace();
}
@@ -84,59 +84,51 @@
return UnitTestUtil.getTestDataPath() + "/PartsSupplierOracle.vdb"; //$NON-NLS-1$
}
- private String getTimestampTestVDB() {
- return UnitTestUtil.getTestDataPath() + "/tstest.vdb"; //$NON-NLS-1$
+ private void helpTestVisitor(String vdb, String input, Map modifiers, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
+ helpTestVisitor(vdb, input, modifiers, EMPTY_CONTEXT, dbmsTimeZone, expectedOutput, false);
}
- private void helpTestVisitor(String vdb, String input, Map modifiers, String dbmsTimeZone, int expectedType, String expectedOutput) throws ConnectorException {
- helpTestVisitor(vdb, input, modifiers, EMPTY_CONTEXT, dbmsTimeZone, expectedType, expectedOutput, false);
+ private void helpTestVisitor(String vdb, String input, Map modifiers, String dbmsTimeZone, String expectedOutput, boolean correctNaming) throws ConnectorException {
+ helpTestVisitor(vdb, input, modifiers, EMPTY_CONTEXT, dbmsTimeZone, expectedOutput, correctNaming);
}
- private void helpTestVisitor(String vdb, String input, Map modifiers, String dbmsTimeZone, int expectedType, String expectedOutput, boolean correctNaming) throws ConnectorException {
- helpTestVisitor(vdb, input, modifiers, EMPTY_CONTEXT, dbmsTimeZone, expectedType, expectedOutput, correctNaming);
- }
-
- private void helpTestVisitor(String vdb, String input, Map modifiers, ExecutionContext context, String dbmsTimeZone, int expectedType, String expectedOutput, boolean correctNaming) throws ConnectorException {
+ private void helpTestVisitor(String vdb, String input, Map modifiers, ExecutionContext context, String dbmsTimeZone, String expectedOutput, boolean correctNaming) throws ConnectorException {
// Convert from sql to objects
TranslationUtility util = new TranslationUtility(vdb);
ICommand obj = util.parseCommand(input, correctNaming, true);
- this.helpTestVisitor(obj, util.createRuntimeMetadata(), modifiers, context, dbmsTimeZone, expectedType, expectedOutput);
+ this.helpTestVisitor(obj, util.createRuntimeMetadata(), modifiers, context, dbmsTimeZone, expectedOutput);
}
/** Helper method takes a QueryMetadataInterface impl instead of a VDB filename
* @throws ConnectorException
*/
- private void helpTestVisitor(QueryMetadataInterface metadata, String input, Map modifiers, ExecutionContext context, String dbmsTimeZone, int expectedType, String expectedOutput) throws ConnectorException {
+ private void helpTestVisitor(QueryMetadataInterface metadata, String input, Map modifiers, ExecutionContext context, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
// Convert from sql to objects
CommandBuilder commandBuilder = new CommandBuilder(metadata);
ICommand obj = commandBuilder.getCommand(input);
RuntimeMetadata runtimeMetadata = new RuntimeMetadataImpl(new MetadataFactory(metadata));
- this.helpTestVisitor(obj, runtimeMetadata, modifiers, context, dbmsTimeZone, expectedType, expectedOutput);
+ this.helpTestVisitor(obj, runtimeMetadata, modifiers, context, dbmsTimeZone, expectedOutput);
}
- private void helpTestVisitor(ICommand obj, RuntimeMetadata metadata, Map modifiers, ExecutionContext context, String dbmsTimeZone, int expectedType, String expectedOutput) throws ConnectorException {
+ private void helpTestVisitor(ICommand obj, RuntimeMetadata metadata, Map modifiers, ExecutionContext context, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
// Apply function replacement
FunctionReplacementVisitor funcVisitor = new FunctionReplacementVisitor(modifiers);
-
+ OracleSQLTranslator translator = new OracleSQLTranslator();
+ Properties p = new Properties();
+ if (dbmsTimeZone != null) {
+ p.setProperty(JDBCPropertyNames.DATABASE_TIME_ZONE, dbmsTimeZone);
+ }
+ translator.initialize(EnvironmentUtility.createEnvironment(p, false));
// Convert back to SQL
- OracleSQLConversionVisitor sqlVisitor = new OracleSQLConversionVisitor();
- sqlVisitor.setFunctionModifiers(modifiers);
+ SQLConversionVisitor sqlVisitor = new SQLConversionVisitor(translator);
sqlVisitor.setExecutionContext(context);
- sqlVisitor.setRuntimeMetadata(metadata);
- if(dbmsTimeZone != null && dbmsTimeZone.trim().length() > 0) {
- sqlVisitor.setDatabaseTimeZone(TimeZone.getTimeZone(dbmsTimeZone));
- }
- sqlVisitor.setLanguageFactory(LanguageFactoryImpl.INSTANCE);
- OracleSQLTranslator translator = new OracleSQLTranslator();
- translator.initialize(EnvironmentUtility.createEnvironment(new Properties(), false), metadata);
TranslatedCommand tc = new TranslatedCommand(context, translator, sqlVisitor, funcVisitor);
tc.translateCommand(obj);
// Check stuff
assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
- assertEquals("Did not get expected command type", expectedType, tc.getExecutionType()); //$NON-NLS-1$
}
/**
@@ -151,19 +143,17 @@
helpTestVisitor(getTestVDB(),
input,
MODIFIERS, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
/** defect 21775 */
public void testDateStuff() throws Exception {
String input = "SELECT ((CASE WHEN month(datevalue) < 10 THEN ('0' || convert(month(datevalue), string)) ELSE convert(month(datevalue), string) END || CASE WHEN dayofmonth(datevalue) < 10 THEN ('0' || convert(dayofmonth(datevalue), string)) ELSE convert(dayofmonth(datevalue), string) END) || convert(year(datevalue), string)), SUM(intkey) FROM bqt1.SMALLA GROUP BY datevalue"; //$NON-NLS-1$
- String output = "SELECT CASE WHEN (CASE WHEN (CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE ('0' || to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL) OR (CASE WHEN TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD')) < 10 THEN CASE WHEN to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD'))) IS NULL THEN NULL ELSE ('0' || to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD')))) END ELSE to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD'))) END IS NULL) THEN NULL ELSE (CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE ('0' || to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END || CASE WHEN TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD')) < 10 THEN CASE WHEN to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'D!
D'))) IS NULL THEN NULL ELSE ('0' || to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD')))) END ELSE to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD'))) END) END IS NULL) OR (to_char(EXTRACT(YEAR FROM SmallA.DateValue)) IS NULL) THEN NULL ELSE (CASE WHEN (CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE ('0' || to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL) OR (CASE WHEN TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD')) < 10 THEN CASE WHEN to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD'))) IS NULL THEN NULL ELSE ('0' || to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD')))) END ELSE to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD'))) END IS NULL) THEN NULL ELSE (CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE ('0' || to_char(EXTRACT(MONTH FROM S!
mallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValu
e)) END || CASE WHEN TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD')) < 10 THEN CASE WHEN to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD'))) IS NULL THEN NULL ELSE ('0' || to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD')))) END ELSE to_char(TO_NUMBER(TO_CHAR(SmallA.DateValue, 'DD'))) END) END || to_char(EXTRACT(YEAR FROM SmallA.DateValue))) END, SUM(SmallA.IntKey) FROM SmallA GROUP BY SmallA.DateValue"; //$NON-NLS-1$
+ String output = "SELECT CASE WHEN (CASE WHEN (CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL) OR (CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END IS NULL) THEN NULL ELSE concat(CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END, CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE con!
cat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END) END IS NULL) OR (to_char(EXTRACT(YEAR FROM SmallA.DateValue)) IS NULL) THEN NULL ELSE concat(CASE WHEN (CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL) OR (CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END IS NULL) THEN NULL ELSE concat(CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FR!
OM SmallA.DateValue)) END, CASE WHEN EXTRACT(DAY FROM SmallA.DateValue
) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END) END, to_char(EXTRACT(YEAR FROM SmallA.DateValue))) END, SUM(SmallA.IntKey) FROM SmallA GROUP BY SmallA.DateValue"; //$NON-NLS-1$
helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
input,
MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -180,7 +170,6 @@
helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
input,
MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -192,7 +181,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testLcaseFunction() throws Exception {
@@ -203,7 +192,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testUcaseFunction() throws Exception {
@@ -214,7 +203,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testIfnullFunction() throws Exception {
@@ -225,7 +214,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testLogFunction() throws Exception {
@@ -236,7 +225,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testLog10Function() throws Exception {
@@ -247,7 +236,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testConvertFunctionInteger() throws Exception {
@@ -259,7 +248,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testConvertFunctionChar() throws Exception {
@@ -270,7 +259,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testConvertFunctionBoolean() throws Exception {
@@ -282,7 +271,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testConvertFunctionDate() throws Exception {
@@ -293,7 +282,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testConvertFunctionTime() throws Exception {
@@ -305,7 +294,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testConvertFunctionTimestamp() throws Exception {
@@ -317,7 +306,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
public void testExtractFunctionTimestamp() throws Exception {
@@ -327,38 +316,14 @@
helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
input,
MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
- public void testFormatFunctionTimestamp() throws Exception {
- String input = "SELECT formattimestamp(TIMESTAMPVALUE, 'YYYY-DD-MM HH24:MI:SS.fffffffff') FROM BQT1.Smalla"; //$NON-NLS-1$
- String output = "SELECT to_char(SmallA.TimestampValue, 'YYYY-DD-MM HH24:MI:SS.fffffffff') FROM SmallA"; //$NON-NLS-1$
-
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
- input,
- MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testFormatFunctionTime() throws Exception {
- String input = "SELECT formattime(TIMEVALUE, 'HH24:MI:SS') FROM BQT1.Smalla"; //$NON-NLS-1$
- String output = "SELECT to_char(SmallA.TimeValue, 'HH24:MI:SS') FROM SmallA"; //$NON-NLS-1$
-
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
- input,
- MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
public void testAliasedGroup() throws Exception {
helpTestVisitor(getTestVDB(),
"select y.part_name from parts as y", //$NON-NLS-1$
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT y.PART_NAME FROM PARTS y"); //$NON-NLS-1$
}
@@ -367,7 +332,6 @@
"select {d'2002-12-31'} FROM parts", //$NON-NLS-1$
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT {d'2002-12-31'} FROM PARTS"); //$NON-NLS-1$
}
@@ -376,7 +340,6 @@
"select {t'13:59:59'} FROM parts", //$NON-NLS-1$
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT {ts'1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
}
@@ -385,34 +348,14 @@
"select {ts'2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT {ts'2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
}
- public void testTimestampLiteralInCriteria() throws Exception {
- helpTestVisitor(getTimestampTestVDB(),
- "select timestampvalue FROM hugea WHERE timestampvalue = {ts'2002-12-31 13:59:59.0'}", //$NON-NLS-1$
- MODIFIERS,
- null,
- TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT HUGEA.TIMESTAMPVALUE FROM HUGEA WHERE HUGEA.TIMESTAMPVALUE = to_timestamp('2002-12-31 13:59:59.0','YYYY-MM-DD HH24:MI:SS.FF')"); //$NON-NLS-1$
- }
-
- public void testTimestampLiteralInCriteria2() throws Exception {
- helpTestVisitor(getTimestampTestVDB(),
- "select datevalue FROM hugea WHERE datevalue = {ts'2002-12-31 13:59:59.0'}", //$NON-NLS-1$
- MODIFIERS,
- null,
- TranslatedCommand.EXEC_TYPE_QUERY,
- "SELECT HUGEA.DATEVALUE FROM HUGEA WHERE HUGEA.DATEVALUE = to_date('2002-12-31 13:59:59','YYYY-MM-DD HH24:MI:SS')"); //$NON-NLS-1$
- }
-
public void testUnionOrderByWithThreeBranches() throws Exception {
helpTestVisitor(getTestVDB(),
"select part_id id FROM parts UNION ALL select part_name FROM parts UNION ALL select part_id FROM parts ORDER BY id", //$NON-NLS-1$
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY,
"(SELECT g_2.PART_ID AS c_0 FROM PARTS g_2 UNION ALL SELECT g_1.PART_NAME AS c_0 FROM PARTS g_1) UNION ALL SELECT g_0.PART_ID AS c_0 FROM PARTS g_0 ORDER BY c_0", true); //$NON-NLS-1$
}
@@ -421,7 +364,6 @@
"select part_id FROM parts UNION ALL select part_name FROM parts ORDER BY part_id", //$NON-NLS-1$
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT g_1.PART_ID AS c_0 FROM PARTS g_1 UNION ALL SELECT g_0.PART_NAME AS c_0 FROM PARTS g_0 ORDER BY c_0", true); //$NON-NLS-1$
}
@@ -430,7 +372,6 @@
"select part_id as p FROM parts UNION ALL select part_name FROM parts ORDER BY p", //$NON-NLS-1$
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY,
"SELECT PARTS.PART_ID AS p FROM PARTS UNION ALL SELECT PARTS.PART_NAME FROM PARTS ORDER BY p"); //$NON-NLS-1$
}
@@ -441,7 +382,6 @@
helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
input,
MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_UPDATE,
output);
}
@@ -463,7 +403,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
/**
@@ -482,7 +422,7 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
/**
@@ -500,34 +440,10 @@
input,
MODIFIERS,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output);
+ output);
}
/**
- * Test using an Oracle sequence object to generate (via "nextVal") a value to use
- * in an insert statement. Currently, MM does not allow column names in the value list
- * of an Insert statement. This depends on the column being modeled with special stuff
- * in it's "name in source" field. Case 3743
- *
- * @since 4.3
- */
- public void testInsertUsingSequence() throws Exception {
-
- String input = "INSERT INTO PARTS (PART_ID, PART_NAME, PART_COLOR, PART_WEIGHT) VALUES ('blah', 'Toaster', 'Beige', '2 kilos')"; //$NON-NLS-1$
-
- // Column "PART_ID" is modeled with a name in source of 'PART_ID:USE_SEQUENCE=MY_SEQ.nextVal',
- // the Oracle SQL Connector will extract the sequence value and put it in the db-specific SQL
- String output = "INSERT INTO PARTS (PART_ID, PART_NAME, PART_COLOR, PART_WEIGHT) VALUES (MY_SEQ.nextVal, 'Toaster', 'Beige', '2 kilos')"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- MODIFIERS,
- null,
- TranslatedCommand.EXEC_TYPE_UPDATE, output);
-
- }
-
- /**
* Case 3744. Test that an Oracle-specific db hint, delivered as a String via command
* payload, is added to the translated SQL.
*
@@ -545,7 +461,7 @@
MODIFIERS,
context,
null,
- TranslatedCommand.EXEC_TYPE_QUERY, output, false);
+ output, false);
}
/**
@@ -559,7 +475,7 @@
FakeMetadataFacade metadata = exampleCase3845();
- helpTestVisitor(metadata, input, MODIFIERS, EMPTY_CONTEXT, null, TranslatedCommand.EXEC_TYPE_QUERY, output);
+ helpTestVisitor(metadata, input, MODIFIERS, EMPTY_CONTEXT, null, output);
}
/** create fake BQT metadata to test this case, name in source is important */
@@ -578,61 +494,36 @@
}
public void helpTestVisitor(String vdb, String input, String expectedOutput) throws ConnectorException {
- helpTestVisitor(vdb, input, MODIFIERS, null, TranslatedCommand.EXEC_TYPE_QUERY, expectedOutput);
+ helpTestVisitor(vdb, input, MODIFIERS, null, expectedOutput);
}
public void testRowLimit2() throws Exception {
String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
- String output = "SELECT MM_VIEW_FOR_LIMIT.intkey FROM (SELECT MM_VIEW_FOR_LIMIT.intkey, ROWNUM AS MM_ROWNUM FROM (SELECT SmallA.IntKey AS intkey FROM SmallA) MM_VIEW_FOR_LIMIT) MM_VIEW_FOR_LIMIT WHERE MM_VIEW_FOR_LIMIT.MM_ROWNUM <= 100"; //$NON-NLS-1$
+ String output = "SELECT * FROM (SELECT SmallA.IntKey FROM SmallA) WHERE ROWNUM <= 100"; //$NON-NLS-1$
helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
input,
MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
public void testRowLimit3() throws Exception {
String input = "select intkey from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
- String output = "SELECT MM_VIEW_FOR_LIMIT.intkey FROM (SELECT MM_VIEW_FOR_LIMIT.intkey, ROWNUM AS MM_ROWNUM FROM (SELECT SmallA.IntKey AS intkey FROM SmallA) MM_VIEW_FOR_LIMIT) MM_VIEW_FOR_LIMIT WHERE (MM_VIEW_FOR_LIMIT.MM_ROWNUM > 50) AND (MM_VIEW_FOR_LIMIT.MM_ROWNUM <= 150)"; //$NON-NLS-1$
+ String output = "SELECT * FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT SmallA.IntKey FROM SmallA) VIEW_FOR_LIMIT WHERE ROWNUM <= 100) WHERE ROWNUM_ > 50"; //$NON-NLS-1$
helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
input,
MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
-
- public void testRowLimit4() throws Exception {
- String input = "select intkey, null, null, null from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
- String output = "SELECT MM_VIEW_FOR_LIMIT.intkey, MM_VIEW_FOR_LIMIT.expr, MM_VIEW_FOR_LIMIT.expr0, MM_VIEW_FOR_LIMIT.expr1 FROM (SELECT MM_VIEW_FOR_LIMIT.intkey, MM_VIEW_FOR_LIMIT.expr, MM_VIEW_FOR_LIMIT.expr0, MM_VIEW_FOR_LIMIT.expr1, ROWNUM AS MM_ROWNUM FROM (SELECT SmallA.IntKey AS intkey, NULL AS expr, NULL AS expr0, NULL AS expr1 FROM SmallA) MM_VIEW_FOR_LIMIT) MM_VIEW_FOR_LIMIT WHERE (MM_VIEW_FOR_LIMIT.MM_ROWNUM > 50) AND (MM_VIEW_FOR_LIMIT.MM_ROWNUM <= 150)"; //$NON-NLS-1$
-
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
- input,
- MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
- public void testRowLimitWithOrderBy() throws Exception {
- String input = "select null, intkey as expr, null from bqt1.smalla order by expr limit 50, 100"; //$NON-NLS-1$
- String output = "SELECT MM_VIEW_FOR_LIMIT.expr, MM_VIEW_FOR_LIMIT.expr0, MM_VIEW_FOR_LIMIT.expr1 FROM (SELECT MM_VIEW_FOR_LIMIT.expr, MM_VIEW_FOR_LIMIT.expr0, MM_VIEW_FOR_LIMIT.expr1, ROWNUM AS MM_ROWNUM FROM (SELECT NULL AS expr, SmallA.IntKey AS expr0, NULL AS expr1 FROM SmallA ORDER BY expr0) MM_VIEW_FOR_LIMIT) MM_VIEW_FOR_LIMIT WHERE (MM_VIEW_FOR_LIMIT.MM_ROWNUM > 50) AND (MM_VIEW_FOR_LIMIT.MM_ROWNUM <= 150)"; //$NON-NLS-1$
-
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
- input,
- MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
- output);
- }
-
+
public void testLimitWithNestedInlineView() throws Exception {
String input = "select max(intkey), stringkey from (select intkey, stringkey from bqt1.smalla order by intkey limit 100) x group by intkey"; //$NON-NLS-1$
- String output = "SELECT MAX(x.intkey), x.stringkey FROM (SELECT MM_VIEW_FOR_LIMIT.intkey, MM_VIEW_FOR_LIMIT.stringkey FROM (SELECT MM_VIEW_FOR_LIMIT.intkey, MM_VIEW_FOR_LIMIT.stringkey, ROWNUM AS MM_ROWNUM FROM (SELECT SmallA.IntKey AS intkey, SmallA.StringKey AS stringkey FROM SmallA ORDER BY intkey) MM_VIEW_FOR_LIMIT) MM_VIEW_FOR_LIMIT WHERE MM_VIEW_FOR_LIMIT.MM_ROWNUM <= 100) x GROUP BY x.intkey"; //$NON-NLS-1$
+ String output = "SELECT MAX(x.intkey), x.stringkey FROM (SELECT * FROM (SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY intkey) WHERE ROWNUM <= 100) x GROUP BY x.intkey"; //$NON-NLS-1$
helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
input,
MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
@@ -643,7 +534,6 @@
helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
input,
MODIFIERS, EMPTY_CONTEXT, null,
- TranslatedCommand.EXEC_TYPE_QUERY,
output);
}
Modified: trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataID.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataID.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataID.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -38,6 +38,7 @@
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.ISelectSymbol;
import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.metadata.runtime.MetadataID.Type;
import com.metamatrix.core.util.UnitTestUtil;
/**
@@ -75,7 +76,7 @@
MetadataID groupID = getGroupID(fullGroupName, transUtil);
assertEquals(fullGroupName, groupID.getFullName());
assertEquals(shortGroupName, groupID.getName());
- assertEquals(MetadataID.TYPE_GROUP, groupID.getType());
+ assertEquals(Type.TYPE_GROUP, groupID.getType());
assertNull(groupID.getParentID());
// Check children
@@ -84,7 +85,7 @@
Iterator childIter = children.iterator();
while(childIter.hasNext()) {
MetadataID childID = (MetadataID) childIter.next();
- assertEquals(MetadataID.TYPE_ELEMENT, childID.getType());
+ assertEquals(Type.TYPE_ELEMENT, childID.getType());
assertEquals(groupID, childID.getParentID());
assertTrue(childID.getFullName().startsWith(groupID.getFullName()));
}
@@ -109,7 +110,7 @@
public void helpTestElementID(String groupName, String elementName, TranslationUtility transUtil) throws Exception {
MetadataID elementID = getElementID(groupName, elementName, transUtil);
- assertEquals(MetadataID.TYPE_ELEMENT, elementID.getType());
+ assertEquals(Type.TYPE_ELEMENT, elementID.getType());
assertEquals(groupName + "." + elementName, elementID.getFullName()); //$NON-NLS-1$
assertEquals(elementName, elementID.getName());
assertEquals(Collections.EMPTY_LIST, elementID.getChildIDs());
@@ -145,7 +146,7 @@
public void helpTestProcedureID(String procName, String shortName, int inputParamCount, String[] paramNames, TranslationUtility transUtil) throws Exception {
MetadataID procID = getProcedureID(procName, inputParamCount, transUtil);
- assertEquals(MetadataID.TYPE_PROCEDURE, procID.getType());
+ assertEquals(Type.TYPE_PROCEDURE, procID.getType());
assertEquals(procName, procID.getFullName()); //$NON-NLS-1$
assertNull(procID.getParentID());
assertEquals(shortName, procID.getName());
@@ -157,7 +158,7 @@
Iterator childIter = children.iterator();
while(childIter.hasNext()) {
MetadataID childID = (MetadataID) childIter.next();
- assertEquals(MetadataID.TYPE_PARAMETER, childID.getType());
+ assertEquals(Type.TYPE_PARAMETER, childID.getType());
assertEquals(procID, childID.getParentID());
assertTrue(childID.getFullName().startsWith(procID.getFullName()));
Modified: trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestParams.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestParams.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestParams.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -35,6 +35,7 @@
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.Parameter;
import com.metamatrix.connector.metadata.runtime.TypeModel;
+import com.metamatrix.connector.metadata.runtime.MetadataID.Type;
import com.metamatrix.core.util.UnitTestUtil;
@@ -103,7 +104,7 @@
assertEquals(scale, p.getScale());
assertEquals(null, param.getValue());
assertEquals(false, param.getValueSpecified());
- assertEquals(MetadataID.TYPE_PARAMETER, metadataID.getType());
+ assertEquals(Type.TYPE_PARAMETER, metadataID.getType());
//System.out.println("\n" + p.getModeledType() + "\n" + p.getModeledBaseType() + "\n" + p.getModeledPrimitiveType());
Modified: trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestProcedure.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestProcedure.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestProcedure.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -36,6 +36,7 @@
import com.metamatrix.connector.metadata.runtime.Parameter;
import com.metamatrix.connector.metadata.runtime.Procedure;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.metadata.runtime.MetadataID.Type;
import com.metamatrix.core.util.UnitTestUtil;
/**
@@ -130,7 +131,7 @@
MetadataID elemID = (MetadataID) rsCols.get(0);
assertEquals("RSCol1", elemID.getName()); //$NON-NLS-1$
assertEquals("ConnectorMetadata.TestProc2.RSParam.RSCol1", elemID.getFullName()); //$NON-NLS-1$
- assertEquals(MetadataID.TYPE_ELEMENT, elemID.getType());
+ assertEquals(Type.TYPE_ELEMENT, elemID.getType());
Element e1 = (Element) rmd.getObject(elemID);
assertEquals("Result set column name in source", e1.getNameInSource()); //$NON-NLS-1$
assertEquals(java.sql.Timestamp.class, e1.getJavaType());
@@ -139,7 +140,7 @@
MetadataID elemID2 = (MetadataID) rsCols.get(1);
assertEquals("RSCol2", elemID2.getName()); //$NON-NLS-1$
assertEquals("ConnectorMetadata.TestProc2.RSParam.RSCol2", elemID2.getFullName()); //$NON-NLS-1$
- assertEquals(MetadataID.TYPE_ELEMENT, elemID2.getType());
+ assertEquals(Type.TYPE_ELEMENT, elemID2.getType());
Element e2 = (Element) rmd.getObject(elemID2);
assertEquals(null, e2.getNameInSource()); //$NON-NLS-1$
assertEquals(String.class, e2.getJavaType());
Modified: trunk/test-integration/src/test/java/com/metamatrix/data/visitor/util/TestSQLStringVisitor.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/data/visitor/util/TestSQLStringVisitor.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/visitor/util/TestSQLStringVisitor.java 2009-02-19 17:59:09 UTC (rev 476)
@@ -34,8 +34,8 @@
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.IGroup;
import com.metamatrix.connector.language.ILanguageObject;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.metadata.runtime.MetadataID.Type;
import com.metamatrix.connector.visitor.util.SQLStringVisitor;
import com.metamatrix.dqp.internal.datamgr.language.AggregateImpl;
import com.metamatrix.dqp.internal.datamgr.language.ElementImpl;
@@ -43,7 +43,6 @@
import com.metamatrix.dqp.internal.datamgr.language.GroupImpl;
import com.metamatrix.dqp.internal.datamgr.language.LiteralImpl;
import com.metamatrix.dqp.internal.datamgr.language.TestAggregateImpl;
-import com.metamatrix.dqp.internal.datamgr.language.TestCaseExpressionImpl;
import com.metamatrix.dqp.internal.datamgr.language.TestCompareCriteriaImpl;
import com.metamatrix.dqp.internal.datamgr.language.TestDeleteImpl;
import com.metamatrix.dqp.internal.datamgr.language.TestElementImpl;
@@ -66,9 +65,9 @@
import com.metamatrix.dqp.internal.datamgr.language.TestSearchedCaseExpressionImpl;
import com.metamatrix.dqp.internal.datamgr.language.TestSelectImpl;
import com.metamatrix.dqp.internal.datamgr.language.TestSelectSymbolImpl;
+import com.metamatrix.dqp.internal.datamgr.language.TestSetQueryImpl;
import com.metamatrix.dqp.internal.datamgr.language.TestSubqueryCompareCriteriaImpl;
import com.metamatrix.dqp.internal.datamgr.language.TestSubqueryInCriteriaImpl;
-import com.metamatrix.dqp.internal.datamgr.language.TestSetQueryImpl;
import com.metamatrix.dqp.internal.datamgr.language.TestUpdateImpl;
import com.metamatrix.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
import com.metamatrix.dqp.internal.datamgr.metadata.MetadataFactory;
@@ -84,7 +83,7 @@
public class TestSQLStringVisitor extends TestCase {
- public static final RuntimeMetadata metadata = TstLanguageBridgeFactory.metadataFactory.createRuntimeMetadata();
+ public static final RuntimeMetadata metadata = TstLanguageBridgeFactory.metadataFactory.getRuntimeMetadata();
/**
@@ -96,11 +95,11 @@
}
private String getString(ILanguageObject obj) {
- return SQLStringVisitor.getSQLString(obj, metadata);
+ return SQLStringVisitor.getSQLString(obj);
}
private String getString(ILanguageObject obj, RuntimeMetadata metadata) {
- return SQLStringVisitor.getSQLString(obj, metadata);
+ return SQLStringVisitor.getSQLString(obj);
}
/** create fake BQT metadata to test this case, name in source is important */
@@ -139,54 +138,6 @@
}
/*
- * Test for void visit(ICaseExpression)
- */
- public void testVisitICaseExpression() throws Exception {
- String expected = "CASE WHEN g1.e1='a' THEN 0 WHEN g1.e1='b' THEN 1 WHEN g1.e1='c' THEN 2 ELSE 9999 END"; //$NON-NLS-1$
- assertEquals(expected, getString(TestCaseExpressionImpl.example()));
- }
-
- /*
- * Test for void visit(ICaseExpression)
- */
- public void testVisitICaseExpressionNulFirst() throws Exception {
- String expected = "CASE WHEN g1.e1 IS NULL THEN 0 WHEN g1.e1='b' THEN 1 WHEN g1.e1='c' THEN 2 ELSE 9999 END"; //$NON-NLS-1$
- assertEquals(expected, getString(TestCaseExpressionImpl.exampleNullFirst()));
- }
-
- /*
- * Test for void visit(ICaseExpression)
- */
- public void testVisitICaseExpressionNullMiddle() throws Exception {
- String expected = "CASE WHEN g1.e1 IS NULL THEN 1 WHEN g1.e1='a' THEN 0 WHEN g1.e1='c' THEN 2 ELSE 9999 END"; //$NON-NLS-1$
- assertEquals(expected, getString(TestCaseExpressionImpl.exampleNullMiddle()));
- }
-
- /*
- * Test for void visit(ICaseExpression)
- */
- public void testVisitICaseExpressionNullLast() throws Exception {
- String expected = "CASE WHEN g1.e1 IS NULL THEN 2 WHEN g1.e1='a' THEN 0 WHEN g1.e1='b' THEN 1 ELSE 9999 END"; //$NON-NLS-1$
- assertEquals(expected, getString(TestCaseExpressionImpl.exampleNullLast()));
- }
-
- /*
- * Test for void visit(ICaseExpression)
- */
- public void testVisitICaseExpressionNullElse() throws Exception {
- String expected = "CASE WHEN g1.e1='a' THEN 0 WHEN g1.e1='b' THEN 1 WHEN g1.e1='c' THEN 2 ELSE g1.e1 END"; //$NON-NLS-1$
- assertEquals(expected, getString(TestCaseExpressionImpl.exampleElementElse() ) );
- }
-
- /*
- * Test for void visit(ICaseExpression)
- */
- public void testVisitICaseExpressionInteger() throws Exception {
- String expected = "CASE WHEN g1.e1='a' THEN 0 WHEN g1.e1='b' THEN 1 WHEN g1.e1='c' THEN 2 ELSE g1.e1 END"; //$NON-NLS-1$
- assertEquals(expected, getString(TestCaseExpressionImpl.exampleInteger() ) );
- }
-
- /*
* Test for void visit(ICompareCriteria)
*/
public void testVisitICompareCriteria() throws Exception {
@@ -269,8 +220,8 @@
IExpression [] params = null;
params = new IExpression[2];
- IGroup g = new GroupImpl("SmallA", null, metadataFactory.createMetadataID(facade.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP), MetadataID.TYPE_GROUP)); //$NON-NLS-1$
- IElement e = new ElementImpl(g, "DoubleNum", metadataFactory.createMetadataID(facade.getStore().findObject("DoubleNum", FakeMetadataObject.ELEMENT), MetadataID.TYPE_ELEMENT), Double.class); //$NON-NLS-1$ //$NON-NLS-2$
+ IGroup g = new GroupImpl("SmallA", null, metadataFactory.createMetadataID(facade.getStore().findObject("BQT1.SmallA", FakeMetadataObject.GROUP), Type.TYPE_GROUP)); //$NON-NLS-1$
+ IElement e = new ElementImpl(g, "DoubleNum", metadataFactory.createMetadataID(facade.getStore().findObject("DoubleNum", FakeMetadataObject.ELEMENT), Type.TYPE_ELEMENT), Double.class); //$NON-NLS-1$ //$NON-NLS-2$
params[0] = e;
params[1] = new LiteralImpl("integer", String.class); //$NON-NLS-1$
@@ -294,19 +245,6 @@
assertEquals(expected, getString(test));
}
- public void testVisitConvertFunctionSQLServerStyle() throws Exception {
- String expected = "convert(integer, columnA)"; //$NON-NLS-1$
-
- IExpression [] params = null;
- params = new IExpression[2];
- params[0] = new LiteralImpl("integer", String.class); //$NON-NLS-1$
- params[1] = new ElementImpl(null, "columnA", null, String.class); //$NON-NLS-1$
- IFunction test = new FunctionImpl("convert", params, Integer.class); //$NON-NLS-1$
-
- assertEquals(expected, getString(test));
-
- }
-
/*
* Test for void visit(IGroup)
*/
15 years, 10 months
teiid SVN: r475 - in trunk: connector-api/src/main/java/com/metamatrix/connector and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-02-16 16:35:28 -0500 (Mon, 16 Feb 2009)
New Revision: 475
Removed:
trunk/connector-api/src/main/java/com/metamatrix/connector/exception/
trunk/connector-api/src/main/java/com/metamatrix/connector/monitor/
trunk/connector-api/src/main/java/com/metamatrix/data/
trunk/connector-api/src/test/java/com/metamatrix/data/basic/
trunk/engine/src/main/java/com/metamatrix/dqp/internal/cache/connector/
trunk/server/src/test/java/com/metamatrix/common/net/
Log:
TEIID-351 TEIID-348 TEIID-164 minor fix for ldap lt gt support, removed explicit interfaces for monitoredconnector, repackaged connectorexception, added the use of appropriate generics to connector api.
15 years, 10 months
teiid SVN: r474 - in trunk: connector-api/src/main/java/com/metamatrix/connector/basic and 106 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-02-16 16:35:21 -0500 (Mon, 16 Feb 2009)
New Revision: 474
Added:
trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorException.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/CredentialMap.java
trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java
Removed:
trunk/connector-api/src/main/java/com/metamatrix/connector/pool/CredentialMap.java
Modified:
trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connection.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connector.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/DataNotAvailableException.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/Execution.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/ExecutionContext.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/ProcedureExecution.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/ResultSetExecution.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/TypeFacility.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/UpdateExecution.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/ValueTranslator.java
trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnection.java
trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicExecution.java
trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicValueTranslator.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IBatchedUpdates.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IBulkInsert.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICommand.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICompareCriteria.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICompoundCriteria.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IFrom.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IGroupBy.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IInCriteria.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IInsert.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IJoin.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILanguageFactory.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IOrderBy.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IParameter.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IProcedure.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/ISelect.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/ISubqueryCompareCriteria.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/LanguageUtil.java
trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Element.java
trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataID.java
trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataObject.java
trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Parameter.java
trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/RuntimeMetadata.java
trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/TypeModel.java
trunk/connector-api/src/main/java/com/metamatrix/connector/pool/ConnectorIdentity.java
trunk/connector-api/src/main/java/com/metamatrix/connector/pool/ConnectorIdentityFactory.java
trunk/connector-api/src/main/java/com/metamatrix/connector/pool/PoolAwareConnection.java
trunk/connector-api/src/main/java/com/metamatrix/connector/pool/SingleIdentity.java
trunk/connector-api/src/main/java/com/metamatrix/connector/pool/SingleIdentityFactory.java
trunk/connector-api/src/main/java/com/metamatrix/connector/pool/UserIdentity.java
trunk/connector-api/src/main/java/com/metamatrix/connector/pool/UserIdentityFactory.java
trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/AbstractLanguageVisitor.java
trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/HierarchyVisitor.java
trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/CollectorVisitor.java
trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/SQLStringVisitor.java
trunk/connector-api/src/main/java/com/metamatrix/connector/xa/api/XAConnection.java
trunk/connector-api/src/main/java/com/metamatrix/connector/xa/api/XAConnector.java
trunk/connector-api/src/test/java/com/metamatrix/data/pool/TestCredentialMap.java
trunk/connector-api/src/test/java/com/metamatrix/data/transform/TestBasicValueTranslator.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/IndexConnector.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/MetadataProcedureExecution.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectConnection.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectConnector.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectSynchExecution.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/MetadataSearchCriteriaBuilder.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedure.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectQuery.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/TestIndexConnector.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/adapter/FakeObjectConnector.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/adapter/TestObjectConnector.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeRuntimeMetadata.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestConnectorHost.java
trunk/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java
trunk/connector-sdk/src/main/java/com/metamatrix/cdk/IConnectorHost.java
trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCBaseExecution.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCProcedureExecution.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCQueryExecution.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUpdateExecution.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUserIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2ConvertModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyConvertModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/TranslatedCommand.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ConcatFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleConvertModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ssl/JDBCSequeLinkSingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/util/JDBCExecutionHelper.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSourceXAConnection.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCXAConnector.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/access/TestAccessSQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2SqlTranslator.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/mysql/TestMySQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/MockExampleConnectionFactory.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/MockSourceConnection.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/TestPerUserPool.java
trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java
trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java
trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java
trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java
trunk/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java
trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnector.java
trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackExecution.java
trunk/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoopbackExecution.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Util.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/DeleteVisitor.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/ICriteriaVisitor.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/IQueryProvidingVisitor.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java
trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java
trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java
trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java
trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java
trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java
trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestMultiFileTextSynchExecution.java
trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestRowHeaderTextSynchExecution.java
trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnection.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/AbstractCachingConnector.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/AsynchronousDocumentProducer.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/BaseXMLConnectorState.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/CachingConnector.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/DocumentProducer.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/NamedDocumentExecutor.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/SecureConnectorState.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/XMLConnection.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/XMLConnectorState.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/BaseBatchProducer.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/BaseResultsProducer.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/CriteriaDesc.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/DocumentBuilder.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/FileBackedValueReference.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeOrSmallString.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeTextExtractingXmlFilter.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeTextValueReference.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LoggingConnector.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/OutputXPathDesc.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ParameterDescriptor.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/QueryAnalyzer.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/RequestResponseDocumentProducer.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/Response.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/SecureConnectorStateImpl.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/TrustedPayloadBridge.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ValueConvertor.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectionImpl.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnector.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLExecutionImpl.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLExtractor.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/DocumentCache.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/IDocumentCache.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/RequestRecord.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileConnectorState.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileExecutor.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/DefaultTrustDeserializer.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPConnectorState.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPExecutor.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPRequestor.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPTrustDeserializer.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSConnection.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSExecution.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSRequestExecutor.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSSOAPConnectorState.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSXMLConnectorState.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorState.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorStateImpl.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLConnectionFacory.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceConnection.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceConnector.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceExecution.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/file/FileConnection.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/file/FileExecution.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/soap/SoapConnection.java
trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/soap/SoapExecution.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/MockCachingConnector.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/ProxyObjectFactory.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestCriteriaDesc.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestExecutionInfo.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestOutputXPathDesc.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestParameterDescriptor.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestQueryAnalyzer.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestStringBackedValueReference.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnection.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnector.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnectorState.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLExecution.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLExtractor.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/cache/TestCache.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/file/TestFileConnectorState.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/file/TestFileExecutor.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/TestHTTPConnectorState.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/jms/TestJMSConnectorState.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/jms/TestJMSSOAPConnectorState.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/FakeRuntimeMetadata.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/file/TestFileConnection.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/file/TestFileExecution.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/soap/TestSoapConnection.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/soap/TestSoapExecution.java
trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java
trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java
trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java
trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecVisitor.java
trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/FakeExecConnector.java
trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSource.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/command/ObjectCommand.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/command/ProcedureCommand.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseObjectSource.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/value/BasicValueRetriever.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/value/JavaUtilDateValueTranslator.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectExecutionHelper.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialConnector.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialSQLTranslator.java
trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/TickerCollectorVisitor.java
trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java
trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java
trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java
trunk/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistry.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWorkItem.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWrapper.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ExecutionContextImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/TypeFacilityImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CompareCriteriaImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CompoundCriteriaImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/JoinImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageBridgeFactory.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageFactoryImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ParameterImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ElementImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataFactory.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataIDImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataObjectImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterIDImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureIDImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/TypeModelImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPool.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPoolException.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionWrapper.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/PooledConnector.java
trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeConnector.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeProcedureExecution.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestJoinImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestParameterImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionPool.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/SocketVMController.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketClientInstance.java
trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketListener.java
trunk/server/src/main/java/com/metamatrix/platform/vm/controller/VMController.java
trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java
trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServiceInterface.java
trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformDataService.java
trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestCommSockets.java
trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/util/TestJDBCExecutionHelper.java
trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/MockConnector.java
trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataInConnector.java
trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestParams.java
trunk/test-integration/src/test/java/com/metamatrix/data/visitor/util/TestCollectorVisitor.java
trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/FakeXAConnection.java
trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java
Log:
TEIID-351 TEIID-348 TEIID-164 minor fix for ldap lt gt support, removed explicit interfaces for monitoredconnector, repackaged connectorexception, added the use of appropriate generics to connector api.
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connection.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,6 @@
package com.metamatrix.connector.api;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.pool.PoolAwareConnection;
@@ -58,5 +57,12 @@
* using the connection for an execution.
*/
void close();
+
+ /**
+ * Called to determine whether the connection is open
+ * @return true if open, false if there is a source error.
+ */
+ boolean isAlive();
+
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connector.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,6 @@
package com.metamatrix.connector.api;
-import com.metamatrix.connector.exception.ConnectorException;
/**
* <p>The primary entry point for a Connector. This interface should be implemented
@@ -33,8 +32,6 @@
* instantiated, the {@link #initialize(ConnectorEnvironment)} method will be called
* with all necessary connector properties. The {@link #start()} and {@link #stop()}
* methods are lifecycle methods called when starting or stopping the connector.</p>
- *
- * <p>
*/
public interface Connector {
@@ -58,7 +55,8 @@
* with a particular security context. The connection is assumed to be pooled in
* the underlying source if pooling is necessary - the connection will be closed
* when execution has completed against it.
- * @param context The context of the current MetaMatrix user that will be using this connection
+ * @param context The context of the current user that will be using this connection,
+ * may be null if this connection is for an administrative operation.
* @return A Connection, created by the Connector
* @throws ConnectorException If an error occurred obtaining a connection
*/
@@ -67,7 +65,7 @@
/**
* Get the capabilities of this connector. The capabilities affect what kinds of
* queries (and other commands) will be sent to the connector.
- * @return Connector capabilities, may return null if the Connector provides User scoped capabilities {@link Connection#getCapabilities()}
+ * @return ConnectorCapabilities, may return null if the Connector provides User scoped capabilities {@link Connection#getCapabilities()}
*/
ConnectorCapabilities getCapabilities();
Copied: trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorException.java (from rev 468, trunk/connector-api/src/main/java/com/metamatrix/connector/exception/ConnectorException.java)
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorException.java (rev 0)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorException.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -0,0 +1,70 @@
+/*
+ * 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 com.metamatrix.connector.api;
+
+import com.metamatrix.core.MetaMatrixCoreException;
+
+/**
+ * An exception the connector writer can return in case of an
+ * error while using the connector.
+ */
+public class ConnectorException extends MetaMatrixCoreException{
+
+ private static final long serialVersionUID = -5980862789340592219L;
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public ConnectorException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public ConnectorException( String message ) {
+ super( message );
+ }
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param code A code denoting the exception
+ * @param e An exception to nest within this one
+ */
+ public ConnectorException( Throwable e, String message ) {
+ super( e, message );
+ }
+
+ /**
+ * Construct an instance with a linked exception specified.
+ *
+ * @param e An exception to chain to this exception
+ */
+ public ConnectorException( Throwable e ) {
+ super( e );
+ }
+
+}
Property changes on: trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorException.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connector-api/src/main/java/com/metamatrix/connector/api/CredentialMap.java (from rev 468, trunk/connector-api/src/main/java/com/metamatrix/connector/pool/CredentialMap.java)
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/CredentialMap.java (rev 0)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/CredentialMap.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -0,0 +1,376 @@
+/*
+ * 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 com.metamatrix.connector.api;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.metamatrix.connector.DataPlugin;
+import com.metamatrix.core.util.StringUtil;
+
+/**
+ * Allows credentials to be passed on a per user basis to a connector.
+ *
+ * A CredentialsMap object is produced based on information provided in the JDBC
+ * URL. The static method parseCredentials() is used for this purpose.
+ *
+ * This CredentialMap serves as the session "trusted payload".
+ *
+ * It is the responsibility of a Connector to call
+ * {@link ExecutionContext#getTrustedPayload()} to retrieve the CredentialMap.
+ *
+ * The system name should be the same as the Connector Binding Name retrieved from
+ * {@link ConnectorEnvironment#getConnectorName()}.
+ *
+ * To get the keyword/value pairs use getSystemCredentials(systemName), this will
+ * return a Map that contains the properties for the specified system.
+ *
+ * Specific user and password values can be retrieved with
+ * getUser(systemName) and getPassword(systemName)
+ */
+public class CredentialMap implements Serializable {
+ //Parsing keywords for system, user, and password. Comparison is done
+ //ignoring case.
+ public final static String SYSTEM_KEYWORD = "system"; //$NON-NLS-1$
+ public final static String USER_KEYWORD = "user"; //$NON-NLS-1$
+ public final static String PASSWORD_KEYWORD = "password"; //$NON-NLS-1$
+ public final static String ESCAPE_CHAR = "\\"; //$NON-NLS-1$
+ public final static String DEFAULT_SYSTEM = "default"; //$NON-NLS-1$
+
+ private final static String ESCAPE_SLASH = "ESCAPE_SLASH"; // forward slash //$NON-NLS-1$
+ private final static String ESCAPE_COMMA = "ESCAPE_COMMA"; // comma //$NON-NLS-1$
+ private final static String ESCAPE_EQUAL = "ESCAPE_EQUAL"; // equals //$NON-NLS-1$
+// private final static String ESCAPE_SEMI = "ESCAPE_SEMI"; // semicolon
+// private final static String ESCAPE_CLOSE_PAREN = "ESCAPE_CLOSE_PAREN"; // closing paren
+
+
+ private final static String[] escape_chars = {
+ ESCAPE_CHAR + "/", // forward slash //$NON-NLS-1$
+ ESCAPE_CHAR + ",", // comma //$NON-NLS-1$
+ ESCAPE_CHAR + "="}; // equals //$NON-NLS-1$
+// ESCAPE_CHAR + ";", // semicolon
+// ESCAPE_CHAR + ")"}; // closing paren
+
+ private final static String[] escape_strings = {
+ ESCAPE_SLASH, // forward slash
+ ESCAPE_COMMA, // comma
+ ESCAPE_EQUAL }; // equals
+// ESCAPE_SEMI, // semicolon
+// ESCAPE_CLOSE_PAREN }; // closing paren
+
+ /**
+ * In this mode, the CredentialMap will ignore the default credentials
+ * and only credentials set for a system will be exposed. This is the
+ * default setting for the CredentialMap.
+ */
+ public static final short MODE_IGNORE_DEFAULTS = 0;
+
+ /**
+ * In this mode, the default credentials will be returned for any system,
+ * overlaid with any system-specific credentials. If a system is unknown,
+ * all default credentials are returned for that system.
+ */
+ public static final short MODE_USE_DEFAULTS_GLOBALLY = 1;
+
+ /**
+ * In this mode, the default credentials will be returned for any system,
+ * overlaid with any system-specific credentials. If a system is unknown,
+ * the default credentials are NOT used.
+ */
+ public static final short MODE_USE_DEFAULTS_ON_EXISTING = 2;
+
+ /**
+ * The map of map of credentials (keyed by system name, upper case).
+ */
+ private Map map = new HashMap();
+
+ private short defaultCredentialMode = MODE_IGNORE_DEFAULTS;
+ private Map defaultCredentials;
+
+
+ /**
+ * Method to parse a credentials substring extracted from a JDBC URL. The
+ * presumed command line syntax is ...;credentials=(...);...
+ * Only the substring starting and ending with the parentheses is passed to
+ * this method. That is, the first non-blank character must be a '(' and the
+ * last non-blank character must be a ')', or an exception will be thrown.
+ *
+ * Syntax is: (credentialspec1/credentialspec2/.../credentialspecn)
+ *
+ * Any number one or greater of credential specifications may be included,
+ * separated by '/' characters.
+ *
+ * Each credentials spec will be specified in the following way:
+ * Keyword-specified, order-independent name-value pairs of the form
+ * keyword=value. The only required keyword is "system", which must be specified
+ * for each credentials spec, and must have a value corresponding to the name of an EIS
+ * already known to the system.
+ *
+ * Ex: system=sys1,user=sys1un,pass=sys1pw, whatever=somevalue.
+ * Each of the keywords must be unique.
+ *
+ * All blank space is ignored, except within a keyword or value.
+ *
+ * Any syntax error will cause an Exception to be thrown.
+ *
+ * @param inputStr the string to be parsed; first non-blank must be a '(', last non-blank must be a ')'
+ * @return a CredentialMap containing the input
+ * @throws ConnectorException upon any syntax error; descriptive text included
+ */
+ public static CredentialMap parseCredentials(String inputStr) throws ConnectorException {
+
+ for (int i = 0; i < escape_chars.length; i++) {
+ inputStr = StringUtil.replaceAll(inputStr, escape_chars[i], escape_strings[i]);
+ }
+
+ if (inputStr == null) {
+ throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Null_input")); //$NON-NLS-1$
+ }
+
+ inputStr = inputStr.trim();
+
+ CredentialMap credentialMap = new CredentialMap(); // map of maps keyed on system
+ int strLen = inputStr.length();
+
+ //Check that not empty
+
+ if (strLen == 0) {
+ throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Empty_input")); //$NON-NLS-1$
+ }
+
+ //Check that first non-blank char is left paren
+ if (!inputStr.startsWith("(")|| !inputStr.endsWith(")")) { //$NON-NLS-1$ //$NON-NLS-2$
+ throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Missing_parens")); //$NON-NLS-1$
+ }
+
+ // strip of ()'s
+ inputStr = inputStr.substring(1, inputStr.length()-1);
+
+ List credentials = StringUtil.getTokens(inputStr, "/"); //$NON-NLS-1$
+ Iterator credentialIter = credentials.iterator();
+
+ while (credentialIter.hasNext()) {
+ String credential = (String) credentialIter.next();
+
+ // Convert the escaped "/" since we already parsed on the "/"
+ credential = StringUtil.replaceAll(credential, escape_strings[0], "/"); //$NON-NLS-1$
+
+ Map newMap = getCredentialMap(credential.trim());
+ String system = (String) newMap.get(SYSTEM_KEYWORD);
+ if (system == null || system.length() == 0) {
+ throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Missing_system_prop")); //$NON-NLS-1$
+ }
+ credentialMap.addSystemCredentials(system, newMap); // add to Map of Maps.
+ }
+ return credentialMap;
+ }
+
+
+ /**
+ * Takes a string containing key/value pairs.
+ * Example "propName1=propValue1,propName2,propValue2,....."
+ * and returns a map of key/value pairs.
+ */
+ private static Map getCredentialMap(String credential) {
+ List propList = StringUtil.getTokens(credential, ","); //$NON-NLS-1$
+ Iterator propIter = propList.iterator();
+ Map map = new HashMap();
+ while (propIter.hasNext()) {
+ String propVal = (String) propIter.next();
+ List pvList = StringUtil.getTokens(propVal, "="); //$NON-NLS-1$
+ String key = null;
+ String val = null;
+ if (pvList.size() > 0) {
+ key = (String) pvList.get(0);
+ key = key.trim();
+ }
+ if (pvList.size() > 1) {
+ val = (String) pvList.get(1);
+ val = val.trim();
+ // put back the escaped "," and "=" since we already parsed on these.
+ val = StringUtil.replaceAll(val, escape_strings[1], ","); //$NON-NLS-1$
+ val = StringUtil.replaceAll(val, escape_strings[2], "="); //$NON-NLS-1$
+ }
+ map.put(key,val);
+ }
+ return map;
+ }
+
+ public CredentialMap() {
+ super();
+ }
+
+ /**
+ * Method to return an array of systems that have been added to this
+ * CredentialMap.
+ *
+ * @return array of the systems that have been added using addSystemCredentials() - always uppercase
+ */
+ public String[] getSystems() {
+ Set keySet = map.keySet();
+ String[] keys = new String[keySet.size()];
+ Iterator it = keySet.iterator();
+ for (int i = 0; it.hasNext(); i++) {
+ keys[i] = (String)it.next();
+ }
+ return keys;
+ }
+
+ /**
+ * Method to add a user name and credentials (e.g. password) for a system
+ *
+ * @param system system name corresponding to the user and credentials
+ * @param credentials Map containing name/val pairs
+ */
+ public void addSystemCredentials(String system, Map credentials) {
+ map.put(system.toUpperCase(), credentials);
+ }
+
+ /**
+ * Set the default credentials to use with this credential map. See the
+ * various default credential modes to understand when and how these will
+ * be returned.
+ *
+ * @param defaultCredentials Map of credentials
+ * @since 4.3
+ */
+ public void setDefaultCredentials(Map defaultCredentials) {
+ this.defaultCredentials = defaultCredentials;
+ }
+
+ /**
+ * Set the default credential mode to determine when default credentials should
+ * be returned.
+ *
+ * @param mode The mode
+ * @see #MODE_IGNORE_DEFAULTS
+ * @see #MODE_USE_DEFAULTS_GLOBALLY
+ * @see #MODE_USE_DEFAULTS_ON_EXISTING
+ * @since 4.3
+ */
+ public void setDefaultCredentialMode(short mode) {
+ this.defaultCredentialMode = mode;
+ }
+
+ /**
+ * Method to return the credentials map for a system
+ *
+ * @param systemName system name
+ * @return Map
+ */
+ public Map getSystemCredentials(String systemName) {
+ Map systemCredentials = (Map)map.get(systemName.toUpperCase());
+
+ // If ignoring defaults, return just as is
+ if(this.defaultCredentialMode == MODE_IGNORE_DEFAULTS) {
+ return systemCredentials;
+ }
+
+ // Pre-load the credential set to return with the defaults if
+ // 1. defaults exist
+ // 2. AND using defaults globally
+ // 3. OR (using defaults on existing AND system credentials exist)
+ Map workingMap = null;
+ if(this.defaultCredentials != null &&
+ (this.defaultCredentialMode == MODE_USE_DEFAULTS_GLOBALLY ||
+ (this.defaultCredentialMode == MODE_USE_DEFAULTS_ON_EXISTING &&
+ systemCredentials != null))) {
+
+ workingMap = new HashMap();
+ workingMap.putAll(defaultCredentials);
+ }
+
+ // Apply system credentials over the top if they exist
+ if(systemCredentials != null) {
+ if(workingMap == null) {
+ workingMap = new HashMap();
+ }
+ workingMap.putAll(systemCredentials);
+ }
+
+ return workingMap;
+ }
+
+ /**
+ * Get the user property for the specified system, if it exists. The
+ * user property is defined by the static constant {@link #USER_KEYWORD}.
+ *
+ * @param systemName The system to look up (case insensitive)
+ * @return The user name for this system if the system was found and the system had a user property
+ * @since 4.3
+ */
+ public String getUser(String systemName) {
+ Map credentials = getSystemCredentials(systemName);
+ if(credentials != null) {
+ return (String) credentials.get(USER_KEYWORD);
+ }
+
+ return null;
+ }
+
+ /**
+ * Get the password property for the specified system, if it exists. The
+ * password property is defined by the static constant {@link #PASSWORD_KEYWORD}.
+ *
+ * @param systemName The system to look up (case insensitive)
+ * @return The password for this system if the system was found and the system had a password property
+ * @since 4.3
+ */
+ public String getPassword(String systemName) {
+ Map credentials = getSystemCredentials(systemName);
+ if(credentials != null) {
+ return (String) credentials.get(PASSWORD_KEYWORD);
+ }
+
+ return null;
+ }
+
+ public String toString() {
+ StringBuffer b = new StringBuffer();
+ String[] systems = this.getSystems();
+ for (int i=0; i < systems.length; i++) {
+ String system = systems[i];
+ Map map = this.getSystemCredentials(system);
+ b.append("\n"); //$NON-NLS-1$
+ b.append(system);
+ b.append("\n"); //$NON-NLS-1$
+ Iterator iter = map.keySet().iterator();
+ while (iter.hasNext()) {
+ Object key = iter.next();
+ b.append("\t"); //$NON-NLS-1$
+ b.append(key);
+ b.append("="); //$NON-NLS-1$
+ b.append(map.get(key));
+ b.append("\n"); //$NON-NLS-1$
+ }
+ }
+ return b.toString();
+ }
+
+}//end CredentialMap
+
+
Property changes on: trunk/connector-api/src/main/java/com/metamatrix/connector/api/CredentialMap.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/DataNotAvailableException.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/DataNotAvailableException.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/DataNotAvailableException.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -1,9 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
package com.metamatrix.connector.api;
-import com.metamatrix.connector.exception.ConnectorException;
-
+/**
+ * Used by asynch connectors to indicate data is not available
+ * and results should be polled for after the given delay.
+ */
public class DataNotAvailableException extends ConnectorException {
+ private static final long serialVersionUID = 5569111182915674334L;
+
private long retryDelay = 0;
public DataNotAvailableException() {
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/Execution.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/Execution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/Execution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,10 +22,6 @@
package com.metamatrix.connector.api;
-import java.util.List;
-
-import com.metamatrix.connector.exception.ConnectorException;
-
/**
* An execution represents the state and lifecycle for a particular
* command execution. The methods provided on this interface define
@@ -54,10 +50,4 @@
*/
void execute() throws ConnectorException;
- /**
- * Get and clear the warnings for this execution. Will be called
- * each time results are retrieved.
- * @return a List of ConnectorExceptions or null if there are no warnings
- */
- List<Exception> getWarnings();
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/ExecutionContext.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/ExecutionContext.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/ExecutionContext.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -152,5 +152,11 @@
* @return the Connector batch size.
*/
int getBatchSize();
+
+ /**
+ * Add an exception as a warning to this Execution.
+ * @param ex
+ */
+ void addWarning(Exception ex);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/ProcedureExecution.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/ProcedureExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/ProcedureExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,6 @@
package com.metamatrix.connector.api;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IParameter;
/**
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/ResultSetExecution.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/ResultSetExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/ResultSetExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,13 +24,12 @@
import java.util.List;
-import com.metamatrix.connector.exception.ConnectorException;
/**
*/
public interface ResultSetExecution extends Execution {
- List next() throws ConnectorException, DataNotAvailableException;
+ List<?> next() throws ConnectorException, DataNotAvailableException;
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/TypeFacility.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/TypeFacility.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/TypeFacility.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,6 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.types.MMJDBCSQLTypeInfo;
-import com.metamatrix.connector.exception.ConnectorException;
/**
*/
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/UpdateExecution.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/UpdateExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/UpdateExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,6 @@
package com.metamatrix.connector.api;
-import com.metamatrix.connector.exception.ConnectorException;
/**
* The update execution represents the case where a connector can
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/ValueTranslator.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/ValueTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/ValueTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,17 +24,16 @@
*/
package com.metamatrix.connector.api;
-import com.metamatrix.connector.exception.ConnectorException;
/**
* A ValueTranslator knows how to convert an object value of a given source type
* into a target type.
*/
-public interface ValueTranslator {
+public interface ValueTranslator<S, T> {
- Class getSourceType();
+ Class<S> getSourceType();
- Class getTargetType();
+ Class<T> getTargetType();
- Object translate(Object value, ExecutionContext context) throws ConnectorException;
+ T translate(S value, ExecutionContext context) throws ConnectorException;
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnection.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,18 +23,27 @@
package com.metamatrix.connector.basic;
import com.metamatrix.connector.api.ConnectorCapabilities;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.Execution;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.UpdateExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.language.IQueryCommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.pool.ConnectorIdentity;
import com.metamatrix.connector.pool.PoolAwareConnection;
+/**
+ * Provides a default implementation of a {@link PoolAwareConnection} for a Connector
+ * that supports global capabilities. Extensions of this class should implement
+ * {@link #createProcedureExecution(IProcedure, ExecutionContext, RuntimeMetadata)}
+ * {@link #createResultSetExecution(IProcedure, ExecutionContext, RuntimeMetadata)}
+ * {@link #createUpdateExecution(IProcedure, ExecutionContext, RuntimeMetadata)}
+ * as necessary.
+ */
public abstract class BasicConnection implements PoolAwareConnection {
@Override
@@ -73,6 +82,12 @@
}
@Override
+ public void setConnectorIdentity(ConnectorIdentity context)
+ throws ConnectorException {
+
+ }
+
+ @Override
public ConnectorCapabilities getCapabilities() {
return null;
}
Added: trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java (rev 0)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -0,0 +1,29 @@
+/*
+ * 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 com.metamatrix.connector.basic;
+
+import com.metamatrix.connector.api.Connector;
+
+public abstract class BasicConnector implements Connector {
+
+}
Property changes on: trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicExecution.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,31 +22,8 @@
package com.metamatrix.connector.basic;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
import com.metamatrix.connector.api.Execution;
public abstract class BasicExecution implements Execution {
- private List<Exception> warnings = new LinkedList<Exception>();
-
- /**
- * Add an exception as a warning to this Execution.
- */
- public void addWarning(Exception ex) {
- if (ex == null) {
- return;
- }
- this.warnings.add(ex);
- }
-
- @Override
- public List<Exception> getWarnings() {
- List<Exception> result = new ArrayList<Exception>(warnings);
- warnings.clear();
- return result;
- }
-
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicValueTranslator.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicValueTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicValueTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,37 +25,41 @@
package com.metamatrix.connector.basic;
import com.metamatrix.connector.DataPlugin;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.api.ValueTranslator;
-import com.metamatrix.connector.exception.ConnectorException;
/**
* BasicValueTranslator can translate between types using the standard {@link TypeFacility}
* transformations.
*/
-public class BasicValueTranslator implements ValueTranslator {
- private Class sourceType;
- private Class targetType;
+public class BasicValueTranslator<S, T> implements ValueTranslator<S, T> {
+ private Class<S> sourceType;
+ private Class<T> targetType;
private TypeFacility typeFacility;
- public BasicValueTranslator(Class sourceType, Class targetType, TypeFacility typeFacility) {
+ public static <S, T> BasicValueTranslator<S, T> createTranslator(Class<S> sourceType, Class<T> targetType, TypeFacility typeFacility) {
+ return new BasicValueTranslator<S, T>(sourceType, targetType, typeFacility);
+ }
+
+ public BasicValueTranslator(Class<S> sourceType, Class<T> targetType, TypeFacility typeFacility) {
this.sourceType = sourceType;
this.targetType = targetType;
this.typeFacility = typeFacility;
}
- public Class getSourceType() {
+ public Class<S> getSourceType() {
return this.sourceType;
}
- public Class getTargetType() {
+ public Class<T> getTargetType() {
return this.targetType;
}
- public Object translate(Object value, ExecutionContext context) throws ConnectorException {
+ public T translate(S value, ExecutionContext context) throws ConnectorException {
if (typeFacility.hasTransformation(sourceType, targetType)) {
- return typeFacility.transformValue(value, sourceType, targetType);
+ return (T)typeFacility.transformValue(value, sourceType, targetType);
}
throw new ConnectorException(DataPlugin.Util.getString("ValueTranslator.no_tranfrom_found", new Object[] {this.sourceType, this.targetType}));
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IBatchedUpdates.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IBatchedUpdates.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IBatchedUpdates.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -36,5 +36,5 @@
* @return a list of IInsert, IUpdate and IDelete commands in this batched update.
* @since 4.2
*/
- List getUpdateCommands();
+ List<ICommand> getUpdateCommands();
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IBulkInsert.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IBulkInsert.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IBulkInsert.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,7 +25,7 @@
import java.util.List;
/**
- * This is a simple variation of insert, where mulitple rows with single insert
+ * This is a simple variation of insert, where multiple rows with single insert
* will be loaded.
*/
public interface IBulkInsert extends IInsert {
@@ -34,11 +34,11 @@
* Get the list of row values for this bulk insert
* @return list; never null
*/
- List getRows();
+ List<List<?>> getRows();
/**
* Set the list of row values for this bulk insert
* @return list; never null
*/
- void setRows(List rows);
+ void setRows(List<List<?>> rows);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICommand.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICommand.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICommand.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,7 +29,4 @@
*/
public interface ICommand extends ILanguageObject {
- //List<List> getPreparedValues();
-
- //void setPreparedValues(List<List>);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICompareCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICompareCriteria.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICompareCriteria.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,13 +28,15 @@
*/
public interface ICompareCriteria extends IPredicateCriteria {
- public static final int EQ = 0;
- public static final int NE = 1;
- public static final int LT = 2;
- public static final int LE = 3;
- public static final int GT = 4;
- public static final int GE = 5;
-
+ public enum Operator {
+ EQ,
+ NE,
+ LT,
+ LE,
+ GT,
+ GE
+ }
+
/**
* Get left expression.
* @return Left expression
@@ -62,24 +64,24 @@
/**
* Get operator from set defined in this interface.
* @return Operator constant
- * @see #EQ
- * @see #NE
- * @see #LT
- * @see #LE
- * @see #GT
- * @see #GE
+ * @see Operator#EQ
+ * @see Operator#NE
+ * @see Operator#LT
+ * @see Operator#LE
+ * @see Operator#GT
+ * @see Operator#GE
*/
- int getOperator();
+ Operator getOperator();
/**
* Set operator from set defined in this interface.
* @param operator Operator constant
- * @see #EQ
- * @see #NE
- * @see #LT
- * @see #LE
- * @see #GT
- * @see #GE
+ * @see Operator#EQ
+ * @see Operator#NE
+ * @see Operator#LT
+ * @see Operator#LE
+ * @see Operator#GT
+ * @see Operator#GE
*/
- void setOperator(int operator);
+ void setOperator(Operator operator);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICompoundCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICompoundCriteria.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICompoundCriteria.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,35 +29,37 @@
*/
public interface ICompoundCriteria extends ILogicalCriteria {
- public static final int AND = 0;
- public static final int OR = 1;
-
+ public enum Operator {
+ AND,
+ OR
+ }
+
/**
* Get operator used to connect these criteria.
* @return Operator constant
- * @see #AND
- * @see #OR
+ * @see Operator#AND
+ * @see Operator#OR
*/
- int getOperator();
+ Operator getOperator();
/**
* Set operator used to connect these criteria.
* @param operator Operator constant
- * @see #AND
- * @see #OR
+ * @see Operator#AND
+ * @see Operator#OR
*/
- void setOperator(int operator);
+ void setOperator(Operator operator);
/**
* Get list of ICriteria combined by this compound criteria.
* @return List of ICriteria
*/
- List getCriteria();
+ List<ICriteria> getCriteria();
/**
* Set list of ICriteria combined by this compound criteria.
* @param criteria List of ICriteria
*/
- void setCriteria(List criteria);
+ void setCriteria(List<ICriteria> criteria);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IFrom.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IFrom.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IFrom.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,12 +33,12 @@
* Get a List of IFromItem in this FROM clause.
* @return List of IFromItem
*/
- List getItems();
+ List<IFromItem> getItems();
/**
* Set a List of IFromItem in this FROM clause.
* @param items List of IFromItem
*/
- void setItems(List items);
+ void setItems(List<IFromItem> items);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IGroupBy.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IGroupBy.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IGroupBy.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,12 +33,12 @@
* Get list of IExpression that the GROUP BY should be grouped on.
* @return List of IExpression
*/
- List getElements();
+ List<IExpression> getElements();
/**
* Set list of IExpression that the GROUP BY should be grouped on.
* @param elements List of IExpression
*/
- void setElements(List elements);
+ void setElements(List<IExpression> elements);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IInCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IInCriteria.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IInCriteria.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,12 +33,12 @@
* Get List of IExpression in the set on the right side of the criteria.
* @return List of IExpression
*/
- List getRightExpressions();
+ List<IExpression> getRightExpressions();
/**
* Set List of IExpression in the set on the right side of the criteria.
* @param expressions List of IExpression
*/
- void setRightExpressions(List expressions);
+ void setRightExpressions(List<IExpression> expressions);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IInsert.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IInsert.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IInsert.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -39,13 +39,13 @@
* Get list of elements being inserted into
* @return List of IElement
*/
- List getElements();
+ List<IElement> getElements();
/**
* Get list of values being inserted
* @return List of ILiteral
*/
- List getValues();
+ List<IExpression> getValues();
/**
* Set group that is being inserted into.
@@ -57,12 +57,12 @@
* Set list of elements being inserted into
* @param elements List of IElement
*/
- void setElements(List elements);
+ void setElements(List<IElement> elements);
/**
* Set list of values being inserted
- * @param values List of ILiteral
+ * @param values List of IExpression
*/
- void setValues(List values);
+ void setValues(List<IExpression> values);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IJoin.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IJoin.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IJoin.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,12 +30,14 @@
*/
public interface IJoin extends IFromItem {
- public static final int INNER_JOIN = 0;
- public static final int CROSS_JOIN = 1;
- public static final int LEFT_OUTER_JOIN = 2;
- public static final int RIGHT_OUTER_JOIN = 3;
- public static final int FULL_OUTER_JOIN = 4;
-
+ public enum JoinType {
+ INNER_JOIN,
+ CROSS_JOIN,
+ LEFT_OUTER_JOIN,
+ RIGHT_OUTER_JOIN,
+ FULL_OUTER_JOIN
+ }
+
/**
* Get the left IFromItem
* @return From item
@@ -51,19 +53,19 @@
/**
* Get join type
* @return Join type
- * @see #INNER_JOIN
- * @see #CROSS_JOIN
- * @see #LEFT_OUTER_JOIN
- * @see #RIGHT_OUTER_JOIN
- * @see #FULL_OUTER_JOIN
+ * @see JoinType#INNER_JOIN
+ * @see JoinType#CROSS_JOIN
+ * @see JoinType#LEFT_OUTER_JOIN
+ * @see JoinType#RIGHT_OUTER_JOIN
+ * @see JoinType#FULL_OUTER_JOIN
*/
- int getJoinType();
+ JoinType getJoinType();
/**
* Return List of CompareCriteria specifying join criteria.
* @return List of CompareCriteria
*/
- List getCriteria();
+ List<ICriteria> getCriteria();
/**
* Set the left IFromItem
@@ -80,17 +82,17 @@
/**
* Set join type
* @param type Join type
- * @see #INNER_JOIN
- * @see #CROSS_JOIN
- * @see #LEFT_OUTER_JOIN
- * @see #RIGHT_OUTER_JOIN
- * @see #FULL_OUTER_JOIN
+ * @see JoinType#INNER_JOIN
+ * @see JoinType#CROSS_JOIN
+ * @see JoinType#LEFT_OUTER_JOIN
+ * @see JoinType#RIGHT_OUTER_JOIN
+ * @see JoinType#FULL_OUTER_JOIN
*/
- void setJoinType(int type);
+ void setJoinType(JoinType type);
/**
* Set List of CompareCriteria specifying join criteria.
- * @param criteria List of CompareCriteria
+ * @param criteria List of Criteria
*/
- void setCriteria(List criteria);
+ void setCriteria(List<ICriteria> criteria);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILanguageFactory.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILanguageFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILanguageFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,6 +24,8 @@
import java.util.List;
+import com.metamatrix.connector.language.ICompoundCriteria.Operator;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.runtime.MetadataID;
/**
@@ -52,7 +54,7 @@
* @param type Data type
* @return New ICaseExpression
*/
- ICaseExpression createCaseExpression(IExpression mainExpression, List whenExpressions, List thenExpressions, IExpression elseExpression, Class type);
+ ICaseExpression createCaseExpression(IExpression mainExpression, List<IExpression> whenExpressions, List<IExpression> thenExpressions, IExpression elseExpression, Class type);
/**
* Create compare criteria.
@@ -61,16 +63,16 @@
* @param rightExpression Right expression
* @return New ICompareCriteria
*/
- ICompareCriteria createCompareCriteria(int operator, IExpression leftExpression, IExpression rightExpression);
+ ICompareCriteria createCompareCriteria(ICompareCriteria.Operator operator, IExpression leftExpression, IExpression rightExpression);
/**
* Create a new ICompoundCriteria
- * @param operator Operator, as defined by {@link ICompoundCriteria#AND} or
- * {@link ICompoundCriteria#OR}
+ * @param operator Operator, as defined by {@link Operator#AND} or
+ * {@link Operator#OR}
* @param innerCriteria List of ICriteria, typically containing two criteria
* @return New ICompoundCriteria
*/
- ICompoundCriteria createCompoundCriteria(int operator, List innerCriteria);
+ ICompoundCriteria createCompoundCriteria(ICompoundCriteria.Operator operator, List<ICriteria> innerCriteria);
/**
* Create a new IDelete.
@@ -102,7 +104,7 @@
* @param items List of IFromItem
* @return New IFrom
*/
- IFrom createFrom(List items);
+ IFrom createFrom(List<IFromItem> items);
/**
* Create new function
@@ -127,7 +129,7 @@
* @param items List of IGroupByItem
* @return New IGroupBy
*/
- IGroupBy createGroupBy(List items);
+ IGroupBy createGroupBy(List<IExpression> items);
/**
* Create new IN criteria
@@ -136,7 +138,7 @@
* @param isNegated True if NOT IN, false for IN
* @return New IInCriteria
*/
- IInCriteria createInCriteria(IExpression leftExpression, List rightExpressions, boolean isNegated);
+ IInCriteria createInCriteria(IExpression leftExpression, List<IExpression> rightExpressions, boolean isNegated);
/**
* Create new inline view
@@ -153,17 +155,16 @@
* @param values List of IExpression (usually ILiteral)
* @return New IInsert
*/
- IInsert createInsert(IGroup group, List columns, List values);
+ IInsert createInsert(IGroup group, List<IElement> columns, List<IExpression> values);
/**
* Create new bulk insert command
* @param group Insert group
* @param columns List of IElement being inserted into
- * @param List of Rows which contain --> List(s) of values, which are usally
- * List of IExpression (usually ILiteral)
+ * @param List of Lists containing the actual values
* @return New IBulkInsert
*/
- IBulkInsert createBulkInsert(IGroup group, List columns, List rows);
+ IBulkInsert createBulkInsert(IGroup group, List<IElement> columns, List<List<Object>> rows);
/**
* Create new IS NULL criteria
@@ -181,7 +182,7 @@
* @param criteria List of ICriteria (considered to be AND'ed together)
* @return New IJoin
*/
- IJoin createJoin(int joinType, IFromItem leftItem, IFromItem rightItem, List criteria);
+ IJoin createJoin(IJoin.JoinType joinType, IFromItem leftItem, IFromItem rightItem, List<ICriteria> criteria);
/**
* Create new LIKE criteria
@@ -213,7 +214,7 @@
* @param items List of IOrderByItem
* @return New IOrderBy
*/
- IOrderBy createOrderBy(List items);
+ IOrderBy createOrderBy(List<IOrderByItem> items);
/**
* Create new ORDER BY item
@@ -233,7 +234,7 @@
* @param metadataReference Metadata identifier reference
* @return New IParameter
*/
- IParameter createParameter(int index, int direction, Object value, Class type, MetadataID metadataReference);
+ IParameter createParameter(int index, Direction direction, Object value, Class type, MetadataID metadataReference);
/**
* Create new procedure
@@ -242,7 +243,7 @@
* @param metadataReference Metadata identifier reference
* @return New IProcedure
*/
- IProcedure createProcedure(String name, List parameters, MetadataID metadataReference);
+ IProcedure createProcedure(String name, List<IParameter> parameters, MetadataID metadataReference);
/**
* Create new query
@@ -273,7 +274,7 @@
* @param type Data type
* @return New ICaseExpression
*/
- ISearchedCaseExpression createSearchedCaseExpression(List whenExpressions, List thenExpressions, IExpression elseExpression, Class type);
+ ISearchedCaseExpression createSearchedCaseExpression(List<IExpression> whenExpressions, List<IExpression> thenExpressions, IExpression elseExpression, Class type);
/**
* Create new SELECT clause
@@ -281,7 +282,7 @@
* @param selectSymbols List of ISelectSymbol
* @return New ISelect
*/
- ISelect createSelect(boolean isDistinct, List selectSymbols);
+ ISelect createSelect(boolean isDistinct, List<ISelectSymbol> selectSymbols);
/**
* Create new select symbol
@@ -299,7 +300,7 @@
* @param subquery Right subquery
* @return New ISubqueryCompareCriteria
*/
- ISubqueryCompareCriteria createSubqueryCompareCriteria(IExpression leftExpression, int operator, int quantifier, IQuery subquery);
+ ISubqueryCompareCriteria createSubqueryCompareCriteria(IExpression leftExpression, ICompareCriteria.Operator operator, ISubqueryCompareCriteria.Quantifier quantifier, IQuery subquery);
/**
* Create new subquery IN criteria
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IOrderBy.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IOrderBy.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IOrderBy.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -38,12 +38,12 @@
* Get list of {@link IOrderByItem}s specifying the ordering of the results.
* @return List of IOrderByItem
*/
- List getItems();
+ List<IOrderByItem> getItems();
/**
* Set list of {@link IOrderByItem}s specifying the ordering of the results.
* @param items List of IOrderByItem
*/
- void setItems(List items);
+ void setItems(List<IOrderByItem> items);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IParameter.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IParameter.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IParameter.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,13 +26,15 @@
* Represents an execution parameter.
*/
public interface IParameter extends ILanguageObject, IMetadataReference {
+
+ public enum Direction {
+ IN,
+ OUT,
+ INOUT,
+ RETURN,
+ RESULT_SET
+ }
- public static final int IN = 0;
- public static final int OUT = 1;
- public static final int INOUT = 2;
- public static final int RETURN = 3;
- public static final int RESULT_SET = 4;
-
/**
* Get index of this parameter in the IExecution.
* @return Index of the parameter
@@ -42,12 +44,12 @@
/**
* Get direction of parameter
* @return Direction
- * @see #IN
- * @see #OUT
- * @see #INOUT
- * @see #RETURN
+ * @see Direction#IN
+ * @see Direction#OUT
+ * @see Direction#INOUT
+ * @see Direction#RETURN
*/
- int getDirection();
+ Direction getDirection();
/**
* Get type of parameter, defined as a Java class. Output result sets will
@@ -84,12 +86,12 @@
/**
* Set direction of parameter
* @param direction Direction
- * @see #IN
- * @see #OUT
- * @see #INOUT
- * @see #RETURN
+ * @see Direction#IN
+ * @see Direction#OUT
+ * @see Direction#INOUT
+ * @see Direction#RETURN
*/
- void setDirection(int direction);
+ void setDirection(Direction direction);
/**
* Set type of parameter, defined as a Java class. Output result sets will
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IProcedure.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IProcedure.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IProcedure.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -40,7 +40,7 @@
* The parameters describe inputs and outputs.
* @return List of IParameter
*/
- List getParameters();
+ List<IParameter> getParameters();
/**
* Sets the name of the procedure.
@@ -53,6 +53,6 @@
* The parameters describe inputs and outputs.
* @param parameters List of IParameter
*/
- void setParameters(List parameters);
+ void setParameters(List<IParameter> parameters);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/ISelect.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/ISelect.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ISelect.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,7 +33,7 @@
* Get List of ISelectSymbol.
* @return List of ISelectSymbol
*/
- List getSelectSymbols();
+ List<ISelectSymbol> getSelectSymbols();
/**
* Determine whether the DISTINCT flag is used in this SELECT.
@@ -45,7 +45,7 @@
* Set List of ISelectSymbol.
* @param symbols List of ISelectSymbol
*/
- void setSelectSymbols(List symbols);
+ void setSelectSymbols(List<ISelectSymbol> symbols);
/**
* Set whether the DISTINCT flag is used in this SELECT.
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/ISubqueryCompareCriteria.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/ISubqueryCompareCriteria.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ISubqueryCompareCriteria.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,16 +29,10 @@
*/
public interface ISubqueryCompareCriteria extends IPredicateCriteria, ISubqueryContainer {
- public static final int EQ = 1;
- public static final int NE = 2;
- public static final int LT = 3;
- public static final int LE = 4;
- public static final int GT = 5;
- public static final int GE = 6;
-
- public static final int SOME = 0;
- public static final int ALL = 1;
-
+ public enum Quantifier {
+ SOME,
+ ALL
+ }
/**
* Get left expression.
* @return Left expression
@@ -55,15 +49,15 @@
* @see #GT
* @see #GE
*/
- int getOperator();
+ ICompareCriteria.Operator getOperator();
/**
* Get quantifier.
* @return Quantifier constant
- * @see #SOME
- * @see #ALL
+ * @see Quantifier#SOME
+ * @see Quantifier#ALL
*/
- int getQuantifier();
+ Quantifier getQuantifier();
/**
* Set left expression.
@@ -81,15 +75,15 @@
* @see #GT
* @see #GE
*/
- void setOperator(int operator);
+ void setOperator(ICompareCriteria.Operator operator);
/**
* Set quantifier.
* @param quantifier Quantifier constant
- * @see #SOME
- * @see #ALL
+ * @see Quantifier#SOME
+ * @see Quantifier#ALL
*/
- void setQuantifier(int quantifier);
+ void setQuantifier(Quantifier quantifier);
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/LanguageUtil.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/LanguageUtil.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/LanguageUtil.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,9 +23,9 @@
package com.metamatrix.connector.language;
import java.util.*;
-import java.util.Collections;
-import java.util.List;
+import com.metamatrix.connector.language.ICompoundCriteria.Operator;
+
/**
* Helpful utility methods to work with language interfaces.
*/
@@ -66,7 +66,7 @@
private static void separateCriteria(ICriteria crit, List parts) {
if(crit instanceof ICompoundCriteria) {
ICompoundCriteria compCrit = (ICompoundCriteria) crit;
- if(compCrit.getOperator() == ICompoundCriteria.AND) {
+ if(compCrit.getOperator() == Operator.AND) {
List subCrits = compCrit.getCriteria();
Iterator iter = subCrits.iterator();
while(iter.hasNext()) {
@@ -97,7 +97,7 @@
return additionalCrit;
} else if(additionalCrit == null) {
return primaryCrit;
- } else if((primaryCrit instanceof ICompoundCriteria) && ((ICompoundCriteria)primaryCrit).getOperator() == ICompoundCriteria.AND) {
+ } else if((primaryCrit instanceof ICompoundCriteria) && ((ICompoundCriteria)primaryCrit).getOperator() == Operator.AND) {
ICompoundCriteria primaryCompound = (ICompoundCriteria) primaryCrit;
primaryCompound.getCriteria().add(additionalCrit);
return primaryCrit;
@@ -105,7 +105,7 @@
List crits = new ArrayList(2);
crits.add(primaryCrit);
crits.add(additionalCrit);
- ICompoundCriteria compCrit = languageFactory.createCompoundCriteria(ICompoundCriteria.AND, crits);
+ ICompoundCriteria compCrit = languageFactory.createCompoundCriteria(Operator.AND, crits);
return compCrit;
}
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Element.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Element.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Element.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
*/
package com.metamatrix.connector.metadata.runtime;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
/**
* Represents an element, such as a column, in runtime metadata.
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataID.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataID.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataID.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
import java.util.List;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
/**
* Represents a runtime metadata identifier.
@@ -52,7 +52,7 @@
* A procedure ID will return the IDs of it's parameters.
* @return List of MetadataID, which may be empty but never null
*/
- List getChildIDs() throws ConnectorException;
+ List<MetadataID> getChildIDs() throws ConnectorException;
/**
* Get the parent ID if one exists
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataObject.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataObject.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataObject.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
import java.util.Properties;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
/**
* Represents a runtime metadata object.
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Parameter.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Parameter.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Parameter.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,7 @@
package com.metamatrix.connector.metadata.runtime;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
/**
* Represents a procedure parameter in the runtime metadata.
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/RuntimeMetadata.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/RuntimeMetadata.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/RuntimeMetadata.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,7 @@
package com.metamatrix.connector.metadata.runtime;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
/**
* Helper methods that can be used to access runtime metadata.
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/TypeModel.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/TypeModel.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/TypeModel.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,7 @@
package com.metamatrix.connector.metadata.runtime;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
/**
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/pool/ConnectorIdentity.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/ConnectorIdentity.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/pool/ConnectorIdentity.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,6 @@
*/
package com.metamatrix.connector.pool;
-import com.metamatrix.connector.api.ExecutionContext;
/**
* Represents the identity of a connection in the pool. Identities are
@@ -33,11 +32,5 @@
* {@link java.lang.Object#hashCode()} methods.
*/
public interface ConnectorIdentity {
-
- /**
- * Get the security context that was used to create this identity.
- * @return The original context
- * @deprecated see {@link ExecutionContext#getConnectorIdentity()}
- */
- ExecutionContext getSecurityContext();
+
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/pool/ConnectorIdentityFactory.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/ConnectorIdentityFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/pool/ConnectorIdentityFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,16 +22,13 @@
package com.metamatrix.connector.pool;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
public interface ConnectorIdentityFactory {
/**
- * Create an identity object based on a security context. This method determines
- * how different security contexts are treated within the connection pool. For
- * example, using a {@link SingleIdentity} specifies that ALL contexts are treated
- * equally and thus use the same pool.
+ * Create an identity object based on a security context.
*
* If single identity is not supported then an exception should be thrown when a
* null context is supplied.
Deleted: trunk/connector-api/src/main/java/com/metamatrix/connector/pool/CredentialMap.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/CredentialMap.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/pool/CredentialMap.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -1,379 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.connector.pool;
-
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.metamatrix.connector.DataPlugin;
-import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
-import com.metamatrix.core.util.StringUtil;
-
-/**
- * Allows credentials to be passed on a per user basis to a connector.
- *
- * A CredentialsMap object is produced based on information provided in the JDBC
- * URL. The static method parseCredentials() is used for this purpose.
- *
- * This CredentialMap serves as the session "trusted payload".
- *
- * It is the responsibility of a Connector to call
- * {@link ExecutionContext#getTrustedPayload()} to retrieve the CredentialMap.
- *
- * The system name should be the same as the Connector Binding Name retrieved from
- * {@link ConnectorEnvironment#getConnectorName()}.
- *
- * To get the keyword/value pairs use getSystemCredentials(systemName), this will
- * return a Map that contains the properties for the specified system.
- *
- * Specific user and password values can be retrieved with
- * getUser(systemName) and getPassword(systemName)
- */
-public class CredentialMap implements Serializable {
- //Parsing keywords for system, user, and password. Comparison is done
- //ignoring case.
- public final static String SYSTEM_KEYWORD = "system"; //$NON-NLS-1$
- public final static String USER_KEYWORD = "user"; //$NON-NLS-1$
- public final static String PASSWORD_KEYWORD = "password"; //$NON-NLS-1$
- public final static String ESCAPE_CHAR = "\\"; //$NON-NLS-1$
- public final static String DEFAULT_SYSTEM = "default"; //$NON-NLS-1$
-
- private final static String ESCAPE_SLASH = "ESCAPE_SLASH"; // forward slash //$NON-NLS-1$
- private final static String ESCAPE_COMMA = "ESCAPE_COMMA"; // comma //$NON-NLS-1$
- private final static String ESCAPE_EQUAL = "ESCAPE_EQUAL"; // equals //$NON-NLS-1$
-// private final static String ESCAPE_SEMI = "ESCAPE_SEMI"; // semicolon
-// private final static String ESCAPE_CLOSE_PAREN = "ESCAPE_CLOSE_PAREN"; // closing paren
-
-
- private final static String[] escape_chars = {
- ESCAPE_CHAR + "/", // forward slash //$NON-NLS-1$
- ESCAPE_CHAR + ",", // comma //$NON-NLS-1$
- ESCAPE_CHAR + "="}; // equals //$NON-NLS-1$
-// ESCAPE_CHAR + ";", // semicolon
-// ESCAPE_CHAR + ")"}; // closing paren
-
- private final static String[] escape_strings = {
- ESCAPE_SLASH, // forward slash
- ESCAPE_COMMA, // comma
- ESCAPE_EQUAL }; // equals
-// ESCAPE_SEMI, // semicolon
-// ESCAPE_CLOSE_PAREN }; // closing paren
-
- /**
- * In this mode, the CredentialMap will ignore the default credentials
- * and only credentials set for a system will be exposed. This is the
- * default setting for the CredentialMap.
- */
- public static final short MODE_IGNORE_DEFAULTS = 0;
-
- /**
- * In this mode, the default credentials will be returned for any system,
- * overlaid with any system-specific credentials. If a system is unknown,
- * all default credentials are returned for that system.
- */
- public static final short MODE_USE_DEFAULTS_GLOBALLY = 1;
-
- /**
- * In this mode, the default credentials will be returned for any system,
- * overlaid with any system-specific credentials. If a system is unknown,
- * the default credentials are NOT used.
- */
- public static final short MODE_USE_DEFAULTS_ON_EXISTING = 2;
-
- /**
- * The map of map of credentials (keyed by system name, upper case).
- */
- private Map map = new HashMap();
-
- private short defaultCredentialMode = MODE_IGNORE_DEFAULTS;
- private Map defaultCredentials;
-
-
- /**
- * Method to parse a credentials substring extracted from a JDBC URL. The
- * presumed command line syntax is ...;credentials=(...);...
- * Only the substring starting and ending with the parentheses is passed to
- * this method. That is, the first non-blank character must be a '(' and the
- * last non-blank character must be a ')', or an exception will be thrown.
- *
- * Syntax is: (credentialspec1/credentialspec2/.../credentialspecn)
- *
- * Any number one or greater of credential specifications may be included,
- * separated by '/' characters.
- *
- * Each credentials spec will be specified in the following way:
- * Keyword-specified, order-independent name-value pairs of the form
- * keyword=value. The only required keyword is "system", which must be specified
- * for each credentials spec, and must have a value corresponding to the name of an EIS
- * already known to the system.
- *
- * Ex: system=sys1,user=sys1un,pass=sys1pw, whatever=somevalue.
- * Each of the keywords must be unique.
- *
- * All blank space is ignored, except within a keyword or value.
- *
- * Any syntax error will cause an Exception to be thrown.
- *
- * @param inputStr the string to be parsed; first non-blank must be a '(', last non-blank must be a ')'
- * @return a CredentialMap containing the input
- * @throws ConnectorException upon any syntax error; descriptive text included
- */
- public static CredentialMap parseCredentials(String inputStr) throws ConnectorException {
-
- for (int i = 0; i < escape_chars.length; i++) {
- inputStr = StringUtil.replaceAll(inputStr, escape_chars[i], escape_strings[i]);
- }
-
- if (inputStr == null) {
- throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Null_input")); //$NON-NLS-1$
- }
-
- inputStr = inputStr.trim();
-
- CredentialMap credentialMap = new CredentialMap(); // map of maps keyed on system
- int strLen = inputStr.length();
-
- //Check that not empty
-
- if (strLen == 0) {
- throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Empty_input")); //$NON-NLS-1$
- }
-
- //Check that first non-blank char is left paren
- if (!inputStr.startsWith("(")|| !inputStr.endsWith(")")) { //$NON-NLS-1$ //$NON-NLS-2$
- throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Missing_parens")); //$NON-NLS-1$
- }
-
- // strip of ()'s
- inputStr = inputStr.substring(1, inputStr.length()-1);
-
- List credentials = StringUtil.getTokens(inputStr, "/"); //$NON-NLS-1$
- Iterator credentialIter = credentials.iterator();
-
- while (credentialIter.hasNext()) {
- String credential = (String) credentialIter.next();
-
- // Convert the escaped "/" since we already parsed on the "/"
- credential = StringUtil.replaceAll(credential, escape_strings[0], "/"); //$NON-NLS-1$
-
- Map newMap = getCredentialMap(credential.trim());
- String system = (String) newMap.get(SYSTEM_KEYWORD);
- if (system == null || system.length() == 0) {
- throw new ConnectorException(DataPlugin.Util.getString("CredentialMap.Missing_system_prop")); //$NON-NLS-1$
- }
- credentialMap.addSystemCredentials(system, newMap); // add to Map of Maps.
- }
- return credentialMap;
- }
-
-
- /**
- * Takes a string containing key/value pairs.
- * Example "propName1=propValue1,propName2,propValue2,....."
- * and returns a map of key/value pairs.
- */
- private static Map getCredentialMap(String credential) {
- List propList = StringUtil.getTokens(credential, ","); //$NON-NLS-1$
- Iterator propIter = propList.iterator();
- Map map = new HashMap();
- while (propIter.hasNext()) {
- String propVal = (String) propIter.next();
- List pvList = StringUtil.getTokens(propVal, "="); //$NON-NLS-1$
- String key = null;
- String val = null;
- if (pvList.size() > 0) {
- key = (String) pvList.get(0);
- key = key.trim();
- }
- if (pvList.size() > 1) {
- val = (String) pvList.get(1);
- val = val.trim();
- // put back the escaped "," and "=" since we already parsed on these.
- val = StringUtil.replaceAll(val, escape_strings[1], ","); //$NON-NLS-1$
- val = StringUtil.replaceAll(val, escape_strings[2], "="); //$NON-NLS-1$
- }
- map.put(key,val);
- }
- return map;
- }
-
- public CredentialMap() {
- super();
- }
-
- /**
- * Method to return an array of systems that have been added to this
- * CredentialMap.
- *
- * @return array of the systems that have been added using addSystemCredentials() - always uppercase
- */
- public String[] getSystems() {
- Set keySet = map.keySet();
- String[] keys = new String[keySet.size()];
- Iterator it = keySet.iterator();
- for (int i = 0; it.hasNext(); i++) {
- keys[i] = (String)it.next();
- }
- return keys;
- }
-
- /**
- * Method to add a user name and credentials (e.g. password) for a system
- *
- * @param system system name corresponding to the user and credentials
- * @param credentials Map containing name/val pairs
- */
- public void addSystemCredentials(String system, Map credentials) {
- map.put(system.toUpperCase(), credentials);
- }
-
- /**
- * Set the default credentials to use with this credential map. See the
- * various default credential modes to understand when and how these will
- * be returned.
- *
- * @param defaultCredentials Map of credentials
- * @since 4.3
- */
- public void setDefaultCredentials(Map defaultCredentials) {
- this.defaultCredentials = defaultCredentials;
- }
-
- /**
- * Set the default credential mode to determine when default credentials should
- * be returned.
- *
- * @param mode The mode
- * @see #MODE_IGNORE_DEFAULTS
- * @see #MODE_USE_DEFAULTS_GLOBALLY
- * @see #MODE_USE_DEFAULTS_ON_EXISTING
- * @since 4.3
- */
- public void setDefaultCredentialMode(short mode) {
- this.defaultCredentialMode = mode;
- }
-
- /**
- * Method to return the credentials map for a system
- *
- * @param systemName system name
- * @return Map
- */
- public Map getSystemCredentials(String systemName) {
- Map systemCredentials = (Map)map.get(systemName.toUpperCase());
-
- // If ignoring defaults, return just as is
- if(this.defaultCredentialMode == MODE_IGNORE_DEFAULTS) {
- return systemCredentials;
- }
-
- // Pre-load the credential set to return with the defaults if
- // 1. defaults exist
- // 2. AND using defaults globally
- // 3. OR (using defaults on existing AND system credentials exist)
- Map workingMap = null;
- if(this.defaultCredentials != null &&
- (this.defaultCredentialMode == MODE_USE_DEFAULTS_GLOBALLY ||
- (this.defaultCredentialMode == MODE_USE_DEFAULTS_ON_EXISTING &&
- systemCredentials != null))) {
-
- workingMap = new HashMap();
- workingMap.putAll(defaultCredentials);
- }
-
- // Apply system credentials over the top if they exist
- if(systemCredentials != null) {
- if(workingMap == null) {
- workingMap = new HashMap();
- }
- workingMap.putAll(systemCredentials);
- }
-
- return workingMap;
- }
-
- /**
- * Get the user property for the specified system, if it exists. The
- * user property is defined by the static constant {@link #USER_KEYWORD}.
- *
- * @param systemName The system to look up (case insensitive)
- * @return The user name for this system if the system was found and the system had a user property
- * @since 4.3
- */
- public String getUser(String systemName) {
- Map credentials = getSystemCredentials(systemName);
- if(credentials != null) {
- return (String) credentials.get(USER_KEYWORD);
- }
-
- return null;
- }
-
- /**
- * Get the password property for the specified system, if it exists. The
- * password property is defined by the static constant {@link #PASSWORD_KEYWORD}.
- *
- * @param systemName The system to look up (case insensitive)
- * @return The password for this system if the system was found and the system had a password property
- * @since 4.3
- */
- public String getPassword(String systemName) {
- Map credentials = getSystemCredentials(systemName);
- if(credentials != null) {
- return (String) credentials.get(PASSWORD_KEYWORD);
- }
-
- return null;
- }
-
- public String toString() {
- StringBuffer b = new StringBuffer();
- String[] systems = this.getSystems();
- for (int i=0; i < systems.length; i++) {
- String system = systems[i];
- Map map = this.getSystemCredentials(system);
- b.append("\n"); //$NON-NLS-1$
- b.append(system);
- b.append("\n"); //$NON-NLS-1$
- Iterator iter = map.keySet().iterator();
- while (iter.hasNext()) {
- Object key = iter.next();
- b.append("\t"); //$NON-NLS-1$
- b.append(key);
- b.append("="); //$NON-NLS-1$
- b.append(map.get(key));
- b.append("\n"); //$NON-NLS-1$
- }
- }
- return b.toString();
- }
-
-}//end CredentialMap
-
-
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/pool/PoolAwareConnection.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/PoolAwareConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/pool/PoolAwareConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,18 +25,13 @@
package com.metamatrix.connector.pool;
import com.metamatrix.connector.api.Connection;
+import com.metamatrix.connector.api.ConnectorException;
/**
* Pooled Connections can optionally implement this interface to provide implementations
* for Connection testing and pool life-cycle events.
*/
public interface PoolAwareConnection extends Connection {
-
- /**
- * Called by the pool to determine whether the connection is open
- * @return True if open, false if closed or failed.
- */
- boolean isAlive();
/**
* Called by the pool to indicate that the connection was returned to the pool.
@@ -44,4 +39,12 @@
*/
void closeCalled();
+ /**
+ * Called by the pool when an existing connection is leased so that the underlying
+ * Connection may have it's identity switched to a different user.
+ * @param identity
+ * @throws ConnectorException
+ */
+ void setConnectorIdentity(ConnectorIdentity identity) throws ConnectorException;
+
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/pool/SingleIdentity.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/SingleIdentity.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/pool/SingleIdentity.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,25 +30,15 @@
* This class represents a single ConnectorIdentity. All the connections are treated the same.
*/
public class SingleIdentity implements ConnectorIdentity {
- private ExecutionContext context;
/**
* Construct with a context
* @param context The context
*/
public SingleIdentity(ExecutionContext context){
- this.context = context;
}
/**
- * Get the original context
- * @return The original context
- */
- public ExecutionContext getSecurityContext() {
- return this.context;
- }
-
- /**
* Return true for everything - all identities are identical.
*/
public boolean equals(Object obj){
@@ -56,9 +46,6 @@
}
public String toString(){
- if (context != null) {
- return "SingleIdentity: atomic-request="+this.context.getRequestIdentifier()+"."+this.context.getPartIdentifier()+"."+this.context.getExecutionCountIdentifier(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
return "SingleIdentity"; //$NON-NLS-1$
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/pool/SingleIdentityFactory.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/SingleIdentityFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/pool/SingleIdentityFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,8 +22,8 @@
package com.metamatrix.connector.pool;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
public class SingleIdentityFactory implements ConnectorIdentityFactory {
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/pool/UserIdentity.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/UserIdentity.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/pool/UserIdentity.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -39,13 +39,6 @@
this.context = context;
}
- /*
- * @see com.metamatrix.data.pool.ConnectorIdentity#getSecurityContext()
- */
- public ExecutionContext getSecurityContext() {
- return this.context;
- }
-
/**
* Implement equals based on the case-insensitive user name.
* @param obj Other identity object
@@ -58,7 +51,7 @@
if (obj instanceof UserIdentity) {
UserIdentity that = (UserIdentity)obj;
- return this.context.getUser().toUpperCase().equals(that.context.getUser().toUpperCase());
+ return this.context.getUser().equals(that.context.getUser());
}
return false;
@@ -68,7 +61,7 @@
* Get hash code, based on user name
*/
public int hashCode(){
- return context.getUser().toUpperCase().hashCode();
+ return context.getUser().hashCode();
}
public String toString(){
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/pool/UserIdentityFactory.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/UserIdentityFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/pool/UserIdentityFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,8 +23,8 @@
package com.metamatrix.connector.pool;
import com.metamatrix.connector.DataPlugin;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
/**
* Segregates connections by user. It is assumed that no single identity
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/AbstractLanguageVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/AbstractLanguageVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/AbstractLanguageVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,9 +23,45 @@
package com.metamatrix.connector.visitor.framework;
import java.util.Collection;
-import java.util.Iterator;
-import com.metamatrix.connector.language.*;
+import com.metamatrix.connector.language.IAggregate;
+import com.metamatrix.connector.language.IBatchedUpdates;
+import com.metamatrix.connector.language.IBulkInsert;
+import com.metamatrix.connector.language.ICaseExpression;
+import com.metamatrix.connector.language.ICompareCriteria;
+import com.metamatrix.connector.language.ICompoundCriteria;
+import com.metamatrix.connector.language.IDelete;
+import com.metamatrix.connector.language.IElement;
+import com.metamatrix.connector.language.IExistsCriteria;
+import com.metamatrix.connector.language.IFrom;
+import com.metamatrix.connector.language.IFunction;
+import com.metamatrix.connector.language.IGroup;
+import com.metamatrix.connector.language.IGroupBy;
+import com.metamatrix.connector.language.IInCriteria;
+import com.metamatrix.connector.language.IInlineView;
+import com.metamatrix.connector.language.IInsert;
+import com.metamatrix.connector.language.IIsNullCriteria;
+import com.metamatrix.connector.language.IJoin;
+import com.metamatrix.connector.language.ILanguageObject;
+import com.metamatrix.connector.language.ILikeCriteria;
+import com.metamatrix.connector.language.ILimit;
+import com.metamatrix.connector.language.ILiteral;
+import com.metamatrix.connector.language.INotCriteria;
+import com.metamatrix.connector.language.IOrderBy;
+import com.metamatrix.connector.language.IOrderByItem;
+import com.metamatrix.connector.language.IParameter;
+import com.metamatrix.connector.language.IProcedure;
+import com.metamatrix.connector.language.IQuery;
+import com.metamatrix.connector.language.IScalarSubquery;
+import com.metamatrix.connector.language.ISearchedCaseExpression;
+import com.metamatrix.connector.language.ISelect;
+import com.metamatrix.connector.language.ISelectSymbol;
+import com.metamatrix.connector.language.ISetClause;
+import com.metamatrix.connector.language.ISetClauseList;
+import com.metamatrix.connector.language.ISetQuery;
+import com.metamatrix.connector.language.ISubqueryCompareCriteria;
+import com.metamatrix.connector.language.ISubqueryInCriteria;
+import com.metamatrix.connector.language.IUpdate;
/**
* Visitor that visits an instance of ILanguageObject and performs an operation
@@ -57,10 +93,10 @@
* can be used by subclasses to visit each ILanguageObject in the Collection
* @param nodes a Collection of ILanguageObjects
*/
- public void visitNodes(Collection nodes) {
+ public void visitNodes(Collection<? extends ILanguageObject> nodes) {
if (nodes != null && nodes.size() > 0) {
- for (Iterator i = nodes.iterator(); i.hasNext();) {
- visitNode((ILanguageObject)i.next());
+ for (ILanguageObject node : nodes) {
+ visitNode(node);
}
}
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/HierarchyVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/HierarchyVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/framework/HierarchyVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -250,8 +250,4 @@
visitNode(obj.getValue());
}
- public void reset() {
-
- }
-
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/CollectorVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/CollectorVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/CollectorVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,27 +33,22 @@
* tree. Each visit method does an instanceof method to check whether the object
* is of the expected type.
*/
-public class CollectorVisitor implements LanguageObjectVisitor {
+public class CollectorVisitor<T> implements LanguageObjectVisitor {
- private Class type;
- private Collection objects;
+ private Class<T> type;
+ private Collection<T> objects = new ArrayList<T>();
- public CollectorVisitor(Class type) {
+ public CollectorVisitor(Class<T> type) {
this.type = type;
- reset();
}
- public void reset() {
- objects= new ArrayList();
- }
-
private void checkInstance(ILanguageObject obj) {
if(type.isInstance(obj)) {
- this.objects.add(obj);
+ this.objects.add((T)obj);
}
}
- public Collection getCollectedObjects() {
+ public Collection<T> getCollectedObjects() {
return this.objects;
}
@@ -314,8 +309,8 @@
* @param object Root of the language object tree
* @return Collection of ILanguageObject of the specified type
*/
- public static Collection collectObjects(Class type, ILanguageObject object) {
- CollectorVisitor visitor = new CollectorVisitor(type);
+ public static <T> Collection<T> collectObjects(Class<T> type, ILanguageObject object) {
+ CollectorVisitor<T> visitor = new CollectorVisitor<T>(type);
DelegatingHierarchyVisitor hierarchyVisitor = new DelegatingHierarchyVisitor(visitor, null);
object.acceptVisitor(hierarchyVisitor);
return visitor.getCollectedObjects();
@@ -328,7 +323,7 @@
* @param object Root of the language object tree
* @return Collection of IElement of the specified type
*/
- public static Collection collectElements(ILanguageObject object) {
+ public static Collection<IElement> collectElements(ILanguageObject object) {
return CollectorVisitor.collectObjects(IElement.class, object);
}
@@ -339,7 +334,7 @@
* @param object Root of the language object tree
* @return Collection of IGroup of the specified type
*/
- public static Collection collectGroups(ILanguageObject object) {
+ public static Collection<IGroup> collectGroups(ILanguageObject object) {
return CollectorVisitor.collectObjects(IGroup.class, object);
}
@@ -350,17 +345,13 @@
* @param object Root of the language object tree
* @return Set of IGroup
*/
- public static Set collectGroupsUsedByElements(ILanguageObject object) {
- Collection elements = CollectorVisitor.collectElements(object);
- Set groups = new HashSet();
- Iterator iter = elements.iterator();
- while(iter.hasNext()) {
- IElement element = (IElement) iter.next();
+ public static Set<IGroup> collectGroupsUsedByElements(ILanguageObject object) {
+ Set<IGroup> groups = new HashSet<IGroup>();
+ for (IElement element : CollectorVisitor.collectElements(object)) {
if(element.getGroup() != null) {
groups.add(element.getGroup());
}
}
-
return groups;
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/SQLStringVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/SQLStringVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/SQLStringVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import java.util.List;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IAggregate;
import com.metamatrix.connector.language.IBulkInsert;
import com.metamatrix.connector.language.ICaseExpression;
@@ -69,6 +69,7 @@
import com.metamatrix.connector.language.ISubqueryCompareCriteria;
import com.metamatrix.connector.language.ISubqueryInCriteria;
import com.metamatrix.connector.language.IUpdate;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
@@ -131,7 +132,7 @@
* by creating a comma-separated list.
* @param items a list of ILanguageObjects
*/
- protected void append(List items) {
+ protected void append(List<? extends ILanguageObject> items) {
if (items != null && items.size() != 0) {
append((ILanguageObject)items.get(0));
for (int i = 1; i < items.size(); i++) {
@@ -276,14 +277,13 @@
append(obj.getLeftExpression());
buffer.append(SPACE);
- final int op = obj.getOperator();
- switch(op) {
- case ICompareCriteria.EQ: buffer.append(EQ); break;
- case ICompareCriteria.GE: buffer.append(GE); break;
- case ICompareCriteria.GT: buffer.append(GT); break;
- case ICompareCriteria.LE: buffer.append(LE); break;
- case ICompareCriteria.LT: buffer.append(LT); break;
- case ICompareCriteria.NE: buffer.append(NE); break;
+ switch(obj.getOperator()) {
+ case EQ: buffer.append(EQ); break;
+ case GE: buffer.append(GE); break;
+ case GT: buffer.append(GT); break;
+ case LE: buffer.append(LE); break;
+ case LT: buffer.append(LT); break;
+ case NE: buffer.append(NE); break;
default: buffer.append(UNDEFINED);
}
buffer.append(SPACE);
@@ -295,10 +295,9 @@
*/
public void visit(ICompoundCriteria obj) {
String opString = null;
- final int op = obj.getOperator();
- switch(op) {
- case ICompoundCriteria.AND: opString = AND; break;
- case ICompoundCriteria.OR: opString = OR; break;
+ switch(obj.getOperator()) {
+ case AND: opString = AND; break;
+ case OR: opString = OR; break;
default: opString = UNDEFINED;
}
@@ -446,7 +445,7 @@
IParameter param = null;
for (int i = 0; i < params.size(); i++) {
param = (IParameter)params.get(i);
- if (param.getDirection() == IParameter.IN || param.getDirection() == IParameter.INOUT) {
+ if (param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT) {
if (i != 0) {
buffer.append(COMMA)
.append(SPACE);
@@ -745,25 +744,24 @@
}
buffer.append(SPACE);
- final int type = obj.getJoinType();
- switch(type) {
- case IJoin.CROSS_JOIN:
+ switch(obj.getJoinType()) {
+ case CROSS_JOIN:
buffer.append(CROSS);
break;
- case IJoin.FULL_OUTER_JOIN:
+ case FULL_OUTER_JOIN:
buffer.append(FULL)
.append(SPACE)
.append(OUTER);
break;
- case IJoin.INNER_JOIN:
+ case INNER_JOIN:
buffer.append(INNER);
break;
- case IJoin.LEFT_OUTER_JOIN:
+ case LEFT_OUTER_JOIN:
buffer.append(LEFT)
.append(SPACE)
.append(OUTER);
break;
- case IJoin.RIGHT_OUTER_JOIN:
+ case RIGHT_OUTER_JOIN:
buffer.append(RIGHT)
.append(SPACE)
.append(OUTER);
@@ -1053,28 +1051,25 @@
append(obj.getLeftExpression());
buffer.append(SPACE);
- final int op = obj.getOperator();
- switch(op) {
- case ISubqueryCompareCriteria.EQ: buffer.append(EQ); break;
- case ISubqueryCompareCriteria.GE: buffer.append(GE); break;
- case ISubqueryCompareCriteria.GT: buffer.append(GT); break;
- case ISubqueryCompareCriteria.LE: buffer.append(LE); break;
- case ISubqueryCompareCriteria.LT: buffer.append(LT); break;
- case ISubqueryCompareCriteria.NE: buffer.append(NE); break;
+ switch(obj.getOperator()) {
+ case EQ: buffer.append(EQ); break;
+ case GE: buffer.append(GE); break;
+ case GT: buffer.append(GT); break;
+ case LE: buffer.append(LE); break;
+ case LT: buffer.append(LT); break;
+ case NE: buffer.append(NE); break;
default: buffer.append(UNDEFINED);
}
buffer.append(SPACE);
switch(obj.getQuantifier()) {
- case ISubqueryCompareCriteria.ALL: buffer.append(ALL); break;
- case ISubqueryCompareCriteria.SOME: buffer.append(SOME); break;
+ case ALL: buffer.append(ALL); break;
+ case SOME: buffer.append(SOME); break;
default: buffer.append(UNDEFINED);
}
buffer.append(SPACE);
buffer.append(LPAREN);
append(obj.getQuery());
buffer.append(RPAREN);
-
-
}
/*
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/xa/api/XAConnection.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/xa/api/XAConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/xa/api/XAConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,7 +27,7 @@
import javax.transaction.xa.XAResource;
import com.metamatrix.connector.api.Connection;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public interface XAConnection extends Connection{
/**
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/xa/api/XAConnector.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/xa/api/XAConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/xa/api/XAConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,7 +25,6 @@
package com.metamatrix.connector.xa.api;
import com.metamatrix.connector.api.*;
-import com.metamatrix.connector.exception.ConnectorException;
public interface XAConnector extends Connector{
@@ -36,7 +35,8 @@
* with a particular security context. The connection is assumed to be pooled in
* the underlying source if pooling is necessary - the connection will be closed
* when execution has completed against it.
- * @param executionContext The context of the current MetaMatrix user that will be using this connection
+ * @param context The context of the current user that will be using this connection,
+ * may be null if this connection is for an administrative operation.
* @param transactionContext The context of the transaction under which the connection will be used. May be null.
* @return A Connection, created by the Connector
* @throws ConnectorException If an error occurred obtaining a connection
Modified: trunk/connector-api/src/test/java/com/metamatrix/data/pool/TestCredentialMap.java
===================================================================
--- trunk/connector-api/src/test/java/com/metamatrix/data/pool/TestCredentialMap.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/test/java/com/metamatrix/data/pool/TestCredentialMap.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,7 +25,7 @@
import java.util.HashMap;
import java.util.Map;
-import com.metamatrix.connector.pool.CredentialMap;
+import com.metamatrix.connector.api.CredentialMap;
import junit.framework.TestCase;
Modified: trunk/connector-api/src/test/java/com/metamatrix/data/transform/TestBasicValueTranslator.java
===================================================================
--- trunk/connector-api/src/test/java/com/metamatrix/data/transform/TestBasicValueTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-api/src/test/java/com/metamatrix/data/transform/TestBasicValueTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,10 +26,10 @@
import org.mockito.Mockito;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.basic.BasicValueTranslator;
-import com.metamatrix.connector.exception.ConnectorException;
/**
@@ -39,7 +39,7 @@
public void testExceptionFromTransform() throws Exception {
- BasicValueTranslator adaptor = new BasicValueTranslator(String.class, Short.class, new FakeTypeFacility());
+ BasicValueTranslator<String, Short> adaptor = BasicValueTranslator.createTranslator(String.class, Short.class, new FakeTypeFacility());
try {
adaptor.translate("mmuuid:blah", Mockito.mock(ExecutionContext.class)); //$NON-NLS-1$
fail("exceptoin expected"); //$NON-NLS-1$
Modified: trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/IndexConnector.java
===================================================================
--- trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/IndexConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/IndexConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,9 +23,9 @@
package com.metamatrix.connector.metadata;
import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.metadata.adapter.ObjectConnector;
import com.metamatrix.connector.metadata.internal.IObjectSource;
import com.metamatrix.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
Modified: trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/MetadataProcedureExecution.java
===================================================================
--- trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/MetadataProcedureExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/MetadataProcedureExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,12 +25,13 @@
import java.util.Iterator;
import java.util.List;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.internal.IObjectSource;
import com.metamatrix.connector.metadata.internal.ObjectProcedure;
import com.metamatrix.connector.metadata.internal.ObjectProcedureProcessor;
@@ -89,7 +90,7 @@
* @since 4.2
*/
public Object getOutputValue(final IParameter parameter) throws ConnectorException {
- if(parameter.getDirection() != IParameter.OUT && parameter.getDirection() != IParameter.INOUT && parameter.getDirection() != IParameter.RETURN){
+ if(parameter.getDirection() != Direction.OUT && parameter.getDirection() != Direction.INOUT && parameter.getDirection() != Direction.RETURN){
throw new ConnectorException(MetadataConnectorPlugin.Util.getString("ObjectProcedureExecution.0")); //$NON-NLS-1$
}
//TODO: Output parameters are not currently handled
Modified: trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectConnection.java
===================================================================
--- trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,11 +23,11 @@
package com.metamatrix.connector.metadata.adapter;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.IQueryCommand;
Modified: trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectConnector.java
===================================================================
--- trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,8 +26,8 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.metadata.internal.IObjectSource;
/**
Modified: trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectSynchExecution.java
===================================================================
--- trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectSynchExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectSynchExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,10 +25,10 @@
import java.util.Iterator;
import java.util.List;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.MetadataConnectorPlugin;
import com.metamatrix.connector.metadata.internal.IObjectQuery;
Modified: trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/MetadataSearchCriteriaBuilder.java
===================================================================
--- trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/MetadataSearchCriteriaBuilder.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/MetadataSearchCriteriaBuilder.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,7 +29,7 @@
import java.util.Map;
import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICompoundCriteria;
import com.metamatrix.connector.language.ICriteria;
@@ -39,6 +39,7 @@
import com.metamatrix.connector.language.ILikeCriteria;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IQuery;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
import com.metamatrix.connector.metadata.MetadataConnectorConstants;
import com.metamatrix.connector.metadata.MetadataConnectorPlugin;
import com.metamatrix.connector.metadata.index.MetadataInCriteria;
@@ -195,7 +196,7 @@
* @since 4.3
*/
private void buildMetadataCompareCriteria(ICompareCriteria criteria) throws ConnectorException {
- Assertion.assertTrue(criteria.getOperator() == ICompareCriteria.EQ, "Only supports equals."); //$NON-NLS-1$
+ Assertion.assertTrue(criteria.getOperator() == Operator.EQ, "Only supports equals."); //$NON-NLS-1$
IExpression ltExpression = criteria.getLeftExpression();
@@ -283,7 +284,7 @@
* @since 4.3
*/
private void buildMetadataCompoundCriteria(ICompoundCriteria compoundCriteria) throws ConnectorException {
- if (compoundCriteria.getOperator() == ICompoundCriteria.AND) {
+ if (compoundCriteria.getOperator() == com.metamatrix.connector.language.ICompoundCriteria.Operator.AND) {
for(final Iterator critIter = compoundCriteria.getCriteria().iterator(); critIter.hasNext();) {
buildMetadataSearchCriteria((ICriteria)critIter.next());
}
Modified: trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedure.java
===================================================================
--- trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedure.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedure.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,11 +29,12 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IMetadataReference;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.MetadataConnectorConstants;
import com.metamatrix.connector.metadata.MetadataConnectorPlugin;
import com.metamatrix.connector.metadata.index.MetadataLiteralCriteria;
@@ -101,11 +102,11 @@
for(final Iterator iter = parameters.iterator(); iter.hasNext();) {
IParameter parameter = (IParameter) iter.next();
// if there is one result set parameter
- if(parameter.getDirection() == IParameter.RESULT_SET) {
+ if(parameter.getDirection() == Direction.RESULT_SET) {
this.resultSetParameter = parameter;
initResultSet();
}
- if(parameter.getDirection() == IParameter.IN || parameter.getDirection() == IParameter.INOUT) {
+ if(parameter.getDirection() == Direction.IN || parameter.getDirection() == Direction.INOUT) {
inParams.add(parameter);
}
}
Modified: trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java
===================================================================
--- trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedureProcessor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -36,7 +36,7 @@
import com.metamatrix.common.types.ClobType;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.common.vdb.api.VDBFile;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.MetadataConnectorConstants;
import com.metamatrix.connector.metadata.ResultsIterator;
import com.metamatrix.core.util.ArgCheck;
Modified: trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectQuery.java
===================================================================
--- trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectQuery.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectQuery.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,7 +27,7 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IExpression;
Modified: trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/TestIndexConnector.java
===================================================================
--- trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/TestIndexConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/TestIndexConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -36,10 +36,10 @@
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.adapter.ObjectConnector;
import com.metamatrix.connector.metadata.internal.IObjectSource;
Modified: trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/adapter/FakeObjectConnector.java
===================================================================
--- trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/adapter/FakeObjectConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/adapter/FakeObjectConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,8 +26,8 @@
import java.util.List;
import java.util.Map;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.metadata.internal.IObjectSource;
public class FakeObjectConnector extends ObjectConnector {
Modified: trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/adapter/TestObjectConnector.java
===================================================================
--- trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/adapter/TestObjectConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/adapter/TestObjectConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,9 +33,9 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.core.MetaMatrixRuntimeException;
Modified: trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeRuntimeMetadata.java
===================================================================
--- trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeRuntimeMetadata.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeRuntimeMetadata.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,7 @@
package com.metamatrix.connector.metadata.internal;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestConnectorHost.java
===================================================================
--- trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestConnectorHost.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestConnectorHost.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,7 +32,7 @@
import com.metamatrix.cdk.IConnectorHost;
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.IndexConnector;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.metadata.runtime.FakeMetadataService;
Modified: trunk/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java
===================================================================
--- trunk/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -54,7 +54,7 @@
import com.metamatrix.common.config.xml.XMLConfigurationImportExportUtility;
import com.metamatrix.common.util.ByteArrayHelper;
import com.metamatrix.connector.api.Connector;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.language.IQuery;
Modified: trunk/connector-sdk/src/main/java/com/metamatrix/cdk/IConnectorHost.java
===================================================================
--- trunk/connector-sdk/src/main/java/com/metamatrix/cdk/IConnectorHost.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-sdk/src/main/java/com/metamatrix/cdk/IConnectorHost.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import java.util.List;
import java.util.Properties;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ICommand;
/**
Modified: trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java
===================================================================
--- trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/ConnectorHost.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -35,12 +35,12 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.Execution;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.UpdateExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCBaseExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCBaseExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCBaseExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,10 +33,10 @@
import java.util.Properties;
import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
@@ -283,7 +283,7 @@
if (logger.isDetailEnabled()) {
logger.logDetail(context.getRequestIdentifier() + " Warning: ", warning); //$NON-NLS-1$
}
- addWarning(toAdd);
+ context.addWarning(toAdd);
}
this.statement.clearWarnings();
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,10 +28,10 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.pool.ConnectorIdentity;
import com.metamatrix.connector.pool.ConnectorIdentityFactory;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCProcedureExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCProcedureExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCProcedureExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,11 +33,11 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ProcedureExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
@@ -46,6 +46,7 @@
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
@@ -124,7 +125,7 @@
Iterator iter = params.iterator();
while(iter.hasNext()){
IParameter param = (IParameter)iter.next();
- if(param.getDirection() == IParameter.RESULT_SET){
+ if(param.getDirection() == Direction.RESULT_SET){
resultSet = param;
break;
}
@@ -164,7 +165,7 @@
Iterator iter = parameters.iterator();
while(iter.hasNext()){
IParameter param = (IParameter)iter.next();
- if(param.getDirection() == IParameter.RETURN){
+ if(param.getDirection() == Direction.RETURN){
paramsIndexes.put(param, new Integer(index++));
break;
}
@@ -173,7 +174,7 @@
iter = parameters.iterator();
while(iter.hasNext()){
IParameter param = (IParameter)iter.next();
- if(param.getDirection() != IParameter.RESULT_SET && param.getDirection() != IParameter.RETURN){
+ if(param.getDirection() != Direction.RESULT_SET && param.getDirection() != Direction.RETURN){
paramsIndexes.put(param, new Integer(index++));
}
}
@@ -184,7 +185,7 @@
* @see com.metamatrix.data.ProcedureExecution#getOutputValue(com.metamatrix.data.language.IParameter)
*/
public Object getOutputValue(IParameter parameter) throws ConnectorException {
- if(parameter.getDirection() != IParameter.OUT && parameter.getDirection() != IParameter.INOUT && parameter.getDirection() != IParameter.RETURN){
+ if(parameter.getDirection() != Direction.OUT && parameter.getDirection() != Direction.INOUT && parameter.getDirection() != Direction.RETURN){
throw new ConnectorException(JDBCPlugin.Util.getString("JDBCProcedureExecution.The_parameter_direction_must_be_out_or_inout_1")); //$NON-NLS-1$
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCQueryExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCQueryExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCQueryExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -38,13 +38,13 @@
import java.util.TimeZone;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.api.ValueTranslator;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSingleIdentityConnectionFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSingleIdentityConnectionFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,9 +30,9 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.pool.SingleIdentityFactory;
/**
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,13 +28,13 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.UpdateExecution;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.language.ICommand;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,8 +32,8 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.internal.ConnectorPropertyNames;
import com.metamatrix.connector.pool.ConnectorIdentity;
import com.metamatrix.connector.pool.ConnectorIdentityFactory;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUpdateExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUpdateExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUpdateExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,11 +29,11 @@
import java.util.List;
import java.util.Properties;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.UpdateExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUserIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUserIdentityConnectionFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUserIdentityConnectionFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,9 +27,9 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.api.CredentialMap;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
-import com.metamatrix.connector.pool.CredentialMap;
import com.metamatrix.connector.pool.UserIdentityFactory;
/**
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,7 +27,7 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
import com.metamatrix.connector.language.ILanguageFactory;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2ConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2ConvertModifier.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2ConvertModifier.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,6 +30,7 @@
import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
import com.metamatrix.connector.jdbc.extension.impl.DropFunctionModifier;
import com.metamatrix.connector.language.*;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
/**
*/
@@ -127,7 +128,7 @@
// AFTER: CASE WHEN booleanExpression = 0 THEN 'false' ELSE 'true' END
ILiteral literalZero = this.langFactory.createLiteral(new Integer(0), TypeFacility.RUNTIME_TYPES.INTEGER);
- ICompareCriteria when = this.langFactory.createCompareCriteria(ICompareCriteria.EQ, expression, literalZero);
+ ICompareCriteria when = this.langFactory.createCompareCriteria(Operator.EQ, expression, literalZero);
List whens = new ArrayList(1);
whens.add(when);
@@ -167,7 +168,7 @@
// BEFORE: convert(stringExpression, boolean)
// AFTER: CASE WHEN stringExpression = 'true' THEN 1 ELSE 0 END
ILiteral literalTrue = this.langFactory.createLiteral("true", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$
- ICompareCriteria when = this.langFactory.createCompareCriteria(ICompareCriteria.EQ, expression, literalTrue);
+ ICompareCriteria when = this.langFactory.createCompareCriteria(Operator.EQ, expression, literalTrue);
List whens = new ArrayList(1);
whens.add(when);
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLConversionVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLConversionVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,6 +26,7 @@
import com.metamatrix.connector.language.IFromItem;
import com.metamatrix.connector.language.IJoin;
import com.metamatrix.connector.language.ILimit;
+import com.metamatrix.connector.language.IJoin.JoinType;
/**
* @since 4.3
@@ -73,8 +74,7 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.connector.language.IJoin)
*/
public void visit(IJoin obj) {
- final int type = obj.getJoinType();
- if(type != IJoin.CROSS_JOIN) {
+ if(obj.getJoinType() != JoinType.CROSS_JOIN) {
super.visit(obj);
return;
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,8 +28,8 @@
import java.util.Map;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyConvertModifier.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyConvertModifier.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,6 +30,7 @@
import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
import com.metamatrix.connector.jdbc.extension.impl.DropFunctionModifier;
import com.metamatrix.connector.language.*;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
/**
*/
@@ -146,7 +147,7 @@
// AFTER: CASE WHEN booleanExpression = 0 THEN 'false' ELSE 'true' END
ILiteral literalZero = this.langFactory.createLiteral(new Integer(0), TypeFacility.RUNTIME_TYPES.INTEGER);
- ICompareCriteria when = this.langFactory.createCompareCriteria(ICompareCriteria.EQ, expression, literalZero);
+ ICompareCriteria when = this.langFactory.createCompareCriteria(Operator.EQ, expression, literalZero);
List whens = new ArrayList(1);
whens.add(when);
@@ -186,7 +187,7 @@
// BEFORE: convert(stringExpression, boolean)
// AFTER: CASE WHEN stringExpression = 'true' THEN 1 ELSE 0 END
ILiteral literalTrue = this.langFactory.createLiteral("true", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$
- ICompareCriteria when = this.langFactory.createCompareCriteria(ICompareCriteria.EQ, expression, literalTrue);
+ ICompareCriteria when = this.langFactory.createCompareCriteria(Operator.EQ, expression, literalTrue);
List whens = new ArrayList(1);
whens.add(when);
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,7 +27,7 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ResultsTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ResultsTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,9 +33,9 @@
import java.util.TimeZone;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
/**
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLConversionVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLConversionVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -52,6 +52,7 @@
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.IUpdate;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.visitor.util.SQLStringVisitor;
/**
@@ -393,7 +394,7 @@
Iterator iter = params.iterator();
while(iter.hasNext()){
IParameter param = (IParameter)iter.next();
- if(param.getDirection() == IParameter.RETURN){
+ if(param.getDirection() == Direction.RETURN){
needQuestionMark = true;
break;
}
@@ -413,7 +414,7 @@
iter = params.iterator();
while(iter.hasNext()){
IParameter param = (IParameter)iter.next();
- if(param.getDirection() == IParameter.IN || param.getDirection() == IParameter.OUT || param.getDirection() == IParameter.INOUT){
+ if(param.getDirection() == Direction.IN || param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){
if(numberOfParameters > 0){
prepareCallBuffer.append(","); //$NON-NLS-1$
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,8 +27,8 @@
import java.util.Map;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/TranslatedCommand.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/TranslatedCommand.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/TranslatedCommand.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,14 +24,12 @@
*/
package com.metamatrix.connector.jdbc.extension;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.ILiteral;
@@ -131,10 +129,7 @@
* @return
*/
private boolean hasBindValue(ICommand command) {
- Collection literals = CollectorVisitor.collectObjects(ILiteral.class, command);
-
- for (Iterator i = literals.iterator(); i.hasNext();) {
- ILiteral l = (ILiteral)i.next();
+ for (ILiteral l : CollectorVisitor.collectObjects(ILiteral.class, command)) {
if (l.isBindValue() || isBindEligible(l)) {
return true;
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicResultsTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicResultsTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -36,9 +36,9 @@
import java.util.TimeZone;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.internal.ConnectorPropertyNames;
import com.metamatrix.connector.jdbc.JDBCPropertyNames;
import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
@@ -46,6 +46,7 @@
import com.metamatrix.connector.jdbc.extension.ValueRetriever;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IParameter;
+import com.metamatrix.connector.language.IParameter.Direction;
/**
*/
@@ -110,7 +111,7 @@
Iterator iter = params.iterator();
while(iter.hasNext()){
IParameter param = (IParameter)iter.next();
- if(param.getDirection() == IParameter.RETURN){
+ if(param.getDirection() == Direction.RETURN){
registerSpecificTypeOfOutParameter(statement,param, index++);
}
}
@@ -121,13 +122,13 @@
while(iter.hasNext()){
IParameter param = (IParameter)iter.next();
- if(param.getDirection() == IParameter.INOUT){
+ if(param.getDirection() == Direction.INOUT){
registerSpecificTypeOfOutParameter(statement,param, index);
- }else if(param.getDirection() == IParameter.OUT){
+ }else if(param.getDirection() == Direction.OUT){
registerSpecificTypeOfOutParameter(statement,param, index++);
}
- if(param.getDirection() == IParameter.IN || param.getDirection() == IParameter.INOUT){
+ if(param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT){
bindValue(statement, param.getValue(), param.getType(), index++, cal);
}
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicSQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicSQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,8 +29,8 @@
import java.util.TimeZone;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.JDBCPropertyNames;
import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.SQLTranslator;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,7 +27,7 @@
import java.util.*;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.extension.impl.*;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,7 +27,7 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ConcatFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ConcatFunctionModifier.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ConcatFunctionModifier.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,12 +28,12 @@
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
-import com.metamatrix.connector.language.ICompoundCriteria;
import com.metamatrix.connector.language.ICriteria;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
import com.metamatrix.connector.language.ILiteral;
+import com.metamatrix.connector.language.ICompoundCriteria.Operator;
/**
@@ -81,7 +81,7 @@
} else if (crits.size() == 1) {
crit = (ICriteria)crits.get(0);
} else {
- crit = langFactory.createCompoundCriteria(ICompoundCriteria.OR, crits);
+ crit = langFactory.createCompoundCriteria(Operator.OR, crits);
}
when.add(crit);
List then = Arrays.asList(new IExpression[] {nullValue});
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleConvertModifier.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleConvertModifier.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,9 +25,9 @@
import java.util.Iterator;
import java.util.List;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.FunctionModifier;
import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
import com.metamatrix.connector.jdbc.extension.impl.DropFunctionModifier;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLConversionVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLConversionVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,8 +27,8 @@
import java.sql.Time;
import java.util.Iterator;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.IElement;
@@ -143,14 +143,13 @@
append(leftExpression);
buffer.append(SPACE);
- final int op = obj.getOperator();
- switch(op) {
- case ICompareCriteria.EQ: buffer.append(EQ); break;
- case ICompareCriteria.GE: buffer.append(GE); break;
- case ICompareCriteria.GT: buffer.append(GT); break;
- case ICompareCriteria.LE: buffer.append(LE); break;
- case ICompareCriteria.LT: buffer.append(LT); break;
- case ICompareCriteria.NE: buffer.append(NE); break;
+ switch(obj.getOperator()) {
+ case EQ: buffer.append(EQ); break;
+ case GE: buffer.append(GE); break;
+ case GT: buffer.append(GT); break;
+ case LE: buffer.append(LE); break;
+ case LT: buffer.append(LT); break;
+ case NE: buffer.append(NE); break;
}
buffer.append(SPACE);
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -35,18 +35,17 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
import com.metamatrix.connector.language.ICommand;
-import com.metamatrix.connector.language.ICompareCriteria;
-import com.metamatrix.connector.language.ICompoundCriteria;
import com.metamatrix.connector.language.ICriteria;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IFrom;
+import com.metamatrix.connector.language.IFromItem;
import com.metamatrix.connector.language.IGroup;
import com.metamatrix.connector.language.IInlineView;
import com.metamatrix.connector.language.ILanguageFactory;
@@ -59,6 +58,7 @@
import com.metamatrix.connector.language.ISelect;
import com.metamatrix.connector.language.ISelectSymbol;
import com.metamatrix.connector.language.ISetQuery;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.visitor.util.CollectorVisitor;
import com.metamatrix.connector.visitor.util.SQLStringVisitor;
@@ -129,20 +129,20 @@
IGroup group = languageFactory.createGroup(INLINE_VIEW_ALIAS, null, null);
IElement eleRowNum = languageFactory.createElement(ROWNUM_ALIAS, group, null, TypeFacility.RUNTIME_TYPES.INTEGER);
ILiteral litOffset = languageFactory.createLiteral(new Integer( limit.getRowOffset() ), TypeFacility.RUNTIME_TYPES.INTEGER);
- ICriteria criteria = languageFactory.createCompareCriteria(ICompareCriteria.GT, eleRowNum, litOffset);
+ ICriteria criteria = languageFactory.createCompareCriteria(Operator.GT, eleRowNum, litOffset);
lstCriteria.add( criteria );
}
IGroup group = languageFactory.createGroup(INLINE_VIEW_ALIAS, null, null);
IElement eleRowNum = languageFactory.createElement(ROWNUM_ALIAS, group, null, TypeFacility.RUNTIME_TYPES.INTEGER);
ILiteral litLimit = languageFactory.createLiteral(new Integer( limit.getRowOffset() + limit.getRowLimit() ),TypeFacility.RUNTIME_TYPES.INTEGER);
- ICriteria criteria = languageFactory.createCompareCriteria(ICompareCriteria.LE, eleRowNum, litLimit);
+ ICriteria criteria = languageFactory.createCompareCriteria(Operator.LE, eleRowNum, litLimit);
lstCriteria.add( criteria );
if ( lstCriteria.size() == 1 ) {
criteria = lstCriteria.get( 0 );
} else {
- criteria = languageFactory.createCompoundCriteria(ICompoundCriteria.AND, lstCriteria );
+ criteria = languageFactory.createCompoundCriteria(com.metamatrix.connector.language.ICompoundCriteria.Operator.AND, lstCriteria );
}
IQuery intermediate = createLimitQuery(command, null, true);
@@ -167,7 +167,7 @@
ICriteria criteria, boolean alias) {
IInlineView view = languageFactory.createInlineView(query, INLINE_VIEW_ALIAS);
- IFrom from = languageFactory.createFrom(Arrays.asList(new Object[] {view}));
+ IFrom from = languageFactory.createFrom(Arrays.asList(new IFromItem[] {view}));
LinkedHashMap<String, Class<?>> names = new LinkedHashMap<String, Class<?>>();
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,7 +27,7 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,7 +29,7 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ssl/JDBCSequeLinkSingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ssl/JDBCSequeLinkSingleIdentityConnectionFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ssl/JDBCSequeLinkSingleIdentityConnectionFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,7 +32,7 @@
import java.sql.SQLException;
import java.util.Properties;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.ConnectionQueryStrategy;
import com.metamatrix.connector.jdbc.ConnectionStrategy;
import com.metamatrix.connector.jdbc.JDBCPropertyNames;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,7 +29,7 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
import com.metamatrix.connector.jdbc.extension.impl.BasicSQLTranslator;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/util/JDBCExecutionHelper.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/util/JDBCExecutionHelper.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/util/JDBCExecutionHelper.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,11 +27,11 @@
import java.util.Iterator;
import java.util.List;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.api.ValueTranslator;
import com.metamatrix.connector.basic.BasicValueTranslator;
-import com.metamatrix.connector.exception.ConnectorException;
/**
*/
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -34,8 +34,8 @@
import javax.sql.XAConnection;
import javax.sql.XADataSource;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.JDBCPlugin;
import com.metamatrix.connector.jdbc.JDBCPropertyNames;
import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSourceXAConnection.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSourceXAConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSourceXAConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,7 +32,7 @@
import javax.transaction.xa.XAResource;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.ConnectionListener;
import com.metamatrix.connector.jdbc.ConnectionStrategy;
import com.metamatrix.connector.jdbc.JDBCSourceConnection;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCXAConnector.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCXAConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCXAConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,9 +29,9 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.JDBCConnector;
import com.metamatrix.connector.jdbc.JDBCPropertyNames;
import com.metamatrix.connector.xa.api.TransactionContext;
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/access/TestAccessSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/access/TestAccessSQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/access/TestAccessSQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
import com.metamatrix.connector.language.ICommand;
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2SqlTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2SqlTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,8 +30,8 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
import com.metamatrix.connector.language.ICommand;
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/mysql/TestMySQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/mysql/TestMySQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import junit.framework.TestCase;
import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.MetadataFactory;
import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/postgresql/TestPostgreSQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/postgresql/TestPostgreSQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import junit.framework.TestCase;
import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.MetadataFactory;
import com.metamatrix.connector.jdbc.extension.SQLTranslator;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,7 +29,7 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.MetadataFactory;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import junit.framework.TestCase;
import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.MetadataFactory;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/MockExampleConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/MockExampleConnectionFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/MockExampleConnectionFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import java.util.Properties;
import com.metamatrix.connector.api.Connection;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.JDBCUserIdentityConnectionFactory;
/**
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/MockSourceConnection.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/MockSourceConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/MockSourceConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,18 +22,16 @@
package com.metamatrix.connector.jdbc.userpool;
-import com.metamatrix.connector.api.Connection;
-import com.metamatrix.connector.api.ConnectorCapabilities;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.Execution;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.basic.BasicConnection;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.pool.PoolAwareConnection;
/**
*/
-public class MockSourceConnection implements PoolAwareConnection, Connection {
+public class MockSourceConnection extends BasicConnection {
private String url;
private int transLevel;
@@ -76,18 +74,8 @@
}
@Override
- public ConnectorCapabilities getCapabilities() {
- return null;
- }
-
- @Override
public void close() {
}
- @Override
- public void closeCalled() {
-
- }
-
}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/TestPerUserPool.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/TestPerUserPool.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/TestPerUserPool.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,12 +30,12 @@
import org.mockito.Mockito;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.api.CredentialMap;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.internal.ConnectorPropertyNames;
import com.metamatrix.connector.jdbc.JDBCPropertyNames;
import com.metamatrix.connector.jdbc.JDBCSourceConnectionFactory;
-import com.metamatrix.connector.pool.CredentialMap;
import com.metamatrix.dqp.internal.datamgr.impl.ExecutionContextImpl;
/**
Modified: trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -50,8 +50,8 @@
import javax.naming.ldap.SortKey;
import javax.naming.NamingException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IAggregate;
import com.metamatrix.connector.language.ICaseExpression;
import com.metamatrix.connector.language.ICompareCriteria;
@@ -73,6 +73,7 @@
import com.metamatrix.connector.language.IScalarSubquery;
import com.metamatrix.connector.language.ISearchedCaseExpression;
import com.metamatrix.connector.language.ISelectSymbol;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.Group;
import com.metamatrix.connector.metadata.runtime.MetadataID;
@@ -359,11 +360,11 @@
* @param op operator to evaluate
* @return LDAP-specific string equivalent of the operator
*/
- private String parseCompoundCriteriaOp(int op) throws ConnectorException {
+ private String parseCompoundCriteriaOp(ICompoundCriteria.Operator op) throws ConnectorException {
switch(op) {
- case ICompoundCriteria.AND:
+ case AND:
return "&"; //$NON-NLS-1$
- case ICompoundCriteria.OR:
+ case OR:
return "|"; //$NON-NLS-1$
default:
final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.criteriaNotParsableError"); //$NON-NLS-1$
@@ -469,7 +470,7 @@
// Recursive case: compound criteria
if(criteria instanceof ICompoundCriteria) {
logger.logTrace("Parsing compound criteria."); //$NON-NLS-1$
- int op = ((ICompoundCriteria) criteria).getOperator();
+ ICompoundCriteria.Operator op = ((ICompoundCriteria) criteria).getOperator();
List criteriaList = ((ICompoundCriteria) criteria).getCriteria();
String stringOp = parseCompoundCriteriaOp(op);
@@ -486,7 +487,8 @@
// Base case
} else if(criteria instanceof ICompareCriteria) {
logger.logTrace("Parsing compare criteria."); //$NON-NLS-1$
- int op = ((ICompareCriteria) criteria).getOperator();
+ ICompareCriteria.Operator op = ((ICompareCriteria) criteria).getOperator();
+
IExpression lhs = ((ICompareCriteria) criteria).getLeftExpression();
IExpression rhs = ((ICompareCriteria) criteria).getRightExpression();
@@ -496,8 +498,8 @@
final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.missingNISError"); //$NON-NLS-1$
throw new ConnectorException(msg);
}
+
addCompareCriteriaToList(filterList, op, lhsString, rhsString);
-
// Base case
} else if(criteria instanceof IExistsCriteria) {
logger.logTrace("Parsing EXISTS criteria: NOT IMPLEMENTED YET"); //$NON-NLS-1$
@@ -506,7 +508,7 @@
} else if(criteria instanceof ILikeCriteria) {
logger.logTrace("Parsing LIKE criteria."); //$NON-NLS-1$
// Convert LIKE to Equals, where any "%" symbol is replaced with "*".
- int op = ICompareCriteria.EQ;
+ ICompareCriteria.Operator op = Operator.EQ;
IExpression lhs = ((ILikeCriteria) criteria).getLeftExpression();
IExpression rhs = ((ILikeCriteria) criteria).getRightExpression();
@@ -536,10 +538,10 @@
return;
}
filterList.add("("); //$NON-NLS-1$
- filterList.add(parseCompoundCriteriaOp(ICompoundCriteria.OR));
+ filterList.add(parseCompoundCriteriaOp(com.metamatrix.connector.language.ICompoundCriteria.Operator.OR));
Iterator rhsItr = rhsList.iterator();
while(rhsItr.hasNext()) {
- addCompareCriteriaToList(filterList, ICompareCriteria.EQ, getExpressionString(lhs),
+ addCompareCriteriaToList(filterList, Operator.EQ, getExpressionString(lhs),
getExpressionString((IExpression)rhsItr.next()));
}
filterList.add(")"); //$NON-NLS-1$
@@ -552,11 +554,11 @@
* @param lhs left hand side expression
* @param rhs right hand side expression
*/
- private void addCompareCriteriaToList(List filterList, int op, String lhs, String rhs) throws ConnectorException {
+ private void addCompareCriteriaToList(List filterList, ICompareCriteria.Operator op, String lhs, String rhs) throws ConnectorException {
// Push the comparison statement into the list, e.g.:
// (sn=Mike)
// !(empNum>=100)
- if(op == ICompareCriteria.NE) {
+ if(op == Operator.NE || op == Operator.GT || op == Operator.LT) {
filterList.add("("); //$NON-NLS-1$
filterList.add("!"); //$NON-NLS-1$
}
@@ -564,26 +566,18 @@
filterList.add(lhs);
switch(op) {
- case ICompareCriteria.EQ:
+ case NE:
+ case EQ:
filterList.add("="); //$NON-NLS-1$
break;
- case ICompareCriteria.GE:
+ case LT:
+ case GE:
filterList.add(">="); //$NON-NLS-1$
break;
- // Arguably, this is not correct, but LDAP doesn't support GT, and
- // we want to support pushdown in this case, to make things uniform.
- case ICompareCriteria.GT:
- filterList.add(">="); //$NON-NLS-1$
- break;
- case ICompareCriteria.LE:
+ case GT:
+ case LE:
filterList.add("<="); //$NON-NLS-1$
break;
- case ICompareCriteria.LT:
- filterList.add("<="); //$NON-NLS-1$
- break;
- case ICompareCriteria.NE:
- filterList.add("="); //$NON-NLS-1$
- break;
default:
final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.criteriaNotSupportedError"); //$NON-NLS-1$
throw new ConnectorException(msg);
@@ -591,7 +585,7 @@
}
filterList.add(rhs);
filterList.add(")"); //$NON-NLS-1$
- if(op == ICompareCriteria.NE) {
+ if(op == Operator.NE || op == Operator.GT || op == Operator.LT) {
filterList.add(")"); //$NON-NLS-1$
}
}
Modified: trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java
===================================================================
--- trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,12 +29,12 @@
import javax.naming.NamingException;
import javax.naming.ldap.InitialLdapContext;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.UpdateExecution;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.IQueryCommand;
Modified: trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java
===================================================================
--- trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,9 +27,9 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
/**
* LDAPConnector. This is responsible for initializing
Modified: trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java
===================================================================
--- trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -94,12 +94,11 @@
import javax.naming.ldap.SortControl;
import javax.naming.ldap.SortKey;
-import com.metamatrix.connector.api.ConnectorCapabilities;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java
===================================================================
--- trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,12 +33,12 @@
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.UpdateExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICriteria;
@@ -49,6 +49,7 @@
import com.metamatrix.connector.language.ILiteral;
import com.metamatrix.connector.language.ISetClause;
import com.metamatrix.connector.language.IUpdate;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
@@ -368,7 +369,7 @@
throw new ConnectorException(msg);
}
ICompareCriteria compareCriteria = (ICompareCriteria)criteria;
- if (compareCriteria.getOperator() != ICompareCriteria.EQ) {
+ if (compareCriteria.getOperator() != Operator.EQ) {
final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaNotEqualsError"); //$NON-NLS-1$
throw new ConnectorException(msg);
}
Modified: trunk/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -35,6 +35,7 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.SysLogger;
import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IQuery;
@@ -90,8 +91,8 @@
SortKey[] sortKeys = searchDetails.getSortKeys();
// Compare actual with Expected
- assertEquals(contextName, expectedContextName);
- assertEquals(contextFilter, expectedContextFilter);
+ assertEquals(expectedContextName, contextName);
+ assertEquals(expectedContextFilter, contextFilter);
assertEquals(attrList.size(),expectedAttrNameList.size());
Iterator iter = attrList.iterator();
@@ -102,25 +103,16 @@
assertEquals(actualName, expectedName);
}
- assertEquals(countLimit, expectedCountLimit);
- assertEquals(searchScope, expectedSearchScope);
- assertEquals(sortKeys, expectedSortKeys);
+ assertEquals(expectedCountLimit, countLimit);
+ assertEquals(expectedSearchScope, searchScope);
+ assertEquals(expectedSortKeys, sortKeys);
}
/**
* Test a Query without criteria
*/
public void testSelectFrom1() throws Exception {
- ConnectorLogger logger = new SysLogger(false);
- QueryMetadataInterface metadata = exampleLdap();
- RuntimeMetadata rm = new MetadataFactory(metadata).createRuntimeMetadata();
- Properties props = new Properties();
-
- IQueryToLdapSearchParser searchParser = new IQueryToLdapSearchParser(logger,rm,props);
-
- IQuery query = (IQuery)getCommand("SELECT UserID, Name FROM LdapModel.People", metadata); //$NON-NLS-1$
-
- LDAPSearchDetails searchDetails = searchParser.translateSQLQueryToLDAPSearch(query);
+ LDAPSearchDetails searchDetails = helpGetSearchDetails("SELECT UserID, Name FROM LdapModel.People"); //$NON-NLS-1$
//-----------------------------------
// Set Expected SearchDetails Values
@@ -145,16 +137,7 @@
* Test a Query with a criteria
*/
public void testSelectFromWhere1() throws Exception {
- ConnectorLogger logger = new SysLogger(false);
- QueryMetadataInterface metadata = exampleLdap();
- RuntimeMetadata rm = new MetadataFactory(metadata).createRuntimeMetadata();
- Properties props = new Properties();
-
- IQueryToLdapSearchParser searchParser = new IQueryToLdapSearchParser(logger,rm,props);
-
- IQuery query = (IQuery)getCommand("SELECT UserID, Name FROM LdapModel.People WHERE Name = 'R%'", metadata); //$NON-NLS-1$
-
- LDAPSearchDetails searchDetails = searchParser.translateSQLQueryToLDAPSearch(query);
+ LDAPSearchDetails searchDetails = helpGetSearchDetails("SELECT UserID, Name FROM LdapModel.People WHERE Name = 'R%'"); //$NON-NLS-1$
//-----------------------------------
// Set Expected SearchDetails Values
@@ -175,7 +158,63 @@
}
+ public void testGT() throws Exception {
+ LDAPSearchDetails searchDetails = helpGetSearchDetails("SELECT UserID, Name FROM LdapModel.People WHERE Name > 'R'"); //$NON-NLS-1$
+
+ //-----------------------------------
+ // Set Expected SearchDetails Values
+ //-----------------------------------
+ String expectedContextName = "ou=people,dc=metamatrix,dc=com"; //$NON-NLS-1$
+ String expectedContextFilter = "(!(cn<=R))"; //$NON-NLS-1$
+
+ List expectedAttrNameList = new ArrayList();
+ expectedAttrNameList.add("uid"); //$NON-NLS-1$
+ expectedAttrNameList.add("cn"); //$NON-NLS-1$
+
+ long expectedCountLimit = -1;
+ int expectedSearchScope = SearchControls.ONELEVEL_SCOPE;
+ SortKey[] expectedSortKeys = null;
+
+ helpTestSearchDetails(searchDetails, expectedContextName, expectedContextFilter, expectedAttrNameList,
+ expectedCountLimit, expectedSearchScope, expectedSortKeys);
+ }
+ public void testLT() throws Exception {
+ LDAPSearchDetails searchDetails = helpGetSearchDetails("SELECT UserID, Name FROM LdapModel.People WHERE Name < 'R'"); //$NON-NLS-1$
+
+ //-----------------------------------
+ // Set Expected SearchDetails Values
+ //-----------------------------------
+ String expectedContextName = "ou=people,dc=metamatrix,dc=com"; //$NON-NLS-1$
+ String expectedContextFilter = "(!(cn>=R))"; //$NON-NLS-1$
+
+ List expectedAttrNameList = new ArrayList();
+ expectedAttrNameList.add("uid"); //$NON-NLS-1$
+ expectedAttrNameList.add("cn"); //$NON-NLS-1$
+
+ long expectedCountLimit = -1;
+ int expectedSearchScope = SearchControls.ONELEVEL_SCOPE;
+ SortKey[] expectedSortKeys = null;
+
+ helpTestSearchDetails(searchDetails, expectedContextName, expectedContextFilter, expectedAttrNameList,
+ expectedCountLimit, expectedSearchScope, expectedSortKeys);
+ }
+
+ private LDAPSearchDetails helpGetSearchDetails(String queryString) throws ConnectorException {
+ ConnectorLogger logger = new SysLogger(false);
+ QueryMetadataInterface metadata = exampleLdap();
+ RuntimeMetadata rm = new MetadataFactory(metadata).createRuntimeMetadata();
+ Properties props = new Properties();
+
+ IQueryToLdapSearchParser searchParser = new IQueryToLdapSearchParser(logger,rm,props);
+
+ IQuery query = (IQuery)getCommand(queryString, metadata);
+
+ LDAPSearchDetails searchDetails = searchParser.translateSQLQueryToLDAPSearch(query);
+ return searchDetails;
+ }
+
+
public static FakeMetadataFacade exampleLdap() {
// Create models
FakeMetadataObject ldapModel = FakeMetadataFactory.createPhysicalModel("LdapModel"); //$NON-NLS-1$
Modified: trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java
===================================================================
--- trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,7 +23,7 @@
package com.metamatrix.connector.loopback;
import com.metamatrix.connector.api.*;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.basic.BasicConnection;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
@@ -31,7 +31,7 @@
* Serves as a connection for the Loopback connector. Since there is no actual
* data source, this "connection" doesn't really have any state.
*/
-public class LoopbackConnection implements Connection {
+public class LoopbackConnection extends BasicConnection {
private ConnectorEnvironment env;
@@ -42,14 +42,6 @@
this.env = env;
}
- /*
- * @see com.metamatrix.data.Connection#getCapabilities()
- */
- public ConnectorCapabilities getCapabilities() {
- return null;
- }
-
-
@Override
public Execution createExecution(ICommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
Modified: trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnector.java
===================================================================
--- trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,7 +23,6 @@
package com.metamatrix.connector.loopback;
import com.metamatrix.connector.api.*;
-import com.metamatrix.connector.exception.ConnectorException;
/**
* Starting point for the Loopback connector.
Modified: trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackExecution.java
===================================================================
--- trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -35,12 +35,12 @@
import java.util.Random;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.api.UpdateExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IQueryCommand;
Modified: trunk/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoopbackExecution.java
===================================================================
--- trunk/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoopbackExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoopbackExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,7 +32,7 @@
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public class TestLoopbackExecution extends TestCase {
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,13 +29,13 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
+import com.metamatrix.connector.api.CredentialMap;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.pool.ConnectorIdentity;
import com.metamatrix.connector.pool.ConnectorIdentityFactory;
-import com.metamatrix.connector.pool.CredentialMap;
import com.metamatrix.connector.pool.SingleIdentityFactory;
import com.metamatrix.connector.pool.UserIdentityFactory;
import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/ConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,8 +25,8 @@
import java.net.URL;
import java.util.Properties;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
public class ConnectorState {
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Util.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Util.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Util.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public class Util {
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,11 +25,11 @@
import java.util.List;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.UpdateExecution;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IQueryCommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/impl/ConnectionImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -37,8 +37,8 @@
import org.apache.axis.transport.http.CommonsHTTPSender;
import org.apache.axis.transport.http.HTTPTransport;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.salesforce.execution.DataPayload;
import com.sforce.soap.partner.CallOptions;
import com.sforce.soap.partner.DeleteResult;
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/DeleteExecutionImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -21,7 +21,7 @@
*/
package com.metamatrix.connector.salesforce.execution;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IDelete;
import com.metamatrix.connector.salesforce.execution.visitors.DeleteVisitor;
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/InsertExecutionImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,7 @@
package com.metamatrix.connector.salesforce.execution;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IInsert;
import com.metamatrix.connector.salesforce.execution.visitors.InsertVisitor;
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,12 +32,12 @@
import org.apache.axis.message.MessageElement;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQueryCommand;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import org.apache.axis.message.MessageElement;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.ILiteral;
import com.metamatrix.connector.language.ISetClause;
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionParent.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,11 +24,11 @@
import java.util.ArrayList;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.UpdateExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICriteria;
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IExpression;
@@ -37,6 +37,7 @@
import com.metamatrix.connector.language.IInCriteria;
import com.metamatrix.connector.language.ILikeCriteria;
import com.metamatrix.connector.language.ILiteral;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.Group;
import com.metamatrix.connector.metadata.runtime.MetadataID;
@@ -67,7 +68,7 @@
protected static final String CLOSE = ")";
protected RuntimeMetadata metadata;
- private HashMap<Integer, String> comparisonOperators;
+ private HashMap<ICompareCriteria.Operator, String> comparisonOperators;
protected List<String> criteriaList = new ArrayList<String>();
protected boolean hasCriteria;
protected Map<String, Element> columnElementsByName = new HashMap<String, Element>();
@@ -77,13 +78,13 @@
public CriteriaVisitor(RuntimeMetadata metadata) {
this.metadata = metadata;
- comparisonOperators = new HashMap<Integer, String>();
- comparisonOperators.put(ICompareCriteria.EQ, "=");
- comparisonOperators.put(ICompareCriteria.GE, ">=");
- comparisonOperators.put(ICompareCriteria.GT, ">");
- comparisonOperators.put(ICompareCriteria.LE, "<=");
- comparisonOperators.put(ICompareCriteria.LT, "<");
- comparisonOperators.put(ICompareCriteria.NE, "!=");
+ comparisonOperators = new HashMap<ICompareCriteria.Operator, String>();
+ comparisonOperators.put(Operator.EQ, "=");
+ comparisonOperators.put(Operator.GE, ">=");
+ comparisonOperators.put(Operator.GT, ">");
+ comparisonOperators.put(Operator.LE, "<=");
+ comparisonOperators.put(Operator.LT, "<");
+ comparisonOperators.put(Operator.NE, "!=");
}
@Override
@@ -91,7 +92,7 @@
super.visit(criteria);
try {
addCompareCriteria(criteriaList, criteria);
- boolean isAcceptableID = (ICompareCriteria.EQ == criteria.getOperator() &&
+ boolean isAcceptableID = (Operator.EQ == criteria.getOperator() &&
isIdColumn(criteria.getLeftExpression()));
setHasCriteria(true, isAcceptableID);
} catch (ConnectorException e) {
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/DeleteVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/DeleteVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/DeleteVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,7 +23,7 @@
import java.util.Iterator;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IDelete;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/ICriteriaVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/ICriteriaVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/ICriteriaVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -21,7 +21,7 @@
*/
package com.metamatrix.connector.salesforce.execution.visitors;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public interface ICriteriaVisitor {
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/IQueryProvidingVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/IQueryProvidingVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/IQueryProvidingVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -21,7 +21,7 @@
*/
package com.metamatrix.connector.salesforce.execution.visitors;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public interface IQueryProvidingVisitor extends ICriteriaVisitor {
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,8 +28,9 @@
import org.apache.axis.message.MessageElement;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IElement;
+import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IInsert;
import com.metamatrix.connector.language.ILiteral;
import com.metamatrix.connector.metadata.runtime.Element;
@@ -51,7 +52,7 @@
loadColumnMetadata(insert.getGroup());
List<IElement> columns = insert.getElements();
- List<Object> values = insert.getValues();
+ List<IExpression> values = insert.getValues();
if(columns.size() != values.size()) {
throw new ConnectorException("Error: columns.size and values.size are not the same.");
}
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFrom;
Modified: trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/UpdateVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,7 +23,7 @@
import java.util.Iterator;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IUpdate;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java
===================================================================
--- trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/TestConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,8 +24,8 @@
import junit.framework.TestCase;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
import com.metamatrix.connector.salesforce.test.util.ObjectFactory;
@@ -52,14 +52,10 @@
noCredConnector.start(env2);
}
- public void testGetConnection() {
+ public void testGetConnection() throws Exception {
ExecutionContext secContext = ObjectFactory.getDefaultSecurityContext();
- try {
- SalesforceConnection connection = (SalesforceConnection) connector.getConnection(secContext);
- assertNotNull("the connection is null", connection);
- } catch (ConnectorException e) {
- fail(e.getMessage());
- }
+ SalesforceConnection connection = (SalesforceConnection) connector.getConnection(secContext);
+ assertNotNull("the connection is null", connection);
}
/*
@@ -80,11 +76,10 @@
try {
localConnector.start(env);
localConnector.getConnection(secContext);
+ fail("should have produced an exception");
} catch (ConnectorException e) {
assertFalse("There is no error message", e.getMessage().length() == 0);
- return;
}
- fail("should have produced an exception");
}
public void testGetConnectionEmptyUser() {
@@ -94,11 +89,10 @@
try {
localConnector.start(env);
localConnector.getConnection(secContext);
+ fail("should have produced an exception");
} catch (ConnectorException e) {
assertTrue("Wrong error message", e.getMessage().contains("Invalid"));
- return;
}
- fail("should have produced an exception");
}
public void testGetConnectionBadPass() {
@@ -108,11 +102,10 @@
try {
localConnector.start(env);
localConnector.getConnection(secContext);
+ fail("should have produced an exception");
} catch (ConnectorException e) {
assertFalse("There is no error message", e.getMessage().length() == 0);
- return;
}
- fail("should have produced an exception");
}
public void testGetConnectionEmptyPass() {
@@ -122,31 +115,22 @@
try {
localConnector.start(env);
localConnector.getConnection(secContext);
+ fail("should have produced an exception");
} catch (ConnectorException e) {
assertTrue("Wrong error message", e.getMessage().contains("Invalid credential configuration"));
- return;
}
- fail("should have produced an exception");
}
- public void testInitialize() {
+ public void testInitialize() throws Exception {
Connector localConnector = new Connector();
- try {
- localConnector.start(ObjectFactory.getDefaultTestConnectorEnvironment());
- assertEquals(ObjectFactory.VALID_PASSWORD, connector.getState().getPassword());
- assertEquals(ObjectFactory.VALID_USERNAME, connector.getState().getUsername());
- } catch (ConnectorException e) {
- fail(e.getMessage());
- }
+ localConnector.start(ObjectFactory.getDefaultTestConnectorEnvironment());
+ assertEquals(ObjectFactory.VALID_PASSWORD, connector.getState().getPassword());
+ assertEquals(ObjectFactory.VALID_USERNAME, connector.getState().getUsername());
}
- public void testGetLogger() {
- try {
- assertNotNull(connector.getLogger());
- } catch (ConnectorException e) {
- fail(e.getMessage());
- }
+ public void testGetLogger() throws Exception {
+ assertNotNull(connector.getLogger());
}
public void testGetState() {
Modified: trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java
===================================================================
--- trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/test/util/ObjectFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,8 +27,8 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.CredentialMap;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.pool.CredentialMap;
import com.metamatrix.connector.salesforce.ConnectorState;
public class ObjectFactory {
Modified: trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java
===================================================================
--- trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,10 +26,10 @@
import java.util.Map;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.IQueryCommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java
===================================================================
--- trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -38,9 +38,9 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
/**
* Implementation of text connector.
Modified: trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java
===================================================================
--- trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -38,12 +38,12 @@
import java.util.Properties;
import com.metamatrix.connector.api.Connection;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IFrom;
Modified: trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestMultiFileTextSynchExecution.java
===================================================================
--- trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestMultiFileTextSynchExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestMultiFileTextSynchExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,7 +30,7 @@
import junit.framework.TestCase;
import com.metamatrix.cdk.api.ConnectorHost;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.query.unittest.TimestampUtil;
Modified: trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestRowHeaderTextSynchExecution.java
===================================================================
--- trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestRowHeaderTextSynchExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestRowHeaderTextSynchExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
import junit.framework.TestCase;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public class TestRowHeaderTextSynchExecution extends TestCase {
Modified: trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnection.java
===================================================================
--- trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,7 +29,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.core.util.UnitTestUtil;
/**
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/AbstractCachingConnector.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/AbstractCachingConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/AbstractCachingConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import java.util.Map;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.base.LoggingConnector;
import com.metamatrix.connector.xml.cache.DocumentCache;
import com.metamatrix.connector.xml.cache.IDocumentCache;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/AsynchronousDocumentProducer.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/AsynchronousDocumentProducer.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/AsynchronousDocumentProducer.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
package com.metamatrix.connector.xml;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public interface AsynchronousDocumentProducer extends DocumentProducer {
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/BaseXMLConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/BaseXMLConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/BaseXMLConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,8 +26,8 @@
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
public interface BaseXMLConnectorState {
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/CachingConnector.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/CachingConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/CachingConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
package com.metamatrix.connector.xml;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.base.StatefulConnector;
import com.metamatrix.connector.xml.cache.IDocumentCache;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/DocumentProducer.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/DocumentProducer.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/DocumentProducer.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,7 +25,7 @@
import java.io.Serializable;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.base.Response;
/**
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/NamedDocumentExecutor.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/NamedDocumentExecutor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/NamedDocumentExecutor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,7 +23,7 @@
package com.metamatrix.connector.xml;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public interface NamedDocumentExecutor
{
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/SecureConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/SecureConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/SecureConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
package com.metamatrix.connector.xml;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public interface SecureConnectorState {
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/XMLConnection.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/XMLConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/XMLConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public interface XMLConnection extends Connection {
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/XMLConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/XMLConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/XMLConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,8 +26,8 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
public interface XMLConnectorState extends BaseXMLConnectorState {
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/BaseBatchProducer.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/BaseBatchProducer.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/BaseBatchProducer.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,8 +26,8 @@
import java.util.List;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
public class BaseBatchProducer {
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/BaseResultsProducer.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/BaseResultsProducer.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/BaseResultsProducer.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -50,8 +50,8 @@
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.cache.IDocumentCache;
import com.metamatrix.connector.xml.http.Messages;
/**
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/CriteriaDesc.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/CriteriaDesc.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/CriteriaDesc.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,7 +27,7 @@
import java.util.List;
import java.util.Properties;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IBaseInCriteria;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICriteria;
@@ -37,6 +37,7 @@
import com.metamatrix.connector.language.ILiteral;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.LanguageUtil;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
import com.metamatrix.connector.metadata.runtime.Element;
/**
@@ -380,7 +381,7 @@
ICriteria criteriaSeg = (ICriteria) criteriaIter.next();
if (criteriaSeg instanceof ICompareCriteria) {
ICompareCriteria compCriteria = (ICompareCriteria) criteriaSeg;
- if (compCriteria.getOperator() == ICompareCriteria.EQ) {
+ if (compCriteria.getOperator() == Operator.EQ) {
IExpression lExpr = compCriteria.getLeftExpression();
IExpression rExpr = compCriteria.getRightExpression();
handleCompareCriteria(lExpr, rExpr, fullName, parmPair);
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/DocumentBuilder.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/DocumentBuilder.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/DocumentBuilder.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -36,7 +36,7 @@
import org.jdom.Namespace;
import org.jdom.output.XMLOutputter;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.soap.SOAPDocBuilder;
public class DocumentBuilder {
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/FileBackedValueReference.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/FileBackedValueReference.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/FileBackedValueReference.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import java.io.RandomAccessFile;
import java.lang.Long;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public class FileBackedValueReference implements LargeTextValueReference {
private RandomAccessFile file;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeOrSmallString.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeOrSmallString.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeOrSmallString.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,7 @@
package com.metamatrix.connector.xml.base;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public class LargeOrSmallString
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeTextExtractingXmlFilter.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeTextExtractingXmlFilter.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeTextExtractingXmlFilter.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -36,8 +36,8 @@
import org.xml.sax.SAXException;
import org.xml.sax.helpers.XMLFilterImpl;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
class LargeTextExtractingXmlFilter extends XMLFilterImpl {
LargeTextExtractingXmlFilter(int maxInMemoryStringSize,
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeTextValueReference.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeTextValueReference.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LargeTextValueReference.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,7 @@
package com.metamatrix.connector.xml.base;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public interface LargeTextValueReference {
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LoggingConnector.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LoggingConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LoggingConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,8 +23,8 @@
package com.metamatrix.connector.xml.base;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.XMLConnectorState;
/**
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/OutputXPathDesc.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/OutputXPathDesc.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/OutputXPathDesc.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,7 +25,7 @@
import java.text.MessageFormat;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ILiteral;
import com.metamatrix.connector.metadata.runtime.Element;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ParameterDescriptor.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ParameterDescriptor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ParameterDescriptor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,7 +23,7 @@
package com.metamatrix.connector.xml.base;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.Element;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/QueryAnalyzer.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/QueryAnalyzer.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/QueryAnalyzer.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,9 +28,9 @@
import java.util.List;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFrom;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/RequestResponseDocumentProducer.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/RequestResponseDocumentProducer.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/RequestResponseDocumentProducer.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,8 +32,8 @@
import java.util.Iterator;
import java.util.List;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.DocumentProducer;
import com.metamatrix.connector.xml.XMLConnectorState;
import com.metamatrix.connector.xml.XMLExecution;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/Response.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/Response.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/Response.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,7 +33,7 @@
import org.apache.commons.codec.binary.Base64;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.DocumentProducer;
import com.metamatrix.connector.xml.cache.DocumentCache;
import com.metamatrix.connector.xml.cache.IDocumentCache;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/SecureConnectorStateImpl.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/SecureConnectorStateImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/SecureConnectorStateImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,7 +27,7 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.SecureConnectorState;
import com.metamatrix.connector.xml.TrustedPayloadHandler;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/TrustedPayloadBridge.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/TrustedPayloadBridge.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/TrustedPayloadBridge.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.pool.CredentialMap;
+import com.metamatrix.connector.api.CredentialMap;
import com.metamatrix.connector.xml.TrustedPayloadHandler;
public abstract class TrustedPayloadBridge implements TrustedPayloadHandler {
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ValueConvertor.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ValueConvertor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ValueConvertor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,9 +28,9 @@
import java.util.ArrayList;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.metadata.runtime.Element;
public class ValueConvertor {
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectionImpl.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectionImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectionImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,11 +26,11 @@
import java.io.Serializable;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.IQueryCommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnector.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,10 +26,10 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.AbstractCachingConnector;
@ConnectionPooling(enabled=false)
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLConnectorStateImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,8 +27,8 @@
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.IQueryPreprocessor;
import com.metamatrix.connector.xml.SAXFilterProvider;
import com.metamatrix.connector.xml.XMLConnectorState;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLExecutionImpl.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLExecutionImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLExecutionImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,12 +29,12 @@
import java.util.List;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xml.DocumentProducer;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLExtractor.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLExtractor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/XMLExtractor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -41,8 +41,8 @@
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.helpers.XMLFilterImpl;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.SAXFilterProvider;
/**
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/DocumentCache.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/DocumentCache.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/DocumentCache.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -40,8 +40,8 @@
import java.util.Set;
import java.util.Vector;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.base.XMLDocument;
/**
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/IDocumentCache.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/IDocumentCache.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/IDocumentCache.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,7 +23,7 @@
package com.metamatrix.connector.xml.cache;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public interface IDocumentCache {
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/RequestRecord.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/RequestRecord.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/cache/RequestRecord.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,8 +27,8 @@
import java.util.HashMap;
import java.util.Map;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.CachingConnector;
/**
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,8 +27,8 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.CachingConnector;
import com.metamatrix.connector.xml.DocumentProducer;
import com.metamatrix.connector.xml.XMLExecution;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileExecutor.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileExecutor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/file/FileExecutor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -34,9 +34,9 @@
import org.jdom.Document;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.DocumentProducer;
import com.metamatrix.connector.xml.NamedDocumentExecutor;
import com.metamatrix.connector.xml.SAXFilterProvider;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/DefaultTrustDeserializer.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/DefaultTrustDeserializer.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/DefaultTrustDeserializer.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,7 +29,7 @@
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.XMLConnectorState;
import com.metamatrix.connector.xml.base.TrustedPayloadBridge;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -40,8 +40,8 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.CachingConnector;
import com.metamatrix.connector.xml.DocumentProducer;
import com.metamatrix.connector.xml.XMLExecution;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPExecutor.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPExecutor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPExecutor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -43,8 +43,8 @@
import org.apache.commons.httpclient.util.ParameterParser;
import org.jdom.Document;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.CachingConnector;
import com.metamatrix.connector.xml.SAXFilterProvider;
import com.metamatrix.connector.xml.XMLConnection;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPRequestor.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPRequestor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPRequestor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -38,8 +38,8 @@
import org.jdom.Document;
import org.jdom.output.XMLOutputter;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
/**
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPTrustDeserializer.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPTrustDeserializer.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/http/HTTPTrustDeserializer.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,8 +29,8 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.TrustedPayloadHandler;
import com.metamatrix.connector.xml.XMLConnectorState;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSConnection.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -36,10 +36,10 @@
import javax.naming.NamingException;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.IQueryCommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSExecution.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -34,12 +34,12 @@
import javax.jms.Session;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xml.SOAPConnectorState;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSRequestExecutor.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSRequestExecutor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSRequestExecutor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -41,9 +41,9 @@
import org.jdom.Document;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.AsynchronousDocumentProducer;
import com.metamatrix.connector.xml.SOAPConnectorState;
import com.metamatrix.connector.xml.base.CriteriaDesc;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSSOAPConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSSOAPConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSSOAPConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,8 +27,8 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.SOAPConnectorState;
import com.metamatrix.connector.xml.soap.SOAPConnectorStateImpl;
import com.metamatrix.connector.xmlsource.soap.SecurityToken;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSXMLConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSXMLConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/jms/JMSXMLConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -31,8 +31,8 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.CachingConnector;
import com.metamatrix.connector.xml.DocumentProducer;
import com.metamatrix.connector.xml.XMLExecution;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,8 +27,8 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.DocumentProducer;
import com.metamatrix.connector.xml.XMLExecution;
import com.metamatrix.connector.xml.http.HTTPConnectorState;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorStateImpl.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorStateImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPConnectorStateImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -31,8 +31,8 @@
import javax.net.ssl.HttpsURLConnection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.SOAPConnectorState;
import com.metamatrix.connector.xml.base.Messages;
import com.metamatrix.connector.xml.http.HTTPConnectorState;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPDocBuilder.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -35,7 +35,7 @@
import org.jdom.Element;
import org.jdom.Namespace;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.SOAPConnectorState;
import com.metamatrix.connector.xml.base.CriteriaDesc;
import com.metamatrix.connector.xml.base.DocumentBuilder;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/soap/SOAPExecutor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -57,8 +57,8 @@
import org.w3c.dom.NodeList;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.CachingConnector;
import com.metamatrix.connector.xml.SOAPConnectorState;
import com.metamatrix.connector.xml.TrustedPayloadHandler;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLConnectionFacory.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLConnectionFacory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLConnectionFacory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,8 +26,8 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
/**
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceConnection.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,8 +23,8 @@
package com.metamatrix.connector.xmlsource;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.exception.ConnectorException;
/**
* A Base XML Connection to an XML Source
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceConnector.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,9 +26,9 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
-import com.metamatrix.connector.exception.ConnectorException;
/**
* XML Source connector, will give provide a XML document as source to
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceExecution.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,10 +30,10 @@
import com.metamatrix.connector.DataPlugin;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IParameter;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/file/FileConnection.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/file/FileConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/file/FileConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,9 +26,9 @@
import java.util.Properties;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ProcedureExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xmlsource.XMLSourceConnection;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/file/FileExecution.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/file/FileExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/file/FileExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,8 +32,8 @@
import javax.xml.transform.stream.StreamSource;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/soap/SoapConnection.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/soap/SoapConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/soap/SoapConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -50,9 +50,9 @@
import org.apache.axis.wsdl.symbolTable.SymbolTable;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ProcedureExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xmlsource.XMLSourceConnection;
Modified: trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/soap/SoapExecution.java
===================================================================
--- trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/soap/SoapExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/soap/SoapExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,10 +30,11 @@
import javax.xml.transform.Source;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xmlsource.XMLSourceExecution;
@@ -88,10 +89,10 @@
// extract all the input parameters to send to the service
for (Iterator i = procedure.getParameters().iterator(); i.hasNext();) {
IParameter param = (IParameter)i.next();
- if (param.getDirection() == IParameter.IN ) {
+ if (param.getDirection() == Direction.IN ) {
argsList.add(param.getValue());
}
- else if (param.getDirection() == IParameter.INOUT) {
+ else if (param.getDirection() == Direction.INOUT) {
argsList.add(param.getValue());
}
}
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/MockCachingConnector.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/MockCachingConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/MockCachingConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,9 +26,9 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.cache.IDocumentCache;
import com.metamatrix.connector.xml.cache.MockDocumentCache;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/ProxyObjectFactory.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/ProxyObjectFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/ProxyObjectFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -34,8 +34,8 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xml.SecureConnectorState;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestCriteriaDesc.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestCriteriaDesc.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestCriteriaDesc.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,7 +29,7 @@
import junit.framework.TestCase;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IBaseInCriteria;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICriteria;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestExecutionInfo.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestExecutionInfo.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestExecutionInfo.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,9 +32,9 @@
import com.metamatrix.cdk.api.SysLogger;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xml.IQueryPreprocessor;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestOutputXPathDesc.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestOutputXPathDesc.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestOutputXPathDesc.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import junit.framework.TestCase;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICriteria;
import com.metamatrix.connector.language.IElement;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestParameterDescriptor.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestParameterDescriptor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestParameterDescriptor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import junit.framework.TestCase;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IQuery;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestQueryAnalyzer.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestQueryAnalyzer.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestQueryAnalyzer.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,9 +30,9 @@
import com.metamatrix.cdk.api.SysLogger;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xml.IQueryPreprocessor;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestStringBackedValueReference.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestStringBackedValueReference.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestStringBackedValueReference.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
import junit.framework.TestCase;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
public class TestStringBackedValueReference extends TestCase {
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnection.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,8 +26,8 @@
import junit.framework.TestCase;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
public class TestXMLConnection extends TestCase {
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnector.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,8 +29,8 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.XMLConnectorState;
import com.metamatrix.connector.xml.file.FileConnectorState;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,9 +30,9 @@
import com.metamatrix.cdk.api.SysLogger;
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.Execution;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.xml.CachingConnector;
import com.metamatrix.connector.xml.DocumentProducer;
import com.metamatrix.connector.xml.XMLConnectorState;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLExecution.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import junit.framework.TestCase;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IQuery;
/**
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLExtractor.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLExtractor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestXMLExtractor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,8 +30,8 @@
import org.jdom.Document;
import com.metamatrix.cdk.api.SysLogger;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
-import com.metamatrix.connector.exception.ConnectorException;
public class TestXMLExtractor extends TestCase {
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/cache/TestCache.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/cache/TestCache.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/cache/TestCache.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,7 +30,7 @@
import junit.framework.TestSuite;
import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.core.util.UnitTestUtil;
/**
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/file/TestFileConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/file/TestFileConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/file/TestFileConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.api.SysLogger;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.DocumentProducer;
import com.metamatrix.connector.xml.base.ProxyObjectFactory;
import com.metamatrix.connector.xml.base.XMLExecutionImpl;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/file/TestFileExecutor.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/file/TestFileExecutor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/file/TestFileExecutor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,7 +32,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.api.SysLogger;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IQuery;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/TestHTTPConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/TestHTTPConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/http/TestHTTPConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.api.SysLogger;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.base.ProxyObjectFactory;
/**
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/jms/TestJMSConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/jms/TestJMSConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/jms/TestJMSConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,7 +32,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.api.SysLogger;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.base.ProxyObjectFactory;
public class TestJMSConnectorState extends TestCase {
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/jms/TestJMSSOAPConnectorState.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/jms/TestJMSSOAPConnectorState.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/jms/TestJMSSOAPConnectorState.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,7 +32,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.api.SysLogger;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xml.base.ProxyObjectFactory;
import com.metamatrix.connector.xml.soap.SOAPConnectorStateImpl;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/FakeRuntimeMetadata.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/FakeRuntimeMetadata.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/FakeRuntimeMetadata.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
import java.util.Properties;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/file/TestFileConnection.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/file/TestFileConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/file/TestFileConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.core.util.UnitTestUtil;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/file/TestFileExecution.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/file/TestFileExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/file/TestFileExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,13 +32,12 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ILanguageFactory;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.visitor.framework.LanguageObjectVisitor;
import com.metamatrix.connector.xmlsource.FakeRuntimeMetadata;
import com.metamatrix.core.util.UnitTestUtil;
@@ -68,8 +67,9 @@
List result = exec.next();
assertNotNull(result);
assertNull(exec.next());
+ IParameter returnParam = fact.createParameter(0, Direction.RETURN, null, null, null);
try {
- exec.getOutputValue(getReturnParameter());
+ exec.getOutputValue(returnParam);
fail("should have thrown error in returning a return"); //$NON-NLS-1$
}catch(Exception e) {
}
@@ -109,37 +109,6 @@
}
}
-
- IParameter getReturnParameter() {
- return new IParameter() {
- public int getIndex() {
- return 0;
- }
- public int getDirection() {
- return IParameter.RETURN;
- }
- public Class getType() {
- return null;
- }
- public Object getValue() {
- return null;
- }
- public boolean getValueSpecified() {
- return false;
- }
- public void setIndex(int index) {}
- public void setDirection(int direction) {}
- public void setType(Class type) {}
- public void setValue(Object value) {}
- public void setValueSpecified(boolean specified) {}
- public void acceptVisitor(LanguageObjectVisitor visitor) {}
- public MetadataID getMetadataID() {
- return null;
- }
- public void setMetadataID(MetadataID metadataID) {}
- };
- }
-
String readFile(String filename) throws Exception {
Reader reader = new FileReader(filename);
StringBuffer fileContents = new StringBuffer();
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/soap/TestSoapConnection.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/soap/TestSoapConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/soap/TestSoapConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,7 +29,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.core.util.UnitTestUtil;
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/soap/TestSoapExecution.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/soap/TestSoapExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/soap/TestSoapExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -40,9 +40,8 @@
import com.metamatrix.connector.language.ILanguageFactory;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.visitor.framework.LanguageObjectVisitor;
import com.metamatrix.connector.xmlsource.FakeRuntimeMetadata;
import com.metamatrix.connector.xmlsource.soap.service.WebServiceServer;
import com.metamatrix.core.util.UnitTestUtil;
@@ -548,7 +547,7 @@
List parameters = new ArrayList();
if (args != null && args.length > 0) {
for (int i = 0; i < args.length; i++) {
- IParameter param = fact.createParameter(i+1, IParameter.IN, args[i], args[i].getClass(), null);
+ IParameter param = fact.createParameter(i+1, Direction.IN, args[i], args[i].getClass(), null);
parameters.add(param);
}
}
@@ -560,9 +559,9 @@
List result = exec.next();
assertNotNull(result);
assertNull(exec.next());
-
+ IParameter returnParam = fact.createParameter(0, Direction.RETURN, null, null, null);
try {
- exec.getOutputValue(getReturnParameter());
+ exec.getOutputValue(returnParam);
fail("should have thrown error in returning a return"); //$NON-NLS-1$
}catch(Exception e) {
}
@@ -577,34 +576,4 @@
// System.out.println(xmlString);
}
- IParameter getReturnParameter() {
- return new IParameter() {
- public int getIndex() {
- return 0;
- }
- public int getDirection() {
- return IParameter.RETURN;
- }
- public Class getType() {
- return null;
- }
- public Object getValue() {
- return null;
- }
- public boolean getValueSpecified() {
- return false;
- }
- public void setIndex(int index) {}
- public void setDirection(int direction) {}
- public void setType(Class type) {}
- public void setValue(Object value) {}
- public void setValueSpecified(boolean specified) {}
- public void acceptVisitor(LanguageObjectVisitor visitor) {}
- public MetadataID getMetadataID() {
- return null;
- }
- public void setMetadataID(MetadataID metadataID) {}
- };
- }
-
}
Modified: trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java
===================================================================
--- trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -49,11 +49,11 @@
import com.metamatrix.common.util.CommonPropertyNames;
import com.metamatrix.common.util.OSPlatformUtil;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.core.util.Assertion;
Modified: trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java
===================================================================
--- trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,11 +25,11 @@
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.IQueryCommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java
===================================================================
--- trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -35,9 +35,9 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.core.util.ObjectConverterUtil;
/**
Modified: trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecVisitor.java
===================================================================
--- trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import java.util.Map;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.ICriteria;
import com.metamatrix.connector.language.IElement;
Modified: trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/FakeExecConnector.java
===================================================================
--- trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/FakeExecConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/FakeExecConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import java.util.List;
import java.util.Properties;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
/**
* Implmentation of text connector.
Modified: trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java
===================================================================
--- trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-exec/src/test/java/com/metamatrix/connector/exec/TestsExec.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,8 +33,8 @@
import junit.framework.TestCase;
import com.metamatrix.cdk.api.ConnectorHost;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ResultSetExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.core.util.UnitTestUtil;
/**
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,11 +25,11 @@
import com.metamatrix.admin.api.exception.AdminException;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.object.extension.IObjectSource;
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,9 +26,9 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.object.util.ObjectConnectorUtil;
import com.metamatrix.connector.pool.ConnectorIdentity;
import com.metamatrix.connector.pool.ConnectorIdentityFactory;
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectProcedureExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,11 +25,11 @@
import java.util.List;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -2,8 +2,8 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.pool.ConnectorIdentity;
import com.metamatrix.connector.pool.SingleIdentity;
import com.metamatrix.connector.pool.UserIdentity;
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSource.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSource.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/IObjectSource.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
import java.util.List;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.object.ObjectProcedureExecution;
/**
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/ISourceTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,8 +28,8 @@
import java.util.TimeZone;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/command/ObjectCommand.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/command/ObjectCommand.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/command/ObjectCommand.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,7 @@
package com.metamatrix.connector.object.extension.command;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IMetadataReference;
import com.metamatrix.connector.metadata.runtime.MetadataID;
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/command/ProcedureCommand.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/command/ProcedureCommand.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/command/ProcedureCommand.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,9 +29,10 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
@@ -167,13 +168,13 @@
for(final Iterator iter = parameters.iterator(); iter.hasNext();) {
IParameter parameter = (IParameter) iter.next();
// if there is one result set parameter
- if(parameter.getDirection() == IParameter.RESULT_SET) {
+ if(parameter.getDirection() == Direction.RESULT_SET) {
this.resultSetParameter = parameter;
initResultSet();
- } else if(parameter.getDirection() == IParameter.IN || parameter.getDirection() == IParameter.INOUT) {
+ } else if(parameter.getDirection() == Direction.IN || parameter.getDirection() == Direction.INOUT) {
initCriteria(parameter);
// inParams.add(parameter);
- } else if (parameter.getDirection() == IParameter.RETURN && this.resultSetParameter==null) {
+ } else if (parameter.getDirection() == Direction.RETURN && this.resultSetParameter==null) {
this.resultSetParameter = parameter;
initResultReturn();
}
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseObjectSource.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseObjectSource.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseObjectSource.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,7 +30,7 @@
import java.util.Collections;
import java.util.List;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.object.ObjectSourceMethodManager;
import com.metamatrix.connector.object.extension.IObjectCommand;
import com.metamatrix.connector.object.extension.IObjectSource;
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,8 +26,8 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.object.ObjectConnection;
import com.metamatrix.connector.object.SourceConnectionFactory;
import com.metamatrix.connector.object.extension.IObjectSource;
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BasicSourceTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,9 +29,9 @@
import java.util.TimeZone;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.api.ValueTranslator;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/value/BasicValueRetriever.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/value/BasicValueRetriever.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/value/BasicValueRetriever.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,7 +33,7 @@
import java.util.Map;
import java.util.Properties;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.object.ObjectSourceMethodManager;
import com.metamatrix.connector.object.extension.IObjectCommand;
import com.metamatrix.connector.object.extension.IValueRetriever;
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/value/JavaUtilDateValueTranslator.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/value/JavaUtilDateValueTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/value/JavaUtilDateValueTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,9 +27,9 @@
import java.sql.Timestamp;
import java.util.Date;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ValueTranslator;
-import com.metamatrix.connector.exception.ConnectorException;
/**
*/
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IMetadataReference;
import com.metamatrix.connector.metadata.runtime.MetadataID;
Modified: trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectExecutionHelper.java
===================================================================
--- trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectExecutionHelper.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectExecutionHelper.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -36,11 +36,11 @@
import java.util.TimeZone;
import com.metamatrix.common.util.TimestampWithTimezone;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.api.ValueTranslator;
import com.metamatrix.connector.basic.BasicValueTranslator;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.object.ObjectPlugin;
import com.metamatrix.connector.object.extension.IObjectCommand;
import com.metamatrix.connector.object.extension.ISourceTranslator;
Modified: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialConnector.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,7 +30,7 @@
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.jdbc.JDBCConnector;
public class OracleSpatialConnector extends JDBCConnector {
Modified: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialSQLTranslator.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialSQLTranslator.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialSQLTranslator.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,8 +27,8 @@
import java.util.List;
import java.util.Map;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
import com.metamatrix.connector.jdbc.oracle.OracleSQLTranslator;
import com.metamatrix.connector.language.ICommand;
Modified: trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/TickerCollectorVisitor.java
===================================================================
--- trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/TickerCollectorVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/TickerCollectorVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
import java.util.*;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.*;
import com.metamatrix.connector.visitor.framework.HierarchyVisitor;
Modified: trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java
===================================================================
--- trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,10 +23,10 @@
package com.metamatrix.connector.yahoo;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.IQueryCommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java
===================================================================
--- trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,7 +23,6 @@
package com.metamatrix.connector.yahoo;
import com.metamatrix.connector.api.*;
-import com.metamatrix.connector.exception.ConnectorException;
public class YahooConnector implements Connector {
Modified: trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java
===================================================================
--- trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -40,11 +40,11 @@
import java.util.StringTokenizer;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICriteria;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IExpression;
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -62,7 +62,6 @@
import com.metamatrix.common.util.crypto.CryptoException;
import com.metamatrix.common.util.crypto.CryptoUtil;
import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.connector.monitor.AliveStatus;
import com.metamatrix.dqp.embedded.DQPEmbeddedManager;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.service.ConfigurationService;
@@ -320,12 +319,12 @@
// Binding state needs to be converted into pool state; until then we use
// binding state as pool state.
try {
- AliveStatus status = getDataService().getConnectorBindingState(src.getDeployedName());
- if (status == AliveStatus.ALIVE) {
+ Boolean status = getDataService().getConnectorBindingState(src.getDeployedName());
+ if (status == Boolean.TRUE) {
binding.setState(com.metamatrix.admin.api.objects.ConnectorBinding.STATE_OPEN);
}
- else if (status == AliveStatus.DEAD) {
- binding.setState(com.metamatrix.admin.api.objects.ConnectorBinding.STATE_CLOSED);
+ else if (status == Boolean.FALSE) {
+ binding.setState(com.metamatrix.admin.api.objects.ConnectorBinding.STATE_DATA_SOURCE_UNAVAILABLE);
}
else {
binding.setState(com.metamatrix.admin.api.objects.ConnectorBinding.STATE_DATA_SOURCE_UNAVAILABLE);
Modified: trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java
===================================================================
--- trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -48,9 +48,8 @@
import com.metamatrix.common.util.crypto.CryptoUtil;
import com.metamatrix.common.vdb.api.VDBArchive;
import com.metamatrix.common.vdb.api.VDBDefn;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.internal.ConnectorPropertyNames;
-import com.metamatrix.connector.monitor.AliveStatus;
import com.metamatrix.core.vdb.VDBStatus;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.embedded.configuration.ExtensionModuleReader;
@@ -291,13 +290,13 @@
* @see com.metamatrix.dqp.service.DataService#getConnectorBindingState(java.lang.String)
* @since 4.3
*/
- public AliveStatus getConnectorBindingState(String deployedConnectorBindingName)
+ public Boolean getConnectorBindingState(String deployedConnectorBindingName)
throws MetaMatrixComponentException {
ConnectorBinding binding = getConnectorBinding(deployedConnectorBindingName);
if (binding != null) {
ConnectorManager mgr = getConnectorManager(binding);
if (mgr != null) {
- return mgr.getStatus().getStatus();
+ return mgr.getStatus();
}
}
throw new MetaMatrixComponentException(DQPEmbeddedPlugin.Util.getString("DataService.Unable_to_find_connector", deployedConnectorBindingName)); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistry.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistry.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/common/comm/ClientServiceRegistry.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,14 +24,12 @@
import java.util.concurrent.ConcurrentHashMap;
-public class ClientServiceRegistry<S> {
+public class ClientServiceRegistry {
private ConcurrentHashMap<String, Object> localServices = new ConcurrentHashMap<String, Object>();
private ConcurrentHashMap<String, String> loggingContext = new ConcurrentHashMap<String, String>();
- private S sessionServiceProxy;
- public ClientServiceRegistry(S sessionService) {
- this.sessionServiceProxy = sessionService;
+ public ClientServiceRegistry() {
}
public <T> T getClientService(Class<T> iface) {
@@ -42,10 +40,6 @@
return localServices.get(iface);
}
- public S getSessionService() {
- return this.sessionServiceProxy;
- }
-
public void registerClientService(Class<?> iface, Object instance, String loggingContext) {
this.localServices.put(iface.getName(), instance);
this.loggingContext.put(iface.getName(), loggingContext);
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorManager.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorManager.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -54,12 +54,11 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
import com.metamatrix.connector.api.ConnectorAnnotations.SynchronousWorkers;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.internal.ConnectorPropertyNames;
-import com.metamatrix.connector.monitor.ConnectionStatus;
import com.metamatrix.connector.xa.api.XAConnection;
import com.metamatrix.connector.xa.api.XAConnector;
import com.metamatrix.core.util.Assertion;
@@ -270,7 +269,7 @@
/**
* @see com.metamatrix.dqp.internal.datamgr.ConnectorManager#isAlive()
*/
- public ConnectionStatus getStatus() {
+ public Boolean getStatus() {
ClassLoader contextloader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(classloader);
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -34,12 +34,12 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.Connector;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.Execution;
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.UpdateExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.language.IQueryCommand;
@@ -331,10 +331,6 @@
}
return null;
}
- @Override
- public List<Exception> getWarnings() {
- return exec.getWarnings();
- }
};
}
@@ -406,7 +402,7 @@
// implicit close.
response.setSupportsImplicitClose(!this.securityContext.keepExecutionAlive());
response.setTransactional(this.securityContext.isTransactional());
- response.setWarnings(this.execution.getWarnings());
+ response.setWarnings(this.securityContext.getWarnings());
if ( lastBatch ) {
response.setFinalRow(rowCount);
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWrapper.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWrapper.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWrapper.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,11 +26,8 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
-import com.metamatrix.connector.monitor.AliveStatus;
-import com.metamatrix.connector.monitor.ConnectionStatus;
-import com.metamatrix.connector.monitor.MonitoredConnector;
import com.metamatrix.connector.pool.ConnectorIdentity;
import com.metamatrix.connector.pool.ConnectorIdentityFactory;
import com.metamatrix.connector.pool.SingleIdentity;
@@ -41,7 +38,7 @@
/**
* ConnectorWrapper adds default behavior to the wrapped connector.
*/
-public class ConnectorWrapper implements XAConnector, MonitoredConnector, ConnectorIdentityFactory {
+public class ConnectorWrapper implements XAConnector, ConnectorIdentityFactory {
private Connector actualConnector;
@@ -94,17 +91,20 @@
return actualConnector.getCapabilities();
}
- @Override
- public final ConnectionStatus getStatus() {
- if(actualConnector instanceof MonitoredConnector){
- return ((MonitoredConnector)actualConnector).getStatus();
+ public final Boolean getStatus() {
+ if (supportsSingleIdentity()) {
+ Connection conn = null;
+ try {
+ conn = this.getConnection(null);
+ return conn.isAlive();
+ } catch (ConnectorException e) {
+ return Boolean.FALSE;
+ } finally {
+ conn.close();
+ }
}
- return getStatusDirect();
+ return null;
}
-
- protected ConnectionStatus getStatusDirect() {
- return new ConnectionStatus(AliveStatus.UNKNOWN);
- }
public Connector getActualConnector() {
return actualConnector;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ExecutionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,6 +23,9 @@
package com.metamatrix.dqp.internal.datamgr.impl;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
import com.metamatrix.common.buffer.impl.BufferConfig;
import com.metamatrix.connector.api.ExecutionContext;
@@ -63,6 +66,7 @@
private ConnectorIdentity connectorIdentity;
private int batchSize = BufferConfig.DEFAULT_CONNECTOR_BATCH_SIZE;
+ private List<Exception> warnings = new LinkedList<Exception>();
public ExecutionContextImpl(String vdbName, String vdbVersion, String userName,
Serializable trustedPayload, Serializable executionPayload,
@@ -189,4 +193,21 @@
public void setBatchSize(int batchSize) {
this.batchSize = batchSize;
}
+
+ /**
+ * Add an exception as a warning to this Execution.
+ */
+ @Override
+ public void addWarning(Exception ex) {
+ if (ex == null) {
+ return;
+ }
+ this.warnings.add(ex);
+ }
+
+ public List<Exception> getWarnings() {
+ List<Exception> result = new ArrayList<Exception>(warnings);
+ warnings.clear();
+ return result;
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ProcedureBatchHandler.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ProcedureBatchHandler.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -31,10 +31,11 @@
import java.util.Iterator;
import java.util.List;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ProcedureExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.dqp.DQPPlugin;
class ProcedureBatchHandler {
@@ -53,9 +54,9 @@
Iterator iter = params.iterator();
while(iter.hasNext()){
IParameter param = (IParameter)iter.next();
- if (param.getDirection() == IParameter.RESULT_SET) {
+ if (param.getDirection() == Direction.RESULT_SET) {
resultSetCols = param.getMetadataID().getChildIDs().size();
- } else if(param.getDirection() == IParameter.RETURN || param.getDirection() == IParameter.OUT || param.getDirection() == IParameter.INOUT){
+ } else if(param.getDirection() == Direction.RETURN || param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){
paramCols += 1;
}
}
@@ -89,7 +90,7 @@
//return
while(iter.hasNext()){
IParameter param = (IParameter)iter.next();
- if(param.getDirection() == IParameter.RETURN){
+ if(param.getDirection() == Direction.RETURN){
outParamValues.set(index++, procExec.getOutputValue(param));
}
}
@@ -97,7 +98,7 @@
iter = params.iterator();
while(iter.hasNext()){
IParameter param = (IParameter)iter.next();
- if(param.getDirection() == IParameter.OUT || param.getDirection() == IParameter.INOUT){
+ if(param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){
outParamValues.set(index++, procExec.getOutputValue(param));
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,7 +33,7 @@
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.xa.XATransactionException;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.xa.api.XAConnection;
import com.metamatrix.dqp.message.AtomicRequestMessage;
import com.metamatrix.dqp.message.AtomicResultsMessage;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/TypeFacilityImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/TypeFacilityImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/TypeFacilityImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,8 +23,8 @@
package com.metamatrix.dqp.internal.datamgr.impl;
import com.metamatrix.common.types.*;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.exception.ConnectorException;
/**
*/
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CompareCriteriaImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CompareCriteriaImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,9 +30,9 @@
private IExpression leftExpression = null;
private IExpression rightExpression = null;
- private int operator;
+ private Operator operator;
- public CompareCriteriaImpl(IExpression left, IExpression right, int operator) {
+ public CompareCriteriaImpl(IExpression left, IExpression right, Operator operator) {
leftExpression = left;
rightExpression = right;
this.operator = operator;
@@ -54,7 +54,7 @@
/**
* @see com.metamatrix.connector.language.ICompareCriteria#getOperator()
*/
- public int getOperator() {
+ public Operator getOperator() {
return this.operator;
}
@@ -75,7 +75,7 @@
/*
* @see com.metamatrix.data.language.ICompareCriteria#setOperator(int)
*/
- public void setOperator(int operator) {
+ public void setOperator(Operator operator) {
this.operator = operator;
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CompoundCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CompoundCriteriaImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/CompoundCriteriaImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,9 +30,9 @@
public class CompoundCriteriaImpl extends BaseLanguageObject implements ICompoundCriteria {
private List criteria = null;
- private int operator = AND;
+ private Operator operator = Operator.AND;
- public CompoundCriteriaImpl(List nestedCriteria, int operator) {
+ public CompoundCriteriaImpl(List nestedCriteria, Operator operator) {
criteria = nestedCriteria;
this.operator = operator;
}
@@ -40,7 +40,7 @@
/**
* @see com.metamatrix.connector.language.ICompoundCriteria#getOperator()
*/
- public int getOperator() {
+ public Operator getOperator() {
return this.operator;
}
@@ -61,7 +61,7 @@
/*
* @see com.metamatrix.data.language.ICompoundCriteria#setOperator(int)
*/
- public void setOperator(int operator) {
+ public void setOperator(Operator operator) {
this.operator = operator;
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/JoinImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/JoinImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/JoinImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,10 +32,10 @@
private IFromItem leftItem = null;
private IFromItem rightItem = null;
- private int joinType;
+ private JoinType joinType;
private List criteria = null;
- public JoinImpl(IFromItem left, IFromItem right, int joinType, List criteria) {
+ public JoinImpl(IFromItem left, IFromItem right, JoinType joinType, List criteria) {
this.leftItem = left;
this.rightItem = right;
this.joinType = joinType;
@@ -58,7 +58,7 @@
/**
* @see com.metamatrix.connector.language.IJoin#getJoinType()
*/
- public int getJoinType() {
+ public JoinType getJoinType() {
return this.joinType;
}
@@ -90,7 +90,7 @@
/*
* @see com.metamatrix.data.language.IJoin#setJoinType(int)
*/
- public void setJoinType(int type) {
+ public void setJoinType(JoinType type) {
this.joinType = type;
}
/*
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -67,6 +67,9 @@
import com.metamatrix.connector.language.ISubqueryCompareCriteria;
import com.metamatrix.connector.language.ISubqueryInCriteria;
import com.metamatrix.connector.language.IUpdate;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
+import com.metamatrix.connector.language.IParameter.Direction;
+import com.metamatrix.connector.language.ISubqueryCompareCriteria.Quantifier;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.internal.datamgr.metadata.MetadataFactory;
@@ -250,17 +253,17 @@
criteria.add(translate((Criteria)i.next()));
}
- int joinType = IJoin.INNER_JOIN;
+ IJoin.JoinType joinType = IJoin.JoinType.INNER_JOIN;
if(join.getJoinType().equals(JoinType.JOIN_INNER)) {
- joinType = IJoin.INNER_JOIN;
+ joinType = IJoin.JoinType.INNER_JOIN;
} else if(join.getJoinType().equals(JoinType.JOIN_LEFT_OUTER)) {
- joinType = IJoin.LEFT_OUTER_JOIN;
+ joinType = IJoin.JoinType.LEFT_OUTER_JOIN;
} else if(join.getJoinType().equals(JoinType.JOIN_RIGHT_OUTER)) {
- joinType = IJoin.RIGHT_OUTER_JOIN;
+ joinType = IJoin.JoinType.RIGHT_OUTER_JOIN;
} else if(join.getJoinType().equals(JoinType.JOIN_FULL_OUTER)) {
- joinType = IJoin.FULL_OUTER_JOIN;
+ joinType = IJoin.JoinType.FULL_OUTER_JOIN;
} else if(join.getJoinType().equals(JoinType.JOIN_CROSS)) {
- joinType = IJoin.CROSS_JOIN;
+ joinType = IJoin.JoinType.CROSS_JOIN;
}
return new JoinImpl(translate(join.getLeftClause()),
@@ -302,25 +305,25 @@
}
ICompareCriteria translate(CompareCriteria criteria) throws MetaMatrixComponentException {
- int operator = ICompareCriteria.EQ;
+ ICompareCriteria.Operator operator = Operator.EQ;
switch(criteria.getOperator()) {
case CompareCriteria.EQ:
- operator = ICompareCriteria.EQ;
+ operator = Operator.EQ;
break;
case CompareCriteria.NE:
- operator = ICompareCriteria.NE;
+ operator = Operator.NE;
break;
case CompareCriteria.LT:
- operator = ICompareCriteria.LT;
+ operator = Operator.LT;
break;
case CompareCriteria.LE:
- operator = ICompareCriteria.LE;
+ operator = Operator.LE;
break;
case CompareCriteria.GT:
- operator = ICompareCriteria.GT;
+ operator = Operator.GT;
break;
case CompareCriteria.GE:
- operator = ICompareCriteria.GE;
+ operator = Operator.GE;
break;
}
@@ -336,14 +339,7 @@
translatedCriteria.add(translate((Criteria)i.next()));
}
- int operator = 0;
- if(criteria.getOperator() == CompoundCriteria.AND) {
- operator = ICompoundCriteria.AND;
- } else {
- operator = ICompoundCriteria.OR;
- }
-
- return new CompoundCriteriaImpl(translatedCriteria, operator);
+ return new CompoundCriteriaImpl(translatedCriteria, criteria.getOperator() == CompoundCriteria.AND?ICompoundCriteria.Operator.AND:ICompoundCriteria.Operator.OR);
}
IExistsCriteria translate(ExistsCriteria criteria) throws MetaMatrixComponentException {
@@ -377,38 +373,38 @@
}
ISubqueryCompareCriteria translate(SubqueryCompareCriteria criteria) throws MetaMatrixComponentException {
- int quantifier = 0;
+ Quantifier quantifier = Quantifier.ALL;
switch(criteria.getPredicateQuantifier()) {
case SubqueryCompareCriteria.ALL:
- quantifier = ISubqueryCompareCriteria.ALL;
+ quantifier = Quantifier.ALL;
break;
case SubqueryCompareCriteria.ANY:
- quantifier = ISubqueryCompareCriteria.SOME;
+ quantifier = Quantifier.SOME;
break;
case SubqueryCompareCriteria.SOME:
- quantifier = ISubqueryCompareCriteria.SOME;
+ quantifier = Quantifier.SOME;
break;
}
- int operator = 0;
+ ICompareCriteria.Operator operator = ICompareCriteria.Operator.EQ;
switch(criteria.getOperator()) {
case SubqueryCompareCriteria.EQ:
- operator = ISubqueryCompareCriteria.EQ;
+ operator = ICompareCriteria.Operator.EQ;
break;
case SubqueryCompareCriteria.NE:
- operator = ISubqueryCompareCriteria.NE;
+ operator = ICompareCriteria.Operator.NE;
break;
case SubqueryCompareCriteria.LT:
- operator = ISubqueryCompareCriteria.LT;
+ operator = ICompareCriteria.Operator.LT;
break;
case SubqueryCompareCriteria.LE:
- operator = ISubqueryCompareCriteria.LE;
+ operator = ICompareCriteria.Operator.LE;
break;
case SubqueryCompareCriteria.GT:
- operator = ISubqueryCompareCriteria.GT;
+ operator = ICompareCriteria.Operator.GT;
break;
case SubqueryCompareCriteria.GE:
- operator = ISubqueryCompareCriteria.GE;
+ operator = ICompareCriteria.Operator.GE;
break;
}
@@ -664,28 +660,28 @@
}
IParameter translate(SPParameter param, ProcedureIDImpl procID) throws MetaMatrixComponentException {
- int direction = IParameter.IN;
+ Direction direction = Direction.IN;
switch(param.getParameterType()) {
case ParameterInfo.IN:
- direction = IParameter.IN;
+ direction = Direction.IN;
break;
case ParameterInfo.INOUT:
- direction = IParameter.INOUT;
+ direction = Direction.INOUT;
break;
case ParameterInfo.OUT:
- direction = IParameter.OUT;
+ direction = Direction.OUT;
break;
case ParameterInfo.RESULT_SET:
- direction = IParameter.RESULT_SET;
+ direction = Direction.RESULT_SET;
break;
case ParameterInfo.RETURN_VALUE:
- direction = IParameter.RETURN;
+ direction = Direction.RETURN;
break;
}
try {
MetadataID metadataID = null;
- if(direction == IParameter.RESULT_SET) {
+ if(direction == Direction.RESULT_SET) {
metadataID = metadataFactory.createResultSetID(procID, param.getMetadataID(), param.getResultSetIDs());
return new ParameterImpl(param.getIndex(), direction, param.getValue(), param.getClassType(), metadataID);
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageFactoryImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageFactoryImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageFactoryImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -61,7 +61,7 @@
* @see com.metamatrix.data.language.ILanguageFactory#createCompareCriteria(int, com.metamatrix.data.language.IExpression, com.metamatrix.data.language.IExpression)
*/
public ICompareCriteria createCompareCriteria(
- int operator,
+ ICompareCriteria.Operator operator,
IExpression leftExpression,
IExpression rightExpression) {
return new CompareCriteriaImpl(leftExpression, rightExpression, operator);
@@ -70,7 +70,7 @@
/*
* @see com.metamatrix.data.language.ILanguageFactory#createCompoundCriteria(int, java.util.List)
*/
- public ICompoundCriteria createCompoundCriteria(int operator, List innerCriteria) {
+ public ICompoundCriteria createCompoundCriteria(ICompoundCriteria.Operator operator, List innerCriteria) {
return new CompoundCriteriaImpl(innerCriteria, operator);
}
@@ -154,7 +154,7 @@
/*
* @see com.metamatrix.data.language.ILanguageFactory#createJoin(int, com.metamatrix.data.language.IFromItem, com.metamatrix.data.language.IFromItem, java.util.List)
*/
- public IJoin createJoin(int joinType, IFromItem leftItem, IFromItem rightItem, List criteria) {
+ public IJoin createJoin(IJoin.JoinType joinType, IFromItem leftItem, IFromItem rightItem, List criteria) {
return new JoinImpl(leftItem, rightItem, joinType, criteria);
}
@@ -200,7 +200,7 @@
/*
* @see com.metamatrix.data.language.ILanguageFactory#createParameter(int, int, java.lang.Object, java.lang.Class)
*/
- public IParameter createParameter(int index, int direction, Object value, Class type, MetadataID metadataReference) {
+ public IParameter createParameter(int index, IParameter.Direction direction, Object value, Class type, MetadataID metadataReference) {
return new ParameterImpl(index, direction, value, type, metadataReference);
}
@@ -261,8 +261,8 @@
*/
public ISubqueryCompareCriteria createSubqueryCompareCriteria(
IExpression leftExpression,
- int operator,
- int quantifier,
+ ICompareCriteria.Operator operator,
+ ISubqueryCompareCriteria.Quantifier quantifier,
IQuery subquery) {
return new SubqueryCompareCriteriaImpl(leftExpression, operator, quantifier, subquery);
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ParameterImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ParameterImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ParameterImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,13 +29,13 @@
public class ParameterImpl extends BaseLanguageObject implements IParameter {
private int index;
- private int direction;
+ private Direction direction;
private Object value;
private boolean valueSpecified;
private Class type;
private MetadataID metadataID;
- public ParameterImpl(int index, int direction, Object value, Class type, MetadataID metadataID) {
+ public ParameterImpl(int index, Direction direction, Object value, Class type, MetadataID metadataID) {
setIndex(index);
setDirection(direction);
setValue(value);
@@ -53,7 +53,7 @@
/**
* @see com.metamatrix.connector.language.IParameter#getDirection()
*/
- public int getDirection() {
+ public Direction getDirection() {
return this.direction;
}
@@ -88,7 +88,7 @@
/*
* @see com.metamatrix.data.language.IParameter#setDirection(int)
*/
- public void setDirection(int direction) {
+ public void setDirection(Direction direction) {
this.direction = direction;
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/SubqueryCompareCriteriaImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -23,6 +23,7 @@
package com.metamatrix.dqp.internal.datamgr.language;
import com.metamatrix.connector.language.*;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
import com.metamatrix.connector.visitor.framework.LanguageObjectVisitor;
/**
@@ -30,14 +31,14 @@
public class SubqueryCompareCriteriaImpl extends BaseLanguageObject implements ISubqueryCompareCriteria {
private IExpression leftExpr;
- private int operator;
- private int quantifier;
+ private Operator operator;
+ private Quantifier quantifier;
private IQueryCommand query;
/**
*
*/
- public SubqueryCompareCriteriaImpl(IExpression leftExpr, int operator, int quantifier, IQueryCommand query) {
+ public SubqueryCompareCriteriaImpl(IExpression leftExpr, Operator operator, Quantifier quantifier, IQueryCommand query) {
this.leftExpr = leftExpr;
this.operator = operator;
this.quantifier = quantifier;
@@ -54,14 +55,14 @@
/*
* @see com.metamatrix.data.language.ISubqueryCompareCriteria#getOperator()
*/
- public int getOperator() {
+ public Operator getOperator() {
return this.operator;
}
/*
* @see com.metamatrix.data.language.ISubqueryCompareCriteria#getQuantifier()
*/
- public int getQuantifier() {
+ public Quantifier getQuantifier() {
return this.quantifier;
}
@@ -89,14 +90,14 @@
/*
* @see com.metamatrix.data.language.ISubqueryCompareCriteria#setOperator(int)
*/
- public void setOperator(int operator) {
+ public void setOperator(Operator operator) {
this.operator = operator;
}
/*
* @see com.metamatrix.data.language.ISubqueryCompareCriteria#setQuantifier(int)
*/
- public void setQuantifier(int quantifier) {
+ public void setQuantifier(Quantifier quantifier) {
this.quantifier = quantifier;
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ElementImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ElementImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ElementImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -27,7 +27,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.query.metadata.SupportConstants;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataFactory.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.*;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.query.metadata.QueryMetadataInterface;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataIDImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataIDImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataIDImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.query.metadata.QueryMetadataInterface;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataObjectImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataObjectImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataObjectImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.query.metadata.QueryMetadataInterface;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterIDImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterIDImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterIDImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,7 +25,7 @@
import java.util.*;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.query.metadata.QueryMetadataInterface;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.Parameter;
import com.metamatrix.dqp.DQPPlugin;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureIDImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureIDImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureIDImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.StoredProcedureInfo;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.*;
/**
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/TypeModelImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/TypeModelImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/TypeModelImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.TypeModel;
import com.metamatrix.query.metadata.SupportConstants;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPool.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPool.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPool.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Iterator;
@@ -42,10 +41,8 @@
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.connector.DataPlugin;
import com.metamatrix.connector.api.Connection;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
-import com.metamatrix.connector.monitor.AliveStatus;
-import com.metamatrix.connector.monitor.ConnectionStatus;
import com.metamatrix.connector.pool.ConnectorIdentity;
import com.metamatrix.connector.pool.PoolAwareConnection;
import com.metamatrix.connector.pool.SingleIdentity;
@@ -135,14 +132,6 @@
private volatile boolean shuttingDownPool;
- protected volatile boolean lastConnectionAttemptFailed = false;
-
- /**Exception received during last failed connection attempt*/
- private volatile Exception lastConnectionAttemptException = null;
-
- /**Time of last failed connection attempt*/
- private volatile Date lastConnectionAttemptDate = null;
-
/**
* Construct the connection pool with a connection factory
*
@@ -261,10 +250,15 @@
ConnectionWrapper conn = connLists.unused.removeFirst();
if ( conn.isAlive() ) {
- LogManager.logTrace(CTX_CONNECTOR, new Object[] {"Existing connection leased for", id}); //$NON-NLS-1$
- connLists.used.addLast(conn);
- success = true;
- return conn;
+ try {
+ conn.setConnectorIdentity(id);
+ LogManager.logDetail(CTX_CONNECTOR, new Object[] {"Existing connection leased for", id}); //$NON-NLS-1$
+ connLists.used.addLast(conn);
+ success = true;
+ return conn;
+ } catch (ConnectorException e) {
+ LogManager.logDetail(CTX_CONNECTOR, new Object[] {"Existing connection failed to have identity updated", id}); //$NON-NLS-1$
+ }
}
closeSourceConnection(conn, id);
}
@@ -351,12 +345,8 @@
sourceConnection = new ConnectionWrapper(connection, this, testConnectInterval);
LogManager.logTrace(CTX_CONNECTOR, new Object[] {"Connection pool created a connection for", id}); //$NON-NLS-1$
} catch (ConnectorException e) {
- lastConnectionAttemptFailed = true;
- lastConnectionAttemptException = e;
- lastConnectionAttemptDate = new Date();
throw new ConnectionPoolException(e);
}
- lastConnectionAttemptFailed = false;
return sourceConnection;
}
@@ -398,103 +388,6 @@
}
/**
- * Check the status of connections in this pool.
- * The pool is operational if it has at least one live
- * connection available to it.
- *
- * @return AliveStatus.ALIVE if there are any connections in use, or any live unused connections.
- * <p>AliveStatus.DEAD if there are no live connections, and the connection pool cannot create a new connection.
- * <p>AliveStatus.UNKNOWN if there are no live connections, and we don't have the ability to test getting a new connection.
- */
- public ConnectionStatus getStatus() {
- AliveStatus poolStatus;
-
- Collection values = null;
- synchronized (this.lock) {
- values = new LinkedList(this.idConnections.values());
- }
-
- poolStatus = checkStatusOfUsedConnections(values);
-
- if (poolStatus.equals(AliveStatus.UNKNOWN)) {
- poolStatus = checkStatusOfUnusedConnections(values);
- }
-
- if (poolStatus.equals(AliveStatus.UNKNOWN)) {
- poolStatus = testGetConnection();
- }
-
- if (poolStatus.equals(AliveStatus.UNKNOWN) && lastConnectionAttemptFailed) {
- poolStatus = AliveStatus.DEAD;
- }
-
- //never set the status of "UserIdentity" connectors to DEAD.
- if (poolStatus.equals(AliveStatus.DEAD) && (!connectionFactory.supportsSingleIdentity())) {
- poolStatus = AliveStatus.UNKNOWN;
- }
-
- return new ConnectionStatus(poolStatus, getTotalConnectionCount(), lastConnectionAttemptException,
- lastConnectionAttemptDate);
- }
-
- private AliveStatus checkStatusOfUsedConnections(Collection connectionInfos) {
- // Check size of all used pools. If any > 0, pool is alive.
- // Note that this only proves pool is alive for one ConnectorIdentity.
-
- for (Iterator i = connectionInfos.iterator(); i.hasNext(); ) {
- ConnectionsForId connLists = (ConnectionsForId) i.next();
-
- synchronized (connLists) {
- // check size of this used conn list for one identity
- if ( connLists.used.size() > 0 ) {
- return AliveStatus.ALIVE;
- }
- }
- }
- return AliveStatus.UNKNOWN;
- }
-
- private AliveStatus checkStatusOfUnusedConnections(Collection connectionInfos) {
- // If we're here, we haven't found a live connection yet.
- // Must query unused connections.
- for (Iterator i = connectionInfos.iterator(); i.hasNext(); ) {
- ConnectionsForId connLists = (ConnectionsForId)i.next();
-
- synchronized (connLists) {
- // check size of this used conn list for one identity
- Iterator unusedConnItr = connLists.unused.iterator();
- while (unusedConnItr.hasNext()) {
- if (((ConnectionWrapper)unusedConnItr.next()).isAlive()) {
- return AliveStatus.ALIVE;
- }
- //TODO: remove connection
- }
- }
- }
- return AliveStatus.UNKNOWN;
- }
-
- /**
- * Test datasource availability by getting a connection.
- * @return
- * @since 4.3
- */
- private AliveStatus testGetConnection() {
- if (connectionFactory.supportsSingleIdentity()) {
- try {
- ConnectionWrapper connection = obtain(null);
- boolean alive = connection.isAlive();
- release(connection, !alive);
- return (alive ? AliveStatus.ALIVE : AliveStatus.DEAD);
- } catch (ConnectionPoolException e) {
- return AliveStatus.DEAD;
- }
- }
-
- return AliveStatus.UNKNOWN;
- }
-
- /**
* Shut down the pool.
*/
public void shutDown() {
@@ -553,11 +446,11 @@
//log that we removed a connection
if (LogManager.isMessageToBeRecorded(CTX_CONNECTOR, MessageLevel.TRACE)) {
- LogManager.logTrace(CTX_CONNECTOR, DataPlugin.Util.getString("ConnectionPool.Removed_conn", id)); //$NON-NLS-1$
+ LogManager.logDetail(CTX_CONNECTOR, DataPlugin.Util.getString("ConnectionPool.Removed_conn", id)); //$NON-NLS-1$
}
} catch (Exception e) {
- LogManager.logError(CTX_CONNECTOR, DataPlugin.Util.getString("ConnectionPool.Failed_close_a_connection__2", id)); //$NON-NLS-1$
+ LogManager.logWarning(CTX_CONNECTOR, DataPlugin.Util.getString("ConnectionPool.Failed_close_a_connection__2", id)); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPoolException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPoolException.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPoolException.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
*/
package com.metamatrix.dqp.internal.pooling.connector;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
/**
* This class is for exceptions occurring within the connection pool.
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionWrapper.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionWrapper.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionWrapper.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,11 +26,12 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorCapabilities;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.Execution;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
+import com.metamatrix.connector.pool.ConnectorIdentity;
import com.metamatrix.connector.pool.PoolAwareConnection;
import com.metamatrix.connector.xa.api.XAConnection;
@@ -137,5 +138,13 @@
public void setTestInterval(long testInterval) {
this.testInterval = testInterval;
}
+
+ @Override
+ public void setConnectorIdentity(ConnectorIdentity context)
+ throws ConnectorException {
+ if (this.connection instanceof PoolAwareConnection) {
+ ((PoolAwareConnection)this.connection).setConnectorIdentity(context);
+ }
+ }
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/PooledConnector.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/PooledConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/PooledConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -34,9 +34,8 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
-import com.metamatrix.connector.monitor.ConnectionStatus;
import com.metamatrix.connector.xa.api.TransactionContext;
import com.metamatrix.connector.xa.api.XAConnection;
import com.metamatrix.connector.xa.api.XAConnector;
@@ -166,9 +165,4 @@
return conn;
}
- @Override
- public ConnectionStatus getStatusDirect() {
- return pool.getStatus();
- }
-
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,7 +29,7 @@
import java.util.List;
import com.metamatrix.common.batch.BatchSerializer;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.core.util.ExternalizeUtil;
public class AtomicResultsMessage implements Externalizable {
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/DataService.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -31,7 +31,6 @@
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.connector.monitor.AliveStatus;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestID;
@@ -122,7 +121,7 @@
* @throws MetaMatrixComponentException
* @since 4.3
*/
- AliveStatus getConnectorBindingState(String connectorBindingName)
+ Boolean getConnectorBindingState(String connectorBindingName)
throws MetaMatrixComponentException;
/**
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeConnector.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -33,25 +33,23 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.Execution;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.UpdateExecution;
+import com.metamatrix.connector.basic.BasicConnection;
import com.metamatrix.connector.basic.BasicConnectorCapabilities;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IQueryCommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.monitor.AliveStatus;
-import com.metamatrix.connector.monitor.ConnectionStatus;
-import com.metamatrix.connector.monitor.MonitoredConnector;
import com.metamatrix.connector.xa.api.TransactionContext;
import com.metamatrix.connector.xa.api.XAConnection;
import com.metamatrix.connector.xa.api.XAConnector;
-public class FakeConnector implements Connector, XAConnector, MonitoredConnector {
+public class FakeConnector implements Connector, XAConnector {
private static final int RESULT_SIZE = 5;
private boolean executeBlocks;
@@ -78,7 +76,7 @@
return new FakeXAConnection();
}
- private class FakeConnection implements Connection {
+ private class FakeConnection extends BasicConnection {
public boolean released = false;
public Execution createExecution(ICommand command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
return new FakeBlockingExecution(executionContext);
@@ -131,7 +129,7 @@
}
@Override
public void execute() throws ConnectorException {
- this.addWarning(new Exception("Some warning")); //$NON-NLS-1$
+ ec.addWarning(new Exception("Some warning")); //$NON-NLS-1$
}
@Override
public List next() throws ConnectorException, DataNotAvailableException {
@@ -193,11 +191,6 @@
this.simulatedBatchRetrievalTime = simulatedBatchRetrievalTime;
}
- @Override
- public ConnectionStatus getStatus() {
- return new ConnectionStatus(AliveStatus.DEAD);
- }
-
public void setClassloader(ClassLoader classloader) {
this.classloader = classloader;
}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeProcedureExecution.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeProcedureExecution.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeProcedureExecution.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,10 +25,10 @@
import java.util.Arrays;
import java.util.List;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IParameter;
final class FakeProcedureExecution extends BasicExecution implements ProcedureExecution {
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -38,7 +38,6 @@
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.connector.internal.ConnectorPropertyNames;
-import com.metamatrix.connector.monitor.AliveStatus;
import com.metamatrix.dqp.internal.datamgr.impl.TestConnectorWorkItem.QueueResultsReceiver;
import com.metamatrix.dqp.internal.pooling.connector.FakeSourceConnectionFactory;
import com.metamatrix.dqp.internal.process.DQPWorkContext;
@@ -149,16 +148,6 @@
cm.stop();
}
- public void testMonitoredConnector() throws Exception {
- ConnectorManager cm = new ConnectorManager();
- Properties props = new Properties();
- props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, FakeConnector.class.getName());
- props.put(ConnectorPropertyNames.CONNECTOR_CLASS_LOADER, this.getClass().getClassLoader());
- startConnectorManager(cm, props);
- assertTrue(cm.getStatus().getStatus() == AliveStatus.DEAD);
- cm.stop();
- }
-
public void testDefect19049() throws Exception {
ConnectorManager cm = new ConnectorManager();
Properties props = new Properties();
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,8 +30,8 @@
import junit.framework.TestCase;
import com.metamatrix.common.comm.api.ResultsReceiver;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ProcedureExecution;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,7 +22,7 @@
package com.metamatrix.dqp.internal.datamgr.language;
-import com.metamatrix.connector.language.ICompareCriteria;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.symbol.Constant;
@@ -62,12 +62,12 @@
}
public void testGetOperator() throws Exception {
- assertEquals(ICompareCriteria.EQ, example(CompareCriteria.EQ, 200, 100).getOperator());
- assertEquals(ICompareCriteria.GE, example(CompareCriteria.GE, 200, 100).getOperator());
- assertEquals(ICompareCriteria.GT, example(CompareCriteria.GT, 200, 100).getOperator());
- assertEquals(ICompareCriteria.LE, example(CompareCriteria.LE, 200, 100).getOperator());
- assertEquals(ICompareCriteria.LT, example(CompareCriteria.LT, 200, 100).getOperator());
- assertEquals(ICompareCriteria.NE, example(CompareCriteria.NE, 200, 100).getOperator());
+ assertEquals(Operator.EQ, example(CompareCriteria.EQ, 200, 100).getOperator());
+ assertEquals(Operator.GE, example(CompareCriteria.GE, 200, 100).getOperator());
+ assertEquals(Operator.GT, example(CompareCriteria.GT, 200, 100).getOperator());
+ assertEquals(Operator.LE, example(CompareCriteria.LE, 200, 100).getOperator());
+ assertEquals(Operator.LT, example(CompareCriteria.LT, 200, 100).getOperator());
+ assertEquals(Operator.NE, example(CompareCriteria.NE, 200, 100).getOperator());
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,6 +25,7 @@
import java.util.Iterator;
import com.metamatrix.connector.language.ICriteria;
+import com.metamatrix.connector.language.ICompoundCriteria.Operator;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.CompoundCriteria;
@@ -51,8 +52,8 @@
}
public void testGetOperator() throws Exception {
- assertEquals(CompoundCriteriaImpl.AND, example(CompoundCriteria.AND).getOperator());
- assertEquals(CompoundCriteriaImpl.OR, example(CompoundCriteria.OR).getOperator());
+ assertEquals(Operator.AND, example(CompoundCriteria.AND).getOperator());
+ assertEquals(Operator.OR, example(CompoundCriteria.OR).getOperator());
}
public void testGetCriteria() throws Exception {
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestJoinImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestJoinImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestJoinImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -26,7 +26,6 @@
import java.util.Iterator;
import com.metamatrix.connector.language.ICriteria;
-import com.metamatrix.connector.language.IJoin;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.JoinPredicate;
import com.metamatrix.query.sql.lang.JoinType;
@@ -69,11 +68,11 @@
}
public void testGetJoinType() throws Exception {
- assertEquals(IJoin.CROSS_JOIN, example(JoinType.JOIN_CROSS).getJoinType());
- assertEquals(IJoin.FULL_OUTER_JOIN, example(JoinType.JOIN_FULL_OUTER).getJoinType());
- assertEquals(IJoin.INNER_JOIN, example(JoinType.JOIN_INNER).getJoinType());
- assertEquals(IJoin.LEFT_OUTER_JOIN, example(JoinType.JOIN_LEFT_OUTER).getJoinType());
- assertEquals(IJoin.RIGHT_OUTER_JOIN, example(JoinType.JOIN_RIGHT_OUTER).getJoinType());
+ assertEquals(com.metamatrix.connector.language.IJoin.JoinType.CROSS_JOIN, example(JoinType.JOIN_CROSS).getJoinType());
+ assertEquals(com.metamatrix.connector.language.IJoin.JoinType.FULL_OUTER_JOIN, example(JoinType.JOIN_FULL_OUTER).getJoinType());
+ assertEquals(com.metamatrix.connector.language.IJoin.JoinType.INNER_JOIN, example(JoinType.JOIN_INNER).getJoinType());
+ assertEquals(com.metamatrix.connector.language.IJoin.JoinType.LEFT_OUTER_JOIN, example(JoinType.JOIN_LEFT_OUTER).getJoinType());
+ assertEquals(com.metamatrix.connector.language.IJoin.JoinType.RIGHT_OUTER_JOIN, example(JoinType.JOIN_RIGHT_OUTER).getJoinType());
}
public void testGetCriteria() throws Exception {
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestParameterImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestParameterImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestParameterImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,7 +24,7 @@
import java.sql.ResultSet;
-import com.metamatrix.connector.language.IParameter;
+import com.metamatrix.connector.language.IParameter.Direction;
import junit.framework.TestCase;
@@ -48,9 +48,9 @@
}
public void testGetDirection() throws Exception {
- assertEquals(ParameterImpl.RESULT_SET, example(0).getDirection());
- assertEquals(ParameterImpl.IN, example(1).getDirection());
- assertEquals(ParameterImpl.IN, example(2).getDirection());
+ assertEquals(Direction.RESULT_SET, example(0).getDirection());
+ assertEquals(Direction.IN, example(1).getDirection());
+ assertEquals(Direction.IN, example(2).getDirection());
}
public void testGetType() throws Exception {
@@ -67,7 +67,7 @@
public void testGetValueSpecified() throws Exception {
assertEquals(false, example(0).getValueSpecified());
- ParameterImpl param = new ParameterImpl(1, IParameter.IN, null, String.class, null);
+ ParameterImpl param = new ParameterImpl(1, Direction.IN, null, String.class, null);
// Test construction state (null value)
assertEquals(false, param.getValueSpecified());
// Test value specified not set on null
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -22,12 +22,15 @@
package com.metamatrix.dqp.internal.datamgr.language;
-import com.metamatrix.connector.language.ISubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.*;
+import junit.framework.TestCase;
+
+import com.metamatrix.connector.language.ICompareCriteria;
+import com.metamatrix.connector.language.ISubqueryCompareCriteria.Quantifier;
+import com.metamatrix.query.sql.lang.CompareCriteria;
+import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
import com.metamatrix.query.sql.symbol.ElementSymbol;
-import junit.framework.TestCase;
-
/**
*/
public class TestSubqueryCompareCriteriaImpl extends TestCase {
@@ -60,11 +63,11 @@
}
public void testOperator() throws Exception {
- assertEquals("Wrong operator", ISubqueryCompareCriteria.GT, example().getOperator()); //$NON-NLS-1$
+ assertEquals("Wrong operator", ICompareCriteria.Operator.GT, example().getOperator()); //$NON-NLS-1$
}
public void testQuantifier() throws Exception {
- assertEquals("Wrong quantifier", ISubqueryCompareCriteria.SOME, example().getQuantifier()); //$NON-NLS-1$
+ assertEquals("Wrong quantifier", Quantifier.SOME, example().getQuantifier()); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,12 +28,12 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.Execution;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.basic.BasicConnection;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.pool.PoolAwareConnection;
/**
*/
@@ -42,7 +42,7 @@
static boolean alive = true;
- class FakeSourceConnection implements Connection, PoolAwareConnection {
+ class FakeSourceConnection extends BasicConnection {
int id;
FakeSourceConnection(int id){
@@ -78,10 +78,6 @@
}
- @Override
- public void closeCalled() {
-
- }
}
@Override
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -24,8 +24,8 @@
*/
package com.metamatrix.dqp.internal.pooling.connector;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.pool.ConnectorIdentity;
import com.metamatrix.connector.pool.ConnectorIdentityFactory;
import com.metamatrix.connector.pool.UserIdentity;
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionPool.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionPool.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionPool.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -29,7 +29,6 @@
import junit.framework.TestCase;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.monitor.AliveStatus;
import com.metamatrix.connector.pool.UserIdentity;
import com.metamatrix.dqp.internal.datamgr.impl.ConnectorWrapper;
import com.metamatrix.dqp.internal.datamgr.impl.ExecutionContextImpl;
@@ -169,7 +168,7 @@
singleIDPool.obtain(context);
fail("No exception received when maxing out the pool"); //$NON-NLS-1$
} catch(ConnectionPoolException e) {
- assertEquals("The connection pool for identity \"SingleIdentity: atomic-request=null.null.null\" is at the maximum connection count \"5\" and no connection became available in the timeout period. Consider increasing the number of connections allowed per identity or the wait time.", e.getMessage()); //$NON-NLS-1$
+ assertEquals("The connection pool for identity \"SingleIdentity\" is at the maximum connection count \"5\" and no connection became available in the timeout period. Consider increasing the number of connections allowed per identity or the wait time.", e.getMessage()); //$NON-NLS-1$
}
}
@@ -197,7 +196,7 @@
fail("No exception received on pool timeout"); //$NON-NLS-1$
} catch (ConnectionPoolException e) {
- assertEquals("The connection pool for identity \"SingleIdentity: atomic-request=null.null.null\" exceeded wait time for connection, \"1\" ms, and no connection became available in the timeout period. Consider increasing the number of connections allowed per identity or the wait time.", e.getMessage()); //$NON-NLS-1$
+ assertEquals("The connection pool for identity \"SingleIdentity\" exceeded wait time for connection, \"1\" ms, and no connection became available in the timeout period. Consider increasing the number of connections allowed per identity or the wait time.", e.getMessage()); //$NON-NLS-1$
}
}
@@ -279,49 +278,6 @@
assertEquals(1, usedConns2.size());
}
- /**
- * Tests ConnectionPool.getStatus() with a SingleIdentity
- * @since 4.3
- */
- public void testGetStatusSingleIdentity() throws Exception {
- //connection is open: status should be ALIVE
- singleIDPool.lastConnectionAttemptFailed = false;
- FakeSourceConnectionFactory.alive = true;
- assertEquals(AliveStatus.ALIVE, singleIDPool.getStatus().aliveStatus);
-
- //connection can't be reached: status should be DEAD
- singleIDPool.lastConnectionAttemptFailed = false;
- FakeSourceConnectionFactory.alive = false;
- assertEquals(AliveStatus.DEAD, singleIDPool.getStatus().aliveStatus);
-
- //connection can't be reached: status should be DEAD
- singleIDPool.lastConnectionAttemptFailed = true;
- assertEquals(AliveStatus.DEAD, singleIDPool.getStatus().aliveStatus);
- }
-
- /**
- * Tests ConnectionPool.getStatus() with a UserIdentity
- * @since 4.3
- */
- public void testGetStatusUserIdentity() throws Exception {
- userIDPool.lastConnectionAttemptFailed = false;
-
- //status should always be UNKNOWN
- userIDPool.lastConnectionAttemptFailed = false;
- FakeSourceConnectionFactory.alive = true;
- assertEquals(AliveStatus.UNKNOWN, userIDPool.getStatus().aliveStatus);
-
- //status should always be UNKNOWN
- userIDPool.lastConnectionAttemptFailed = false;
- FakeSourceConnectionFactory.alive = false;
- assertEquals(AliveStatus.UNKNOWN, userIDPool.getStatus().aliveStatus);
-
- //status should always be UNKNOWN
- userIDPool.lastConnectionAttemptFailed = true;
- assertEquals(AliveStatus.UNKNOWN, userIDPool.getStatus().aliveStatus);
-
- }
-
static class LoadRunner extends Thread {
ConnectionPool pool;
private int n;
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDataTierManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDataTierManager.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/process/TestDataTierManager.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -43,7 +43,6 @@
import com.metamatrix.common.buffer.TupleSourceID;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.connector.monitor.AliveStatus;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.message.AtomicRequestID;
import com.metamatrix.dqp.message.AtomicRequestMessage;
@@ -371,7 +370,7 @@
public void startConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,ComponentNotFoundException {}
public void stopConnectorBinding(String connectorBindingName) throws ApplicationLifecycleException,ComponentNotFoundException {}
public List getConnectorBindings() throws ComponentNotFoundException {return null;}
- public AliveStatus getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {return null;}
+ public Boolean getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {return null;}
public ConnectorBinding getConnectorBinding(String connectorBindingName) throws MetaMatrixComponentException {return null;}
public Collection getConnectorBindingStatistics(String connectorBindingName) throws MetaMatrixComponentException {return null;}
public void clearConnectorBindingCache(String connectorBindingName) throws MetaMatrixComponentException {}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,15 +28,12 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.connector.monitor.AliveStatus;
-import com.metamatrix.connector.monitor.ConnectionStatus;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.internal.datamgr.impl.ConnectorWorkItem;
import com.metamatrix.dqp.internal.process.DQPWorkContext;
@@ -170,34 +167,6 @@
return caps;
}
- /*
- * @see com.metamatrix.dqp.service.DataService#getConnectorStatus()
- */
- public Map getConnectorStatus() {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see com.metamatrix.dqp.service.DataService#getConnectorStatus()
- */
- public ConnectionStatus getConnectorStatus(String connectorName) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see com.metamatrix.dqp.service.DataService#getConnectorNames()
- */
- public String[] getConnectorNames() {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see com.metamatrix.dqp.service.DataService#restartConnector(java.lang.String)
- */
- public void restartConnector(String connectorName) throws ApplicationLifecycleException {
- throw new UnsupportedOperationException();
- }
-
/**
* @see com.metamatrix.dqp.service.DataService#startConnectorBinding(java.lang.String)
* @since 4.3
@@ -226,7 +195,7 @@
* @see com.metamatrix.dqp.service.DataService#getConnectorBindingState(java.lang.String)
* @since 4.3
*/
- public AliveStatus getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {
+ public Boolean getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {
return null;
}
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/SocketVMController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/SocketVMController.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/SocketVMController.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -42,6 +42,7 @@
import com.metamatrix.common.util.VMNaming;
import com.metamatrix.platform.PlatformPlugin;
import com.metamatrix.platform.registry.ClusteredRegistryState;
+import com.metamatrix.platform.util.PlatformProxyHelper;
import com.metamatrix.platform.vm.controller.ServerEvents;
import com.metamatrix.platform.vm.controller.SocketListenerStats;
import com.metamatrix.platform.vm.controller.VMController;
@@ -140,7 +141,7 @@
ServerSocketConfiguration helper = new ServerSocketConfiguration();
try {
helper.init();
- listener = new SocketListener(socketPort, bindaddress, this.clientServices, inputBufferSize, outputBufferSize, workerPool, helper.getServerSSLEngine(), helper.isClientEncryptionEnabled());
+ listener = new SocketListener(socketPort, bindaddress, this.clientServices, inputBufferSize, outputBufferSize, workerPool, helper.getServerSSLEngine(), helper.isClientEncryptionEnabled(), PlatformProxyHelper.getSessionServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL));
} catch (Exception e) {
LogManager.logCritical(LogCommonConstants.CTX_CONTROLLER, e, PlatformPlugin.Util.getString("SocketVMController.2",param)); //$NON-NLS-1$
System.exit(1);
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/LogonImpl.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -35,8 +35,8 @@
import com.metamatrix.api.exception.security.SessionServiceException;
import com.metamatrix.common.api.MMURL;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.connector.exception.ConnectorException;
-import com.metamatrix.connector.pool.CredentialMap;
+import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.api.CredentialMap;
import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.jdbc.api.ConnectionProperties;
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/ServerWorkItem.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -57,15 +57,17 @@
private final ClientInstance socketClientInstance;
private final Serializable messageKey;
private final Message message;
- private final ClientServiceRegistry<SessionServiceInterface> server;
+ private final ClientServiceRegistry server;
+ private final SessionServiceInterface sessionService;
public ServerWorkItem(ClientInstance socketClientInstance,
Serializable messageKey, Message message,
- ClientServiceRegistry server) {
+ ClientServiceRegistry server, SessionServiceInterface sessionService) {
this.socketClientInstance = socketClientInstance;
this.messageKey = messageKey;
this.message = message;
this.server = server;
+ this.sessionService = sessionService;
}
/**
@@ -103,7 +105,7 @@
}
if (!(instance instanceof ILogon)) {
DQPWorkContext workContext = this.socketClientInstance.getWorkContext();
- server.getSessionService().validateSession(workContext.getSessionId());
+ sessionService.validateSession(workContext.getSessionId());
}
service = serviceStruct.targetClass;
ReflectionHelper helper = new ReflectionHelper(instance.getClass());
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketClientInstance.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketClientInstance.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketClientInstance.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -41,6 +41,7 @@
import com.metamatrix.common.util.crypto.NullCryptor;
import com.metamatrix.core.log.MessageLevel;
import com.metamatrix.dqp.internal.process.DQPWorkContext;
+import com.metamatrix.platform.security.api.service.SessionServiceInterface;
/**
* Sockets implementation of the communication framework class representing the server's view of a client connection.
@@ -59,12 +60,14 @@
private boolean usingEncryption;
private DhKeyGenerator keyGen;
private DQPWorkContext workContext = new DQPWorkContext();
+ private SessionServiceInterface sessionService;
- public SocketClientInstance(ObjectChannel objectSocket, WorkerPool workerPool, ClientServiceRegistry server, boolean isClientEncryptionEnabled) {
+ public SocketClientInstance(ObjectChannel objectSocket, WorkerPool workerPool, ClientServiceRegistry server, boolean isClientEncryptionEnabled, SessionServiceInterface sessionService) {
this.objectSocket = objectSocket;
this.workerPool = workerPool;
this.server = server;
this.usingEncryption = isClientEncryptionEnabled;
+ this.sessionService = sessionService;
}
public void send(Message message, Serializable messageKey) {
@@ -135,7 +138,7 @@
if (LogManager.isMessageToBeRecorded(SocketVMController.SOCKET_CONTEXT, SocketLog.DETAIL)) {
LogManager.logDetail(SocketVMController.SOCKET_CONTEXT, "processing message:" + packet); //$NON-NLS-1$
}
- workerPool.execute(new ServerWorkItem(this, packet.getMessageKey(), packet, this.server));
+ workerPool.execute(new ServerWorkItem(this, packet.getMessageKey(), packet, this.server, this.sessionService));
}
public void shutdown() throws CommunicationException {
Modified: trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketListener.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketListener.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/server/src/main/java/com/metamatrix/common/comm/platform/socket/server/SocketListener.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -45,6 +45,7 @@
import com.metamatrix.common.queue.WorkerPool;
import com.metamatrix.common.queue.WorkerPoolFactory;
import com.metamatrix.core.util.MetaMatrixProductVersion;
+import com.metamatrix.platform.security.api.service.SessionServiceInterface;
import com.metamatrix.platform.vm.controller.SocketListenerStats;
/**
@@ -56,6 +57,7 @@
private SSLAwareChannelHandler channelHandler;
private Channel serverChanel;
private boolean isClientEncryptionEnabled;
+ private SessionServiceInterface sessionService;
/**
*
@@ -69,9 +71,9 @@
*/
public SocketListener(int port, String bindAddress,
ClientServiceRegistry server, int inputBufferSize,
- int outputBufferSize, WorkerPool workerPool, SSLEngine engine, boolean isClientEncryptionEnabled) {
+ int outputBufferSize, WorkerPool workerPool, SSLEngine engine, boolean isClientEncryptionEnabled, SessionServiceInterface sessionService) {
this.isClientEncryptionEnabled = isClientEncryptionEnabled;
-
+ this.sessionService = sessionService;
if (port < 0 || port > 0xFFFF) {
throw new IllegalArgumentException("port out of range:" + port); //$NON-NLS-1$
}
@@ -122,7 +124,7 @@
}
public ChannelListener createChannelListener(ObjectChannel channel) {
- return new SocketClientInstance(channel, this.workerPool, this.server, this.isClientEncryptionEnabled);
+ return new SocketClientInstance(channel, this.workerPool, this.server, this.isClientEncryptionEnabled, this.sessionService);
}
}
\ No newline at end of file
Modified: trunk/server/src/main/java/com/metamatrix/platform/vm/controller/VMController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/vm/controller/VMController.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/server/src/main/java/com/metamatrix/platform/vm/controller/VMController.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -169,7 +169,7 @@
// Server events that are being generated
ServerEvents events;
- protected ClientServiceRegistry<SessionServiceInterface> clientServices;
+ protected ClientServiceRegistry clientServices;
private Map<ComponentTypeID, Properties> defaultPropertiesCache = new HashMap<ComponentTypeID, Properties>();
private Properties hostProperties;
@@ -206,7 +206,7 @@
//Register with registry
logMessage(PlatformPlugin.Util.getString(LogMessageKeys.VM_0006, id));
- this.clientServices = new ClientServiceRegistry(PlatformProxyHelper.getSessionServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL));
+ this.clientServices = new ClientServiceRegistry();
RuntimeMetadataCatalog.getInstance().init(CurrentConfiguration.getInstance().getProperties(), ResourceFinder.getMessageBus(), ResourceFinder.getCacheFactory());
Modified: trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -70,10 +70,8 @@
import com.metamatrix.common.util.VMNaming;
import com.metamatrix.common.util.crypto.CryptoException;
import com.metamatrix.common.util.crypto.CryptoUtil;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.internal.ConnectorPropertyNames;
-import com.metamatrix.connector.monitor.AliveStatus;
-import com.metamatrix.connector.monitor.ConnectionStatus;
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.event.EventObjectListener;
import com.metamatrix.core.util.ReflectionHelper;
@@ -349,24 +347,20 @@
public void checkState() throws ServiceStateException {
if (monitoringEnabled) {
- ConnectionStatus status = connectorMgr.getStatus();
+ Boolean status = connectorMgr.getStatus();
int state = getCurrentState();
- if (state == ServiceState.STATE_OPEN) {
- if (status.getStatus().equals(AliveStatus.DEAD)) {
- updateState(ServiceState.STATE_DATA_SOURCE_UNAVAILABLE);
-
- logOK("ConnectorService.Change_state_to_data_source_unavailable", connectorMgrName); //$NON-NLS-1$
-
- //TODO: store the exception in the registry
- }
+ if (state == ServiceState.STATE_OPEN && status == Boolean.FALSE) {
+ updateState(ServiceState.STATE_DATA_SOURCE_UNAVAILABLE);
+
+ logOK("ConnectorService.Change_state_to_data_source_unavailable", connectorMgrName); //$NON-NLS-1$
+
+ //TODO: store the exception in the registry
}
- if (state == ServiceState.STATE_DATA_SOURCE_UNAVAILABLE) {
- if (status.getStatus().equals(AliveStatus.ALIVE)) {
- this.updateState(ServiceState.STATE_OPEN);
-
- logOK("ConnectorService.Change_state_to_open", connectorMgrName); //$NON-NLS-1$
- }
+ if (state == ServiceState.STATE_DATA_SOURCE_UNAVAILABLE && status == Boolean.TRUE) {
+ this.updateState(ServiceState.STATE_OPEN);
+
+ logOK("ConnectorService.Change_state_to_open", connectorMgrName); //$NON-NLS-1$
}
}
Modified: trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServiceInterface.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServiceInterface.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServiceInterface.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,7 +30,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.comm.api.ResultsReceiver;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestID;
Modified: trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformDataService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformDataService.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/server/src/main/java/com/metamatrix/server/dqp/service/PlatformDataService.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -28,7 +28,6 @@
import java.util.Collection;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
@@ -39,12 +38,8 @@
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
import com.metamatrix.common.comm.api.ResultsReceiver;
import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.api.ConnectorBindingType;
-import com.metamatrix.connector.exception.ConnectorException;
-import com.metamatrix.connector.monitor.AliveStatus;
-import com.metamatrix.connector.monitor.ConnectionStatus;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.server.ResourceFinder;
import com.metamatrix.dqp.internal.datamgr.ConnectorID;
import com.metamatrix.dqp.internal.process.DQPWorkContext;
import com.metamatrix.dqp.message.AtomicRequestID;
@@ -54,6 +49,7 @@
import com.metamatrix.dqp.service.DataService;
import com.metamatrix.platform.util.PlatformProxyHelper;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
+import com.metamatrix.server.ResourceFinder;
import com.metamatrix.server.ServerPlugin;
import com.metamatrix.server.connector.service.ConnectorServiceInterface;
@@ -165,27 +161,6 @@
// that the client is shutting down
}
- /*
- * @see com.metamatrix.dqp.service.DataService#getConnectorStatus()
- */
- public Map getConnectorStatus() {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see com.metamatrix.dqp.service.DataService#getConnectorStatus()
- */
- public ConnectionStatus getConnectorStatus(String connectorName) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see com.metamatrix.dqp.service.DataService#getConnectorNames()
- */
- public String[] getConnectorNames() {
- throw new UnsupportedOperationException();
- }
-
/**
* @see com.metamatrix.dqp.service.DataService#startConnectorBinding(java.lang.String)
* @since 4.3
@@ -213,34 +188,10 @@
}
/**
- * @see com.metamatrix.dqp.service.DataService#addConnectorType(java.lang.String, com.metamatrix.common.config.api.ConnectorBindingType)
- * @since 4.3
- */
- public void addConnectorType(String name, ConnectorBindingType type) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @see com.metamatrix.dqp.service.DataService#deleteConnectorType(java.lang.String)
- * @since 4.3
- */
- public void deleteConnectorType(String name) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @see com.metamatrix.dqp.service.DataService#getConnectorTypes()
- * @since 4.3
- */
- public List getConnectorTypes() {
- throw new UnsupportedOperationException();
- }
-
- /**
* @see com.metamatrix.dqp.service.DataService#getConnectorBindingState(java.lang.String)
* @since 4.3
*/
- public AliveStatus getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {
+ public Boolean getConnectorBindingState(String connectorBindingName) throws MetaMatrixComponentException {
throw new UnsupportedOperationException();
}
Modified: trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestCommSockets.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestCommSockets.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestCommSockets.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -62,12 +62,12 @@
public void testFailedConnect() throws Exception {
InetSocketAddress addr = new InetSocketAddress(0);
- ClientServiceRegistry<SessionServiceInterface> csr = new ClientServiceRegistry(
- mock(SessionServiceInterface.class));
- csr.registerClientService(ILogon.class, new LogonImpl(csr.getSessionService(), "fakeCluster"), "foo"); //$NON-NLS-1$ //$NON-NLS-2$
+ ClientServiceRegistry csr = new ClientServiceRegistry();
+ SessionServiceInterface sessionService = mock(SessionServiceInterface.class);
+ csr.registerClientService(ILogon.class, new LogonImpl(sessionService, "fakeCluster"), "foo"); //$NON-NLS-1$ //$NON-NLS-2$
listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(),
csr, 1024, 1024, WorkerPoolFactory.newWorkerPool(
- "testIO", 1, 120000), null, true); //$NON-NLS-1$
+ "testIO", 1, 120000), null, true, sessionService); //$NON-NLS-1$
try {
Properties p = new Properties();
@@ -114,10 +114,9 @@
SSLEngine serverSSL, boolean isClientEncryptionEnabled, Properties socketConfig) throws CommunicationException,
ConnectionException {
InetSocketAddress addr = new InetSocketAddress(0);
- ClientServiceRegistry<SessionServiceInterface> csr = new ClientServiceRegistry(
- mock(SessionServiceInterface.class));
- csr.registerClientService(ILogon.class, new LogonImpl(csr
- .getSessionService(), "fakeCluster") { //$NON-NLS-1$
+ SessionServiceInterface sessionService = mock(SessionServiceInterface.class);
+ ClientServiceRegistry csr = new ClientServiceRegistry();
+ csr.registerClientService(ILogon.class, new LogonImpl(sessionService, "fakeCluster") { //$NON-NLS-1$
@Override
public LogonResult logon(Properties connProps)
throws LogonException, ComponentNotFoundException {
@@ -126,7 +125,7 @@
}, "foo"); //$NON-NLS-1$
listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(),
csr, 1024, 1024, WorkerPoolFactory.newWorkerPool(
- "testIO", 1, 120000), serverSSL, isClientEncryptionEnabled); //$NON-NLS-1$
+ "testIO", 1, 120000), serverSSL, isClientEncryptionEnabled, sessionService); //$NON-NLS-1$
SocketListenerStats stats = listener.getStats();
assertEquals(0, stats.maxSockets);
Modified: trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/server/src/test/java/com/metamatrix/common/comm/platform/socket/server/TestSocketRemoting.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -106,7 +106,7 @@
public void send(Message message, MessageListener listener,
Serializable messageKey) throws CommunicationException {
- ServerWorkItem workItem = new ServerWorkItem(this, messageKey, message, clientServiceRegistry);
+ ServerWorkItem workItem = new ServerWorkItem(this, messageKey, message, clientServiceRegistry, SimpleMock.createSimpleMock(SessionServiceInterface.class));
this.listener = listener;
workItem.run();
}
@@ -143,7 +143,7 @@
}
public void testMethodInvocation() throws Exception {
- ClientServiceRegistry csr = new ClientServiceRegistry(SimpleMock.createSimpleMock(SessionServiceInterface.class));
+ ClientServiceRegistry csr = new ClientServiceRegistry();
csr.registerClientService(ILogon.class, new ILogon() {
public ResultsFuture<?> logoff()
Modified: trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -30,8 +30,8 @@
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.JDBCPropertyNames;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
import com.metamatrix.connector.language.ICommand;
Modified: trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -32,8 +32,8 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
import com.metamatrix.connector.language.ICommand;
Modified: trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/util/TestJDBCExecutionHelper.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/util/TestJDBCExecutionHelper.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/util/TestJDBCExecutionHelper.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -31,8 +31,8 @@
import junit.framework.TestCase;
import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.ISelect;
import com.metamatrix.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
Modified: trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/MockConnector.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/MockConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/MockConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -10,12 +10,12 @@
import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicConnection;
import com.metamatrix.connector.basic.BasicConnectorCapabilities;
-import com.metamatrix.connector.exception.ConnectorException;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IGroup;
import com.metamatrix.connector.language.IProcedure;
Modified: trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataInConnector.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataInConnector.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataInConnector.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -1,6 +1,6 @@
package com.metamatrix.data.metadata.runtime;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.jdbc.api.AbstractMMQueryTestCase;
Modified: trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestParams.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestParams.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestParams.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -31,6 +31,7 @@
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
+import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.Parameter;
import com.metamatrix.connector.metadata.runtime.TypeModel;
@@ -77,7 +78,7 @@
String name,
String fullName,
int index,
- int direction,
+ Direction direction,
String nameInSource,
String defaultValue,
int nullability,
@@ -121,7 +122,7 @@
"in1",
"sptest.proc1.in1",
1,
- IParameter.IN,
+ Direction.IN,
null,
"sample default",
TypeModel.NOT_NULLABLE,
@@ -138,7 +139,7 @@
"in2",
"sptest.proc1.in2",
2,
- IParameter.IN,
+ Direction.IN,
null,
"15",
TypeModel.NULLABLE,
@@ -155,7 +156,7 @@
"in3",
"sptest.proc1.in3",
3,
- IParameter.IN,
+ Direction.IN,
null,
"2003-04-23 09:30:00",
TypeModel.NULLABLE_UNKNOWN,
@@ -172,7 +173,7 @@
"inOptional",
"sptest.proc1.inOptional",
4,
- IParameter.IN,
+ Direction.IN,
"optionalName",
null,
TypeModel.NULLABLE,
Modified: trunk/test-integration/src/test/java/com/metamatrix/data/visitor/util/TestCollectorVisitor.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/data/visitor/util/TestCollectorVisitor.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/visitor/util/TestCollectorVisitor.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,6 +25,7 @@
import java.util.*;
import com.metamatrix.connector.language.*;
+import com.metamatrix.connector.language.ICompareCriteria.Operator;
import com.metamatrix.connector.visitor.util.CollectorVisitor;
import com.metamatrix.dqp.internal.datamgr.language.*;
@@ -115,7 +116,7 @@
GroupImpl g1 = new GroupImpl("g1", null, null); //$NON-NLS-1$
ElementImpl e1 = new ElementImpl(g1, "e1", null, String.class); //$NON-NLS-1$
ElementImpl e2 = new ElementImpl(g1, "e2", null, String.class); //$NON-NLS-1$
- CompareCriteriaImpl cc = new CompareCriteriaImpl(e1, e2, ICompareCriteria.EQ);
+ CompareCriteriaImpl cc = new CompareCriteriaImpl(e1, e2, Operator.EQ);
helpTestElementsUsedByGroups(cc, new String[] {"g1.e1", "g1.e2"}, new String[] {"g1"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
Modified: trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/FakeXAConnection.java
===================================================================
--- trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/FakeXAConnection.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/FakeXAConnection.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -25,14 +25,15 @@
import javax.transaction.xa.XAResource;
import com.metamatrix.connector.api.ConnectorCapabilities;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.Execution;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.basic.BasicConnection;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xa.api.XAConnection;
-class FakeXAConnection implements XAConnection {
+class FakeXAConnection extends BasicConnection implements XAConnection {
String name;
boolean released = false;
boolean failToCreateXAResource = false;
Modified: trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java
===================================================================
--- trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java 2009-02-16 18:56:03 UTC (rev 473)
+++ trunk/txn-jbossts/src/test/java/com/metamatrix/xa/arjuna/TestArjunaRecovery.java 2009-02-16 21:35:21 UTC (rev 474)
@@ -35,7 +35,7 @@
import com.arjuna.ats.arjuna.common.Configuration;
import com.arjuna.ats.arjuna.recovery.RecoveryConfiguration;
import com.metamatrix.common.xa.MMXid;
-import com.metamatrix.connector.exception.ConnectorException;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.dqp.internal.transaction.TransactionProvider;
import com.metamatrix.dqp.service.TransactionService;
15 years, 10 months
teiid SVN: r473 - in trunk: connectors/connector-salesforce and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-02-16 13:56:03 -0500 (Mon, 16 Feb 2009)
New Revision: 473
Modified:
trunk/connectors/connector-salesforce/pom.xml
trunk/connectors/connector-xml-common/pom.xml
trunk/connectors/connector-xml/pom.xml
trunk/connectors/salesforce-api/pom.xml
trunk/pom.xml
Log:
TEIID-133 minimizing dependencies in common xml module.
Modified: trunk/connectors/connector-salesforce/pom.xml
===================================================================
--- trunk/connectors/connector-salesforce/pom.xml 2009-02-16 17:42:45 UTC (rev 472)
+++ trunk/connectors/connector-salesforce/pom.xml 2009-02-16 18:56:03 UTC (rev 473)
@@ -1,56 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <parent>
- <artifactId>teiid-connectors</artifactId>
- <groupId>org.jboss.teiid.connectors</groupId>
- <version>6.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>connector-salesforce</artifactId>
- <name>Salesforce Connector</name>
- <description>Integrates the query engine with Salesforce.com.</description>
- <dependencies>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis-saaj</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis-jaxrpc</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>apache-discovery</groupId>
- <artifactId>commons-discovery</artifactId>
- <version>0.2</version>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- </dependency>
- <dependency>
- <groupId>wsdl4j</groupId>
- <artifactId>wsdl4j</artifactId>
- <version>1.5.1</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis</artifactId>
- <version>1.3</version>
- </dependency>
- <dependency>
- <groupId>apache-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.0.1</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <parent>
+ <artifactId>teiid-connectors</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
- <artifactId>salesforce-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
+ <version>6.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>connector-salesforce</artifactId>
+ <name>Salesforce Connector</name>
+ <description>Integrates the query engine with Salesforce.com.</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>connector-xml-common</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>salesforce-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
\ No newline at end of file
Modified: trunk/connectors/connector-xml/pom.xml
===================================================================
--- trunk/connectors/connector-xml/pom.xml 2009-02-16 17:42:45 UTC (rev 472)
+++ trunk/connectors/connector-xml/pom.xml 2009-02-16 18:56:03 UTC (rev 473)
@@ -1,27 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <parent>
- <artifactId>connector-xml-common</artifactId>
- <groupId>org.jboss.teiid.connectors</groupId>
- <version>6.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>connector-xml</artifactId>
- <name>XML Connector</name>
- <description>This connector produces the XML documents from Web
- service and transforms the document into a relational structure.</description>
- <dependencies>
- <dependency>
- <groupId>org.jboss.teiid.connectors</groupId>
- <artifactId>connector-xml-common</artifactId>
- <version>6.0.0-SNAPSHOT</version>
- <type>pom</type>
- </dependency>
- </dependencies>
- <dependencyManagement>
- <dependencies>
- </dependencies>
- </dependencyManagement>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <parent>
+ <artifactId>teiid-connectors</artifactId>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <version>6.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>connector-xml</artifactId>
+ <name>XML Connector</name>
+ <description>This connector produces the XML documents from Web
+ service and transforms the document into a relational structure.</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>connector-xml-common</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
</project>
\ No newline at end of file
Modified: trunk/connectors/connector-xml-common/pom.xml
===================================================================
--- trunk/connectors/connector-xml-common/pom.xml 2009-02-16 17:42:45 UTC (rev 472)
+++ trunk/connectors/connector-xml-common/pom.xml 2009-02-16 18:56:03 UTC (rev 473)
@@ -8,11 +8,9 @@
<version>6.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.teiid.connectors</groupId>
<artifactId>connector-xml-common</artifactId>
<packaging>pom</packaging>
<name>XML Common Connector</name>
- <version>6.0.0-SNAPSHOT</version>
<description>This project holds the common dependencies for the XML Connector</description>
<dependencies>
<dependency>
@@ -39,6 +37,18 @@
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>dom4j</groupId>
+ <artifactId>dom4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xom</groupId>
+ <artifactId>xom</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -67,12 +77,6 @@
</dependency>
<dependency>
<groupId>axis</groupId>
- <artifactId>axis-wsdl4j</artifactId>
- <version>1.5.1</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
<artifactId>axis-schema</artifactId>
<version>1.3</version>
<scope>runtime</scope>
@@ -106,10 +110,5 @@
<version>2.7.0</version>
<scope>runtime</scope>
</dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <scope>compile</scope>
- </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: trunk/connectors/salesforce-api/pom.xml
===================================================================
--- trunk/connectors/salesforce-api/pom.xml 2009-02-16 17:42:45 UTC (rev 472)
+++ trunk/connectors/salesforce-api/pom.xml 2009-02-16 18:56:03 UTC (rev 473)
@@ -1,6 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <artifactId>connector-xml-common</artifactId>
+ <artifactId>teiid-connectors</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
<version>6.0.0-SNAPSHOT</version>
</parent>
@@ -12,7 +12,7 @@
<dependency>
<groupId>org.jboss.teiid.connectors</groupId>
<artifactId>connector-xml-common</artifactId>
- <version>6.0.0-SNAPSHOT</version>
+ <version>${project.version}</version>
<type>pom</type>
</dependency>
</dependencies>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-02-16 17:42:45 UTC (rev 472)
+++ trunk/pom.xml 2009-02-16 18:56:03 UTC (rev 473)
@@ -343,6 +343,16 @@
<artifactId>commons-logging</artifactId>
<version>1.1</version>
<scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>logkit</groupId>
+ <artifactId>logkit</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>avalon-framework</groupId>
+ <artifactId>avalon-framework</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>jgroups</groupId>
15 years, 10 months
teiid SVN: r472 - trunk/connectors/connector-xml-common.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2009-02-16 12:42:45 -0500 (Mon, 16 Feb 2009)
New Revision: 472
Modified:
trunk/connectors/connector-xml-common/
Log:
TEIID-133: Re-factored common dependencies from XML Connector.
Property changes on: trunk/connectors/connector-xml-common
___________________________________________________________________
Name: svn:ignore
+ target
15 years, 10 months
teiid SVN: r471 - in trunk/connectors: connector-xml and 1 other directories.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2009-02-16 12:02:02 -0500 (Mon, 16 Feb 2009)
New Revision: 471
Modified:
trunk/connectors/connector-xml/pom.xml
trunk/connectors/pom.xml
trunk/connectors/salesforce-api/pom.xml
Log:
TEIID-133: Re-factored common dependencies from XML Connector.
Modified: trunk/connectors/connector-xml/pom.xml
===================================================================
--- trunk/connectors/connector-xml/pom.xml 2009-02-16 16:59:17 UTC (rev 470)
+++ trunk/connectors/connector-xml/pom.xml 2009-02-16 17:02:02 UTC (rev 471)
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<parent>
- <artifactId>teiid-connectors</artifactId>
+ <artifactId>connector-xml-common</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
<version>6.0.0-SNAPSHOT</version>
</parent>
@@ -13,106 +13,15 @@
<description>This connector produces the XML documents from Web
service and transforms the document into a relational structure.</description>
<dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- </dependency>
- <dependency>
- <groupId>apache-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.0.1</version>
- </dependency>
- <dependency>
- <groupId>apache-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>jaxen</groupId>
- <artifactId>jaxen</artifactId>
- <version>1.1.1</version>
- <exclusions>
- <exclusion>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.jms</groupId>
- <artifactId>jms</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis</artifactId>
- <version>1.3</version>
- </dependency>
- <dependency>
- <groupId>wss4j</groupId>
- <artifactId>wss4j</artifactId>
- <version>1.5.0</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis-jaxrpc</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis-saaj</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis-wsdl4j</artifactId>
- <version>1.5.1</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis-schema</artifactId>
- <version>1.3</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>opensaml</groupId>
- <artifactId>opensaml</artifactId>
- <version>1.1b</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>apache-xmlsec</groupId>
- <artifactId>xmlsec</artifactId>
- <version>1.3.0</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>apache-discovery</groupId>
- <artifactId>commons-discovery</artifactId>
- <version>0.2</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>xalan</groupId>
- <artifactId>xalan</artifactId>
- <version>2.7.0</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <scope>compile</scope>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>connector-xml-common</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
</dependencies>
+ <dependencyManagement>
+ <dependencies>
+ </dependencies>
+ </dependencyManagement>
</project>
\ No newline at end of file
Modified: trunk/connectors/pom.xml
===================================================================
--- trunk/connectors/pom.xml 2009-02-16 16:59:17 UTC (rev 470)
+++ trunk/connectors/pom.xml 2009-02-16 17:02:02 UTC (rev 471)
@@ -121,5 +121,6 @@
<module>connector-salesforce</module>
<module>salesforce-api</module>
<module>connector-ldap</module>
+ <module>connector-xml-common</module>
</modules>
</project>
\ No newline at end of file
Modified: trunk/connectors/salesforce-api/pom.xml
===================================================================
--- trunk/connectors/salesforce-api/pom.xml 2009-02-16 16:59:17 UTC (rev 470)
+++ trunk/connectors/salesforce-api/pom.xml 2009-02-16 17:02:02 UTC (rev 471)
@@ -1,6 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <artifactId>teiid-connectors</artifactId>
+ <artifactId>connector-xml-common</artifactId>
<groupId>org.jboss.teiid.connectors</groupId>
<version>6.0.0-SNAPSHOT</version>
</parent>
@@ -9,37 +9,11 @@
<name>Salesforce API</name>
<description>The java API for the Salesforce.com partner web service API</description>
<dependencies>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis</artifactId>
- <version>1.3</version>
- </dependency>
- <dependency>
- <groupId>wss4j</groupId>
- <artifactId>wss4j</artifactId>
- <version>1.5.0</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis-jaxrpc</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis-saaj</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis-wsdl4j</artifactId>
- <version>1.5.1</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>axis</groupId>
- <artifactId>axis-schema</artifactId>
- <version>1.3</version>
- <scope>runtime</scope>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>connector-xml-common</artifactId>
+ <version>6.0.0-SNAPSHOT</version>
+ <type>pom</type>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
15 years, 10 months
teiid SVN: r470 - in trunk/connectors: connector-xml-common and 1 other directory.
by teiid-commits@lists.jboss.org
Author: tejones
Date: 2009-02-16 11:59:17 -0500 (Mon, 16 Feb 2009)
New Revision: 470
Added:
trunk/connectors/connector-xml-common/
trunk/connectors/connector-xml-common/pom.xml
Log:
TEIID-133: Re-factored common dependencies from XML Connector
Added: trunk/connectors/connector-xml-common/pom.xml
===================================================================
--- trunk/connectors/connector-xml-common/pom.xml (rev 0)
+++ trunk/connectors/connector-xml-common/pom.xml 2009-02-16 16:59:17 UTC (rev 470)
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <parent>
+ <artifactId>teiid-connectors</artifactId>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <version>6.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>connector-xml-common</artifactId>
+ <packaging>pom</packaging>
+ <name>XML Common Connector</name>
+ <version>6.0.0-SNAPSHOT</version>
+ <description>This project holds the common dependencies for the XML Connector</description>
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+ <dependency>
+ <groupId>apache-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>apache-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ <version>1.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.jms</groupId>
+ <artifactId>jms</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis</artifactId>
+ <version>1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>wss4j</groupId>
+ <artifactId>wss4j</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis-saaj</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis-wsdl4j</artifactId>
+ <version>1.5.1</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>axis</groupId>
+ <artifactId>axis-schema</artifactId>
+ <version>1.3</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>opensaml</groupId>
+ <artifactId>opensaml</artifactId>
+ <version>1.1b</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-xmlsec</groupId>
+ <artifactId>xmlsec</artifactId>
+ <version>1.3.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-discovery</groupId>
+ <artifactId>commons-discovery</artifactId>
+ <version>0.2</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Property changes on: trunk/connectors/connector-xml-common/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 10 months