teiid SVN: r489 - in trunk: common-internal/src/main/java/com/metamatrix/common/log and 4 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-02-24 11:16:49 -0500 (Tue, 24 Feb 2009)
New Revision: 489
Removed:
trunk/common-internal/src/main/java/com/metamatrix/common/log/format/
trunk/common-internal/src/main/java/com/metamatrix/dqp/
trunk/common-internal/src/main/java/com/metamatrix/platform/security/membership/service/
trunk/connector-api/src/main/java/com/metamatrix/connector/identity/
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/
Log:
TEIID-164 TEIID-374 refactored connector metadata, removed collection setters from connector api, moved pooling and identity knowlege onto base connector api
15 years, 10 months
teiid SVN: r488 - in trunk: connector-api/src/main/java/com/metamatrix/connector/basic and 61 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-02-24 11:16:42 -0500 (Tue, 24 Feb 2009)
New Revision: 488
Added:
trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorIdentity.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/MappedUserIdentity.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/SingleIdentity.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestPerUserPool.java
trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataObject.java
Removed:
trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataID.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeRuntimeMetadata.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/cache/MockDocumentCache.java
trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/FakeRuntimeMetadata.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/ParameterIDImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureIDImpl.java
trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataID.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/ConnectorAnnotations.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/ExecutionContext.java
trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnection.java
trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IBulkInsert.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICompoundCriteria.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IElement.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IFrom.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IFunction.java
trunk/connector-api/src/main/java/com/metamatrix/connector/language/IGroup.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/IMetadataReference.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/metadata/runtime/Element.java
trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Group.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/Procedure.java
trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/RuntimeMetadata.java
trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/SQLStringVisitor.java
trunk/connector-api/src/main/resources/com/metamatrix/data/i18n.properties
trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectConnector.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/ObjectQuery.java
trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQueryProcessor.java
trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/TranslationUtility.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/JDBCSourceConnection.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/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/mysql/MySQLConvertModifier.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/DayWeekQuarterFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ExtractFunctionModifier.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/LocateFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/Log10FunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.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/DatePartFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/ModifiedDatePartFunctionModifier.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/sybase/ModFunctionModifier.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/translator/BasicFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/DropFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SubstringFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/util/FunctionReplacementVisitor.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/derby/TestDerbyConvertModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestDropFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.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-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.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/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/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/execution/UpdateExecutionImpl.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/InsertVisitor.java
trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.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-xml/src/main/java/com/metamatrix/connector/xml/base/CriteriaDesc.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/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/xmlsource/XMLSourceConnector.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/SoapExecution.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/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/cache/TestRequestRecord.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/xmlsource/file/TestFileExecution.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/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-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.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/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/BaseSourceConnectionFactory.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/FilterFunctionModifier.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/NearestNeighborFunctionModifier.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/RelateFunctionModifier.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/WithinDistanceFunctionModifier.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/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/language/ElementImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/FunctionImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/GroupImpl.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/ProcedureImpl.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/GroupImpl.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/ParameterImpl.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureImpl.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/ConnectionWrapper.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeConnector.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestElementImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestFunctionImpl.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java
trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/metadata/TestMetadataFactory.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/pooling/connector/TestConnectionWrapper.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/QueryMetadataInterfaceBuilder.java
trunk/test-integration/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.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/MockConnector.java
trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestElement.java
trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestGroup.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/TestCollectorVisitor.java
trunk/test-integration/src/test/java/com/metamatrix/data/visitor/util/TestSQLStringVisitor.java
Log:
TEIID-164 TEIID-374 refactored connector metadata, removed collection setters from connector api, moved pooling and identity knowlege onto base 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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connection.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,7 +22,6 @@
package com.metamatrix.connector.api;
-import com.metamatrix.connector.identity.PoolAwareConnection;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
@@ -63,6 +62,20 @@
* @return true if open, false if there is a source error.
*/
boolean isAlive();
-
+
+ /**
+ * 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 context)
+ throws ConnectorException;
+
+ /**
+ * Called by the pool to indicate that the connection was returned to the pool.
+ * The actual close call will be made when the pool wants to purge this connection.
+ */
+ void closeCalled();
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -68,5 +68,21 @@
* @return ConnectorCapabilities, may return null if the Connector provides User scoped capabilities {@link Connection#getCapabilities()}
*/
ConnectorCapabilities getCapabilities();
+
+ /**
+ * 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.
+ *
+ * Implementors of this class may use a different implementation of the
+ * {@link ConnectorIdentity} interface to similarly affect pooling.
+ *
+ * @param context The context provided by the Connector Manager
+ * @return The associated connector identity
+ * @throws ConnectorException If a null context is not accepted or an error occurs while creating the identity.
+ */
+ ConnectorIdentity createIdentity(ExecutionContext context)
+ throws ConnectorException;
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorAnnotations.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorAnnotations.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorAnnotations.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -27,7 +27,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import com.metamatrix.connector.identity.ConnectorIdentityFactory;
import com.metamatrix.connector.internal.ConnectorPropertyNames;
public class ConnectorAnnotations {
@@ -51,5 +50,13 @@
public @interface SynchronousWorkers {
boolean enabled() default true;
}
+
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target({ElementType.TYPE})
+ public @interface ConnectorConfiguration {
+ boolean userIdentityCapable() default false;
+ boolean useSynchronousWorkers() default true;
+ boolean useConnectionPooling() default true;
+ }
}
Copied: trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorIdentity.java (from rev 481, trunk/connector-api/src/main/java/com/metamatrix/connector/identity/ConnectorIdentity.java)
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorIdentity.java (rev 0)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorIdentity.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -0,0 +1,34 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.connector.api;
+
+
+/**
+ * Represents the identity of a connection in the pool. Identities are
+ * used to determine whether two connections can be put in the same pool.
+ * Implementors must supply appropriate {@link java.lang.Object#equals(java.lang.Object)} and
+ * {@link java.lang.Object#hashCode()} methods.
+ */
+public interface ConnectorIdentity {
+
+}
Property changes on: trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorIdentity.java
___________________________________________________________________
Name: svn:mergeinfo
+
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/ExecutionContext.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -24,9 +24,6 @@
import java.io.Serializable;
-import com.metamatrix.connector.identity.ConnectorIdentity;
-import com.metamatrix.connector.identity.ConnectorIdentityFactory;
-import com.metamatrix.connector.identity.SingleIdentity;
/**
* The security context provides information about the user context in which
Copied: trunk/connector-api/src/main/java/com/metamatrix/connector/api/MappedUserIdentity.java (from rev 481, trunk/connector-api/src/main/java/com/metamatrix/connector/identity/UserIdentity.java)
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/MappedUserIdentity.java (rev 0)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/MappedUserIdentity.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+
+/**
+ * This class represents a ConnectorIdentity keyed on a username with
+ * a mapped identity
+ */
+public class MappedUserIdentity implements ConnectorIdentity {
+ private String username;
+ private String mappedUser;
+ private String password;
+
+ /**
+ * Construct with a security context
+ * @param context The context
+ */
+ public MappedUserIdentity(String username, String mappedUser, String password){
+ this.username = username;
+ this.mappedUser = mappedUser;
+ this.password = password;
+ }
+
+ /**
+ * Implement equals based on the case-insensitive user name.
+ * @param obj Other identity object
+ * @return True if other object is a UserIdentity with the same user name
+ */
+ public boolean equals(Object obj){
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof MappedUserIdentity) {
+ MappedUserIdentity that = (MappedUserIdentity)obj;
+ return username.equals(that.username);
+ }
+
+ return false;
+ }
+
+ /**
+ * Get hash code, based on user name
+ */
+ public int hashCode(){
+ return username.hashCode();
+ }
+
+ public String toString(){
+ return "UserIdentity " + username; //$NON-NLS-1$
+ }
+
+ public String getMappedUser() {
+ return mappedUser;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+}
Property changes on: trunk/connector-api/src/main/java/com/metamatrix/connector/api/MappedUserIdentity.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connector-api/src/main/java/com/metamatrix/connector/api/SingleIdentity.java (from rev 481, trunk/connector-api/src/main/java/com/metamatrix/connector/identity/SingleIdentity.java)
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/SingleIdentity.java (rev 0)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/SingleIdentity.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+
+/**
+ * This class represents a single ConnectorIdentity. All the connections are treated the same.
+ */
+public class SingleIdentity implements ConnectorIdentity {
+
+ public SingleIdentity(){
+ }
+
+ /**
+ * Return true for everything - all identities are identical.
+ */
+ public boolean equals(Object obj){
+ return obj instanceof SingleIdentity;
+ }
+
+ public String toString(){
+ return "SingleIdentity"; //$NON-NLS-1$
+ }
+
+ public int hashCode(){
+ return 0;
+ }
+}
Property changes on: trunk/connector-api/src/main/java/com/metamatrix/connector/api/SingleIdentity.java
___________________________________________________________________
Name: svn:mergeinfo
+
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnection.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -25,12 +25,12 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.api.ConnectorIdentity;
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.identity.ConnectorIdentity;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.language.IQueryCommand;
@@ -81,20 +81,12 @@
return null;
}
- /**
- * Called by the pool to indicate that the connection was returned to the pool.
- * The actual close call will be made when the pool wants to purge this connection.
- */
+ @Override
public 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
- */
+ @Override
public void setConnectorIdentity(ConnectorIdentity context)
throws ConnectorException {
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -1,7 +1,61 @@
package com.metamatrix.connector.basic;
+import com.metamatrix.connector.DataPlugin;
import com.metamatrix.connector.api.Connector;
+import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.api.ConnectorIdentity;
+import com.metamatrix.connector.api.CredentialMap;
+import com.metamatrix.connector.api.ExecutionContext;
+import com.metamatrix.connector.api.SingleIdentity;
+import com.metamatrix.connector.api.MappedUserIdentity;
public abstract class BasicConnector implements Connector {
+ private boolean useCredentialMap;
+ private boolean adminConnectionsAllowed = true;
+ private String connectorName;
+
+ /* (non-Javadoc)
+ * @see com.metamatrix.connector.api.Connector#createIdentity(com.metamatrix.connector.api.ExecutionContext)
+ */
+ public ConnectorIdentity createIdentity(ExecutionContext context)
+ throws ConnectorException {
+ if (context == null) {
+ if (adminConnectionsAllowed) {
+ return new SingleIdentity();
+ }
+ throw new ConnectorException(DataPlugin.Util.getString("UserIdentityFactory.single_identity_not_supported")); //$NON-NLS-1$
+ }
+ Object payload = context.getTrustedPayload();
+ if (!(payload instanceof CredentialMap)) {
+ if (useCredentialMap) {
+ throw new ConnectorException(DataPlugin.Util.getString("UserIdentityFactory.extraction_error")); //$NON-NLS-1$
+ }
+ return new SingleIdentity();
+ }
+ CredentialMap credMap = (CredentialMap)payload;
+ String user = credMap.getUser(connectorName);
+ String password = credMap.getPassword(connectorName);
+ if (user == null || password == null) {
+ throw new ConnectorException("Payload missing credentials for " + connectorName); //$NON-NLS-1$
+ }
+ return new MappedUserIdentity(context.getUser(), user, password);
+ }
+
+ public void setConnectorName(String connectorName) {
+ this.connectorName = connectorName;
+ }
+
+ public void setUseCredentialMap(boolean useCredentialMap) {
+ this.useCredentialMap = useCredentialMap;
+ }
+
+ public boolean areAdminConnectionsAllowed() {
+ return adminConnectionsAllowed;
+ }
+
+ public void setAdminConnectionsAllowed(boolean adminConnectionsAllowed) {
+ this.adminConnectionsAllowed = adminConnectionsAllowed;
+ }
+
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IBulkInsert.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -36,9 +36,4 @@
*/
List<List<?>> getRows();
- /**
- * Set the list of row values for this bulk insert
- * @return list; never null
- */
- void setRows(List<List<?>> rows);
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ICompoundCriteria.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -56,10 +56,4 @@
*/
List<ICriteria> getCriteria();
- /**
- * Set list of ICriteria combined by this compound criteria.
- * @param criteria List of ICriteria
- */
- void setCriteria(List<ICriteria> criteria);
-
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IElement.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IElement.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IElement.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,11 +22,13 @@
package com.metamatrix.connector.language;
+import com.metamatrix.connector.metadata.runtime.Element;
+
/**
* Represents an element in the language. An example of an element
* would be a column reference in a SELECT clause.
*/
-public interface IElement extends IMetadataReference, IExpression {
+public interface IElement extends IMetadataReference<Element>, IExpression {
/**
* Gets the name of the element.
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IFrom.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -35,10 +35,4 @@
*/
List<IFromItem> getItems();
- /**
- * Set a List of IFromItem in this FROM clause.
- * @param items List of IFromItem
- */
- void setItems(List<IFromItem> items);
-
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IFunction.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IFunction.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IFunction.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,8 @@
package com.metamatrix.connector.language;
+import java.util.List;
+
/**
* Represents a function in the language. A function has a name and 0..n
* Expressions that are parameters.
@@ -38,7 +40,7 @@
* Get the parameters used in this function.
* @return Array of IExpressions defining the parameters
*/
- IExpression[] getParameters();
+ List<IExpression> getParameters();
/**
* Set name of the function
@@ -46,10 +48,4 @@
*/
void setName(String name);
- /**
- * Set the parameters used in this function.
- * @param parameters Array of IExpressions defining the parameters
- */
- void setParameters(IExpression[] parameters);
-
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IGroup.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IGroup.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IGroup.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,12 +22,14 @@
package com.metamatrix.connector.language;
+import com.metamatrix.connector.metadata.runtime.Group;
+
/**
* Represents a group in the language objects. An example of a group would
* be a table reference in the FROM clause. An IGroup may have a context name
* used in references to this group.
*/
-public interface IGroup extends IMetadataReference, IFromItem, ILanguageObject {
+public interface IGroup extends IMetadataReference<Group>, IFromItem, ILanguageObject {
/**
* Get the name of the group as defined in the VDB. This is null if the
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IGroupBy.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -35,10 +35,4 @@
*/
List<IExpression> getElements();
- /**
- * Set list of IExpression that the GROUP BY should be grouped on.
- * @param elements List of IExpression
- */
- 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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IInCriteria.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -35,10 +35,4 @@
*/
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<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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IInsert.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -53,16 +53,4 @@
*/
void setGroup(IGroup group);
- /**
- * Set list of elements being inserted into
- * @param elements List of IElement
- */
- void setElements(List<IElement> elements);
-
- /**
- * Set list of values being inserted
- * @param values List of IExpression
- */
- 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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IJoin.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -90,9 +90,4 @@
*/
void setJoinType(JoinType type);
- /**
- * Set List of CompareCriteria specifying join criteria.
- * @param criteria List of 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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ILanguageFactory.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -26,7 +26,10 @@
import com.metamatrix.connector.language.ICompoundCriteria.Operator;
import com.metamatrix.connector.language.IParameter.Direction;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.metadata.runtime.Element;
+import com.metamatrix.connector.metadata.runtime.Group;
+import com.metamatrix.connector.metadata.runtime.Parameter;
+import com.metamatrix.connector.metadata.runtime.Procedure;
/**
* Factory for the construction of language objects that implement the language interfaces.
@@ -61,7 +64,7 @@
* @param innerCriteria List of ICriteria, typically containing two criteria
* @return New ICompoundCriteria
*/
- ICompoundCriteria createCompoundCriteria(ICompoundCriteria.Operator operator, List<ICriteria> innerCriteria);
+ ICompoundCriteria createCompoundCriteria(ICompoundCriteria.Operator operator, List<? extends ICriteria> innerCriteria);
/**
* Create a new IDelete.
@@ -79,7 +82,7 @@
* @param type Data type
* @return New IElement
*/
- IElement createElement(String name, IGroup group, MetadataID metadataReference, Class type);
+ IElement createElement(String name, IGroup group, Element metadataReference, Class type);
/**
* Create new exists criteria.
@@ -93,7 +96,16 @@
* @param items List of IFromItem
* @return New IFrom
*/
- IFrom createFrom(List<IFromItem> items);
+ IFrom createFrom(List<? extends IFromItem> items);
+
+ /**
+ * Create new function
+ * @param functionName Name of the function
+ * @param args Arguments, should never be null
+ * @param type Data type returned
+ * @return New IFunction
+ */
+ IFunction createFunction(String functionName, IExpression[] args, Class type);
/**
* Create new function
@@ -102,7 +114,7 @@
* @param type Data type returned
* @return New IFunction
*/
- IFunction createFunction(String functionName, IExpression[] args, Class type);
+ IFunction createFunction(String functionName, List<? extends IExpression> args, Class type);
/**
* Create new group.
@@ -111,14 +123,14 @@
* @param metadataReference Reference to metadata identifier
* @return New IGroup
*/
- IGroup createGroup(String context, String definition, MetadataID metadataReference);
+ IGroup createGroup(String context, String definition, Group metadataReference);
/**
* Create new group by.
* @param items List of IGroupByItem
* @return New IGroupBy
*/
- IGroupBy createGroupBy(List<IExpression> items);
+ IGroupBy createGroupBy(List<? extends IExpression> items);
/**
* Create new IN criteria
@@ -127,7 +139,7 @@
* @param isNegated True if NOT IN, false for IN
* @return New IInCriteria
*/
- IInCriteria createInCriteria(IExpression leftExpression, List<IExpression> rightExpressions, boolean isNegated);
+ IInCriteria createInCriteria(IExpression leftExpression, List<? extends IExpression> rightExpressions, boolean isNegated);
/**
* Create new inline view
@@ -144,7 +156,7 @@
* @param values List of IExpression (usually ILiteral)
* @return New IInsert
*/
- IInsert createInsert(IGroup group, List<IElement> columns, List<IExpression> values);
+ IInsert createInsert(IGroup group, List<IElement> columns, List<? extends IExpression> values);
/**
* Create new bulk insert command
@@ -153,7 +165,7 @@
* @param List of Lists containing the actual values
* @return New IBulkInsert
*/
- IBulkInsert createBulkInsert(IGroup group, List<IElement> columns, List<List<Object>> rows);
+ IBulkInsert createBulkInsert(IGroup group, List<? extends IElement> columns, List<List<Object>> rows);
/**
* Create new IS NULL criteria
@@ -171,7 +183,7 @@
* @param criteria List of ICriteria (considered to be AND'ed together)
* @return New IJoin
*/
- IJoin createJoin(IJoin.JoinType joinType, IFromItem leftItem, IFromItem rightItem, List<ICriteria> criteria);
+ IJoin createJoin(IJoin.JoinType joinType, IFromItem leftItem, IFromItem rightItem, List<? extends ICriteria> criteria);
/**
* Create new LIKE criteria
@@ -203,7 +215,7 @@
* @param items List of IOrderByItem
* @return New IOrderBy
*/
- IOrderBy createOrderBy(List<IOrderByItem> items);
+ IOrderBy createOrderBy(List<? extends IOrderByItem> items);
/**
* Create new ORDER BY item
@@ -223,7 +235,7 @@
* @param metadataReference Metadata identifier reference
* @return New IParameter
*/
- IParameter createParameter(int index, Direction direction, Object value, Class type, MetadataID metadataReference);
+ IParameter createParameter(int index, Direction direction, Object value, Class type, Parameter metadataReference);
/**
* Create new procedure
@@ -232,7 +244,7 @@
* @param metadataReference Metadata identifier reference
* @return New IProcedure
*/
- IProcedure createProcedure(String name, List<IParameter> parameters, MetadataID metadataReference);
+ IProcedure createProcedure(String name, List<? extends IParameter> parameters, Procedure metadataReference);
/**
* Create new query
@@ -263,7 +275,7 @@
* @param type Data type
* @return New ICaseExpression
*/
- ISearchedCaseExpression createSearchedCaseExpression(List<IExpression> whenExpressions, List<IExpression> thenExpressions, IExpression elseExpression, Class type);
+ ISearchedCaseExpression createSearchedCaseExpression(List<? extends ICriteria> whenExpressions, List<? extends IExpression> thenExpressions, IExpression elseExpression, Class type);
/**
* Create new SELECT clause
@@ -271,7 +283,7 @@
* @param selectSymbols List of ISelectSymbol
* @return New ISelect
*/
- ISelect createSelect(boolean isDistinct, List<ISelectSymbol> selectSymbols);
+ ISelect createSelect(boolean isDistinct, List<? extends ISelectSymbol> selectSymbols);
/**
* Create new select symbol
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/language/IMetadataReference.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/language/IMetadataReference.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IMetadataReference.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,23 +22,14 @@
package com.metamatrix.connector.language;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.metadata.runtime.MetadataObject;
/**
* This interface is used to mark language objects as having a
* reference to a MetadataID.
*/
-public interface IMetadataReference {
+public interface IMetadataReference<T extends MetadataObject> {
- /**
- * Return the MetadataID that is being referred to.
- * @return MetadataID
- */
- MetadataID getMetadataID();
+ T getMetadataObject();
- /**
- * Set the MetadataID that is being referred to.
- * @param metadataID MetadataID
- */
- void setMetadataID(MetadataID metadataID);
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IOrderBy.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -40,10 +40,4 @@
*/
List<IOrderByItem> getItems();
- /**
- * Set list of {@link IOrderByItem}s specifying the ordering of the results.
- * @param items List of IOrderByItem
- */
- 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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IParameter.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,10 +22,12 @@
package com.metamatrix.connector.language;
+import com.metamatrix.connector.metadata.runtime.Parameter;
+
/**
* Represents an execution parameter.
*/
-public interface IParameter extends ILanguageObject, IMetadataReference {
+public interface IParameter extends ILanguageObject, IMetadataReference<Parameter> {
public enum Direction {
IN,
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/IProcedure.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -24,10 +24,12 @@
import java.util.List;
+import com.metamatrix.connector.metadata.runtime.Procedure;
+
/**
* Represents a procedural execution (such as a stored procedure).
*/
-public interface IProcedure extends ICommand, IMetadataReference {
+public interface IProcedure extends ICommand, IMetadataReference<Procedure> {
/**
* Gets the name of the procedure.
@@ -48,11 +50,4 @@
*/
void setProcedureName(String name);
- /**
- * Sets list of the IParameter objects associated with this execution.
- * The parameters describe inputs and outputs.
- * @param parameters List of IParameter
- */
- 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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/language/ISelect.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -42,12 +42,6 @@
boolean isDistinct();
/**
- * Set List of ISelectSymbol.
- * @param symbols List of ISelectSymbol
- */
- void setSelectSymbols(List<ISelectSymbol> symbols);
-
- /**
* Set whether the DISTINCT flag is used in this SELECT.
* @param distinct True if SELECT DISTINCT, false if SELECT ALL
*/
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Element.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -98,5 +98,12 @@
* @return
* @throws ConnectorException
*/
- String getFormat() throws ConnectorException;
+ String getFormat() throws ConnectorException;
+
+ /**
+ * Get the parent
+ * @return Parent
+ */
+ Group getParent() throws ConnectorException;
+
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Group.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Group.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Group.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,8 +22,15 @@
package com.metamatrix.connector.metadata.runtime;
+import java.util.List;
+
+import com.metamatrix.connector.api.ConnectorException;
+
/**
* Represents a group, such as a table, in the runtime metadata.
*/
public interface Group extends MetadataObject {
+
+ List<Element> getChildren() throws ConnectorException;
+
}
Deleted: 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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataID.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -1,81 +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.metadata.runtime;
-
-import java.util.List;
-
-import com.metamatrix.connector.api.ConnectorException;
-
-/**
- * Represents a runtime metadata identifier.
- */
-public interface MetadataID {
-
- public enum Type {
- TYPE_ELEMENT,
- TYPE_GROUP,
- TYPE_PARAMETER,
- TYPE_PROCEDURE
- }
- /**
- * Get the type of metadataID
- * @return ID type
- * @see #TYPE_ELEMENT
- * @see #TYPE_GROUP
- * @see #TYPE_PROCEDURE
- * @see #TYPE_PARAMETER
- */
- Type getType();
-
- /**
- * Get a list of child IDs from this ID. A group metadata ID will
- * return child element IDs. An element ID will return no child IDs.
- * A procedure ID will return the IDs of it's parameters.
- * @return List of MetadataID, which may be empty but never null
- */
- List<MetadataID> getChildIDs() throws ConnectorException;
-
- /**
- * Get the parent ID if one exists
- * @return Parent ID or null if none exists
- */
- MetadataID getParentID() throws ConnectorException;
-
- /**
- * Get the short name from the metadataID
- * @return String shortName
- */
- String getName();
-
- /**
- * Get the full name from the metadataID
- * @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/metadata/runtime/MetadataObject.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataObject.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/MetadataObject.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -32,12 +32,6 @@
public interface MetadataObject {
/**
- * Get the identifier for this object.
- * @return Unique identifier for the object
- */
- MetadataID getMetadataID();
-
- /**
* Get name in source for this object, as provided in the model
* @return Name in source
* @throws ConnectorException If an error occurs retrieving the data
@@ -53,4 +47,16 @@
* from runtime metadata
*/
Properties getProperties() throws ConnectorException;
+
+ /**
+ * Get the short name from the metadataID
+ * @return String shortName
+ */
+ String getName();
+
+ /**
+ * Get the full name from the metadataID
+ * @return String fullName
+ */
+ String getFullName();
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Parameter.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,8 @@
package com.metamatrix.connector.metadata.runtime;
+import java.util.List;
+
import com.metamatrix.connector.api.ConnectorException;
/**
@@ -53,5 +55,12 @@
*/
int getDirection() throws ConnectorException;
+ /**
+ * Get the parent
+ * @return Parent
+ */
+ Procedure getParent() throws ConnectorException;
+ List<Element> getChildren() throws ConnectorException;
+
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Procedure.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Procedure.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/Procedure.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,9 +22,12 @@
package com.metamatrix.connector.metadata.runtime;
+import java.util.List;
+
/**
* Represents a procedure construct (such as a Stored Procedure).
*/
public interface Procedure extends MetadataObject{
+ List<Parameter> getChildren();
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/metadata/runtime/RuntimeMetadata.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -31,10 +31,24 @@
/**
* Look up an object by identifier
- * @param id The identifier
+ * @param fullName
* @return The object
*/
- MetadataObject getObject(MetadataID id) throws ConnectorException;
+ Group getGroup(String fullName) throws ConnectorException;
+
+ /**
+ * Look up an object by identifier
+ * @param fullName
+ * @return The object
+ */
+ Element getElement(String fullName) throws ConnectorException;
+
+ /**
+ * Look up an object by identifier
+ * @param fullName
+ * @return The object
+ */
+ Procedure getProcedure(String fullName) throws ConnectorException;
/**
* Gets the contents of a VDB resource in binary form.
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/visitor/util/SQLStringVisitor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -70,7 +70,6 @@
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.visitor.framework.AbstractLanguageVisitor;
import com.metamatrix.core.util.StringUtil;
@@ -93,19 +92,15 @@
* @param id the id of the group or element
* @return the name of that element or group as defined in the source
*/
- protected String getName(MetadataID id) {
+ protected String getName(MetadataObject object) {
try {
- MetadataObject obj = id.getMetadataObject();
- if (obj == null) {
- return id.getName();
- }
- String nameInSource = obj.getNameInSource();
+ String nameInSource = object.getNameInSource();
if(nameInSource != null && nameInSource.length() > 0) {
return nameInSource;
}
- return id.getName();
+ return object.getName();
} catch(ConnectorException e) {
- return id.getName();
+ return object.getName();
}
}
@@ -291,7 +286,7 @@
if(group.getDefinition() != null) {
groupName = group.getContext();
} else {
- MetadataID groupID = group.getMetadataID();
+ MetadataObject groupID = group.getMetadataObject();
if(groupID != null) {
groupName = getName(groupID);
} else {
@@ -301,7 +296,7 @@
}
String elemShortName = null;
- MetadataID elementID = obj.getMetadataID();
+ MetadataObject elementID = obj.getMetadataObject();
if(elementID != null) {
elemShortName = getName(elementID);
} else {
@@ -345,8 +340,8 @@
buffer.append(EXEC)
.append(SPACE);
- if(obj.getMetadataID() != null) {
- buffer.append(getName(obj.getMetadataID()));
+ if(obj.getMetadataObject() != null) {
+ buffer.append(getName(obj.getMetadataObject()));
} else {
buffer.append(obj.getProcedureName());
}
@@ -399,15 +394,15 @@
public void visit(IFunction obj) {
String name = obj.getName();
- IExpression[] args = obj.getParameters();
+ List<IExpression> args = obj.getParameters();
if(name.equalsIgnoreCase(CONVERT) || name.equalsIgnoreCase(CAST)) {
- Object typeValue = ((ILiteral)args[1]).getValue();
+ Object typeValue = ((ILiteral)args.get(1)).getValue();
buffer.append(name);
buffer.append(LPAREN);
- append(args[0]);
+ append(args.get(0));
if(name.equalsIgnoreCase(CONVERT)) {
buffer.append(COMMA);
@@ -423,9 +418,9 @@
buffer.append(LPAREN);
if(args != null) {
- for(int i=0; i<args.length; i++) {
- append(args[i]);
- if(i < (args.length-1)) {
+ for(int i=0; i<args.size(); i++) {
+ append(args.get(i));
+ if(i < (args.size()-1)) {
buffer.append(SPACE);
buffer.append(name);
buffer.append(SPACE);
@@ -438,13 +433,16 @@
buffer.append(name);
buffer.append(LPAREN);
- if(args != null && args.length > 0) {
- buffer.append(((ILiteral)args[0]).getValue());
+ if(args != null && args.size() > 0) {
+ buffer.append(((ILiteral)args.get(0)).getValue());
- for(int i=1; i<args.length; i++) {
- buffer.append(COMMA);
- buffer.append(SPACE);
- append(args[i]);
+ for(int i=1; i<args.size(); i++) {
+ append(args.get(i));
+ if(i < (args.size()-1)) {
+ buffer.append(SPACE);
+ buffer.append(name);
+ buffer.append(SPACE);
+ }
}
}
buffer.append(RPAREN);
@@ -462,7 +460,7 @@
* @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.connector.language.IGroup)
*/
public void visit(IGroup obj) {
- MetadataID groupID = obj.getMetadataID();
+ MetadataObject groupID = obj.getMetadataObject();
if(groupID != null) {
buffer.append(getName(groupID));
} else {
Modified: trunk/connector-api/src/main/resources/com/metamatrix/data/i18n.properties
===================================================================
--- trunk/connector-api/src/main/resources/com/metamatrix/data/i18n.properties 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-api/src/main/resources/com/metamatrix/data/i18n.properties 2009-02-24 16:16:42 UTC (rev 488)
@@ -59,4 +59,5 @@
ValueTranslator.no_tranfrom_found=To Suitable transform found to convert {0} type value to {1}
unknown_object_type_to_tranfrom_xml=Unknown object type supplied to transform into SQLXML.
-UserIdentityFactory.single_identity_not_supported=Single identity is not supported by the UserIdentityFactory. A context is required.
\ No newline at end of file
+UserIdentityFactory.single_identity_not_supported=Single identity is not supported by the UserIdentityFactory. A context is required.
+UserIdentityFactory.extraction_error=Unable to extract credentials from command payload or trusted session payload for per-user connection.
\ No newline at end of file
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/adapter/ObjectConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,17 +23,17 @@
package com.metamatrix.connector.metadata.adapter;
import com.metamatrix.connector.api.Connection;
-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.basic.BasicConnector;
import com.metamatrix.connector.metadata.internal.IObjectSource;
/**
* Adapter to expose the object processing logic via the standard connector API.
*/
-public abstract class ObjectConnector implements Connector {
+public abstract class ObjectConnector extends BasicConnector {
private ConnectorEnvironment environment;
public ConnectorCapabilities getCapabilities() {
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectProcedure.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -39,7 +39,6 @@
import com.metamatrix.connector.metadata.MetadataConnectorPlugin;
import com.metamatrix.connector.metadata.index.MetadataLiteralCriteria;
import com.metamatrix.connector.metadata.runtime.Element;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -118,15 +117,14 @@
* @since 4.2
*/
private void initResultSet() throws ConnectorException {
- List columnMetadata = resultSetParameter.getMetadataID().getChildIDs();
+ List<Element> columnMetadata = resultSetParameter.getMetadataObject().getChildren();
int size = columnMetadata.size();
columnNames = new String[size];
columnNamesInSource = new String[size];
columnTypes = new Class[size];
for(int i =0; i<size; i++ ){
- MetadataID mID = (MetadataID)columnMetadata.get(i);
- Element element = (Element) metadata.getObject(mID);
- columnNames[i] = element.getMetadataID().getFullName();
+ Element element = columnMetadata.get(i);
+ columnNames[i] = element.getFullName();
columnNamesInSource[i] = element.getNameInSource();
columnTypes[i] = element.getJavaType();
}
@@ -271,8 +269,7 @@
if(reference == null) {
return null;
}
- MetadataID id = reference.getMetadataID();
- MetadataObject obj = metadata.getObject(id);
+ MetadataObject obj = reference.getMetadataObject();
if (obj != null && obj.getNameInSource() != null) {
return obj.getNameInSource();
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-metadata/src/main/java/com/metamatrix/connector/metadata/internal/ObjectQuery.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -39,7 +39,6 @@
import com.metamatrix.connector.language.ISelectSymbol;
import com.metamatrix.connector.metadata.MetadataConnectorPlugin;
import com.metamatrix.connector.metadata.runtime.Element;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.core.MetaMatrixRuntimeException;
@@ -169,19 +168,18 @@
if(expression instanceof IFunction) {
IFunction function = (IFunction) expression;
functionName = function.getName();
- IExpression[] expressions = function.getParameters();
- element = (IElement)expressions[0];
+ List<IExpression> expressions = function.getParameters();
+ element = (IElement)expressions.get(0);
} else if(expression instanceof IElement) {
element = (IElement)expression;
}
IMetadataReference reference = element;
- MetadataID id = reference.getMetadataID();
- MetadataObject obj = metadata.getObject(id);
+ MetadataObject obj = reference.getMetadataObject();
if (obj != null && obj.getNameInSource() != null) {
Element elementMetadata = (Element) obj;
columnTypes.add( elementMetadata.getJavaType() );
columnNamesInSource.add(obj.getNameInSource());
- columnNames.add(obj.getMetadataID().getFullName());
+ columnNames.add(obj.getFullName());
if(functionName == null) {
caseTypes.add(NO_CASE);
} else if(functionName.equalsIgnoreCase("UPPER") || functionName.equalsIgnoreCase("UCASE")) { //$NON-NLS-1$ //$NON-NLS-2$
@@ -194,8 +192,7 @@
private String getMetadataObjectName(Object element) throws ConnectorException {
IMetadataReference reference = (IMetadataReference) element;
- MetadataID id = reference.getMetadataID();
- MetadataObject obj = metadata.getObject(id);
+ MetadataObject obj = reference.getMetadataObject();
if (obj != null && obj.getNameInSource() != null) {
return obj.getNameInSource();
}
@@ -228,8 +225,8 @@
String functionName = null;
if(expression instanceof IFunction) {
IFunction function = (IFunction) expression;
- IExpression[] expressions = function.getParameters();
- literal = (ILiteral)expressions[0];
+ List<IExpression> expressions = function.getParameters();
+ literal = (ILiteral)expressions.get(0);
functionName = function.getName();
} else if(expression instanceof ILiteral) {
literal = (ILiteral) expression;
@@ -249,8 +246,8 @@
IElement element = null;
if(expression instanceof IFunction) {
IFunction function = (IFunction) expression;
- IExpression[] expressions = function.getParameters();
- element = (IElement)expressions[0];
+ List<IExpression> expressions = function.getParameters();
+ element = (IElement)expressions.get(0);
} else if(expression instanceof IElement) {
element = (IElement)expression;
}
Deleted: 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-24 14:33:28 UTC (rev 487)
+++ trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/FakeRuntimeMetadata.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -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.metadata.internal;
-
-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;
-
-/**
- */
-public class FakeRuntimeMetadata implements RuntimeMetadata {
-
- /**
- *
- */
- public FakeRuntimeMetadata() {
- super();
- }
-
- /*
- * @see com.metamatrix.data.metadata.runtime.RuntimeMetadata#getObject(com.metamatrix.data.metadata.runtime.MetadataID)
- */
- public MetadataObject getObject(MetadataID id) {
- return null;
- }
-
- public byte[] getBinaryVDBResource(String resourcePath) throws ConnectorException {
- return null;
- }
-
- public String getCharacterVDBResource(String resourcePath) throws ConnectorException {
- return null;
- }
-
- public String[] getVDBResourcePaths() throws ConnectorException {
- return null;
- }
-}
Modified: trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQueryProcessor.java
===================================================================
--- trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQueryProcessor.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-metadata/src/test/java/com/metamatrix/connector/metadata/internal/TestObjectQueryProcessor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -36,7 +36,6 @@
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.dqp.internal.datamgr.metadata.MetadataFactory;
import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.metadata.runtime.FakeMetadataService;
import com.metamatrix.metadata.runtime.FakeQueryMetadata;
@@ -73,7 +72,7 @@
}
public static RuntimeMetadata getRuntimeMetadata() {
- return new RuntimeMetadataImpl(new MetadataFactory(FakeQueryMetadata.getQueryMetadata()));
+ return new RuntimeMetadataImpl(FakeQueryMetadata.getQueryMetadata());
}
private void checkResults(String expected, String actual) {
Modified: trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/TranslationUtility.java
===================================================================
--- trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/TranslationUtility.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connector-sdk/src/main/java/com/metamatrix/cdk/api/TranslationUtility.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -28,7 +28,6 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-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;
@@ -89,6 +88,6 @@
* @return RuntimeMetadata for testing
*/
public RuntimeMetadata createRuntimeMetadata() {
- return new RuntimeMetadataImpl(new MetadataFactory(metadata));
+ return new RuntimeMetadataImpl(metadata);
}
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCBaseExecution.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -34,10 +34,10 @@
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.api.ConnectorIdentity;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.identity.ConnectorIdentity;
import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.language.ICommand;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -37,19 +37,16 @@
import javax.sql.XADataSource;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.connector.DataPlugin;
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.SingleIdentity;
+import com.metamatrix.connector.api.MappedUserIdentity;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
-import com.metamatrix.connector.identity.ConnectorIdentity;
-import com.metamatrix.connector.identity.ConnectorIdentityFactory;
-import com.metamatrix.connector.identity.SingleIdentity;
-import com.metamatrix.connector.identity.UserIdentity;
+import com.metamatrix.connector.basic.BasicConnector;
import com.metamatrix.connector.internal.ConnectorPropertyNames;
import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.jdbc.xa.JDBCSourceXAConnection;
@@ -64,7 +61,7 @@
* JDBC implementation of Connector interface.
*/
@ConnectionPooling
-public class JDBCConnector implements XAConnector, ConnectorIdentityFactory {
+public class JDBCConnector extends BasicConnector implements XAConnector {
public static final String INVALID_AUTHORIZATION_SPECIFICATION_NO_SUBCLASS = "28000"; //$NON-NLS-1$
@@ -95,48 +92,7 @@
private DataSource ds;
private XADataSource xaDs;
private int transIsoLevel = NO_ISOLATION_LEVEL_SET;
-
- private boolean useCredentialMap;
- private boolean adminConnectionsAllowed = true;
- private String connectorName;
-
- @Override
- public ConnectorIdentity createIdentity(ExecutionContext context)
- throws ConnectorException {
- if (context == null) {
- if (adminConnectionsAllowed) {
- return new SingleIdentity();
- }
- throw new ConnectorException(DataPlugin.Util.getString("UserIdentityFactory.single_identity_not_supported")); //$NON-NLS-1$
- }
- Object payload = context.getTrustedPayload();
- if (!(payload instanceof CredentialMap)) {
- if (useCredentialMap) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCUserIdentityConnectionFactory.Unable_to_get_credentials")); //$NON-NLS-1$
- }
- return new SingleIdentity();
- }
- CredentialMap credMap = (CredentialMap)payload;
- String user = credMap.getUser(connectorName);
- String password = credMap.getPassword(connectorName);
- if (user == null || password == null) {
- throw new ConnectorException("Payload missing credentials for " + connectorName); //$NON-NLS-1$
- }
- return new UserIdentity(context.getUser(), user, password);
- }
-
- public void setConnectorName(String connectorName) {
- this.connectorName = connectorName;
- }
-
- public void setUseCredentialMap(boolean useCredentialMap) {
- this.useCredentialMap = useCredentialMap;
- }
-
- public void setAdminConnectionsAllowed(boolean adminConnectionsAllowed) {
- this.adminConnectionsAllowed = adminConnectionsAllowed;
- }
-
+
@Override
public void start(ConnectorEnvironment environment)
throws ConnectorException {
@@ -172,7 +128,7 @@
}
sqlTranslator.initialize(environment);
- if (this.adminConnectionsAllowed) {
+ if (areAdminConnectionsAllowed()) {
testConnection();
}
@@ -235,8 +191,8 @@
try {
if (context == null || context.getConnectorIdentity() instanceof SingleIdentity) {
conn = dataSource.getConnection();
- } else if (context.getConnectorIdentity() instanceof UserIdentity) {
- UserIdentity id = (UserIdentity)context.getConnectorIdentity();
+ } else if (context.getConnectorIdentity() instanceof MappedUserIdentity) {
+ MappedUserIdentity id = (MappedUserIdentity)context.getConnectorIdentity();
conn = dataSource.getConnection(id.getMappedUser(), id.getPassword());
}
setDefaultTransactionIsolationLevel(conn);
@@ -258,8 +214,8 @@
try {
if (context == null || context.getConnectorIdentity() instanceof SingleIdentity) {
conn = xaDataSource.getXAConnection();
- } else if (context.getConnectorIdentity() instanceof UserIdentity) {
- UserIdentity id = (UserIdentity)context.getConnectorIdentity();
+ } else if (context.getConnectorIdentity() instanceof MappedUserIdentity) {
+ MappedUserIdentity id = (MappedUserIdentity)context.getConnectorIdentity();
conn = xaDataSource.getXAConnection(id.getMappedUser(), id.getPassword());
}
java.sql.Connection c = conn.getConnection();
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCProcedureExecution.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -46,7 +46,6 @@
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,15 +123,12 @@
}
if(resultSet != null){
- List columnMetadata = null;
- columnMetadata = resultSet.getMetadataID().getChildIDs();
+ List<Element> columnMetadata = resultSet.getMetadataObject().getChildren();
int size = columnMetadata.size();
Class[] coulmnDTs = new Class[size];
for(int i =0; i<size; i++ ){
- MetadataID mID = (MetadataID)columnMetadata.get(i);
- Object mObj = metadata.getObject(mID);
- coulmnDTs[i] = ((Element)mObj).getJavaType();
+ coulmnDTs[i] = columnMetadata.get(i).getJavaType();
}
return coulmnDTs;
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -35,7 +35,6 @@
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.jdbc.translator.Translator;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IProcedure;
@@ -45,7 +44,7 @@
/**
*
*/
-public class JDBCSourceConnection extends BasicConnection {
+public class JDBCSourceConnection extends com.metamatrix.connector.basic.BasicConnection {
protected java.sql.Connection physicalConnection;
protected ConnectorEnvironment environment;
private ConnectorLogger logger;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2ConvertModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,6 +23,7 @@
package com.metamatrix.connector.jdbc.db2;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import com.metamatrix.connector.api.TypeFacility;
@@ -45,9 +46,9 @@
}
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
- Class sourceType = args[0].getType();
- String targetTypeString = getTargetType(args[1]);
+ List<IExpression> args = function.getParameters();
+ Class sourceType = args.get(0).getType();
+ String targetTypeString = getTargetType(args.get(1));
Class targetType = TypeFacility.getDataTypeClass(targetTypeString);
IExpression returnExpr = null;
@@ -55,40 +56,40 @@
// targetType is always lower-case due to getTargetType implementation
if(targetType.equals(TypeFacility.RUNTIME_TYPES.STRING)) {
- returnExpr = convertToString(args[0], sourceType);
+ returnExpr = convertToString(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.TIMESTAMP)) {
- returnExpr = convertToTimestamp(args[0], sourceType);
+ returnExpr = convertToTimestamp(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.DATE)) {
- returnExpr = convertToDate(args[0], sourceType);
+ returnExpr = convertToDate(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
- returnExpr = convertToTime(args[0], sourceType);
+ returnExpr = convertToTime(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.BOOLEAN) ||
targetType.equals(TypeFacility.RUNTIME_TYPES.BYTE) ||
targetType.equals(TypeFacility.RUNTIME_TYPES.SHORT)) {
- returnExpr = convertToSmallInt(args[0], sourceType, targetType);
+ returnExpr = convertToSmallInt(args.get(0), sourceType, targetType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.INTEGER)) {
- returnExpr = convertToInteger(args[0], sourceType);
+ returnExpr = convertToInteger(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.LONG) ||
targetType.equals(TypeFacility.RUNTIME_TYPES.BIG_INTEGER)) {
- returnExpr = convertToBigInt(args[0], sourceType);
+ returnExpr = convertToBigInt(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.FLOAT)) {
- returnExpr = convertToReal(args[0], sourceType);
+ returnExpr = convertToReal(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.DOUBLE)) {
- returnExpr = convertToDouble(args[0], sourceType);
+ returnExpr = convertToDouble(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL)) {
- returnExpr = convertToBigDecimal(args[0], sourceType);
+ returnExpr = convertToBigDecimal(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.CHAR)) {
- returnExpr = convertToChar(args[0], sourceType);
+ returnExpr = convertToChar(args.get(0), sourceType);
}
if(returnExpr != null) {
@@ -155,7 +156,7 @@
Class sourceType) {
if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING)) {
ILiteral literalOne = this.langFactory.createLiteral(new Integer(1), TypeFacility.RUNTIME_TYPES.INTEGER);
- return this.langFactory.createFunction("char", new IExpression[] { expression, literalOne }, TypeFacility.RUNTIME_TYPES.CHAR); //$NON-NLS-1$
+ return this.langFactory.createFunction("char", Arrays.asList(expression, literalOne), TypeFacility.RUNTIME_TYPES.CHAR); //$NON-NLS-1$
}
return null;
@@ -302,13 +303,13 @@
// BEFORE: convert(EXPR, timestamp)
// AFTER: timestamp(EXPR, '00:00:00')
ILiteral timeString = this.langFactory.createLiteral("00:00:00", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$
- return this.langFactory.createFunction("timestamp", new IExpression[] {expression, timeString}, TypeFacility.RUNTIME_TYPES.TIMESTAMP); //$NON-NLS-1$
+ return this.langFactory.createFunction("timestamp", Arrays.asList(expression, timeString), TypeFacility.RUNTIME_TYPES.TIMESTAMP); //$NON-NLS-1$
} else if(sourceType.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
// BEFORE: convert(EXPR, timestamp)
// AFTER: timestamp('1970-01-01', EXPR)
ILiteral dateString = this.langFactory.createLiteral("1970-01-01", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$
- return this.langFactory.createFunction("timestamp", new IExpression[] {dateString, expression}, TypeFacility.RUNTIME_TYPES.TIMESTAMP); //$NON-NLS-1$
+ return this.langFactory.createFunction("timestamp", Arrays.asList(dateString, expression), TypeFacility.RUNTIME_TYPES.TIMESTAMP); //$NON-NLS-1$
}
return null;
@@ -325,7 +326,7 @@
String functionName,
Class outputType) {
return langFactory.createFunction(functionName,
- new IExpression[] { expression },
+ Arrays.asList(expression),
outputType);
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLTranslator.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -24,8 +24,6 @@
*/
package com.metamatrix.connector.jdbc.db2;
-import java.util.Arrays;
-
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
@@ -70,7 +68,7 @@
return;
}
ILiteral one = getLanguageFactory().createLiteral(1, TypeFacility.RUNTIME_TYPES.INTEGER);
- obj.setCriteria(Arrays.asList(getLanguageFactory().createCompareCriteria(Operator.EQ, one, one)));
+ obj.getCriteria().add(getLanguageFactory().createCompareCriteria(Operator.EQ, one, one));
obj.setJoinType(JoinType.INNER_JOIN);
}
};
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyConvertModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,6 +23,7 @@
package com.metamatrix.connector.jdbc.derby;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import com.metamatrix.connector.api.TypeFacility;
@@ -54,9 +55,9 @@
List parts = new ArrayList();
parts.add("cast("); //$NON-NLS-1$
- parts.add(function.getParameters()[0]);
+ parts.add(function.getParameters().get(0));
parts.add(" as "); //$NON-NLS-1$
- ILiteral type = (ILiteral) function.getParameters()[1];
+ ILiteral type = (ILiteral) function.getParameters().get(1);
parts.add(type.getValue());
parts.add(")"); //$NON-NLS-1$
@@ -64,9 +65,9 @@
}
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
- Class sourceType = args[0].getType();
- String targetTypeString = getTargetType(args[1]);
+ List<IExpression> args = function.getParameters();
+ Class sourceType = args.get(0).getType();
+ String targetTypeString = getTargetType(args.get(1));
Class targetType = TypeFacility.getDataTypeClass(targetTypeString);
IExpression returnExpr = null;
@@ -74,40 +75,40 @@
// targetType is always lower-case due to getTargetType implementation
if(targetType.equals(TypeFacility.RUNTIME_TYPES.STRING)) {
- returnExpr = convertToString(args[0], sourceType);
+ returnExpr = convertToString(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.TIMESTAMP)) {
- returnExpr = convertToTimestamp(args[0], sourceType);
+ returnExpr = convertToTimestamp(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.DATE)) {
- returnExpr = convertToDate(args[0], sourceType);
+ returnExpr = convertToDate(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
- returnExpr = convertToTime(args[0], sourceType);
+ returnExpr = convertToTime(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.BOOLEAN) ||
targetType.equals(TypeFacility.RUNTIME_TYPES.BYTE) ||
targetType.equals(TypeFacility.RUNTIME_TYPES.SHORT)) {
- returnExpr = convertToSmallInt(args[0], sourceType, targetType);
+ returnExpr = convertToSmallInt(args.get(0), sourceType, targetType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.INTEGER)) {
- returnExpr = convertToInteger(args[0], sourceType);
+ returnExpr = convertToInteger(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.LONG) ||
targetType.equals(TypeFacility.RUNTIME_TYPES.BIG_INTEGER)) {
- returnExpr = convertToBigInt(args[0], sourceType);
+ returnExpr = convertToBigInt(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.FLOAT)) {
- returnExpr = convertToFloat(args[0], sourceType);
+ returnExpr = convertToFloat(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.DOUBLE)) {
- returnExpr = convertToDouble(args[0], sourceType);
+ returnExpr = convertToDouble(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL)) {
- returnExpr = convertToBigDecimal(args[0], sourceType);
+ returnExpr = convertToBigDecimal(args.get(0), sourceType);
} else if(targetType.equals(TypeFacility.RUNTIME_TYPES.CHAR)) {
- returnExpr = convertToChar(args[0], sourceType);
+ returnExpr = convertToChar(args.get(0), sourceType);
}
if(returnExpr != null) {
@@ -174,7 +175,7 @@
Class sourceType) {
if(sourceType.equals(TypeFacility.RUNTIME_TYPES.STRING)) {
ILiteral literalOne = this.langFactory.createLiteral(new Integer(1), TypeFacility.RUNTIME_TYPES.INTEGER);
- return this.langFactory.createFunction("char", new IExpression[] { expression, literalOne }, TypeFacility.RUNTIME_TYPES.CHAR); //$NON-NLS-1$
+ return this.langFactory.createFunction("char", Arrays.asList( expression, literalOne ), TypeFacility.RUNTIME_TYPES.CHAR); //$NON-NLS-1$
}
return null;
@@ -251,11 +252,11 @@
// BEFORE: convert(string_expr, float)
// AFTER: cast(cast(string_expr as decimal) as float)
IFunction inner = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] { expression, langFactory.createLiteral("decimal", TypeFacility.RUNTIME_TYPES.STRING) }, //$NON-NLS-1$
+ Arrays.asList( expression, langFactory.createLiteral("decimal", TypeFacility.RUNTIME_TYPES.STRING) ), //$NON-NLS-1$
TypeFacility.RUNTIME_TYPES.BIG_DECIMAL);
IFunction outer = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] { inner, langFactory.createLiteral("float", TypeFacility.RUNTIME_TYPES.STRING) }, //$NON-NLS-1$
+ Arrays.asList( inner, langFactory.createLiteral("float", TypeFacility.RUNTIME_TYPES.STRING) ), //$NON-NLS-1$
TypeFacility.RUNTIME_TYPES.FLOAT);
return outer;
@@ -266,7 +267,7 @@
// BEFORE: convert(num_expr, float)
// AFTER: cast(num_expr as float)
return langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] { expression, langFactory.createLiteral("float", TypeFacility.RUNTIME_TYPES.STRING) }, //$NON-NLS-1$
+ Arrays.asList( expression, langFactory.createLiteral("float", TypeFacility.RUNTIME_TYPES.STRING) ), //$NON-NLS-1$
TypeFacility.RUNTIME_TYPES.FLOAT);
}
@@ -280,11 +281,11 @@
// BEFORE: convert(string_expr, double)
// AFTER: cast(cast(string_expr as decimal) as double)
IFunction inner = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] { expression, langFactory.createLiteral("decimal", TypeFacility.RUNTIME_TYPES.STRING) }, //$NON-NLS-1$
+ Arrays.asList( expression, langFactory.createLiteral("decimal", TypeFacility.RUNTIME_TYPES.STRING) ), //$NON-NLS-1$
TypeFacility.RUNTIME_TYPES.BIG_DECIMAL);
return langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] { inner, langFactory.createLiteral("double", TypeFacility.RUNTIME_TYPES.STRING) }, //$NON-NLS-1$
+ Arrays.asList( inner, langFactory.createLiteral("double", TypeFacility.RUNTIME_TYPES.STRING) ), //$NON-NLS-1$
TypeFacility.RUNTIME_TYPES.DOUBLE);
}
@@ -298,7 +299,7 @@
// BEFORE: convert(string_expr, bigdecimal)
// AFTER: cast(string_expr as decimal)
return langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] { expression, langFactory.createLiteral("decimal", TypeFacility.RUNTIME_TYPES.STRING) }, //$NON-NLS-1$
+ Arrays.asList( expression, langFactory.createLiteral("decimal", TypeFacility.RUNTIME_TYPES.STRING) ), //$NON-NLS-1$
TypeFacility.RUNTIME_TYPES.BIG_DECIMAL);
}
@@ -340,13 +341,13 @@
// BEFORE: convert(EXPR, timestamp)
// AFTER: timestamp(EXPR, '00:00:00')
ILiteral timeString = this.langFactory.createLiteral("00:00:00", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$
- return this.langFactory.createFunction("timestamp", new IExpression[] {expression, timeString}, TypeFacility.RUNTIME_TYPES.TIMESTAMP); //$NON-NLS-1$
+ return this.langFactory.createFunction("timestamp", Arrays.asList(expression, timeString), TypeFacility.RUNTIME_TYPES.TIMESTAMP); //$NON-NLS-1$
} else if(sourceType.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
// BEFORE: convert(EXPR, timestamp)
// AFTER: timestamp(EXPR, '1970-01-01', EXPR)
ILiteral dateString = this.langFactory.createLiteral("1970-01-01", TypeFacility.RUNTIME_TYPES.STRING); //$NON-NLS-1$
- return this.langFactory.createFunction("timestamp", new IExpression[] {dateString, expression}, TypeFacility.RUNTIME_TYPES.TIMESTAMP); //$NON-NLS-1$
+ return this.langFactory.createFunction("timestamp", Arrays.asList(dateString, expression), TypeFacility.RUNTIME_TYPES.TIMESTAMP); //$NON-NLS-1$
}
return null;
@@ -363,7 +364,7 @@
String functionName,
Class outputType) {
return langFactory.createFunction(functionName,
- new IExpression[] { expression },
+ Arrays.asList( expression ),
outputType);
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLConvertModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -27,6 +27,8 @@
import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.jdbc.translator.DropFunctionModifier;
+import com.metamatrix.connector.language.ICompareCriteria;
+import com.metamatrix.connector.language.ICriteria;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
@@ -52,17 +54,17 @@
}
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
- if (args[0] != null && args[0] instanceof ILiteral && ((ILiteral)args[0]).getValue() == null ) {
- if (args[1] != null && args[1] instanceof ILiteral) {
+ if (args.get(0) != null && args.get(0) instanceof ILiteral && ((ILiteral)args.get(0)).getValue() == null ) {
+ if (args.get(1) != null && args.get(1) instanceof ILiteral) {
// This is a convert(null, ...) or cast(null as ...)
return DROP_MODIFIER.modify(function);
}
}
- if (args[1] != null && args[1] instanceof ILiteral) {
- String target = ((String)((ILiteral)args[1]).getValue()).toLowerCase();
+ if (args.get(1) != null && args.get(1) instanceof ILiteral) {
+ String target = ((String)((ILiteral)args.get(1)).getValue()).toLowerCase();
if (target.equals("string")) { //$NON-NLS-1$
return convertToString(function);
} else if (target.equals("byte") || //$NON-NLS-1$
@@ -77,11 +79,11 @@
target.equals("bigdecimal")) { //$NON-NLS-1$
return convertToNumeric(function);
} else if (target.equals("date")) { //$NON-NLS-1$
- return convertToDateTime("DATE", args[0], java.sql.Date.class); //$NON-NLS-1$
+ return convertToDateTime("DATE", args.get(0), java.sql.Date.class); //$NON-NLS-1$
} else if (target.equals("time")) { //$NON-NLS-1$
- return convertToDateTime("TIME", args[0], java.sql.Time.class); //$NON-NLS-1$
+ return convertToDateTime("TIME", args.get(0), java.sql.Time.class); //$NON-NLS-1$
} else if (target.equals("timestamp")) { //$NON-NLS-1$
- return convertToDateTime("TIMESTAMP", args[0], java.sql.Timestamp.class); //$NON-NLS-1$
+ return convertToDateTime("TIMESTAMP", args.get(0), java.sql.Timestamp.class); //$NON-NLS-1$
} else if (target.equals("char")) { //$NON-NLS-1$
return convertToNativeType(function, "CHAR (1)"); //$NON-NLS-1$
} else if (target.equals("boolean")) { //$NON-NLS-1$
@@ -96,8 +98,8 @@
switch(srcCode) {
case BOOLEAN:
// 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$
+ List<ICompareCriteria> when = Arrays.asList(langFactory.createCompareCriteria(Operator.EQ, function.getParameters().get(0), langFactory.createLiteral(Boolean.TRUE, Boolean.class)));
+ List<ILiteral> then = Arrays.asList(langFactory.createLiteral("1", String.class)); //$NON-NLS-1$
IExpression elseExpr = langFactory.createLiteral("0", String.class); //$NON-NLS-1$
return langFactory.createSearchedCaseExpression(when, then, elseExpr, String.class);
case BYTE:
@@ -125,10 +127,9 @@
}
private IExpression convertToNativeType(IFunction function, String targetType) {
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
function.setName("convert"); //$NON-NLS-1$
- args[1] = langFactory.createLiteral(targetType, String.class);
- function.setParameters(args);
+ args.set(1, langFactory.createLiteral(targetType, String.class));
return function;
}
@@ -141,14 +142,14 @@
private IExpression convertToNumeric(IFunction function) {
// convert(x, float/double/bigdecimal) --> (x + 0.0)
return langFactory.createFunction("+", //$NON-NLS-1$
- new IExpression[] {function.getParameters()[0],
- langFactory.createLiteral(new Double(0.0), Double.class)},
+ Arrays.asList(function.getParameters().get(0),
+ langFactory.createLiteral(new Double(0.0), Double.class)),
Double.class);
}
private IExpression convertToDateTime(String functionName, IExpression value, Class targetType) {
return langFactory.createFunction(functionName,
- new IExpression[] {value},
+ Arrays.asList(value),
targetType);
}
@@ -158,8 +159,8 @@
case STRING:
// convert(src, boolean) --> CASE src WHEN 'true' THEN 1 ELSE 0 END
// 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$
+ List<ICompareCriteria> when = Arrays.asList(langFactory.createCompareCriteria(Operator.EQ, function.getParameters().get(0), langFactory.createLiteral("true", String.class)));
+ List<ILiteral> then = Arrays.asList(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:
@@ -169,16 +170,15 @@
private IFunction convertDateTimeToString(IFunction function, String format) {
// convert (date, string) --> date_format(date, format)
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
function.setName("date_format"); //$NON-NLS-1$
- args[1] = langFactory.createLiteral(format, String.class);
- function.setParameters(args);
+ args.set(1, langFactory.createLiteral(format, String.class));
return function;
}
private int getSrcCode(IFunction function) {
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class srcType = args.get(0).getType();
return ((Integer) typeMap.get(srcType)).intValue();
}
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ConcatFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -26,6 +26,7 @@
import java.util.Arrays;
import java.util.List;
+import com.metamatrix.connector.api.SourceSystemFunctions;
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.language.ICriteria;
@@ -58,8 +59,8 @@
*/
public IExpression modify(IFunction function) {
List when = new ArrayList();
- IExpression a = function.getParameters()[0];
- IExpression b = function.getParameters()[1];
+ IExpression a = function.getParameters().get(0);
+ IExpression b = function.getParameters().get(1);
List crits = new ArrayList();
ILiteral nullValue = langFactory.createLiteral(null, TypeFacility.RUNTIME_TYPES.STRING);
@@ -95,8 +96,8 @@
}
if (expr instanceof IFunction) {
IFunction function = (IFunction)expr;
- if (function.getName().equalsIgnoreCase("NVL") || function.getName().equalsIgnoreCase("IFNULL")) { //$NON-NLS-1$ //$NON-NLS-2$
- return isNotNull(function.getParameters()[1]);
+ if (function.getName().equalsIgnoreCase("NVL") || function.getName().equalsIgnoreCase(SourceSystemFunctions.IFNULL)) { //$NON-NLS-1$
+ return isNotNull(function.getParameters().get(0));
}
}
return false;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/DayWeekQuarterFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/DayWeekQuarterFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/DayWeekQuarterFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,9 @@
package com.metamatrix.connector.jdbc.oracle;
+import java.util.Arrays;
+import java.util.List;
+
import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.*;
@@ -47,16 +50,16 @@
* @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
*/
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
IFunction inner = langFactory.createFunction("TO_CHAR", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- langFactory.createLiteral(format, String.class)},
+ Arrays.asList(
+ args.get(0),
+ langFactory.createLiteral(format, String.class)),
String.class);
IFunction outer = langFactory.createFunction("TO_NUMBER", //$NON-NLS-1$
- new IExpression[] {inner},
+ Arrays.asList(inner),
Integer.class);
return outer;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ExtractFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ExtractFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ExtractFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -45,7 +45,7 @@
public List translate(IFunction function) {
StringBuffer buffer = new StringBuffer();
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
List objs = new ArrayList();
buffer.append("EXTRACT("); //$NON-NLS-1$
@@ -54,7 +54,7 @@
buffer.append("FROM"); //$NON-NLS-1$
buffer.append(SPACE);
- buffer.append(args[0]);
+ buffer.append(args.get(0));
buffer.append(")"); //$NON-NLS-1$
objs.add(buffer.toString());
return objs;
Modified: 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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LeftOrRightFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,9 @@
package com.metamatrix.connector.jdbc.oracle;
+import java.util.Arrays;
+import java.util.List;
+
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.jdbc.translator.FunctionModifier;
@@ -42,25 +45,25 @@
* @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
*/
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
+ List<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],
+ Arrays.asList(
+ args.get(0),
langFactory.createLiteral(Integer.valueOf(1), TypeFacility.RUNTIME_TYPES.INTEGER),
- args[1]},
+ args.get(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]},
+ Arrays.asList(langFactory.createLiteral(Integer.valueOf(-1), TypeFacility.RUNTIME_TYPES.INTEGER), args.get(1)),
Integer.class);
func = langFactory.createFunction("SUBSTR", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- negIndex},
+ Arrays.asList(
+ args.get(0),
+ negIndex),
String.class);
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LocateFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LocateFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LocateFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,9 +22,15 @@
package com.metamatrix.connector.jdbc.oracle;
+import java.util.Arrays;
+import java.util.List;
+
import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.jdbc.translator.FunctionModifier;
-import com.metamatrix.connector.language.*;
+import com.metamatrix.connector.language.IExpression;
+import com.metamatrix.connector.language.IFunction;
+import com.metamatrix.connector.language.ILanguageFactory;
+import com.metamatrix.connector.language.ILiteral;
/**
* Modify the locate function to use the Oracle instr function.
@@ -45,33 +51,28 @@
* @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
*/
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
- IExpression[] instrArgs = new IExpression[args.length];
- instrArgs[0] = args[1];
- instrArgs[1] = args[0];
-
- if(args.length == 3) {
- if(args[2] instanceof ILiteral) {
- ILiteral indexConst = (ILiteral)args[2];
- if(indexConst.getValue() == null) {
- instrArgs[2] = args[2];
- } else {
+ function.setName("instr"); //$NON-NLS-1$
+ List<IExpression> args = function.getParameters();
+ IExpression expr = args.get(0);
+ args.set(0, args.get(1));
+ args.set(1, expr);
+ if(args.size() == 3) {
+ if(args.get(2) instanceof ILiteral) {
+ ILiteral indexConst = (ILiteral)args.get(2);
+ if(indexConst.getValue() != null) {
// Just modify the constant
- Integer index = (Integer) ((ILiteral)args[2]).getValue();
- instrArgs[2] = langFactory.createLiteral(new Integer(index.intValue()+1), Integer.class);
+ Integer index = (Integer) indexConst.getValue();
+ args.set(2, langFactory.createLiteral(new Integer(index.intValue()+1), Integer.class));
}
} else {
// Make plus function since this involves an element or function
IFunction plusFunction = langFactory.createFunction("+", //$NON-NLS-1$
- new IExpression[] { args[2], langFactory.createLiteral(new Integer(1), Integer.class) },
+ Arrays.asList( args.get(2), langFactory.createLiteral(new Integer(1), Integer.class) ),
Integer.class);
- instrArgs[2] = plusFunction;
+ args.set(2, plusFunction);
}
- }
-
- IFunction instrFunction = langFactory.createFunction("instr", instrArgs, Integer.class); //$NON-NLS-1$
-
- return instrFunction;
+ }
+ return function;
}
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/Log10FunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/Log10FunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/Log10FunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,8 @@
package com.metamatrix.connector.jdbc.oracle;
+import java.util.List;
+
import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.*;
@@ -37,12 +39,9 @@
public IExpression modify(IFunction function) {
function.setName("log"); //$NON-NLS-1$
- IExpression[] args = function.getParameters();
- IExpression[] newArgs = new IExpression[args.length+1];
- newArgs[1] = args[0];
- newArgs[0] = languageFactory.createLiteral(new Integer(10), Integer.class);
- function.setParameters(newArgs);
-
+ List<IExpression> args = function.getParameters();
+ args.add(args.get(0));
+ args.set(0, languageFactory.createLiteral(new Integer(10), Integer.class));
return function;
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,9 +22,14 @@
package com.metamatrix.connector.jdbc.oracle;
+import java.util.Arrays;
+import java.util.List;
+
import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.jdbc.translator.FunctionModifier;
-import com.metamatrix.connector.language.*;
+import com.metamatrix.connector.language.IExpression;
+import com.metamatrix.connector.language.IFunction;
+import com.metamatrix.connector.language.ILanguageFactory;
/**
* Convert the MONTHNAME etc. function into an equivalent Oracle function.
@@ -43,17 +48,17 @@
* @see com.metamatrix.connector.jdbc.extension.FunctionModifier#modify(com.metamatrix.data.language.IFunction)
*/
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
IFunction func = langFactory.createFunction("TO_CHAR", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- langFactory.createLiteral(format, String.class)},
+ Arrays.asList(
+ args.get(0),
+ langFactory.createLiteral(format, String.class)),
String.class);
// For some reason, these values have trailing spaces
IFunction trimFunc = langFactory.createFunction("RTRIM", //$NON-NLS-1$
- new IExpression[] { func }, String.class);
+ Arrays.asList( func ), String.class);
return trimFunc;
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleConvertModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,7 @@
package com.metamatrix.connector.jdbc.oracle;
+import java.util.Arrays;
import java.util.List;
import com.metamatrix.connector.api.ConnectorLogger;
@@ -53,10 +54,10 @@
}
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
IExpression modified = null;
- String target = ((String)((ILiteral)args[1]).getValue()).toLowerCase();
+ String target = ((String)((ILiteral)args.get(1)).getValue()).toLowerCase();
if (target.equals("string")) { //$NON-NLS-1$
modified = convertToString(function);
} else if (target.equals("short")) { //$NON-NLS-1$
@@ -93,20 +94,20 @@
private IExpression convertToDate(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class srcType = args.get(0).getType();
int srcCode = getSrcCode(srcType);
switch(srcCode) {
case STRING:
// convert(STRING, date) --> to_date(STRING, format)
String format = "YYYY-MM-DD"; //$NON-NLS-1$
- convert = dateTypeHelper("to_date", new IExpression[] {args[0], //$NON-NLS-1$
- langFactory.createLiteral(format, String.class)}, java.sql.Date.class);
+ convert = dateTypeHelper("to_date", Arrays.asList(args.get(0), //$NON-NLS-1$
+ langFactory.createLiteral(format, String.class)), java.sql.Date.class);
break;
case TIMESTAMP:
// convert(TSELEMENT, date) --> trunc(TSELEMENT)
- convert = dateTypeHelper("trunc", new IExpression[] {args[0]}, java.sql.Date.class); //$NON-NLS-1$
+ convert = dateTypeHelper("trunc", Arrays.asList(args.get(0)), java.sql.Date.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -123,8 +124,8 @@
*/
private IExpression convertToTime(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class srcType = args.get(0).getType();
String format = "YYYY-MM-DD HH24:MI:SS"; //$NON-NLS-1$
int srcCode = getSrcCode(srcType);
@@ -132,20 +133,20 @@
case STRING:
//convert(STRING, time) --> to_date('1970-01-01 ' || to_char(timevalue, 'HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS')
IFunction inner0 = langFactory.createFunction("to_char", //$NON-NLS-1$
- new IExpression[] {
- args[0],
- langFactory.createLiteral("HH24:MI:SS", String.class)}, //$NON-NLS-1$
+ Arrays.asList(
+ args.get(0),
+ langFactory.createLiteral("HH24:MI:SS", String.class)), //$NON-NLS-1$
String.class);
IExpression prependedPart0 = langFactory.createFunction("||", //$NON-NLS-1$
- new IExpression[] {
+ Arrays.asList(
langFactory.createLiteral("1970-01-01 ", String.class), //$NON-NLS-1$
- inner0},
+ inner0),
String.class);
convert = langFactory.createFunction("to_date", //$NON-NLS-1$
- new IExpression[] {prependedPart0,
- langFactory.createLiteral(format, String.class)},
+ Arrays.asList(prependedPart0,
+ langFactory.createLiteral(format, String.class)),
java.sql.Time.class);
break;
case TIMESTAMP:
@@ -153,20 +154,20 @@
// --> 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("HH24:MI:SS", String.class)}, //$NON-NLS-1$
+ Arrays.asList(
+ args.get(0),
+ langFactory.createLiteral("HH24:MI:SS", String.class)), //$NON-NLS-1$
String.class);
IExpression prependedPart = langFactory.createFunction("||", //$NON-NLS-1$
- new IExpression[] {
+ Arrays.asList(
langFactory.createLiteral("1970-01-01 ", String.class), //$NON-NLS-1$
- inner},
+ inner),
String.class);
convert = langFactory.createFunction("to_date", //$NON-NLS-1$
- new IExpression[] {prependedPart,
- langFactory.createLiteral(format, String.class)},
+ Arrays.asList(prependedPart,
+ langFactory.createLiteral(format, String.class)),
java.sql.Time.class);
break;
default:
@@ -179,20 +180,20 @@
private IExpression convertToTimestamp(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class srcType = args.get(0).getType();
int srcCode = getSrcCode(srcType);
switch(srcCode) {
case STRING:
// 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);
+ convert = dateTypeHelper("to_timestamp", Arrays.asList(args.get(0), //$NON-NLS-1$
+ langFactory.createLiteral(format, String.class)), java.sql.Timestamp.class);
break;
case TIME:
case DATE:
- convert = dateTypeHelper("cast", new IExpression[] {args[0], //$NON-NLS-1$
- langFactory.createLiteral("timestamp", String.class)}, java.sql.Timestamp.class); //$NON-NLS-1$
+ convert = dateTypeHelper("cast", Arrays.asList(args.get(0), //$NON-NLS-1$
+ langFactory.createLiteral("timestamp", String.class)), java.sql.Timestamp.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -212,18 +213,18 @@
private IExpression convertToString(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
String format = null;
int srcCode = getSrcCode(function);
switch(srcCode) { // convert(input, string) --> to_char(input)
case BOOLEAN:
- convert = langFactory.createFunction("decode", new IExpression[] //$NON-NLS-1$
- { args[0],
+ convert = langFactory.createFunction("decode", Arrays.asList( //$NON-NLS-1$
+ args.get(0),
langFactory.createLiteral(new Integer(0), Integer.class),
langFactory.createLiteral("false", String.class), //$NON-NLS-1$
langFactory.createLiteral(new Integer(1), Integer.class),
- langFactory.createLiteral("true", String.class) }, //$NON-NLS-1$
+ langFactory.createLiteral("true", String.class) ), //$NON-NLS-1$
String.class);
break;
@@ -235,19 +236,19 @@
case FLOAT:
case DOUBLE:
case BIGDECIMAL:
- convert = createStringFunction(args[0]);
+ convert = createStringFunction(args.get(0));
break;
// convert(input, string) --> to_char(input, format)
case DATE:
format = "YYYY-MM-DD"; //$NON-NLS-1$
- convert = createStringFunction(args[0], format);
+ convert = createStringFunction(args.get(0), format);
break;
case TIME:
format = "HH24:MI:SS"; //$NON-NLS-1$
- convert = createStringFunction(args[0], format);
+ convert = createStringFunction(args.get(0), format);
break;
case TIMESTAMP:
- convert = createStringFunction(args[0], "YYYY-MM-DD HH24:MI:SS.FF"); //$NON-NLS-1$
+ convert = createStringFunction(args.get(0), "YYYY-MM-DD HH24:MI:SS.FF"); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -446,7 +447,7 @@
return convert;
}
- private IFunction dateTypeHelper(String functionName, IExpression[] args, Class target) {
+ private IFunction dateTypeHelper(String functionName, List<IExpression> args, Class target) {
IFunction convert = langFactory.createFunction(functionName,
args, target);
return convert;
@@ -454,50 +455,48 @@
private IFunction booleanHelper(IFunction function) {
// using decode(value, 'true', 1, 'false', 0)
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
- IExpression[] modified = new IExpression[] {
- args[0],
- langFactory.createLiteral("true", String.class), //$NON-NLS-1$
- langFactory.createLiteral(new Byte((byte)1), Byte.class),
- langFactory.createLiteral("false", String.class), //$NON-NLS-1$
- langFactory.createLiteral(new Byte((byte)0), Byte.class)
- };
-
return langFactory.createFunction("decode", //$NON-NLS-1$
- modified, java.lang.Boolean.class);
+ Arrays.asList(
+ args.get(0),
+ langFactory.createLiteral("true", String.class), //$NON-NLS-1$
+ langFactory.createLiteral(new Byte((byte)1), Byte.class),
+ langFactory.createLiteral("false", String.class), //$NON-NLS-1$
+ langFactory.createLiteral(new Byte((byte)0), Byte.class)
+ ), java.lang.Boolean.class);
}
private IExpression stringSrcHelper(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
// switch the target type
String functionName = "to_number"; //$NON-NLS-1$
int targetCode = getTargetCode(function.getType());
switch(targetCode) {
case BYTE:
- convert = createFunction(functionName, args[0], Byte.class);
+ convert = createFunction(functionName, args.get(0), Byte.class);
break;
case SHORT:
- convert = createFunction(functionName, args[0], Short.class);
+ convert = createFunction(functionName, args.get(0), Short.class);
break;
case INTEGER:
- convert = createFunction(functionName, args[0], Integer.class);
+ convert = createFunction(functionName, args.get(0), Integer.class);
break;
case LONG:
- convert = createFunction(functionName, args[0], Long.class);
+ convert = createFunction(functionName, args.get(0), Long.class);
break;
case BIGINTEGER:
- convert = createFunction(functionName, args[0], java.math.BigInteger.class);
+ convert = createFunction(functionName, args.get(0), java.math.BigInteger.class);
break;
case FLOAT:
- convert = createFunction(functionName, args[0], Float.class);
+ convert = createFunction(functionName, args.get(0), Float.class);
break;
case DOUBLE:
- convert = createFunction(functionName, args[0], Double.class);
+ convert = createFunction(functionName, args.get(0), Double.class);
break;
case BIGDECIMAL:
- convert = createFunction(functionName, args[0], java.math.BigDecimal.class);
+ convert = createFunction(functionName, args.get(0), java.math.BigDecimal.class);
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -508,26 +507,26 @@
private IFunction createFunction(String functionName, IExpression args0, Class targetClass) {
IFunction created = langFactory.createFunction(functionName,
- new IExpression[] {args0}, targetClass);
+ Arrays.asList(args0), targetClass);
return created;
}
private IFunction createStringFunction(IExpression args0, String format) {
IFunction created = langFactory.createFunction("to_char", //$NON-NLS-1$
- new IExpression[] {args0, langFactory.createLiteral(format, String.class)},
+ Arrays.asList(args0, langFactory.createLiteral(format, String.class)),
String.class);
return created;
}
private IFunction createStringFunction(IExpression args) {
IFunction created = langFactory.createFunction("to_char", //$NON-NLS-1$
- new IExpression[] { args }, String.class);
+ Arrays.asList( args ), String.class);
return created;
}
private int getSrcCode(IFunction function) {
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class srcType = args.get(0).getType();
return ((Integer) typeMap.get(srcType)).intValue();
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLTranslator.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -46,7 +46,6 @@
import com.metamatrix.connector.language.ILimit;
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;
/**
@@ -99,7 +98,7 @@
* 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();
+ List<Element> allElements = insert.getGroup().getMetadataObject().getChildren();
if (allElements.size() == insert.getValues().size()) {
return command;
}
@@ -107,8 +106,7 @@
int index = 0;
List<IElement> elements = insert.getElements();
- for (MetadataID metadataID : allElements) {
- Element element = (Element)metadataID.getMetadataObject();
+ for (Element element : allElements) {
if (!element.isAutoIncremented()) {
continue;
}
@@ -119,7 +117,7 @@
}
boolean found = false;
while (index < elements.size()) {
- if (metadataID.equals(elements.get(index).getMetadataID())) {
+ if (element.equals(elements.get(index).getMetadataObject())) {
found = true;
break;
}
@@ -140,7 +138,7 @@
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.getElements().add(index, this.getLanguageFactory().createElement(element.getName(), insert.getGroup(), element, element.getJavaType()));
insert.getValues().add(index, sequenceElement);
}
return command;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/DatePartFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/DatePartFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/DatePartFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,8 @@
package com.metamatrix.connector.jdbc.postgresql;
+import java.util.Arrays;
+
import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
@@ -43,7 +45,7 @@
public IExpression modify(IFunction function) {
return factory.createFunction("date_part", //$NON-NLS-1$
- new IExpression[] {factory.createLiteral(part, String.class), function.getParameters()[0]},
+ Arrays.asList(factory.createLiteral(part, String.class), function.getParameters().get(0)),
Integer.class);
}
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/ModifiedDatePartFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/ModifiedDatePartFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/ModifiedDatePartFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,8 @@
package com.metamatrix.connector.jdbc.postgresql;
+import java.util.Arrays;
+
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
@@ -44,7 +46,7 @@
public IExpression modify(IFunction function) {
IExpression expr = super.modify(function);
return factory.createFunction(modifier,
- new IExpression[] {expr, factory.createLiteral(arg, arg.getClass())},
+ Arrays.asList(expr, factory.createLiteral(arg, arg.getClass())),
arg.getClass());
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLConvertModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -51,33 +51,33 @@
}
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
- if (args[0] != null && args[0] instanceof ILiteral && ((ILiteral)args[0]).getValue() == null ) {
- if (args[1] != null && args[1] instanceof ILiteral) {
+ if (args.get(0) != null && args.get(0) instanceof ILiteral && ((ILiteral)args.get(0)).getValue() == null ) {
+ if (args.get(1) != null && args.get(1) instanceof ILiteral) {
// This is a convert(null, ...) or cast(null as ...)
return DROP_MODIFIER.modify(function);
}
}
- if (args[1] != null && args[1] instanceof ILiteral) {
- String target = ((String)((ILiteral)args[1]).getValue()).toLowerCase();
+ if (args.get(1) != null && args.get(1) instanceof ILiteral) {
+ String target = ((String)((ILiteral)args.get(1)).getValue()).toLowerCase();
if (target.equals("string")) { //$NON-NLS-1$
return convertToString(function);
} else if (target.equals("short")) { //$NON-NLS-1$
- return createCastFunction(args[0], "smallint", Short.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "smallint", Short.class); //$NON-NLS-1$
} else if (target.equals("integer")) { //$NON-NLS-1$
- return createCastFunction(args[0], "integer", Integer.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "integer", Integer.class); //$NON-NLS-1$
} else if (target.equals("long")) { //$NON-NLS-1$
- return createCastFunction(args[0], "bigint", Long.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "bigint", Long.class); //$NON-NLS-1$
} else if (target.equals("biginteger")) { //$NON-NLS-1$
- return createCastFunction(args[0], "numeric", BigInteger.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "numeric", BigInteger.class); //$NON-NLS-1$
} else if (target.equals("float")) { //$NON-NLS-1$
- return createCastFunction(args[0], "real", Float.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "real", Float.class); //$NON-NLS-1$
} else if (target.equals("double")) { //$NON-NLS-1$
- return createCastFunction(args[0], "float8", Double.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "float8", Double.class); //$NON-NLS-1$
} else if (target.equals("bigdecimal")) { //$NON-NLS-1$
- return createCastFunction(args[0], "decimal", BigDecimal.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "decimal", BigDecimal.class); //$NON-NLS-1$
} else if (target.equals("date")) { //$NON-NLS-1$
return convertToDate(function);
} else if (target.equals("time")) { //$NON-NLS-1$
@@ -85,44 +85,44 @@
} else if (target.equals("timestamp")) { //$NON-NLS-1$
return convertToTimestamp(function);
} else if (target.equals("char")) { //$NON-NLS-1$
- return createCastFunction(args[0], "varchar", String.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "varchar", String.class); //$NON-NLS-1$
} else if (target.equals("boolean")) { //$NON-NLS-1$
- return createCastFunction(args[0], "boolean", Boolean.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "boolean", Boolean.class); //$NON-NLS-1$
} else if (target.equals("byte")) { //$NON-NLS-1$
- return createCastFunction(args[0], "smallint", Byte.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "smallint", Byte.class); //$NON-NLS-1$
}
}
return DROP_MODIFIER.modify(function);
}
private IExpression convertToDate(IFunction function) {
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
int srcCode = getSrcCode(function);
switch(srcCode) {
case STRING:
- return createConversionFunction("to_date", args[0], "YYYY-MM-DD", java.sql.Date.class); //$NON-NLS-1$//$NON-NLS-2$
+ return createConversionFunction("to_date", args.get(0), "YYYY-MM-DD", java.sql.Date.class); //$NON-NLS-1$//$NON-NLS-2$
case TIMESTAMP:
- return createCastFunction(args[0], "date", java.sql.Date.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "date", java.sql.Date.class); //$NON-NLS-1$
default:
return DROP_MODIFIER.modify(function);
}
}
private IExpression convertToTime(IFunction function) {
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
int srcCode = getSrcCode(function);
switch(srcCode) {
case STRING:
//convert(STRING, time) --> to_timestamp('1970-01-01 ' || timevalue, 'YYYY-MM-DD HH24:MI:SS')
IExpression prependedPart0 = langFactory.createFunction("||", //$NON-NLS-1$
- new IExpression[] {langFactory.createLiteral("1970-01-01 ", String.class), args[0]}, //$NON-NLS-1$
+ Arrays.asList(langFactory.createLiteral("1970-01-01 ", String.class), args.get(0)), //$NON-NLS-1$
String.class);
return createConversionFunction("to_timestamp", prependedPart0, "YYYY-MM-DD HH24:MI:SS", java.sql.Time.class); //$NON-NLS-1$ //$NON-NLS-2$
case TIMESTAMP:
- return createCastFunction(args[0], "time", java.sql.Time.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "time", java.sql.Time.class); //$NON-NLS-1$
default:
return DROP_MODIFIER.modify(function);
}
@@ -134,16 +134,16 @@
* @return IFunction
*/
private IExpression convertToTimestamp(IFunction function) {
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
int srcCode = getSrcCode(function);
switch(srcCode) {
case STRING:
// convert(STRING, timestamp) --> to_date(timestampvalue, 'YYYY-MM-DD HH24:MI:SS'))) from smalla
- return createConversionFunction("to_timestamp", args[0], "YYYY-MM-DD HH24:MI:SS.UF", java.sql.Timestamp.class); //$NON-NLS-1$ //$NON-NLS-2$
+ return createConversionFunction("to_timestamp", args.get(0), "YYYY-MM-DD HH24:MI:SS.UF", java.sql.Timestamp.class); //$NON-NLS-1$ //$NON-NLS-2$
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 = createStringFunction(args[0], "YYYY-MM-DD HH24:MI:SS"); //$NON-NLS-1$
+ IFunction inner = createStringFunction(args.get(0), "YYYY-MM-DD HH24:MI:SS"); //$NON-NLS-1$
return createConversionFunction("to_timestamp", inner, "YYYY-MM-DD HH24:MI:SS", java.sql.Timestamp.class); //$NON-NLS-1$ //$NON-NLS-2$
default:
@@ -152,14 +152,14 @@
}
private IExpression convertToString(IFunction function) {
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
int srcCode = getSrcCode(function);
switch(srcCode) {
case BOOLEAN:
// 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$
+ List when = Arrays.asList(langFactory.createCompareCriteria(Operator.EQ, function.getParameters().get(0), langFactory.createLiteral(Boolean.TRUE, Boolean.class)));
+ List then = Arrays.asList(langFactory.createLiteral("1", String.class)); //$NON-NLS-1$
IExpression elseExpr = langFactory.createLiteral("0", String.class); //$NON-NLS-1$
return langFactory.createSearchedCaseExpression(when, then, elseExpr, String.class);
case BYTE:
@@ -171,14 +171,14 @@
case DOUBLE:
case BIGDECIMAL:
// convert(src, string) --> cast (src AS varchar)
- return createCastFunction(args[0], "varchar", String.class); //$NON-NLS-1$
+ return createCastFunction(args.get(0), "varchar", String.class); //$NON-NLS-1$
// convert(input, string) --> to_char(input, format)
case DATE:
- return createStringFunction(args[0], "YYYY-MM-DD"); //$NON-NLS-1$
+ return createStringFunction(args.get(0), "YYYY-MM-DD"); //$NON-NLS-1$
case TIME:
- return createStringFunction(args[0], "HH24:MI:SS"); //$NON-NLS-1$
+ return createStringFunction(args.get(0), "HH24:MI:SS"); //$NON-NLS-1$
case TIMESTAMP:
- return createStringFunction(args[0], "YYYY-MM-DD HH24:MI:SS.US"); //$NON-NLS-1$
+ return createStringFunction(args.get(0), "YYYY-MM-DD HH24:MI:SS.US"); //$NON-NLS-1$
default:
return DROP_MODIFIER.modify(function);
}
@@ -193,12 +193,12 @@
}
private IFunction createConversionFunction(String functionName, IExpression value, String target, Class targetClass) {
- return langFactory.createFunction(functionName, new IExpression[] {value, langFactory.createLiteral(target, String.class)}, targetClass);
+ return langFactory.createFunction(functionName, Arrays.asList(value, langFactory.createLiteral(target, String.class)), targetClass);
}
private int getSrcCode(IFunction function) {
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class srcType = args.get(0).getType();
return ((Integer) typeMap.get(srcType)).intValue();
}
}
Modified: 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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/ModFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,8 @@
package com.metamatrix.connector.jdbc.sybase;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import com.metamatrix.connector.api.TypeFacility.RUNTIME_TYPES;
@@ -41,26 +43,21 @@
@Override
public IExpression modify(IFunction function) {
- IExpression[] expressions = function.getParameters();
- if (RUNTIME_TYPES.INTEGER.equals(expressions[0].getType())) {
+ List<IExpression> expressions = function.getParameters();
+ if (RUNTIME_TYPES.INTEGER.equals(expressions.get(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 divide = langFactory.createFunction("/", new ArrayList<IExpression>(expressions), expressions.get(0).getType()); //$NON-NLS-1$
- IFunction floor = langFactory.createFunction("floor", new IExpression[] {divide}, divide.getType()); //$NON-NLS-1$
+ IFunction floor = langFactory.createFunction("floor", Arrays.asList(divide), divide.getType()); //$NON-NLS-1$
- IExpression[] multArgs = new IExpression[] {
- floor, expressions[1]
- };
- IFunction mult = langFactory.createFunction("*", multArgs, multArgs[1].getType()); //$NON-NLS-1$
+ List<IExpression> multArgs = Arrays.asList(floor, expressions.get(1));
+ IFunction mult = langFactory.createFunction("*", multArgs, multArgs.get(1).getType()); //$NON-NLS-1$
+
+ List<IExpression> minusArgs = Arrays.asList(expressions.get(0), mult);
- IExpression[] minusArgs = new IExpression[] {
- expressions[0], mult
- };
- return langFactory.createFunction("-", minusArgs, minusArgs[0].getType()); //$NON-NLS-1$
+ return langFactory.createFunction("-", minusArgs, minusArgs.get(0).getType()); //$NON-NLS-1$
}
@Override
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseConvertModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,12 +23,16 @@
package com.metamatrix.connector.jdbc.sybase;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.jdbc.translator.DropFunctionModifier;
import com.metamatrix.connector.jdbc.translator.FunctionModifier;
-import com.metamatrix.connector.language.*;
+import com.metamatrix.connector.language.IExpression;
+import com.metamatrix.connector.language.IFunction;
+import com.metamatrix.connector.language.ILanguageFactory;
+import com.metamatrix.connector.language.ILiteral;
/**
*/
@@ -47,11 +51,11 @@
}
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
IExpression modified = null;
- if (args[1] != null && args[1] instanceof ILiteral) {
- String target = ((String)((ILiteral)args[1]).getValue()).toLowerCase();
+ if (args.get(1) != null && args.get(1) instanceof ILiteral) {
+ String target = ((String)((ILiteral)args.get(1)).getValue()).toLowerCase();
if (target.equals("string")) { //$NON-NLS-1$
modified = convertToString(function);
} else if (target.equals("short")) { //$NON-NLS-1$
@@ -96,17 +100,17 @@
List parts = new ArrayList();
parts.add("convert("); //$NON-NLS-1$
- IExpression[] args = function.getParameters();
+ List<IExpression> args = function.getParameters();
- if(args != null && args.length > 0) {
- ILiteral type = (ILiteral) args[0];
+ if(args != null && args.size() > 0) {
+ ILiteral type = (ILiteral) args.get(0);
String typeStr = type.getValue().toString();
parts.add(typeStr);
- for(int i=1; i<args.length; i++) {
+ for(int i=1; i<args.size(); i++) {
parts.add(", "); //$NON-NLS-1$
- parts.add(args[i]);
+ parts.add(args.get(i));
}
}
parts.add(")"); //$NON-NLS-1$
@@ -115,8 +119,8 @@
private IExpression convertToBoolean(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class src = args.get(0).getType();
int srcCode = getSrcCode(src);
switch(srcCode) {
@@ -130,7 +134,7 @@
case FLOAT:
case DOUBLE:
case BIGDECIMAL:
- convert = createFunction(args[0], "bit", Boolean.class); //$NON-NLS-1$
+ convert = createFunction(args.get(0), "bit", Boolean.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -142,8 +146,8 @@
private IExpression convertToByte(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class src = args.get(0).getType();
int srcCode = getSrcCode(src);
switch(srcCode) {
@@ -156,7 +160,7 @@
case FLOAT:
case DOUBLE:
case BIGDECIMAL:
- convert = createFunction(args[0], "tinyint", String.class); //$NON-NLS-1$
+ convert = createFunction(args.get(0), "tinyint", String.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -168,8 +172,8 @@
private IExpression convertToString(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class src = args.get(0).getType();
int srcCode = getSrcCode(src);
switch(srcCode) {
@@ -183,17 +187,17 @@
case FLOAT:
case DOUBLE:
case BIGDECIMAL:
- convert = createFunction(args[0], "varchar", String.class); //$NON-NLS-1$
+ convert = createFunction(args.get(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);
+ convert = createFunction(args.get(0), 101, String.class);
break;
case TIME: // convert(time, string) --> convert(varchar, time, 108)
- convert = createFunction(args[0], 108, String.class);
+ convert = createFunction(args.get(0), 108, String.class);
break;
case TIMESTAMP: // convert(time, string) --> convert(varchar, timestamp, 109)
- convert = createFunction(args[0], 109, String.class);
+ convert = createFunction(args.get(0), 109, String.class);
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -205,8 +209,8 @@
private IExpression convertToShort(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class src = args.get(0).getType();
int srcCode = getSrcCode(src);
switch(srcCode) {
@@ -219,7 +223,7 @@
case FLOAT:
case DOUBLE:
case BIGDECIMAL:
- convert = createFunction(args[0], "smallint", Short.class); //$NON-NLS-1$
+ convert = createFunction(args.get(0), "smallint", Short.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -231,8 +235,8 @@
private IExpression convertToInteger(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class src = args.get(0).getType();
int srcCode = getSrcCode(src);
switch(srcCode) {
@@ -245,7 +249,7 @@
case FLOAT:
case DOUBLE:
case BIGDECIMAL:
- convert = createFunction(args[0], "int", Integer.class); //$NON-NLS-1$
+ convert = createFunction(args.get(0), "int", Integer.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -257,8 +261,8 @@
private IExpression convertToLong(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class src = args.get(0).getType();
int srcCode = getSrcCode(src);
switch(srcCode) {
@@ -271,7 +275,7 @@
case FLOAT:
case DOUBLE:
case BIGDECIMAL:
- convert = createFunction(args[0], "numeric", Long.class); //$NON-NLS-1$
+ convert = createFunction(args.get(0), "numeric", Long.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -283,8 +287,8 @@
private IExpression convertToBigInteger(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class src = args.get(0).getType();
int srcCode = getSrcCode(src);
switch(srcCode) {
@@ -297,7 +301,7 @@
case FLOAT:
case DOUBLE:
case BIGDECIMAL:
- convert = createFunction(args[0], "numeric", java.math.BigInteger.class); //$NON-NLS-1$
+ convert = createFunction(args.get(0), "numeric", java.math.BigInteger.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -309,8 +313,8 @@
private IExpression convertToFloat(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class src = args.get(0).getType();
int srcCode = getSrcCode(src);
switch(srcCode) {
@@ -323,7 +327,7 @@
case BIGINTEGER:
case DOUBLE:
case BIGDECIMAL:
- convert = createFunction(args[0], "real", Float.class); //$NON-NLS-1$
+ convert = createFunction(args.get(0), "real", Float.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -335,8 +339,8 @@
private IExpression convertToDouble(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class src = args.get(0).getType();
int srcCode = getSrcCode(src);
switch(srcCode) {
@@ -349,7 +353,7 @@
case BIGINTEGER:
case FLOAT:
case BIGDECIMAL:
- convert = createFunction(args[0], "float", Double.class); //$NON-NLS-1$
+ convert = createFunction(args.get(0), "float", Double.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -361,8 +365,8 @@
private IExpression convertToBigDecimal(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class src = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class src = args.get(0).getType();
int srcCode = getSrcCode(src);
switch(srcCode) {
@@ -375,7 +379,7 @@
case BIGINTEGER:
case FLOAT:
case DOUBLE:
- convert = createFunction(args[0], "float", java.math.BigDecimal.class); //$NON-NLS-1$
+ convert = createFunction(args.get(0), "float", java.math.BigDecimal.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -386,36 +390,36 @@
}
private IExpression convertToChar(IFunction function) {
- IExpression[] args = function.getParameters();
- return createFunction(args[0], "char", Character.class); //$NON-NLS-1$
+ List<IExpression> args = function.getParameters();
+ return createFunction(args.get(0), "char", Character.class); //$NON-NLS-1$
}
private IExpression convertToDate(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class srcType = args.get(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$
+ convert = createFunction(args.get(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[] {
+ Arrays.asList(
langFactory.createLiteral("varchar", String.class), //$NON-NLS-1$
- args[0],
- langFactory.createLiteral(new Integer(109), Integer.class) },
+ args.get(0),
+ langFactory.createLiteral(new Integer(109), Integer.class) ),
String.class);
// Build outer convert
convert = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
+ Arrays.asList(
langFactory.createLiteral("datetime", String.class), //$NON-NLS-1$
- innerConvert },
+ innerConvert ),
java.sql.Timestamp.class);
break;
@@ -429,30 +433,30 @@
private IExpression convertToTime(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class srcType = args.get(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$
+ convert = createFunction(args.get(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[] {
+ Arrays.asList(
langFactory.createLiteral("varchar", String.class), //$NON-NLS-1$
- args[0],
- langFactory.createLiteral(new Integer(108), Integer.class) },
+ args.get(0),
+ langFactory.createLiteral(new Integer(108), Integer.class) ),
String.class);
// Build outer convert
convert = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
+ Arrays.asList(
langFactory.createLiteral("datetime", String.class), //$NON-NLS-1$
- innerConvert },
+ innerConvert ),
java.sql.Time.class);
break;
@@ -466,15 +470,15 @@
private IExpression convertToTimestamp(IFunction function) {
IExpression convert = null;
- IExpression[] args = function.getParameters();
- Class srcType = args[0].getType();
+ List<IExpression> args = function.getParameters();
+ Class srcType = args.get(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$
+ convert = createFunction(args.get(0), "datetime", java.sql.Timestamp.class); //$NON-NLS-1$
break;
default:
convert = DROP_MODIFIER.modify(function);
@@ -486,18 +490,18 @@
private IFunction createFunction(IExpression args0, String targetType, Class targetClass) {
IFunction created = langFactory.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
+ Arrays.asList(
langFactory.createLiteral(targetType, String.class),
- args0},
+ 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$
+ Arrays.asList( langFactory.createLiteral("varchar", String.class), //$NON-NLS-1$
args0,
- langFactory.createLiteral(new Integer(formatNumber), Integer.class) },
+ langFactory.createLiteral(new Integer(formatNumber), Integer.class) ),
targetClass);
return created;
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BasicFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BasicFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BasicFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -98,13 +98,13 @@
List objs = new ArrayList();
objs.add(function.getName());
objs.add("("); //$NON-NLS-1$
- IExpression[] params = function.getParameters();
- if(params.length > 0) {
- objs.add(params[0]);
- if(params.length > 1) {
- for(int i=1; i<params.length; i++) {
+ List<IExpression> params = function.getParameters();
+ if(params.size() > 0) {
+ objs.add(params.get(0));
+ if(params.size() > 1) {
+ for(int i=1; i<params.size(); i++) {
objs.add(", "); //$NON-NLS-1$
- objs.add(params[i]);
+ objs.add(params.get(i));
}
}
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/DropFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/DropFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/DropFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,8 @@
package com.metamatrix.connector.jdbc.translator;
+import java.util.List;
+
import com.metamatrix.connector.jdbc.JDBCPlugin;
import com.metamatrix.connector.language.*;
@@ -40,11 +42,11 @@
}
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
- if(args.length <= replaceIndex) {
+ List<IExpression> args = function.getParameters();
+ if(args.size() <= replaceIndex) {
throw new IllegalArgumentException(JDBCPlugin.Util.getString("DropFunctionModifier.DropFunctionModifier_can_only_be_used_on_functions_with___1") + function); //$NON-NLS-1$
}
- return args[replaceIndex];
+ return args.get(replaceIndex);
}
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SQLConversionVisitor.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SQLConversionVisitor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -246,7 +246,7 @@
}
prepareCallBuffer.append(" call ");//$NON-NLS-1$
- prepareCallBuffer.append(exec.getMetadataID() != null ? getName(exec.getMetadataID()) : exec.getProcedureName());
+ prepareCallBuffer.append(exec.getMetadataObject() != null ? getName(exec.getMetadataObject()) : exec.getProcedureName());
prepareCallBuffer.append("("); //$NON-NLS-1$
int numberOfParameters = 0;
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SubstringFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SubstringFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SubstringFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,9 @@
package com.metamatrix.connector.jdbc.translator;
+import java.util.Arrays;
+import java.util.List;
+
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
@@ -43,20 +46,11 @@
* @see com.metamatrix.connector.jdbc.translator.FunctionModifier#modify(com.metamatrix.query.sql.symbol.Function)
*/
public IExpression modify(IFunction function) {
- IExpression[] args = function.getParameters();
- IExpression[] newArgs = new IExpression[3];
- function.setParameters(newArgs);
-
- newArgs[0] = args[0];
- newArgs[1] = args[1];
+ List<IExpression> args = function.getParameters();
- if(args.length == 2) {
- newArgs[2] = languageFactory.createFunction(length_function, new IExpression[] { args[0] }, Integer.class);
- } else {
- newArgs[2] = args[2];
- }
-
- function.setParameters(newArgs);
+ if(args.size() == 2) {
+ args.add(languageFactory.createFunction(length_function, Arrays.asList(args.get(0)), Integer.class));
+ }
return function;
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/util/FunctionReplacementVisitor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,7 +22,6 @@
package com.metamatrix.connector.jdbc.util;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -84,12 +83,10 @@
*/
public void visit(IFunction obj) {
super.visit(obj);
- IExpression[] args = obj.getParameters();
- IExpression[] newArgs = new IExpression[args.length];
- for(int i=0; i<args.length; i++) {
- newArgs[i] = replaceFunction(args[i]);
+ List<IExpression> args = obj.getParameters();
+ for(int i=0; i<args.size(); i++) {
+ args.set(i, replaceFunction(args.get(i)));
}
- obj.setParameters(newArgs);
}
/**
@@ -98,14 +95,12 @@
*/
public void visit(IGroupBy obj) {
super.visit(obj);
- List expressions = obj.getElements();
+ List<IExpression> expressions = obj.getElements();
for (int i=0; i<expressions.size(); i++) {
IExpression expression = (IExpression)expressions.get(i);
expressions.set(i, replaceFunction(expression));
}
-
- obj.setElements(expressions);
}
/*
@@ -114,14 +109,12 @@
public void visit(IInCriteria obj) {
super.visit(obj);
obj.setLeftExpression(replaceFunction(obj.getLeftExpression()));
- List rightExprs = obj.getRightExpressions();
- List newRightExprs = new ArrayList(rightExprs.size());
+ List<IExpression> rightExprs = obj.getRightExpressions();
for(int i=0; i<rightExprs.size(); i++) {
IExpression expr = (IExpression) rightExprs.get(i);
- newRightExprs.add(replaceFunction(expr));
+ rightExprs.set(i, replaceFunction(expr));
}
- obj.setRightExpressions(newRightExprs);
}
/**
@@ -129,14 +122,12 @@
*/
public void visit(IInsert obj) {
super.visit(obj);
- List values = obj.getValues();
- List newValues = new ArrayList(values.size());
+ List<IExpression> values = obj.getValues();
for(int i=0; i<values.size(); i++) {
IExpression expr = (IExpression) values.get(i);
- newValues.add(replaceFunction(expr));
+ values.set(i, replaceFunction(expr));
}
- obj.setValues(newValues);
}
/*
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2ConvertModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -25,6 +25,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
+import java.util.Arrays;
import java.util.Properties;
import junit.framework.TestCase;
@@ -64,9 +65,9 @@
public void helpTest(IExpression srcExpression, String tgtType, String expectedExpression) throws Exception {
IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
+ Arrays.asList(
srcExpression,
- LANG_FACTORY.createLiteral(tgtType, String.class)},
+ LANG_FACTORY.createLiteral(tgtType, String.class)),
TypeFacility.getDataTypeClass(tgtType));
DB2ConvertModifier mod = new DB2ConvertModifier(LANG_FACTORY);
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/derby/TestDerbyConvertModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -25,6 +25,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
+import java.util.Arrays;
import java.util.Properties;
import junit.framework.TestCase;
@@ -64,9 +65,9 @@
public void helpTest(IExpression srcExpression, String tgtType, String expectedExpression) throws Exception {
IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
+ Arrays.asList(
srcExpression,
- LANG_FACTORY.createLiteral(tgtType, String.class)},
+ LANG_FACTORY.createLiteral(tgtType, String.class)),
TypeFacility.getDataTypeClass(tgtType));
DerbyConvertModifier mod = new DerbyConvertModifier(LANG_FACTORY);
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestDropFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestDropFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestDropFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,8 @@
package com.metamatrix.connector.jdbc.extension.impl;
+import java.util.Arrays;
+
import junit.framework.TestCase;
import com.metamatrix.cdk.CommandBuilder;
@@ -47,7 +49,7 @@
ILiteral arg1 = CommandBuilder.getLanuageFactory().createLiteral(new Integer(5), Integer.class);
ILiteral arg2 = CommandBuilder.getLanuageFactory().createLiteral("string", String.class);//$NON-NLS-1$
- IFunction func = CommandBuilder.getLanuageFactory().createFunction("convert", new IExpression[] { arg1, arg2}, Integer.class); //$NON-NLS-1$
+ IFunction func = CommandBuilder.getLanuageFactory().createFunction("convert", Arrays.asList(arg1, arg2), Integer.class); //$NON-NLS-1$
IExpression output = mod.modify(func);
assertEquals("Did not get expected function after using drop modifier", arg1, output); //$NON-NLS-1$
@@ -64,7 +66,7 @@
ILiteral arg1 = CommandBuilder.getLanuageFactory().createLiteral("string", String.class);//$NON-NLS-1$
ILiteral arg2 = CommandBuilder.getLanuageFactory().createLiteral(new Integer(5), Integer.class);
- IFunction func = CommandBuilder.getLanuageFactory().createFunction("convert", new IExpression[] { arg1, arg2}, Integer.class); //$NON-NLS-1$
+ IFunction func = CommandBuilder.getLanuageFactory().createFunction("convert", Arrays.asList(arg1, arg2), Integer.class); //$NON-NLS-1$
IExpression output = mod.modify(func);
assertEquals("Did not get expected function after using drop modifier", arg2, output); //$NON-NLS-1$
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -29,7 +29,6 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.connector.jdbc.translator.EscapeSyntaxModifier;
-import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILiteral;
@@ -50,7 +49,7 @@
ILiteral arg1 = CommandBuilder.getLanuageFactory().createLiteral("arg1", String.class); //$NON-NLS-1$
ILiteral arg2 = CommandBuilder.getLanuageFactory().createLiteral("arg2", String.class);//$NON-NLS-1$
- IFunction func = CommandBuilder.getLanuageFactory().createFunction("concat", new IExpression[] { arg1, arg2}, Integer.class); //$NON-NLS-1$
+ IFunction func = CommandBuilder.getLanuageFactory().createFunction("concat", Arrays.asList( arg1, arg2), Integer.class); //$NON-NLS-1$
func = (IFunction) mod.modify(func);
List parts = mod.translate(func);
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,6 +23,7 @@
package com.metamatrix.connector.jdbc.oracle;
import java.sql.Timestamp;
+import java.util.Arrays;
import java.util.Properties;
import junit.framework.TestCase;
@@ -52,7 +53,7 @@
public IExpression helpTestMod(ILiteral c, String format, String expectedStr) throws Exception {
IFunction func = LANG_FACTORY.createFunction("dayweekquarter", //$NON-NLS-1$
- new IExpression[] { c },
+ Arrays.asList(c),
String.class);
DayWeekQuarterFunctionModifier mod = new DayWeekQuarterFunctionModifier (LANG_FACTORY, format);
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestExtractFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,6 +23,7 @@
package com.metamatrix.connector.jdbc.oracle;
import java.sql.Timestamp;
+import java.util.Arrays;
import java.util.Properties;
import junit.framework.TestCase;
@@ -55,7 +56,7 @@
public IExpression helpTestMod(IExpression c, String expectedStr, String target) throws Exception {
IFunction func = LANG_FACTORY.createFunction(target,
- new IExpression[] { c },
+ Arrays.asList(c),
Integer.class);
ExtractFunctionModifier mod = new ExtractFunctionModifier (target);
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLeftOrRightFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,7 @@
package com.metamatrix.connector.jdbc.oracle;
+import java.util.Arrays;
import java.util.Properties;
import junit.framework.TestCase;
@@ -50,7 +51,7 @@
public IExpression helpTestMod(ILiteral c, ILiteral d, String target, String expectedStr) throws Exception {
IFunction func = LANG_FACTORY.createFunction(target,
- new IExpression[] { c, d },
+ Arrays.asList( c, d ),
String.class);
LeftOrRightFunctionModifier mod = new LeftOrRightFunctionModifier (LANG_FACTORY);
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLocateFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,7 @@
package com.metamatrix.connector.jdbc.oracle;
+import java.util.Arrays;
import java.util.Properties;
import junit.framework.TestCase;
@@ -49,7 +50,7 @@
public IExpression helpTestMod(IExpression[] args, String expectedStr) throws Exception {
IFunction func = LANG_FACTORY.createFunction("hour", //$NON-NLS-1$
- args,
+ Arrays.asList(args),
Integer.class);
LocateFunctionModifier mod = new LocateFunctionModifier(LANG_FACTORY);
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLog10FunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,9 @@
package com.metamatrix.connector.jdbc.oracle;
+import java.util.Arrays;
+import java.util.List;
+
import junit.framework.TestCase;
import com.metamatrix.cdk.CommandBuilder;
@@ -44,7 +47,7 @@
public void testModifier() {
ILiteral arg = CommandBuilder.getLanuageFactory().createLiteral(new Double(5.2), Double.class);
- IFunction func = CommandBuilder.getLanuageFactory().createFunction("log10", new IExpression[] {arg}, Double.class); //$NON-NLS-1$
+ IFunction func = CommandBuilder.getLanuageFactory().createFunction("log10", Arrays.asList(arg), Double.class); //$NON-NLS-1$
Log10FunctionModifier modifier = new Log10FunctionModifier(CommandBuilder.getLanuageFactory());
IExpression outExpr = modifier.modify(func);
@@ -55,12 +58,12 @@
assertEquals("log", outFunc.getName()); //$NON-NLS-1$
assertEquals(func.getType(), outFunc.getType());
- IExpression[] outArgs = func.getParameters();
- assertEquals(2, outArgs.length);
- assertEquals(arg, outArgs[1]);
+ List<IExpression> outArgs = func.getParameters();
+ assertEquals(2, outArgs.size());
+ assertEquals(arg, outArgs.get(1));
- assertTrue(outArgs[1] instanceof ILiteral);
- ILiteral newArg = (ILiteral) outArgs[0];
+ assertTrue(outArgs.get(1) instanceof ILiteral);
+ ILiteral newArg = (ILiteral) outArgs.get(0);
assertEquals(Integer.class, newArg.getType());
assertEquals(new Integer(10), newArg.getValue());
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,6 +23,7 @@
package com.metamatrix.connector.jdbc.oracle;
import java.sql.Timestamp;
+import java.util.Arrays;
import java.util.Properties;
import junit.framework.TestCase;
@@ -52,7 +53,7 @@
public IExpression helpTestMod(ILiteral c, String format, String expectedStr) throws Exception {
IFunction func = LANG_FACTORY.createFunction(format.toLowerCase()+"name", // "monthname" //$NON-NLS-1$
- new IExpression[] { c },
+ Arrays.asList( c ),
String.class);
MonthOrDayNameFunctionModifier mod = new MonthOrDayNameFunctionModifier (LANG_FACTORY, format);
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleConvertModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -25,6 +25,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Timestamp;
+import java.util.Arrays;
import java.util.Properties;
import junit.framework.TestCase;
@@ -64,9 +65,9 @@
public void helpTest(IExpression srcExpression, String tgtType, String expectedExpression) throws Exception {
IFunction func = LANG_FACTORY.createFunction("convert", //$NON-NLS-1$
- new IExpression[] {
+ Arrays.asList(
srcExpression,
- LANG_FACTORY.createLiteral(tgtType, String.class)},
+ LANG_FACTORY.createLiteral(tgtType, String.class)),
TypeFacility.getDataTypeClass(tgtType));
OracleConvertModifier mod = new OracleConvertModifier(LANG_FACTORY, null);
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestSubstringFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,7 @@
package com.metamatrix.connector.jdbc.oracle;
+import java.util.Arrays;
import java.util.Properties;
import junit.framework.TestCase;
@@ -52,7 +53,7 @@
public IExpression helpTestMod(IExpression[] args, String expectedStr) throws Exception {
IFunction func = LANG_FACTORY.createFunction("substring", //$NON-NLS-1$
- args, TypeFacility.RUNTIME_TYPES.STRING);
+ Arrays.asList(args), TypeFacility.RUNTIME_TYPES.STRING);
OracleSQLTranslator trans = new OracleSQLTranslator();
trans.initialize(EnvironmentUtility.createEnvironment(new Properties(), false));
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -75,7 +75,6 @@
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;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
/**
@@ -240,7 +239,7 @@
// TODO: Re-use the getExpressionString method if possible, rather than
// rewriting the same code twice.
if(fromItem instanceof IGroup) {
- Group group = (Group) rm.getObject(((IGroup)fromItem).getMetadataID());
+ Group group = ((IGroup)fromItem).getMetadataObject();
nameInSource = group.getNameInSource();
// if NameInSource is null set it to an empty
// string instead so we can safely call split on it
@@ -277,13 +276,12 @@
private String getRestrictToNamedClass(IFromItem fromItem) throws ConnectorException {
String nameInSource;
String namedClass = null;
- MetadataID mdIDGroup;
if(fromItem instanceof IGroup) {
// Here we use slightly different logic than in
// getContextNameFromFromItem so it is easier to get
// the group name later if needed
- mdIDGroup = ((IGroup)fromItem).getMetadataID();
- nameInSource = rm.getObject(mdIDGroup).getNameInSource();
+ Group mdIDGroup = ((IGroup)fromItem).getMetadataObject();
+ nameInSource = mdIDGroup.getNameInSource();
// groupName = mdIDGroup.getName();
// if NameInSource is null set it to an empty
// string instead so we can safely call split on it
@@ -319,7 +317,7 @@
// TODO: Re-use the getExpressionString method if possible, rather than
// rewriting the same code twice.
if(fromItem instanceof IGroup) {
- Group group = (Group) rm.getObject(((IGroup)fromItem).getMetadataID());
+ Group group = ((IGroup)fromItem).getMetadataObject();
String nameInSource = group.getNameInSource();
// if NameInSource is null set it to an empty
// string instead so we can safely call split on it
@@ -384,8 +382,8 @@
// GHH 20080326 - changed around the IElement handling here
// - the rest of this method is unchanged
if(e instanceof IElement) {
- MetadataID mdIDElement = ((IElement)e).getMetadataID();
- expressionName = rm.getObject(mdIDElement).getNameInSource();
+ Element mdIDElement = ((IElement)e).getMetadataObject();
+ expressionName = mdIDElement.getNameInSource();
if(expressionName == null || expressionName.equals("")) { //$NON-NLS-1$
expressionName = mdIDElement.getName();
}
@@ -597,10 +595,9 @@
// code from another custom connector.
public String getNameFromElement(Element e) throws ConnectorException {
String ldapAttributeName = null;
- MetadataID mdIDElement = e.getMetadataID();
- ldapAttributeName = rm.getObject(mdIDElement).getNameInSource();
+ ldapAttributeName = e.getNameInSource();
if (ldapAttributeName == null || ldapAttributeName.equals("")) { //$NON-NLS-1$
- ldapAttributeName = mdIDElement.getName();
+ ldapAttributeName = e.getName();
// If name in source is not set, then fall back to the column name.
}
return ldapAttributeName;
@@ -653,8 +650,7 @@
*/
private Element getElementFromSymbol(ISelectSymbol symbol) throws ConnectorException {
IElement expr = (IElement) symbol.getExpression();
- MetadataID elementID = expr.getMetadataID();
- return (Element) rm.getObject(elementID);
+ return expr.getMetadataObject();
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -24,18 +24,18 @@
import java.util.Properties;
import com.metamatrix.connector.api.Connection;
-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.basic.BasicConnector;
/**
* LDAPConnector. This is responsible for initializing
* a connection factory, and obtaining connections to LDAP.
*/
-public class LDAPConnector implements Connector {
+public class LDAPConnector extends BasicConnector {
private ConnectorEnvironment env;
private ConnectorLogger logger;
private Properties props;
@@ -59,7 +59,7 @@
/**
* (non-Javadoc)
- * @see com.metamatrix.connector.api.Connector#initialize(com.metamatrix.connector.api.ConnectorEnvironment)
+ * @see com.metamatrix.connector.basic.BasicConnector#initialize(com.metamatrix.connector.api.ConnectorEnvironment)
*/
@Override
public void start(ConnectorEnvironment env) throws ConnectorException {
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -50,7 +50,6 @@
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;
@@ -405,20 +404,13 @@
if (elementNameDirect == null) {
} else {
}
- MetadataID mdIDElement = e.getMetadataID();
- if (mdIDElement == null) {
- return ""; //$NON-NLS-1$
- }
- if (rm == null) {
- return ""; //$NON-NLS-1$
- }
- MetadataObject mdObject = rm.getObject(mdIDElement);
+ MetadataObject mdObject = e.getMetadataObject();
if (mdObject == null) {
return ""; //$NON-NLS-1$
}
ldapAttributeName = mdObject.getNameInSource();
if(ldapAttributeName == null || ldapAttributeName.equals("")) { //$NON-NLS-1$
- ldapAttributeName = mdIDElement.getName();
+ ldapAttributeName = mdObject.getName();
// If name in source is not set, then fall back to the column name.
}
return ldapAttributeName;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -40,7 +40,7 @@
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.dqp.internal.datamgr.metadata.MetadataFactory;
+import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
@@ -203,7 +203,7 @@
private LDAPSearchDetails helpGetSearchDetails(String queryString) throws ConnectorException {
ConnectorLogger logger = new SysLogger(false);
QueryMetadataInterface metadata = exampleLdap();
- RuntimeMetadata rm = new MetadataFactory(metadata).getRuntimeMetadata();
+ RuntimeMetadata rm = new RuntimeMetadataImpl(metadata);
Properties props = new Properties();
IQueryToLdapSearchParser searchParser = new IQueryToLdapSearchParser(logger,rm,props);
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnection.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,7 +22,10 @@
package com.metamatrix.connector.loopback;
-import com.metamatrix.connector.api.*;
+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.basic.BasicConnection;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-loopback/src/main/java/com/metamatrix/connector/loopback/LoopbackConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,11 +23,12 @@
package com.metamatrix.connector.loopback;
import com.metamatrix.connector.api.*;
+import com.metamatrix.connector.basic.BasicConnector;
/**
* Starting point for the Loopback connector.
*/
-public class LoopbackConnector implements Connector {
+public class LoopbackConnector extends BasicConnector {
private ConnectorEnvironment env;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-loopback/src/test/java/com/metamatrix/connector/loopback/TestLoopbackExecution.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -38,7 +38,6 @@
public TestLoopbackExecution(String name) {
super(name);
- System.setProperty("metamatrix.config.none", "true");
}
public Properties exampleProperties(int waitTime, int rowCount) {
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -34,19 +34,14 @@
import com.metamatrix.connector.api.CredentialMap;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
-import com.metamatrix.connector.identity.ConnectorIdentity;
-import com.metamatrix.connector.identity.ConnectorIdentityFactory;
-import com.metamatrix.connector.identity.SingleIdentityFactory;
-import com.metamatrix.connector.identity.UserIdentityFactory;
import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
@ConnectionPooling
-public class Connector implements com.metamatrix.connector.api.Connector, ConnectorIdentityFactory {
+public class Connector extends com.metamatrix.connector.basic.BasicConnector {
private ConnectorLogger logger;
private ConnectorEnvironment connectorEnv;
- private ConnectorIdentityFactory connectorIdentityFactory;
private ConnectorState state;
private boolean singleIdentity;
private String username;
@@ -102,20 +97,18 @@
//validate that both are empty or both have values
if(null == username && null == password) {
- } else if ((null == username || username.equals("")) && (null != password || !password.equals("")) ||
- ((null == password || password.equals("")) && (null != username || !username.equals("")))) {
+ } else if ((null == username || username.equals("")) && (null != password && !password.equals("")) ||
+ ((null == password || password.equals("")) && (null != username && !username.equals("")))) {
String msg = Messages.getString("SalesforceSourceConnectionFactory.Invalid.username.password.pair");
env.getLogger().logError(msg);
throw new ConnectorException(msg);
- } else if(null != username || !username.equals("")) {
+ } else if(null != username && !username.equals("")) {
singleIdentity = true;
this.password = password;
this.username = username;
- }
- if (singleIdentity) {
- this.connectorIdentityFactory = new SingleIdentityFactory();
} else {
- this.connectorIdentityFactory = new UserIdentityFactory();
+ this.setAdminConnectionsAllowed(false);
+ this.setUseCredentialMap(true);
}
String capabilitiesClass = env.getProperties().getProperty("ConnectorCapabilities", SalesforceCapabilities.class.getName());
@@ -167,12 +160,6 @@
public ConnectorState getState() {
return state;
}
-
- @Override
- public ConnectorIdentity createIdentity(ExecutionContext context)
- throws ConnectorException {
- return this.connectorIdentityFactory.createIdentity(context);
- }
@Override
public ConnectorCapabilities getCapabilities() {
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -51,8 +51,7 @@
List<MessageElement> elements = new ArrayList<MessageElement>();
for (ISetClause clause : update.getChanges().getClauses()) {
IElement element = clause.getSymbol();
- Element column = (Element) parent.getMetadata().getObject(
- element.getMetadataID());
+ Element column = element.getMetadataObject();
String val = ((ILiteral) clause.getValue())
.toString();
MessageElement messageElem = new MessageElement(new QName(
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -40,7 +40,6 @@
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;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.salesforce.Messages;
import com.metamatrix.connector.salesforce.Util;
@@ -158,13 +157,13 @@
}
private void generateMultiSelect(IFunction func, String funcName) throws ConnectorException {
- IExpression[] expressions = func.getParameters();
+ List<IExpression> expressions = func.getParameters();
validateFunction(expressions);
- IExpression columnExpression = expressions[0];
- Element column = (Element)metadata.getObject(((IElement)columnExpression).getMetadataID());
+ IExpression columnExpression = expressions.get(0);
+ Element column = ((IElement)columnExpression).getMetadataObject();
StringBuffer criterion = new StringBuffer();
criterion.append(column.getNameInSource()).append(SPACE).append(funcName);
- addFunctionParams((ILiteral)expressions[1], criterion);
+ addFunctionParams((ILiteral)expressions.get(1), criterion);
criteriaList.add(criterion.toString());
}
@@ -195,15 +194,14 @@
criteriaList.add(result.toString());
}
- private void validateFunction(IExpression[] expressions) throws ConnectorException {
- if(expressions.length != 2) {
+ private void validateFunction(List<IExpression> expressions) throws ConnectorException {
+ if(expressions.size() != 2) {
throw new ConnectorException(Messages.getString("CriteriaVisitor.invalid.arg.count"));
}
- IExpression columnExpression = expressions[0];
- if(!(expressions[0] instanceof IElement)) {
+ if(!(expressions.get(0) instanceof IElement)) {
throw new ConnectorException(Messages.getString("CriteriaVisitor.function.not.column.arg"));
}
- if(!(expressions[1] instanceof ILiteral)) {
+ if(!(expressions.get(1) instanceof ILiteral)) {
throw new ConnectorException(Messages.getString("CriteriaVisitor.function.not.literal.arg"));
}
}
@@ -233,7 +231,7 @@
parseFunction((IFunction)lExpr);
} else {
IElement left = (IElement) lExpr;
- Element column = (Element) metadata.getObject(left.getMetadataID());
+ Element column = left.getMetadataObject();
String columnName = column.getNameInSource();
StringBuffer queryString = new StringBuffer();
queryString.append(columnName).append(SPACE);
@@ -268,8 +266,7 @@
queryString.append(' ');
queryString.append("IN");
queryString.append('(');
- Element column = (Element) metadata.getObject(
- ((IElement)criteria.getLeftExpression()).getMetadataID());
+ Element column = ((IElement)criteria.getLeftExpression()).getMetadataObject();
boolean timeColumn = isTimeColumn(column);
boolean first = true;
Iterator iter = criteria.getRightExpressions().iterator();
@@ -299,8 +296,7 @@
String result;
if (expr instanceof IElement) {
IElement element = (IElement) expr;
- Element element2 = (Element) metadata.getObject(element
- .getMetadataID());
+ Element element2 = element.getMetadataObject();
result = element2.getNameInSource();
} else if (expr instanceof ILiteral) {
ILiteral literal = (ILiteral) expr;
@@ -314,8 +310,7 @@
}
protected void loadColumnMetadata(IGroup group) throws ConnectorException {
- MetadataID id = group.getMetadataID();
- table = (Group) metadata.getObject(id);
+ table = group.getMetadataObject();
String supportsQuery = (String) table.getProperties().get(
"Supports Query");
if (!Util.convertStringToBoolean(supportsQuery)) {
@@ -325,13 +320,10 @@
+ Messages
.getString("CriteriaVisitor.query.not.supported"));
}
- List<MetadataID> columnIds = table.getMetadataID().getChildIDs();
- Iterator<MetadataID> iter = columnIds.iterator();
- while (iter.hasNext()) {
- MetadataID columnID = (MetadataID) iter.next();
- Element element = (Element) metadata.getObject(columnID);
- String name = columnID.getParentID().getName() + '.'
- + columnID.getName();
+ List<Element> columnIds = table.getChildren();
+ for (Element element : columnIds) {
+ String name = table.getName() + '.'
+ + element.getName();
columnElementsByName.put(name, element);
}
}
@@ -340,9 +332,7 @@
throws ConnectorException {
boolean result = false;
if (expression instanceof IElement) {
- MetadataID elementID = (MetadataID) ((IElement) expression)
- .getMetadataID();
- Element element = (Element) metadata.getObject(elementID);
+ Element element = ((IElement) expression).getMetadataObject();
String nameInSource = element.getNameInSource();
if (nameInSource.equalsIgnoreCase("id")) {
result = true;
@@ -355,9 +345,7 @@
throws ConnectorException {
boolean result = false;
if (expression instanceof IElement) {
- MetadataID elementID = (MetadataID) ((IElement) expression)
- .getMetadataID();
- Element element = (Element) metadata.getObject(elementID);
+ Element element = ((IElement) expression).getMetadataObject();
String nativeType = element.getNativeType();
if (nativeType.equalsIgnoreCase("multipicklist") ||
nativeType.equalsIgnoreCase("restrictedmultiselectpicklist")) {
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/InsertVisitor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -59,7 +59,7 @@
for(int i = 0; i < columns.size(); i++) {
IElement element = columns.get(i);
- Element column = (Element)metadata.getObject(element.getMetadataID());
+ Element column = element.getMetadataObject();
Object value = values.get(i);
String val;
if(value instanceof ILiteral) {
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -35,7 +35,6 @@
import com.metamatrix.connector.language.ISelect;
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;
import com.metamatrix.connector.salesforce.Messages;
import com.metamatrix.connector.salesforce.Util;
@@ -80,9 +79,7 @@
// get the name in source
IExpression expression = symbol.getExpression();
if (expression instanceof IElement) {
- MetadataID elementID = (MetadataID) ((IElement) expression)
- .getMetadataID();
- Element element = (Element) metadata.getObject(elementID);
+ Element element = ((IElement) expression).getMetadataObject();
selectSymbolIndexToElement.put(index, element);
selectSymbolNameToIndex .put(element.getNameInSource(), index);
String nameInSource = element.getNameInSource();
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -35,17 +35,17 @@
import java.util.Properties;
import com.metamatrix.connector.api.Connection;
-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.basic.BasicConnector;
/**
* Implementation of text connector.
*/
-public class TextConnector implements Connector {
+public class TextConnector extends BasicConnector {
private ConnectorLogger logger;
private ConnectorEnvironment env;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -49,11 +49,9 @@
import com.metamatrix.connector.language.IFrom;
import com.metamatrix.connector.language.IGroup;
import com.metamatrix.connector.language.IQuery;
-import com.metamatrix.connector.language.ISelect;
import com.metamatrix.connector.language.ISelectSymbol;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.Group;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.core.util.StringUtil;
@@ -399,7 +397,7 @@
* attempt to create the request as we may need
* column names from the header row.
*/
- String groupName = group.getMetadataID().getFullName();
+ String groupName = group.getMetadataObject().getFullName();
Map metadataMap = metadataProps;
groupProps = (Properties) metadataMap.get(groupName.toUpperCase());
@@ -412,11 +410,11 @@
Object[] params = new Object[] { groupName, ex.getMessage() };
throw new ConnectorException(ex, TextPlugin.Util.getString("TextSynchExecution.Unable_get_Reader", params)); //$NON-NLS-1$
}
- List elementIDs = group.getMetadataID().getChildIDs();
- numModeledColumns = elementIDs.size();
- int[] colWidthArray = new int[elementIDs.size()];
+ List<Element> elements = group.getMetadataObject().getChildren();
+ numModeledColumns = elements.size();
+ int[] colWidthArray = new int[elements.size()];
for (int i = 0; i < colWidthArray.length; i++) {
- Element element = (Element)rm.getObject((MetadataID)elementIDs.get(i));
+ Element element = elements.get(i);
colWidthArray[getColumn(element)] = element.getLength();
}
for (int i = 0; i < colWidthArray.length; i++) {
@@ -462,12 +460,10 @@
IFrom from = ((IQuery) cmd).getFrom();
List groups = from.getItems();
IGroup symbol = (IGroup) groups.get(0);
- Group group = (Group) rm.getObject(symbol.getMetadataID());
+ Group group = symbol.getMetadataObject();
-
+ String groupName = group.getFullName();
- String groupName = group.getMetadataID().getFullName();
-
Map metadataMap = (Map) response;
Properties connProps = (Properties) metadataMap.get(TextPropertyNames.CONNECTOR_PROPERTIES);
@@ -607,8 +603,7 @@
*/
private Element getElementFromSymbol(ISelectSymbol symbol) throws ConnectorException {
IElement expr = (IElement) symbol.getExpression();
- MetadataID elementID = expr.getMetadataID();
- return (Element) rm.getObject(elementID);
+ return expr.getMetadataObject();
}
/**
@@ -636,16 +631,16 @@
} catch(NumberFormatException e) {
// Name In Source was not numeric, so look for a column with a heading matching Name In Source
if ( colStr == null ) {
- colStr = elem.getMetadataID().getName();
+ colStr = elem.getName();
}
if ( headerRow == null ) getCurrentReader();
if ( headerRow != null ) {
for ( int i = 0; i < headerRow.size(); i++ ) {
if ( colStr.compareToIgnoreCase((String)headerRow.get(i) )==0) return i;
}
- throw new ConnectorException(TextPlugin.Util.getString("TextSynchExecution.Column_not_found_in_header_row", new Object[] {colStr, elem.getMetadataID().getFullName() } )); //$NON-NLS-1$
+ throw new ConnectorException(TextPlugin.Util.getString("TextSynchExecution.Column_not_found_in_header_row", new Object[] {colStr, elem.getFullName() } )); //$NON-NLS-1$
}
- throw new ConnectorException(TextPlugin.Util.getString("TextSynchExecution.Invalid_column_number", new Object[] {colStr, elem.getMetadataID().getFullName() } ) ); //$NON-NLS-1$
+ throw new ConnectorException(TextPlugin.Util.getString("TextSynchExecution.Invalid_column_number", new Object[] {colStr, elem.getFullName() } ) ); //$NON-NLS-1$
}
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/CriteriaDesc.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -138,7 +138,7 @@
} else if (findIsRequired(element)) {
throw new ConnectorException(
Messages.getString("CriteriaDesc.value.not.found.for.param") //$NON-NLS-1$
- + element.getMetadataID().getName());
+ + element.getName());
}
}
@@ -369,7 +369,7 @@
//Thsi should be much more bulletproof and more easily supported
private static ArrayList parseCriteriaToValues(Element element, IQuery query) throws ConnectorException {
- String fullName = element.getMetadataID().getFullName().trim().toUpperCase();
+ String fullName = element.getFullName().trim().toUpperCase();
ArrayList parmPair = new ArrayList();
if (element.getSearchability() == Element.SEARCHABLE
|| element.getSearchability() == Element.SEARCHABLE_COMPARE) {
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/LoggingConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -25,6 +25,7 @@
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
+import com.metamatrix.connector.basic.BasicConnector;
import com.metamatrix.connector.xml.XMLConnectorState;
/**
@@ -33,7 +34,7 @@
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
-public abstract class LoggingConnector implements StatefulConnector {
+public abstract class LoggingConnector extends BasicConnector implements StatefulConnector {
private static ConnectorLogger m_logger;
private ConnectorEnvironment m_environment;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/ParameterDescriptor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -51,7 +51,7 @@
if(getElement().getNameInSource() != null) {
setColumnName(getElement().getNameInSource());
} else {
- setColumnName(getElement().getMetadataID().getName().trim());
+ setColumnName(getElement().getName().trim());
}
String nis = getElement().getNameInSource();
if (nis != null) {
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/QueryAnalyzer.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -41,7 +41,6 @@
import com.metamatrix.connector.language.ISelectSymbol;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.Group;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xml.IQueryPreprocessor;
@@ -122,8 +121,7 @@
List fromItems = from.getItems();
//better be only one
IGroup group = (IGroup) fromItems.get(0);
- MetadataID id = group.getMetadataID();
- m_table = (Group) m_metadata.getObject(id);
+ m_table = (Group) group.getMetadataObject();
m_info.setTableXPath(m_table.getNameInSource());
}
@@ -149,9 +147,7 @@
if (expr instanceof ILiteral) {
xpath = new OutputXPathDesc((ILiteral) expr);
} else if (expr instanceof IElement) {
- MetadataID elementID = (MetadataID) ((IElement) expr)
- .getMetadataID();
- Element element = (Element) m_metadata.getObject(elementID);
+ Element element = ((IElement)expr).getMetadataObject();
xpath = new OutputXPathDesc(element);
}
if (xpath != null) {
@@ -175,19 +171,13 @@
// containing names, element (metadata), and equivilence value, or all
// set values
- MetadataID groupID = m_table.getMetadataID();
- List elementList = groupID.getChildIDs();
-
ArrayList params = new ArrayList();
ArrayList crits = new ArrayList();
ArrayList responses = new ArrayList();
ArrayList locations = new ArrayList();
//Iterate through each field in the table
- Iterator elementListIterator = elementList.iterator();
- while (elementListIterator.hasNext()) {
- MetadataID elementID = (MetadataID) elementListIterator.next();
- Element element = (Element) m_metadata.getObject(elementID);
+ for (Element element : m_table.getChildren()) {
CriteriaDesc criteria = CriteriaDesc.getCriteriaDescForColumn(
element, m_query);
if (criteria != null) {
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/XMLSourceConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -29,13 +29,14 @@
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
+import com.metamatrix.connector.basic.BasicConnector;
/**
* XML Source connector, will give provide a XML document as source to
* Metamatrix engine.
*/
@ConnectionPooling
-public class XMLSourceConnector implements Connector {
+public class XMLSourceConnector extends BasicConnector {
private ConnectorEnvironment env;
private XMLConnectionFacory connFactory;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/file/FileExecution.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -76,7 +76,7 @@
public void execute() throws ConnectorException {
// look for the name of the file to return in the metadata, "Name in Source" property
- MetadataObject metaObject = this.metadata.getObject(procedure.getMetadataID());
+ MetadataObject metaObject = procedure.getMetadataObject();
String fileName = metaObject.getNameInSource();
// if the source procedure name is not supplied then throw an exception
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/main/java/com/metamatrix/connector/xmlsource/soap/SoapExecution.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -74,7 +74,7 @@
ArrayList argsList = new ArrayList();
// look for the name of the Service to return in the metadata, "Name in Source" property
- MetadataObject metaObject = this.metadata.getObject(procedure.getMetadataID());
+ MetadataObject metaObject = procedure.getMetadataObject();
String sourceProcedureName = metaObject.getNameInSource();
// if the source procedure name is not supplied then throw an exception
Deleted: 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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/MockCachingConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -1,95 +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.xml;
-
-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.xml.cache.IDocumentCache;
-import com.metamatrix.connector.xml.cache.MockDocumentCache;
-
-public class MockCachingConnector implements CachingConnector {
-
- IDocumentCache mockCache = new MockDocumentCache();
-
- public void createCacheObjectRecord(String requestID, String partID, String executionID, String sourceRequestID, String cacheKey) throws ConnectorException {
- // TODO Auto-generated method stub
- }
-
- public void deleteCacheItems(String requestIdentifier, String partIdentifier, String executionIdentifier) {
- // TODO Auto-generated method stub
- }
-
- public IDocumentCache getCache() {
- return mockCache;
- }
-
- public IDocumentCache getStatementCache() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public ConnectorEnvironment getEnvironment() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public ConnectorLogger getLogger() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public XMLConnectorState getState() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Connection getConnection(ExecutionContext arg0) throws ConnectorException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void stop() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public ConnectorCapabilities getCapabilities() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void start(ConnectorEnvironment environment)
- throws ConnectorException {
- // TODO Auto-generated method stub
-
- }
-
-
-}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestCriteriaDesc.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -43,7 +43,6 @@
import com.metamatrix.connector.language.LanguageUtil;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.Group;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
/**
@@ -77,85 +76,56 @@
System.setProperty("metamatrix.config.none", "true");
}
- public void testGetCriteriaDescForColumn() {
+ public void testGetCriteriaDescForColumn() throws Exception {
//case 1: values provided
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam in ('foo')";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
-
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam in ('foo')";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetCriteriaDescForColumnDefaultedValue() {
+ public void testGetCriteriaDescForColumnDefaultedValue() throws Exception {
//case 2: param, required, defaulted
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select RequiredDefaultedParam from CriteriaDescTable";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select RequiredDefaultedParam from CriteriaDescTable";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetCriteriaDescForColumnNoCriteria() {
+ public void testGetCriteriaDescForColumnNoCriteria() throws Exception {
//case 3: param, not required, not defaulted, not allowed empty
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select OptionalNotAllowedEmptyParam from CriteriaDescTable";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNull("CriteriaDesc is not null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select OptionalNotAllowedEmptyParam from CriteriaDescTable";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNull("CriteriaDesc is not null", desc);
}
- public void testGetCriteriaDescForColumnAllowEmpty() {
+ public void testGetCriteriaDescForColumnAllowEmpty() throws Exception {
//case 4: param, not required, not defaulted, allowed empty
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select OptionalAllowedEmptyParam from CriteriaDescTable";
- final int colLocation = 0;
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select OptionalAllowedEmptyParam from CriteriaDescTable";
+ final int colLocation = 0;
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
public void testGetCriteriaDescForColumnError() {
@@ -167,98 +137,66 @@
final int colLocation = 0;
ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
+ Element elem = ((IElement) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
fail("exception not thrown");
} catch (ConnectorException ce) {
- assertNotNull(ce);
}
}
- public void testGetCriteriaDescForColumnNotParam() {
+ public void testGetCriteriaDescForColumnNotParam() throws Exception {
//case 6: not a param
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select OutputColumn from CriteriaDescTable";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNull("CriteriaDesc is not null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select OutputColumn from CriteriaDescTable";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNull("CriteriaDesc is not null", desc);
}
- public void testGetCriteriaDescForColumnCompare() {
+ public void testGetCriteriaDescForColumnCompare() throws Exception {
//case 7: compare criteria
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam = 'foo'";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
-
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam = 'foo'";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetCriteriaDescForColumnMultiElement() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select MultiElementParam from CriteriaDescTable where MultiElementParam in ('foo','bar')";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- String multiplicityStr = elem.getProperties().getProperty(
- CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetCriteriaDescForColumnMultiElement() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select MultiElementParam from CriteriaDescTable where MultiElementParam in ('foo','bar')";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ String multiplicityStr = elem.getProperties().getProperty(
+ CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetCriteriaDescForColumnDelimited() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select DelimitedParam from CriteriaDescTable where DelimitedParam in ('foo','bar')";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- String multiplicityStr = elem.getProperties().getProperty(
- CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetCriteriaDescForColumnDelimited() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select DelimitedParam from CriteriaDescTable where DelimitedParam in ('foo','bar')";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ String multiplicityStr = elem.getProperties().getProperty(
+ CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
public void testGetCriteriaDescForColumnLikeSearchable() {
@@ -269,37 +207,26 @@
final int colLocation = 0;
ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
+ Element elem = ((IElement) expr).getMetadataObject();
String multiplicityStr = elem.getProperties().getProperty(
CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
fail("should not be able to handle default value");
} catch (ConnectorException ce) {
- assertTrue(true);
}
}
- public void testGetCriteriaDescForColumnUnlikeSearchable() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select UnlikeSearchableParam from CriteriaDescTable where UnlikeSearchableParam in ('foo')";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- String multiplicityStr = elem.getProperties().getProperty(
- CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("could not create CriteriaDesc", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetCriteriaDescForColumnUnlikeSearchable() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select UnlikeSearchableParam from CriteriaDescTable where UnlikeSearchableParam in ('foo')";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ String multiplicityStr = elem.getProperties().getProperty(
+ CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
}
public void testGetCriteriaDescForColumnUnsearchable() {
@@ -310,235 +237,151 @@
final int colLocation = 0;
ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
+ Element elem = ((IElement) expr).getMetadataObject();
String multiplicityStr = elem.getProperties().getProperty(
CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
fail("should not be able to handle default value");
} catch (ConnectorException ce) {
- assertTrue(true);
}
}
- public void testGetCriteriaDescForColumnLike() {
+ public void testGetCriteriaDescForColumnLike() throws Exception {
//case 1: values provided
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam like 'foo'";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
-
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam like 'foo'";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetCriteriaDescForColumnNotEquals() {
+ public void testGetCriteriaDescForColumnNotEquals() throws Exception {
//case 1: values provided
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam != 'foo'";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
-
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam != 'foo'";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetCriteriaDescForColumnLiteral() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select RequiredDefaultedParam from CriteriaDescTable where concat(RequiredDefaultedParam, 'bar') in('foo')";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
-
+ public void testGetCriteriaDescForColumnLiteral() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select RequiredDefaultedParam from CriteriaDescTable where concat(RequiredDefaultedParam, 'bar') in('foo')";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetCriteriaDescForColumnNameMatchFailure() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select RequiredDefaultedParam from CriteriaDescTable where AttributeParam in('foo')";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
-
+ public void testGetCriteriaDescForColumnNameMatchFailure() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select RequiredDefaultedParam from CriteriaDescTable where AttributeParam in('foo')";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetCriteriaDescForColumnLeftLiteral() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select RequiredDefaultedParam from CriteriaDescTable "
- + "where concat('bar', 'foo') = concat('bar', RequiredDefaultedParam)";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetCriteriaDescForColumnLeftLiteral() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select RequiredDefaultedParam from CriteriaDescTable "
+ + "where concat('bar', 'foo') = concat('bar', RequiredDefaultedParam)";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetCriteriaDescForColumnTwoElements() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select RequiredDefaultedParam from CriteriaDescTable where OutputColumn = RequiredDefaultedParam";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetCriteriaDescForColumnTwoElements() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select RequiredDefaultedParam from CriteriaDescTable where OutputColumn = RequiredDefaultedParam";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetCriteriaDescForColumnLeftElementEqualsLiteral() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select RequiredDefaultedParam from CriteriaDescTable where AttributeParam = 'foo'";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetCriteriaDescForColumnLeftElementEqualsLiteral() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select RequiredDefaultedParam from CriteriaDescTable where AttributeParam = 'foo'";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetCriteriaDescForColumnLeftElementEqualsNonLiteral() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select RequiredDefaultedParam from CriteriaDescTable where"
- + " RequiredDefaultedParam = concat('foo', OutputColumn)";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetCriteriaDescForColumnLeftElementEqualsNonLiteral() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select RequiredDefaultedParam from CriteriaDescTable where"
+ + " RequiredDefaultedParam = concat('foo', OutputColumn)";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertNotNull("CriteriaDesc is null", desc);
}
- public void testGetInputXPathNoXpath() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select BadNoInputXpath from CriteriaDescTable where BadNoInputXpath in ('foo')";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertEquals(desc.getColumnName(), desc.getInputXpath());
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetInputXPathNoXpath() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select BadNoInputXpath from CriteriaDescTable where BadNoInputXpath in ('foo')";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertEquals(desc.getColumnName(), desc.getInputXpath());
}
- public void testGetInputXPathEmptyXpath() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select BadEmptyInputXPath from CriteriaDescTable where BadEmptyInputXPath in ('foo')";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertEquals(desc.getColumnName(), desc.getInputXpath());
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetInputXPathEmptyXpath() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select BadEmptyInputXPath from CriteriaDescTable where BadEmptyInputXPath in ('foo')";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertEquals(desc.getColumnName(), desc.getInputXpath());
}
- public void testGetDataAttributeNameEmptyName() {
- try {
- assertNotNull("vdb path is null", vdbPath);
- String query = "select BadNoDataAttributeName from CriteriaDescTable where BadNoDataAttributeName in ('foo')";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertEquals("", desc.getDataAttributeName());
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetDataAttributeNameEmptyName() throws Exception {
+ assertNotNull("vdb path is null", vdbPath);
+ String query = "select BadNoDataAttributeName from CriteriaDescTable where BadNoDataAttributeName in ('foo')";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertEquals("", desc.getDataAttributeName());
}
@@ -697,98 +540,65 @@
}
}
- public void testGetCurrentIndexValueEnumerated() {
+ public void testGetCurrentIndexValueEnumerated() throws Exception {
String query = "select DelimitedParam from CriteriaDescTable where DelimitedParam in ('foo', 'bar')";
IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- try {
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertEquals("There should be two values" , 2, desc.getNumberOfValues());
- assertEquals("foo", desc.getCurrentIndexValue());
- desc.incrementIndex();
- assertEquals("bar", desc.getCurrentIndexValue());
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertEquals("There should be two values" , 2, desc.getNumberOfValues());
+ assertEquals("foo", desc.getCurrentIndexValue());
+ desc.incrementIndex();
+ assertEquals("bar", desc.getCurrentIndexValue());
}
- public void testIncrementIndexEnumerated() {
+ public void testIncrementIndexEnumerated() throws Exception {
String query = "select DelimitedParam from CriteriaDescTable where DelimitedParam in ('foo', 'bar')";
IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- try {
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertTrue("We should be able to increment this CriteriaDesc", desc.incrementIndex());
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
+ Element elem = ((IElement) expr).getMetadataObject();
+ CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
+ assertTrue("We should be able to increment this CriteriaDesc", desc.incrementIndex());
}
- public void testGetCurrentIndexValueNoValue() {
- try {
- final String query = "select OptionalAllowedEmptyParam from CriteriaDescTable";
- Element elem = getElement(query);
- ArrayList list = new ArrayList();
- CriteriaDesc desc = new CriteriaDesc(elem, list);
- assertEquals("", desc.getCurrentIndexValue());
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetCurrentIndexValueNoValue() throws Exception {
+ final String query = "select OptionalAllowedEmptyParam from CriteriaDescTable";
+ Element elem = getElement(query);
+ ArrayList list = new ArrayList();
+ CriteriaDesc desc = new CriteriaDesc(elem, list);
+ assertEquals("", desc.getCurrentIndexValue());
}
- public void testGetCurrentIndexValueNoValueNotEmpty() {
- try {
- final String query = "select OptionalNotAllowedEmptyParam from CriteriaDescTable";
- Element elem = getElement(query);
- ArrayList list = new ArrayList();
- CriteriaDesc desc = new CriteriaDesc(elem, list);
- assertNull(desc.getCurrentIndexValue());
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testGetCurrentIndexValueNoValueNotEmpty() throws Exception {
+ final String query = "select OptionalNotAllowedEmptyParam from CriteriaDescTable";
+ Element elem = getElement(query);
+ ArrayList list = new ArrayList();
+ CriteriaDesc desc = new CriteriaDesc(elem, list);
+ assertNull(desc.getCurrentIndexValue());
}
- public void testIncrementIndex() {
- try {
- final String value2 = "value2";
- String query = "select MultiCol from MultiTable where MultiCol in ('" + VALUE + "', '" + value2 + "')";
- Element elem = getElement(query);
- ArrayList list = new ArrayList();
- list.add(VALUE);
- list.add(value2);
- CriteriaDesc desc = new CriteriaDesc(elem, list);
- assertEquals(VALUE, desc.getCurrentIndexValue());
- assertTrue("index increment failed", desc.incrementIndex());
- assertEquals(value2, desc.getCurrentIndexValue());
- assertFalse("index went beyond number of values", desc.incrementIndex());
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testIncrementIndex() throws Exception {
+ final String value2 = "value2";
+ String query = "select MultiCol from MultiTable where MultiCol in ('" + VALUE + "', '" + value2 + "')";
+ Element elem = getElement(query);
+ ArrayList list = new ArrayList();
+ list.add(VALUE);
+ list.add(value2);
+ CriteriaDesc desc = new CriteriaDesc(elem, list);
+ assertEquals(VALUE, desc.getCurrentIndexValue());
+ assertTrue("index increment failed", desc.incrementIndex());
+ assertEquals(value2, desc.getCurrentIndexValue());
+ assertFalse("index went beyond number of values", desc.incrementIndex());
}
- public void testResetIndex() {
- try {
- CriteriaDesc desc = createCriteriaDesc(QUERY);
- desc.resetIndex();
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testResetIndex() throws Exception {
+ CriteriaDesc desc = createCriteriaDesc(QUERY);
+ desc.resetIndex();
}
public void testNameMatch() {
@@ -882,26 +692,11 @@
private Element getElement(String query, int colLocation)
throws ConnectorException {
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
IExpression expr = symbol.getExpression();
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
+ Element elem = ((IElement) expr).getMetadataObject();
return elem;
}
- private Group getTable(String query) throws ConnectorException {
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- ISelect select = iquery.getSelect();
- List elems = select.getSelectSymbols();
- IFrom from = iquery.getFrom();
- List fromItems = from.getItems();
- //better be only one
- IGroup group = (IGroup) fromItems.get(0);
- MetadataID id = group.getMetadataID();
- return (Group) metadata.getObject(id);
- }
-
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestOutputXPathDesc.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -37,8 +37,6 @@
import com.metamatrix.connector.language.ISelectSymbol;
import com.metamatrix.connector.language.LanguageUtil;
import com.metamatrix.connector.metadata.runtime.Element;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
-import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
/**
* created by JChoate on Jun 27, 2005
@@ -74,71 +72,50 @@
/*
* Class under test for void OutputXPathDesc(Element)
*/
- public void testOutputXPathDescElement() {
-
+ public void testOutputXPathDescElement() throws Exception {
IQuery query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
ISelect select = query.getSelect();
List symbols = select.getSelectSymbols();
ISelectSymbol selectSymbol = (ISelectSymbol) symbols.get(0);
IExpression expr = selectSymbol.getExpression();
- Element element = null;
- try {
- if (expr instanceof IElement) {
- MetadataID elementID = ((IElement) expr).getMetadataID();
- element = (Element) metadata.getObject(elementID);
- } else {
- fail("select symbols is not an element");
- }
- OutputXPathDesc desc = new OutputXPathDesc(element);
- assertNull(desc.getCurrentValue());
- assertNotNull(desc.getDataType());;
- } catch (ConnectorException ex) {
- ex.printStackTrace();
- fail(ex.getMessage());
- }
-
+ assertTrue(expr instanceof IElement);
+ Element element = ((IElement) expr).getMetadataObject();
+ OutputXPathDesc desc = new OutputXPathDesc(element);
+ assertNull(desc.getCurrentValue());
+ assertNotNull(desc.getDataType());;
}
- public void testOutputXPathDescParam() {
- try {
- String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam in ('foo')";
- IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
- IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- OutputXPathDesc desc = new OutputXPathDesc(elem);
- assertNotNull("OutputXPathDesc is null", desc);
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ public void testOutputXPathDescParam() throws Exception {
+ String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam in ('foo')";
+ IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ final int colLocation = 0;
+ ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
+ IExpression expr = symbol.getExpression();
+ assertTrue(expr instanceof IElement);
+ Element element = ((IElement) expr).getMetadataObject();
+ OutputXPathDesc desc = new OutputXPathDesc(element);
+ assertNotNull("OutputXPathDesc is null", desc);
}
- public void testOutputXPathDescNoXPath() {
+ public void testOutputXPathDescNoXPath() throws Exception {
try {
String query = "select OutputColumnNoXPath from CriteriaDescTable";
IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
IExpression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- MetadataID elementID = ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
- OutputXPathDesc desc = new OutputXPathDesc(elem);
+ assertTrue(expr instanceof IElement);
+ Element element = ((IElement) expr).getMetadataObject();
+ OutputXPathDesc desc = new OutputXPathDesc(element);
fail("should not be able to create OuputXPathDesc with no XPath");
} catch (ConnectorException ce) {
- assertNotNull(ce);
}
}
/*
* Class under test for void OutputXPathDesc(ILiteral)
*/
- public void testOutputXPathDescILiteral() {
+ public void testOutputXPathDescILiteral() throws Exception {
String strLiteral = "MetaMatrix";
String strQuery = "Select Company_id from Company where Company_id = '" + strLiteral + "'";
IQuery query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
@@ -146,18 +123,13 @@
List criteriaList = LanguageUtil.separateCriteriaByAnd(crits);
ICompareCriteria compCriteria = (ICompareCriteria) criteriaList.get(0);
ILiteral literal = (ILiteral) compCriteria.getRightExpression();
- try {
- OutputXPathDesc desc = new OutputXPathDesc(literal);
- assertNotNull(desc);
- assertEquals(strLiteral, desc.getCurrentValue().toString());
- assertEquals(strLiteral.getClass(), desc.getDataType());
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ OutputXPathDesc desc = new OutputXPathDesc(literal);
+ assertNotNull(desc);
+ assertEquals(strLiteral, desc.getCurrentValue().toString());
+ assertEquals(strLiteral.getClass(), desc.getDataType());
}
- public void testOutputXPathDescILiteralNullValue() {
+ public void testOutputXPathDescILiteralNullValue() throws Exception {
String strLiteral = "MetaMatrix";
String strQuery = "Select Company_id from Company where Company_id = '" + strLiteral + "'";
IQuery query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
@@ -166,64 +138,37 @@
ICompareCriteria compCriteria = (ICompareCriteria) criteriaList.get(0);
ILiteral literal = (ILiteral) compCriteria.getRightExpression();
literal.setValue(null);
- try {
- OutputXPathDesc desc = new OutputXPathDesc(literal);
- assertNotNull(desc);
- assertNull(desc.getCurrentValue());
- assertEquals(strLiteral.getClass(), desc.getDataType());
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ OutputXPathDesc desc = new OutputXPathDesc(literal);
+ assertNotNull(desc);
+ assertNull(desc.getCurrentValue());
+ assertEquals(strLiteral.getClass(), desc.getDataType());
}
- public void testSetAndGetCurrentValue() {
+ public void testSetAndGetCurrentValue() throws Exception {
IQuery query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
ISelect select = query.getSelect();
List symbols = select.getSelectSymbols();
ISelectSymbol selectSymbol = (ISelectSymbol) symbols.get(0);
IExpression expr = selectSymbol.getExpression();
- Element element = null;
- try {
- if (expr instanceof IElement) {
- MetadataID elementID = ((IElement) expr).getMetadataID();
- element = (Element) metadata.getObject(elementID);
- } else {
- fail("select symbols is not an element");
- }
- OutputXPathDesc desc = new OutputXPathDesc(element);
- String myVal = "myValue";
- desc.setCurrentValue(myVal);
- assertEquals(myVal, desc.getCurrentValue());
- } catch (ConnectorException ex) {
- ex.printStackTrace();
- fail(ex.getMessage());
- }
+ assertTrue(expr instanceof IElement);
+ Element element = ((IElement) expr).getMetadataObject();
+ OutputXPathDesc desc = new OutputXPathDesc(element);
+ String myVal = "myValue";
+ desc.setCurrentValue(myVal);
+ assertEquals(myVal, desc.getCurrentValue());
}
- public void testGetDataType() {
+ public void testGetDataType() throws Exception {
IQuery query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
ISelect select = query.getSelect();
List symbols = select.getSelectSymbols();
ISelectSymbol selectSymbol = (ISelectSymbol) symbols.get(0);
IExpression expr = selectSymbol.getExpression();
- Element element = null;
- try {
- if (expr instanceof IElement) {
- MetadataID elementID = ((IElement) expr).getMetadataID();
- element = (Element) metadata.getObject(elementID);
- } else {
- fail("select symbols is not an element");
- }
- OutputXPathDesc desc = new OutputXPathDesc(element);
- assertNotNull(desc.getDataType());
- assertEquals(String.class, desc.getDataType());
- } catch (ConnectorException ex) {
- ex.printStackTrace();
- fail(ex.getMessage());
- }
+ assertTrue(expr instanceof IElement);
+ Element element = ((IElement) expr).getMetadataObject();
+ OutputXPathDesc desc = new OutputXPathDesc(element);
+ assertNotNull(desc.getDataType());
+ assertEquals(String.class, desc.getDataType());
}
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestParameterDescriptor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -33,8 +33,6 @@
import com.metamatrix.connector.language.ISelect;
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;
/**
* created by JChoate on Jun 27, 2005
@@ -70,76 +68,43 @@
/*
* Class under test for void ParameterDescriptor(Element)
*/
- public void testParameterDescriptorElement() {
+ public void testParameterDescriptorElement() throws Exception {
IQuery query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
ISelect select = query.getSelect();
List symbols = select.getSelectSymbols();
ISelectSymbol selectSymbol = (ISelectSymbol) symbols.get(0);
IExpression expr = selectSymbol.getExpression();
- Element element = null;
- try {
- if (expr instanceof IElement) {
- MetadataID elementID = ((IElement) expr).getMetadataID();
- element = (Element) metadata.getObject(elementID);
- } else {
- fail("select symbols is not an element");
- }
- ParameterDescriptor desc = new ParameterDescriptorImpl(element);
- assertNotNull(desc);
- } catch (ConnectorException ex) {
- ex.printStackTrace();
- fail(ex.getMessage());
- }
+ assertTrue(expr instanceof IElement);
+ Element element = ((IElement) expr).getMetadataObject();
+ ParameterDescriptor desc = new ParameterDescriptorImpl(element);
+ assertNotNull(desc);
}
- public void testParameterDescriptorElementParameter() {
+ public void testParameterDescriptorElementParameter() throws Exception {
IQuery query = ProxyObjectFactory.getDefaultIQuery(vdbPath, "select RequiredDefaultedParam from CriteriaDescTable");
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
ISelect select = query.getSelect();
List symbols = select.getSelectSymbols();
ISelectSymbol selectSymbol = (ISelectSymbol) symbols.get(0);
IExpression expr = selectSymbol.getExpression();
- Element element = null;
- try {
- if (expr instanceof IElement) {
- MetadataID elementID = ((IElement) expr).getMetadataID();
- element = (Element) metadata.getObject(elementID);
- } else {
- fail("select symbols is not an element");
- }
- ParameterDescriptor desc = new ParameterDescriptorImpl(element);
- assertNotNull(desc);
- } catch (ConnectorException ex) {
- ex.printStackTrace();
- fail(ex.getMessage());
- }
+ assertTrue(expr instanceof IElement);
+ Element element = ((IElement) expr).getMetadataObject();
+ ParameterDescriptor desc = new ParameterDescriptorImpl(element);
+ assertNotNull(desc);
}
- public void testParameterDescriptorElementSpaceXPath() {
+ public void testParameterDescriptorElementSpaceXPath() throws Exception {
IQuery query = ProxyObjectFactory.getDefaultIQuery(vdbPath, "select OutputColumnSpaceXPath from CriteriaDescTable");
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
ISelect select = query.getSelect();
List symbols = select.getSelectSymbols();
ISelectSymbol selectSymbol = (ISelectSymbol) symbols.get(0);
IExpression expr = selectSymbol.getExpression();
- Element element = null;
- try {
- if (expr instanceof IElement) {
- MetadataID elementID = ((IElement) expr).getMetadataID();
- element = (Element) metadata.getObject(elementID);
- } else {
- fail("select symbols is not an element");
- }
- ParameterDescriptor desc = new ParameterDescriptorImpl(element);
- assertNotNull(desc);
- } catch (ConnectorException ex) {
- ex.printStackTrace();
- fail(ex.getMessage());
- }
+ assertTrue(expr instanceof IElement);
+ Element element = ((IElement) expr).getMetadataObject();
+ ParameterDescriptor desc = new ParameterDescriptorImpl(element);
+ assertNotNull(desc);
}
/*
@@ -153,116 +118,80 @@
assertNull(desc.getColumnName());
}
- public void testSetGetXPath() {
+ public void testSetGetXPath() throws Exception {
ParameterDescriptor desc = getParameterDescriptor();
String xpath = "/foo";
desc.setXPath(xpath);
assertEquals(xpath, desc.getXPath());
}
- public void testSetIsParameter() {
+ public void testSetIsParameter() throws Exception {
ParameterDescriptor desc = getParameterDescriptor();
boolean is = !desc.isParameter();
desc.setIsParameter(is);
assertEquals(is, desc.isParameter());
}
- public void testSetGetColumnName() {
+ public void testSetGetColumnName() throws Exception {
ParameterDescriptor desc = getParameterDescriptor();
String name = "myColumn";
desc.setColumnName(name);
assertEquals(name, desc.getColumnName());
}
- public void testSetGetColumnNumber() {
+ public void testSetGetColumnNumber() throws Exception {
ParameterDescriptor desc = getParameterDescriptor();
int number = desc.getColumnNumber() + 1;
desc.setColumnNumber(number);
assertEquals(number, desc.getColumnNumber());
}
- public void testGetElement() {
+ public void testGetElement() throws Exception {
IQuery query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
ISelect select = query.getSelect();
List symbols = select.getSelectSymbols();
ISelectSymbol selectSymbol = (ISelectSymbol) symbols.get(0);
IExpression expr = selectSymbol.getExpression();
- Element element = null;
- try {
- if (expr instanceof IElement) {
- MetadataID elementID = ((IElement) expr).getMetadataID();
- element = (Element) metadata.getObject(elementID);
- } else {
- fail("select symbols is not an element");
- }
- ParameterDescriptor desc = new ParameterDescriptorImpl(element);
- assertEquals(element, desc.getElement());
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ assertTrue(expr instanceof IElement);
+ Element element = ((IElement) expr).getMetadataObject();
+ ParameterDescriptor desc = new ParameterDescriptorImpl(element);
+ assertEquals(element, desc.getElement());
}
- public void testTestForParam() {
+ public void testTestForParam() throws Exception {
String trueQuery = "select EmptyCol from EmptyTable where EmptyCol = 'foo'";
String falseQuery = "select Company_id from Company";
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
IQuery query = ProxyObjectFactory.getDefaultIQuery(vdbPath, trueQuery);
ISelect select = query.getSelect();
List symbols = select.getSelectSymbols();
ISelectSymbol selectSymbol = (ISelectSymbol) symbols.get(0);
IExpression expr = selectSymbol.getExpression();
- Element element = null;
- try {
- MetadataID elementID = ((IElement) expr).getMetadataID();
- element = (Element) metadata.getObject(elementID);
- assertTrue(ParameterDescriptor.testForParam(element));
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ assertTrue(expr instanceof IElement);
+ Element element = ((IElement) expr).getMetadataObject();
+ assertTrue(ParameterDescriptor.testForParam(element));
query = ProxyObjectFactory.getDefaultIQuery(vdbPath, falseQuery);
select = query.getSelect();
symbols = select.getSelectSymbols();
selectSymbol = (ISelectSymbol) symbols.get(0);
expr = selectSymbol.getExpression();
- element = null;
- try {
- MetadataID elementID = ((IElement) expr).getMetadataID();
- element = (Element) metadata.getObject(elementID);
- assertFalse(ParameterDescriptor.testForParam(element));
- } catch (ConnectorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
+ assertTrue(expr instanceof IElement);
+ element = ((IElement) expr).getMetadataObject();
+ assertFalse(ParameterDescriptor.testForParam(element));
}
- private ParameterDescriptor getParameterDescriptor() {
+ private ParameterDescriptor getParameterDescriptor() throws Exception {
IQuery query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
ISelect select = query.getSelect();
List symbols = select.getSelectSymbols();
ISelectSymbol selectSymbol = (ISelectSymbol) symbols.get(0);
IExpression expr = selectSymbol.getExpression();
- Element element = null;
- try {
- if (expr instanceof IElement) {
- MetadataID elementID = ((IElement) expr).getMetadataID();
- element = (Element) metadata.getObject(elementID);
- } else {
- fail("select symbols is not an element");
- }
- ParameterDescriptor desc = new ParameterDescriptorImpl(element);
- assertNotNull(desc);
- return desc;
- } catch (ConnectorException ex) {
- ex.printStackTrace();
- fail(ex.getMessage());
- return null;
- }
+ assertTrue(expr instanceof IElement);
+ Element element = ((IElement) expr).getMetadataObject();
+ ParameterDescriptor desc = new ParameterDescriptorImpl(element);
+ assertNotNull(desc);
+ return desc;
}
private class ParameterDescriptorImpl extends ParameterDescriptor {
Deleted: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/cache/MockDocumentCache.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/cache/MockDocumentCache.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/cache/MockDocumentCache.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -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.xml.cache;
-
-public class MockDocumentCache implements IDocumentCache {
-
- public void addToCache(String cacheKey, Object obj, int size, String id) {
- // TODO Auto-generated method stub
-
- }
-
- public void clearCache() {
- // TODO Auto-generated method stub
-
- }
-
- public Object fetchObject(String id, String requestID) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void release(String cacheKey, String id) {
- // TODO Auto-generated method stub
-
- }
-
- public void shutdownCleaner() {
- // TODO Auto-generated method stub
-
- }
-
-}
Modified: trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/cache/TestRequestRecord.java
===================================================================
--- trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/cache/TestRequestRecord.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/cache/TestRequestRecord.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -24,24 +24,21 @@
import junit.framework.TestCase;
+import org.mockito.Mockito;
+
import com.metamatrix.cdk.api.SysLogger;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.xml.CachingConnector;
-import com.metamatrix.connector.xml.MockCachingConnector;
public class TestRequestRecord extends TestCase {
ConnectorLogger logger = new SysLogger(false);
- CachingConnector mockConnector = new MockCachingConnector();
+ CachingConnector mockConnector = Mockito.mock(CachingConnector.class);
- protected void setUp() throws Exception {
- super.setUp();
+ public TestRequestRecord() {
+ Mockito.stub(mockConnector.getCache()).toReturn(Mockito.mock(IDocumentCache.class));
}
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
+
public void testRequestRecord() {
RequestRecord testRecord;
try {
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/file/TestFileExecutor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -38,7 +38,6 @@
import com.metamatrix.connector.language.IQuery;
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;
import com.metamatrix.connector.xml.MockXMLExecution;
import com.metamatrix.connector.xml.base.ExecutionInfo;
@@ -300,8 +299,7 @@
IQuery iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
ISelectSymbol symbol = (ISelectSymbol) iquery.getSelect().getSelectSymbols().get(colLocation);
IExpression expr = symbol.getExpression();
- MetadataID elementID = (MetadataID) ((IElement) expr).getMetadataID();
- Element elem = (Element) metadata.getObject(elementID);
+ Element elem = ((IElement) expr).getMetadataObject();
return elem;
}
Deleted: 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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/FakeRuntimeMetadata.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -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.xmlsource;
-
-import java.util.Properties;
-
-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;
-
-public class FakeRuntimeMetadata implements RuntimeMetadata {
- String fileName;
-
- public FakeRuntimeMetadata(String fileName) {
- this.fileName = fileName;
- }
-
- public MetadataObject getObject(MetadataID id) throws ConnectorException {
- return new MetadataObject() {
- public MetadataID getMetadataID() {
- return null;
- }
- public String getNameInSource() throws ConnectorException {
- return fileName;
- }
- public Properties getProperties() throws ConnectorException {
- return null;
- }
- };
- }
- public byte[] getBinaryVDBResource(String resourcePath) throws ConnectorException {
- return null;
- }
- public String getCharacterVDBResource(String resourcePath) throws ConnectorException {
- return null;
- }
- public String[] getVDBResourcePaths() throws ConnectorException {
- return null;
- }
-}
\ No newline at end of file
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/file/TestFileExecution.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -30,6 +30,8 @@
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.ConnectorException;
@@ -37,8 +39,8 @@
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.Procedure;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.xmlsource.FakeRuntimeMetadata;
import com.metamatrix.core.util.UnitTestUtil;
@@ -55,10 +57,10 @@
try {
FileConnection conn = new FileConnection(env);
assertTrue(conn.isConnected());
- RuntimeMetadata metadata = new FakeRuntimeMetadata("BookCollection.xml"); //$NON-NLS-1$
+ RuntimeMetadata metadata = Mockito.mock(RuntimeMetadata.class);
ILanguageFactory fact = env.getLanguageFactory();
- IProcedure procedure = fact.createProcedure("GetXMLFile", null, null); //$NON-NLS-1$
+ IProcedure procedure = fact.createProcedure("GetXMLFile", null, createMockProcedureMetadata("BookCollection.xml")); //$NON-NLS-1$
FileExecution exec = (FileExecution)conn.createExecution(procedure, EnvironmentUtility.createExecutionContext("100", "100"), metadata); //$NON-NLS-1$ //$NON-NLS-2$
@@ -97,9 +99,9 @@
try {
FileConnection conn = new FileConnection(env);
assertTrue(conn.isConnected());
- RuntimeMetadata metadata = new FakeRuntimeMetadata("nofile.xml"); //$NON-NLS-1$
+ RuntimeMetadata metadata = Mockito.mock(RuntimeMetadata.class);
ILanguageFactory fact = env.getLanguageFactory();
- FileExecution exec = (FileExecution)conn.createExecution(fact.createProcedure("GetXMLFile", null, null), EnvironmentUtility.createExecutionContext("100", "100"), metadata); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ FileExecution exec = (FileExecution)conn.createExecution(fact.createProcedure("GetXMLFile", null, createMockProcedureMetadata("nofile.xml")), EnvironmentUtility.createExecutionContext("100", "100"), metadata); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
exec.execute();
@@ -120,4 +122,14 @@
reader.close();
return fileContents.toString();
}
+
+ public static Procedure createMockProcedureMetadata(String nameInSource) {
+ Procedure rm = Mockito.mock(Procedure.class);
+ try {
+ Mockito.stub(rm.getNameInSource()).toReturn(nameInSource);
+ } catch (ConnectorException e) {
+ throw new RuntimeException(e);
+ }
+ return rm;
+ }
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/connector-xml/src/test/java/com/metamatrix/connector/xmlsource/soap/TestSoapExecution.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -33,6 +33,8 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.mockito.Mockito;
+
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.api.SysLogger;
import com.metamatrix.connector.api.ConnectorEnvironment;
@@ -42,7 +44,7 @@
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.language.IParameter.Direction;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.xmlsource.FakeRuntimeMetadata;
+import com.metamatrix.connector.xmlsource.file.TestFileExecution;
import com.metamatrix.connector.xmlsource.soap.service.WebServiceServer;
import com.metamatrix.core.util.UnitTestUtil;
@@ -542,7 +544,7 @@
ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, new SysLogger(false));
SoapConnection conn = new SoapConnection(env);
- RuntimeMetadata metadata = new FakeRuntimeMetadata(procName);
+ RuntimeMetadata metadata = Mockito.mock(RuntimeMetadata.class);
ILanguageFactory fact = env.getLanguageFactory();
List parameters = new ArrayList();
if (args != null && args.length > 0) {
@@ -551,7 +553,7 @@
parameters.add(param);
}
}
- IProcedure procedure = fact.createProcedure("AnyNAME", parameters, null); //$NON-NLS-1$
+ IProcedure procedure = fact.createProcedure("AnyNAME", parameters, TestFileExecution.createMockProcedureMetadata(procName)); //$NON-NLS-1$
ProcedureExecution exec = (ProcedureExecution)conn.createExecution(procedure, EnvironmentUtility.createExecutionContext("100", "100"), metadata); //$NON-NLS-1$ //$NON-NLS-2$
exec.execute();
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,7 +23,6 @@
package com.metamatrix.connector.exec;
import java.util.List;
-import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -32,18 +32,18 @@
import com.metamatrix.common.extensionmodule.ExtensionModuleManager;
import com.metamatrix.common.extensionmodule.exception.ExtensionModuleNotFoundException;
import com.metamatrix.connector.api.Connection;
-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.basic.BasicConnector;
import com.metamatrix.core.util.ObjectConverterUtil;
/**
* Implementation of text connector.
*/
-public class ExecConnector implements Connector {
+public class ExecConnector extends BasicConnector {
private ConnectorLogger logger;
private ConnectorEnvironment env;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecVisitor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -82,11 +82,11 @@
if (whereValue != null) {
- whereClause.put(symbol.getMetadataID().getName(), whereValue);
+ whereClause.put(symbol.getMetadataObject().getName(), whereValue);
// System.out.println("SYMBOL: " + symbol.getMetadataID().getName() + " value: " + whereValue );//$NON-NLS-1$ //$NON-NLS-2$
} else {
- this.exception = new ConnectorException(ExecPlugin.Util.getString("SoapVisitor.No_where_value_found", symbol.getMetadataID().getName())); //$NON-NLS-1$
+ this.exception = new ConnectorException(ExecPlugin.Util.getString("SoapVisitor.No_where_value_found", symbol.getMetadataObject().getName())); //$NON-NLS-1$
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,20 +23,19 @@
package com.metamatrix.connector.object;
import com.metamatrix.connector.api.Connection;
-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.ConnectorIdentity;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.identity.ConnectorIdentity;
-import com.metamatrix.connector.identity.ConnectorIdentityFactory;
+import com.metamatrix.connector.basic.BasicConnector;
import com.metamatrix.connector.object.util.ObjectConnectorUtil;
/**
* Implmentation of the connector interface.
*/
-public class ObjectConnector implements Connector, ConnectorIdentityFactory {
+public class ObjectConnector extends BasicConnector {
private ConnectorLogger logger;
private ConnectorEnvironment env;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -3,9 +3,9 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.api.ConnectorIdentity;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.identity.ConnectorIdentity;
-import com.metamatrix.connector.identity.SingleIdentity;
+import com.metamatrix.connector.api.SingleIdentity;
public interface SourceConnectionFactory {
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/command/ObjectCommand.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -25,7 +25,7 @@
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;
+import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.object.extension.IObjectCommand;
import com.metamatrix.connector.object.util.ObjectConnectorUtil;
@@ -78,7 +78,7 @@
protected String determineName(IMetadataReference reference) throws ConnectorException {
String nis = getMetadataObjectNameInSource(reference);
if (nis == null || nis.length() == 0) {
- MetadataID id = reference.getMetadataID();
+ MetadataObject id = reference.getMetadataObject();
return id.getName();
}
return nis;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/command/ProcedureCommand.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -34,7 +34,6 @@
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;
import com.metamatrix.connector.object.ObjectPlugin;
import com.metamatrix.connector.object.util.ObjectConnectorUtil;
@@ -145,7 +144,7 @@
}
public static final String getMethodName(final RuntimeMetadata metadata, final IProcedure procedure) throws ConnectorException {
- String procName=procedure.getMetadataID().getName();
+ String procName=procedure.getMetadataObject().getName();
String procNameInSource = ObjectConnectorUtil.getMetadataObjectNameInSource(metadata, procedure, procedure);
@@ -157,7 +156,7 @@
protected void initParameters() throws ConnectorException {
- this.procName=this.procedure.getMetadataID().getName();
+ this.procName=this.procedure.getMetadataObject().getName();
this.procNameInSource = getMetadataObjectNameInSource(procedure);
@@ -187,20 +186,19 @@
* @since 4.2
*/
protected void initResultSet() throws ConnectorException {
- List columnMetadata = resultSetParameter.getMetadataID().getChildIDs();
+ List<Element> columnMetadata = resultSetParameter.getMetadataObject().getChildren();
int size = columnMetadata.size();
columnNames = new String[size];
columnNamesInSource = new String[size];
columnTypes = new Class[size];
for(int i =0; i<size; i++ ){
- MetadataID mID = (MetadataID)columnMetadata.get(i);
- Element element = (Element) this.getMetadata().getObject(mID);
+ Element element = (Element) columnMetadata.get(i);
if (element.getNameInSource() != null && element.getNameInSource().length() > 0) {
columnNamesInSource[i] = element.getNameInSource();
} else {
columnNamesInSource[i] = null;
}
- columnNames[i] = element.getMetadataID().getName();
+ columnNames[i] = element.getName();
columnTypes[i] = element.getJavaType();
hasResults=true;
@@ -212,7 +210,7 @@
columnTypes = new Class[1];
columnNamesInSource = new String[1];
- columnNames[0] = resultSetParameter.getMetadataID().getName();
+ columnNames[0] = resultSetParameter.getMetadataObject().getName();
columnTypes[0] = resultSetParameter.getType();
columnNamesInSource[0] = this.getMetadataObjectNameInSource(resultSetParameter);
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -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.ConnectorIdentity;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.identity.ConnectorIdentity;
-import com.metamatrix.connector.identity.SingleIdentity;
+import com.metamatrix.connector.api.SingleIdentity;
import com.metamatrix.connector.object.ObjectConnection;
import com.metamatrix.connector.object.SourceConnectionFactory;
import com.metamatrix.connector.object.extension.IObjectSource;
@@ -60,7 +60,7 @@
/**
- * @see com.metamatrix.data.pool.SourceConnectionFactory#createConnection(com.metamatrix.connector.identity.ConnectorIdentity)
+ * @see com.metamatrix.data.pool.SourceConnectionFactory#createConnection(com.metamatrix.connector.api.ConnectorIdentity)
* @since 4.3
*/
public final Connection createConnection(ConnectorIdentity id) throws 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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/util/ObjectConnectorUtil.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -29,7 +29,6 @@
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;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.object.ObjectPlugin;
@@ -51,8 +50,7 @@
if(reference == null) {
return null;
}
- MetadataID id = reference.getMetadataID();
- MetadataObject obj = metadata.getObject(id);
+ MetadataObject obj = reference.getMetadataObject();
if (obj != null) {
if (obj.getNameInSource() != null) {
return obj.getNameInSource();
Modified: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/FilterFunctionModifier.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/FilterFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/FilterFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -44,14 +44,14 @@
List objs = new ArrayList();
objs.add("SDO_FILTER"); //$NON-NLS-1$
objs.add("("); //$NON-NLS-1$
- IExpression[] params = function.getParameters();
- if (params.length == 3) {
- addParamWithConversion(objs, params[0]);
+ List<IExpression> params = function.getParameters();
+ if (params.size() == 3) {
+ addParamWithConversion(objs, params.get(0));
objs.add(", "); //comma between parms //$NON-NLS-1$
- addParamWithConversion(objs, params[1]);
+ addParamWithConversion(objs, params.get(1));
objs.add(", "); //$NON-NLS-1$
- objs.add(params[2]);
+ objs.add(params.get(2));
} else {
return super.translate(function);
}
Modified: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/NearestNeighborFunctionModifier.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/NearestNeighborFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/NearestNeighborFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -44,17 +44,17 @@
List objs = new ArrayList();
objs.add("SDO_NN"); // recast name from sdoNN to SDO_NN //$NON-NLS-1$
objs.add("("); //$NON-NLS-1$
- IExpression[] params = function.getParameters();
- if (params.length >= 3) {
- addParamWithConversion(objs, params[0]);
+ List<IExpression> params = function.getParameters();
+ if (params.size() >= 3) {
+ addParamWithConversion(objs, params.get(0));
objs.add(", "); //comma between parms //$NON-NLS-1$
- addParamWithConversion(objs, params[1]);
+ addParamWithConversion(objs, params.get(1));
objs.add(", "); //$NON-NLS-1$
- objs.add(params[2]);
- if (params.length == 4) {
+ objs.add(params.get(2));
+ if (params.size() == 4) {
objs.add(", "); //$NON-NLS-1$
- objs.add(params[3]);
+ objs.add(params.get(3));
}
} else {
return super.translate(function);
Modified: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/RelateFunctionModifier.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/RelateFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/RelateFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -47,16 +47,16 @@
List objs = new ArrayList();
objs.add("SDO_RELATE"); // recast name from sdoRelate to SDO_RELATE //$NON-NLS-1$
objs.add("("); //$NON-NLS-1$
- IExpression[] params = function.getParameters();
+ List<IExpression> params = function.getParameters();
//if it doesn't have 3 parms, it is not a version of SDO_RELATE which
// we are prepared to translate
- if (params.length == 3) {
- addParamWithConversion(objs, params[0]);
+ if (params.size() == 3) {
+ addParamWithConversion(objs, params.get(0));
objs.add(", "); //comma between parms //$NON-NLS-1$
- addParamWithConversion(objs, params[1]);
+ addParamWithConversion(objs, params.get(1));
objs.add(", "); //$NON-NLS-1$
- addParamWithConversion(objs, params[2]);
+ addParamWithConversion(objs, params.get(2));
} else {
return super.translate(function);
}
Modified: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/WithinDistanceFunctionModifier.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/WithinDistanceFunctionModifier.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/WithinDistanceFunctionModifier.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -44,16 +44,16 @@
List objs = new ArrayList();
objs.add("SDO_WITHIN_DISTANCE"); // recast name from sdoNN to SDO_NN //$NON-NLS-1$
objs.add("("); //$NON-NLS-1$
- IExpression[] params = function.getParameters();
+ List<IExpression> params = function.getParameters();
//if it doesn't have 3 parms, it is not a version of SDO_RELATE which
// we are prepared to translate
- if (params.length == 3) {
- addParamWithConversion(objs, params[0]);
+ if (params.size() == 3) {
+ addParamWithConversion(objs, params.get(0));
objs.add(", "); //comma between parms //$NON-NLS-1$
- addParamWithConversion(objs, params[1]);
+ addParamWithConversion(objs, params.get(1));
objs.add(", "); //$NON-NLS-1$
- objs.add(params[2]);
+ objs.add(params.get(2));
} else {
return super.translate(function);
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,8 +23,9 @@
package com.metamatrix.connector.yahoo;
import com.metamatrix.connector.api.*;
+import com.metamatrix.connector.basic.BasicConnector;
-public class YahooConnector implements Connector {
+public class YahooConnector extends BasicConnector {
private ConnectorEnvironment env;
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-24 14:33:28 UTC (rev 487)
+++ trunk/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -52,7 +52,6 @@
import com.metamatrix.connector.language.ISelect;
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;
/**
@@ -255,8 +254,7 @@
ISelectSymbol symbol = (ISelectSymbol) iter.next();
IExpression expr = symbol.getExpression();
if(expr instanceof IElement) {
- MetadataID id = ((IElement)expr).getMetadataID();
- Element element = (Element) metadata.getObject(id);
+ Element element = ((IElement)expr).getMetadataObject();
cols[i] = element.getPosition();
} else {
throw new ConnectorException(YahooPlugin.Util.getString("YahooExecution.Invalid_select_symbol", expr)); //$NON-NLS-1$
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorManager.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -89,7 +89,7 @@
import com.metamatrix.query.sql.lang.Command;
/**
- * The <code>ConnectorManager</code> manages a {@link com.metamatrix.connector.api.Connector Connector}
+ * The <code>ConnectorManager</code> manages a {@link com.metamatrix.connector.basic.BasicConnector Connector}
* and its associated workers' state.
*/
public class ConnectorManager implements ApplicationService {
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -48,7 +48,6 @@
import com.metamatrix.core.util.Assertion;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.internal.datamgr.language.LanguageBridgeFactory;
-import com.metamatrix.dqp.internal.datamgr.metadata.MetadataFactory;
import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.dqp.internal.process.AbstractWorkItem;
import com.metamatrix.dqp.internal.process.DQPWorkContext;
@@ -288,7 +287,7 @@
LanguageBridgeFactory factory = new LanguageBridgeFactory(queryMetadata);
this.translatedCommand = factory.translate(command);
- RuntimeMetadata rmd = new RuntimeMetadataImpl(new MetadataFactory(queryMetadata));
+ RuntimeMetadata rmd = new RuntimeMetadataImpl(queryMetadata);
// Create the execution based on mode
final Execution exec = connection.createExecution(this.translatedCommand, this.securityContext, rmd);
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWrapper.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -27,10 +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.ConnectorIdentity;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.identity.ConnectorIdentity;
-import com.metamatrix.connector.identity.ConnectorIdentityFactory;
-import com.metamatrix.connector.identity.SingleIdentity;
import com.metamatrix.connector.xa.api.TransactionContext;
import com.metamatrix.connector.xa.api.XAConnection;
import com.metamatrix.connector.xa.api.XAConnector;
@@ -38,7 +36,7 @@
/**
* ConnectorWrapper adds default behavior to the wrapped connector.
*/
-public class ConnectorWrapper implements XAConnector, ConnectorIdentityFactory {
+public class ConnectorWrapper implements XAConnector {
private Connector actualConnector;
@@ -113,10 +111,7 @@
@Override
public ConnectorIdentity createIdentity(ExecutionContext context)
throws ConnectorException {
- if (actualConnector instanceof ConnectorIdentityFactory) {
- return ((ConnectorIdentityFactory)actualConnector).createIdentity(context);
- }
- return new SingleIdentity();
+ return actualConnector.createIdentity(context);
}
public boolean supportsSingleIdentity() {
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -28,8 +28,8 @@
import java.util.List;
import com.metamatrix.common.buffer.impl.BufferConfig;
+import com.metamatrix.connector.api.ConnectorIdentity;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.identity.ConnectorIdentity;
import com.metamatrix.core.util.HashCodeUtil;
/**
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ProcedureBatchHandler.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -55,7 +55,7 @@
while(iter.hasNext()){
IParameter param = (IParameter)iter.next();
if (param.getDirection() == Direction.RESULT_SET) {
- resultSetCols = param.getMetadataID().getChildIDs().size();
+ resultSetCols = param.getMetadataObject().getChildren().size();
} else if(param.getDirection() == Direction.RETURN || param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){
paramCols += 1;
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ElementImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ElementImpl.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ElementImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -24,20 +24,20 @@
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.Element;
import com.metamatrix.connector.visitor.framework.LanguageObjectVisitor;
public class ElementImpl extends BaseLanguageObject implements IElement {
private IGroup group;
private String name;
- private MetadataID metadataID;
+ private Element metadataObject;
private Class type;
- public ElementImpl(IGroup group, String name, MetadataID metadataID, Class type) {
+ public ElementImpl(IGroup group, String name, Element metadataObject, Class type) {
this.group = group;
this.name = name;
- this.metadataID = metadataID;
+ this.metadataObject = metadataObject;
this.type = type;
}
@@ -55,17 +55,15 @@
return group;
}
- /**
- * @see com.metamatrix.connector.language.IMetadataReference#getMetadataID()
- */
- public MetadataID getMetadataID() {
- return metadataID;
+ @Override
+ public Element getMetadataObject() {
+ return this.metadataObject;
}
- public void setMetadataID(MetadataID id){
- this.metadataID = id;
- }
-
+ public void setMetadataObject(Element metadataObject) {
+ this.metadataObject = metadataObject;
+ }
+
/**
* @see com.metamatrix.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
*/
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/FunctionImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/FunctionImpl.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/FunctionImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,9 @@
package com.metamatrix.dqp.internal.datamgr.language;
+import java.util.ArrayList;
+import java.util.List;
+
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.visitor.framework.LanguageObjectVisitor;
@@ -29,12 +32,16 @@
public class FunctionImpl extends BaseLanguageObject implements IFunction {
private String name;
- private IExpression[] parameters;
+ private List<IExpression> parameters;
private Class type;
- public FunctionImpl(String name, IExpression[] params, Class type) {
+ public FunctionImpl(String name, List<? extends IExpression> params, Class type) {
this.name = name;
- this.parameters = params;
+ if (params == null) {
+ this.parameters = new ArrayList<IExpression>(0);
+ } else {
+ this.parameters = new ArrayList<IExpression>(params);
+ }
this.type = type;
}
@@ -48,7 +55,7 @@
/**
* @see com.metamatrix.connector.language.IFunction#getParameters()
*/
- public IExpression[] getParameters() {
+ public List<IExpression> getParameters() {
return parameters;
}
@@ -67,13 +74,6 @@
}
/*
- * @see com.metamatrix.data.language.IFunction#setParameters(com.metamatrix.data.language.IExpression[])
- */
- public void setParameters(IExpression[] parameters) {
- this.parameters = parameters;
- }
-
- /*
* @see com.metamatrix.data.language.IExpression#getType()
*/
public Class getType() {
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/GroupImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/GroupImpl.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/GroupImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,20 +23,21 @@
package com.metamatrix.dqp.internal.datamgr.language;
import com.metamatrix.connector.language.IGroup;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.metadata.runtime.Group;
import com.metamatrix.connector.visitor.framework.LanguageObjectVisitor;
import com.metamatrix.core.util.HashCodeUtil;
+import com.metamatrix.metadata.runtime.api.MetadataID;
public class GroupImpl extends BaseLanguageObject implements IGroup {
private String context;
private String definition;
- private MetadataID metadataID;
+ private Group metadataObject;
- public GroupImpl(String context, String definition, MetadataID id) {
+ public GroupImpl(String context, String definition, Group group) {
this.context = context;
this.definition = definition;
- this.metadataID = id;
+ this.metadataObject = group;
}
/**
@@ -53,16 +54,14 @@
return this.definition;
}
- /**
- * @see com.metamatrix.connector.language.IMetadataReference#getMetadataID()
- */
- public MetadataID getMetadataID() {
- return metadataID;
+ @Override
+ public Group getMetadataObject() {
+ return this.metadataObject;
}
-
- public void setMetadataID(MetadataID id){
- this.metadataID = id;
- }
+
+ public void setMetadataObject(Group metadataObject) {
+ this.metadataObject = metadataObject;
+ }
/**
* @see com.metamatrix.connector.language.ILanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -27,8 +27,8 @@
import java.util.List;
import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.common.log.LogManager;
+import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.language.IAggregate;
import com.metamatrix.connector.language.IBatchedUpdates;
import com.metamatrix.connector.language.ICommand;
@@ -69,11 +69,10 @@
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.connector.metadata.runtime.MetadataID.Type;
+import com.metamatrix.connector.metadata.runtime.Parameter;
+import com.metamatrix.connector.metadata.runtime.Procedure;
import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.internal.datamgr.metadata.MetadataFactory;
-import com.metamatrix.dqp.internal.datamgr.metadata.ProcedureIDImpl;
+import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -126,11 +125,11 @@
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
public class LanguageBridgeFactory {
- private MetadataFactory metadataFactory = null;
+ private RuntimeMetadataImpl metadataFactory = null;
public LanguageBridgeFactory(QueryMetadataInterface metadata) {
if (metadata != null) {
- metadataFactory = new MetadataFactory(metadata);
+ metadataFactory = new RuntimeMetadataImpl(metadata);
}
}
@@ -489,11 +488,10 @@
IFunction translate(Function function) throws MetaMatrixComponentException {
Expression [] args = function.getArgs();
- IExpression [] params = null;
+ List<IExpression> params = new ArrayList<IExpression>(args.length);
if (args != null) {
- params = new IExpression[args.length];
for (int i = 0; i < args.length; i++) {
- params[i] = translate(args[i]);
+ params.add(translate(args[i]));
}
}
return new FunctionImpl(function.getName(), params, function.getType());
@@ -542,19 +540,14 @@
ElementImpl element = null;
element = new ElementImpl(translate(symbol.getGroupSymbol()), symbol.getOutputName(), null, symbol.getType());
- if (element.getGroup().getMetadataID() == null) {
+ if (element.getGroup().getMetadataObject() == null) {
return element;
}
Object mid = symbol.getMetadataID();
if(! (mid instanceof TempMetadataID)) {
- try {
- 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);
- }
+ element.setMetadataObject(metadataFactory.getElement(mid));
}
return element;
}
@@ -627,26 +620,25 @@
/* Execute */
IProcedure translate(StoredProcedure sp) throws MetaMatrixComponentException {
- ProcedureIDImpl metadataID = null;
+ Procedure proc = null;
if(sp.getProcedureID() != null) {
try {
- metadataID = (ProcedureIDImpl) metadataFactory.createProcedureID(sp.getProcedureID());
- } catch(Exception e) {
- LogManager.logWarning(LogConstants.CTX_CONNECTOR, e, DQPPlugin.Util.getString("LanguageBridgeFactory.Unable_to_set_the_metadata_ID_for_element_{0}._10", sp.getProcedureName())); //$NON-NLS-1$
+ proc = this.metadataFactory.getProcedure(sp.getGroup().getName());
+ } catch(ConnectorException e) {
throw new MetaMatrixComponentException(e);
}
}
List parameters = sp.getParameters();
- List translatedParameters = new ArrayList();
+ List<IParameter> translatedParameters = new ArrayList<IParameter>();
for (Iterator i = parameters.iterator(); i.hasNext();) {
- translatedParameters.add(translate((SPParameter)i.next(), metadataID));
+ translatedParameters.add(translate((SPParameter)i.next(), proc));
}
- return new ProcedureImpl(sp.getProcedureName(), translatedParameters, metadataID);
+ return new ProcedureImpl(sp.getProcedureName(), translatedParameters, proc);
}
- IParameter translate(SPParameter param, ProcedureIDImpl procID) throws MetaMatrixComponentException {
+ IParameter translate(SPParameter param, Procedure parent) throws MetaMatrixComponentException {
Direction direction = Direction.IN;
switch(param.getParameterType()) {
case ParameterInfo.IN:
@@ -666,19 +658,8 @@
break;
}
- try {
- MetadataID metadataID = null;
- if(direction == Direction.RESULT_SET) {
- metadataID = metadataFactory.createResultSetID(procID, param.getMetadataID(), param.getResultSetIDs());
- return new ParameterImpl(param.getIndex(), direction, param.getValue(), param.getClassType(), metadataID);
-
- }
- metadataID = metadataFactory.createParameterID(procID, param.getMetadataID());
- return new ParameterImpl(param.getIndex(), direction, param.getValue(), param.getClassType(), metadataID);
- } catch(QueryMetadataException e) {
- throw new MetaMatrixComponentException(e);
- }
-
+ Parameter metadataParam = metadataFactory.getParameter(param, parent);
+ return new ParameterImpl(param.getIndex(), direction, param.getValue(), param.getClassType(), metadataParam);
}
IGroup translate(GroupSymbol symbol) throws MetaMatrixComponentException {
@@ -687,7 +668,7 @@
return group;
}
try {
- group.setMetadataID(metadataFactory.createMetadataID(symbol.getMetadataID(), Type.TYPE_GROUP));
+ group.setMetadataObject(metadataFactory.getGroup(symbol.getMetadataID()));
} 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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/LanguageFactoryImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,10 +22,53 @@
package com.metamatrix.dqp.internal.datamgr.language;
+import java.util.Arrays;
import java.util.List;
-import com.metamatrix.connector.language.*;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.language.IAggregate;
+import com.metamatrix.connector.language.IBulkInsert;
+import com.metamatrix.connector.language.ICompareCriteria;
+import com.metamatrix.connector.language.ICompoundCriteria;
+import com.metamatrix.connector.language.ICriteria;
+import com.metamatrix.connector.language.IDelete;
+import com.metamatrix.connector.language.IElement;
+import com.metamatrix.connector.language.IExistsCriteria;
+import com.metamatrix.connector.language.IExpression;
+import com.metamatrix.connector.language.IFrom;
+import com.metamatrix.connector.language.IFromItem;
+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.ILanguageFactory;
+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.IQueryCommand;
+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;
+import com.metamatrix.connector.metadata.runtime.Element;
+import com.metamatrix.connector.metadata.runtime.Group;
+import com.metamatrix.connector.metadata.runtime.Parameter;
+import com.metamatrix.connector.metadata.runtime.Procedure;
/**
*/
@@ -72,7 +115,7 @@
/*
* @see com.metamatrix.data.language.ILanguageFactory#createElement(java.lang.String, com.metamatrix.data.language.IGroup, com.metamatrix.data.metadata.runtime.MetadataID)
*/
- public IElement createElement(String name, IGroup group, MetadataID metadataReference, Class type) {
+ public IElement createElement(String name, IGroup group, Element metadataReference, Class type) {
return new ElementImpl(group, name, metadataReference, type);
}
@@ -89,18 +132,24 @@
public IFrom createFrom(List items) {
return new FromImpl(items);
}
+
+ @Override
+ public IFunction createFunction(String functionName, IExpression[] args,
+ Class type) {
+ return new FunctionImpl(functionName, Arrays.asList(args), type);
+ }
/*
* @see com.metamatrix.data.language.ILanguageFactory#createFunction(java.lang.String, com.metamatrix.data.language.IExpression[], java.lang.Class)
*/
- public IFunction createFunction(String functionName, IExpression[] args, Class type) {
+ public IFunction createFunction(String functionName, List<? extends IExpression> args, Class type) {
return new FunctionImpl(functionName, args, type);
}
/*
* @see com.metamatrix.data.language.ILanguageFactory#createGroup(java.lang.String, java.lang.String, com.metamatrix.data.metadata.runtime.MetadataID)
*/
- public IGroup createGroup(String context, String definition, MetadataID metadataReference) {
+ public IGroup createGroup(String context, String definition, Group metadataReference) {
return new GroupImpl(context, definition, metadataReference);
}
@@ -188,14 +237,14 @@
/*
* @see com.metamatrix.data.language.ILanguageFactory#createParameter(int, int, java.lang.Object, java.lang.Class)
*/
- public IParameter createParameter(int index, IParameter.Direction direction, Object value, Class type, MetadataID metadataReference) {
+ public IParameter createParameter(int index, IParameter.Direction direction, Object value, Class type, Parameter metadataReference) {
return new ParameterImpl(index, direction, value, type, metadataReference);
}
/*
* @see com.metamatrix.data.language.ILanguageFactory#createProcedure(java.lang.String, java.util.List, com.metamatrix.data.metadata.runtime.MetadataID)
*/
- public IProcedure createProcedure(String name, List parameters, MetadataID metadataReference) {
+ public IProcedure createProcedure(String name, List parameters, Procedure metadataReference) {
return new ProcedureImpl(name, parameters, metadataReference);
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ParameterImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -23,7 +23,7 @@
package com.metamatrix.dqp.internal.datamgr.language;
import com.metamatrix.connector.language.IParameter;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.metadata.runtime.Parameter;
import com.metamatrix.connector.visitor.framework.LanguageObjectVisitor;
public class ParameterImpl extends BaseLanguageObject implements IParameter {
@@ -33,14 +33,14 @@
private Object value;
private boolean valueSpecified;
private Class type;
- private MetadataID metadataID;
+ private Parameter metadataObject;
- public ParameterImpl(int index, Direction direction, Object value, Class type, MetadataID metadataID) {
+ public ParameterImpl(int index, Direction direction, Object value, Class type, Parameter metadataObject) {
setIndex(index);
setDirection(direction);
setValue(value);
setType(type);
- setMetadataID(metadataID);
+ this.metadataObject = metadataObject;
}
/**
@@ -109,16 +109,14 @@
}
}
- public MetadataID getMetadataID() {
- return this.metadataID;
+ @Override
+ public Parameter getMetadataObject() {
+ return this.metadataObject;
}
- /*
- * @see com.metamatrix.data.language.IMetadataReference#setMetadataID(com.metamatrix.data.metadata.runtime.MetadataID)
- */
- public void setMetadataID(MetadataID metadataID) {
- this.metadataID = metadataID;
- }
+ public void setMetadataObject(Parameter metadataObject) {
+ this.metadataObject = metadataObject;
+ }
/**
* @see com.metamatrix.connector.language.IParameter#getValueSpecified()
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ProcedureImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ProcedureImpl.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/language/ProcedureImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -24,20 +24,21 @@
import java.util.List;
+import com.metamatrix.connector.language.IParameter;
import com.metamatrix.connector.language.IProcedure;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
+import com.metamatrix.connector.metadata.runtime.Procedure;
import com.metamatrix.connector.visitor.framework.LanguageObjectVisitor;
public class ProcedureImpl extends BaseLanguageObject implements IProcedure {
private String name;
- private List parameters;
- private MetadataID metadataID;
+ private List<IParameter> parameters;
+ private Procedure metadataObject;
- public ProcedureImpl(String name, List parameters, MetadataID metadataID) {
+ public ProcedureImpl(String name, List<IParameter> parameters, Procedure metadataObject) {
this.name = name;
this.parameters = parameters;
- this.metadataID = metadataID;
+ this.metadataObject = metadataObject;
}
/**
@@ -50,7 +51,7 @@
/**
* @see com.metamatrix.data.language.IExecute#getVariableValues()
*/
- public List getParameters() {
+ public List<IParameter> getParameters() {
return parameters;
}
@@ -71,22 +72,17 @@
/*
* @see com.metamatrix.data.language.IExecute#setParameters(java.util.List)
*/
- public void setParameters(List parameters) {
+ public void setParameters(List<IParameter> parameters) {
this.parameters = parameters;
}
- /*
- * @see com.metamatrix.data.language.IMetadataReference#getMetadataID()
- */
- public MetadataID getMetadataID() {
- return this.metadataID;
+ @Override
+ public Procedure getMetadataObject() {
+ return this.metadataObject;
}
- /*
- * @see com.metamatrix.data.language.IMetadataReference#setMetadataID(com.metamatrix.data.metadata.runtime.MetadataID)
- */
- public void setMetadataID(MetadataID metadataID) {
- this.metadataID = metadataID;
+ public void setMetadataObject(Procedure metadataID) {
+ this.metadataObject = metadataID;
}
public boolean equals(Object obj) {
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ElementImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -29,14 +29,15 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.Element;
+import com.metamatrix.connector.metadata.runtime.Group;
import com.metamatrix.query.metadata.SupportConstants;
/**
*/
public class ElementImpl extends TypeModelImpl implements Element {
- ElementImpl(MetadataIDImpl metadataID){
- super(metadataID);
+ ElementImpl(Object actualID, RuntimeMetadataImpl factory){
+ super(actualID, factory);
}
public Class getJavaType() throws ConnectorException {
@@ -140,5 +141,18 @@
} catch(MetaMatrixComponentException e) {
throw new ConnectorException(e);
}
+ }
+
+ @Override
+ public Group getParent() throws ConnectorException {
+ Object groupId;
+ try {
+ groupId = this.getMetadata().getGroupIDForElementID(getActualID());
+ } catch (QueryMetadataException e) {
+ throw new ConnectorException(e);
+ } catch (MetaMatrixComponentException e) {
+ throw new ConnectorException(e);
+ }
+ return new GroupImpl(groupId, getFactory());
}
}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/GroupImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/GroupImpl.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/GroupImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -24,12 +24,36 @@
*/
package com.metamatrix.dqp.internal.datamgr.metadata;
+import java.util.ArrayList;
+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.Element;
import com.metamatrix.connector.metadata.runtime.Group;
/**
*/
public class GroupImpl extends MetadataObjectImpl implements Group {
- GroupImpl(MetadataIDImpl metadataID){
- super(metadataID);
+
+ GroupImpl(Object actualID, RuntimeMetadataImpl factory){
+ super(actualID, factory);
}
+
+ @Override
+ public List<Element> getChildren() throws ConnectorException {
+ try {
+ List elementIds = getMetadata().getElementIDsInGroupID(getActualID());
+ List<Element> result = new ArrayList<Element>(elementIds.size());
+ for (Object elementId : elementIds) {
+ result.add(new ElementImpl(elementId, getFactory()));
+ }
+ return result;
+ } catch (QueryMetadataException e) {
+ throw new ConnectorException(e);
+ } catch (MetaMatrixComponentException e) {
+ throw new ConnectorException(e);
+ }
+ }
}
Deleted: 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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataFactory.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -1,149 +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.metadata;
-
-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.*;
-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;
-
-/**
- */
-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 RuntimeMetadataImpl getRuntimeMetadata(){
- return this.runtimeMetadata;
- }
-
- /**
- * Method for creating group and element MetadataIDs. It will not return an id for virtual groups.
- * @param metadataID Object from QueryMetadataInterface representing group or element identifier
- * @param type Either TYPE_ELEMENT or TYPE_GROUP
- * @return MetadataID
- * @throws QueryMetadataException
- * @throws MetaMatrixComponentException
- */
- 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, getRuntimeMetadata());
- id.setType(type);
- return id;
- }
-
- /**
- * Method for creating procedure MetadataIDs.
- * @param procedureID Procedure ID
- * @return Parameter ID
- * @throws QueryMetadataException
- * @throws MetaMatrixComponentException
- */
- 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);
- id.setType(Type.TYPE_PROCEDURE);
- return id;
- }
-
- /**
- * Special factory method for creating parameter MetadataIDs based on a procedure MetadataID.
- * @param procedureID Procedure ID
- * @return Parameter ID
- * @throws QueryMetadataException
- * @throws MetaMatrixComponentException
- */
- public MetadataID createParameterID(ProcedureIDImpl procedureID, Object metadataID) throws QueryMetadataException, MetaMatrixComponentException{
- ParameterIDImpl id = new ParameterIDImpl(metadataID, procedureID, getRuntimeMetadata());
- id.setType(Type.TYPE_PARAMETER);
- return id;
- }
-
- /**
- * Special factory method for creating result set MetadataIDs based on a procedure MetadataID.
- * @param procedureID Procedure ID
- * @return Parameter ID
- * @throws QueryMetadataException
- * @throws MetaMatrixComponentException
- */
- public MetadataID createResultSetID(ProcedureIDImpl procedureID, Object metadataID, List resultSetColumns) throws QueryMetadataException, MetaMatrixComponentException{
- ParameterIDImpl id = new ParameterIDImpl(metadataID, procedureID, getRuntimeMetadata(), resultSetColumns);
- id.setType(Type.TYPE_PARAMETER);
- return id;
- }
-
- public MetadataObject createMetadataObject(MetadataID id) throws QueryMetadataException, MetaMatrixComponentException, ConnectorException {
- Type type = id.getType();
- MetadataIDImpl idImpl = (MetadataIDImpl) id;
- MetadataObject mObj = null;
- if(type == Type.TYPE_GROUP){
- mObj = new GroupImpl(idImpl);
-
- } else if(type == Type.TYPE_ELEMENT){
- mObj = new ElementImpl(idImpl);
-
- } else if(type == Type.TYPE_PROCEDURE){
- mObj = new ProcedureImpl(idImpl);
-
- } else if(type == Type.TYPE_PARAMETER) {
- mObj = new ParameterImpl(idImpl);
-
- } else{
- //throw exception
- }
- return mObj;
- }
-
- public byte[] getBinaryVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
- return metadata.getBinaryVDBResource(resourcePath);
- }
-
- public String getCharacterVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
- return metadata.getCharacterVDBResource(resourcePath);
- }
-
- public String[] getVDBResourcePaths() throws MetaMatrixComponentException, QueryMetadataException {
- return metadata.getVDBResourcePaths();
- }
-
- public QueryMetadataInterface getMetadata() {
- return metadata;
- }
-}
Deleted: 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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataIDImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -1,155 +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.metadata;
-
-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.connector.metadata.runtime.MetadataObject;
-
-/**
- */
-public class MetadataIDImpl implements MetadataID {
- private Type type;
- private Object actualMetadataID;
- private String fullName;
- private RuntimeMetadataImpl metadata;
-
- MetadataIDImpl(Object actualMetadataID, RuntimeMetadataImpl metadata) throws MetaMatrixComponentException {
- this.actualMetadataID = actualMetadataID;
- this.metadata = metadata;
-
- if (actualMetadataID != null) {
- try {
- fullName = metadata.getMetadata().getFullName(actualMetadataID);
- } catch (QueryMetadataException ex) {
- throw new MetaMatrixComponentException(ex, ex.getMessage());
- }
- }
- }
-
- RuntimeMetadataImpl getMetadata() {
- return this.metadata;
- }
-
- public Type getType() {
- return type;
- }
-
- public List getChildIDs() throws ConnectorException {
- if(type == Type.TYPE_GROUP && actualMetadataID != null){
- try {
- 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(Type.TYPE_ELEMENT);
- childIDs.add(id);
- }
- return childIDs;
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
- return Collections.EMPTY_LIST;
- }
-
- public MetadataID getParentID() throws ConnectorException {
- if(type == Type.TYPE_ELEMENT && actualMetadataID != null) {
- try {
- MetadataIDImpl id = new MetadataIDImpl(metadata.getMetadata().getGroupIDForElementID(actualMetadataID), metadata);
- id.setType(Type.TYPE_GROUP);
- return id;
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
-
- }
- return null;
- }
-
- public boolean equals(Object obj){
- if (this == obj) {
- return true;
- }
-
- if (this.getClass().isInstance(obj)) {
- MetadataIDImpl that = (MetadataIDImpl)obj;
- return this.actualMetadataID.equals(that.actualMetadataID);
- }
-
- return false;
- }
-
- public int hashCode(){
- return actualMetadataID.hashCode();
- }
-
- void setType(Type type){
- this.type = type;
- }
-
- Object getActualMetadataID(){
- return this.actualMetadataID;
- }
-
- public String getFullName() {
- return this.fullName;
- }
-
- /**
- * Get shortName from the metadataID.
- * @return string of shortName
- */
- public String getName() {
- String shortName = null;
- String fullName = getFullName();
- if (fullName != null && fullName.trim().length() != 0) {
- int index = fullName.lastIndexOf("."); //$NON-NLS-1$
- if(index != -1){
- shortName = fullName.substring(index + 1);
- }else{
- shortName = fullName;
- }
- }
- 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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/MetadataObjectImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -29,30 +29,40 @@
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.connector.metadata.runtime.MetadataObject;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.query.metadata.QueryMetadataInterface;
/**
*/
public abstract class MetadataObjectImpl implements MetadataObject {
- private MetadataIDImpl metadataID;
+ private Object actualID;
+ private RuntimeMetadataImpl factory;
+ private String fullName;
- MetadataObjectImpl(MetadataIDImpl metadataID){
- this.metadataID = metadataID;
+ MetadataObjectImpl(Object actualID, RuntimeMetadataImpl factory){
+ this.actualID = actualID;
+ this.factory = factory;
+ try {
+ this.fullName = getMetadata().getFullName(actualID);
+ } catch (QueryMetadataException e) {
+ throw new MetaMatrixRuntimeException(e);
+ } catch (MetaMatrixComponentException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
}
- public MetadataID getMetadataID() {
- return metadataID;
- }
-
Object getActualID() {
- return metadataID.getActualMetadataID();
+ return actualID;
}
QueryMetadataInterface getMetadata() {
- return metadataID.getMetadata().getMetadata();
+ return factory.getMetadata();
}
+
+ RuntimeMetadataImpl getFactory() {
+ return factory;
+ }
public String getNameInSource() throws ConnectorException {
try {
@@ -81,14 +91,25 @@
if (this.getClass().isInstance(obj)) {
MetadataObjectImpl that = (MetadataObjectImpl)obj;
- return this.metadataID.equals(that.metadataID);
+ return this.actualID.equals(that.actualID);
}
return false;
}
public int hashCode(){
- return metadataID.hashCode();
+ return actualID.hashCode();
}
+
+ @Override
+ public String getName() {
+ int index = fullName.lastIndexOf("."); //$NON-NLS-1$
+ return fullName.substring(index + 1);
+ }
+
+ @Override
+ public String getFullName() {
+ return fullName;
+ }
}
Deleted: 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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterIDImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -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.dqp.internal.datamgr.metadata;
-
-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;
-
-/**
- */
-public class ParameterIDImpl extends MetadataIDImpl {
-
- private ProcedureIDImpl procID;
- private List resultSetColumns;
-
- public ParameterIDImpl(Object actualMetadataID, ProcedureIDImpl procedureID, RuntimeMetadataImpl metadata)
- throws MetaMatrixComponentException {
- super(actualMetadataID, metadata);
-
- this.procID = procedureID;
- }
-
- public ParameterIDImpl(Object actualMetadataID, ProcedureIDImpl procedureID, RuntimeMetadataImpl metadata, List resultSetColumns)
- throws MetaMatrixComponentException {
- super(actualMetadataID, metadata);
-
- this.procID = procedureID;
- this.resultSetColumns = resultSetColumns;
- }
-
- public MetadataID getParentID() {
- return procID;
- }
-
- public boolean isResultSet() {
- return (this.resultSetColumns != null);
- }
-
- public List getChildIDs() throws ConnectorException {
- if(resultSetColumns != null && resultSetColumns.size() > 0) {
- try {
- List childIDs = new ArrayList(resultSetColumns.size());
- Iterator iter = resultSetColumns.iterator();
- while(iter.hasNext()){
- Object colID = iter.next();
- MetadataIDImpl id = new MetadataIDImpl(colID, getMetadata());
- id.setType(Type.TYPE_ELEMENT);
- childIDs.add(id);
- }
- return childIDs;
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
- return Collections.EMPTY_LIST;
- }
-}
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ParameterImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,8 @@
package com.metamatrix.dqp.internal.datamgr.metadata;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -29,9 +31,9 @@
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.Element;
import com.metamatrix.connector.metadata.runtime.Parameter;
+import com.metamatrix.connector.metadata.runtime.Procedure;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.message.ParameterInfo;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
import com.metamatrix.query.metadata.SupportConstants;
import com.metamatrix.query.sql.lang.SPParameter;
@@ -40,27 +42,18 @@
public class ParameterImpl extends TypeModelImpl implements Parameter {
private SPParameter param;
+ private Procedure parent;
/**
* @param metadataID
*/
- ParameterImpl(MetadataIDImpl metadataID) {
- super(metadataID);
+ ParameterImpl(RuntimeMetadataImpl factory, SPParameter param, Procedure parent) {
+ super(param.getMetadataID(), factory);
+ this.parent = parent;
+ this.param = param;
}
private SPParameter getParameterInfo() throws ConnectorException {
- if(param == null) {
- ParameterIDImpl paramID = (ParameterIDImpl) getMetadataID();
- StoredProcedureInfo procInfo = ((ProcedureIDImpl)paramID.getParentID()).getProcedureInfo();
- List params = procInfo.getParameters();
- for(int i=0; i<params.size(); i++) {
- SPParameter aParam = (SPParameter) params.get(i);
- if(aParam.getMetadataID().equals(paramID.getActualMetadataID())) {
- this.param = aParam;
- break;
- }
- }
- }
return param;
}
@@ -118,6 +111,21 @@
}
}
+ @Override
+ public List<Element> getChildren() throws ConnectorException {
+ if (param.getParameterType() == SPParameter.RESULT_SET) {
+ List<Element> result = new ArrayList<Element>(param.getResultSetIDs().size());
+ for (Object elementId : param.getResultSetIDs()) {
+ result.add(new ElementImpl(elementId, getFactory()));
+ }
+ return result;
+ }
+ return Collections.emptyList();
+ }
+ @Override
+ public Procedure getParent() throws ConnectorException {
+ return parent;
+ }
}
Deleted: 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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureIDImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -1,84 +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.metadata;
-
-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.StoredProcedureInfo;
-import com.metamatrix.query.sql.lang.SPParameter;
-
-/**
- */
-public class ProcedureIDImpl extends MetadataIDImpl {
-
- private StoredProcedureInfo procInfo;
- private MetadataFactory factory;
-
- /**
- * @param actualMetadataID
- * @param metadata
- * @throws MetaMatrixComponentException
- */
- public ProcedureIDImpl(Object actualMetadataID, StoredProcedureInfo procInfo, MetadataFactory factory)
- throws MetaMatrixComponentException {
-
- super(actualMetadataID, factory.getRuntimeMetadata());
- this.procInfo = procInfo;
- this.factory = factory;
- }
-
- StoredProcedureInfo getProcedureInfo() {
- return this.procInfo;
- }
-
- /*
- * @see com.metamatrix.data.metadata.runtime.MetadataID#getChildIDs()
- */
- public List getChildIDs() throws ConnectorException {
- try {
- List parameters = procInfo.getParameters();
- List childIDs = new ArrayList(parameters.size());
- Iterator iter = parameters.iterator();
- while(iter.hasNext()){
- SPParameter param = (SPParameter) iter.next();
- if(param.getParameterType() == ParameterInfo.RESULT_SET) {
- childIDs.add(factory.createResultSetID(this, param.getMetadataID(), param.getResultSetIDs()));
- } else {
- childIDs.add(factory.createParameterID(this, param.getMetadataID()));
- }
- }
- return childIDs;
- } catch(QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch(MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
- }
-
-}
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureImpl.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/ProcedureImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -24,15 +24,32 @@
*/
package com.metamatrix.dqp.internal.datamgr.metadata;
+import java.util.ArrayList;
+import java.util.List;
+
+import com.metamatrix.connector.metadata.runtime.Parameter;
import com.metamatrix.connector.metadata.runtime.Procedure;
+import com.metamatrix.query.metadata.StoredProcedureInfo;
+import com.metamatrix.query.sql.lang.SPParameter;
/**
*/
public class ProcedureImpl extends MetadataObjectImpl implements Procedure {
+
+ private StoredProcedureInfo procInfo;
- ProcedureImpl(MetadataIDImpl metadataID){
- super(metadataID);
+ ProcedureImpl(RuntimeMetadataImpl factory, StoredProcedureInfo procInfo){
+ super(procInfo.getProcedureID(), factory);
+ this.procInfo = procInfo;
}
+ @Override
+ public List<Parameter> getChildren() {
+ List<Parameter> result = new ArrayList<Parameter>(procInfo.getParameters().size());
+ for (SPParameter param : procInfo.getParameters()) {
+ result.add(new ParameterImpl(getFactory(), param, this));
+ }
+ return result;
+ }
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -28,31 +28,79 @@
import com.metamatrix.api.exception.query.QueryMetadataException;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.metadata.runtime.*;
+import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.metadata.StoredProcedureInfo;
+import com.metamatrix.query.sql.lang.SPParameter;
/**
*/
public class RuntimeMetadataImpl implements RuntimeMetadata {
- private MetadataFactory factory;
+ private QueryMetadataInterface metadata;
- public RuntimeMetadataImpl(MetadataFactory factory){
- this.factory = factory;
+ public RuntimeMetadataImpl(QueryMetadataInterface metadata){
+ ArgCheck.isNotNull(metadata);
+ this.metadata = metadata;
}
- public MetadataObject getObject(MetadataID id) throws ConnectorException {
+ @Override
+ public Element getElement(String fullName) throws ConnectorException {
+ try {
+ Object elementId = metadata.getElementID(fullName);
+ return new ElementImpl(elementId, this);
+ } catch (QueryMetadataException e) {
+ throw new ConnectorException(e);
+ } catch (MetaMatrixComponentException e) {
+ throw new ConnectorException(e);
+ }
+ }
+
+ public ElementImpl getElement(Object elementId) {
+ return new ElementImpl(elementId, this);
+ }
+
+ @Override
+ public Group getGroup(String fullName) throws ConnectorException {
+ try {
+ Object groupId = metadata.getGroupID(fullName);
+ return getGroup(groupId);
+ } catch (QueryMetadataException e) {
+ throw new ConnectorException(e);
+ } catch (MetaMatrixComponentException e) {
+ throw new ConnectorException(e);
+ }
+ }
- try {
- return factory.createMetadataObject(id);
- } catch (QueryMetadataException e) {
- throw new ConnectorException(e);
- } catch (MetaMatrixComponentException e) {
- throw new ConnectorException(e);
- }
+ public GroupImpl getGroup(Object groupId) throws QueryMetadataException, MetaMatrixComponentException {
+ if (!metadata.isVirtualGroup(groupId)) {
+ return new GroupImpl(groupId, this);
+ }
+ return null;
+ }
+
+ @Override
+ public Procedure getProcedure(String fullName) throws ConnectorException {
+ try {
+ StoredProcedureInfo sp = metadata.getStoredProcedureInfoForProcedure(fullName);
+ return getProcedure(sp);
+ } catch (QueryMetadataException e) {
+ throw new ConnectorException(e);
+ } catch (MetaMatrixComponentException e) {
+ throw new ConnectorException(e);
+ }
}
+ public Procedure getProcedure(StoredProcedureInfo sp) {
+ return new ProcedureImpl(this, sp);
+ }
+
+ public Parameter getParameter(SPParameter param, Procedure parent) {
+ return new ParameterImpl(this, param, parent);
+ }
+
public byte[] getBinaryVDBResource(String resourcePath) throws ConnectorException {
try {
- return factory.getBinaryVDBResource(resourcePath);
+ return metadata.getBinaryVDBResource(resourcePath);
} catch (QueryMetadataException e) {
throw new ConnectorException(e);
} catch (MetaMatrixComponentException e) {
@@ -62,7 +110,7 @@
public String getCharacterVDBResource(String resourcePath) throws ConnectorException {
try {
- return factory.getCharacterVDBResource(resourcePath);
+ return metadata.getCharacterVDBResource(resourcePath);
} catch (QueryMetadataException e) {
throw new ConnectorException(e);
} catch (MetaMatrixComponentException e) {
@@ -72,7 +120,7 @@
public String[] getVDBResourcePaths() throws ConnectorException {
try {
- return factory.getVDBResourcePaths();
+ return metadata.getVDBResourcePaths();
} catch (QueryMetadataException e) {
throw new ConnectorException(e);
} catch (MetaMatrixComponentException e) {
@@ -81,7 +129,7 @@
}
QueryMetadataInterface getMetadata() {
- return this.factory.getMetadata();
+ return metadata;
}
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/metadata/TypeModelImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -37,11 +37,10 @@
TypeModel {
/**
- * @param metadataID
* @since 4.3
*/
- public TypeModelImpl(MetadataIDImpl metadataID) {
- super(metadataID);
+ public TypeModelImpl(Object actualID, RuntimeMetadataImpl factory) {
+ super(actualID, factory);
}
public int getNullability() throws ConnectorException {
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPool.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -42,10 +42,9 @@
import com.metamatrix.connector.DataPlugin;
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.api.ConnectorIdentity;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.identity.ConnectorIdentity;
-import com.metamatrix.connector.identity.PoolAwareConnection;
-import com.metamatrix.connector.identity.SingleIdentity;
+import com.metamatrix.connector.api.SingleIdentity;
import com.metamatrix.connector.xa.api.TransactionContext;
import com.metamatrix.connector.xa.api.XAConnector;
import com.metamatrix.core.log.MessageLevel;
@@ -455,7 +454,7 @@
}
//for testing purpose
- final List<ConnectionWrapper> getUsedConnections(PoolAwareConnection connection) {
+ final List<ConnectionWrapper> getUsedConnections(Connection connection) {
ConnectorIdentity id = null;
ConnectionsForId connLists = null;
synchronized (this.lock) {
@@ -471,7 +470,7 @@
}
//for testing purpose
- final List<ConnectionWrapper> getUnusedConnections(PoolAwareConnection connection) {
+ final List<ConnectionWrapper> getUnusedConnections(Connection connection) {
ConnectorIdentity id = null;
ConnectionsForId connLists = null;
synchronized (this.lock) {
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionWrapper.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -27,15 +27,14 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.api.ConnectorIdentity;
import com.metamatrix.connector.api.Execution;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.identity.ConnectorIdentity;
-import com.metamatrix.connector.identity.PoolAwareConnection;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xa.api.XAConnection;
-public class ConnectionWrapper implements PoolAwareConnection, XAConnection {
+public class ConnectionWrapper implements XAConnection {
private Connection connection;
private long timeReturnedToPool = System.currentTimeMillis();
@@ -128,9 +127,7 @@
@Override
public void closeCalled() {
- if (this.connection instanceof PoolAwareConnection) {
- ((PoolAwareConnection)this.connection).closeCalled();
- }
+ this.connection.closeCalled();
}
public void setTestInterval(long testInterval) {
@@ -140,9 +137,7 @@
@Override
public void setConnectorIdentity(ConnectorIdentity context)
throws ConnectorException {
- if (this.connection instanceof PoolAwareConnection) {
- ((PoolAwareConnection)this.connection).setConnectorIdentity(context);
- }
+ this.connection.setConnectorIdentity(context);
}
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/FakeConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -30,7 +30,6 @@
import junit.framework.Assert;
import com.metamatrix.connector.api.Connection;
-import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
@@ -40,6 +39,7 @@
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.UpdateExecution;
import com.metamatrix.connector.basic.BasicConnection;
+import com.metamatrix.connector.basic.BasicConnector;
import com.metamatrix.connector.basic.BasicConnectorCapabilities;
import com.metamatrix.connector.basic.BasicExecution;
import com.metamatrix.connector.language.ICommand;
@@ -49,7 +49,7 @@
import com.metamatrix.connector.xa.api.XAConnection;
import com.metamatrix.connector.xa.api.XAConnector;
-public class FakeConnector implements Connector, XAConnector {
+public class FakeConnector extends BasicConnector implements XAConnector {
private static final int RESULT_SIZE = 5;
private boolean executeBlocks;
@@ -73,10 +73,10 @@
@Override
public XAConnection getXAConnection(ExecutionContext executionContext,
TransactionContext transactionContext) throws ConnectorException {
- return new FakeXAConnection();
+ return new FakeConnection();
}
- private class FakeConnection extends BasicConnection {
+ private class FakeConnection extends BasicConnection implements XAConnection {
public boolean released = false;
public Execution createExecution(ICommand command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
return new FakeBlockingExecution(executionContext);
@@ -88,15 +88,6 @@
Assert.assertFalse("The connection should not be released more than once", released); //$NON-NLS-1$
released = true;
}
- }
-
- private final class FakeXAConnection extends FakeConnection implements XAConnection {
- public boolean released = false;
-
- public void close() {
- Assert.assertFalse("The connection should not be released more than once", released); //$NON-NLS-1$
- released = true;
- }
@Override
public XAResource getXAResource() throws ConnectorException {
return null;
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestElementImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -27,8 +27,7 @@
import com.metamatrix.common.types.DataTypeManager;
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.connector.metadata.runtime.Element;
import com.metamatrix.dqp.internal.datamgr.metadata.TestMetadataFactory;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.unittest.FakeMetadataObject;
@@ -96,7 +95,7 @@
public void testGetMetadataID() throws Exception {
FakeMetadataObject group = TestMetadataFactory.createGroup("pm1.g1", null); //$NON-NLS-1$
FakeMetadataObject metadataID = TestMetadataFactory.createElement("e", group, DataTypeManager.DefaultDataTypes.STRING, 0); //$NON-NLS-1$
- assertNotNull(example("pm1.g1", "e", metadataID).getMetadataID()); //$NON-NLS-1$ //$NON-NLS-2$
+ assertNotNull(example("pm1.g1", "e", metadataID).getMetadataObject()); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testGetType() throws Exception {
@@ -107,10 +106,10 @@
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, Type.TYPE_ELEMENT);
- element.setMetadataID(connID);
- assertNotNull(element.getMetadataID());
- assertEquals(connID, element.getMetadataID());
+ Element elem = TstLanguageBridgeFactory.metadataFactory.getElement(metadataID);
+ element.setMetadataObject(elem);
+ assertNotNull(element.getMetadataObject());
+ assertEquals(elem, element.getMetadataObject());
}
public void helpTestEquals(IElement e1, IElement e2, boolean equal) {
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestFunctionImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestFunctionImpl.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TestFunctionImpl.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,6 +22,8 @@
package com.metamatrix.dqp.internal.datamgr.language;
+import java.util.List;
+
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.Expression;
@@ -56,11 +58,11 @@
}
public void testGetParameters() throws Exception {
- IExpression[] params = example("testFunction").getParameters(); //$NON-NLS-1$
+ List<IExpression> params = example("testFunction").getParameters(); //$NON-NLS-1$
assertNotNull(params);
- assertEquals(2, params.length);
- for (int i = 0; i < params.length; i++) {
- assertNotNull(params[i]);
+ assertEquals(2, params.size());
+ for (int i = 0; i < params.size(); i++) {
+ assertNotNull(params.get(i));
}
}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,14 +22,14 @@
package com.metamatrix.dqp.internal.datamgr.language;
-import com.metamatrix.dqp.internal.datamgr.metadata.MetadataFactory;
+import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.query.unittest.FakeMetadataFacade;
import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TstLanguageBridgeFactory {
public static final FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- public static final MetadataFactory metadataFactory = new MetadataFactory(metadata);
+ public static final RuntimeMetadataImpl metadataFactory = new RuntimeMetadataImpl(metadata);
public static final LanguageBridgeFactory factory = new LanguageBridgeFactory(metadata);
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/metadata/TestMetadataFactory.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -30,14 +30,12 @@
import junit.framework.TestCase;
import com.metamatrix.common.types.DataTypeManager;
-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;
public class TestMetadataFactory extends TestCase {
- private MetadataFactory metadataFactory;
+ private RuntimeMetadataImpl metadataFactory;
private FakeMetadataObject pm1g1;
private FakeMetadataObject pm1g1e1;
@@ -54,7 +52,7 @@
pm1g1e1 = (FakeMetadataObject)pm1g1e.get(0);
store.addObject(pm1g1);
store.addObjects(pm1g1e);
- metadataFactory = new MetadataFactory(new FakeMetadataFacade(store));
+ metadataFactory = new RuntimeMetadataImpl(new FakeMetadataFacade(store));
}
@@ -105,88 +103,50 @@
//tests
- public void testCreateMetadataID(){
- try{
- //test create MetadataID for 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, Type.TYPE_ELEMENT);
- assertEquals(eID.getActualMetadataID(), pm1g1e1);
- assertEquals(((MetadataIDImpl)eID.getParentID()).getActualMetadataID(), pm1g1);
- }catch(Exception e){
- e.printStackTrace();
- fail(e.getMessage());
- }
+ public void testCreateMetadataID() throws Exception {
+ //test create MetadataID for Group
+ GroupImpl gID = metadataFactory.getGroup(pm1g1);
+ assertEquals(gID.getActualID(), pm1g1);
+ assertEquals(((ElementImpl)gID.getChildren().get(0)).getActualID(), pm1g1e1);
+
+ //test create MetadataID for Element
+ ElementImpl eID = metadataFactory.getElement(pm1g1e1);
+ assertEquals(eID.getActualID(), pm1g1e1);
+ assertEquals(((GroupImpl)eID.getParent()).getActualID(), pm1g1);
}
- public void testRuntimeMetadata(){
- try{
- 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);
+ public void testRuntimeMetadata() throws Exception {
+ GroupImpl group = metadataFactory.getGroup(pm1g1);
+ assertEquals(group.getNameInSource(), "g1"); //$NON-NLS-1$
+ assertEquals(group.getActualID(), pm1g1);
- 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);
- assertEquals(element.getNameInSource(), "e1"); //$NON-NLS-1$
- assertEquals(((MetadataIDImpl)element.getMetadataID()).getActualMetadataID(), pm1g1e1);
- }catch(Exception e){
- e.printStackTrace();
- fail(e.getMessage());
- }
+ ElementImpl element = metadataFactory.getElement(pm1g1e1);
+ assertEquals(element.getLength(), 100);
+ assertEquals(element.getJavaType(), DataTypeManager.DefaultDataClasses.STRING);
+ assertEquals(element.getNameInSource(), "e1"); //$NON-NLS-1$
+ assertEquals(element.getActualID(), pm1g1e1);
}
- public void testGetVDBResourcePaths() {
+ public void testGetVDBResourcePaths() throws Exception {
String[] expectedPaths = new String[] {"my/resource/path"}; //$NON-NLS-1$
- try {
- RuntimeMetadata runtimeMetadata = metadataFactory.getRuntimeMetadata();
- String[] mfPaths = metadataFactory.getVDBResourcePaths();
- String[] rtmdPaths = runtimeMetadata.getVDBResourcePaths();
- assertEquals(expectedPaths.length, mfPaths.length);
- assertEquals(expectedPaths.length, rtmdPaths.length);
- for (int i = 0; i < expectedPaths.length; i++) {
- assertEquals(expectedPaths[i], mfPaths[i]);
- assertEquals(expectedPaths[i], rtmdPaths[i]);
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
+ String[] mfPaths = metadataFactory.getVDBResourcePaths();
+ assertEquals(expectedPaths.length, mfPaths.length);
+ for (int i = 0; i < expectedPaths.length; i++) {
+ assertEquals(expectedPaths[i], mfPaths[i]);
}
}
- public void testGetBinaryVDBResource() {
- try {
- RuntimeMetadata runtimeMetadata = metadataFactory.getRuntimeMetadata();
- byte[] expectedBytes = "ResourceContents".getBytes(); //$NON-NLS-1$
- byte[] mfBytes = metadataFactory.getBinaryVDBResource(null);
- byte[] rtmdBytes = runtimeMetadata.getBinaryVDBResource(null);
- assertEquals(expectedBytes.length, mfBytes.length);
- assertEquals(expectedBytes.length, rtmdBytes.length);
- for (int i = 0; i < expectedBytes.length; i++) {
- assertEquals("Byte at index " + i + " differs from expected content", expectedBytes[i], mfBytes[i]); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Byte at index " + i + " differs from expected content", expectedBytes[i], rtmdBytes[i]); //$NON-NLS-1$ //$NON-NLS-2$
- }
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
+ public void testGetBinaryVDBResource() throws Exception {
+ byte[] expectedBytes = "ResourceContents".getBytes(); //$NON-NLS-1$
+ byte[] mfBytes = metadataFactory.getBinaryVDBResource(null);
+ assertEquals(expectedBytes.length, mfBytes.length);
+ for (int i = 0; i < expectedBytes.length; i++) {
+ assertEquals("Byte at index " + i + " differs from expected content", expectedBytes[i], mfBytes[i]); //$NON-NLS-1$ //$NON-NLS-2$
}
}
- public void testGetCharacterVDBResource() {
- try {
- RuntimeMetadata runtimeMetadata = metadataFactory.getRuntimeMetadata();
- assertEquals("ResourceContents", metadataFactory.getCharacterVDBResource(null)); //$NON-NLS-1$
- assertEquals("ResourceContents", runtimeMetadata.getCharacterVDBResource(null)); //$NON-NLS-1$
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
+ public void testGetCharacterVDBResource() throws Exception {
+ assertEquals("ResourceContents", metadataFactory.getCharacterVDBResource(null)); //$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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeSourceConnectionFactory.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -25,19 +25,19 @@
package com.metamatrix.dqp.internal.pooling.connector;
import com.metamatrix.connector.api.Connection;
-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.basic.BasicConnection;
+import com.metamatrix.connector.basic.BasicConnector;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
/**
*/
-public class FakeSourceConnectionFactory implements Connector {
+public class FakeSourceConnectionFactory extends BasicConnector {
static int connCnt;
static boolean alive = true;
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -25,14 +25,13 @@
package com.metamatrix.dqp.internal.pooling.connector;
import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.api.ConnectorIdentity;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.identity.ConnectorIdentity;
-import com.metamatrix.connector.identity.ConnectorIdentityFactory;
-import com.metamatrix.connector.identity.UserIdentity;
+import com.metamatrix.connector.api.MappedUserIdentity;
/**
*/
-public class FakeUserIdentityConnectionFactory extends FakeSourceConnectionFactory implements ConnectorIdentityFactory {
+public class FakeUserIdentityConnectionFactory extends FakeSourceConnectionFactory {
/*
* @see com.metamatrix.data.pool.SourceConnectionFactory#createIdentity(com.metamatrix.data.SecurityContext)
@@ -42,7 +41,7 @@
return null;
}
//use user name for now
- return new UserIdentity(context.getUser(), null, null);
+ return new MappedUserIdentity(context.getUser(), null, null);
}
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionPool.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -29,7 +29,7 @@
import junit.framework.TestCase;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.identity.UserIdentity;
+import com.metamatrix.connector.api.MappedUserIdentity;
import com.metamatrix.dqp.internal.datamgr.impl.ConnectorWrapper;
import com.metamatrix.dqp.internal.datamgr.impl.ExecutionContextImpl;
@@ -69,7 +69,7 @@
public static ExecutionContext createContext(final String user, boolean userIdentity) {
ExecutionContextImpl context = new ExecutionContextImpl(null, null, user, null, null, null, null, null, null, null, false);
if (userIdentity) {
- context.setConnectorIdentity(new UserIdentity(context.getUser(), null, null));
+ context.setConnectorIdentity(new MappedUserIdentity(context.getUser(), null, null));
}
return context;
}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionWrapper.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionWrapper.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionWrapper.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -26,13 +26,12 @@
import org.mockito.Mockito;
-import com.metamatrix.connector.api.Connection;
-import com.metamatrix.connector.identity.PoolAwareConnection;
+import com.metamatrix.connector.basic.BasicConnection;
public class TestConnectionWrapper extends TestCase {
public void testIdleTime() throws Exception {
- ConnectionWrapper wrapper = new ConnectionWrapper(Mockito.mock(Connection.class), Mockito.mock(ConnectionPool.class), 1);
+ ConnectionWrapper wrapper = new ConnectionWrapper(Mockito.mock(BasicConnection.class), Mockito.mock(ConnectionPool.class), 1);
long time = wrapper.getTimeReturnedToPool();
Thread.sleep(5);
wrapper.close();
@@ -40,7 +39,7 @@
}
public void testIsAliveTestInterval() throws Exception {
- PoolAwareConnection connection = Mockito.mock(PoolAwareConnection.class);
+ BasicConnection connection = Mockito.mock(BasicConnection.class);
Mockito.stub(connection.isAlive()).toReturn(Boolean.TRUE);
ConnectionWrapper wrapper = new ConnectionWrapper(connection, Mockito.mock(ConnectionPool.class), 1);
wrapper.setTestInterval(-1); //trigger an actual call.
Copied: trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestPerUserPool.java (from rev 486, trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/TestPerUserPool.java)
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestPerUserPool.java (rev 0)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestPerUserPool.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -0,0 +1,141 @@
+/*
+ * 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.pooling.connector;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
+
+import com.metamatrix.common.application.ApplicationEnvironment;
+import com.metamatrix.connector.api.Connection;
+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.CredentialMap;
+import com.metamatrix.connector.api.ExecutionContext;
+import com.metamatrix.connector.api.MappedUserIdentity;
+import com.metamatrix.connector.basic.BasicConnector;
+import com.metamatrix.connector.internal.ConnectorPropertyNames;
+import com.metamatrix.dqp.internal.datamgr.impl.ConnectorEnvironmentImpl;
+import com.metamatrix.dqp.internal.datamgr.impl.ExecutionContextImpl;
+
+/**
+ */
+public class TestPerUserPool extends TestCase {
+
+ public TestPerUserPool(String name) {
+ super(name);
+ }
+
+ private Connector getTestConnector(ConnectorEnvironment env) throws ConnectorException {
+ BasicConnector con = new BasicConnector() {
+
+ @Override
+ public ConnectorCapabilities getCapabilities() {
+ return null;
+ }
+
+ @Override
+ public Connection getConnection(ExecutionContext context)
+ throws ConnectorException {
+ assertTrue(context.getConnectorIdentity() instanceof MappedUserIdentity);
+ return null;
+ }
+
+ @Override
+ public void start(ConnectorEnvironment environment)
+ throws ConnectorException {
+
+ }
+
+ @Override
+ public void stop() {
+
+ }
+
+ };
+ con.setUseCredentialMap(true);
+ con.setAdminConnectionsAllowed(false);
+ con.setConnectorName("oracle system");
+ con.start(env);
+ return con;
+ }
+
+ public void testWrongCredentials() throws Exception {
+ ConnectorEnvironment env = initConnectorEnvironment();
+ Connector factory = getTestConnector(env);
+ try {
+ ExecutionContext ctx = createSecurityContext("pw1", false, factory); //$NON-NLS-1$
+ factory.getConnection(ctx);
+ fail("expected failure"); //$NON-NLS-1$
+ } catch (ConnectorException e) {
+ assertEquals("Unable to extract credentials from command payload or trusted session payload for per-user connection.", e.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+ private ConnectorEnvironment initConnectorEnvironment() throws Exception {
+ final Properties connProps = new Properties();
+ connProps.put(ConnectorPropertyNames.CONNECTOR_BINDING_NAME, "oracle system"); //$NON-NLS-1$
+ return new ConnectorEnvironmentImpl(connProps, Mockito.mock(ConnectorLogger.class), new ApplicationEnvironment());
+ }
+
+ private ExecutionContext createSecurityContext(String credentialsStr, boolean useMap, Connector factory) throws Exception {
+ Serializable credentials = credentialsStr;
+ if (useMap) {
+ credentials = CredentialMap.parseCredentials(credentialsStr);
+ }
+
+ // session payload
+ ExecutionContextImpl impl = new ExecutionContextImpl(null, null, null, credentials, null, null, null, null, null, null, false);
+ impl.setConnectorIdentity(factory.createIdentity(impl));
+ return impl;
+ }
+
+ public void testCredentialMapInSessionPayload() throws Exception {
+ ConnectorEnvironment env = initConnectorEnvironment();
+ Connector factory = getTestConnector(env);
+ ExecutionContext ctx = createSecurityContext("(system=oracle system,user=bqt2,password=mm)", true, factory); //$NON-NLS-1$
+ factory.getConnection(ctx);
+ }
+
+ public void testCredentialMapMissingSystem() throws Exception {
+ ConnectorEnvironment env = initConnectorEnvironment();
+ Connector factory = getTestConnector(env);
+
+ // Set system to "x" instead of "oracle system" which will cause no credentials to be found
+ try {
+ ExecutionContext ctx = createSecurityContext("(system=x,user=bqt2,password=mm)", true, factory); //$NON-NLS-1$
+ factory.getConnection(ctx);
+ fail("Expected exception when creating connection with missing system credentials"); //$NON-NLS-1$
+ } catch(Exception e) {
+ // expected
+ assertEquals("Payload missing credentials for oracle system", e.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+}
Property changes on: trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestPerUserPool.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/QueryMetadataInterfaceBuilder.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/QueryMetadataInterfaceBuilder.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/QueryMetadataInterfaceBuilder.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -31,7 +31,6 @@
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.internal.datamgr.metadata.MetadataFactory;
import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.dqp.message.ParameterInfo;
import com.metamatrix.query.metadata.QueryMetadataInterface;
@@ -172,7 +171,7 @@
}
public RuntimeMetadata getRuntimeMetadata(){
- return new RuntimeMetadataImpl(new MetadataFactory(getQueryMetadata()));
+ return new RuntimeMetadataImpl(getQueryMetadata());
}
private FakeMetadataObject createPhysicalModel(String name) {
Modified: trunk/test-integration/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/test-integration/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -27,7 +27,6 @@
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IGroup;
import com.metamatrix.connector.language.IQuery;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.core.util.UnitTestUtil;
@@ -87,11 +86,10 @@
// Translate command to get some ids
IQuery query = (IQuery) util.parseCommand("select * from partssupplier.parts"); //$NON-NLS-1$
IGroup group = (IGroup) query.getFrom().getItems().get(0);
- MetadataID mid = group.getMetadataID();
+ MetadataObject mid = group.getMetadataObject();
assertEquals("PartsSupplier.PARTSSUPPLIER.PARTS", mid.getFullName()); //$NON-NLS-1$
// Use RMD to get stuff
- MetadataObject groupObj = rmd.getObject(mid);
- assertEquals("PARTS", groupObj.getNameInSource()); //$NON-NLS-1$
+ assertEquals("PARTS", mid.getNameInSource()); //$NON-NLS-1$
}
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -113,7 +113,7 @@
throw new RuntimeException(e);
}
}
- public static final RuntimeMetadata metadata = TstLanguageBridgeFactory.metadataFactory.getRuntimeMetadata();
+ public static final RuntimeMetadata metadata = TstLanguageBridgeFactory.metadataFactory;
private String getStringWithContext(ILanguageObject obj) throws ConnectorException {
Properties props = new Properties();
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-24 14:33:28 UTC (rev 487)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -43,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.metadata.MetadataFactory;
import com.metamatrix.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.unittest.FakeMetadataFacade;
@@ -106,7 +105,7 @@
// Convert from sql to objects
CommandBuilder commandBuilder = new CommandBuilder(metadata);
ICommand obj = commandBuilder.getCommand(input);
- RuntimeMetadata runtimeMetadata = new RuntimeMetadataImpl(new MetadataFactory(metadata));
+ RuntimeMetadata runtimeMetadata = new RuntimeMetadataImpl(metadata);
this.helpTestVisitor(obj, runtimeMetadata, modifiers, context, dbmsTimeZone, expectedOutput);
}
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-24 14:33:28 UTC (rev 487)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/MockConnector.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -7,7 +7,6 @@
import org.mockito.Mockito;
import com.metamatrix.connector.api.Connection;
-import com.metamatrix.connector.api.Connector;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
@@ -15,6 +14,7 @@
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.basic.BasicConnection;
+import com.metamatrix.connector.basic.BasicConnector;
import com.metamatrix.connector.basic.BasicConnectorCapabilities;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IGroup;
@@ -25,7 +25,7 @@
import com.metamatrix.connector.metadata.runtime.MetadataObject;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-public class MockConnector implements Connector {
+public class MockConnector extends BasicConnector {
@Override
public ConnectorCapabilities getCapabilities() {
@@ -47,7 +47,7 @@
Properties props = new Properties();
props.setProperty("customBehaviour", "SkipExecute");//$NON-NLS-1$ //$NON-NLS-2$
- MetadataObject metaObject = metadata.getObject(procedure.getMetadataID());
+ MetadataObject metaObject = procedure.getMetadataObject();
TestCase.assertEquals("AnyModel.ProcedureB",procedure.getProcedureName()); //$NON-NLS-1$
TestCase.assertEquals("PROC", metaObject.getNameInSource()); //$NON-NLS-1$
@@ -64,13 +64,13 @@
Properties groupProps = new Properties();
groupProps.setProperty("customName", "CustomTableA");//$NON-NLS-1$ //$NON-NLS-2$
IGroup group = (IGroup)query.getProjectedQuery().getFrom().getItems().get(0);
- MetadataObject groupMD = metadata.getObject(group.getMetadataID());
+ MetadataObject groupMD = group.getMetadataObject();
TestCase.assertEquals(groupProps, groupMD.getProperties());
ISelectSymbol symbl = (ISelectSymbol)query.getProjectedQuery().getSelect().getSelectSymbols().get(0);
IElement element = (IElement)symbl.getExpression();
- Element elementMD = (Element)metadata.getObject(element.getMetadataID());
+ Element elementMD = element.getMetadataObject();
Properties elementProps = new Properties();
elementProps.setProperty("customPosition", "11");//$NON-NLS-1$ //$NON-NLS-2$
@@ -98,7 +98,7 @@
ISelectSymbol symbl2 = (ISelectSymbol)query.getProjectedQuery().getSelect().getSelectSymbols().get(1);
IElement element2 = (IElement)symbl2.getExpression();
- Element elementMD2 = (Element)metadata.getObject(element2.getMetadataID());
+ Element elementMD2 = element2.getMetadataObject();
Properties elementProps2 = new Properties();
elementProps2.setProperty("customPosition", "12");//$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestElement.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestElement.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestElement.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -31,7 +31,6 @@
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.ISelectSymbol;
import com.metamatrix.connector.metadata.runtime.Element;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.core.util.UnitTestUtil;
/**
@@ -59,8 +58,7 @@
IQuery query = (IQuery) transUtil.parseCommand("SELECT " + elementName + " FROM " + groupName); //$NON-NLS-1$ //$NON-NLS-2$
ISelectSymbol symbol = (ISelectSymbol) query.getSelect().getSelectSymbols().get(0);
IElement element = (IElement) symbol.getExpression();
- MetadataID metadataID = element.getMetadataID();
- return (Element) transUtil.createRuntimeMetadata().getObject(metadataID);
+ return element.getMetadataObject();
}
public void helpTestElement(String fullGroupName, String elementShortName, TranslationUtility transUtil,
Modified: trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestGroup.java
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestGroup.java 2009-02-24 14:33:28 UTC (rev 487)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestGroup.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -30,7 +30,6 @@
import com.metamatrix.connector.language.IGroup;
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.metadata.runtime.Group;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
import com.metamatrix.core.util.UnitTestUtil;
/**
@@ -60,8 +59,7 @@
public Group getGroup(String groupName, TranslationUtility transUtil) throws Exception {
IQuery query = (IQuery) transUtil.parseCommand("SELECT 1 FROM " + groupName); //$NON-NLS-1$
IGroup group = (IGroup) query.getFrom().getItems().get(0);
- MetadataID metadataID = group.getMetadataID();
- return (Group) transUtil.createRuntimeMetadata().getObject(metadataID);
+ return group.getMetadataObject();
}
public void helpTestGroup(String fullGroupName, String nameInSource, Properties expectedProps, TranslationUtility transUtil) throws Exception {
Deleted: 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-24 14:33:28 UTC (rev 487)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataID.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -1,188 +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.data.metadata.runtime;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.connector.language.IElement;
-import com.metamatrix.connector.language.IGroup;
-import com.metamatrix.connector.language.IProcedure;
-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;
-
-/**
- */
-public class TestMetadataID extends TestCase {
-
- private static TranslationUtility CONNECTOR_METADATA_UTILITY = createTranslationUtility(getTestVDBName());
-
- /**
- * Constructor for TestMetadataID.
- * @param name
- */
- public TestMetadataID(String name) {
- super(name);
- }
-
- private static String getTestVDBName() {
- return UnitTestUtil.getTestDataPath() + "/ConnectorMetadata.vdb"; //$NON-NLS-1$
- }
-
- public static TranslationUtility createTranslationUtility(String vdbName) {
- return new TranslationUtility(vdbName);
- }
-
-
- // ################ TEST GROUP METADATAID ######################
-
- public MetadataID getGroupID(String groupName, TranslationUtility transUtil) {
- IQuery query = (IQuery) transUtil.parseCommand("SELECT 1 FROM " + groupName); //$NON-NLS-1$
- IGroup group = (IGroup) query.getFrom().getItems().get(0);
- return group.getMetadataID();
- }
-
- public void helpTestGroupID(String fullGroupName, String shortGroupName, int elementCount, TranslationUtility transUtil) throws Exception {
- MetadataID groupID = getGroupID(fullGroupName, transUtil);
- assertEquals(fullGroupName, groupID.getFullName());
- assertEquals(shortGroupName, groupID.getName());
- assertEquals(Type.TYPE_GROUP, groupID.getType());
- assertNull(groupID.getParentID());
-
- // Check children
- List children = groupID.getChildIDs();
- assertEquals(elementCount, children.size());
- Iterator childIter = children.iterator();
- while(childIter.hasNext()) {
- MetadataID childID = (MetadataID) childIter.next();
- assertEquals(Type.TYPE_ELEMENT, childID.getType());
- assertEquals(groupID, childID.getParentID());
- assertTrue(childID.getFullName().startsWith(groupID.getFullName()));
- }
- }
-
- public void testGroupID() throws Exception {
- helpTestGroupID("ConnectorMetadata.TestTable", "TestTable", 7, CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testGroupID_longName() throws Exception {
- helpTestGroupID("ConnectorMetadata.TestCatalog.TestSchema.TestTable2", "TestTable2", 1, CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // ################ TEST ELEMENT METADATAID ######################
-
- public MetadataID getElementID(String groupName, String elementName, TranslationUtility transUtil) {
- IQuery query = (IQuery) transUtil.parseCommand("SELECT " + elementName + " FROM " + groupName); //$NON-NLS-1$ //$NON-NLS-2$
- ISelectSymbol symbol = (ISelectSymbol) query.getSelect().getSelectSymbols().get(0);
- IElement element = (IElement) symbol.getExpression();
- return element.getMetadataID();
- }
-
- public void helpTestElementID(String groupName, String elementName, TranslationUtility transUtil) throws Exception {
- MetadataID elementID = getElementID(groupName, elementName, transUtil);
- assertEquals(Type.TYPE_ELEMENT, elementID.getType());
- assertEquals(groupName + "." + elementName, elementID.getFullName()); //$NON-NLS-1$
- assertEquals(elementName, elementID.getName());
- assertEquals(Collections.EMPTY_LIST, elementID.getChildIDs());
- assertNotNull(elementID.getParentID());
- assertEquals(groupName, elementID.getParentID().getFullName());
- }
-
- public void testElementID() throws Exception {
- helpTestElementID("ConnectorMetadata.TestTable", "TestNameInSource", CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testElementID_longName() throws Exception {
- helpTestElementID("ConnectorMetadata.TestCatalog.TestSchema.TestTable2", "TestCol", CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // ################ TEST PROCEDURE AND PARAMETER METADATAID ######################
-
- public MetadataID getProcedureID(String procName, int inputParamCount, TranslationUtility transUtil) {
- StringBuffer sql = new StringBuffer("EXEC "); //$NON-NLS-1$
- sql.append(procName);
- sql.append("("); //$NON-NLS-1$
- for(int i=0; i<inputParamCount; i++) {
- sql.append("null"); //$NON-NLS-1$
- if(i<(inputParamCount-1)) {
- sql.append(", "); //$NON-NLS-1$
- }
- }
- sql.append(")"); //$NON-NLS-1$
-
- IProcedure proc = (IProcedure) transUtil.parseCommand(sql.toString());
- return proc.getMetadataID();
- }
-
- public void helpTestProcedureID(String procName, String shortName, int inputParamCount, String[] paramNames, TranslationUtility transUtil) throws Exception {
- MetadataID procID = getProcedureID(procName, inputParamCount, transUtil);
- assertEquals(Type.TYPE_PROCEDURE, procID.getType());
- assertEquals(procName, procID.getFullName()); //$NON-NLS-1$
- assertNull(procID.getParentID());
- assertEquals(shortName, procID.getName());
-
- // Check children
- List children = procID.getChildIDs();
- assertEquals(paramNames.length, children.size());
- Set actualParamNames = new HashSet();
- Iterator childIter = children.iterator();
- while(childIter.hasNext()) {
- MetadataID childID = (MetadataID) childIter.next();
- assertEquals(Type.TYPE_PARAMETER, childID.getType());
- assertEquals(procID, childID.getParentID());
- assertTrue(childID.getFullName().startsWith(procID.getFullName()));
-
- actualParamNames.add(childID.getName());
- }
-
- // Compare actual with expected param names
- Set expectedParamNames = new HashSet(Arrays.asList(paramNames));
- assertEquals(expectedParamNames, actualParamNames);
- }
-
- public void testProcedureID() throws Exception {
- String[] paramNames = new String[] { "InParam", "OutParam", "InOutParam", "ReturnParam" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
- helpTestProcedureID("ConnectorMetadata.TestProc1", "TestProc1", 2, paramNames, CONNECTOR_METADATA_UTILITY); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testProcedureID_resultSet() throws Exception {
- String[] paramNames = new String[] { "Param1", "RSParam" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
- helpTestProcedureID("ConnectorMetadata.TestProc2", "TestProc2", 1, paramNames, CONNECTOR_METADATA_UTILITY); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testProcedureID_longName() throws Exception {
- helpTestProcedureID("ConnectorMetadata.TestCatalog.TestSchema.TestProc", "TestProc", 0, new String[0], CONNECTOR_METADATA_UTILITY); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
-}
Copied: trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataObject.java (from rev 480, trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataID.java)
===================================================================
--- trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataObject.java (rev 0)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataObject.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -0,0 +1,175 @@
+/*
+ * 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.data.metadata.runtime;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import com.metamatrix.cdk.api.TranslationUtility;
+import com.metamatrix.connector.language.IElement;
+import com.metamatrix.connector.language.IGroup;
+import com.metamatrix.connector.language.IProcedure;
+import com.metamatrix.connector.language.IQuery;
+import com.metamatrix.connector.language.ISelectSymbol;
+import com.metamatrix.connector.metadata.runtime.Element;
+import com.metamatrix.connector.metadata.runtime.Group;
+import com.metamatrix.connector.metadata.runtime.Parameter;
+import com.metamatrix.connector.metadata.runtime.Procedure;
+import com.metamatrix.core.util.UnitTestUtil;
+
+/**
+ */
+public class TestMetadataObject extends TestCase {
+
+ private static TranslationUtility CONNECTOR_METADATA_UTILITY = createTranslationUtility(getTestVDBName());
+
+ /**
+ * Constructor for TestMetadataID.
+ * @param name
+ */
+ public TestMetadataObject(String name) {
+ super(name);
+ }
+
+ private static String getTestVDBName() {
+ return UnitTestUtil.getTestDataPath() + "/ConnectorMetadata.vdb"; //$NON-NLS-1$
+ }
+
+ public static TranslationUtility createTranslationUtility(String vdbName) {
+ return new TranslationUtility(vdbName);
+ }
+
+
+ // ################ TEST GROUP METADATAID ######################
+
+ public Group getGroupID(String groupName, TranslationUtility transUtil) {
+ IQuery query = (IQuery) transUtil.parseCommand("SELECT 1 FROM " + groupName); //$NON-NLS-1$
+ IGroup group = (IGroup) query.getFrom().getItems().get(0);
+ return group.getMetadataObject();
+ }
+
+ public void helpTestGroupID(String fullGroupName, String shortGroupName, int elementCount, TranslationUtility transUtil) throws Exception {
+ Group groupID = getGroupID(fullGroupName, transUtil);
+ assertEquals(fullGroupName, groupID.getFullName());
+ assertEquals(shortGroupName, groupID.getName());
+
+ // Check children
+ List<Element> children = groupID.getChildren();
+ assertEquals(elementCount, children.size());
+ for (Element element : children) {
+ assertEquals(groupID, element.getParent());
+ assertTrue(element.getFullName().startsWith(groupID.getFullName()));
+ }
+ }
+
+ public void testGroupID() throws Exception {
+ helpTestGroupID("ConnectorMetadata.TestTable", "TestTable", 7, CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testGroupID_longName() throws Exception {
+ helpTestGroupID("ConnectorMetadata.TestCatalog.TestSchema.TestTable2", "TestTable2", 1, CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // ################ TEST ELEMENT METADATAID ######################
+
+ public Element getElementID(String groupName, String elementName, TranslationUtility transUtil) {
+ IQuery query = (IQuery) transUtil.parseCommand("SELECT " + elementName + " FROM " + groupName); //$NON-NLS-1$ //$NON-NLS-2$
+ ISelectSymbol symbol = (ISelectSymbol) query.getSelect().getSelectSymbols().get(0);
+ IElement element = (IElement) symbol.getExpression();
+ return element.getMetadataObject();
+ }
+
+ public void helpTestElementID(String groupName, String elementName, TranslationUtility transUtil) throws Exception {
+ Element elementID = getElementID(groupName, elementName, transUtil);
+ assertEquals(groupName + "." + elementName, elementID.getFullName()); //$NON-NLS-1$
+ assertEquals(elementName, elementID.getName());
+ assertNotNull(elementID.getParent());
+ assertEquals(groupName, elementID.getParent().getFullName());
+ }
+
+ public void testElementID() throws Exception {
+ helpTestElementID("ConnectorMetadata.TestTable", "TestNameInSource", CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testElementID_longName() throws Exception {
+ helpTestElementID("ConnectorMetadata.TestCatalog.TestSchema.TestTable2", "TestCol", CONNECTOR_METADATA_UTILITY);//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // ################ TEST PROCEDURE AND PARAMETER METADATAID ######################
+
+ public Procedure getProcedureID(String procName, int inputParamCount, TranslationUtility transUtil) {
+ StringBuffer sql = new StringBuffer("EXEC "); //$NON-NLS-1$
+ sql.append(procName);
+ sql.append("("); //$NON-NLS-1$
+ for(int i=0; i<inputParamCount; i++) {
+ sql.append("null"); //$NON-NLS-1$
+ if(i<(inputParamCount-1)) {
+ sql.append(", "); //$NON-NLS-1$
+ }
+ }
+ sql.append(")"); //$NON-NLS-1$
+
+ IProcedure proc = (IProcedure) transUtil.parseCommand(sql.toString());
+ return proc.getMetadataObject();
+ }
+
+ public void helpTestProcedureID(String procName, String shortName, int inputParamCount, String[] paramNames, TranslationUtility transUtil) throws Exception {
+ Procedure procID = getProcedureID(procName, inputParamCount, transUtil);
+ assertEquals(procName, procID.getFullName()); //$NON-NLS-1$
+ assertEquals(shortName, procID.getName());
+
+ // Check children
+ List<Parameter> children = procID.getChildren();
+ assertEquals(paramNames.length, children.size());
+ Set actualParamNames = new HashSet();
+ for (Parameter childID : children) {
+ assertEquals(procID, childID.getParent());
+ assertTrue(childID.getFullName().startsWith(procID.getFullName()));
+ actualParamNames.add(childID.getName());
+ }
+
+ // Compare actual with expected param names
+ Set expectedParamNames = new HashSet(Arrays.asList(paramNames));
+ assertEquals(expectedParamNames, actualParamNames);
+ }
+
+ public void testProcedureID() throws Exception {
+ String[] paramNames = new String[] { "InParam", "OutParam", "InOutParam", "ReturnParam" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
+ helpTestProcedureID("ConnectorMetadata.TestProc1", "TestProc1", 2, paramNames, CONNECTOR_METADATA_UTILITY); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testProcedureID_resultSet() throws Exception {
+ String[] paramNames = new String[] { "Param1", "RSParam" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
+ helpTestProcedureID("ConnectorMetadata.TestProc2", "TestProc2", 1, paramNames, CONNECTOR_METADATA_UTILITY); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public void testProcedureID_longName() throws Exception {
+ helpTestProcedureID("ConnectorMetadata.TestCatalog.TestSchema.TestProc", "TestProc", 0, new String[0], CONNECTOR_METADATA_UTILITY); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+}
Property changes on: trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestMetadataObject.java
___________________________________________________________________
Name: svn:mergeinfo
+
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-24 14:33:28 UTC (rev 487)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestParams.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -32,10 +32,8 @@
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;
-import com.metamatrix.connector.metadata.runtime.MetadataID.Type;
import com.metamatrix.core.util.UnitTestUtil;
@@ -88,10 +86,9 @@
int precision,
int scale,
TranslationUtility transUtil, String modeledType, String modeledBaseType, String modeledPrimitiveType) throws Exception {
- MetadataID metadataID = param.getMetadataID();
- Parameter p = (Parameter)transUtil.createRuntimeMetadata().getObject(metadataID);
- assertEquals(name, metadataID.getName());
- assertEquals(fullName, metadataID.getFullName());
+ Parameter p = param.getMetadataObject();
+ assertEquals(name, p.getName());
+ assertEquals(fullName, p.getFullName());
assertEquals(index, param.getIndex());
assertEquals(direction, param.getDirection());
assertEquals(nameInSource, p.getNameInSource());
@@ -104,7 +101,6 @@
assertEquals(scale, p.getScale());
assertEquals(null, param.getValue());
assertEquals(false, param.getValueSpecified());
- 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-24 14:33:28 UTC (rev 487)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/metadata/runtime/TestProcedure.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -22,8 +22,6 @@
package com.metamatrix.data.metadata.runtime;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Properties;
@@ -32,11 +30,9 @@
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.connector.language.IProcedure;
import com.metamatrix.connector.metadata.runtime.Element;
-import com.metamatrix.connector.metadata.runtime.MetadataID;
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;
/**
@@ -71,8 +67,7 @@
}
sql.append(")"); //$NON-NLS-1$
IProcedure proc = (IProcedure) transUtil.parseCommand(sql.toString()); //$NON-NLS-1$
- MetadataID metadataID = proc.getMetadataID();
- return (Procedure) transUtil.createRuntimeMetadata().getObject(metadataID);
+ return proc.getMetadataObject();
}
public void testProcedure1() throws Exception {
@@ -84,13 +79,9 @@
int[] index = new int[] { 1, 2, 3, 4 };
Class[] type = new Class[] { Integer.class, Long.class, Short.class, java.sql.Date.class };
- MetadataID procID = proc.getMetadataID();
- Collection paramIDs = procID.getChildIDs();
- Iterator paramIter = paramIDs.iterator();
- for(int i=0; paramIter.hasNext(); i++) {
- MetadataID paramID = (MetadataID) paramIter.next();
- Parameter param = (Parameter) CONNECTOR_METADATA_UTILITY.createRuntimeMetadata().getObject(paramID);
-
+ List<Parameter> params = proc.getChildren();
+ for (int i = 0; i < params.size(); i++) {
+ Parameter param = params.get(i);
assertEquals(nameInSource[i], param.getNameInSource());
assertEquals(direction[i], param.getDirection());
assertEquals(index[i], param.getIndex());
@@ -109,42 +100,32 @@
int[] index = new int[] { 1, 2 };
Class[] type = new Class[] { String.class, java.sql.ResultSet.class };
- MetadataID procID = proc.getMetadataID();
- Collection paramIDs = procID.getChildIDs();
- Iterator paramIter = paramIDs.iterator();
- MetadataID paramID = null;
- for(int i=0; paramIter.hasNext(); i++) {
- paramID = (MetadataID) paramIter.next();
- Parameter param = (Parameter) rmd.getObject(paramID);
-
+ List<Parameter> params = proc.getChildren();
+ for (int i = 0; i < params.size(); i++) {
+ Parameter param = params.get(i);
assertEquals(nameInSource[i], param.getNameInSource());
assertEquals(direction[i], param.getDirection());
assertEquals(index[i], param.getIndex());
assertEquals(type[i], param.getJavaType());
}
- // Check last param is a result set
- List rsCols = paramID.getChildIDs();
-
+ Parameter param = params.get(1);
+ List<Element> rsCols = param.getChildren();
// Check first column of result set
assertEquals(2, rsCols.size());
- MetadataID elemID = (MetadataID) rsCols.get(0);
+ Element elemID = rsCols.get(0);
assertEquals("RSCol1", elemID.getName()); //$NON-NLS-1$
assertEquals("ConnectorMetadata.TestProc2.RSParam.RSCol1", elemID.getFullName()); //$NON-NLS-1$
- 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());
- assertEquals(0, e1.getPosition());
+ assertEquals("Result set column name in source", elemID.getNameInSource()); //$NON-NLS-1$
+ assertEquals(java.sql.Timestamp.class, elemID.getJavaType());
+ assertEquals(0, elemID.getPosition());
- MetadataID elemID2 = (MetadataID) rsCols.get(1);
+ Element elemID2 = rsCols.get(1);
assertEquals("RSCol2", elemID2.getName()); //$NON-NLS-1$
assertEquals("ConnectorMetadata.TestProc2.RSParam.RSCol2", elemID2.getFullName()); //$NON-NLS-1$
- assertEquals(Type.TYPE_ELEMENT, elemID2.getType());
- Element e2 = (Element) rmd.getObject(elemID2);
- assertEquals(null, e2.getNameInSource()); //$NON-NLS-1$
- assertEquals(String.class, e2.getJavaType());
- assertEquals(1, e2.getPosition());
+ assertEquals(null, elemID2.getNameInSource()); //$NON-NLS-1$
+ assertEquals(String.class, elemID2.getJavaType());
+ assertEquals(1, elemID2.getPosition());
Properties props = new Properties();
props.put("ColProp", "defaultvalue"); //$NON-NLS-1$ //$NON-NLS-2$
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-24 14:33:28 UTC (rev 487)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/visitor/util/TestCollectorVisitor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -70,7 +70,7 @@
GroupImpl g = new GroupImpl("g1", null, null); //$NON-NLS-1$
List symbols = new ArrayList();
symbols.add(new ElementImpl(g, "e1", null, String.class)); //$NON-NLS-1$
- IFunction function = new FunctionImpl("length", new IExpression[] { new ElementImpl(g, "e2", null, String.class) }, Integer.class); //$NON-NLS-1$ //$NON-NLS-2$
+ IFunction function = new FunctionImpl("length", Arrays.asList(new ElementImpl(g, "e2", null, String.class)), Integer.class); //$NON-NLS-1$ //$NON-NLS-2$
symbols.add(function);
SelectImpl s = new SelectImpl(symbols, false);
List groups = new ArrayList();
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-24 14:33:28 UTC (rev 487)
+++ trunk/test-integration/src/test/java/com/metamatrix/data/visitor/util/TestSQLStringVisitor.java 2009-02-24 16:16:42 UTC (rev 488)
@@ -25,6 +25,8 @@
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
+import java.util.Arrays;
+import java.util.List;
import junit.framework.TestCase;
@@ -35,7 +37,6 @@
import com.metamatrix.connector.language.IGroup;
import com.metamatrix.connector.language.ILanguageObject;
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;
@@ -70,7 +71,6 @@
import com.metamatrix.dqp.internal.datamgr.language.TestSubqueryInCriteriaImpl;
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.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.ReservedWords;
@@ -83,7 +83,7 @@
public class TestSQLStringVisitor extends TestCase {
- public static final RuntimeMetadata metadata = TstLanguageBridgeFactory.metadataFactory.getRuntimeMetadata();
+ public static final RuntimeMetadata metadata = TstLanguageBridgeFactory.metadataFactory;
/**
@@ -103,8 +103,8 @@
}
/** create fake BQT metadata to test this case, name in source is important */
- private RuntimeMetadata exampleRuntimeMetadata(QueryMetadataInterface metadata) {
- return new RuntimeMetadataImpl(new MetadataFactory(metadata));
+ private RuntimeMetadataImpl exampleRuntimeMetadata(QueryMetadataInterface metadata) {
+ return new RuntimeMetadataImpl(metadata);
}
/** create fake BQT metadata to test this case, name in source is important */
@@ -215,18 +215,12 @@
public void testVisitConvertFunctionOracleStyleWithNIS() throws Exception {
FakeMetadataFacade facade = new FakeMetadataFacade(exampleMetadataStore());
- RuntimeMetadata metadata = exampleRuntimeMetadata(facade);
- MetadataFactory metadataFactory = new MetadataFactory(facade);
+ RuntimeMetadataImpl metadata = exampleRuntimeMetadata(facade);
- IExpression [] params = null;
- params = new IExpression[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$
-
+ IGroup g = new GroupImpl("SmallA", null, metadata.getGroup("BQT1.SmallA")); //$NON-NLS-1$
+ IElement e = new ElementImpl(g, "DoubleNum", metadata.getElement("DoubleNum"), Double.class); //$NON-NLS-1$ //$NON-NLS-2$
+ List<? extends IExpression> params = Arrays.asList(e, new LiteralImpl("integer", String.class)); //$NON-NLS-1$
-
final String expected = "convert(SmallishA.doublishNum, integer)"; //$NON-NLS-1$
IFunction test = new FunctionImpl("convert", params, Integer.class); //$NON-NLS-1$
@@ -236,10 +230,7 @@
public void testVisitConvertFunctionOracleStyle() throws Exception {
String expected = "convert(columnA, integer)"; //$NON-NLS-1$
- IExpression [] params = null;
- params = new IExpression[2];
- params[0] = new ElementImpl(null, "columnA", null, String.class); //$NON-NLS-1$
- params[1] = new LiteralImpl("integer", String.class); //$NON-NLS-1$
+ List<? extends IExpression> params = Arrays.asList(new ElementImpl(null, "columnA", null, String.class), new LiteralImpl("integer", String.class));
IFunction test = new FunctionImpl("convert", params, Integer.class); //$NON-NLS-1$
assertEquals(expected, getString(test));
15 years, 10 months
teiid SVN: r487 - trunk.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-02-24 09:33:28 -0500 (Tue, 24 Feb 2009)
New Revision: 487
Removed:
trunk/salesforce-api/
trunk/sandbox/
Log:
removing empty folders
15 years, 10 months
teiid SVN: r486 - in trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc: postgresql and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-02-24 09:21:49 -0500 (Tue, 24 Feb 2009)
New Revision: 486
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/postgresql/PostgreSQLTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/Translator.java
Log:
TEIID-379 adding a session level set of ansi mode
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-23 21:51:59 UTC (rev 485)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLTranslator.java 2009-02-24 14:21:49 UTC (rev 486)
@@ -22,7 +22,10 @@
package com.metamatrix.connector.jdbc.mysql;
+import java.sql.Connection;
import java.sql.Date;
+import java.sql.SQLException;
+import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
@@ -64,8 +67,29 @@
}
@Override
- public int getTimestampNanoSecondPrecision() {
+ public int getTimestampNanoPrecision() {
return 6;
}
+ @Override
+ public void afterConnectionCreation(Connection connection) {
+ super.afterConnectionCreation(connection);
+
+ Statement stmt = null;
+ try {
+ stmt = connection.createStatement();
+ stmt.execute("set SESSION sql-mode = 'ANSI'"); //$NON-NLS-1$
+ } catch (SQLException e) {
+ getEnvironment().getLogger().logError("Error setting ANSI mode", e); //$NON-NLS-1$
+ } finally {
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ getEnvironment().getLogger().logDetail("Error closing statement", e); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
}
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-23 21:51:59 UTC (rev 485)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLTranslator.java 2009-02-24 14:21:49 UTC (rev 486)
@@ -102,7 +102,7 @@
}
@Override
- public int getTimestampNanoSecondPrecision() {
+ public int getTimestampNanoPrecision() {
return 6;
}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/Translator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/Translator.java 2009-02-23 21:51:59 UTC (rev 485)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/Translator.java 2009-02-24 14:21:49 UTC (rev 486)
@@ -264,11 +264,11 @@
* @return Formatted string
*/
public String formatDateValue(java.util.Date dateObject) {
- if (dateObject instanceof Timestamp && getTimestampNanoSecondPrecision() < 9) {
+ if (dateObject instanceof Timestamp && getTimestampNanoPrecision() < 9) {
Timestamp ts = (Timestamp)dateObject;
Timestamp newTs = new Timestamp(ts.getTime());
- if (getTimestampNanoSecondPrecision() > 0) {
- int mask = 10^(9-getTimestampNanoSecondPrecision());
+ if (getTimestampNanoPrecision() > 0) {
+ int mask = 10^(9-getTimestampNanoPrecision());
newTs.setNanos(ts.getNanos()/mask*mask);
}
dateObject = newTs;
@@ -330,7 +330,7 @@
return null;
}
- public int getTimestampNanoSecondPrecision() {
+ public int getTimestampNanoPrecision() {
return 9;
}
15 years, 10 months
teiid SVN: r485 - trunk.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-02-23 16:51:59 -0500 (Mon, 23 Feb 2009)
New Revision: 485
Added:
trunk/sandbox/
Log:
15 years, 10 months
teiid SVN: r484 - trunk.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-02-23 16:51:25 -0500 (Mon, 23 Feb 2009)
New Revision: 484
Added:
trunk/salesforce-api/
Log:
15 years, 10 months
teiid SVN: r483 - in trunk/server/src/main/java/com/metamatrix: server and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-02-23 14:51:45 -0500 (Mon, 23 Feb 2009)
New Revision: 483
Modified:
trunk/server/src/main/java/com/metamatrix/common/log/DbLogListener.java
trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java
Log:
TEIID-361
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-23 19:46:08 UTC (rev 482)
+++ trunk/server/src/main/java/com/metamatrix/common/log/DbLogListener.java 2009-02-23 19:51:45 UTC (rev 483)
@@ -25,7 +25,6 @@
import java.util.Properties;
import com.metamatrix.common.CommonPlugin;
-import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.log.LogMessage;
@@ -34,27 +33,23 @@
*/
public class DbLogListener implements LogListener {
- public static final String LOG_DB_ENABLED = "metamatrix.log.jdbcDatabase.enabled"; //$NON-NLS-1$
-
private DbLogWriter writer = null;
private boolean enabled = true;
/**
* Listen for log messages and write them to a database.
*/
- public DbLogListener(Properties prop){
+ public DbLogListener(Properties prop, boolean enable){
if (prop == null) {
final String msg = CommonPlugin.Util.getString("DbLogListener.The_Properties_reference_may_not_be_null"); //$NON-NLS-1$
throw new IllegalArgumentException(msg);
}
writer = new DbLogWriter(prop);
writer.initialize();
- enabled = PropertiesUtils.getBooleanProperty(prop, LOG_DB_ENABLED, true);
+ this.enabled = enable;
}
-
public void logMessage(LogMessage msg) {
-
if (enabled) {
writer.logMessage(msg);
}
@@ -63,15 +58,8 @@
public void shutdown() {
writer.shutdown();
}
-
- public void determineIfEnabled(Properties props) {
- boolean isenabled = PropertiesUtils.getBooleanProperty(props, LOG_DB_ENABLED, true);
- enableDBLogging(isenabled);
- }
-
- void enableDBLogging(boolean enable) {
+ public void enableDBLogging(boolean enable) {
enabled = enable;
}
-
}
Modified: trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java 2009-02-23 19:46:08 UTC (rev 482)
+++ trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java 2009-02-23 19:51:45 UTC (rev 483)
@@ -96,7 +96,8 @@
private DbLogListener buildDBLogger() {
Properties currentProps = CurrentConfiguration.getInstance().getProperties();
Properties resultsProps = PropertiesUtils.clone(currentProps, null, true, false);
- return new DbLogListener(resultsProps);
+ boolean enabled = PropertiesUtils.getBooleanProperty(resultsProps, LOG_DB_ENABLED, true);
+ return new DbLogListener(resultsProps, enabled);
}
}
15 years, 10 months
teiid SVN: r482 - trunk/server/src/main/java/com/metamatrix/server.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-02-23 14:46:08 -0500 (Mon, 23 Feb 2009)
New Revision: 482
Added:
trunk/server/src/main/java/com/metamatrix/server/FileLogListenerProvider.java
Modified:
trunk/server/src/main/java/com/metamatrix/server/Configuration.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/main/java/com/metamatrix/server/ServerLogListernerProvider.java
Log:
TEIID-361
Modified: trunk/server/src/main/java/com/metamatrix/server/Configuration.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/Configuration.java 2009-02-23 17:43:19 UTC (rev 481)
+++ trunk/server/src/main/java/com/metamatrix/server/Configuration.java 2009-02-23 19:46:08 UTC (rev 482)
@@ -28,5 +28,7 @@
final String VMNAME = "VMName"; //$NON-NLS-1$
final String VMID = "VMId"; //$NON-NLS-1$
final String CLUSTERNAME = "ClusterName"; //$NON-NLS-1$
+ final String LOGFILE = "LogFile"; //$NON-NLS-1$
+ final String LOGDIR = "LogDir"; //$NON-NLS-1$
}
Added: trunk/server/src/main/java/com/metamatrix/server/FileLogListenerProvider.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/FileLogListenerProvider.java (rev 0)
+++ trunk/server/src/main/java/com/metamatrix/server/FileLogListenerProvider.java 2009-02-23 19:46:08 UTC (rev 482)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.server;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.util.Properties;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.name.Named;
+import com.metamatrix.common.config.CurrentConfiguration;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.core.log.FileLimitSizeLogWriter;
+import com.metamatrix.core.log.LogListener;
+import com.metamatrix.internal.core.log.PlatformLog;
+
+public class FileLogListenerProvider implements Provider<LogListener> {
+
+ @Inject
+ @Named(com.metamatrix.server.Configuration.LOGFILE)
+ String logFile;
+
+ @Inject
+ @Named(com.metamatrix.server.Configuration.LOGDIR)
+ String path;
+
+ @Override
+ public LogListener get() {
+ final PlatformLog log = new PlatformLog();
+ try {
+ FileLimitSizeLogWriter flw = buildFileLogger();
+ log.addListener(flw);
+ } catch (FileNotFoundException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ return log;
+ }
+
+
+ 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/FileLogListenerProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java 2009-02-23 17:43:19 UTC (rev 481)
+++ trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java 2009-02-23 19:46:08 UTC (rev 482)
@@ -64,6 +64,9 @@
bindConstant().annotatedWith(Names.named(Configuration.HOSTNAME)).to(host.getFullName());
bind(Host.class).annotatedWith(Names.named(Configuration.HOST)).toInstance(host);
bindConstant().annotatedWith(Names.named(Configuration.CLUSTERNAME)).to(systemName);
+ bindConstant().annotatedWith(Names.named(Configuration.LOGFILE)).to(StringUtil.replaceAll(host.getFullName(), ".", "_")+"_hc.log"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ bindConstant().annotatedWith(Names.named(Configuration.LOGDIR)).to(host.getLogDirectory());
+
Names.bindProperties(binder(), CurrentConfiguration.getInstance().getProperties());
@@ -77,8 +80,7 @@
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);
+ bind(LogListener.class).toProvider(FileLogListenerProvider.class).in(Scopes.SINGLETON);
// this needs to be removed.
binder().requestStaticInjection(LogManager.class);
Modified: trunk/server/src/main/java/com/metamatrix/server/Main.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/Main.java 2009-02-23 17:43:19 UTC (rev 481)
+++ trunk/server/src/main/java/com/metamatrix/server/Main.java 2009-02-23 19:46:08 UTC (rev 482)
@@ -55,44 +55,49 @@
@Inject
LogListener logListener;
- public static void main(String[] args) throws Exception{
+ public static void main(String[] args) {
- if (args.length < 2 || args.length > 4) {
- System.out.println("Usage: java com.metamatrix.server.Main <vm_name> <host_name>"); //$NON-NLS-1$
- System.exit(1);
- }
+ try {
+ if (args.length < 2 || args.length > 4) {
+ System.out.println("Usage: java com.metamatrix.server.Main <vm_name> <host_name>"); //$NON-NLS-1$
+ System.exit(1);
+ }
- String vmName = args[0];
- String hostName = args[1];
+ String vmName = args[0];
+ String hostName = args[1];
- Host host = null;
- try {
- host = CurrentConfiguration.getInstance().getHost(hostName);
- } catch (ConfigurationException e) {
- }
-
- if (host == null) {
- System.err.println(PlatformPlugin.Util.getString("SocketVMController.5", hostName)); //$NON-NLS-1$
- System.exit(-1);
- }
-
- VMComponentDefn deployedVM = CurrentConfiguration.getInstance().getConfiguration().getVMForHost(hostName, vmName);
- String bindAddress = deployedVM.getBindAddress();
-
- VMNaming.setVMName(vmName);
- VMNaming.setup(host.getFullName(), host.getHostAddress(), bindAddress);
-
- // write info log
- writeInfoLog(host, vmName);
-
- createTempDirectory();
-
- // wire up guice modules
- Main main = loadMain(host, vmName);
-
- // launch the server
-
- main.launchServer();
+ Host host = null;
+ try {
+ host = CurrentConfiguration.getInstance().getHost(hostName);
+ } catch (ConfigurationException e) {
+ }
+
+ if (host == null) {
+ System.err.println(PlatformPlugin.Util.getString("SocketVMController.5", hostName)); //$NON-NLS-1$
+ System.exit(-1);
+ }
+
+ VMComponentDefn deployedVM = CurrentConfiguration.getInstance().getConfiguration().getVMForHost(hostName, vmName);
+ String bindAddress = deployedVM.getBindAddress();
+
+ VMNaming.setVMName(vmName);
+ VMNaming.setup(host.getFullName(), host.getHostAddress(), bindAddress);
+
+ // write info log
+ writeInfoLog(host, vmName);
+
+ createTempDirectory();
+
+ // wire up guice modules
+ Main main = loadMain(host, vmName);
+
+ // launch the server
+
+ main.launchServer();
+ } catch (Throwable e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
}
Modified: trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java 2009-02-23 17:43:19 UTC (rev 481)
+++ trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java 2009-02-23 19:46:08 UTC (rev 482)
@@ -83,6 +83,8 @@
bindConstant().annotatedWith(Names.named(Configuration.VMID)).to(vmID);
bind(Host.class).annotatedWith(Names.named(Configuration.HOST)).toInstance(host);
bindConstant().annotatedWith(Names.named(Configuration.CLUSTERNAME)).to(systemName);
+ bindConstant().annotatedWith(Names.named(Configuration.LOGFILE)).to(StringUtil.replaceAll(host.getFullName(), ".", "_")+".log"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ bindConstant().annotatedWith(Names.named(Configuration.LOGDIR)).to(host.getLogDirectory());
Names.bindProperties(binder(), CurrentConfiguration.getInstance().getProperties());
@@ -101,13 +103,9 @@
// this needs to be removed.
binder().requestStaticInjection(PlatformProxyHelper.class);
+ // Start the log file
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);
Modified: trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java 2009-02-23 17:43:19 UTC (rev 481)
+++ trunk/server/src/main/java/com/metamatrix/server/ServerLogListernerProvider.java 2009-02-23 19:46:08 UTC (rev 482)
@@ -22,15 +22,11 @@
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;
@@ -49,62 +45,52 @@
import com.metamatrix.platform.config.event.ConfigurationChangeEvent;
@Singleton
-class ServerLogListernerProvider implements Provider<LogListener> {
-
- String logFile;
- String path;
- boolean addDBLogger;
- DbLogListener dbLogger;
+class ServerLogListernerProvider extends FileLogListenerProvider {
+ public static final String LOG_DB_ENABLED = "metamatrix.log.jdbcDatabase.enabled"; //$NON-NLS-1$
@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();
+ final PlatformLog log = new PlatformLog();
try {
FileLimitSizeLogWriter flw = buildFileLogger();
- realLog.addListener(flw);
+ log.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) {
+ final DbLogListener dbLogger = buildDBLogger();
+ log.addListener(dbLogger);
+
+ try {
+
+ this.messsgeBus.addListener(ConfigurationChangeEvent.class, new EventObjectListener() {
+
+ public void processEvent(EventObject obj) {
+ if(obj instanceof ConfigurationChangeEvent){
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());
- }
+ try {
+ Configuration currentConfig = CurrentConfiguration.getInstance().getConfiguration();
+ Properties props = currentConfig.getProperties();
+ boolean enabled = PropertiesUtils.getBooleanProperty(props, LOG_DB_ENABLED, true);
+ dbLogger.enableDBLogging(enabled);
+ } catch( ConfigurationException ce ) {
+ LogManager.logError(LogContextsUtil.CommonConstants.CTX_MESSAGE_BUS, ce, ce.getMessage());
}
}
- }
- });
-
- } catch (MessagingException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- }
- return realLog;
+ }
+ }
+ });
+
+ } catch (MessagingException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ return log;
}
private DbLogListener buildDBLogger() {
@@ -112,38 +98,5 @@
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;
- }
-
-
}
15 years, 10 months
teiid SVN: r481 - in trunk: common-core/src/main/java/com/metamatrix/core/util and 51 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-02-23 12:43:19 -0500 (Mon, 23 Feb 2009)
New Revision: 481
Added:
trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java
trunk/connector-api/src/main/java/com/metamatrix/connector/identity/
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/AliasModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BasicFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BindValueVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/DropFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/EscapeSyntaxModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/FunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SQLConversionVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SubstringFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/TranslatedCommand.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/Translator.java
Removed:
trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java
trunk/connector-api/src/main/java/com/metamatrix/connector/pool/
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionListener.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionQueryStrategy.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionStrategy.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/DefaultConnectionListener.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/JDBCSourceConnectionFactory.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/extension/BindValueVisitor.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/FunctionModifier.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/
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mm/MMSingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleResultsTranslator.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSingleIdentityConnectionFactory.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleUserIdentityConnectionFactory.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/xa/JDBCSingleIdentityDSConnectionFactory.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/TestConnectionQueryStrategy.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/MockExampleConnectionFactory.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialResultsTranslator.java
trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServicePropertyNames.java
Modified:
trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
trunk/common-core/src/main/java/com/metamatrix/core/util/StringUtil.java
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/DEFReaderWriter.java
trunk/common-internal/src/main/resources/com/metamatrix/common/i18n.properties
trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connection.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorAnnotations.java
trunk/connector-api/src/main/java/com/metamatrix/connector/api/ExecutionContext.java
trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnection.java
trunk/connector-api/src/main/java/com/metamatrix/connector/identity/ConnectorIdentity.java
trunk/connector-api/src/main/java/com/metamatrix/connector/identity/ConnectorIdentityFactory.java
trunk/connector-api/src/main/java/com/metamatrix/connector/identity/PoolAwareConnection.java
trunk/connector-api/src/main/java/com/metamatrix/connector/identity/SingleIdentity.java
trunk/connector-api/src/main/java/com/metamatrix/connector/identity/SingleIdentityFactory.java
trunk/connector-api/src/main/java/com/metamatrix/connector/identity/UserIdentity.java
trunk/connector-api/src/main/java/com/metamatrix/connector/identity/UserIdentityFactory.java
trunk/connector-api/src/main/java/com/metamatrix/connector/internal/ConnectorPropertyNames.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/JDBCPropertyNames.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/JDBCUpdateExecution.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/SimpleCapabilities.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/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/informix/InformixSQLTranslator.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/ConcatFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/DayWeekQuarterFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ExtractFunctionModifier.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/LocateFunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/Log10FunctionModifier.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.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/DatePartFunctionModifier.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/SqlServerSQLTranslator.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/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/JDBCSourceXAConnection.java
trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/XAJDBCPropertyNames.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/extension/impl/TestDropFunctionModifier.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.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/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/TestOracleTranslator.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-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/TestPerUserPool.java
trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/util/TestFunctionReplacementVisitor.java
trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.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/connection/SalesforceConnection.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/SourceConnectionFactory.java
trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialFunctionModifier.java
trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialSQLTranslator.java
trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.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/ConnectorWrapper.java
trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ExecutionContextImpl.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/ConnectionWrapper.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/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorManagerImpl.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/pooling/connector/TestConnectionWrapper.java
trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.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/resources/xml-vp/xmlvp.DEF
Log:
TEIID-164 TEIID-352 removing complexity from the JDBC connector. targetting a scenario where only the translator, connector, and the capabilities should need to be overriden. This is an intermediate check-in. Identity management for connectors will be merged with the base api.
Modified: trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/common-core/src/main/java/com/metamatrix/common/util/PropertiesUtils.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -29,6 +29,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -42,6 +43,7 @@
import com.metamatrix.core.CorePlugin;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.util.ArgCheck;
+import com.metamatrix.core.util.StringUtil;
/**
@@ -938,4 +940,53 @@
return bPass;
}
+
+ public static void setBeanProperties(Object bean, Properties props, String prefix) {
+ // Move all prop names to lower case so we can use reflection to get
+ // method names and look them up in the connection props.
+ final Properties connProps = lowerCaseAllPropNames(props);
+ final Method[] methods = bean.getClass().getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ final Method method = methods[i];
+ final String methodName = method.getName();
+ // If setter ...
+ if ( methodName.startsWith("set") && method.getParameterTypes().length == 1 ) { //$NON-NLS-1$
+ // Get the property name
+ final String propertyName = methodName.substring(3); // remove the "set"
+ String shortName = propertyName.toLowerCase();
+ String propertyValue = null;
+ if (prefix != null) {
+ propertyValue = connProps.getProperty(prefix + "." + shortName);
+ } else {
+ propertyValue = connProps.getProperty(shortName);
+ }
+ if (propertyValue == null) {
+ continue;
+ }
+ final Class<?> argType = method.getParameterTypes()[0];
+ try {
+ final Object[] params = new Object[] {StringUtil.valueOf(propertyValue, argType)};
+ method.invoke(bean, params);
+ } catch (Throwable e) {
+ throw new InvalidPropertyException(propertyName, propertyValue, argType, e);
+ }
+ }
+ }
+ }
+
+ private static Properties lowerCaseAllPropNames(final Properties connectionProps) {
+ final Properties lcProps = new Properties();
+ final Iterator itr = connectionProps.keySet().iterator();
+ while ( itr.hasNext() ) {
+ final String name = (String) itr.next();
+ Object propValue = connectionProps.get(name);
+ if (propValue instanceof String) {
+ // we're only interested in prop values of type String
+ // here since we'll be looking for params to reflected methods
+ lcProps.setProperty(name.toLowerCase(), (String)propValue);
+ } // if
+ }
+ return lcProps;
+ }
+
}
Modified: trunk/common-core/src/main/java/com/metamatrix/core/util/StringUtil.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/util/StringUtil.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/common-core/src/main/java/com/metamatrix/core/util/StringUtil.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -983,7 +983,8 @@
* @param type
* @return
*/
- public static <T> T valueOf(String value, Class<T> type){
+ @SuppressWarnings("unchecked")
+ public static <T> T valueOf(String value, Class<T> type){
if(type == String.class) {
return (T) value;
@@ -992,7 +993,7 @@
return (T) Boolean.valueOf(value);
}
else if (type == Integer.class || type == Integer.TYPE) {
- return (T) Integer.valueOf(value);
+ return (T) Integer.decode(value);
}
else if (type == Float.class || type == Float.TYPE) {
return (T) Float.valueOf(value);
@@ -1001,10 +1002,10 @@
return (T) Double.valueOf(value);
}
else if (type == Long.class || type == Long.TYPE) {
- return (T) Long.valueOf(value);
+ return (T) Long.decode(value);
}
else if (type == Short.class || type == Short.TYPE) {
- return (T) Short.valueOf(value);
+ return (T) Short.decode(value);
}
else if (type.isAssignableFrom(List.class)) {
return (T)new ArrayList<String>(Arrays.asList(value.split(","))); //$NON-NLS-1$
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/DEFReaderWriter.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/DEFReaderWriter.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/DEFReaderWriter.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -37,6 +37,7 @@
import org.jdom.Element;
import org.jdom.JDOMException;
+import com.metamatrix.common.CommonPlugin;
import com.metamatrix.common.config.api.ComponentType;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.config.util.InvalidConfigurationElementException;
@@ -79,7 +80,7 @@
loadConnectorBindings(vdbDefn, root);
} catch (JDOMException e) {
- throw new IOException("VDBDefnXMLHelper.Unable_to_read_defn_file");//$NON-NLS-1$
+ throw new IOException(CommonPlugin.Util.getString("VDBDefnXMLHelper.Unable_to_read_defn_file"));//$NON-NLS-1$
}
return vdbDefn;
}
Modified: trunk/common-internal/src/main/resources/com/metamatrix/common/i18n.properties
===================================================================
--- trunk/common-internal/src/main/resources/com/metamatrix/common/i18n.properties 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/common-internal/src/main/resources/com/metamatrix/common/i18n.properties 2009-02-23 17:43:19 UTC (rev 481)
@@ -3097,3 +3097,5 @@
BasicApplication.Failed_while_installing_service_of_type__1=Failed while installing service of type
+VDBDefnXMLHelper.Unable_to_read_defn_file=Unable to read DEF file.
+
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-23 16:17:44 UTC (rev 480)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/Connection.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -22,9 +22,9 @@
package com.metamatrix.connector.api;
+import com.metamatrix.connector.identity.PoolAwareConnection;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.pool.PoolAwareConnection;
/**
* <p>Represents a connection to this connector. A connection will be obtained
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorAnnotations.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorAnnotations.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/ConnectorAnnotations.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -27,8 +27,8 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import com.metamatrix.connector.identity.ConnectorIdentityFactory;
import com.metamatrix.connector.internal.ConnectorPropertyNames;
-import com.metamatrix.connector.pool.ConnectorIdentityFactory;
public class ConnectorAnnotations {
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-23 16:17:44 UTC (rev 480)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/api/ExecutionContext.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -24,9 +24,9 @@
import java.io.Serializable;
-import com.metamatrix.connector.pool.ConnectorIdentity;
-import com.metamatrix.connector.pool.ConnectorIdentityFactory;
-import com.metamatrix.connector.pool.SingleIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentityFactory;
+import com.metamatrix.connector.identity.SingleIdentity;
/**
* The security context provides information about the user context in which
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-23 16:17:44 UTC (rev 480)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnection.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -22,6 +22,7 @@
package com.metamatrix.connector.basic;
+import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorCapabilities;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.Execution;
@@ -29,12 +30,11 @@
import com.metamatrix.connector.api.ProcedureExecution;
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.UpdateExecution;
+import com.metamatrix.connector.identity.ConnectorIdentity;
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
@@ -44,7 +44,7 @@
* {@link #createUpdateExecution(IProcedure, ExecutionContext, RuntimeMetadata)}
* as necessary.
*/
-public abstract class BasicConnection implements PoolAwareConnection {
+public abstract class BasicConnection implements Connection {
@Override
public Execution createExecution(ICommand command,
@@ -70,26 +70,34 @@
public UpdateExecution createUpdateExecution(ICommand command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
throw new ConnectorException("Unsupported Execution");
}
-
+
@Override
public boolean isAlive() {
return true;
}
@Override
+ public ConnectorCapabilities getCapabilities() {
+ return null;
+ }
+
+ /**
+ * Called by the pool to indicate that the connection was returned to the pool.
+ * The actual close call will be made when the pool wants to purge this connection.
+ */
public void closeCalled() {
}
- @Override
+ /**
+ * 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
+ */
public void setConnectorIdentity(ConnectorIdentity context)
throws ConnectorException {
}
- @Override
- public ConnectorCapabilities getCapabilities() {
- return null;
- }
-
}
Deleted: trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/basic/BasicConnector.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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.connector.basic;
-
-import com.metamatrix.connector.api.Connector;
-
-public abstract class BasicConnector implements Connector {
-
-}
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-23 17:43:19 UTC (rev 481)
@@ -0,0 +1,7 @@
+package com.metamatrix.connector.basic;
+
+import com.metamatrix.connector.api.Connector;
+
+public abstract class BasicConnector implements Connector {
+
+}
Copied: trunk/connector-api/src/main/java/com/metamatrix/connector/identity (from rev 475, trunk/connector-api/src/main/java/com/metamatrix/connector/pool)
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/identity/ConnectorIdentity.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/ConnectorIdentity.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/identity/ConnectorIdentity.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.connector.pool;
+package com.metamatrix.connector.identity;
/**
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/identity/ConnectorIdentityFactory.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/ConnectorIdentityFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/identity/ConnectorIdentityFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.connector.pool;
+package com.metamatrix.connector.identity;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/identity/PoolAwareConnection.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/PoolAwareConnection.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/identity/PoolAwareConnection.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.connector.pool;
+package com.metamatrix.connector.identity;
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorException;
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/identity/SingleIdentity.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/SingleIdentity.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/identity/SingleIdentity.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -22,20 +22,15 @@
/*
*/
-package com.metamatrix.connector.pool;
+package com.metamatrix.connector.identity;
-import com.metamatrix.connector.api.ExecutionContext;
/**
* This class represents a single ConnectorIdentity. All the connections are treated the same.
*/
public class SingleIdentity implements ConnectorIdentity {
- /**
- * Construct with a context
- * @param context The context
- */
- public SingleIdentity(ExecutionContext context){
+ public SingleIdentity(){
}
/**
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/identity/SingleIdentityFactory.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/SingleIdentityFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/identity/SingleIdentityFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.connector.pool;
+package com.metamatrix.connector.identity;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
@@ -30,7 +30,7 @@
@Override
public ConnectorIdentity createIdentity(ExecutionContext context)
throws ConnectorException {
- return new SingleIdentity(context);
+ return new SingleIdentity();
}
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/identity/UserIdentity.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/UserIdentity.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/identity/UserIdentity.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -20,23 +20,26 @@
* 02110-1301 USA.
*/
-package com.metamatrix.connector.pool;
+package com.metamatrix.connector.identity;
-import com.metamatrix.connector.api.ExecutionContext;
/**
- * This class represents a ConnectorIdentity based on user name. Connections are
- * pooled based on user name.
+ * This class represents a ConnectorIdentity keyed on a username with
+ * a mapped identity
*/
public class UserIdentity implements ConnectorIdentity {
- private ExecutionContext context;
+ private String username;
+ private String mappedUser;
+ private String password;
/**
* Construct with a security context
* @param context The context
*/
- public UserIdentity(ExecutionContext context){
- this.context = context;
+ public UserIdentity(String username, String mappedUser, String password){
+ this.username = username;
+ this.mappedUser = mappedUser;
+ this.password = password;
}
/**
@@ -51,7 +54,7 @@
if (obj instanceof UserIdentity) {
UserIdentity that = (UserIdentity)obj;
- return this.context.getUser().equals(that.context.getUser());
+ return username.equals(that.username);
}
return false;
@@ -61,10 +64,18 @@
* Get hash code, based on user name
*/
public int hashCode(){
- return context.getUser().hashCode();
+ return username.hashCode();
}
public String toString(){
- return "UserIdentity " + context.getUser(); //$NON-NLS-1$
+ return "UserIdentity " + username; //$NON-NLS-1$
}
+
+ public String getMappedUser() {
+ return mappedUser;
+ }
+
+ public String getPassword() {
+ return password;
+ }
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/identity/UserIdentityFactory.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/pool/UserIdentityFactory.java 2009-02-16 21:35:28 UTC (rev 475)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/identity/UserIdentityFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -20,28 +20,57 @@
* 02110-1301 USA.
*/
-package com.metamatrix.connector.pool;
+package com.metamatrix.connector.identity;
import com.metamatrix.connector.DataPlugin;
import com.metamatrix.connector.api.ConnectorException;
+import com.metamatrix.connector.api.CredentialMap;
import com.metamatrix.connector.api.ExecutionContext;
/**
- * Segregates connections by user. It is assumed that no single identity
- * exists.
- *
- * If multiple users use the same credentials, consider using a more specific
- * form of connector identity to prevent pool fragmentation.
+ * Segregates connections by user determined by the CredentialMap.
*/
public class UserIdentityFactory implements ConnectorIdentityFactory {
+ private boolean useCredentialMap;
+ private boolean adminConnectionsAllowed = true;
+ private String connectorName;
+
@Override
public ConnectorIdentity createIdentity(ExecutionContext context)
throws ConnectorException {
if (context == null) {
+ if (adminConnectionsAllowed) {
+ return new SingleIdentity();
+ }
throw new ConnectorException(DataPlugin.Util.getString("UserIdentityFactory.single_identity_not_supported")); //$NON-NLS-1$
}
- return new UserIdentity(context);
+ Object payload = context.getTrustedPayload();
+ if (!(payload instanceof CredentialMap)) {
+ if (useCredentialMap) {
+ throw new ConnectorException(DataPlugin.Util.getString("UserIdentityFactory.single_identity_not_supported")); //$NON-NLS-1$
+ }
+ return new SingleIdentity();
+ }
+ CredentialMap credMap = (CredentialMap)payload;
+ String user = credMap.getUser(connectorName);
+ String password = credMap.getPassword(connectorName);
+ if (user == null || password == null) {
+ throw new ConnectorException("Payload missing credentials for " + connectorName); //$NON-NLS-1$
+ }
+ return new UserIdentity(context.getUser(), user, password);
}
+ public void setConnectorName(String connectorName) {
+ this.connectorName = connectorName;
+ }
+
+ public void setUseCredentialMap(boolean useCredentialMap) {
+ this.useCredentialMap = useCredentialMap;
+ }
+
+ public void setAdminConnectionsAllowed(boolean adminConnectionsAllowed) {
+ this.adminConnectionsAllowed = adminConnectionsAllowed;
+ }
+
}
Modified: trunk/connector-api/src/main/java/com/metamatrix/connector/internal/ConnectorPropertyNames.java
===================================================================
--- trunk/connector-api/src/main/java/com/metamatrix/connector/internal/ConnectorPropertyNames.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connector-api/src/main/java/com/metamatrix/connector/internal/ConnectorPropertyNames.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -81,42 +81,25 @@
public static final String CONNECTOR_ID = "ConnectorID"; //$NON-NLS-1$
/**
- * The environment property used as a flag to deregister the driver
- */
- public static final String DEREGISTER_DRIVER = "deregisterDriver"; //$NON-NLS-1$
-
- /**
- * The environment property used as a flag to deregister the driver by ClassLoader
- */
- public static final String DEREGISTER_BY_CLASSLOADER = "deregisterByClassLoader"; //$NON-NLS-1$
-
- /**
- * The environment property used as a flag to deregister the driver by ClassName
- */
- public static final String DEREGISTER_BY_CLASSNAME = "deregisterByClassName"; //$NON-NLS-1$
-
- /**
- * The environment property used to identify a class loader to load connector.
- * The default class loader will be used if it is not defined.
- * This is an optional property.
- * @since 4.0
- */
- public static final String CONNECTOR_CLASS_LOADER = "ConnectorClassLoader"; //$NON-NLS-1$
-
- /**
* The name of the VM where the connector is running on.
* @since 4.0
*/
public static final String CONNECTOR_VM_NAME = "ConnectorVMName"; //$NON-NLS-1$
- public static final String USE_RESULTSET_CACHE = "ResultSetCacheEnabled"; //$NON-NLS-1$
- public static final String MAX_RESULTSET_CACHE_SIZE = "ResultSetCacheMaxSize"; //$NON-NLS-1$
- public static final String MAX_RESULTSET_CACHE_AGE = "ResultSetCacheMaxAge"; //$NON-NLS-1$
- public static final String RESULTSET_CACHE_SCOPE = "ResultSetCacheScope"; //$NON-NLS-1$
-
/**
* Indicates whether the connector represents a pooled resource. If it does, then
* synchronous workers will be used.
*/
public static final String SYNCH_WORKERS = "SynchWorkers"; //$NON-NLS-1$
+
+ public static final String USING_CUSTOM_CLASSLOADER = "UsingCustomClassloader"; //$NON-NLS-1$
+
+ public static final String CONNECTOR_CLASSPATH = "ConnectorClassPath"; //$NON-NLS-1$
+
+ public static final String IS_XA = "IsXA"; //$NON-NLS-1$
+
+ public static final String USE_CREDENTIALS_MAPS = "UseCredentialMaps"; //$NON-NLS-1$
+
+ public static final String ADMIN_CONNECTIONS_ALLOWED = "AdminConnectionsAllowed"; //$NON-NLS-1$
+
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionListener.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionListener.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionListener.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,48 +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;
-
-import java.sql.Connection;
-
-import com.metamatrix.connector.api.ConnectorEnvironment;
-
-/**
- * Connection listner for the life cycle events for the connection
- */
-public interface ConnectionListener {
-
- /**
- * This call will be invoked right after the connection to the datasource
- * is open by the <code>JDBCConnectionFactory</code>. This will invoked every
- * connection in pool.
- * @param connection
- */
- void afterConnectionCreation(Connection connection, ConnectorEnvironment env);
- /**
- * This call will be invoked just before the connection to the datasource
- * is relased to the connection pool or closed, which ever action taken by
- * the <code>JDBCConnectionFactory</code>
- * @param connection
- */
- void beforeConnectionClose(Connection connection, ConnectorEnvironment env );
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionQueryStrategy.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionQueryStrategy.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionQueryStrategy.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,66 +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;
-
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-/**
- * Connection strategy that tests a connection by running a test query.
- */
-public class ConnectionQueryStrategy implements ConnectionStrategy{
- private String connTestquery;
-
- public ConnectionQueryStrategy(String query){
- this.connTestquery = query;
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.ConnectionStrategy#isConnectionAlive()
- */
- public boolean isConnectionAlive(Connection connection) {
- Statement statement = null;
- try {
- if(connection.isClosed()){
- return false;
- }
- statement = connection.createStatement();
- statement.executeQuery(connTestquery);
- } catch(SQLException e) {
- return false;
- } finally {
- if ( statement != null ) {
- try {
- statement.close();
- statement=null;
- } catch ( SQLException e ) {
- }
- }
- }
- return true;
- }
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionStrategy.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionStrategy.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ConnectionStrategy.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,36 +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;
-
-import java.sql.Connection;
-
-public interface ConnectionStrategy {
-
- /**
- * @return true if the connection is alive. false if the connection is closed or failed.
- */
- boolean isConnectionAlive(Connection connection);
-
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/DefaultConnectionListener.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/DefaultConnectionListener.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/DefaultConnectionListener.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.SQLException;
-
-import com.metamatrix.connector.api.ConnectorEnvironment;
-
-/**
- * A default connection listener object, on a given connection factory.
- * @author Ramesh Reddy
- */
-public class DefaultConnectionListener implements ConnectionListener {
- // Since this going to used inside a pool, we would like to report only once
- boolean alreadyReportedDetails = false;
-
- /**
- * defect request 13979 & 13978
- */
- public void afterConnectionCreation(Connection connection, ConnectorEnvironment env) {
-
- if (alreadyReportedDetails) {
- return;
- }
-
- alreadyReportedDetails = true;
- // now dig some details about this driver/database for log.
- try {
- StringBuffer sb = new StringBuffer();
- DatabaseMetaData dbmd = connection.getMetaData();
- sb.append("Commit=").append(connection.getAutoCommit()); //$NON-NLS-1$
- sb.append(";DatabaseProductName=").append(dbmd.getDatabaseProductName()); //$NON-NLS-1$
- sb.append(";DatabaseProductVersion=").append(dbmd.getDatabaseProductVersion()); //$NON-NLS-1$
- sb.append(";DriverMajorVersion=").append(dbmd.getDriverMajorVersion()); //$NON-NLS-1$
- sb.append(";DriverMajorVersion=").append(dbmd.getDriverMinorVersion()); //$NON-NLS-1$
- sb.append(";DriverName=").append(dbmd.getDriverName()); //$NON-NLS-1$
- sb.append(";DriverVersion=").append(dbmd.getDriverVersion()); //$NON-NLS-1$
- sb.append(";IsolationLevel=").append(dbmd.getDefaultTransactionIsolation()); //$NON-NLS-1$
-
- env.getLogger().logInfo(sb.toString());
- } catch (SQLException e) {
- String errorStr = JDBCPlugin.Util.getString("ConnectionListener.failed_to_report_jdbc_connection_details"); //$NON-NLS-1$
- env.getLogger().logInfo(errorStr);
- }
-
- }
-
- /**
- * defect request 13979 & 13978
- */
- public void beforeConnectionClose(Connection connection, ConnectorEnvironment env) {
- }
-}
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCBaseExecution.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -37,11 +37,10 @@
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.basic.BasicExecution;
-import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
-import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
+import com.metamatrix.connector.identity.ConnectorIdentity;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.language.ICommand;
-import com.metamatrix.connector.pool.ConnectorIdentity;
/**
*/
@@ -53,8 +52,7 @@
// Passed to constructor
protected Connection connection;
- protected SQLTranslator sqlTranslator;
- protected ResultsTranslator resultsTranslator;
+ protected Translator sqlTranslator;
protected ConnectorIdentity id;
protected ConnectorLogger logger;
protected ExecutionContext context;
@@ -71,14 +69,12 @@
// ===========================================================================================================================
protected JDBCBaseExecution(Connection connection,
- SQLTranslator sqlTranslator,
- ResultsTranslator resultsTranslator,
+ Translator sqlTranslator,
ConnectorLogger logger,
Properties props,
ExecutionContext context) {
this.connection = connection;
this.sqlTranslator = sqlTranslator;
- this.resultsTranslator = resultsTranslator;
this.logger = logger;
this.context = context;
@@ -88,7 +84,7 @@
}
fetchSize = PropertiesUtils.getIntProperty(props, JDBCPropertyNames.FETCH_SIZE, context.getBatchSize());
- int max = resultsTranslator.getMaxResultRows();
+ int max = sqlTranslator.getMaxResultRows();
if (max > 0) {
fetchSize = Math.min(fetchSize, max);
}
@@ -224,8 +220,8 @@
}
protected void setSizeContraints(Statement statement) throws SQLException {
- if (resultsTranslator.getMaxResultRows() > 0) {
- statement.setMaxRows(resultsTranslator.getMaxResultRows());
+ if (sqlTranslator.getMaxResultRows() > 0) {
+ statement.setMaxRows(sqlTranslator.getMaxResultRows());
}
statement.setFetchSize(fetchSize);
}
@@ -270,7 +266,7 @@
return this.connection;
}
- public SQLTranslator getSqlTranslator() {
+ public Translator getSqlTranslator() {
return sqlTranslator;
}
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCConnector.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -24,66 +24,119 @@
*/
package com.metamatrix.connector.jdbc;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Enumeration;
+import java.util.Properties;
+
+import javax.sql.DataSource;
+import javax.sql.XADataSource;
+
+import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.connector.DataPlugin;
import com.metamatrix.connector.api.Connection;
-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.CredentialMap;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
-import com.metamatrix.connector.pool.ConnectorIdentity;
-import com.metamatrix.connector.pool.ConnectorIdentityFactory;
+import com.metamatrix.connector.identity.ConnectorIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentityFactory;
+import com.metamatrix.connector.identity.SingleIdentity;
+import com.metamatrix.connector.identity.UserIdentity;
+import com.metamatrix.connector.internal.ConnectorPropertyNames;
+import com.metamatrix.connector.jdbc.translator.Translator;
+import com.metamatrix.connector.jdbc.xa.JDBCSourceXAConnection;
+import com.metamatrix.connector.jdbc.xa.XAJDBCPropertyNames;
+import com.metamatrix.connector.xa.api.TransactionContext;
+import com.metamatrix.connector.xa.api.XAConnection;
+import com.metamatrix.connector.xa.api.XAConnector;
+import com.metamatrix.core.MetaMatrixCoreException;
+import com.metamatrix.core.util.ReflectionHelper;
/**
* JDBC implementation of Connector interface.
*/
@ConnectionPooling
-public class JDBCConnector implements Connector, ConnectorIdentityFactory {
- protected ConnectorEnvironment environment;
+public class JDBCConnector implements XAConnector, ConnectorIdentityFactory {
+
+ public static final String INVALID_AUTHORIZATION_SPECIFICATION_NO_SUBCLASS = "28000"; //$NON-NLS-1$
+
+ static final int NO_ISOLATION_LEVEL_SET = Integer.MIN_VALUE;
+
+ enum TransactionIsolationLevel {
+ TRANSACTION_READ_UNCOMMITTED(java.sql.Connection.TRANSACTION_READ_UNCOMMITTED),
+ TRANSACTION_READ_COMMITTED(java.sql.Connection.TRANSACTION_READ_COMMITTED),
+ TRANSACTION_REPEATABLE_READ(java.sql.Connection.TRANSACTION_REPEATABLE_READ),
+ TRANSACTION_SERIALIZABLE(java.sql.Connection.TRANSACTION_SERIALIZABLE),
+ TRANSACTION_NONE(java.sql.Connection.TRANSACTION_NONE);
+
+ private int connectionContant;
+
+ private TransactionIsolationLevel(int connectionConstant) {
+ this.connectionContant = connectionConstant;
+ }
+
+ public int getConnectionConstant() {
+ return connectionContant;
+ }
+ }
+
+ protected ConnectorEnvironment environment;
private ConnectorLogger logger;
- private JDBCSourceConnectionFactory factory;
private ConnectorCapabilities capabilities;
+ private Translator sqlTranslator;
+ private DataSource ds;
+ private XADataSource xaDs;
+ private int transIsoLevel = NO_ISOLATION_LEVEL_SET;
- static ConnectorCapabilities createCapabilities(ConnectorEnvironment environment, ClassLoader loader)
+ private boolean useCredentialMap;
+ private boolean adminConnectionsAllowed = true;
+ private String connectorName;
+
+ @Override
+ public ConnectorIdentity createIdentity(ExecutionContext context)
throws ConnectorException {
- //create Capabilities
- String className = environment.getProperties().getProperty(JDBCPropertyNames.EXT_CAPABILITY_CLASS);
- if(className == null){
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnection.Property_{0}_is_required,_but_not_defined_1", JDBCPropertyNames.EXT_CAPABILITY_CLASS)); //$NON-NLS-1$
- }
-
- try {
- Class capabilitiesClass = loader.loadClass(className);
- ConnectorCapabilities result = (ConnectorCapabilities) capabilitiesClass.newInstance();
- if(result instanceof JDBCCapabilities) {
- String setCriteriaBatchSize = environment.getProperties().getProperty(JDBCPropertyNames.SET_CRITERIA_BATCH_SIZE);
- if(setCriteriaBatchSize != null) {
- int maxInCriteriaSize = Integer.parseInt(setCriteriaBatchSize);
- if(maxInCriteriaSize > 0) {
- ((JDBCCapabilities)result).setMaxInCriteriaSize(maxInCriteriaSize);
- }
- }
- }
- return result;
- } catch (Exception e) {
- throw new ConnectorException(e);
+ if (context == null) {
+ if (adminConnectionsAllowed) {
+ return new SingleIdentity();
+ }
+ throw new ConnectorException(DataPlugin.Util.getString("UserIdentityFactory.single_identity_not_supported")); //$NON-NLS-1$
}
+ Object payload = context.getTrustedPayload();
+ if (!(payload instanceof CredentialMap)) {
+ if (useCredentialMap) {
+ throw new ConnectorException(JDBCPlugin.Util.getString("JDBCUserIdentityConnectionFactory.Unable_to_get_credentials")); //$NON-NLS-1$
+ }
+ return new SingleIdentity();
+ }
+ CredentialMap credMap = (CredentialMap)payload;
+ String user = credMap.getUser(connectorName);
+ String password = credMap.getPassword(connectorName);
+ if (user == null || password == null) {
+ throw new ConnectorException("Payload missing credentials for " + connectorName); //$NON-NLS-1$
+ }
+ return new UserIdentity(context.getUser(), user, password);
}
-
- public void stop() {
- cleanUp();
-
- logger.logInfo(JDBCPlugin.Util.getString("JDBCConnector.JDBCConnector_stopped._3")); //$NON-NLS-1$
- }
+
+ public void setConnectorName(String connectorName) {
+ this.connectorName = connectorName;
+ }
+
+ public void setUseCredentialMap(boolean useCredentialMap) {
+ this.useCredentialMap = useCredentialMap;
+ }
+
+ public void setAdminConnectionsAllowed(boolean adminConnectionsAllowed) {
+ this.adminConnectionsAllowed = adminConnectionsAllowed;
+ }
- public void cleanUp() {
- //Shutdown Factory
- if(this.factory != null) {
- this.factory.shutdown();
- }
- }
-
@Override
public void start(ConnectorEnvironment environment)
throws ConnectorException {
@@ -93,42 +146,289 @@
logger.logInfo(JDBCPlugin.Util.getString("JDBCConnector.JDBCConnector_initialized._1")); //$NON-NLS-1$
capabilities = createCapabilities(environment, Thread.currentThread().getContextClassLoader());
- String scfClassName = environment.getProperties().getProperty(JDBCPropertyNames.EXT_CONNECTION_FACTORY_CLASS, "com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory"); //$NON-NLS-1$
+ Properties connectionProps = environment.getProperties();
+
+ // Get the JDBC properties ...
+ String dataSourceClassName = connectionProps.getProperty(JDBCPropertyNames.CONNECTION_SOURCE_CLASS);
+
+ // Verify required items
+ if (dataSourceClassName == null || dataSourceClassName.trim().length() == 0) {
+ throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Missing_JDBC_driver_class_name_1")); //$NON-NLS-1$
+ }
+ dataSourceClassName = dataSourceClassName.trim();
+
+ String levelStr = connectionProps.getProperty(JDBCPropertyNames.TRANSACTION_ISOLATION_LEVEL);
+
+ if(levelStr != null && levelStr.trim().length() != 0){
+ transIsoLevel = TransactionIsolationLevel.valueOf(levelStr.toUpperCase()).getConnectionConstant();
+ }
+
try {
- //create source connection factory
- Class scfClass = Thread.currentThread().getContextClassLoader().loadClass(scfClassName);
- this.factory = (JDBCSourceConnectionFactory) scfClass.newInstance();
- factory.initialize(environment);
- } catch (ClassNotFoundException e1) {
- throw new ConnectorException(e1);
- } catch (InstantiationException e2) {
- throw new ConnectorException(e2);
- } catch (IllegalAccessException e3) {
- throw new ConnectorException(e3);
- } catch (ConnectorException e5) {
- this.cleanUp();
- throw e5;
+ String className = environment.getProperties().getProperty(JDBCPropertyNames.EXT_TRANSLATOR_CLASS, Translator.class.getName());
+ this.sqlTranslator = (Translator)ReflectionHelper.create(className, null, Thread.currentThread().getContextClassLoader());
+ } catch (MetaMatrixCoreException e) {
+ throw new ConnectorException(e);
}
+ sqlTranslator.initialize(environment);
+
+ if (this.adminConnectionsAllowed) {
+ testConnection();
+ }
logger.logInfo(JDBCPlugin.Util.getString("JDBCConnector.JDBCConnector_started._4")); //$NON-NLS-1$
}
+
+ private void testConnection() throws ConnectorException {
+ Connection connection = null;
+ try {
+ connection = getConnection(null);
+ } catch (ConnectorException e) {
+ SQLException ex = (SQLException)e.getCause();
+ String sqlState = ex.getSQLState();
+ if (sqlState != null && INVALID_AUTHORIZATION_SPECIFICATION_NO_SUBCLASS.equals(sqlState)) {
+ throw e;
+ }
+ this.logger.logError(e.getMessage(), e);
+ } finally {
+ if (connection != null) {
+ connection.close();
+ }
+ }
+ }
+
+ @Override
+ public void stop() {
+ /*
+ * attempt to deregister drivers that may have been implicitly registered
+ * with the driver manager
+ */
+ Enumeration drivers = DriverManager.getDrivers();
- /*
- * @see com.metamatrix.data.Connector#getConnection(com.metamatrix.data.SecurityContext)
- */
+ String driverClassname = this.environment.getProperties().getProperty(JDBCPropertyNames.CONNECTION_SOURCE_CLASS);
+ boolean usingCustomClassLoader = PropertiesUtils.getBooleanProperty(this.environment.getProperties(), ConnectorPropertyNames.USING_CUSTOM_CLASSLOADER, false);
+
+ while(drivers.hasMoreElements()){
+ Driver tempdriver = (Driver)drivers.nextElement();
+ if(tempdriver.getClass().getClassLoader() != this.getClass().getClassLoader()) {
+ continue;
+ }
+ if(usingCustomClassLoader || tempdriver.getClass().getName().equals(driverClassname)) {
+ try {
+ DriverManager.deregisterDriver(tempdriver);
+ } catch (Throwable e) {
+ this.environment.getLogger().logError(e.getMessage());
+ }
+ }
+ }
+
+ logger.logInfo(JDBCPlugin.Util.getString("JDBCConnector.JDBCConnector_stopped._3")); //$NON-NLS-1$
+ }
+
+ @Override
public Connection getConnection(ExecutionContext context) throws ConnectorException {
- return factory.getConnection(context);
+ DataSource dataSource = getDataSource();
+ if (dataSource == null) {
+ return getXAConnection(context, null);
+ }
+ java.sql.Connection conn = null;
+ try {
+ if (context == null || context.getConnectorIdentity() instanceof SingleIdentity) {
+ conn = dataSource.getConnection();
+ } else if (context.getConnectorIdentity() instanceof UserIdentity) {
+ UserIdentity id = (UserIdentity)context.getConnectorIdentity();
+ conn = dataSource.getConnection(id.getMappedUser(), id.getPassword());
+ }
+ setDefaultTransactionIsolationLevel(conn);
+ } catch (SQLException e) {
+ throw new ConnectorException(e);
+ }
+ return new JDBCSourceConnection(conn, this.environment, sqlTranslator);
}
+
+ @Override
+ public XAConnection getXAConnection(
+ ExecutionContext context,
+ TransactionContext transactionContext) throws ConnectorException {
+ XADataSource xaDataSource = getXADataSource();
+ if (xaDataSource == null) {
+ throw new UnsupportedOperationException("Connector is not XA capable");
+ }
+ javax.sql.XAConnection conn = null;
+ try {
+ if (context == null || context.getConnectorIdentity() instanceof SingleIdentity) {
+ conn = xaDataSource.getXAConnection();
+ } else if (context.getConnectorIdentity() instanceof UserIdentity) {
+ UserIdentity id = (UserIdentity)context.getConnectorIdentity();
+ conn = xaDataSource.getXAConnection(id.getMappedUser(), id.getPassword());
+ }
+ java.sql.Connection c = conn.getConnection();
+ setDefaultTransactionIsolationLevel(c);
+ return new JDBCSourceXAConnection(c, conn, this.environment, sqlTranslator);
+ } catch (SQLException e) {
+ throw new ConnectorException(e);
+ }
+ }
@Override
public ConnectorCapabilities getCapabilities() {
return capabilities;
}
- @Override
- public ConnectorIdentity createIdentity(ExecutionContext context)
- throws ConnectorException {
- return factory.createIdentity(context);
+ static ConnectorCapabilities createCapabilities(ConnectorEnvironment environment, ClassLoader loader)
+ throws ConnectorException {
+ //create Capabilities
+ String className = environment.getProperties().getProperty(JDBCPropertyNames.EXT_CAPABILITY_CLASS, JDBCCapabilities.class.getName());
+ try {
+ ConnectorCapabilities result = (ConnectorCapabilities)ReflectionHelper.create(className, null, loader);
+ if(result instanceof JDBCCapabilities) {
+ String setCriteriaBatchSize = environment.getProperties().getProperty(JDBCPropertyNames.SET_CRITERIA_BATCH_SIZE);
+ if(setCriteriaBatchSize != null) {
+ int maxInCriteriaSize = Integer.parseInt(setCriteriaBatchSize);
+ if(maxInCriteriaSize > 0) {
+ ((JDBCCapabilities)result).setMaxInCriteriaSize(maxInCriteriaSize);
+ }
+ }
+ }
+ return result;
+ } catch (Exception e) {
+ throw new ConnectorException(e);
+ }
}
+
+ protected void createDataSources(String dataSourceClassName, final Properties connectionProps) throws ConnectorException {
+ // create data source
+ Object temp = null;
+ try {
+ temp = ReflectionHelper.create(dataSourceClassName, null, Thread.currentThread().getContextClassLoader());
+ } catch (MetaMatrixCoreException e) {
+ throw new ConnectorException(e,JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Unable_to_load_the_JDBC_driver_class_6", dataSourceClassName)); //$NON-NLS-1$
+ }
+
+ final String url = connectionProps.getProperty(JDBCPropertyNames.URL);
+ if (url == null || url.trim().length() == 0) {
+ throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Missing_JDBC_database_name_3")); //$NON-NLS-1$
+ }
+
+ if (temp instanceof Driver) {
+ final Driver driver = (Driver)temp;
+ // check URL if there is one
+ validateURL(driver, url);
+ this.ds = (DataSource)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {DataSource.class}, new InvocationHandler() {
+ @Override
+ public Object invoke(Object proxy, Method method,
+ Object[] args) throws Throwable {
+ if (method.getName().equals("getConnection")) {
+ Properties p = new Properties();
+ if (args.length == 2) {
+ p.put("user", args[0]);
+ p.put("password", args[1]);
+ } else {
+ p.put("user", connectionProps.getProperty(JDBCPropertyNames.USERNAME));
+ p.put("password", connectionProps.getProperty(JDBCPropertyNames.PASSWORD));
+ }
+ return driver.connect(url, p);
+ }
+ throw new UnsupportedOperationException("Driver DataSource proxy only provides Connections");
+ }
+ });
+ } else {
+ parseURL(url, connectionProps);
+ if (temp instanceof DataSource) {
+ this.ds = (DataSource)temp;
+ PropertiesUtils.setBeanProperties(this.ds, connectionProps, null);
+ } else if (temp instanceof XADataSource) {
+ this.xaDs = (XADataSource)temp;
+ PropertiesUtils.setBeanProperties(this.xaDs, connectionProps, null);
+ } else {
+ throw new ConnectorException("Specified class is not a XADataSource, DataSource, or Driver " + dataSourceClassName);
+ }
+ }
+ if (this.ds instanceof XADataSource) {
+ this.xaDs = (XADataSource)this.ds;
+ }
+ }
+
+ public DataSource getDataSource() {
+ return ds;
+ }
+
+ public XADataSource getXADataSource() {
+ return xaDs;
+ }
+
+ private void validateURL(Driver driver, String url) throws ConnectorException {
+ boolean acceptsURL = false;
+ try {
+ acceptsURL = driver.acceptsURL(url);
+ } catch ( SQLException e ) {
+ throw new ConnectorException(e);
+ }
+ if(!acceptsURL ){
+ throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Driver__7", driver.getClass().getName(), url)); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Parse URL for DataSource connection properties and add to connectionProps.
+ * @param url
+ * @param connectionProps
+ * @throws ConnectorException
+ */
+ static void parseURL(final String url, final Properties connectionProps) throws ConnectorException {
+ // Will be: [jdbc:mmx:dbType://aHost:aPort], [DatabaseName=aDataBase], [CollectionID=aCollectionID], ...
+ final String[] urlParts = url.split(";"); //$NON-NLS-1$
+
+ // Will be: [jdbc:mmx:dbType:], [aHost:aPort]
+ final String[] protoHost = urlParts[0].split("//"); //$NON-NLS-1$
+
+ // Will be: [aHost], [aPort]
+ final String[] hostPort = protoHost[1].split(":"); //$NON-NLS-1$
+ connectionProps.setProperty(XAJDBCPropertyNames.SERVER_NAME, (String)hostPort[0]);
+ connectionProps.setProperty(XAJDBCPropertyNames.PORT_NUMBER, (String)hostPort[1]);
+
+ // For "databaseName", "SID", and all optional props
+ // (<propName1>=<propValue1>;<propName2>=<propValue2>;...)
+ for ( int i = 1; i < urlParts.length; i++ ) {
+ final String nameVal = (String) urlParts[i];
+ // Will be: [propName], [propVal]
+ final String[] aProp = nameVal.split("="); //$NON-NLS-1$
+ if ( aProp.length > 1) {
+ // Set optional prop names lower case so that we can find
+ // set method names for them when we introspect the DataSource
+ connectionProps.setProperty(aProp[0].toLowerCase(), aProp[1]);
+ }
+ }
+
+ String serverName = connectionProps.getProperty(XAJDBCPropertyNames.SERVER_NAME);
+ String serverPort = connectionProps.getProperty(XAJDBCPropertyNames.PORT_NUMBER);
+ if ( serverName == null || serverName.trim().length() == 0 ) {
+ throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.MissingProp", //$NON-NLS-1$
+ XAJDBCPropertyNames.SERVER_NAME));
+ }
+ if ( serverPort == null || serverPort.trim().length() == 0 ) {
+ throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.MissingProp", //$NON-NLS-1$
+ XAJDBCPropertyNames.PORT_NUMBER));
+ }
+
+ // Unique resource name for this connector
+ final StringBuffer dataSourceResourceName = new StringBuffer(connectionProps.getProperty(XAJDBCPropertyNames.DATASOURCE_NAME, "XADS")); //$NON-NLS-1$
+ dataSourceResourceName.append('_');
+ dataSourceResourceName.append(serverName);
+ dataSourceResourceName.append('_');
+ dataSourceResourceName.append(connectionProps.getProperty(ConnectorPropertyNames.CONNECTOR_ID));
+ connectionProps.setProperty( XAJDBCPropertyNames.DATASOURCE_NAME, dataSourceResourceName.toString());
+ }
+
+ public int getDefaultTransactionIsolationLevel() {
+ return this.transIsoLevel;
+ }
+
+ protected void setDefaultTransactionIsolationLevel(java.sql.Connection sqlConn)
+ throws SQLException {
+ if(getDefaultTransactionIsolationLevel() != NO_ISOLATION_LEVEL_SET && getDefaultTransactionIsolationLevel() != java.sql.Connection.TRANSACTION_NONE){
+ sqlConn.setTransactionIsolation(getDefaultTransactionIsolationLevel());
+ }
+ }
+
}
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCProcedureExecution.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -38,10 +38,8 @@
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ProcedureExecution;
-import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
-import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
-import com.metamatrix.connector.jdbc.extension.ValueRetriever;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.jdbc.util.JDBCExecutionHelper;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IParameter;
@@ -61,20 +59,18 @@
/**
* @param connection
* @param sqlTranslator
- * @param resultsTranslator
- * @param id
* @param logger
* @param props
+ * @param id
*/
public JDBCProcedureExecution(ICommand command,
Connection connection,
- SQLTranslator sqlTranslator,
- ResultsTranslator resultsTranslator,
+ Translator sqlTranslator,
ConnectorLogger logger,
- Properties props, RuntimeMetadata metadata,
- ExecutionContext context,
+ Properties props,
+ RuntimeMetadata metadata, ExecutionContext context,
ConnectorEnvironment env) {
- super(command, connection, sqlTranslator, resultsTranslator, logger, props, context, env);
+ super(command, connection, sqlTranslator, logger, props, context, env);
this.metadata = metadata;
}
@@ -92,7 +88,7 @@
//create parameter index map
parameterIndexMap = createParameterIndexMap(procedure.getParameters(), sql);
CallableStatement cstmt = getCallableStatement(sql);
- results = resultsTranslator.executeStoredProcedure(cstmt, translatedComm);
+ results = sqlTranslator.executeStoredProcedure(cstmt, translatedComm);
if (results != null) {
initResultSetInfo();
}
@@ -191,12 +187,11 @@
throw new ConnectorException(JDBCPlugin.Util.getString("JDBCProcedureExecution.Unexpected_exception_1")); //$NON-NLS-1$
}
try {
- ValueRetriever valueRetriver = this.resultsTranslator.getValueRetriever();
- Object value = valueRetriver.retrieveValue((CallableStatement)this.statement, index.intValue(), parameter.getType(), calendar, env.getTypeFacility());
+ Object value = sqlTranslator.retrieveValue((CallableStatement)this.statement, index.intValue(), parameter.getType());
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.sqlTranslator.getValueTranslators(), this.sqlTranslator.getTypeFacility(), trimString, context);
return result;
} catch (SQLException e) {
throw new ConnectorException(e);
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCPropertyNames.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCPropertyNames.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCPropertyNames.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -23,21 +23,13 @@
package com.metamatrix.connector.jdbc;
public class JDBCPropertyNames {
- public static final String DRIVER_CLASS = "Driver"; //$NON-NLS-1$
+ public static final String CONNECTION_SOURCE_CLASS = "Driver"; //$NON-NLS-1$
public static final String URL = "URL"; //$NON-NLS-1$
public static final String USERNAME = "User"; //$NON-NLS-1$
public static final String PASSWORD = "Password"; //$NON-NLS-1$
- public static final String MAX_SQL_LENGTH = "MaxSQLLength"; //$NON-NLS-1$
/**
* This is the property name of the ConnectorService property that defines
- * what character, if any, will be used to wrap date type of criteria values
- * in SQL statements submitted to the data source.
- */
- public static final String DATE_WRAP_CHAR = "DateWrapChar"; //$NON-NLS-1$
-
- /**
- * This is the property name of the ConnectorService property that defines
* whether or not String type values in Criteria statements in SQL queries to
* the data source should have spaces trimmed from them.
*/
@@ -61,20 +53,6 @@
public static final String TRANSACTION_ISOLATION_LEVEL = "TransactionIsolationLevel"; //$NON-NLS-1$
/**
- * This property can be used to specify a limit on the size of Blobs, in bytes, that
- * will be retrieved from a source.
- * @since 3.0
- */
- public static final String MAX_BLOB_BYTES = "MaxBlobBytes"; //$NON-NLS-1$
-
- /**
- * This property can be used to specify a limit on the size of Clobs, in characters, that
- * will be retrieved from a source.
- * @since 3.0
- */
- public static final String MAX_CLOB_CHARS= "MaxClobChars"; //$NON-NLS-1$
-
- /**
* This is the property name of the ConnectorService property that defines
* the time zone of the source database. This property should only be used in
* cases where the source database is in a different time zone than the
@@ -92,23 +70,11 @@
/**
* This property is used to specify the implementation of
- * com.metamatrix.connector.jdbc.extension.SQLTranslator
+ * com.metamatrix.connector.jdbc.extension.Translator
*/
- public static final String EXT_SQL_TRANSLATOR_CLASS= "ExtensionSQLTranslationClass"; //$NON-NLS-1$
+ public static final String EXT_TRANSLATOR_CLASS= "ExtensionTranslationClass"; //$NON-NLS-1$
/**
- * This property is used to specify the implementation of
- * com.metamatrix.connector.jdbc.extension.ResultsTranslator.
- */
- public static final String EXT_RESULTS_TRANSLATOR_CLASS= "ExtensionResultsTranslationClass"; //$NON-NLS-1$
-
- /**
- * This property is used to specify the implementation of
- * com.metamatrix.data.pool.SourceConnectionFactory
- */
- public static final String EXT_CONNECTION_FACTORY_CLASS= "ExtensionConnectionFactoryClass"; //$NON-NLS-1$
-
- /**
* This property can be used to specify the fetch size used from the connector to
* its underlying source.
*/
@@ -126,5 +92,10 @@
* This property is used to turn on/off the use of the default comments like
* connection id and requestid in the source SQL query.
*/
- public static final String USE_COMMENTS_SOURCE_QUERY= "UseCommentsInSourceQuery"; //$NON-NLS-1$
+ public static final String USE_COMMENTS_SOURCE_QUERY= "UseCommentsInSourceQuery"; //$NON-NLS-1$
+
+ public static final String CONNECTION_TEST_QUERY = "ConnectionTestQuery"; //$NON-NLS-1$
+
+ public static final String IS_VALID_TIMEOUT = "IsValidTimeout"; //$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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCQueryExecution.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -32,10 +32,8 @@
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.List;
import java.util.Properties;
-import java.util.TimeZone;
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
@@ -45,9 +43,8 @@
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.TypeFacility;
import com.metamatrix.connector.api.ValueTranslator;
-import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
-import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.jdbc.util.JDBCExecutionHelper;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IQueryCommand;
@@ -63,7 +60,6 @@
protected ResultSet results;
protected Class[] columnDataTypes;
- protected Calendar calendar;
protected ConnectorEnvironment env;
protected ICommand command;
private boolean[] transformKnown;
@@ -76,22 +72,13 @@
// ===========================================================================================================================
public JDBCQueryExecution(ICommand command, Connection connection,
- SQLTranslator sqlTranslator,
- ResultsTranslator resultsTranslator,
+ Translator sqlTranslator,
ConnectorLogger logger,
Properties props,
ExecutionContext context,
ConnectorEnvironment env) {
- super(connection, sqlTranslator, resultsTranslator, logger, props, context);
+ super(connection, sqlTranslator, logger, props, context);
this.command = command;
- TimeZone dbmsTimeZone = resultsTranslator.getDatabaseTimezone();
-
- if (dbmsTimeZone != null) {
- calendar = Calendar.getInstance(dbmsTimeZone);
- } else {
- calendar = Calendar.getInstance();
- }
-
this.env = env;
}
@@ -111,7 +98,7 @@
results = getStatement().executeQuery(sql);
} else {
PreparedStatement pstatement = getPreparedStatement(sql);
- resultsTranslator.bindPreparedStatementValues(this.connection, pstatement, translatedComm);
+ sqlTranslator.bindPreparedStatementValues(this.connection, pstatement, translatedComm);
results = pstatement.executeQuery();
}
addStatementWarnings();
@@ -154,13 +141,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], calendar, env.getTypeFacility());
+ Object value = sqlTranslator.retrieveValue(results, i+1, columnDataTypes[i]);
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], sqlTranslator.getValueTranslators(), sqlTranslator.getTypeFacility());
}
transformKnown[i] = true;
}
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSingleIdentityConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,116 +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;
-
-import java.sql.Driver;
-import java.sql.SQLException;
-import java.util.Properties;
-
-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.pool.SingleIdentityFactory;
-
-/**
- * Factory to create JDBCSourceConnection for SingleIdentity.
- */
-public class JDBCSingleIdentityConnectionFactory extends JDBCSourceConnectionFactory {
- public static final String INVALID_AUTHORIZATION_SPECIFICATION_NO_SUBCLASS = "28000"; //$NON-NLS-1$
- private Driver driver;
- private String url;
- private int transIsoLevel;
- private Properties userProps;
- protected ConnectionListener connectionListener = new DefaultConnectionListener();
- private ConnectorLogger logger;
-
- public JDBCSingleIdentityConnectionFactory() {
- super(new SingleIdentityFactory());
- }
-
- public void initialize(ConnectorEnvironment env) throws ConnectorException {
- super.initialize(env);
- verifyConnectionProperties(env.getProperties());
- logger = env.getLogger();
- // attempt to get a connection to verify that properties are valid
- testConnection();
- }
-
- protected void verifyConnectionProperties(Properties connectionProps) throws ConnectorException{
- // Find driver
- String driverClassName = connectionProps.getProperty(JDBCPropertyNames.DRIVER_CLASS);
- driver = createDriver(driverClassName);
-
- // check URL
- url = connectionProps.getProperty(JDBCPropertyNames.URL);
- validateURL(driver, url);
-
- // Build connection properties from user name and password
- String username = connectionProps.getProperty(JDBCPropertyNames.USERNAME);
- String password = connectionProps.getProperty(JDBCPropertyNames.PASSWORD);
- userProps = new Properties();
- if (username != null && username.trim().length() > 0) {
- userProps.setProperty("user", username.trim()); //$NON-NLS-1$
- }
-
- if ( password != null && password.trim().length() > 0 ) {
- userProps.setProperty("password", password.trim()); //$NON-NLS-1$
- }
-
- transIsoLevel = interpretTransactionIsolationLevel( connectionProps.getProperty(JDBCPropertyNames.TRANSACTION_ISOLATION_LEVEL));
- }
-
- private void testConnection() throws ConnectorException {
- try {
- Connection connection = getConnection(null);
- connection.close();
- } catch (ConnectorException e) {
- SQLException ex = (SQLException)e.getCause();
- String sqlState = ex.getSQLState();
- if (sqlState != null && INVALID_AUTHORIZATION_SPECIFICATION_NO_SUBCLASS.equals(sqlState)) {
- throw e;
- }
- this.logger.logError(e.getMessage(), e);
- }
- }
-
- public Connection getConnection(ExecutionContext ctx) throws ConnectorException {
- return createJDBCConnection(driver, url, transIsoLevel, userProps);
- }
-
- protected int getTransactionIsolation(){
- return this.transIsoLevel;
- }
-
- /**
- * Connection Listener only used in the SingleIdentityConnections for now.
- * @see com.metamatrix.connector.jdbc.JDBCSourceConnectionFactory#getConnectionListener()
- */
- protected ConnectionListener getConnectionListener() {
- return connectionListener;
- }
-
-}
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnection.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -24,7 +24,9 @@
*/
package com.metamatrix.connector.jdbc;
+import java.sql.Connection;
import java.sql.SQLException;
+import java.sql.Statement;
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
@@ -34,91 +36,91 @@
import com.metamatrix.connector.api.ResultSetExecution;
import com.metamatrix.connector.api.UpdateExecution;
import com.metamatrix.connector.basic.BasicConnection;
-import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
+import com.metamatrix.connector.jdbc.translator.Translator;
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.PoolAwareConnection;
/**
*
*/
-public class JDBCSourceConnection extends BasicConnection implements PoolAwareConnection {
+public class JDBCSourceConnection extends BasicConnection {
protected java.sql.Connection physicalConnection;
protected ConnectorEnvironment environment;
private ConnectorLogger logger;
- private ConnectionStrategy connectionStrategy;
- private ConnectionListener connectionListener;
- private SQLTranslator sqlTranslator;
- private ResultsTranslator resultsTranslator;
+ private Translator sqlTranslator;
- /**
- * @param connection
- */
- 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, ResultsTranslator resultsTranslator, SQLTranslator sqlTranslator) throws ConnectorException {
- physicalConnection = connection;
+ public JDBCSourceConnection(java.sql.Connection connection, ConnectorEnvironment environment, Translator sqlTranslator) throws ConnectorException {
+ this.physicalConnection = connection;
this.environment = environment;
this.logger = environment.getLogger();
- this.connectionStrategy = connectionStrategy;
- this.connectionListener = connectionListener;
-
-
- // notify the listner that coneection created
- if (this.connectionListener != null) {
- this.connectionListener.afterConnectionCreation(this.physicalConnection, this.environment);
- }
+ this.sqlTranslator = sqlTranslator;
+ this.sqlTranslator.afterConnectionCreation(connection);
}
@Override
public ResultSetExecution createResultSetExecution(IQueryCommand command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new JDBCQueryExecution(command, this.physicalConnection, sqlTranslator, resultsTranslator, logger, this.environment.getProperties(), executionContext, this.environment);
+ return new JDBCQueryExecution(command, this.physicalConnection, sqlTranslator, 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, sqlTranslator, resultsTranslator, logger, this.environment.getProperties(), metadata, executionContext, this.environment);
+ return new JDBCProcedureExecution(command, this.physicalConnection, sqlTranslator, 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, sqlTranslator, resultsTranslator, logger, this.environment.getProperties(), executionContext);
+ return new JDBCUpdateExecution(command, this.physicalConnection, sqlTranslator, logger, this.environment.getProperties(), executionContext);
}
@Override
public void close() {
- try {
- // notify the listener that connection being destroyed
- if (connectionListener != null) {
- connectionListener.beforeConnectionClose(physicalConnection, environment);
- }
+ closeSourceConnection();
+ }
+
+ protected void closeSourceConnection() {
+ try {
this.physicalConnection.close();
} catch(SQLException e) {
logger.logDetail("Exception during close: " + e.getMessage());
}
- }
+ }
@Override
public boolean isAlive() {
- if (connectionStrategy == null) {
- try {
- return !this.physicalConnection.isClosed();
- } catch (SQLException e) {
+ Connection connection = this.physicalConnection;
+ Statement statement = null;
+ try {
+ int timeout = this.sqlTranslator.getIsValidTimeout();
+ if (timeout >= 0) {
+ return connection.isValid(timeout);
+ }
+ if(connection.isClosed()){
return false;
+ }
+ String connectionTestQuery = sqlTranslator.getConnectionTestQuery();
+ if (connectionTestQuery != null) {
+ statement = connection.createStatement();
+ statement.executeQuery(connectionTestQuery);
}
+ } catch(SQLException e) {
+ return false;
+ } finally {
+ if ( statement != null ) {
+ try {
+ statement.close();
+ } catch ( SQLException e ) {
+ }
+ }
}
- return connectionStrategy.isConnectionAlive(this.physicalConnection);
+ return true;
}
@Override
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCSourceConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,230 +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;
-
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.Enumeration;
-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.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;
-
-/**
- * Represents a base class for a JDBC source connection factory. Subclasses
- * are expected to obtain the properties for their connection in different
- * ways (either from connector properties, from security context, or from
- * some lookup to an external source).
- */
-public abstract class JDBCSourceConnectionFactory implements ConnectorIdentityFactory {
-
- protected static final int NO_ISOLATION_LEVEL_SET = Integer.MIN_VALUE;
-
- private ConnectorEnvironment environment;
-
- private String deregisterType;
-
- private ConnectorIdentityFactory connectorIdentityFactory;
- private SQLTranslator sqlTranslator;
- private ResultsTranslator resultsTranslator;
-
- /**
- *
- */
- public JDBCSourceConnectionFactory(ConnectorIdentityFactory connectorIdentityFactory) {
- this.connectorIdentityFactory = connectorIdentityFactory;
- }
-
- public void initialize(ConnectorEnvironment env) throws ConnectorException {
- 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() {
- return this.environment;
- }
-
- protected Driver createDriver(String driverClassName) throws ConnectorException {
- // Verify required items
- if (driverClassName == null || driverClassName.trim().length() == 0) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Missing_JDBC_driver_class_name_1")); //$NON-NLS-1$
- }
- try {
- Class clazz = Thread.currentThread().getContextClassLoader().loadClass(driverClassName);
- return (Driver) clazz.newInstance();
- } catch(Exception e) {
- throw new ConnectorException(e, JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Unable_to_load_the_JDBC_driver_class_6", driverClassName)); //$NON-NLS-1$
- }
- }
-
- protected void validateURL(Driver driver, String url) throws ConnectorException {
- if (url == null || url.trim().length() == 0) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Missing_JDBC_database_name_3")); //$NON-NLS-1$
- }
-
- boolean acceptsURL = false;
- try {
- acceptsURL = driver.acceptsURL(url);
- } catch ( SQLException e ) {
- throw new ConnectorException(e);
- }
- if(!acceptsURL ){
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Driver__7", driver.getClass().getName(), url)); //$NON-NLS-1$
- }
- }
-
- /**
- * This creates a JDBC connection.
- * @throws ConnectorException if there is an error establishing the connection.
- */
- protected com.metamatrix.connector.api.Connection createJDBCConnection(Driver driver, String url, int transactionIsolationLevel, Properties userProps) throws ConnectorException {
- Connection connection = null;
-
- // Connect
- try {
- connection = driver.connect(url, userProps);
- if(transactionIsolationLevel != NO_ISOLATION_LEVEL_SET){
- connection.setTransactionIsolation(transactionIsolationLevel);
- }
- } catch ( SQLException e ) {
- throw new ConnectorException(e);
- }
-
- return new JDBCSourceConnection(connection, this.environment, createConnectionStrategy(), getConnectionListener(), resultsTranslator, sqlTranslator);
- }
-
- /**
- * Subclass can override this method to provide an actual ConnectionListener
- */
- protected ConnectionListener getConnectionListener() {
- return null;
- }
-
- /**
- * Subclass can override this method to provide an actual ConnectionStrategy
- */
- protected ConnectionStrategy createConnectionStrategy() {
- return null;
- }
-
- protected int interpretTransactionIsolationLevel( String levelStr ) throws ConnectorException {
- int isoLevel = NO_ISOLATION_LEVEL_SET;
- if(levelStr == null || levelStr.trim().length() == 0){
- return isoLevel;
- }
-
- levelStr = levelStr.toUpperCase();
-
- if (levelStr.equals("TRANSACTION_READ_UNCOMMITTED")) { //$NON-NLS-1$
- isoLevel = Connection.TRANSACTION_READ_UNCOMMITTED;
- } else if (levelStr.equals("TRANSACTION_READ_COMMITTED")) {//$NON-NLS-1$
- isoLevel = Connection.TRANSACTION_READ_COMMITTED;
- } else if (levelStr.equals("TRANSACTION_REPEATABLE_READ")) {//$NON-NLS-1$
- isoLevel = Connection.TRANSACTION_REPEATABLE_READ;
- } else if (levelStr.equals("TRANSACTION_SERIALIZABLE")) {//$NON-NLS-1$
- isoLevel = Connection.TRANSACTION_SERIALIZABLE;
- } else if (levelStr.equals("TRANSACTION_NONE")) {//$NON-NLS-1$
- isoLevel = Connection.TRANSACTION_NONE;
- } else {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.til", levelStr)); //$NON-NLS-1$
- }
- return isoLevel;
- }
-
- public void shutdown() {
- Enumeration drivers = DriverManager.getDrivers();
- //this is not correct the correct name for datasources, but we will still do the deregister
- String driverClassname = this.environment.getProperties().getProperty(JDBCPropertyNames.DRIVER_CLASS);
- // De-Register Driver
- while(drivers.hasMoreElements()){
- Driver tempdriver = (Driver)drivers.nextElement();
- if(tempdriver.getClass().getClassLoader() != this.getClass().getClassLoader()) {
- continue;
- }
- if(ConnectorPropertyNames.DEREGISTER_BY_CLASSLOADER.equals(this.deregisterType)
- || tempdriver.getClass().getName().equals(driverClassname)) {
- try {
- DriverManager.deregisterDriver(tempdriver);
- } catch (Throwable e) {
- this.environment.getLogger().logError(e.getMessage());
- }
- }
- }
- }
-
- public abstract com.metamatrix.connector.api.Connection getConnection(ExecutionContext context) throws ConnectorException;
-
- @Override
- public ConnectorIdentity createIdentity(ExecutionContext context)
- throws ConnectorException {
- 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUpdateExecution.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -34,9 +34,8 @@
import com.metamatrix.connector.api.DataNotAvailableException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.UpdateExecution;
-import com.metamatrix.connector.jdbc.extension.ResultsTranslator;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
-import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.language.IBatchedUpdates;
import com.metamatrix.connector.language.IBulkInsert;
import com.metamatrix.connector.language.ICommand;
@@ -52,18 +51,16 @@
/**
* @param connection
* @param sqlTranslator
- * @param resultsTranslator
- * @param id
* @param logger
* @param props
+ * @param id
*/
public JDBCUpdateExecution(ICommand command, Connection connection,
- SQLTranslator sqlTranslator,
- ResultsTranslator resultsTranslator,
+ Translator sqlTranslator,
ConnectorLogger logger,
Properties props,
ExecutionContext context) {
- super(connection, sqlTranslator, resultsTranslator, logger, props, context);
+ super(connection, sqlTranslator, logger, props, context);
this.command = command;
}
@@ -119,7 +116,7 @@
}
pstmt = getPreparedStatement(command.getSql());
}
- resultsTranslator.bindPreparedStatementValues(this.connection, pstmt, command);
+ sqlTranslator.bindPreparedStatementValues(this.connection, pstmt, command);
pstmt.addBatch();
} else {
if (previousCommand != null && previousCommand.isPrepared()) {
@@ -174,7 +171,7 @@
connection.setAutoCommit(false);
}
PreparedStatement stmt = getPreparedStatement(sql);
- updateCount = resultsTranslator.executeStatementForBulkInsert(this.connection, stmt, translatedComm);
+ updateCount = sqlTranslator.executeStatementForBulkInsert(this.connection, stmt, translatedComm);
addStatementWarnings();
succeeded = true;
} catch (SQLException e) {
@@ -217,7 +214,7 @@
updateCount = getStatement().executeUpdate(sql);
} else {
PreparedStatement pstatement = getPreparedStatement(sql);
- resultsTranslator.bindPreparedStatementValues(this.connection, pstatement, translatedComm);
+ sqlTranslator.bindPreparedStatementValues(this.connection, pstatement, translatedComm);
updateCount = pstatement.executeUpdate();
}
addStatementWarnings();
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/JDBCUserIdentityConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,116 +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;
-
-import java.sql.Driver;
-import java.util.Properties;
-
-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.pool.UserIdentityFactory;
-
-/**
- */
-public class JDBCUserIdentityConnectionFactory extends JDBCSourceConnectionFactory {
-
- private Driver driver;
- private String url;
- private int transIsoLevel;
- private String system;
-
- public JDBCUserIdentityConnectionFactory() {
- super(new UserIdentityFactory());
- }
-
- public void initialize(ConnectorEnvironment env) throws ConnectorException {
- super.initialize(env);
- system = getConnectorEnvironment().getConnectorName();
- verifyConnectionProperties(env.getProperties());
- }
-
- protected void verifyConnectionProperties(Properties connectionProps) throws ConnectorException{
- // Find driver
- String driverClassName = connectionProps.getProperty(JDBCPropertyNames.DRIVER_CLASS);
- driver = createDriver(driverClassName);
-
- // check URL if there is one
- url = connectionProps.getProperty(JDBCPropertyNames.URL);
- if(url != null && url.trim().length() > 0) {
- validateURL(driver, url);
- }
-
- // Get transaction isolation level
- transIsoLevel = interpretTransactionIsolationLevel( connectionProps.getProperty(JDBCPropertyNames.TRANSACTION_ISOLATION_LEVEL));
- }
-
- protected String getUrl() {
- return this.url;
- }
-
- protected int getTransactionIsolationLevel() {
- return this.transIsoLevel;
- }
-
- public Connection getConnection(ExecutionContext context) throws ConnectorException {
- String[] userProperties = getUserProperties(context);
-
- Properties props = new Properties();
- props.put("user", userProperties[0]); //$NON-NLS-1$
- props.put("password", userProperties[1]); //$NON-NLS-1$
- return createJDBCConnection(this.driver, getUrl(), getTransactionIsolationLevel(), props);
- }
-
- protected String[] getUserProperties(ExecutionContext context) throws ConnectorException {
-
- // By default, assume the session token is a CredentialMap and pull out the user/password props
- Object trustedPayload = context.getTrustedPayload();
-
- if(trustedPayload instanceof CredentialMap) {
- CredentialMap credentials = (CredentialMap)trustedPayload;
- String user = credentials.getUser(system);
- validatePropertyExists(user, CredentialMap.USER_KEYWORD);
-
- String password = credentials.getPassword(system);
- validatePropertyExists(password, CredentialMap.PASSWORD_KEYWORD);
-
- return new String[] { user, password };
- }
-
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCUserIdentityConnectionFactory.Unable_to_get_credentials")); //$NON-NLS-1$
- }
-
- /**
- * @param property
- * @throws ConnectorException
- * @since 4.3
- */
- private void validatePropertyExists(String property, String propertyName) throws ConnectorException {
- if(property == null) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCUserIdentityConnectionFactory.Connection_property_missing", propertyName, system)); //$NON-NLS-1$
- }
- }
-
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/SimpleCapabilities.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/SimpleCapabilities.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/SimpleCapabilities.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -344,13 +344,6 @@
return null;
}
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsXATransactions()
- */
- public boolean supportsXATransactions() {
- return false;
- }
-
public boolean supportsInlineViews() {
return false;
}
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/access/AccessSQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -24,10 +24,10 @@
*/
package com.metamatrix.connector.jdbc.access;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.language.ILimit;
-public class AccessSQLTranslator extends SQLTranslator {
+public class AccessSQLTranslator extends Translator {
@Override
public boolean hasTimeType() {
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2ConvertModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -26,9 +26,9 @@
import java.util.List;
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.jdbc.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.DropFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.*;
import com.metamatrix.connector.language.ICompareCriteria.Operator;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/db2/DB2SQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -31,8 +31,8 @@
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.translator.AliasModifier;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IJoin;
import com.metamatrix.connector.language.ILimit;
@@ -43,7 +43,7 @@
/**
*/
-public class DB2SQLTranslator extends SQLTranslator {
+public class DB2SQLTranslator extends Translator {
@Override
public void initialize(ConnectorEnvironment env) throws ConnectorException {
@@ -80,7 +80,7 @@
}
@Override
- public String getConnectionTestQuery() {
+ public String getDefaultConnectionTestQuery() {
return "Select 'x' from sysibm.systables where 1 = 2"; //$NON-NLS-1$
}
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbyConvertModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -26,9 +26,9 @@
import java.util.List;
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.jdbc.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.DropFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.*;
import com.metamatrix.connector.language.ICompareCriteria.Operator;
@@ -45,7 +45,7 @@
}
/**
- * @see com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier#translate(com.metamatrix.connector.language.IFunction)
+ * @see com.metamatrix.connector.jdbc.translator.BasicFunctionModifier#translate(com.metamatrix.connector.language.IFunction)
* @since 5.0
*/
public List translate(IFunction function) {
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/derby/DerbySQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -25,15 +25,15 @@
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
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;
+import com.metamatrix.connector.jdbc.translator.AliasModifier;
+import com.metamatrix.connector.jdbc.translator.EscapeSyntaxModifier;
+import com.metamatrix.connector.jdbc.translator.Translator;
/**
* @since 4.3
*/
-public class DerbySQLTranslator extends SQLTranslator {
+public class DerbySQLTranslator extends Translator {
@Override
public void initialize(ConnectorEnvironment env) throws ConnectorException {
@@ -54,7 +54,7 @@
}
@Override
- public String getConnectionTestQuery() {
+ public String getDefaultConnectionTestQuery() {
return "Select 0 from sys.systables where 1 = 2"; //$NON-NLS-1$
}
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/BindValueVisitor.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,136 +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;
-
-import com.metamatrix.connector.language.ICompareCriteria;
-import com.metamatrix.connector.language.IExistsCriteria;
-import com.metamatrix.connector.language.IFunction;
-import com.metamatrix.connector.language.IInCriteria;
-import com.metamatrix.connector.language.IInlineView;
-import com.metamatrix.connector.language.IInsert;
-import com.metamatrix.connector.language.ILanguageObject;
-import com.metamatrix.connector.language.ILikeCriteria;
-import com.metamatrix.connector.language.ILiteral;
-import com.metamatrix.connector.language.IScalarSubquery;
-import com.metamatrix.connector.language.ISearchedCaseExpression;
-import com.metamatrix.connector.language.ISetClause;
-import com.metamatrix.connector.language.ISubqueryCompareCriteria;
-import com.metamatrix.connector.visitor.framework.HierarchyVisitor;
-
-/**
- * This visitor will mark literals in well known locations as bindValues.
- * These values will be put in the generated SQL as ?
- * and have the corresponding value set on the PreparedStatement
- */
-final class BindValueVisitor extends HierarchyVisitor {
-
- private boolean replaceWithBinding = false;
-
- public void visit(IInlineView obj) {
- replaceWithBinding = false;
- visitNode(obj.getQuery());
- }
-
- public void visit(IScalarSubquery obj) {
- replaceWithBinding = false;
- super.visit(obj);
- }
-
- public void visit(IExistsCriteria obj) {
- replaceWithBinding = false;
- super.visit(obj);
- }
-
- public void visit(ISubqueryCompareCriteria obj) {
- replaceWithBinding = false;
- super.visit(obj);
- }
-
- /**
- * In general it is not appropriate to use bind values within a function
- * unless the particulars of the function parameters are know.
- * As needed, other visitors or modifiers can set the literals used within
- * a particular function as bind variables.
- */
- public void visit(IFunction obj) {
- replaceWithBinding = false;
- super.visit(obj);
- }
-
- public void visit(IInCriteria obj) {
- replaceWithBinding = true;
- visitNodes(obj.getRightExpressions());
- }
-
- public void visit(ILikeCriteria obj) {
- replaceWithBinding = true;
- visitNode(obj.getRightExpression());
- }
-
- /**
- * Note that this will only visit the right expression. In general most compares
- * involving literals will be something like element = literal (this is enforced as
- * much as possible by the QueryRewriter). In rare circumstances, it is possible to
- * have literal = literal (most notably null <> null). Using bind variables on
- * both sides of the operator is not supported by most databases.
- */
- public void visit(ICompareCriteria obj) {
- replaceWithBinding = true;
- visitNode(obj.getRightExpression());
- }
-
- /**
- * Will look for bind values in the when criteria.
- * 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) {
- for (int i = 0; i < obj.getWhenCount(); i++) {
- visitNode(obj.getWhenCriteria(i));
- }
- }
-
- @Override
- public void visit(IInsert obj) {
- replaceWithBinding = true;
- visitNodes(obj.getValues());
- }
-
- @Override
- public void visit(ISetClause obj) {
- replaceWithBinding = true;
- visitNode(obj.getValue());
- }
-
- public void visit(ILiteral obj) {
- if (replaceWithBinding || TranslatedCommand.isBindEligible(obj)) {
- obj.setBindValue(true);
- }
- }
-
- public void visitNode(ILanguageObject obj) {
- boolean replacementMode = replaceWithBinding;
- super.visitNode(obj);
- this.replaceWithBinding = replacementMode;
- }
-}
\ No newline at end of file
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/FunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/FunctionModifier.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/FunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,57 +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;
-
-import java.util.List;
-
-import com.metamatrix.connector.language.IExpression;
-import com.metamatrix.connector.language.IFunction;
-
-/**
- * Implementations of this interface are used to modify metamatrix functions
- * coming in to the connector into alternate datasource-specific language, if
- * necessary.
- */
-public interface FunctionModifier {
-
- /**
- * Takes an IFunction and returns the datasource-specific IExpression,
- * or can possibly return the unmodified function parameter itself.
- * @param function
- * @return IExpression or unmodified function
- * @since 4.2
- */
- IExpression modify(IFunction function);
-
- /**
- * Return a List of translated parts (LanguageObjects and Strings), or null
- * if this FunctionModifier wishes to rely on the default translation of the
- * conversion visitor.
- * @param function IFunction to be translated
- * @return List of translated parts, or null
- * @since 4.2
- */
- List translate(IFunction function);
-}
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ResultsTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,126 +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;
-
-import java.sql.CallableStatement;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-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.language.ICommand;
-
-/**
- * Specify database-specific behavior for translating results.
- */
-public interface ResultsTranslator {
-
- /**
- * Initialize the results translator with the connector's environment, which
- * can be used to retrieve configuration parameters
- * @param env The connector environment
- * @throws ConnectorException If an error occurs during initialization
- */
- void initialize(ConnectorEnvironment env) throws ConnectorException;
-
- /**
- * Get a list of ValueTranslator objects that specify database-specific value
- * translation logic. By default, the JDBC connector has a large set of available
- * translator.
- * @return List of ValueTranslator
- */
- List getValueTranslators();
-
- /**
- * Used to specify a special database-specific value retriever. By default, the BasicValueRetriever
- * will be used to retrieve objects from the ResultSet via the getObject() method.
- * @return The specialized ValueRetriever
- */
- ValueRetriever getValueRetriever();
-
- /**
- * Execute a stored procedure - this is often database-dependent.
- * @param stmt The CallableStatement created by the connector
- * @param command The translated command information
- * @return The ResultSet returned by the stored procedure
- * @throws SQLException If an error occurs during execution
- */
- ResultSet executeStoredProcedure(CallableStatement stmt, TranslatedCommand command) throws SQLException ;
-
- /**
- * Populate the prepared statement.
- * The prepared statement values will be set.
- * @param conn
- * @param stmt
- * @param command
- * @throws SQLException
- */
- public void bindPreparedStatementValues(Connection conn, PreparedStatement stmt, TranslatedCommand command) throws SQLException;
-
- /**
- * Execute the bulk insert statement.
- * @param conn The connection
- * @param stmt The prepared statement with the query
- * @param command The translated command, which contains the large objects to prepare with
- * @return Update count for the execution
- * @throws SQLException If an error occurs during execution
- */
- public int executeStatementForBulkInsert(Connection conn, PreparedStatement stmt, TranslatedCommand command) throws SQLException;
-
- /**
- * Determine the time zone the database is located in. Typically, this time zone is
- * the same as the local time zone, in which case, null should be returned.
- * @return Database time zone
- */
- TimeZone getDatabaseTimezone();
-
- /**
- * Allow an extension to modify any batch before it is returned to MetaMatrix. This
- * method can be used to apply row-level entitlements, modify data values for particular
- * users, etc.
- * @param batch The batch to return
- * @param context The execution context for the query
- * @param command The modified command that was obtained from the translation visitor provided by the SQLTranslator
- * @return The batch to use instead
- * @since 4.2
- */
- List modifyRow(List batch, ExecutionContext context, ICommand command);
-
- /**
- * Get the max result rows allowed
- *
- * @return the max result rows
- */
- int getMaxResultRows();
-
-
- TypeFacility getTypeFacility();
-}
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLConversionVisitor.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,347 +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;
-
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.language.IBulkInsert;
-import com.metamatrix.connector.language.ICommand;
-import com.metamatrix.connector.language.IElement;
-import com.metamatrix.connector.language.IFunction;
-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.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(RuntimeMetadata) using this method}.
- */
-public class SQLConversionVisitor extends SQLStringVisitor{
-
- 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 Map<String, FunctionModifier> modifiers;
- private ExecutionContext context;
- private SQLTranslator translator;
- private Calendar cal;
-
- private boolean prepared;
-
- private List preparedValues = new ArrayList();
- private List preparedTypes = new ArrayList();
-
- 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);
- }
- }
-
- public void visit(IBulkInsert obj) {
- this.prepared = true;
-
- super.visit(obj);
-
- for (int i = 0; i < obj.getElements().size(); i++) {
- IElement element = (IElement) obj.getElements().get(i);
- this.preparedTypes.add(element.getType());
- }
-
- this.preparedValues = obj.getRows();
- }
-
- /**
- * @param type
- * @param object
- * @param valuesbuffer
- */
- private void translateSQLType(Class type, Object obj, StringBuffer valuesbuffer) {
- if (obj == null) {
- valuesbuffer.append(NULL);
- } else {
- if(Number.class.isAssignableFrom(type)) {
- boolean useFormatting = false;
-
- if (Double.class.isAssignableFrom(type)){
- double value = ((Double)obj).doubleValue();
- useFormatting = (value <= SCIENTIC_LOW || value >= SCIENTIC_HIGH);
- }
- else if (Float.class.isAssignableFrom(type)){
- float value = ((Float)obj).floatValue();
- useFormatting = (value <= SCIENTIC_LOW || value >= SCIENTIC_HIGH);
- }
- // The formatting is to avoid the so-called "scientic-notation"
- // where toString will use for numbers greater than 10p7 and
- // less than 10p-3, where database may not understand.
- if (useFormatting) {
- synchronized (DECIMAL_FORMAT) {
- valuesbuffer.append(DECIMAL_FORMAT.format(obj));
- }
- }
- else {
- valuesbuffer.append(obj);
- }
- } else if(type.equals(TypeFacility.RUNTIME_TYPES.BOOLEAN)) {
- valuesbuffer.append(translator.translateLiteralBoolean((Boolean)obj));
- } else if(type.equals(TypeFacility.RUNTIME_TYPES.TIMESTAMP)) {
- valuesbuffer.append(translator.translateLiteralTimestamp((Timestamp)obj, cal));
- } else if(type.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
- valuesbuffer.append(translator.translateLiteralTime((Time)obj, cal));
- } else if(type.equals(TypeFacility.RUNTIME_TYPES.DATE)) {
- 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.
- valuesbuffer.append("'") //$NON-NLS-1$
- .append(escapeString(obj.toString()))
- .append("'"); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.IProcedure)
- */
- public void visit(IProcedure obj) {
- this.prepared = true;
- /*
- * preparedValues is now a list of procedure params instead of just values
- */
- this.preparedValues = obj.getParameters();
- super.buffer.append(generateSqlForStoredProcedure(obj));
- }
-
- /**
- * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.IFunction)
- */
- public void visit(IFunction obj) {
- if(this.modifiers != null) {
- FunctionModifier functionModifier = (FunctionModifier)this.modifiers.get(obj.getName().toLowerCase());
- if(functionModifier != null) {
- List parts = functionModifier.translate(obj);
-
- // null means the FunctionModifier will rely on default translation
- if (parts != null) {
- Iterator iter = parts.iterator();
- while(iter.hasNext()) {
- Object part = iter.next();
- if(part instanceof String) {
- buffer.append(part);
- } else {
- append((ILanguageObject)part);
- }
- }
- return;
- }
- }
- }
- super.visit(obj);
- }
-
- /**
- * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.ILiteral)
- */
- public void visit(ILiteral obj) {
- if (this.prepared && obj.isBindValue()) {
- buffer.append(UNDEFINED_PARAM);
- preparedValues.add(obj.getValue());
- preparedTypes.add(obj.getType());
- } else {
- translateSQLType(obj.getType(), obj.getValue(), buffer);
- }
- }
-
- /**
- * Set the per-command execution context on this visitor.
- * @param context ExecutionContext
- * @since 4.3
- */
- public void setExecutionContext(ExecutionContext context) {
- this.context = context;
- }
-
- /**
- * Retrieve the per-command execution context for this visitor
- * (intended for subclasses to use).
- * @return
- * @since 4.3
- */
- protected ExecutionContext getExecutionContext() {
- return this.context;
- }
-
- protected String getSourceComment(ICommand command) {
- return this.translator.getSourceComment(this.context, command);
- }
-
- /**
- * This is a generic implementation. Subclass should override this method
- * if necessary.
- * @param exec The command for the stored procedure.
- * @return String to be executed by CallableStatement.
- */
- protected String generateSqlForStoredProcedure(IProcedure exec) {
- StringBuffer prepareCallBuffer = new StringBuffer();
- prepareCallBuffer.append("{ "); //$NON-NLS-1$
-
- List params = exec.getParameters();
-
- //check whether a "?" is needed if there are returns
- boolean needQuestionMark = false;
- Iterator iter = params.iterator();
- while(iter.hasNext()){
- IParameter param = (IParameter)iter.next();
- if(param.getDirection() == Direction.RETURN){
- needQuestionMark = true;
- break;
- }
- }
-
- prepareCallBuffer.append(getSourceComment(exec));
-
- if(needQuestionMark){
- prepareCallBuffer.append("?="); //$NON-NLS-1$
- }
-
- prepareCallBuffer.append(" call ");//$NON-NLS-1$
- prepareCallBuffer.append(exec.getMetadataID() != null ? getName(exec.getMetadataID()) : exec.getProcedureName());
- prepareCallBuffer.append("("); //$NON-NLS-1$
-
- int numberOfParameters = 0;
- iter = params.iterator();
- while(iter.hasNext()){
- IParameter param = (IParameter)iter.next();
- if(param.getDirection() == Direction.IN || param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){
- if(numberOfParameters > 0){
- prepareCallBuffer.append(","); //$NON-NLS-1$
- }
- prepareCallBuffer.append("?"); //$NON-NLS-1$
- numberOfParameters++;
- }
- }
- prepareCallBuffer.append(")"); //$NON-NLS-1$
- prepareCallBuffer.append("}"); //$NON-NLS-1$
- return prepareCallBuffer.toString();
- }
-
- /**
- * @return the preparedValues
- */
- List getPreparedValues() {
- return this.preparedValues;
- }
-
- /**
- * @return the preparedValues
- */
- List getPreparedTypes() {
- return this.preparedTypes;
- }
-
- public boolean isPrepared() {
- return prepared;
- }
-
- public void setPrepared(boolean prepared) {
- this.prepared = prepared;
- }
-
- @Override
- protected boolean useAsInGroupAlias() {
- return this.translator.useAsInGroupAlias();
- }
-
- @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));
- }
-
-}
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/SQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,248 +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;
-
-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.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 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
- */
- 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
- */
- public ICommand modifyCommand(ICommand command, ExecutionContext context) throws ConnectorException {
- return command;
- }
-
- /**
- * Return a map of function name in lower case to FunctionModifier.
- * @return Map of function name to FunctionModifier.
- */
- public Map<String, FunctionModifier> getFunctionModifiers() {
- return functionModifiers;
- }
-
- public void registerFunctionModifier(String name, FunctionModifier modifier) {
- this.functionModifiers.put(name, modifier);
- }
-
- /**
- * 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
- */
- 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$
- }
-
-}
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/TranslatedCommand.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,171 +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;
-
-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.jdbc.util.FunctionReplacementVisitor;
-import com.metamatrix.connector.language.ICommand;
-import com.metamatrix.connector.language.ILiteral;
-import com.metamatrix.connector.visitor.util.CollectorVisitor;
-
-/**
- * This is a utility class used to translate an ICommand using a SQLConversionVisitor.
- * The SQLConversionVisitor should not be invoked directly; this object will use it to
- * translate the ICommand.
- */
-public class TranslatedCommand {
-
- private String sql;
- private boolean prepared;
- private List preparedValues;
- private List preparedTypes;
-
- private SQLConversionVisitor sqlConversionVisitor;
- private FunctionReplacementVisitor functionVisitor;
- private ExecutionContext context;
- private SQLTranslator sqlTranslator;
-
- /**
- * Constructor, takes a SQLConversionVisitor subclass
- * @param visitor a SQLConversionVisitor subclass
- */
- public TranslatedCommand(ExecutionContext context, SQLTranslator sqlTranslator){
- this.context = context;
- this.sqlTranslator = sqlTranslator;
-
- Map<String, FunctionModifier> modifiers = sqlTranslator.getFunctionModifiers();
- this.sqlConversionVisitor = new SQLConversionVisitor(sqlTranslator);
- sqlConversionVisitor.setExecutionContext(context);
- this.functionVisitor = new FunctionReplacementVisitor(modifiers);
- }
-
- public TranslatedCommand(ExecutionContext context, SQLTranslator sqlTranslator, SQLConversionVisitor sqlConversionVisitor, FunctionReplacementVisitor functionVisitor) {
- this.context = context;
- this.sqlTranslator = sqlTranslator;
- this.sqlConversionVisitor = sqlConversionVisitor;
- this.functionVisitor = functionVisitor;
- }
-
- /**
- * The method to cause this object to do it's thing. This method should
- * be called right after the constructor; afterward, all of the getter methods
- * can be called to retrieve results.
- * @param command ICommand to be translated
- * @throws ConnectorException
- */
- public void translateCommand(ICommand command) throws ConnectorException {
- this.sql = getSQL(command);
- 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 (sqlTranslator.usePreparedStatements() || hasBindValue(command)) {
- this.sqlConversionVisitor.setPrepared(true);
-
- command.acceptVisitor(new BindValueVisitor());
- }
-
- this.sqlConversionVisitor.append(command);
- return this.sqlConversionVisitor.toString();
- }
-
- /**
- * Simple check to see if any values in the command should be replaced with bind values
- *
- * @param command
- * @return
- */
- private boolean hasBindValue(ICommand command) {
- for (ILiteral l : CollectorVisitor.collectObjects(ILiteral.class, command)) {
- if (l.isBindValue() || isBindEligible(l)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @param l
- * @return
- */
- static boolean isBindEligible(ILiteral l) {
- if (TypeFacility.RUNTIME_TYPES.CLOB.equals(l.getType())
- || TypeFacility.RUNTIME_TYPES.BLOB.equals(l.getType())
- || TypeFacility.RUNTIME_TYPES.OBJECT.equals(l.getType())) {
- return true;
- }
- return false;
- }
-
- /**
- * 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
- */
- public List getPreparedValues() {
- return preparedValues;
- }
-
- /**
- * Return List of types to set on a prepared statement, if
- * necessary (see {@link #getStatementType})
- * @return List of types to be set on a prepared statement
- */
- public List getPreparedTypes() {
- return preparedTypes;
- }
-
- /**
- * Get String SQL of translated command; but use
- * {@link #nextLargeSetQuerySQL} if this command is
- * a {@link #isLargeSetQuery large set query}
- * @return SQL of translated command, or null if the
- * command is a {@link #isLargeSetQuery large set query}
- */
- public String getSql() {
- return sql;
- }
-
- /**
- * Return the statement type, one of {@link #STMT_TYPE_STATEMENT},
- * {@link #STMT_TYPE_PREPARED_STATEMENT}, or
- * {@link #STMT_TYPE_CALLABLE_STATEMENT}
- * @return statement type of translated command
- */
- public boolean isPrepared() {
- return prepared;
- }
-
-}
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/ValueRetriever.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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.extension;
-
-import java.sql.CallableStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Calendar;
-
-import com.metamatrix.connector.api.TypeFacility;
-
-/**
- * Specifies how value objects are retrieved from JDBC ResultSet for different
- * expected output types. This allows database-specific connectors to use
- * specialized methods like getClob() rather than generic getObject() methods.
- */
-public interface ValueRetriever {
-
- /**
- * Retrieve the value at <code>columnIndex</code> from the specified <code>results</code>.
- *
- * @param results The results to retrieve the value from
- * @param columnIndex The index to use when retrieving the value
- * @param expectedType The MetaMatrix runtime type class that is expected to be returned, as
- * specified by the select statement of the query
- * @param cal The Calendar to be used for Date, Time, and Timestamp values
- * @return The object that was retrieved
- * @throws SQLException If an error occurred retrieving the value
- */
- 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
- * @param results
- * @param parameterIndex
- * @param expectedType
- * @param cal
- * @return
- * @throws SQLException
- */
- Object retrieveValue(CallableStatement results, int parameterIndex, Class expectedType, Calendar cal, TypeFacility typeFacility) throws SQLException;
-}
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/informix/InformixSQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -27,12 +27,12 @@
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.SourceSystemFunctions;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
-import com.metamatrix.connector.jdbc.extension.impl.DropFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.DropFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.Translator;
/**
*/
-public class InformixSQLTranslator extends SQLTranslator {
+public class InformixSQLTranslator extends Translator {
@Override
public void initialize(ConnectorEnvironment env) throws ConnectorException {
@@ -41,7 +41,7 @@
}
@Override
- public String getConnectionTestQuery() {
+ public String getDefaultConnectionTestQuery() {
return "select 'x' from informix.sysusers where 1=0"; //$NON-NLS-1$
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mm/MMSingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mm/MMSingleIdentityConnectionFactory.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mm/MMSingleIdentityConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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.mm;
-
-import com.metamatrix.connector.jdbc.*;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
-
-/**
- * @since 4.3
- */
-public class MMSingleIdentityConnectionFactory 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/MySQLConvertModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLConvertModifier.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLConvertModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -25,8 +25,8 @@
import java.util.Arrays;
import java.util.List;
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
-import com.metamatrix.connector.jdbc.extension.impl.DropFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.DropFunctionModifier;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/mysql/MySQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -25,18 +25,17 @@
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.api.SourceSystemFunctions;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
+import com.metamatrix.connector.jdbc.translator.Translator;
/**
* @since 4.3
*/
-public class MySQLTranslator extends SQLTranslator {
+public class MySQLTranslator extends Translator {
@Override
public void initialize(ConnectorEnvironment env) throws ConnectorException {
@@ -45,18 +44,18 @@
}
@Override
- public String translateLiteralDate(Date dateValue, Calendar cal) {
- return "DATE('" + formatDateValue(dateValue, cal) + "')"; //$NON-NLS-1$//$NON-NLS-2$
+ public String translateLiteralDate(Date dateValue) {
+ return "DATE('" + formatDateValue(dateValue) + "')"; //$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$
+ public String translateLiteralTime(Time timeValue) {
+ return "TIME('" + formatDateValue(timeValue) + "')"; //$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$
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "TIMESTAMP('" + formatDateValue(timestampValue) + "')"; //$NON-NLS-1$//$NON-NLS-2$
}
@Override
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ConcatFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -27,7 +27,7 @@
import java.util.List;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.language.ICriteria;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
@@ -54,7 +54,7 @@
}
/**
- * @see com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier#modify(com.metamatrix.connector.language.IFunction)
+ * @see com.metamatrix.connector.jdbc.translator.BasicFunctionModifier#modify(com.metamatrix.connector.language.IFunction)
*/
public IExpression modify(IFunction function) {
List when = new ArrayList();
@@ -111,7 +111,7 @@
}
/**
- * @see com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier#translate(com.metamatrix.connector.language.IFunction)
+ * @see com.metamatrix.connector.jdbc.translator.BasicFunctionModifier#translate(com.metamatrix.connector.language.IFunction)
*/
public List translate(IFunction function) {
return null; //allow default translation
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/DayWeekQuarterFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/DayWeekQuarterFunctionModifier.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/DayWeekQuarterFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -22,8 +22,8 @@
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.jdbc.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.*;
/**
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ExtractFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ExtractFunctionModifier.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/ExtractFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -25,8 +25,8 @@
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.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
Modified: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LeftOrRightFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -23,8 +23,8 @@
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.jdbc.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.*;
/**
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LocateFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LocateFunctionModifier.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/LocateFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -22,8 +22,8 @@
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.jdbc.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.*;
/**
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/Log10FunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/Log10FunctionModifier.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/Log10FunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -22,8 +22,8 @@
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.jdbc.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.*;
public class Log10FunctionModifier extends BasicFunctionModifier implements FunctionModifier {
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/MonthOrDayNameFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -22,8 +22,8 @@
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.jdbc.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.*;
/**
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleConvertModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -25,9 +25,9 @@
import java.util.List;
import com.metamatrix.connector.api.ConnectorLogger;
-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.jdbc.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.DropFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
@@ -46,7 +46,7 @@
/**
* 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)
+ * @see com.metamatrix.connector.jdbc.translator.FunctionModifier#translate(com.metamatrix.connector.language.IFunction)
*/
public List translate(IFunction function) {
return null;
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleResultsTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleResultsTranslator.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleResultsTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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.oracle;
-
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.sql.Types;
-import java.util.Calendar;
-
-import com.metamatrix.connector.jdbc.extension.impl.BasicResultsTranslator;
-
-public class OracleResultsTranslator extends BasicResultsTranslator {
- protected void bindValue(PreparedStatement stmt, Object param, Class paramType, int i, Calendar cal) throws SQLException {
- if(param == null && Object.class.equals(paramType)){
- //Oracle drive does not support JAVA_OBJECT type
- stmt.setNull(i, Types.LONGVARBINARY);
- return;
- }
- super.bindValue(stmt, param, paramType, i, cal);
- }
-}
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -24,14 +24,21 @@
*/
package com.metamatrix.connector.jdbc.oracle;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Types;
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.SourceSystemFunctions;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
-import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
+import com.metamatrix.connector.jdbc.JDBCPlugin;
+import com.metamatrix.connector.jdbc.translator.AliasModifier;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IGroup;
@@ -44,7 +51,7 @@
/**
*/
-public class OracleSQLTranslator extends SQLTranslator {
+public class OracleSQLTranslator extends Translator {
public final static String HINT_PREFIX = "/*+"; //$NON-NLS-1$
public final static String DUAL = "DUAL"; //$NON-NLS-1$
@@ -223,8 +230,52 @@
}
@Override
- public String getConnectionTestQuery() {
+ public String getDefaultConnectionTestQuery() {
return "Select 'x' from DUAL"; //$NON-NLS-1$
}
+ @Override
+ public void bindValue(PreparedStatement stmt, Object param, Class paramType, int i) throws SQLException {
+ if(param == null && Object.class.equals(paramType)){
+ //Oracle drive does not support JAVA_OBJECT type
+ stmt.setNull(i, Types.LONGVARBINARY);
+ return;
+ }
+ super.bindValue(stmt, param, paramType, i);
+ }
+
+ @Override
+ public void afterInitialConnectionCreation(Connection connection) {
+ String errorStr = JDBCPlugin.Util.getString("ConnectionListener.failed_to_report_oracle_connection_details"); //$NON-NLS-1$
+ ResultSet rs = null;
+ Statement stmt = null;
+ try {
+ stmt = connection.createStatement();
+ rs = stmt.executeQuery("select * from v$instance");
+
+ int columnCount = rs.getMetaData().getColumnCount();
+ while (rs.next()) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 1; i <= columnCount; i++) {
+ sb.append(rs.getMetaData().getColumnName(i)).append("=").append(rs.getString(i)).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ // log the queried information
+ getEnvironment().getLogger().logInfo(sb.toString());
+ }
+
+ } catch (SQLException e) {
+ getEnvironment().getLogger().logInfo(errorStr);
+ }finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (stmt != null) {
+ stmt.close();
+ }
+ } catch (SQLException e1) {
+ getEnvironment().getLogger().logInfo(errorStr);
+ }
+ }
+ }
}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSingleIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSingleIdentityConnectionFactory.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleSingleIdentityConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,120 +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.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import com.metamatrix.connector.api.ConnectorEnvironment;
-import com.metamatrix.connector.jdbc.ConnectionListener;
-import com.metamatrix.connector.jdbc.ConnectionQueryStrategy;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.DefaultConnectionListener;
-import com.metamatrix.connector.jdbc.JDBCPlugin;
-import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
-
-public class OracleSingleIdentityConnectionFactory extends JDBCSingleIdentityConnectionFactory{
- private String queryTest = "Select 'x' from DUAL"; //$NON-NLS-1$
- private ConnectionListener connectionListener = new OracleConnectionListener();
-
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-
- /**
- * @see com.metamatrix.connector.jdbc.JDBCSourceConnectionFactory#getConnectionListener()
- */
- protected ConnectionListener getConnectionListener() {
- return connectionListener;
- }
-
- /**
- * A connection listener strategy class, where gets called after the connection
- * is created and before connection is terminated.
- */
- private static class OracleConnectionListener extends DefaultConnectionListener{
- // Since this going to used inside a pool, we would like to report only once
- boolean alreadyReportedDetails = false;
-
- /**
- * log some debug information about the oracle driver being used.
- * defect request 13979 & 13978
- * @see com.metamatrix.connector.jdbc.ConnectionStrategy#afterConnectionCreation(java.sql.Connection)
- */
- public void afterConnectionCreation(Connection connection, ConnectorEnvironment env) {
- super.afterConnectionCreation(connection, env);
-
- if (alreadyReportedDetails) {
- return;
- }
-
- alreadyReportedDetails = true;
- String errorStr = JDBCPlugin.Util.getString("ConnectionListener.failed_to_report_oracle_connection_details"); //$NON-NLS-1$
- executeSQL(connection, env, "select * from v$instance", errorStr); //$NON-NLS-1$
- }
-
- /**
- * Execute any SQL aginst the connection
- * @param connection
- * @param env
- * @param sql
- */
- private void executeSQL(Connection connection, ConnectorEnvironment env, String sql, String errorStr) {
- ResultSet rs = null;
- Statement stmt = null;
- try {
- stmt = connection.createStatement();
- rs = stmt.executeQuery(sql);
-
-
- int columnCount = rs.getMetaData().getColumnCount();
- while (rs.next()) {
- StringBuffer sb = new StringBuffer();
- for (int i = 1; i <= columnCount; i++) {
- sb.append(rs.getMetaData().getColumnName(i)).append("=").append(rs.getString(i)).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- // log the queried information
- env.getLogger().logInfo(sb.toString());
- }
-
- } catch (SQLException e) {
- env.getLogger().logInfo(errorStr);
- }finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (stmt != null) {
- stmt.close();
- }
- } catch (SQLException e1) {
- env.getLogger().logInfo(errorStr);
- }
- }
- }
- }
-}
Deleted: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleUserIdentityConnectionFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleUserIdentityConnectionFactory.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/oracle/OracleUserIdentityConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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.oracle;
-
-import com.metamatrix.connector.jdbc.*;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCUserIdentityConnectionFactory;
-
-public class OracleUserIdentityConnectionFactory extends JDBCUserIdentityConnectionFactory{
- private String queryTest = "Select 'x' from DUAL"; //$NON-NLS-1$
-
- protected ConnectionStrategy createConnectionStrategy() {
- return new ConnectionQueryStrategy(queryTest);
- }
-
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/DatePartFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/DatePartFunctionModifier.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/DatePartFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -22,7 +22,7 @@
package com.metamatrix.connector.jdbc.postgresql;
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLConvertModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -27,9 +27,9 @@
import java.util.Arrays;
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.jdbc.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.DropFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/postgresql/PostgreSQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -25,17 +25,16 @@
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.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.jdbc.translator.AliasModifier;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.language.IAggregate;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.ILimit;
@@ -46,7 +45,7 @@
/**
* @since 4.3
*/
-public class PostgreSQLTranslator extends SQLTranslator {
+public class PostgreSQLTranslator extends Translator {
public void initialize(ConnectorEnvironment env) throws ConnectorException {
@@ -88,18 +87,18 @@
}
@Override
- public String translateLiteralDate(Date dateValue, Calendar cal) {
- return "DATE '" + formatDateValue(dateValue, cal) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ public String translateLiteralDate(Date dateValue) {
+ return "DATE '" + formatDateValue(dateValue) + "'"; //$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$
+ public String translateLiteralTime(Time timeValue) {
+ return "TIME '" + formatDateValue(timeValue) + "'"; //$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$
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "to_timestamp('" + formatDateValue(timestampValue) + "', 'YYYY-MM-DD HH24:MI:SS.US')"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
}
@Override
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sqlserver/SqlServerSQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -27,9 +27,8 @@
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
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;
+import com.metamatrix.connector.jdbc.translator.AliasModifier;
/**
*/
@@ -37,7 +36,7 @@
public void initialize(ConnectorEnvironment env) throws ConnectorException {
super.initialize(env);
- //FEDERATE-168 remove mod modifier for SQL Server 2008
+ //TEIID-31 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$
}
@@ -46,10 +45,5 @@
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$
- }
-
+
}
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/ssl/JDBCSequeLinkSingleIdentityConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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.
- */
-
-/*
- * com.metamatrix.connector.jdbc.ssl.JDBCSequeLinkSingleIdentityConnectionFactory
- * Created by JChoate on Jan 28, 2005
- * (c) 2005 MetaMatrix, Inc.
- */
-package com.metamatrix.connector.jdbc.ssl;
-
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.ConnectionQueryStrategy;
-import com.metamatrix.connector.jdbc.ConnectionStrategy;
-import com.metamatrix.connector.jdbc.JDBCPropertyNames;
-import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
-import com.metamatrix.connector.jdbc.JDBCSourceConnection;
-
-public class JDBCSequeLinkSingleIdentityConnectionFactory extends
- JDBCSingleIdentityConnectionFactory {
-
- private static final String JDBC_CAPABILITIES = "com.metamatrix.connector.jdbc.JDBCCapabilities"; //$NON-NLS-1$
- private static final String ORACLE_CAPABILITIES = "com.metamatrix.connector.jdbc.oracle.OracleCapabilities"; //$NON-NLS-1$
- private static final String DB2_CAPABILITIES = "com.metamatrix.connector.jdbc.db2.DB2Capabilities"; //$NON-NLS-1$
- private static final String SYBASE_CAPABILITIES = "com.metamatrix.connector.jdbc.sybase.SybaseCapabilities"; //$NON-NLS-1$
- private static final String SQLSERVER_CAPABILITIES = "com.metamatrix.connector.jdbc.sqlserver.SqlServerCapabilities"; //$NON-NLS-1$
-
- // Fix for Case 4049 - USTranscom
- // By default we were not creating a connectionStrategy and therefore not testing connections
- // when pulling them from the pool, this caused problems when the SequeLink proxy would go down
- // and come back up since we never removed the bad connection.
- // Adding this logic lets us run the test query when getting connections from the pool.
- // This is a slight hack, ultimately we want to add an option to Oracle, DB2, etc.. connectorTypes
- // to select ssl mode and remove this Connector type.
- protected ConnectionStrategy createConnectionStrategy() {
-
- String capabilityClass = this.getConnectorEnvironment().getProperties().getProperty(JDBCPropertyNames.EXT_CAPABILITY_CLASS, JDBC_CAPABILITIES);
- String queryTest = null;
-
- if (capabilityClass.equals(ORACLE_CAPABILITIES)) {
- queryTest = "Select 'x' from DUAL"; //$NON-NLS-1$
- } else if (capabilityClass.equals(DB2_CAPABILITIES)) {
- queryTest = "Select 'x' from sysibm.systables where 1 = 2"; //$NON-NLS-1$
- } else if (capabilityClass.equals(SYBASE_CAPABILITIES)) {
- queryTest = "Select 'x'"; //$NON-NLS-1$
- } else if (capabilityClass.equals(SQLSERVER_CAPABILITIES)) {
- queryTest = "Select 'x'"; //$NON-NLS-1$
- } else {
- return null;
- }
- return new ConnectionQueryStrategy(queryTest);
- }
-
- /**
- * This creates a JDBC connection.
- * It overrides the functionality in abstract class com.metamatrix.connector.jdbc.JDBCSourceConnectionFactory
- * @throws ConnectorException if there is an error establishing the connection.
- */
- protected com.metamatrix.connector.api.Connection createJDBCConnection(Driver driver, String url, int transactionIsolationLevel, Properties userProps) throws ConnectorException {
- Connection connection = null;
-
- // Connect
- try {
- connection = driver.connect(url, userProps);
- if(transactionIsolationLevel != NO_ISOLATION_LEVEL_SET){
- connection.setTransactionIsolation(transactionIsolationLevel);
- }
- } catch ( SQLException e ) {
- throw new ConnectorException(e);
- }
-
- return new JDBCSourceConnection(connection, getConnectorEnvironment(), createConnectionStrategy(), getConnectionListener(), getResultsTranslator(), getSqlTranslator());
- }
-}
Modified: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/ModFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -25,7 +25,7 @@
import java.util.List;
import com.metamatrix.connector.api.TypeFacility.RUNTIME_TYPES;
-import com.metamatrix.connector.jdbc.extension.impl.AliasModifier;
+import com.metamatrix.connector.jdbc.translator.AliasModifier;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseConvertModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -25,9 +25,9 @@
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.jdbc.translator.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.DropFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.*;
/**
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/sybase/SybaseSQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -27,13 +27,14 @@
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
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;
+import com.metamatrix.connector.jdbc.translator.AliasModifier;
+import com.metamatrix.connector.jdbc.translator.SubstringFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.Translator;
+import com.metamatrix.connector.language.ILimit;
/**
*/
-public class SybaseSQLTranslator extends SQLTranslator {
+public class SybaseSQLTranslator extends Translator {
/*
* @see com.metamatrix.connector.jdbc.extension.SQLTranslator#initialize(com.metamatrix.data.api.ConnectorEnvironment, com.metamatrix.data.metadata.runtime.RuntimeMetadata)
@@ -62,6 +63,11 @@
@Override
public boolean hasTimeType() {
return false;
- }
+ }
+ @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$
+ }
+
}
Copied: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/AliasModifier.java (from rev 475, trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/AliasModifier.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/AliasModifier.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/AliasModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -0,0 +1,51 @@
+/*
+ * 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.translator;
+
+import com.metamatrix.connector.language.*;
+
+/**
+ */
+public class AliasModifier extends BasicFunctionModifier {
+ // The alias to use
+ private String alias;
+
+ /**
+ * Constructor that takes the alias to use for functions.
+ * @param alias The alias to replace the incoming function name with
+ */
+ public AliasModifier(String alias) {
+ this.alias = alias;
+ }
+
+ /**
+ * @see com.metamatrix.connector.jdbc.translator.FunctionModifier#modify(com.metamatrix.connector.language.IFunction)
+ */
+ public IExpression modify(IFunction function) {
+ function.setName(alias);
+ return function;
+ }
+
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/AliasModifier.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BasicFunctionModifier.java (from rev 475, trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/BasicFunctionModifier.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BasicFunctionModifier.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BasicFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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.connector.jdbc.translator;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+
+import com.metamatrix.connector.api.TypeFacility;
+import com.metamatrix.connector.language.IExpression;
+import com.metamatrix.connector.language.IFunction;
+
+/**
+ */
+public abstract class BasicFunctionModifier implements FunctionModifier {
+
+ /*
+ * Public sharing part for the mapping between class and type in format of Map<class->Integer>.
+ */
+ public static final int STRING = 0;
+ public static final int CHAR = 1;
+ public static final int BOOLEAN = 2;
+ public static final int BYTE = 3;
+ public static final int SHORT = 4;
+ public static final int INTEGER = 5;
+ public static final int LONG = 6;
+ public static final int BIGINTEGER = 7;
+ public static final int FLOAT = 8;
+ public static final int DOUBLE = 9;
+ public static final int BIGDECIMAL = 10;
+ public static final int DATE = 11;
+ public static final int TIME = 12;
+ public static final int TIMESTAMP = 13;
+ public static final int OBJECT = 14;
+ public static final int BLOB = 15;
+ public static final int CLOB = 16;
+ public static final int XML = 17;
+
+ public static final Map typeMap = new HashMap();
+
+ static {
+ typeMap.put(TypeFacility.RUNTIME_TYPES.STRING, new Integer(STRING));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.CHAR, new Integer(CHAR));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.BOOLEAN, new Integer(BOOLEAN));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.BYTE, new Integer(BYTE));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.SHORT, new Integer(SHORT));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.INTEGER, new Integer(INTEGER));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.LONG, new Integer(LONG));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.BIG_INTEGER, new Integer(BIGINTEGER));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.FLOAT, new Integer(FLOAT));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.DOUBLE, new Integer(DOUBLE));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL, new Integer(BIGDECIMAL));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.DATE, new Integer(DATE));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.TIME, new Integer(TIME));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.TIMESTAMP, new Integer(TIMESTAMP));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.OBJECT, new Integer(OBJECT));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.BLOB, new Integer(BLOB));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.CLOB, new Integer(CLOB));
+ typeMap.put(TypeFacility.RUNTIME_TYPES.XML, new Integer(XML));
+ }
+
+ /**
+ * Subclass should override this method as needed.
+ * @see com.metamatrix.connector.jdbc.translator.FunctionModifier#modify(com.metamatrix.connector.language.IFunction)
+ */
+ public IExpression modify(IFunction function) {
+ return function;
+ }
+
+ /**
+ * Subclass should override this method as needed.
+ * @see com.metamatrix.connector.jdbc.translator.FunctionModifier#translate(com.metamatrix.connector.language.IFunction)
+ */
+ public List translate(IFunction function) {
+ List objs = new ArrayList();
+ objs.add(function.getName());
+ objs.add("("); //$NON-NLS-1$
+ IExpression[] params = function.getParameters();
+ if(params.length > 0) {
+ objs.add(params[0]);
+ if(params.length > 1) {
+ for(int i=1; i<params.length; i++) {
+ objs.add(", "); //$NON-NLS-1$
+ objs.add(params[i]);
+ }
+ }
+ }
+ objs.add(")"); //$NON-NLS-1$
+
+ return objs;
+ }
+
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BasicFunctionModifier.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BindValueVisitor.java (from rev 476, 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/translator/BindValueVisitor.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BindValueVisitor.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.connector.jdbc.translator;
+
+import com.metamatrix.connector.language.ICompareCriteria;
+import com.metamatrix.connector.language.IExistsCriteria;
+import com.metamatrix.connector.language.IFunction;
+import com.metamatrix.connector.language.IInCriteria;
+import com.metamatrix.connector.language.IInlineView;
+import com.metamatrix.connector.language.IInsert;
+import com.metamatrix.connector.language.ILanguageObject;
+import com.metamatrix.connector.language.ILikeCriteria;
+import com.metamatrix.connector.language.ILiteral;
+import com.metamatrix.connector.language.IScalarSubquery;
+import com.metamatrix.connector.language.ISearchedCaseExpression;
+import com.metamatrix.connector.language.ISetClause;
+import com.metamatrix.connector.language.ISubqueryCompareCriteria;
+import com.metamatrix.connector.visitor.framework.HierarchyVisitor;
+
+/**
+ * This visitor will mark literals in well known locations as bindValues.
+ * These values will be put in the generated SQL as ?
+ * and have the corresponding value set on the PreparedStatement
+ */
+final class BindValueVisitor extends HierarchyVisitor {
+
+ private boolean replaceWithBinding = false;
+
+ public void visit(IInlineView obj) {
+ replaceWithBinding = false;
+ visitNode(obj.getQuery());
+ }
+
+ public void visit(IScalarSubquery obj) {
+ replaceWithBinding = false;
+ super.visit(obj);
+ }
+
+ public void visit(IExistsCriteria obj) {
+ replaceWithBinding = false;
+ super.visit(obj);
+ }
+
+ public void visit(ISubqueryCompareCriteria obj) {
+ replaceWithBinding = false;
+ super.visit(obj);
+ }
+
+ /**
+ * In general it is not appropriate to use bind values within a function
+ * unless the particulars of the function parameters are know.
+ * As needed, other visitors or modifiers can set the literals used within
+ * a particular function as bind variables.
+ */
+ public void visit(IFunction obj) {
+ replaceWithBinding = false;
+ super.visit(obj);
+ }
+
+ public void visit(IInCriteria obj) {
+ replaceWithBinding = true;
+ visitNodes(obj.getRightExpressions());
+ }
+
+ public void visit(ILikeCriteria obj) {
+ replaceWithBinding = true;
+ visitNode(obj.getRightExpression());
+ }
+
+ /**
+ * Note that this will only visit the right expression. In general most compares
+ * involving literals will be something like element = literal (this is enforced as
+ * much as possible by the QueryRewriter). In rare circumstances, it is possible to
+ * have literal = literal (most notably null <> null). Using bind variables on
+ * both sides of the operator is not supported by most databases.
+ */
+ public void visit(ICompareCriteria obj) {
+ replaceWithBinding = true;
+ visitNode(obj.getRightExpression());
+ }
+
+ /**
+ * Will look for bind values in the when criteria.
+ * 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) {
+ for (int i = 0; i < obj.getWhenCount(); i++) {
+ visitNode(obj.getWhenCriteria(i));
+ }
+ }
+
+ @Override
+ public void visit(IInsert obj) {
+ replaceWithBinding = true;
+ visitNodes(obj.getValues());
+ }
+
+ @Override
+ public void visit(ISetClause obj) {
+ replaceWithBinding = true;
+ visitNode(obj.getValue());
+ }
+
+ public void visit(ILiteral obj) {
+ if (replaceWithBinding || TranslatedCommand.isBindEligible(obj)) {
+ obj.setBindValue(true);
+ }
+ }
+
+ public void visitNode(ILanguageObject obj) {
+ boolean replacementMode = replaceWithBinding;
+ super.visitNode(obj);
+ this.replaceWithBinding = replacementMode;
+ }
+}
\ No newline at end of file
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/BindValueVisitor.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/DropFunctionModifier.java (from rev 475, trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/DropFunctionModifier.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/DropFunctionModifier.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/DropFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -0,0 +1,50 @@
+/*
+ * 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.translator;
+
+import com.metamatrix.connector.jdbc.JDBCPlugin;
+import com.metamatrix.connector.language.*;
+
+/**
+ * This FunctionModifier will cause this function to be dropped by replacing the function
+ * with (by default) the first argument of the function. Optionally, the replacement index
+ * can be overridden. This modifier should only be used with functions having the
+ * minimum or more number of arguments.
+ */
+public class DropFunctionModifier extends BasicFunctionModifier implements FunctionModifier {
+
+ private int replaceIndex = 0;
+
+ public void setReplaceIndex(int index) {
+ this.replaceIndex = index;
+ }
+
+ public IExpression modify(IFunction function) {
+ IExpression[] args = function.getParameters();
+ if(args.length <= replaceIndex) {
+ throw new IllegalArgumentException(JDBCPlugin.Util.getString("DropFunctionModifier.DropFunctionModifier_can_only_be_used_on_functions_with___1") + function); //$NON-NLS-1$
+ }
+
+ return args[replaceIndex];
+ }
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/DropFunctionModifier.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/EscapeSyntaxModifier.java (from rev 475, trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/EscapeSyntaxModifier.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/EscapeSyntaxModifier.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/EscapeSyntaxModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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.connector.jdbc.translator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.metamatrix.connector.language.IFunction;
+
+/**
+ * Wrap a function in standard JDBC escape syntax. In some cases, the
+ * driver can then convert to the correct database syntax for us.
+ * @since 5.0
+ */
+public class EscapeSyntaxModifier extends BasicFunctionModifier {
+
+ public EscapeSyntaxModifier() {
+ super();
+ }
+
+ /**
+ * @see com.metamatrix.connector.jdbc.translator.BasicFunctionModifier#translate(com.metamatrix.connector.language.IFunction)
+ * @since 5.0
+ */
+ public List translate(IFunction function) {
+ List normalParts = super.translate(function);
+ List wrappedParts = new ArrayList(normalParts.size() + 2);
+ wrappedParts.add("{fn "); //$NON-NLS-1$
+ wrappedParts.addAll(normalParts);
+ wrappedParts.add("}"); //$NON-NLS-1$
+ return wrappedParts;
+ }
+
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/EscapeSyntaxModifier.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/FunctionModifier.java (from rev 475, trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/FunctionModifier.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/FunctionModifier.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/FunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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.translator;
+
+import java.util.List;
+
+import com.metamatrix.connector.language.IExpression;
+import com.metamatrix.connector.language.IFunction;
+
+/**
+ * Implementations of this interface are used to modify metamatrix functions
+ * coming in to the connector into alternate datasource-specific language, if
+ * necessary.
+ */
+public interface FunctionModifier {
+
+ /**
+ * Takes an IFunction and returns the datasource-specific IExpression,
+ * or can possibly return the unmodified function parameter itself.
+ * @param function
+ * @return IExpression or unmodified function
+ * @since 4.2
+ */
+ IExpression modify(IFunction function);
+
+ /**
+ * Return a List of translated parts (LanguageObjects and Strings), or null
+ * if this FunctionModifier wishes to rely on the default translation of the
+ * conversion visitor.
+ * @param function IFunction to be translated
+ * @return List of translated parts, or null
+ * @since 4.2
+ */
+ List translate(IFunction function);
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/FunctionModifier.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SQLConversionVisitor.java (from rev 476, 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/translator/SQLConversionVisitor.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SQLConversionVisitor.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -0,0 +1,340 @@
+/*
+ * 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.translator;
+
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import com.metamatrix.connector.api.ExecutionContext;
+import com.metamatrix.connector.api.TypeFacility;
+import com.metamatrix.connector.language.IBulkInsert;
+import com.metamatrix.connector.language.ICommand;
+import com.metamatrix.connector.language.IElement;
+import com.metamatrix.connector.language.IFunction;
+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.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 Translator#getTranslationVisitor(RuntimeMetadata) using this method}.
+ */
+public class SQLConversionVisitor extends SQLStringVisitor{
+
+ 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 Map<String, FunctionModifier> modifiers;
+ private ExecutionContext context;
+ private Translator translator;
+
+ private boolean prepared;
+
+ private List preparedValues = new ArrayList();
+ private List preparedTypes = new ArrayList();
+
+ public SQLConversionVisitor(Translator translator) {
+ this.translator = translator;
+ this.prepared = translator.usePreparedStatements();
+ this.modifiers = translator.getFunctionModifiers();
+ }
+
+ public void visit(IBulkInsert obj) {
+ this.prepared = true;
+
+ super.visit(obj);
+
+ for (int i = 0; i < obj.getElements().size(); i++) {
+ IElement element = (IElement) obj.getElements().get(i);
+ this.preparedTypes.add(element.getType());
+ }
+
+ this.preparedValues = obj.getRows();
+ }
+
+ /**
+ * @param type
+ * @param object
+ * @param valuesbuffer
+ */
+ private void translateSQLType(Class type, Object obj, StringBuffer valuesbuffer) {
+ if (obj == null) {
+ valuesbuffer.append(NULL);
+ } else {
+ if(Number.class.isAssignableFrom(type)) {
+ boolean useFormatting = false;
+
+ if (Double.class.isAssignableFrom(type)){
+ double value = ((Double)obj).doubleValue();
+ useFormatting = (value <= SCIENTIC_LOW || value >= SCIENTIC_HIGH);
+ }
+ else if (Float.class.isAssignableFrom(type)){
+ float value = ((Float)obj).floatValue();
+ useFormatting = (value <= SCIENTIC_LOW || value >= SCIENTIC_HIGH);
+ }
+ // The formatting is to avoid the so-called "scientic-notation"
+ // where toString will use for numbers greater than 10p7 and
+ // less than 10p-3, where database may not understand.
+ if (useFormatting) {
+ synchronized (DECIMAL_FORMAT) {
+ valuesbuffer.append(DECIMAL_FORMAT.format(obj));
+ }
+ }
+ else {
+ valuesbuffer.append(obj);
+ }
+ } else if(type.equals(TypeFacility.RUNTIME_TYPES.BOOLEAN)) {
+ valuesbuffer.append(translator.translateLiteralBoolean((Boolean)obj));
+ } else if(type.equals(TypeFacility.RUNTIME_TYPES.TIMESTAMP)) {
+ valuesbuffer.append(translator.translateLiteralTimestamp((Timestamp)obj));
+ } else if(type.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
+ valuesbuffer.append(translator.translateLiteralTime((Time)obj));
+ } else if(type.equals(TypeFacility.RUNTIME_TYPES.DATE)) {
+ valuesbuffer.append(translator.translateLiteralDate((java.sql.Date)obj));
+ } else {
+ // If obj is string, toSting() will not create a new String
+ // object, it returns it self, so new object creation.
+ valuesbuffer.append("'") //$NON-NLS-1$
+ .append(escapeString(obj.toString()))
+ .append("'"); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /**
+ * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.IProcedure)
+ */
+ public void visit(IProcedure obj) {
+ this.prepared = true;
+ /*
+ * preparedValues is now a list of procedure params instead of just values
+ */
+ this.preparedValues = obj.getParameters();
+ super.buffer.append(generateSqlForStoredProcedure(obj));
+ }
+
+ /**
+ * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.IFunction)
+ */
+ public void visit(IFunction obj) {
+ if(this.modifiers != null) {
+ FunctionModifier functionModifier = (FunctionModifier)this.modifiers.get(obj.getName().toLowerCase());
+ if(functionModifier != null) {
+ List parts = functionModifier.translate(obj);
+
+ // null means the FunctionModifier will rely on default translation
+ if (parts != null) {
+ Iterator iter = parts.iterator();
+ while(iter.hasNext()) {
+ Object part = iter.next();
+ if(part instanceof String) {
+ buffer.append(part);
+ } else {
+ append((ILanguageObject)part);
+ }
+ }
+ return;
+ }
+ }
+ }
+ super.visit(obj);
+ }
+
+ /**
+ * @see com.metamatrix.connector.visitor.util.SQLStringVisitor#visit(com.metamatrix.connector.language.ILiteral)
+ */
+ public void visit(ILiteral obj) {
+ if (this.prepared && obj.isBindValue()) {
+ buffer.append(UNDEFINED_PARAM);
+ preparedValues.add(obj.getValue());
+ preparedTypes.add(obj.getType());
+ } else {
+ translateSQLType(obj.getType(), obj.getValue(), buffer);
+ }
+ }
+
+ /**
+ * Set the per-command execution context on this visitor.
+ * @param context ExecutionContext
+ * @since 4.3
+ */
+ public void setExecutionContext(ExecutionContext context) {
+ this.context = context;
+ }
+
+ /**
+ * Retrieve the per-command execution context for this visitor
+ * (intended for subclasses to use).
+ * @return
+ * @since 4.3
+ */
+ protected ExecutionContext getExecutionContext() {
+ return this.context;
+ }
+
+ protected String getSourceComment(ICommand command) {
+ return this.translator.getSourceComment(this.context, command);
+ }
+
+ /**
+ * This is a generic implementation. Subclass should override this method
+ * if necessary.
+ * @param exec The command for the stored procedure.
+ * @return String to be executed by CallableStatement.
+ */
+ protected String generateSqlForStoredProcedure(IProcedure exec) {
+ StringBuffer prepareCallBuffer = new StringBuffer();
+ prepareCallBuffer.append("{ "); //$NON-NLS-1$
+
+ List params = exec.getParameters();
+
+ //check whether a "?" is needed if there are returns
+ boolean needQuestionMark = false;
+ Iterator iter = params.iterator();
+ while(iter.hasNext()){
+ IParameter param = (IParameter)iter.next();
+ if(param.getDirection() == Direction.RETURN){
+ needQuestionMark = true;
+ break;
+ }
+ }
+
+ prepareCallBuffer.append(getSourceComment(exec));
+
+ if(needQuestionMark){
+ prepareCallBuffer.append("?="); //$NON-NLS-1$
+ }
+
+ prepareCallBuffer.append(" call ");//$NON-NLS-1$
+ prepareCallBuffer.append(exec.getMetadataID() != null ? getName(exec.getMetadataID()) : exec.getProcedureName());
+ prepareCallBuffer.append("("); //$NON-NLS-1$
+
+ int numberOfParameters = 0;
+ iter = params.iterator();
+ while(iter.hasNext()){
+ IParameter param = (IParameter)iter.next();
+ if(param.getDirection() == Direction.IN || param.getDirection() == Direction.OUT || param.getDirection() == Direction.INOUT){
+ if(numberOfParameters > 0){
+ prepareCallBuffer.append(","); //$NON-NLS-1$
+ }
+ prepareCallBuffer.append("?"); //$NON-NLS-1$
+ numberOfParameters++;
+ }
+ }
+ prepareCallBuffer.append(")"); //$NON-NLS-1$
+ prepareCallBuffer.append("}"); //$NON-NLS-1$
+ return prepareCallBuffer.toString();
+ }
+
+ /**
+ * @return the preparedValues
+ */
+ List getPreparedValues() {
+ return this.preparedValues;
+ }
+
+ /**
+ * @return the preparedValues
+ */
+ List getPreparedTypes() {
+ return this.preparedTypes;
+ }
+
+ public boolean isPrepared() {
+ return prepared;
+ }
+
+ public void setPrepared(boolean prepared) {
+ this.prepared = prepared;
+ }
+
+ @Override
+ protected boolean useAsInGroupAlias() {
+ return this.translator.useAsInGroupAlias();
+ }
+
+ @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));
+ }
+
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SQLConversionVisitor.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SubstringFunctionModifier.java (from rev 475, trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/extension/impl/SubstringFunctionModifier.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SubstringFunctionModifier.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SubstringFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -0,0 +1,63 @@
+/*
+ * 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.translator;
+
+import com.metamatrix.connector.language.IExpression;
+import com.metamatrix.connector.language.IFunction;
+import com.metamatrix.connector.language.ILanguageFactory;
+
+/**
+ * Common logic for Substring modifiers requiring 3 parameters
+ */
+public class SubstringFunctionModifier extends BasicFunctionModifier {
+
+ private ILanguageFactory languageFactory;
+ private String length_function;
+
+ public SubstringFunctionModifier(ILanguageFactory languageFactory, String substring_function, String length_function) {
+ this.languageFactory = languageFactory;
+ this.length_function = length_function;
+ }
+
+ /**
+ * @see com.metamatrix.connector.jdbc.translator.FunctionModifier#modify(com.metamatrix.query.sql.symbol.Function)
+ */
+ public IExpression modify(IFunction function) {
+ IExpression[] args = function.getParameters();
+ IExpression[] newArgs = new IExpression[3];
+ function.setParameters(newArgs);
+
+ newArgs[0] = args[0];
+ newArgs[1] = args[1];
+
+ if(args.length == 2) {
+ newArgs[2] = languageFactory.createFunction(length_function, new IExpression[] { args[0] }, Integer.class);
+ } else {
+ newArgs[2] = args[2];
+ }
+
+ function.setParameters(newArgs);
+
+ return function;
+ }
+}
\ No newline at end of file
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/SubstringFunctionModifier.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/TranslatedCommand.java (from rev 476, 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/translator/TranslatedCommand.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/TranslatedCommand.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -0,0 +1,171 @@
+/*
+ * 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.translator;
+
+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.jdbc.util.FunctionReplacementVisitor;
+import com.metamatrix.connector.language.ICommand;
+import com.metamatrix.connector.language.ILiteral;
+import com.metamatrix.connector.visitor.util.CollectorVisitor;
+
+/**
+ * This is a utility class used to translate an ICommand using a SQLConversionVisitor.
+ * The SQLConversionVisitor should not be invoked directly; this object will use it to
+ * translate the ICommand.
+ */
+public class TranslatedCommand {
+
+ private String sql;
+ private boolean prepared;
+ private List preparedValues;
+ private List preparedTypes;
+
+ private SQLConversionVisitor sqlConversionVisitor;
+ private FunctionReplacementVisitor functionVisitor;
+ private ExecutionContext context;
+ private Translator sqlTranslator;
+
+ /**
+ * Constructor, takes a SQLConversionVisitor subclass
+ * @param visitor a SQLConversionVisitor subclass
+ */
+ public TranslatedCommand(ExecutionContext context, Translator sqlTranslator){
+ this.context = context;
+ this.sqlTranslator = sqlTranslator;
+
+ Map<String, FunctionModifier> modifiers = sqlTranslator.getFunctionModifiers();
+ this.sqlConversionVisitor = new SQLConversionVisitor(sqlTranslator);
+ sqlConversionVisitor.setExecutionContext(context);
+ this.functionVisitor = new FunctionReplacementVisitor(modifiers);
+ }
+
+ public TranslatedCommand(ExecutionContext context, Translator sqlTranslator, SQLConversionVisitor sqlConversionVisitor, FunctionReplacementVisitor functionVisitor) {
+ this.context = context;
+ this.sqlTranslator = sqlTranslator;
+ this.sqlConversionVisitor = sqlConversionVisitor;
+ this.functionVisitor = functionVisitor;
+ }
+
+ /**
+ * The method to cause this object to do it's thing. This method should
+ * be called right after the constructor; afterward, all of the getter methods
+ * can be called to retrieve results.
+ * @param command ICommand to be translated
+ * @throws ConnectorException
+ */
+ public void translateCommand(ICommand command) throws ConnectorException {
+ this.sql = getSQL(command);
+ 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 (sqlTranslator.usePreparedStatements() || hasBindValue(command)) {
+ this.sqlConversionVisitor.setPrepared(true);
+
+ command.acceptVisitor(new BindValueVisitor());
+ }
+
+ this.sqlConversionVisitor.append(command);
+ return this.sqlConversionVisitor.toString();
+ }
+
+ /**
+ * Simple check to see if any values in the command should be replaced with bind values
+ *
+ * @param command
+ * @return
+ */
+ private boolean hasBindValue(ICommand command) {
+ for (ILiteral l : CollectorVisitor.collectObjects(ILiteral.class, command)) {
+ if (l.isBindValue() || isBindEligible(l)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param l
+ * @return
+ */
+ static boolean isBindEligible(ILiteral l) {
+ if (TypeFacility.RUNTIME_TYPES.CLOB.equals(l.getType())
+ || TypeFacility.RUNTIME_TYPES.BLOB.equals(l.getType())
+ || TypeFacility.RUNTIME_TYPES.OBJECT.equals(l.getType())) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * 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
+ */
+ public List getPreparedValues() {
+ return preparedValues;
+ }
+
+ /**
+ * Return List of types to set on a prepared statement, if
+ * necessary (see {@link #getStatementType})
+ * @return List of types to be set on a prepared statement
+ */
+ public List getPreparedTypes() {
+ return preparedTypes;
+ }
+
+ /**
+ * Get String SQL of translated command; but use
+ * {@link #nextLargeSetQuerySQL} if this command is
+ * a {@link #isLargeSetQuery large set query}
+ * @return SQL of translated command, or null if the
+ * command is a {@link #isLargeSetQuery large set query}
+ */
+ public String getSql() {
+ return sql;
+ }
+
+ /**
+ * Return the statement type, one of {@link #STMT_TYPE_STATEMENT},
+ * {@link #STMT_TYPE_PREPARED_STATEMENT}, or
+ * {@link #STMT_TYPE_CALLABLE_STATEMENT}
+ * @return statement type of translated command
+ */
+ public boolean isPrepared() {
+ return prepared;
+ }
+
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/TranslatedCommand.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/Translator.java (from rev 476, 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/translator/Translator.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/Translator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -0,0 +1,714 @@
+/*
+ * 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.translator;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+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.api.TypeFacility;
+import com.metamatrix.connector.api.ValueTranslator;
+import com.metamatrix.connector.internal.ConnectorPropertyNames;
+import com.metamatrix.connector.jdbc.JDBCPlugin;
+import com.metamatrix.connector.jdbc.JDBCPropertyNames;
+import com.metamatrix.connector.language.ICommand;
+import com.metamatrix.connector.language.ILanguageFactory;
+import com.metamatrix.connector.language.ILimit;
+import com.metamatrix.connector.language.IParameter;
+import com.metamatrix.connector.language.ISetQuery;
+import com.metamatrix.connector.language.IParameter.Direction;
+
+/**
+ * Base class for creating source SQL queries and retrieving results.
+ * Specific databases should override as necessary.
+ */
+public class Translator {
+
+ // Because the retrieveValue() method will be hit for every value of
+ // every JDBC result set returned, we do lots of weird special stuff here
+ // to improve the performance (most importantly to remove big if/else checks
+ // of every possible type.
+
+ private static final Map<Class<?>, Integer> TYPE_CODE_MAP = new HashMap<Class<?>, Integer>();
+
+ private static final int INTEGER_CODE = 0;
+ private static final int LONG_CODE = 1;
+ private static final int DOUBLE_CODE = 2;
+ private static final int BIGDECIMAL_CODE = 3;
+ private static final int SHORT_CODE = 4;
+ private static final int FLOAT_CODE = 5;
+ private static final int TIME_CODE = 6;
+ private static final int DATE_CODE = 7;
+ private static final int TIMESTAMP_CODE = 8;
+ private static final int BLOB_CODE = 9;
+ private static final int CLOB_CODE = 10;
+
+ static {
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.INTEGER, new Integer(INTEGER_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.LONG, new Integer(LONG_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.DOUBLE, new Integer(DOUBLE_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL, new Integer(BIGDECIMAL_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.SHORT, new Integer(SHORT_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.FLOAT, new Integer(FLOAT_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.TIME, new Integer(TIME_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.DATE, new Integer(DATE_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.TIMESTAMP, new Integer(TIMESTAMP_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.BLOB, new Integer(BLOB_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.CLOB, new Integer(CLOB_CODE));
+ }
+
+ 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 static final ThreadLocal<Calendar> CALENDAR = new ThreadLocal<Calendar>();
+
+ private Map<String, FunctionModifier> functionModifiers = new HashMap<String, FunctionModifier>();
+ private TimeZone databaseTimeZone;
+ private ConnectorEnvironment environment;
+
+ private boolean useComments;
+ private boolean usePreparedStatements;
+
+ private List<ValueTranslator<?, ?>> valueTranslators = new ArrayList<ValueTranslator<?, ?>>();
+ private int maxResultRows = 0;
+ private TypeFacility typeFacility;
+
+ private volatile boolean initialConnection;
+ private String connectionTestQuery;
+ private int isValidTimeout = -1;
+
+ /**
+ * Initialize the SQLTranslator.
+ * @param env
+ * @param metadata
+ * @throws ConnectorException
+ */
+ public void initialize(ConnectorEnvironment env) throws ConnectorException {
+ this.environment = env;
+ this.typeFacility = env.getTypeFacility();
+
+ 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);
+ this.connectionTestQuery = env.getProperties().getProperty(JDBCPropertyNames.CONNECTION_TEST_QUERY, getDefaultConnectionTestQuery());
+ this.isValidTimeout = PropertiesUtils.getIntProperty(env.getProperties(), JDBCPropertyNames.IS_VALID_TIMEOUT, -1);
+
+ String maxResultRowsString = env.getProperties().getProperty(ConnectorPropertyNames.MAX_RESULT_ROWS);
+ if ( maxResultRowsString != null && maxResultRowsString.trim().length() > 0 ) {
+ try {
+ maxResultRows = Integer.parseInt(maxResultRowsString);
+ String exceptionOnMaxRowsString = env.getProperties().getProperty(
+ ConnectorPropertyNames.EXCEPTION_ON_MAX_ROWS);
+ maxResultRows = Math.max(0, maxResultRows);
+ //if the connector work needs to throw an excpetion, set the size plus 1
+ if (maxResultRows > 0 && Boolean.valueOf(exceptionOnMaxRowsString).booleanValue()) {
+ maxResultRows++;
+ }
+ } catch (NumberFormatException e) {
+ //this will already be logged by the connector worker
+ }
+ }
+ }
+
+ public TimeZone getDatabaseTimeZone() {
+ return databaseTimeZone;
+ }
+
+ public Calendar getDatabaseCalendar() {
+ if (this.databaseTimeZone == null) {
+ return null;
+ }
+ Calendar cal = CALENDAR.get();
+ if (cal == null) {
+ cal = Calendar.getInstance(this.databaseTimeZone);
+ CALENDAR.set(cal);
+ }
+ return cal;
+ }
+
+ public final ConnectorEnvironment getEnvironment() {
+ return environment;
+ }
+
+ public final ILanguageFactory getLanguageFactory() {
+ return environment.getLanguageFactory();
+ }
+
+ /**
+ * Modify the command.
+ * @param command
+ * @param context
+ * @return
+ */
+ public ICommand modifyCommand(ICommand command, ExecutionContext context) throws ConnectorException {
+ return command;
+ }
+
+ /**
+ * Return a map of function name in lower case to FunctionModifier.
+ * @return Map of function name to FunctionModifier.
+ */
+ public Map<String, FunctionModifier> getFunctionModifiers() {
+ return functionModifiers;
+ }
+
+ public void registerFunctionModifier(String name, FunctionModifier modifier) {
+ this.functionModifiers.put(name, modifier);
+ }
+
+ public void registerValueTranslator(ValueTranslator<?, ?> translator) {
+ this.valueTranslators.add(translator);
+ }
+
+ /**
+ * 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
+ */
+ 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) {
+ 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
+ */
+ public String translateLiteralTime(Time timeValue) {
+ if (!hasTimeType()) {
+ return "{ts'1970-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ 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
+ */
+ public 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
+ */
+ public String formatDateValue(java.util.Date dateObject) {
+ 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;
+ }
+ Calendar cal = getDatabaseCalendar();
+ 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 connectionTestQuery;
+ }
+
+ public String getDefaultConnectionTestQuery() {
+ return "select 1"; //$NON-NLS-1$
+ }
+
+ public TypeFacility getTypeFacility() {
+ return typeFacility;
+ }
+
+ /**
+ * This is a generic implementation. Because different databases handle
+ * stored procedures differently, subclasses should override this method
+ * if necessary.
+ */
+ public ResultSet executeStoredProcedure(CallableStatement statement, TranslatedCommand command) throws SQLException {
+ List params = command.getPreparedValues();
+ int index = 1;
+
+ Iterator iter = params.iterator();
+ while(iter.hasNext()){
+ IParameter param = (IParameter)iter.next();
+ if(param.getDirection() == Direction.RETURN){
+ registerSpecificTypeOfOutParameter(statement,param, index++);
+ }
+ }
+
+ iter = params.iterator();
+ while(iter.hasNext()){
+ IParameter param = (IParameter)iter.next();
+
+ if(param.getDirection() == Direction.INOUT){
+ registerSpecificTypeOfOutParameter(statement,param, index);
+ }else if(param.getDirection() == Direction.OUT){
+ registerSpecificTypeOfOutParameter(statement,param, index++);
+ }
+
+ if(param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT){
+ bindValue(statement, param.getValue(), param.getType(), index++);
+ }
+ }
+
+ boolean resultSetNext = statement.execute();
+
+ while (!resultSetNext) {
+ int update_count = statement.getUpdateCount();
+ if (update_count == -1) {
+ break;
+ }
+ resultSetNext = statement.getMoreResults();
+ }
+ return statement.getResultSet();
+ }
+
+ /**
+ * @see com.metamatrix.connector.jdbc.extension.ResultsTranslator#getValueTranslators()
+ */
+ public List getValueTranslators() {
+ return valueTranslators;
+ }
+
+ /**
+ * For registering specific output parameter types we need to translate these into the appropriate
+ * java.sql.Types output parameters
+ * We will need to match these up with the appropriate standard sql types
+ * @param cstmt
+ * @param parameter
+ * @throws SQLException
+ */
+ protected void registerSpecificTypeOfOutParameter(CallableStatement statement, IParameter param, int index) throws SQLException {
+ Class runtimeType = param.getType();
+ int typeToSet = TypeFacility.getSQLTypeFromRuntimeType(runtimeType);
+
+ statement.registerOutParameter(index,typeToSet);
+ }
+
+ /**
+ * Will be called by Query and Update executions if a PreparedStatement is used.
+ *
+ * bindValue is ultimately called from this method and for binding CallableStatement
+ * values, so subclasses should override that method if necessery to change the binding
+ * behavior.
+ *
+ * @see com.metamatrix.connector.jdbc.extension.ResultsTranslator#bindPreparedStatementValues(java.sql.Connection, java.sql.PreparedStatement, com.metamatrix.connector.jdbc.translator.TranslatedCommand)
+ */
+ public void bindPreparedStatementValues(Connection conn, PreparedStatement stmt, TranslatedCommand command) throws SQLException {
+ List params = command.getPreparedValues();
+
+ setPreparedStatementValues(stmt, params, command.getPreparedTypes());
+ }
+
+ private void setPreparedStatementValues(PreparedStatement stmt, List paramValues, List paramTypes) throws SQLException {
+ Calendar cal = getDatabaseCalendar();
+ for (int i = 0; i< paramValues.size(); i++) {
+ Object parmvalue = paramValues.get(i);
+ Class paramType = (Class)paramTypes.get(i);
+ // this means the params is one row
+ bindValue(stmt, parmvalue, paramType, i+1);
+ }
+ }
+
+ /**
+ * Sets prepared statement parameter i with param.
+ *
+ * Performs special handling to translate dates using the database time zone and to
+ * translate biginteger, float, and char to JDBC safe objects.
+ *
+ * @param stmt
+ * @param param
+ * @param paramType
+ * @param i
+ * @param cal
+ * @throws SQLException
+ */
+ protected void bindValue(PreparedStatement stmt, Object param, Class paramType, int i) throws SQLException {
+ int type = TypeFacility.getSQLTypeFromRuntimeType(paramType);
+
+ if (param == null) {
+ stmt.setNull(i, type);
+ return;
+ }
+ //if this is a Date object, then use the database calendar
+ if (paramType.equals(TypeFacility.RUNTIME_TYPES.DATE)) {
+ stmt.setDate(i,(java.sql.Date)param, getDatabaseCalendar());
+ return;
+ }
+ if (paramType.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
+ stmt.setTime(i,(java.sql.Time)param, getDatabaseCalendar());
+ return;
+ }
+ if (paramType.equals(TypeFacility.RUNTIME_TYPES.TIMESTAMP)) {
+ stmt.setTimestamp(i,(java.sql.Timestamp)param, getDatabaseCalendar());
+ return;
+ }
+ //convert these the following to jdbc safe values
+ if (TypeFacility.RUNTIME_TYPES.BIG_INTEGER.equals(paramType)) {
+ param = new BigDecimal((BigInteger)param);
+ } else if (TypeFacility.RUNTIME_TYPES.FLOAT.equals(paramType)) {
+ param = new Double(((Float)param).doubleValue());
+ } else if (TypeFacility.RUNTIME_TYPES.CHAR.equals(paramType)) {
+ param = ((Character)param).toString();
+ }
+ stmt.setObject(i, param, type);
+ }
+
+ public int executeStatementForBulkInsert(Connection conn, PreparedStatement stmt, TranslatedCommand command) throws SQLException {
+ List rows = command.getPreparedValues();
+ Calendar cal = getDatabaseCalendar();
+ int updateCount = 0;
+
+ for (int i = 0; i< rows.size(); i++) {
+ List row = (List) rows.get(i);
+
+ setPreparedStatementValues(stmt, row, command.getPreparedTypes());
+
+ stmt.addBatch();
+ }
+
+ int[] results = stmt.executeBatch();
+
+ for (int i=0; i<results.length; i++) {
+ updateCount += results[i];
+ }
+ return updateCount;
+ }
+
+ public List modifyRow(List batch, ExecutionContext context, ICommand command) {
+ return batch;
+ }
+
+ public int getMaxResultRows() {
+ return maxResultRows;
+ }
+
+ /*
+ * @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) 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
+ // data sources as the driver likely knows the best and fastest way to convert from the underlying
+ // raw form of the data to the expected type. We use a switch with codes in order without gaps
+ // as there is a special bytecode instruction that treats this case as a map such that not every value
+ // needs to be tested, which means it is very fast.
+ switch(code.intValue()) {
+ case INTEGER_CODE: {
+ int value = results.getInt(columnIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Integer.valueOf(value);
+ }
+ case LONG_CODE: {
+ long value = results.getLong(columnIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Long.valueOf(value);
+ }
+ case DOUBLE_CODE: {
+ double value = results.getDouble(columnIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return new Double(value);
+ }
+ case BIGDECIMAL_CODE: {
+ return results.getBigDecimal(columnIndex);
+ }
+ case SHORT_CODE: {
+ short value = results.getShort(columnIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Short.valueOf(value);
+ }
+ case FLOAT_CODE: {
+ float value = results.getFloat(columnIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return new Float(value);
+ }
+ case TIME_CODE: {
+ return results.getTime(columnIndex, getDatabaseCalendar());
+ }
+ case DATE_CODE: {
+ return results.getDate(columnIndex, getDatabaseCalendar());
+ }
+ case TIMESTAMP_CODE: {
+ return results.getTimestamp(columnIndex, getDatabaseCalendar());
+ }
+ case BLOB_CODE: {
+ try {
+ return typeFacility.convertToRuntimeType(results.getBlob(columnIndex));
+ } catch (SQLException e) {
+ // ignore
+ }
+ break;
+ }
+ case CLOB_CODE: {
+ try {
+ return typeFacility.convertToRuntimeType(results.getClob(columnIndex));
+ } catch (SQLException e) {
+ // ignore
+ }
+ break;
+ }
+ }
+ }
+
+ return typeFacility.convertToRuntimeType(results.getObject(columnIndex));
+ }
+
+ public Object retrieveValue(CallableStatement results, int parameterIndex, Class expectedType) throws SQLException{
+ Integer code = (Integer) TYPE_CODE_MAP.get(expectedType);
+ if(code != null) {
+ switch(code.intValue()) {
+ case INTEGER_CODE: {
+ int value = results.getInt(parameterIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Integer.valueOf(value);
+ }
+ case LONG_CODE: {
+ long value = results.getLong(parameterIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Long.valueOf(value);
+ }
+ case DOUBLE_CODE: {
+ double value = results.getDouble(parameterIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return new Double(value);
+ }
+ case BIGDECIMAL_CODE: {
+ return results.getBigDecimal(parameterIndex);
+ }
+ case SHORT_CODE: {
+ short value = results.getShort(parameterIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Short.valueOf(value);
+ }
+ case FLOAT_CODE: {
+ float value = results.getFloat(parameterIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return new Float(value);
+ }
+ case TIME_CODE: {
+ try {
+ return results.getTime(parameterIndex, getDatabaseCalendar());
+ } catch (SQLException e) {
+ //ignore
+ }
+ }
+ case DATE_CODE: {
+ try {
+ return results.getDate(parameterIndex, getDatabaseCalendar());
+ } catch (SQLException e) {
+ //ignore
+ }
+ }
+ case TIMESTAMP_CODE: {
+ try {
+ return results.getTimestamp(parameterIndex, getDatabaseCalendar());
+ } catch (SQLException e) {
+ //ignore
+ }
+ }
+ case BLOB_CODE: {
+ try {
+ return typeFacility.convertToRuntimeType(results.getBlob(parameterIndex));
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
+ case CLOB_CODE: {
+ try {
+ return typeFacility.convertToRuntimeType(results.getClob(parameterIndex));
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
+ }
+ }
+
+ // otherwise fall through and call getObject() and rely on the normal
+ // translation routines
+ return typeFacility.convertToRuntimeType(results.getObject(parameterIndex));
+ }
+
+ protected void afterInitialConnectionCreation(Connection connection) {
+ // now dig some details about this driver/database for log.
+ try {
+ StringBuffer sb = new StringBuffer();
+ DatabaseMetaData dbmd = connection.getMetaData();
+ sb.append("Commit=").append(connection.getAutoCommit()); //$NON-NLS-1$
+ sb.append(";DatabaseProductName=").append(dbmd.getDatabaseProductName()); //$NON-NLS-1$
+ sb.append(";DatabaseProductVersion=").append(dbmd.getDatabaseProductVersion()); //$NON-NLS-1$
+ sb.append(";DriverMajorVersion=").append(dbmd.getDriverMajorVersion()); //$NON-NLS-1$
+ sb.append(";DriverMajorVersion=").append(dbmd.getDriverMinorVersion()); //$NON-NLS-1$
+ sb.append(";DriverName=").append(dbmd.getDriverName()); //$NON-NLS-1$
+ sb.append(";DriverVersion=").append(dbmd.getDriverVersion()); //$NON-NLS-1$
+ sb.append(";IsolationLevel=").append(dbmd.getDefaultTransactionIsolation()); //$NON-NLS-1$
+
+ getEnvironment().getLogger().logInfo(sb.toString());
+ } catch (SQLException e) {
+ String errorStr = JDBCPlugin.Util.getString("ConnectionListener.failed_to_report_jdbc_connection_details"); //$NON-NLS-1$
+ getEnvironment().getLogger().logInfo(errorStr);
+ }
+ }
+
+ /**
+ * defect request 13979 & 13978
+ */
+ public void afterConnectionCreation(Connection connection) {
+ if (initialConnection) {
+ initialConnection = false;
+ afterInitialConnectionCreation(connection);
+ }
+ }
+
+ public int getIsValidTimeout() {
+ return isValidTimeout;
+ }
+
+}
Property changes on: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/translator/Translator.java
___________________________________________________________________
Name: svn:mergeinfo
+
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/util/FunctionReplacementVisitor.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -26,7 +26,7 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.connector.jdbc.extension.FunctionModifier;
+import com.metamatrix.connector.jdbc.translator.FunctionModifier;
import com.metamatrix.connector.language.IAggregate;
import com.metamatrix.connector.language.ICompareCriteria;
import com.metamatrix.connector.language.IExpression;
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSingleIdentityDSConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,178 +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.xa;
-
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.sql.SQLException;
-import java.util.Iterator;
-import java.util.Properties;
-
-import javax.sql.DataSource;
-import javax.sql.XAConnection;
-import javax.sql.XADataSource;
-
-import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.jdbc.JDBCPlugin;
-import com.metamatrix.connector.jdbc.JDBCPropertyNames;
-import com.metamatrix.connector.jdbc.JDBCSingleIdentityConnectionFactory;
-import com.metamatrix.connector.pool.PoolAwareConnection;
-
-/**
- * JDBCSingleIdentityDSConnectionFactory
- *
- * <p>Creates connections from DataSources both XA and non-XA.</p>
- */
-public class JDBCSingleIdentityDSConnectionFactory extends JDBCSingleIdentityConnectionFactory{
- private DataSource ds;
- private String resourceName;
-
- protected void verifyConnectionProperties(final Properties connectionProps) throws ConnectorException {
- // Get the JDBC properties ...
- String dataSourceClassName = connectionProps.getProperty(JDBCPropertyNames.DRIVER_CLASS);
- String username = connectionProps.getProperty(XAJDBCPropertyNames.USER);
- String password = connectionProps.getProperty(XAJDBCPropertyNames.PASSWORD);
- String serverName = connectionProps.getProperty(XAJDBCPropertyNames.SERVER_NAME);
- String serverPort = connectionProps.getProperty(XAJDBCPropertyNames.PORT_NUMBER);
-
- // Unique resource name for this connector
- final StringBuffer dataSourceResourceName = new StringBuffer(connectionProps.getProperty(XAJDBCPropertyNames.DATASOURCE_NAME, "XADS")); //$NON-NLS-1$
- dataSourceResourceName.append('_');
- dataSourceResourceName.append(serverName);
- dataSourceResourceName.append('_');
- dataSourceResourceName.append(connectionProps.getProperty(XAJDBCPropertyNames.CONNECTOR_ID));
- resourceName = dataSourceResourceName.toString();
- connectionProps.setProperty( XAJDBCPropertyNames.DATASOURCE_NAME, resourceName);
-
- // Verify required items
- if (dataSourceClassName == null || dataSourceClassName.trim().length() == 0) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Missing_JDBC_driver_class_name_1")); //$NON-NLS-1$
- }
- dataSourceClassName = dataSourceClassName.trim();
- if ( serverName == null || serverName.trim().length() == 0 ) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.MissingProp", //$NON-NLS-1$
- XAJDBCPropertyNames.SERVER_NAME));
- }
- if ( serverPort == null || serverPort.trim().length() == 0 ) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.MissingProp", //$NON-NLS-1$
- XAJDBCPropertyNames.PORT_NUMBER));
- }
- if ( username == null || username.trim().length() == 0 ) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.MissingProp", //$NON-NLS-1$
- XAJDBCPropertyNames.USER));
- }
- if ( password == null || password.trim().length() == 0 ) {
- throw new ConnectorException(JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.MissingProp", //$NON-NLS-1$
- XAJDBCPropertyNames.PASSWORD));
- }
-
- // create data source
- final DataSource baseDs;
- try {
- Class clazz = Thread.currentThread().getContextClassLoader().loadClass(dataSourceClassName);
- baseDs = (DataSource) clazz.newInstance();
- } catch(Exception e) {
- throw new ConnectorException(e,JDBCPlugin.Util.getString("JDBCSourceConnectionFactory.Unable_to_load_the_JDBC_driver_class_6", dataSourceClassName)); //$NON-NLS-1$
- }
-
- setDSProperties(connectionProps, baseDs);
-
- ds = baseDs;
- }
-
- @Override
- public PoolAwareConnection getConnection(ExecutionContext context) throws ConnectorException {
- try{
- XAConnection conn = ((XADataSource)ds).getXAConnection();
- Connection sqlConn = conn.getConnection();
- if(getTransactionIsolation() != NO_ISOLATION_LEVEL_SET && getTransactionIsolation() != Connection.TRANSACTION_NONE){
- sqlConn.setTransactionIsolation(getTransactionIsolation());
- }
- return new JDBCSourceXAConnection(sqlConn, conn, getConnectorEnvironment(), createConnectionStrategy(), getConnectionListener(), getResultsTranslator(), getSqlTranslator());
- }catch(SQLException se){
- throw new ConnectorException(se);
- }
- }
-
- /**
- * @param props
- * @param dataSource
- */
- protected void setDSProperties(final Properties props, final DataSource dataSource) throws ConnectorException {
- // Move all prop names to lower case so we can use reflection to get
- // method names and look them up in the connection props.
- final Properties connProps = lowerCaseAllPropNames(props);
- final Method[] methods = dataSource.getClass().getMethods();
- for (int i = 0; i < methods.length; i++) {
- final Method method = methods[i];
- final String methodName = method.getName();
- // If setter ...
- if ( methodName.startsWith("set") && method.getParameterTypes().length == 1 ) { //$NON-NLS-1$
- // Get the property name
- final String propertyName = methodName.substring(3); // remove the "set"
- final String propertyValue = (String) connProps.get(propertyName.toLowerCase());
- if ( propertyValue != null ) {
- final Class argType = method.getParameterTypes()[0];
- final Object[] params = new Object[1];
- if ( argType == Integer.TYPE ) {
- params[0] = Integer.decode(propertyValue);
- } else if ( argType == Boolean.TYPE ) {
- params[0] = Boolean.valueOf(propertyValue);
- } else if ( argType == String.class ) {
- params[0] = propertyValue;
- }
-
- // Actually set the property ...
- //getConnectorEnvironment().getLogger().logTrace("setDSProperties - Setting property \"" + propertyName + //$NON-NLS-1$
- // "\" = \"" + params[0] + "\" on \"" + props.getProperty(JDBCPropertyNames.DRIVER_CLASS) + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- try {
- method.invoke(dataSource, params);
- } catch (Throwable e) {
- final Object[] msgParams = new Object[]{propertyName, propertyValue};
- final String msg = JDBCPlugin.Util.getString("JDBCSingleIdentityDSConnectionFactory.Unable_to_set_DataSource_property", msgParams); //$NON-NLS-1$
- throw new ConnectorException(msg);
- }
- }
- }
- }
- }
-
- private Properties lowerCaseAllPropNames(final Properties connectionProps) {
- final Properties lcProps = new Properties();
- final Iterator itr = connectionProps.keySet().iterator();
- while ( itr.hasNext() ) {
- final String name = (String) itr.next();
- Object propValue = connectionProps.get(name);
- if (propValue instanceof String) {
- // we're only interested in prop values of type String
- // here since we'll be looking for params to reflected methods
- lcProps.setProperty(name.toLowerCase(), (String)propValue);
- } // if
- }
- return lcProps;
- }
-
-}
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCSourceXAConnection.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -33,11 +33,8 @@
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
-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.jdbc.translator.Translator;
import com.metamatrix.connector.xa.api.XAConnection;
public class JDBCSourceXAConnection extends JDBCSourceConnection implements XAConnection {
@@ -45,8 +42,8 @@
private XAResource resource;
private boolean errorOccurred;
- 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);
+ public JDBCSourceXAConnection(Connection conn, javax.sql.XAConnection xaConn, ConnectorEnvironment environment, Translator sqlTranslator) throws ConnectorException, SQLException {
+ super(conn, environment, sqlTranslator);
this.xaConn = xaConn;
this.xaConn.addConnectionEventListener(new ConnectionEventListener() {
@Override
@@ -84,7 +81,7 @@
*/
@Override
public void closeCalled() {
- super.closeCalled();
+ closeSourceConnection();
try {
this.physicalConnection = this.xaConn.getConnection();
} catch (SQLException e) {
@@ -100,4 +97,8 @@
return super.isAlive();
}
+ public javax.sql.XAConnection getXAConnection() {
+ return this.xaConn;
+ }
+
}
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/JDBCXAConnector.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,107 +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.xa;
-
-import java.util.List;
-import java.util.Properties;
-
-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.jdbc.JDBCConnector;
-import com.metamatrix.connector.jdbc.JDBCPropertyNames;
-import com.metamatrix.connector.xa.api.TransactionContext;
-import com.metamatrix.connector.xa.api.XAConnection;
-import com.metamatrix.connector.xa.api.XAConnector;
-import com.metamatrix.core.util.StringUtil;
-
-@ConnectionPooling
-public class JDBCXAConnector extends JDBCConnector implements XAConnector{
-
- @Override
- public void start(ConnectorEnvironment environment)
- throws ConnectorException {
- Properties appEnvProps = environment.getProperties();
-
- // Get and parse URL for some DataSource properties - add to connectionProps
- final String url = appEnvProps.getProperty(JDBCPropertyNames.URL);
- if ( url == null || url.trim().length() == 0 ) {
- throw new ConnectorException("Missing required property: " + JDBCPropertyNames.URL); //$NON-NLS-1$
- }
-
- parseURL(url, appEnvProps);
-
- super.start(environment);
-
- //TODO: this assumes single identity support
- Connection conn = this.getXAConnection(null, null);
- conn.close();
- }
-
- /*
- * @see com.metamatrix.data.api.xa.XAConnector#getXAConnection(com.metamatrix.data.api.SecurityContext)
- */
- public XAConnection getXAConnection(ExecutionContext context, final TransactionContext transactionContext) throws ConnectorException {
- return (XAConnection)this.getConnection(context);
- }
-
- /**
- * Parse URL for DataSource connection properties and add to connectionProps.
- * @param url
- * @param connectionProps
- */
- static void parseURL(final String url, final Properties connectionProps) {
- // Will be: [jdbc:mmx:dbType://aHost:aPort], [DatabaseName=aDataBase], [CollectionID=aCollectionID], ...
- final List urlParts = StringUtil.split(url, ";"); //$NON-NLS-1$
-
- // Will be: [jdbc:mmx:dbType:], [aHost:aPort]
- final List protoHost = StringUtil.split((String)urlParts.get(0), "//"); //$NON-NLS-1$
-
- // Will be: [aHost], [aPort]
- final List hostPort = StringUtil.split((String) protoHost.get(1), ":"); //$NON-NLS-1$
- connectionProps.setProperty(XAJDBCPropertyNames.SERVER_NAME, (String)hostPort.get(0));
- connectionProps.setProperty(XAJDBCPropertyNames.PORT_NUMBER, (String)hostPort.get(1));
-
- // For "databaseName", "SID", and all optional props
- // (<propName1>=<propValue1>;<propName2>=<propValue2>;...)
- for ( int i = 1; i < urlParts.size(); i++ ) {
- final String nameVal = (String) urlParts.get( i );
- // Will be: [propName], [propVal]
- final List aProp = StringUtil.split(nameVal, "="); //$NON-NLS-1$
- if ( aProp.size() > 1) {
- final String propName = (String) aProp.get(0);
- if ( propName.equalsIgnoreCase(XAJDBCPropertyNames.DATABASE_NAME) ) {
- connectionProps.setProperty(XAJDBCPropertyNames.DATABASE_NAME, (String) aProp.get(1));
- } else {
- // Set optional prop names lower case so that we can find
- // set method names for them when we introspect the DataSource
- connectionProps.setProperty(propName.toLowerCase(), (String) aProp.get(1));
- }
- }
- }
- }
-}
Modified: trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/XAJDBCPropertyNames.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/XAJDBCPropertyNames.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/main/java/com/metamatrix/connector/jdbc/xa/XAJDBCPropertyNames.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -31,59 +31,13 @@
*/
public class XAJDBCPropertyNames {
- /**
- * The environment property used to identify a routing ID. This value should
- * be used to locate this particular connector from the DQP.
- * @since 4.0
- */
- public static final String CONNECTOR_ID = "ConnectorID"; //$NON-NLS-1$
-
/** An XA Transaction-related property. The <code>XADataSource</code>'s unique
* resource name for the underlying <code>ConnectionPoolDataSource</code> object.
*/
public static final String DATASOURCE_NAME = "dataSourceName"; //$NON-NLS-1$
- public static final String DATABASE_NAME = "databaseName";//$NON-NLS-1$
-
- public static final String DESCRIPTION = "description";//$NON-NLS-1$
-
- public static final String NETWORK_PROTOCOL = "networkProtocol";//$NON-NLS-1$
-
- public static final String PASSWORD = "password";//$NON-NLS-1$
-
public static final String PORT_NUMBER = "portNumber";//$NON-NLS-1$
- public static final String ROLE_NAME = "roleName";//$NON-NLS-1$
-
public static final String SERVER_NAME = "serverName";//$NON-NLS-1$
- public static final String USER = "user";//$NON-NLS-1$
-
- /** <i>Not</i> a standard DataSource property - only for debugging */
- public static final String SPYING = "spyAttributes";//$NON-NLS-1$
-
- /**
- * Oracle-specific properties
- */
- public static class Oracle {
- public static final String SID = "sid";//$NON-NLS-1$
- }
-
- /**
- * DB2-specific properties
- */
- public static class DB2 {
- public static final String COLLECTIONID = "CollectionID";//$NON-NLS-1$
- public static final String PACKAGENAME = "PackageName";//$NON-NLS-1$
- }
-
- public static final String IS_XA = "isXA";//$NON-NLS-1$
-
- /**
- * If true, the XAConnection obtained from the pool will not be
- * returned until the transaction is finished.
- */
- public static final String USE_CONNECTION_EXCLUSIVE = "UseConnectionExclusive"; //$NON-NLS-1$
-
-
}
Deleted: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/TestConnectionQueryStrategy.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/TestConnectionQueryStrategy.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/TestConnectionQueryStrategy.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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.connector.jdbc;
-
-import java.sql.Connection;
-
-import com.metamatrix.core.util.SimpleMock;
-
-import junit.framework.TestCase;
-
-
-/**
- * Test case for ConnectionQueryStrategy
- * @since 4.3
- */
-public class TestConnectionQueryStrategy extends TestCase {
-
- private final static String TEST_QUERY = "select 'x' from dual"; //$NON-NLS-1$
-
- private ConnectionQueryStrategy strategy;
- private FakeConnection fakeConnection;
- private Connection connection;
-
- public TestConnectionQueryStrategy(String name) {
- super(name);
- }
-
- public void setUp() throws Exception {
- strategy = new ConnectionQueryStrategy(TEST_QUERY);
-
- fakeConnection = new FakeConnection();
- connection = SimpleMock.createSimpleMock(fakeConnection, Connection.class);
- }
-
-
- /**
- * Tests ConnectionQueryStrategy.isConnectionAlive()
- * @since 4.3
- */
- public void testIsConnectionAlive() {
- //closed connections should not be 'alive'
- fakeConnection.closed = true;
- assertFalse(strategy.isConnectionAlive(connection));
-
-
- //open connections should be 'alive'
- fakeConnection.closed = false;
- assertTrue(strategy.isConnectionAlive(connection));
-
- //failed connections should not be 'alive'
- fakeConnection.fail = true;
- assertFalse(strategy.isConnectionAlive(connection));
-
- }
-
-}
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/TestJDBCSourceConnection.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -30,8 +30,7 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.basic.BasicConnectorCapabilities;
-import com.metamatrix.connector.jdbc.extension.impl.BasicResultsTranslator;
-import com.metamatrix.connector.jdbc.oracle.OracleSQLTranslator;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.core.util.SimpleMock;
@@ -41,18 +40,13 @@
*/
public class TestJDBCSourceConnection extends TestCase {
- private final static String TEST_QUERY = "select 'x' from dual"; //$NON-NLS-1$
-
-
private FakeConnection fakeConnection;
private Connection connection;
private ConnectorEnvironment environment;
- private ConnectionQueryStrategy strategy;
public TestJDBCSourceConnection(String name) {
super(name);
-
}
public void setUp() throws Exception {
@@ -60,13 +54,9 @@
connection = SimpleMock.createSimpleMock(fakeConnection, Connection.class);
final Properties properties = new Properties();
- properties.setProperty(JDBCPropertyNames.EXT_SQL_TRANSLATOR_CLASS, OracleSQLTranslator.class.getName());
- properties.setProperty(JDBCPropertyNames.EXT_RESULTS_TRANSLATOR_CLASS, BasicResultsTranslator.class.getName());
properties.setProperty(JDBCPropertyNames.EXT_CAPABILITY_CLASS, BasicConnectorCapabilities.class.getName());
environment = EnvironmentUtility.createEnvironment(properties, false);
-
- strategy = new ConnectionQueryStrategy(TEST_QUERY);
}
@@ -75,7 +65,12 @@
* @since 4.3
*/
public void testIsAlive() throws Exception {
- JDBCSourceConnection sourceConnection = new JDBCSourceConnection(connection, environment, strategy, null, null);
+ JDBCSourceConnection sourceConnection = new JDBCSourceConnection(connection, environment, new Translator() {
+ @Override
+ public String getConnectionTestQuery() {
+ return "select 1";
+ }
+ });
//closed connections should not be 'alive'
fakeConnection.closed = true;
@@ -96,7 +91,12 @@
* @since 4.3
*/
public void testIsAliveNullStrategy() throws Exception {
- JDBCSourceConnection sourceConnection = new JDBCSourceConnection(connection, environment, null, null, null);
+ JDBCSourceConnection sourceConnection = new JDBCSourceConnection(connection, environment, new Translator() {
+ @Override
+ public String getConnectionTestQuery() {
+ return null;
+ }
+ });
//closed connections should not be 'alive'
fakeConnection.closed = true;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/access/TestAccessSQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -29,8 +29,8 @@
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
-import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.language.ICommand;
@@ -39,7 +39,7 @@
*/
public class TestAccessSQLTranslator extends TestCase {
- private static SQLTranslator TRANSLATOR;
+ private static Translator TRANSLATOR;
static {
try {
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2ConvertModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -32,7 +32,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.jdbc.translator.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/db2/TestDB2SqlTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -32,7 +32,7 @@
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.jdbc.extension.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.core.util.UnitTestUtil;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/derby/TestDerbyConvertModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -32,7 +32,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.jdbc.translator.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestDropFunctionModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestDropFunctionModifier.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestDropFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -25,6 +25,7 @@
import junit.framework.TestCase;
import com.metamatrix.cdk.CommandBuilder;
+import com.metamatrix.connector.jdbc.translator.DropFunctionModifier;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILiteral;
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/extension/impl/TestEscapeSyntaxModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -28,6 +28,7 @@
import junit.framework.TestCase;
import com.metamatrix.cdk.CommandBuilder;
+import com.metamatrix.connector.jdbc.translator.EscapeSyntaxModifier;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILiteral;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/mysql/TestMySQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -30,7 +30,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.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
import com.metamatrix.connector.language.ICommand;
/**
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -29,7 +29,7 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
+import com.metamatrix.connector.jdbc.translator.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestExtractFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -30,7 +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.jdbc.translator.SQLConversionVisitor;
import com.metamatrix.connector.language.IElement;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLeftOrRightFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -28,7 +28,7 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
+import com.metamatrix.connector.jdbc.translator.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestLocateFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -28,7 +28,7 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
+import com.metamatrix.connector.jdbc.translator.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -29,7 +29,7 @@
import com.metamatrix.cdk.CommandBuilder;
import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.connector.jdbc.extension.SQLConversionVisitor;
+import com.metamatrix.connector.jdbc.translator.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleConvertModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -32,7 +32,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.jdbc.translator.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
Modified: 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 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -30,13 +30,13 @@
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.jdbc.translator.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.language.ICommand;
public class TestOracleTranslator extends TestCase {
- private static SQLTranslator TRANSLATOR;
+ private static Translator TRANSLATOR;
static {
try {
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/oracle/TestSubstringFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -29,8 +29,8 @@
import com.metamatrix.cdk.CommandBuilder;
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.jdbc.translator.FunctionModifier;
+import com.metamatrix.connector.jdbc.translator.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/postgresql/TestPostgreSQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -30,7 +30,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.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
import com.metamatrix.connector.language.ICommand;
/**
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -30,8 +30,8 @@
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.translator.SQLConversionVisitor;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
import com.metamatrix.connector.language.ICommand;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseConvertModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -32,7 +32,7 @@
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.jdbc.translator.SQLConversionVisitor;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILanguageFactory;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -29,8 +29,8 @@
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.translator.SQLConversionVisitor;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
import com.metamatrix.connector.language.ICommand;
Deleted: 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/MockExampleConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -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.userpool;
-
-import java.sql.Driver;
-import java.util.Properties;
-
-import com.metamatrix.connector.api.Connection;
-import com.metamatrix.connector.api.ConnectorException;
-import com.metamatrix.connector.jdbc.JDBCUserIdentityConnectionFactory;
-
-/**
- * Overrides createConnection stuff so we can fake obtaining a connection.
- */
-public class MockExampleConnectionFactory extends JDBCUserIdentityConnectionFactory {
-
- public void shutdown() {}
-
- @Override
- protected Connection createJDBCConnection(
- Driver driver,
- String url,
- int transactionIsolationLevel,
- Properties userProps)
- throws ConnectorException {
-
- String user = userProps.getProperty("user"); //$NON-NLS-1$
- String password = userProps.getProperty("password"); //$NON-NLS-1$
-
- return new MockSourceConnection(url, transactionIsolationLevel, user, password);
- }
-
- @Override
- protected Driver createDriver(String driverClassName) throws ConnectorException {
- return null;
- }
-
- @Override
- protected void validateURL(Driver driver, String url)
- throws ConnectorException {
- }
-}
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/userpool/TestPerUserPool.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -25,17 +25,20 @@
import java.io.Serializable;
import java.util.Properties;
-import junit.framework.TestCase;
+import javax.sql.DataSource;
import org.mockito.Mockito;
+import junit.framework.TestCase;
+
+import com.metamatrix.cdk.api.EnvironmentUtility;
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.internal.ConnectorPropertyNames;
+import com.metamatrix.connector.jdbc.JDBCConnector;
import com.metamatrix.connector.jdbc.JDBCPropertyNames;
-import com.metamatrix.connector.jdbc.JDBCSourceConnectionFactory;
import com.metamatrix.dqp.internal.datamgr.impl.ExecutionContextImpl;
/**
@@ -50,10 +53,12 @@
public void testWrongCredentials() throws Exception {
ConnectorEnvironment env = initConnectorEnvironment();
- JDBCSourceConnectionFactory factory = new MockExampleConnectionFactory();
- factory.initialize(env);
- ExecutionContext ctx = createSecurityContext("pw1", false, factory); //$NON-NLS-1$
+ JDBCConnector factory = new JDBCConnector();
+ factory.setUseCredentialMap(true);
+ factory.setAdminConnectionsAllowed(false);
+ factory.start(env);
try {
+ ExecutionContext ctx = createSecurityContext("pw1", false, factory); //$NON-NLS-1$
factory.getConnection(ctx);
fail("expected failure"); //$NON-NLS-1$
} catch (ConnectorException e) {
@@ -63,20 +68,14 @@
private ConnectorEnvironment initConnectorEnvironment() throws Exception {
final Properties connProps = new Properties();
- connProps.put(JDBCPropertyNames.DRIVER_CLASS, "com.metamatrix.jdbc.oracle.OracleDriver"); //$NON-NLS-1$
+ connProps.put(JDBCPropertyNames.CONNECTION_SOURCE_CLASS, "com.metamatrix.jdbc.oracle.OracleDriver"); //$NON-NLS-1$
connProps.put(JDBCPropertyNames.URL, TEST_URL);
connProps.put(ConnectorPropertyNames.CONNECTOR_BINDING_NAME, "oracle system"); //$NON-NLS-1$
connProps.put(JDBCPropertyNames.EXT_CAPABILITY_CLASS, "com.metamatrix.connector.jdbc.oracle.OracleCapabilities"); //$NON-NLS-1$
- connProps.put(JDBCPropertyNames.EXT_CONNECTION_FACTORY_CLASS, "com.metamatrix.connector.jdbc.oracle.OracleUserIdentityConnectionFactory"); //$NON-NLS-1$
- connProps.put(JDBCPropertyNames.EXT_SQL_TRANSLATOR_CLASS, "com.metamatrix.connector.jdbc.oracle.OracleSQLTranslator"); //$NON-NLS-1$
- connProps.put(JDBCPropertyNames.EXT_RESULTS_TRANSLATOR_CLASS, "com.metamatrix.connector.jdbc.oracle.OracleResultsTranslator"); //$NON-NLS-1$
- ConnectorEnvironment env = Mockito.mock(ConnectorEnvironment.class);
- Mockito.stub(env.getConnectorName()).toReturn("oracle system"); //$NON-NLS-1$
- Mockito.stub(env.getProperties()).toReturn(connProps);
- return env;
+ return EnvironmentUtility.createEnvironment(connProps, false);
}
- private ExecutionContext createSecurityContext(String credentialsStr, boolean useMap, JDBCSourceConnectionFactory factory) throws Exception {
+ private ExecutionContext createSecurityContext(String credentialsStr, boolean useMap, JDBCConnector factory) throws Exception {
Serializable credentials = credentialsStr;
if (useMap) {
credentials = CredentialMap.parseCredentials(credentialsStr);
@@ -90,28 +89,37 @@
public void testCredentialMapInSessionPayload() throws Exception {
ConnectorEnvironment env = initConnectorEnvironment();
- JDBCSourceConnectionFactory factory = new MockExampleConnectionFactory();
- factory.initialize(env);
+ JDBCConnector factory = new JDBCConnector() {
+ @Override
+ public DataSource getDataSource() {
+ return Mockito.mock(DataSource.class);
+ }
+ };
+ factory.setUseCredentialMap(true);
+ factory.setAdminConnectionsAllowed(false);
+ factory.setConnectorName("oracle system");
+ factory.start(env);
ExecutionContext ctx = createSecurityContext("(system=oracle system,user=bqt2,password=mm)", true, factory); //$NON-NLS-1$
- MockSourceConnection conn = (MockSourceConnection)factory.getConnection(ctx);
- assertEquals("bqt2", conn.getUser()); //$NON-NLS-1$
- assertEquals("mm", conn.getPassword()); //$NON-NLS-1$
+ factory.getConnection(ctx);
}
public void testCredentialMapMissingSystem() throws Exception {
ConnectorEnvironment env = initConnectorEnvironment();
- JDBCSourceConnectionFactory factory = new MockExampleConnectionFactory();
- factory.initialize(env);
+ JDBCConnector factory = new JDBCConnector();
+ factory.setUseCredentialMap(true);
+ factory.setAdminConnectionsAllowed(false);
+ factory.setConnectorName("oracle system");
+ factory.start(env);
// Set system to "x" instead of "oracle system" which will cause no credentials to be found
- ExecutionContext ctx = createSecurityContext("(system=x,user=bqt2,password=mm)", true, factory); //$NON-NLS-1$
try {
+ ExecutionContext ctx = createSecurityContext("(system=x,user=bqt2,password=mm)", true, factory); //$NON-NLS-1$
factory.getConnection(ctx);
fail("Expected exception when creating connection with missing system credentials"); //$NON-NLS-1$
} catch(Exception e) {
// expected
- assertEquals("Required connection property \"user\" missing for system \"oracle system\".", e.getMessage()); //$NON-NLS-1$
+ assertEquals("Payload missing credentials for oracle system", e.getMessage()); //$NON-NLS-1$
}
}
Modified: trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/util/TestFunctionReplacementVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/util/TestFunctionReplacementVisitor.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-jdbc/src/test/java/com/metamatrix/connector/jdbc/util/TestFunctionReplacementVisitor.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -28,7 +28,7 @@
import junit.framework.TestCase;
import com.metamatrix.connector.jdbc.MetadataFactory;
-import com.metamatrix.connector.jdbc.extension.impl.DropFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.DropFunctionModifier;
import com.metamatrix.connector.language.ICommand;
/**
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -39,12 +39,11 @@
import com.metamatrix.connector.language.IQuery;
import com.metamatrix.connector.language.IQueryCommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.pool.PoolAwareConnection;
/**
* Represents a connection to an LDAP data source.
*/
-public class LDAPConnection extends BasicConnection implements PoolAwareConnection {
+public class LDAPConnection extends BasicConnection {
// Standard Connection data members
private ConnectorLogger logger;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/Connector.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -34,10 +34,10 @@
import com.metamatrix.connector.api.CredentialMap;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.ConnectorAnnotations.ConnectionPooling;
-import com.metamatrix.connector.pool.ConnectorIdentity;
-import com.metamatrix.connector.pool.ConnectorIdentityFactory;
-import com.metamatrix.connector.pool.SingleIdentityFactory;
-import com.metamatrix.connector.pool.UserIdentityFactory;
+import com.metamatrix.connector.identity.ConnectorIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentityFactory;
+import com.metamatrix.connector.identity.SingleIdentityFactory;
+import com.metamatrix.connector.identity.UserIdentityFactory;
import com.metamatrix.connector.salesforce.connection.SalesforceConnection;
@ConnectionPooling
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/connection/SalesforceConnection.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -33,7 +33,6 @@
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.IQueryCommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
-import com.metamatrix.connector.pool.PoolAwareConnection;
import com.metamatrix.connector.salesforce.Messages;
import com.metamatrix.connector.salesforce.connection.impl.ConnectionImpl;
import com.metamatrix.connector.salesforce.execution.DataPayload;
@@ -41,7 +40,7 @@
import com.metamatrix.connector.salesforce.execution.UpdateExecutionParent;
import com.sforce.soap.partner.QueryResult;
-public class SalesforceConnection extends BasicConnection implements PoolAwareConnection {
+public class SalesforceConnection extends BasicConnection {
private ConnectorEnvironment connectorEnv;
private ConnectionImpl connection;
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnection.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -35,13 +35,12 @@
import com.metamatrix.connector.object.extension.IObjectSource;
import com.metamatrix.connector.object.extension.ISourceTranslator;
import com.metamatrix.connector.object.util.ObjectConnectorUtil;
-import com.metamatrix.connector.pool.PoolAwareConnection;
import com.metamatrix.core.util.ArgCheck;
/**
* Implementation of Connection interface for Object connection.
*/
-public class ObjectConnection extends BasicConnection implements PoolAwareConnection {
+public class ObjectConnection extends BasicConnection {
// private static final String DEFAULT_TRANSLATOR = "com.metamatrix.connector.object.extension.source.BasicSourceTranslator";//$NON-NLS-1$
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/ObjectConnector.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -29,9 +29,9 @@
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ConnectorLogger;
import com.metamatrix.connector.api.ExecutionContext;
+import com.metamatrix.connector.identity.ConnectorIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentityFactory;
import com.metamatrix.connector.object.util.ObjectConnectorUtil;
-import com.metamatrix.connector.pool.ConnectorIdentity;
-import com.metamatrix.connector.pool.ConnectorIdentityFactory;
/**
* Implmentation of the connector interface.
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/SourceConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -4,9 +4,8 @@
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.pool.ConnectorIdentity;
-import com.metamatrix.connector.pool.SingleIdentity;
-import com.metamatrix.connector.pool.UserIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentity;
+import com.metamatrix.connector.identity.SingleIdentity;
public interface SourceConnectionFactory {
@@ -30,7 +29,7 @@
* 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. A {@link UserIdentity} specifies that contexts
+ * equally and thus use the same pool. A {@link CredentialMapIdentity} specifies that contexts
* are differentiated based on user name, thus creating a per-user pool of connections.
* Implementors of this class may use a different implementation of the
* {@link ConnectorIdentity} interface to similarly affect pooling.
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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/sandbox/connector-object/src/main/java/com/metamatrix/connector/object/extension/source/BaseSourceConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -28,11 +28,11 @@
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
+import com.metamatrix.connector.identity.ConnectorIdentity;
+import com.metamatrix.connector.identity.SingleIdentity;
import com.metamatrix.connector.object.ObjectConnection;
import com.metamatrix.connector.object.SourceConnectionFactory;
import com.metamatrix.connector.object.extension.IObjectSource;
-import com.metamatrix.connector.pool.ConnectorIdentity;
-import com.metamatrix.connector.pool.SingleIdentity;
/**
* Represents a base factory class for the creation of the source connection. Subclasses
@@ -60,7 +60,7 @@
/**
- * @see com.metamatrix.data.pool.SourceConnectionFactory#createConnection(com.metamatrix.connector.pool.ConnectorIdentity)
+ * @see com.metamatrix.data.pool.SourceConnectionFactory#createConnection(com.metamatrix.connector.identity.ConnectorIdentity)
* @since 4.3
*/
public final Connection createConnection(ConnectorIdentity id) throws ConnectorException {
@@ -81,7 +81,7 @@
* @since 4.3
*/
public ConnectorIdentity createIdentity(ExecutionContext context) throws ConnectorException {
- return new SingleIdentity(context);
+ return new SingleIdentity();
}
}
Modified: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialFunctionModifier.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialFunctionModifier.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialFunctionModifier.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -24,7 +24,7 @@
import java.util.List;
-import com.metamatrix.connector.jdbc.extension.impl.BasicFunctionModifier;
+import com.metamatrix.connector.jdbc.translator.BasicFunctionModifier;
import com.metamatrix.connector.language.IExpression;
import com.metamatrix.connector.language.IFunction;
import com.metamatrix.connector.language.ILiteral;
Deleted: trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialResultsTranslator.java
===================================================================
--- trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialResultsTranslator.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialResultsTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,49 +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 20, 2004 To change the template for this generated file go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-package com.metamatrix.connector.jdbc.oracle.spatial;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.metamatrix.connector.jdbc.oracle.OracleResultsTranslator;
-
-public class OracleSpatialResultsTranslator extends OracleResultsTranslator {
-
- private List translators;
-
- public OracleSpatialResultsTranslator() {
- ArrayList translators = new ArrayList();
- if (super.getValueTranslators() != null) {
- translators.addAll(super.getValueTranslators());
- }
- }
-
- public List getValueTranslators() {
- return translators;
- }
-
-}
\ 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-23 16:17:44 UTC (rev 480)
+++ trunk/connectors/sandbox/connector-oracle-spatial/src/main/java/com/metamatrix/connector/jdbc/oracle/spatial/OracleSpatialSQLTranslator.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -30,7 +30,7 @@
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.api.TypeFacility;
-import com.metamatrix.connector.jdbc.extension.SQLTranslator;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.ICriteria;
import com.metamatrix.connector.language.IFunction;
@@ -39,7 +39,7 @@
import com.metamatrix.connector.language.ISelectSymbol;
import com.metamatrix.connector.visitor.util.CollectorVisitor;
-public class OracleSpatialSQLTranslator extends SQLTranslator {
+public class OracleSpatialSQLTranslator extends Translator {
@Override
public void initialize(ConnectorEnvironment env) throws ConnectorException {
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-23 16:17:44 UTC (rev 480)
+++ trunk/embedded/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedDataService.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -72,7 +72,6 @@
public class EmbeddedDataService extends EmbeddedBaseDQPService implements DataService {
private static final String SYSTEM_PHYSICAL_MODEL_CONNECTOR_BINDING_CLASSNAME = "com.metamatrix.dqp.embedded.services.DefaultIndexConnectorBinding"; //$NON-NLS-1$
private static final String CONNECTOR_MGR_IMPL = "com.metamatrix.dqp.internal.datamgr.impl.ConnectorManager"; //$NON-NLS-1$
- private static final String CONNECTOR_CLASSPATH = "ConnectorClassPath"; //$NON-NLS-1$
// Map of connector binding name to ConnectorID
private Map connectorIDs = new HashMap();
@@ -562,34 +561,26 @@
throws ApplicationLifecycleException{
try {
- ConnectorManager mgr = null;
// Ask the configuration if we can use the extension class loader.
boolean useExtensionClassPath = (getConfigurationService().useExtensionClasspath());
- String classPath = connectorProperties.getProperty(CONNECTOR_CLASSPATH);
+ String classPath = connectorProperties.getProperty(ConnectorPropertyNames.CONNECTOR_CLASSPATH);
if (classPath == null || classPath.length() == 0) {
useExtensionClassPath = false;
}
if (!useExtensionClassPath) {
- connectorProperties.setProperty(ConnectorPropertyNames.DEREGISTER_DRIVER, ConnectorPropertyNames.DEREGISTER_BY_CLASSNAME);
- mgr = new ConnectorManager();
+ return new ConnectorManager();
}
- else {
- DQPEmbeddedPlugin.logInfo("DataService.useClassloader", new Object[] {classPath}); //$NON-NLS-1$
- URL context = getConfigurationService().getExtensionPath();
- URL[] urlPath = ExtensionModuleReader.resolveExtensionClasspath(classPath, context);
-
- ClassLoader classLoader = new URLFilteringClassLoader(urlPath, Thread.currentThread().getContextClassLoader(), new MetaMatrixURLStreamHandlerFactory());
- Class cmgrImplClass = classLoader.loadClass(CONNECTOR_MGR_IMPL);
-
- // Here even though we use a new class loader for the CM, we actually setting the
- // class loader for the JDBC Connectors. Since the CM may already be loaded, getClass().getCL()
- // will return a another CL than, above so to cheat we do this below property.
- connectorProperties.put(ConnectorPropertyNames.CONNECTOR_CLASS_LOADER, classLoader);
-
- return (ConnectorManager)cmgrImplClass.newInstance();
- }
- return mgr;
+ DQPEmbeddedPlugin.logInfo("DataService.useClassloader", new Object[] {classPath}); //$NON-NLS-1$
+ URL context = getConfigurationService().getExtensionPath();
+ URL[] urlPath = ExtensionModuleReader.resolveExtensionClasspath(classPath, context);
+
+ ClassLoader classLoader = new URLFilteringClassLoader(urlPath, Thread.currentThread().getContextClassLoader(), new MetaMatrixURLStreamHandlerFactory());
+ Class cmgrImplClass = classLoader.loadClass(CONNECTOR_MGR_IMPL);
+
+ ConnectorManager cm = (ConnectorManager)cmgrImplClass.newInstance();
+ cm.setClassloader(classLoader);
+ return cm;
} catch (Exception e) {
throw new ApplicationLifecycleException(e);
}
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-23 16:17:44 UTC (rev 480)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorManager.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -61,7 +61,9 @@
import com.metamatrix.connector.internal.ConnectorPropertyNames;
import com.metamatrix.connector.xa.api.XAConnection;
import com.metamatrix.connector.xa.api.XAConnector;
+import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.util.Assertion;
+import com.metamatrix.core.util.ReflectionHelper;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.internal.cache.ResultSetCache;
@@ -338,17 +340,21 @@
*/
private void initStartConnector(String connectorName, ConnectorEnvironment env) throws ApplicationLifecycleException {
String connectorClassName = env.getProperties().getProperty(ConnectorPropertyNames.CONNECTOR_CLASS);
- classloader = (ClassLoader)props.get(ConnectorPropertyNames.CONNECTOR_CLASS_LOADER);
if(classloader == null){
classloader = getClass().getClassLoader();
+ } else {
+ env.getProperties().setProperty(ConnectorPropertyNames.USING_CUSTOM_CLASSLOADER, Boolean.TRUE.toString());
}
Thread currentThread = Thread.currentThread();
ClassLoader threadContextLoader = currentThread.getContextClassLoader();
try {
currentThread.setContextClassLoader(classloader);
- Class<?> clazz = classloader.loadClass(connectorClassName);
-
- Connector c = (Connector) clazz.newInstance();
+ Connector c;
+ try {
+ c = (Connector)ReflectionHelper.create(connectorClassName, null, classloader);
+ } catch (MetaMatrixCoreException e) {
+ throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_find_Connector_class", connectorClassName)); //$NON-NLS-1$
+ }
if(c instanceof XAConnector){
this.isXa = true;
if (this.getTransactionService() == null) {
@@ -371,15 +377,21 @@
if (this.isXa) {
if (this.connector.supportsSingleIdentity()) {
// add this connector as the recovery source
- final XAConnection xaConn = ((XAConnector)connector).getXAConnection(null, null);
-
TransactionServer ts = this.getTransactionService().getTransactionServer();
ts.registerRecoverySource(connectorName, new TransactionProvider.XAConnectionSource() {
-
+ XAConnection conn = null;
+
@Override
public XAResource getXAResource() throws SQLException {
+ if (conn == null) {
+ try {
+ conn = ((XAConnector)connector).getXAConnection(null, null);
+ } catch (ConnectorException e) {
+ throw new SQLException(e);
+ }
+ }
try {
- return xaConn.getXAResource();
+ return conn.getXAResource();
} catch (ConnectorException e) {
throw new SQLException(e);
}
@@ -387,19 +399,15 @@
@Override
public void close() {
- xaConn.close();
+ if (conn != null) {
+ conn.close();
+ }
}
});
} else {
LogManager.logWarning(LogConstants.CTX_CONNECTOR, DQPPlugin.Util.getString("ConnectorManager.cannot_add_to_recovery", this.getName())); //$NON-NLS-1$
}
}
- } catch (InstantiationException e) {
- throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_instantiate_Connector_class", new Object[]{connectorClassName})); //$NON-NLS-1$
- } catch (IllegalAccessException e) {
- throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_access_Connector_class", new Object[]{connectorClassName})); //$NON-NLS-1$
- } catch (ClassNotFoundException e) {
- throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_find_Connector_class", connectorClassName)); //$NON-NLS-1$
} catch (ConnectorException e) {
throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("failed_start_Connector", new Object[] {this.getConnectorID(), e.getMessage()})); //$NON-NLS-1$
} finally {
@@ -609,6 +617,10 @@
return isXa;
}
+ public void setClassloader(ClassLoader classloader) {
+ this.classloader = classloader;
+ }
+
/**
* Overloads the connector capabilities with one defined in the connector binding properties
*/
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-23 16:17:44 UTC (rev 480)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ConnectorWrapper.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -28,9 +28,9 @@
import com.metamatrix.connector.api.ConnectorEnvironment;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.pool.ConnectorIdentity;
-import com.metamatrix.connector.pool.ConnectorIdentityFactory;
-import com.metamatrix.connector.pool.SingleIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentityFactory;
+import com.metamatrix.connector.identity.SingleIdentity;
import com.metamatrix.connector.xa.api.TransactionContext;
import com.metamatrix.connector.xa.api.XAConnection;
import com.metamatrix.connector.xa.api.XAConnector;
@@ -116,7 +116,7 @@
if (actualConnector instanceof ConnectorIdentityFactory) {
return ((ConnectorIdentityFactory)actualConnector).createIdentity(context);
}
- return new SingleIdentity(context);
+ return new SingleIdentity();
}
public boolean supportsSingleIdentity() {
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-23 16:17:44 UTC (rev 480)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -29,7 +29,7 @@
import com.metamatrix.common.buffer.impl.BufferConfig;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.pool.ConnectorIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentity;
import com.metamatrix.core.util.HashCodeUtil;
/**
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-23 16:17:44 UTC (rev 480)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionPool.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -43,9 +43,9 @@
import com.metamatrix.connector.api.Connection;
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.pool.ConnectorIdentity;
-import com.metamatrix.connector.pool.PoolAwareConnection;
-import com.metamatrix.connector.pool.SingleIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentity;
+import com.metamatrix.connector.identity.PoolAwareConnection;
+import com.metamatrix.connector.identity.SingleIdentity;
import com.metamatrix.connector.xa.api.TransactionContext;
import com.metamatrix.connector.xa.api.XAConnector;
import com.metamatrix.core.log.MessageLevel;
@@ -208,7 +208,7 @@
id = executionContext.getConnectorIdentity();
}
if (id == null) {
- id = new SingleIdentity(executionContext);
+ id = new SingleIdentity();
}
LogManager.logTrace(CTX_CONNECTOR, new Object[] {"Obtaining connection for id", id}); //$NON-NLS-1$
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-23 16:17:44 UTC (rev 480)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/internal/pooling/connector/ConnectionWrapper.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -29,10 +29,10 @@
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.Execution;
import com.metamatrix.connector.api.ExecutionContext;
+import com.metamatrix.connector.identity.ConnectorIdentity;
+import com.metamatrix.connector.identity.PoolAwareConnection;
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;
public class ConnectionWrapper implements PoolAwareConnection, XAConnection {
@@ -66,13 +66,11 @@
if (isDead) {
return false;
}
- if (connection instanceof PoolAwareConnection) {
- long now = System.currentTimeMillis();
- if (now - lastTest > testInterval) {
- boolean result = ((PoolAwareConnection)connection).isAlive();
- lastTest = now;
- this.isDead = !result;
- }
+ long now = System.currentTimeMillis();
+ if (now - lastTest > testInterval) {
+ boolean result = connection.isAlive();
+ lastTest = now;
+ this.isDead = !result;
}
return !isDead;
}
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-23 16:17:44 UTC (rev 480)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -341,7 +341,15 @@
// Invoke the method and return the result
try {
- return method.invoke(null, values);
+ Object result = method.invoke(null, values);
+ if (result instanceof String) {
+ String str = (String)result;
+ if (str.length() > DataTypeManager.MAX_STRING_LENGTH) {
+ return str.substring(0, DataTypeManager.MAX_STRING_LENGTH);
+ }
+ return result;
+ }
+ return DataTypeManager.convertToRuntimeType(result);
} catch(InvocationTargetException e) {
throw new FunctionExecutionException(e.getTargetException(), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, fd.getName()));
} catch(IllegalAccessException e) {
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-23 16:17:44 UTC (rev 480)
+++ trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1205,9 +1205,6 @@
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();
}
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-23 16:17:44 UTC (rev 480)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/datamgr/impl/TestConnectorManagerImpl.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -137,7 +137,6 @@
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.isXa());
cm.stop();
@@ -154,7 +153,6 @@
final String connectorName = FakeConnector.class.getName();
props.setProperty(ConnectorPropertyNames.CONNECTOR_CLASS, connectorName);//$NON-NLS-1$
URLClassLoader cl = new URLClassLoader(new URL[0]);
- props.put(ConnectorPropertyNames.CONNECTOR_CLASS_LOADER, cl);
startConnectorManager(cm, props);
((FakeConnector)cm.getConnector().getActualConnector()).setClassloader(cl);
AtomicRequestMessage request = TestConnectorWorkItem.createNewAtomicRequestMessage(1, 1);
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-23 16:17:44 UTC (rev 480)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/FakeUserIdentityConnectionFactory.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -26,9 +26,9 @@
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.pool.ConnectorIdentity;
-import com.metamatrix.connector.pool.ConnectorIdentityFactory;
-import com.metamatrix.connector.pool.UserIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentity;
+import com.metamatrix.connector.identity.ConnectorIdentityFactory;
+import com.metamatrix.connector.identity.UserIdentity;
/**
*/
@@ -42,7 +42,7 @@
return null;
}
//use user name for now
- return new UserIdentity(context);
+ return new UserIdentity(context.getUser(), null, null);
}
}
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-23 16:17:44 UTC (rev 480)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionPool.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -29,7 +29,7 @@
import junit.framework.TestCase;
import com.metamatrix.connector.api.ExecutionContext;
-import com.metamatrix.connector.pool.UserIdentity;
+import com.metamatrix.connector.identity.UserIdentity;
import com.metamatrix.dqp.internal.datamgr.impl.ConnectorWrapper;
import com.metamatrix.dqp.internal.datamgr.impl.ExecutionContextImpl;
@@ -69,7 +69,7 @@
public static ExecutionContext createContext(final String user, boolean userIdentity) {
ExecutionContextImpl context = new ExecutionContextImpl(null, null, user, null, null, null, null, null, null, null, false);
if (userIdentity) {
- context.setConnectorIdentity(new UserIdentity(context));
+ context.setConnectorIdentity(new UserIdentity(context.getUser(), null, null));
}
return context;
}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionWrapper.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionWrapper.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/internal/pooling/connector/TestConnectionWrapper.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -27,7 +27,7 @@
import org.mockito.Mockito;
import com.metamatrix.connector.api.Connection;
-import com.metamatrix.connector.pool.PoolAwareConnection;
+import com.metamatrix.connector.identity.PoolAwareConnection;
public class TestConnectionWrapper extends TestCase {
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-23 16:17:44 UTC (rev 480)
+++ trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorService.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -245,8 +245,8 @@
String connID = id.getVMControllerID().getID() + "|" + id.getID(); //$NON-NLS-1$
deMaskedProps.put(ConnectorPropertyNames.CONNECTOR_ID, connID);
deMaskedProps.put(ConnectorPropertyNames.CONNECTOR_BINDING_NAME, getInstanceName());
- deMaskedProps.put(ConnectorPropertyNames.CONNECTOR_CLASS_LOADER, loader);
deMaskedProps.put(ConnectorPropertyNames.CONNECTOR_VM_NAME, VMNaming.getVMName());
+ connectorManager.setClassloader(loader);
connectorManager.initialize(deMaskedProps);
return connectorManager;
@@ -263,7 +263,7 @@
// Decrypt masked properties
Properties deMaskedProps = decryptMaskedProperties(props);
- String urls = deMaskedProps.getProperty(ConnectorServicePropertyNames.CONNECTOR_CLASS_PATH);
+ String urls = deMaskedProps.getProperty(ConnectorPropertyNames.CONNECTOR_CLASSPATH);
ClassLoader loader = getCustomClassLoader(urls);
// Build a Connector manager using the custom class loader and initialize
Deleted: trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServicePropertyNames.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServicePropertyNames.java 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/server/src/main/java/com/metamatrix/server/connector/service/ConnectorServicePropertyNames.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -1,44 +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: Sep 25, 2003
- * Time: 4:38:45 PM
- */
-package com.metamatrix.server.connector.service;
-
-/**
- * ConnectorServicePropertyNames.
- */
-public class ConnectorServicePropertyNames {
-
- /**
- * Don't allow instantiation.
- */
- private ConnectorServicePropertyNames() {
- }
-
- /** Metadata service - provides acecss to runtime metadata */
- public static final String METADATA_SERVICE = "dqp.metadata"; //$NON-NLS-1$
-
- public static final String CONNECTOR_CLASS_PATH = "ConnectorClassPath"; //$NON-NLS-1$
-}
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-23 16:17:44 UTC (rev 480)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -33,6 +33,9 @@
import com.metamatrix.connector.api.ConnectorException;
import com.metamatrix.connector.api.ExecutionContext;
import com.metamatrix.connector.jdbc.JDBCPropertyNames;
+import com.metamatrix.connector.jdbc.translator.SQLConversionVisitor;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
+import com.metamatrix.connector.jdbc.translator.Translator;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.language.ILanguageObject;
@@ -115,7 +118,7 @@
private String getStringWithContext(ILanguageObject obj) throws ConnectorException {
Properties props = new Properties();
props.setProperty(JDBCPropertyNames.USE_COMMENTS_SOURCE_QUERY, Boolean.TRUE.toString());
- SQLTranslator trans = new SQLTranslator();
+ Translator trans = new Translator();
trans.initialize(EnvironmentUtility.createEnvironment(props, false));
SQLConversionVisitor visitor = new SQLConversionVisitor(trans);
visitor.setExecutionContext(context);
@@ -136,7 +139,7 @@
boolean useMetadata, boolean usePreparedStatement) throws ConnectorException {
// Apply function replacement
FunctionReplacementVisitor funcVisitor = new FunctionReplacementVisitor(modifiers);
- SQLTranslator trans = new SQLTranslator();
+ Translator trans = new Translator();
Properties p = new Properties();
if (usePreparedStatement) {
p.setProperty(JDBCPropertyNames.USE_BIND_VARIABLES, Boolean.TRUE.toString());
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-23 16:17:44 UTC (rev 480)
+++ trunk/test-integration/src/test/java/com/metamatrix/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2009-02-23 17:43:19 UTC (rev 481)
@@ -34,8 +34,8 @@
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.translator.SQLConversionVisitor;
+import com.metamatrix.connector.jdbc.translator.TranslatedCommand;
import com.metamatrix.connector.jdbc.util.FunctionReplacementVisitor;
import com.metamatrix.connector.language.ICommand;
import com.metamatrix.connector.metadata.runtime.RuntimeMetadata;
Modified: trunk/test-integration/src/test/resources/xml-vp/xmlvp.DEF
===================================================================
--- trunk/test-integration/src/test/resources/xml-vp/xmlvp.DEF 2009-02-23 16:17:44 UTC (rev 480)
+++ trunk/test-integration/src/test/resources/xml-vp/xmlvp.DEF 2009-02-23 17:43:19 UTC (rev 481)
@@ -45,115 +45,37 @@
<Property Name="MultiSourceEnabled" Value="false" />
</Model>
<ComponentTypes>
- <ComponentType Name="Oracle ANSI JDBC Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2005-07-22T07:17:46.906-06:00" CreatedBy="ConfigurationStartup" CreationDate="2005-07-22T07:17:46.906-06:00">
+ <ComponentType Name="Loopback Connector" ComponentTypeCode="2" Deployable="true" Deprecated="false" Monitorable="false" SuperComponentType="Connector" ParentComponentType="Connectors" LastChangedBy="ConfigurationStartup" LastChangedDate="2005-07-21T10:07:40.921-06:00" CreatedBy="ConfigurationStartup" CreationDate="2005-07-21T10:07:40.921-06:00">
<ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.jdbc.JDBCConnector" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ <PropertyDefinition Name="CapabilitiesClass" DisplayName="Capabilities Class" ShortDescription="" DefaultValue="" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
</ComponentTypeDefn>
<ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="com.metamatrix.data.pool.enable_shrinking" DisplayName="Pool Shrinking Enabled" ShortDescription="Set whether to enable the pool shrinking" DefaultValue="true" Multiplicity="0..1" PropertyType="Boolean" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ <PropertyDefinition Name="ConnectorClass" DisplayName="Connector Class" ShortDescription="" DefaultValue="com.metamatrix.connector.loopback.LoopbackConnector" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
</ComponentTypeDefn>
<ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="com.metamatrix.data.pool.max_connections_for_each_id" DisplayName="Pool Maximum Connections for Each ID" ShortDescription="Set the maximum number of connections for each connector ID for the connection pool" DefaultValue="20" Multiplicity="1" PropertyType="Integer" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ <PropertyDefinition Name="RowCount" DisplayName="Rows Per Query" ShortDescription="" DefaultValue="1" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="true" />
</ComponentTypeDefn>
<ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="ExtensionConnectionFactoryClass" DisplayName="Extension Connection Factory Class" ShortDescription="" DefaultValue="com.metamatrix.connector.jdbc.oracle.OracleSingleIdentityConnectionFactory" Multiplicity="0..1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ <PropertyDefinition Name="WaitTime" DisplayName="Max Random Wait Time" ShortDescription="" DefaultValue="0" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
</ComponentTypeDefn>
<ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="Driver" DisplayName="Driver Class" ShortDescription="" DefaultValue="com.metamatrix.jdbc.oracle.OracleDriver" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="false" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
+ <PropertyDefinition Name="ConnectorClassPath" DisplayName="Class Path" ShortDescription="" DefaultValue="extensionjar:loopbackconn.jar;extensionjar:jdbcconn.jar" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
</ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="ResultSetCacheScope" DisplayName="ResultSet Cache Scope" ShortDescription="" DefaultValue="vdb" Multiplicity="0..1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false">
- <AllowedValue>vdb</AllowedValue>
- <AllowedValue>session</AllowedValue>
- </PropertyDefinition>
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="DatabaseTimeZone" DisplayName="Database time zone" ShortDescription="Time zone of the database, if different than MetaMatrix Server" Multiplicity="0..1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="ExtensionResultsTranslationClass" DisplayName="Extension Results Translation Class" ShortDescription="" DefaultValue="com.metamatrix.connector.jdbc.oracle.OracleResultsTranslator" Multiplicity="0..1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="ExtensionSQLTranslationClass" DisplayName="Extension SQL Translation Class" ShortDescription="" DefaultValue="com.metamatrix.connector.jdbc.oracle.OracleSQLTranslator" Multiplicity="0..1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="ResultSetCacheMaxAge" DisplayName="ResultSet Cache Maximum Age" ShortDescription="" DefaultValue="0" Multiplicity="0..1" PropertyType="Long" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="ConnectorClassPath" DisplayName="Class Path" ShortDescription="" DefaultValue="extensionjar:MJjdbc.jar;extensionjar:jdbcconn.jar" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="ExtensionCapabilityClass" DisplayName="Extension Capability Class" ShortDescription="" DefaultValue="com.metamatrix.connector.jdbc.oracle.OracleCapabilities" Multiplicity="0..1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="URL" DisplayName="JDBC URL" ShortDescription="" DefaultValue="jdbc:mmx:oracle://<host>:1521;SID=<sid>" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="false" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="true" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="com.metamatrix.data.pool.wait_for_source_time" DisplayName="Pool Connection Waiting Time" ShortDescription="Set the time to wait if the connection is not available" DefaultValue="120000" Multiplicity="0..1" PropertyType="Integer" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="com.metamatrix.data.pool.live_and_unused_time" DisplayName="Pool Connection Idle Time" ShortDescription="Set the idle time of the connection before it should be closed if pool shrinking is enabled" DefaultValue="60" Multiplicity="0..1" PropertyType="Integer" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="Password" DisplayName="Password" ShortDescription="" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="false" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="true" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="com.metamatrix.data.pool.max_connections" DisplayName="Pool Maximum Connections" ShortDescription="Set the maximum number of connections for the connection pool" DefaultValue="20" Multiplicity="1" PropertyType="Integer" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="User" DisplayName="User Name" ShortDescription="" Multiplicity="1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="false" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="true" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="TrimStrings" DisplayName="Trim string flag" ShortDescription="" DefaultValue="false" Multiplicity="0..1" PropertyType="Boolean" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="ResultSetCacheMaxSize" DisplayName="ResultSet Cache Maximum Size" ShortDescription="" DefaultValue="0" Multiplicity="0..1" PropertyType="Integer" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="com.metamatrix.data.pool.cleaning_interval" DisplayName="Pool cleaning Interval" ShortDescription="Set the interval to cleaning the pool" DefaultValue="60" Multiplicity="0..1" PropertyType="Integer" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="TransactionIsolationLevel" DisplayName="Transaction Isolation Level" ShortDescription="Set the data source transaction isolation level" DefaultValue="" Multiplicity="0..1" PropertyType="String" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="MaxSQLLength" DisplayName="Max SQL String Length" ShortDescription="" DefaultValue="16384" Multiplicity="0..1" PropertyType="Integer" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="SetCriteriaBatchSize" DisplayName="SetCriteria Batch Size" ShortDescription="Max number of values in a SetCriteria before batching into multiple queries. A value <= 0 indicates batching is OFF." DefaultValue="0" Multiplicity="0..1" PropertyType="Integer" ValueDelimiter="," IsConstrainedToAllowedValues="false" IsExpert="true" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
- <ComponentTypeDefn Deprecated="false">
- <PropertyDefinition Name="ResultSetCacheEnabled" DisplayName="ResultSet Cache Enabled" ShortDescription="" DefaultValue="false" Multiplicity="0..1" PropertyType="Boolean" ValueDelimiter="," IsConstrainedToAllowedValues="true" IsExpert="false" IsHidden="false" IsMasked="false" IsModifiable="true" IsPreferred="false" />
- </ComponentTypeDefn>
</ComponentType>
</ComponentTypes>
<ConnectorBindings>
- <Connector Name="BQT2 Oracle 9i Simple Cap" ComponentType="Oracle ANSI JDBC Connector" LastChangedBy="metamatrixadmin" LastChangedDate="2005-07-22T10:04:46.156-06:00" CreatedBy="metamatrixadmin" CreationDate="2005-07-22T10:04:46.156-06:00" QueuedService="false" routingUUID="mmuuid:ed2688c1-5dee-1f92-9a22-c39c0fb66e36">
+ <Connector Name="BQT2 Oracle 9i Simple Cap" ComponentType="Loopback Connector" LastChangedBy="metamatrixadmin" LastChangedDate="2005-07-20T12:58:35.551-06:00" CreatedBy="metamatrixadmin" CreationDate="2005-07-20T11:39:55.961-06:00" QueuedService="false" routingUUID="mmuuid:a6ea7cc0-c651-1f91-940a-b13465b430eb">
<Properties>
- <Property Name="metamatrix.service.essentialservice">false</Property>
- <Property Name="TransactionIsolationLevel" />
- <Property Name="com.metamatrix.data.pool.max_connections">5</Property>
- <Property Name="Password">mm</Property>
- <Property Name="com.metamatrix.data.pool.cleaning_interval">60</Property>
- <Property Name="com.metamatrix.data.pool.live_and_unused_time">60</Property>
- <Property Name="User">bqt2</Property>
- <Property Name="com.metamatrix.data.pool.enable_shrinking">false</Property>
- <Property Name="TrimStrings">false</Property>
- <Property Name="ExtensionCapabilityClass">com.metamatrix.connector.jdbc.oracle.OracleCapabilities</Property>
- <Property Name="MaxSQLLength">16384</Property>
- <Property Name="ConnectorClass">com.metamatrix.connector.jdbc.JDBCConnector</Property>
- <Property Name="MaxResultRows">500000</Property>
- <Property Name="URL">jdbc:mmx:oracle://slntds04:1521;SID=ds04</Property>
- <Property Name="ExtensionConnectionFactoryClass">com.metamatrix.connector.jdbc.oracle.OracleSingleIdentityConnectionFactory</Property>
+ <Property Name="MaxResultRows">10000</Property>
<Property Name="ConnectorThreadTTL">120000</Property>
- <Property Name="ServiceClassName">com.metamatrix.server.connector.service.ConnectorService</Property>
- <Property Name="SetCriteriaBatchSize">0</Property>
- <Property Name="com.metamatrix.data.pool.max_connections_for_each_id">5</Property>
<Property Name="ConnectorMaxThreads">5</Property>
- <Property Name="ExtensionSQLTranslationClass">com.metamatrix.connector.jdbc.oracle.OracleSQLTranslator</Property>
- <Property Name="ConnectorClassPath">extensionjar:MJjdbc.jar;extensionjar:jdbcconn.jar</Property>
- <Property Name="com.metamatrix.data.pool.wait_for_source_time">120000</Property>
- <Property Name="Driver">com.metamatrix.jdbc.oracle.OracleDriver</Property>
- <Property Name="ExtensionResultsTranslationClass">com.metamatrix.connector.jdbc.oracle.OracleResultsTranslator</Property>
+ <Property Name="CapabilitiesClass" />
+ <Property Name="metamatrix.service.essentialservice">false</Property>
+ <Property Name="ConnectorClassPath">extensionjar:loopbackconn.jar</Property>
+ <Property Name="RowCount">1</Property>
+ <Property Name="ServiceClassName">com.metamatrix.server.connector.service.ConnectorService</Property>
+ <Property Name="ConnectorClass">com.metamatrix.connector.loopback.LoopbackConnector</Property>
+ <Property Name="WaitTime">0</Property>
</Properties>
</Connector>
</ConnectorBindings>
15 years, 10 months
teiid SVN: r480 - trunk/common-core/src/test/java/com/metamatrix/common/protocol.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-02-23 11:17:44 -0500 (Mon, 23 Feb 2009)
New Revision: 480
Modified:
trunk/common-core/src/test/java/com/metamatrix/common/protocol/TestMMFileURLHandler.java
Log:
TEIID-66
Modified: trunk/common-core/src/test/java/com/metamatrix/common/protocol/TestMMFileURLHandler.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/common/protocol/TestMMFileURLHandler.java 2009-02-21 00:28:43 UTC (rev 479)
+++ trunk/common-core/src/test/java/com/metamatrix/common/protocol/TestMMFileURLHandler.java 2009-02-23 16:17:44 UTC (rev 480)
@@ -176,6 +176,46 @@
foo.delete();
}
+
+ public void testSort() throws Exception {
+ String tmpDir = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
+ File f = new File(tmpDir+File.separator+"x"); //$NON-NLS-1$
+ f.mkdirs();
+
+ File a = new File(tmpDir+File.separator+"/x/a.txt"); //$NON-NLS-1$
+ File z = new File(tmpDir+File.separator+"/x/z.txt"); //$NON-NLS-1$
+
+ // Create File using the File
+ createFile(a);
+ createFile(z);
+
+ assertTrue(a.exists());
+ assertTrue(z.exists());
+
+ URL fooURL = URLHelper.buildURL(f.getAbsolutePath()+"/?action=list&filter=.txt&sort=alpha"); //$NON-NLS-1$
+ assertTrue(fooURL.toString().startsWith("mmfile:")); //$NON-NLS-1$
+ assertTrue(fooURL.toString().endsWith("?action=list&filter=.txt&sort=alpha")); //$NON-NLS-1$
+
+ ObjectInputStream in = new ObjectInputStream(fooURL.openStream());
+ String[] list = (String[])in.readObject();
+ in.close();
+
+ String[] expected = {"a.txt", "z.txt"}; //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue(list[0].endsWith(expected[0]));
+ assertTrue(list[1].endsWith(expected[1]));
+
+ fooURL = URLHelper.buildURL(f.getAbsolutePath()+"/?action=list&filter=.txt&sort=reversealpha"); //$NON-NLS-1$
+ in = new ObjectInputStream(fooURL.openStream());
+ list = (String[])in.readObject();
+ in.close();
+
+ assertTrue(list[0].endsWith(expected[1]));
+ assertTrue(list[1].endsWith(expected[0]));
+
+ a.delete();
+ z.delete();
+ }
public void testDelete() throws Exception {
15 years, 10 months