teiid SVN: r3198 - branches/7.1.x/connectors/sandbox/connector-template/src/main/rar/META-INF.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2011-05-25 18:12:29 -0400 (Wed, 25 May 2011)
New Revision: 3198
Modified:
branches/7.1.x/connectors/sandbox/connector-template/src/main/rar/META-INF/ra.xml
Log:
TEIID-1594 updated rar.xml
Modified: branches/7.1.x/connectors/sandbox/connector-template/src/main/rar/META-INF/ra.xml
===================================================================
--- branches/7.1.x/connectors/sandbox/connector-template/src/main/rar/META-INF/ra.xml 2011-05-25 22:10:37 UTC (rev 3197)
+++ branches/7.1.x/connectors/sandbox/connector-template/src/main/rar/META-INF/ra.xml 2011-05-25 22:12:29 UTC (rev 3198)
@@ -6,76 +6,45 @@
http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd"
version="1.5">
- <vendor-name>${vendor-name}</vendor-name>
- <eis-type>${connector-name}</eis-type>
+ <vendor-name>Red Hat Middleware LLC</vendor-name>
+ <eis-type>Coherence Connector</eis-type>
<resourceadapter-version>1.0</resourceadapter-version>
<license>
<description>
- ${license}
+ JBoss, Home of Professional Open Source.
+ Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ as indicated by the @author tags. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ This 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 software 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 software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
</description>
<license-required>true</license-required>
</license>
<resourceadapter>
- <resourceadapter-class>org.teiid.connector.basic.BasicResourceAdapter</resourceadapter-class>
+ <resourceadapter-class>org.teiid.resource.spi.BasicResourceAdapter</resourceadapter-class>
<outbound-resourceadapter>
<connection-definition>
- <managedconnectionfactory-class>${package-name}.${connector-name}ManagedConnectionFactory</managedconnectionfactory-class>
-
- <!-- Common properties for all connectors -->
- <config-property>
- <description>{$display:"Connector Class",$advanced:"true"}</description>
- <config-property-name>ConnectorClass</config-property-name>
- <config-property-type>java.lang.String</config-property-type>
- <config-property-value>${package-name}.${connector-name}Connector</config-property-value>
- </config-property>
-
- <config-property>
- <description>{$display:"Connector Capabilities",$description:"The class to use to provide the Connector Capabilities",$advanced:"true"}</description>
- <config-property-name>CapabilitiesClass</config-property-name>
- <config-property-type>java.lang.String</config-property-type>
- <config-property-value>${package-name}.${connector-name}Capabilities</config-property-value>
- </config-property>
+ <managedconnectionfactory-class>org.teiid.coherence.connector.CoherenceManagedConnectionFactory</managedconnectionfactory-class>
- <config-property>
- <description>{$display:"Is Immutable",$description:"Is Immutable, True if the source never changes.",$advanced:"true"}</description>
- <description>Is Immutable, True if the source never changes.</description>
- <config-property-name>Immutable</config-property-name>
- <config-property-type>java.lang.Boolean</config-property-type>
- <config-property-value>false</config-property-value>
- </config-property>
-
- <config-property>
- <description>{$display:"Is XA Capable",$description:"True, if this connector supports XA Transactions",$advanced:"true"}</description>
- <config-property-name>XaCapable</config-property-name>
- <config-property-type>java.lang.Boolean</config-property-type>
- <config-property-value>false</config-property-value>
- </config-property>
+ <connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
+ <connectionfactory-impl-class>org.teiid.resource.spi.WrappedConnectionFactory</connectionfactory-impl-class>
+ <connection-interface>javax.resource.cci.Connection</connection-interface>
+ <connection-impl-class>org.teiid.resource.spi.WrappedConnection</connection-impl-class>
- <config-property>
- <description>{$display:"Exception on Exceeding Max Rows",$description:"Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned",$advanced:"true"}</description>
- <config-property-name>ExceptionOnMaxRows</config-property-name>
- <config-property-type>java.lang.Boolean</config-property-type>
- <config-property-value>true</config-property-value>
- </config-property>
-
- <config-property>
- <description>{$display:"Maximum Result Rows",$description:"Maximum Result Rows allowed",$advanced:"true"}</description>
- <config-property-name>MaxResultRows</config-property-name>
- <config-property-type>java.lang.Integer</config-property-type>
- <config-property-value>-1</config-property-value>
- </config-property>
-
- <!-- ${connector-name} Specific properties START -->
-
-
- <!-- ${connector-name} Specific properties END -->
-
- <connectionfactory-interface>org.teiid.connector.api.Connector</connectionfactory-interface>
- <connectionfactory-impl-class>org.teiid.connector.basic.WrappedConnector</connectionfactory-impl-class>
- <connection-interface>org.teiid.connector.api.Connection</connection-interface>
- <connection-impl-class>org.teiid.connector.basic.WrappedConnection</connection-impl-class>
-
</connection-definition>
<transaction-support>NoTransaction</transaction-support>
13 years, 7 months
teiid SVN: r3197 - in trunk/connectors/sandbox/coherence_translator/src: META-INF and 7 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2011-05-25 18:10:37 -0400 (Wed, 25 May 2011)
New Revision: 3197
Added:
trunk/connectors/sandbox/coherence_translator/src/META-INF/
trunk/connectors/sandbox/coherence_translator/src/META-INF/jboss-beans.xml
trunk/connectors/sandbox/coherence_translator/src/test/
trunk/connectors/sandbox/coherence_translator/src/test/java/
trunk/connectors/sandbox/coherence_translator/src/test/java/org/
trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/
trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/
trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/
trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/TestCoherenceConnection.java
trunk/connectors/sandbox/coherence_translator/src/test/resources/
trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.vdb
trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.xmi
Log:
TEIID-1594 added test case and artifacts for testing on server
Added: trunk/connectors/sandbox/coherence_translator/src/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/sandbox/coherence_translator/src/META-INF/jboss-beans.xml (rev 0)
+++ trunk/connectors/sandbox/coherence_translator/src/META-INF/jboss-beans.xml 2011-05-25 22:10:37 UTC (rev 3197)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Custom COHERENCE translator -->
+ <bean name="translator-customoracle-template" class="org.teiid.templates.TranslatorDeploymentTemplate">
+ <property name="info"><inject bean="translator-coherence" /> </property>
+ <property name="managedObjectFactory"> <inject bean="ManagedObjectFactory" /> </property>
+ </bean>
+
+ <bean name="translator-coherence" class="org.teiid.templates.TranslatorTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="TranslatorDeploymentTemplateInfoFactory" />
+ <parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.coherence.CoherenceExecutionFactory</parameter>
+ <parameter class="java.lang.String">translator-coherence</parameter>
+ <parameter class="java.lang.String">coherence</parameter>
+ </constructor>
+ </bean>
+
+</deployment>
\ No newline at end of file
Property changes on: trunk/connectors/sandbox/coherence_translator/src/META-INF/jboss-beans.xml
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ LF
Added: trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/TestCoherenceConnection.java
===================================================================
--- trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/TestCoherenceConnection.java (rev 0)
+++ trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/TestCoherenceConnection.java 2011-05-25 22:10:37 UTC (rev 3197)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.coherence.connector;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.teiid.coherence.translator.Leg;
+import org.teiid.coherence.translator.Trade;
+
+import com.tangosol.net.CacheFactory;
+import com.tangosol.net.NamedCache;
+
+public class TestCoherenceConnection {
+
+ static {
+ try {
+ loadCoherence();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Load the cache with 3 trades and 10 legs for each trade.
+ *
+ * @throws Exception
+ */
+ private static void loadCoherence() throws Exception {
+ NamedCache tradesCache = CacheFactory.getCache("Trades");
+
+ // populate the cache
+ Map legsMap = new HashMap();
+ Trade trade = new Trade();
+
+ for (int i = 1; i <= 3; i++) {
+
+ for (int j = 1; j <= 10; j++) {
+ Leg leg = new Leg();
+ leg.setId(j);
+ leg.setNotional(i + j);
+ legsMap.put(j, leg);
+ }
+ trade.setId(i);
+ trade.setLegs(legsMap);
+ tradesCache.put(i, trade);
+ }
+
+ System.out.println("Loaded Coherence");
+
+ }
+
+ /**
+ * This will instantiate the {@link CoherenceManagedConnectionFactory} and
+ * obtain a connection to
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGet1Trade() throws Exception {
+
+ CoherenceManagedConnectionFactory f = new CoherenceManagedConnectionFactory();
+ CoherenceConnection conn = (CoherenceConnection) f.createConnectionFactory().getConnection();
+
+ List<Long> ids = new ArrayList<Long>();
+ ids.add(new Long(1));
+ // List<Trade> trades = conn.getTrades(ids);
+
+ List<?> trades = conn.get("Id = " + 1 + "l");
+ if (trades == null || trades.size() == 0) {
+ throw new Exception("get1Trade: No trade found for 1");
+ } else {
+ System.out
+ .println("get1Trade: # of Trades found: " + trades.size());
+ }
+
+ // grab the first trade to confirm trade 1 was found in the cache.
+ Trade t = (Trade) trades.get(0);
+ Map legs = t.getLegs();
+ System.out.println("Num of legs are: " + legs.size());
+
+ }
+
+ @Test
+ public void testGetAllTrades() throws Exception {
+
+ CoherenceManagedConnectionFactory f = new CoherenceManagedConnectionFactory();
+ CoherenceConnection conn = (CoherenceConnection) f
+ .createConnectionFactory().getConnection();
+
+ List<Object> trades = conn.get(null);
+ if (trades == null || trades.size() == 0) {
+ throw new Exception("getAllTrades: No trades found for 1");
+ } else {
+ System.out.println("getAllTrades: # of Trades found: "
+ + trades.size());
+ }
+
+ Trade t = (Trade) trades.get(0);
+ Map legs = t.getLegs();
+ System.out.println("Num of legs are: " + legs.size());
+
+ }
+}
Property changes on: trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/TestCoherenceConnection.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ LF
Added: trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.vdb
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.xmi
===================================================================
--- trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.xmi (rev 0)
+++ trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.xmi 2011-05-25 22:10:37 UTC (rev 3197)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ASCII"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:diagram="http://www.metamatrix.com/metamodels/Diagram" xmlns:mmcore="http://www.metamatrix.com/metamodels/Core" xmlns:relational="http://www.metamatrix.com/metamodels/Relational">
+ <mmcore:ModelAnnotation xmi:uuid="mmuuid:f415b6fc-e09b-466a-b19b-f7bdfea4195f" primaryMetamodelUri="http://www.metamatrix.com/metamodels/Relational" modelType="PHYSICAL" ProducerName="Teiid Designer" ProducerVersion="7.1.0.v20110215-1224-H420-GA">
+ <modelImports xmi:uuid="mmuuid:c704e924-4d3e-46c1-ab88-d9811254770a" name="XMLSchema" modelLocation="http://www.w3.org/2001/XMLSchema" modelType="TYPE" primaryMetamodelUri="http://www.eclipse.org/xsd/2002/XSD"/>
+ </mmcore:ModelAnnotation>
+ <diagram:DiagramContainer xmi:uuid="mmuuid:edd4ddef-d373-4aeb-8cf8-212cdd21c3f2">
+ <diagram xmi:uuid="mmuuid:7f6fce9d-a334-4260-9a3a-33f397b9f188" type="packageDiagramType" target="mmuuid/f415b6fc-e09b-466a-b19b-f7bdfea4195f">
+ <diagramEntity xmi:uuid="mmuuid:56b9d09d-2135-4f2f-b19d-eb2925dc1192" name="Trade" modelObject="mmuuid/be73e0b2-9cf2-4d65-a26a-b8fa0892c191" xPosition="20" yPosition="20"/>
+ </diagram>
+ </diagram:DiagramContainer>
+ <mmcore:AnnotationContainer xmi:uuid="mmuuid:7de5077c-41da-4353-b854-d97d63fb5a2c"/>
+ <relational:BaseTable xmi:uuid="mmuuid:be73e0b2-9cf2-4d65-a26a-b8fa0892c191" name="Trade">
+ <columns xmi:uuid="mmuuid:6daf8dc7-6d1b-4564-98dd-3ab2a7f2c0dd" name="TradeID" nativeType="Long">
+ <type href="http://www.w3.org/2001/XMLSchema#long"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:54267915-2eb5-4291-8ca0-0e2f24eb4901" name="LegID" nativeType="Long">
+ <type href="http://www.w3.org/2001/XMLSchema#long"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:e8356ebb-6ee7-49ef-bb21-a713fc692ff5" name="Notational" nativeType="Double">
+ <type href="http://www.w3.org/2001/XMLSchema#double"/>
+ </columns>
+ </relational:BaseTable>
+</xmi:XMI>
13 years, 7 months
teiid SVN: r3196 - in branches/7.4.x: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc and 13 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-05-25 15:53:24 -0400 (Wed, 25 May 2011)
New Revision: 3196
Removed:
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java
Modified:
branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
branches/7.4.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
Log:
TEIID-1605 further refinements to the pushdown function concept to allow for multi-part function names
Modified: branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -23,8 +23,8 @@
package org.teiid.translator;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import javax.resource.ResourceException;
@@ -43,6 +43,7 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
@@ -108,6 +109,8 @@
private int maxInSize = DEFAULT_MAX_IN_CRITERIA_SIZE;
private int maxDependentInPredicates = DEFAULT_MAX_IN_CRITERIA_SIZE;
+ private LinkedList<FunctionMethod> pushdownFunctionMethods = new LinkedList<FunctionMethod>();
+
/**
* Initialize the connector with supplied configuration
*/
@@ -651,10 +654,28 @@
return null;
}
+ /**
+ * Get a list of {@link FunctionMethod}s that will be contributed to the SYS schema.
+ * To avoid conflicts with system functions, the function name should contain a
+ * qualifier - typically <translator name>.<function name>
+ * @see ExecutionFactory#addPushDownFunction(String, String, FunctionParameter, FunctionParameter...)
+ * @return
+ */
public List<FunctionMethod> getPushDownFunctions(){
- return Collections.emptyList();
+ return pushdownFunctionMethods;
}
+ protected FunctionMethod addPushDownFunction(String qualifier, String name, String returnType, String...paramTypes) {
+ FunctionParameter[] params = new FunctionParameter[paramTypes.length];
+ for (int i = 0; i < paramTypes.length; i++) {
+ params[i] = new FunctionParameter("param" + (i+1), paramTypes[i]); //$NON-NLS-1$
+ }
+ FunctionMethod method = new FunctionMethod(qualifier + '.' + name, name, qualifier, params, new FunctionParameter("result", returnType)); //$NON-NLS-1$
+ method.setNameInSource(name);
+ pushdownFunctionMethods.add(method);
+ return method;
+ }
+
/**
* Get the integer value representing the number of values allowed in an IN criteria
* in the WHERE clause of a query
Modified: branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -41,6 +41,7 @@
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
+import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.sql.DataSource;
@@ -144,7 +145,7 @@
}
};
- private Map<String, FunctionModifier> functionModifiers = new HashMap<String, FunctionModifier>();
+ private Map<String, FunctionModifier> functionModifiers = new TreeMap<String, FunctionModifier>(String.CASE_INSENSITIVE_ORDER);
private boolean useBindVariables = true;
private String databaseTimeZone;
@@ -511,9 +512,18 @@
if (obj instanceof Function) {
Function function = (Function)obj;
if (functionModifiers != null) {
- FunctionModifier modifier = functionModifiers.get(function.getName().toLowerCase());
- if (modifier != null) {
- parts = modifier.translate(function);
+ String name = function.getName();
+ while (true) {
+ FunctionModifier modifier = functionModifiers.get(name);
+ if (modifier != null) {
+ parts = modifier.translate(function);
+ break;
+ }
+ int index = name.indexOf('.');
+ if (index < 0 || index == name.length() - 1) {
+ break;
+ }
+ name = name.substring(index + 1);
}
}
} else if (obj instanceof Command) {
@@ -553,7 +563,7 @@
}
/**
- * Return a map of function name in lower case to FunctionModifier.
+ * Return a map of function name to FunctionModifier.
* @return Map of function name to FunctionModifier.
*/
public Map<String, FunctionModifier> getFunctionModifiers() {
@@ -566,7 +576,7 @@
* @param modifier
*/
public void registerFunctionModifier(String name, FunctionModifier modifier) {
- this.functionModifiers.put(name.toLowerCase(), modifier);
+ this.functionModifiers.put(name, modifier);
}
/**
Modified: branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ingres/IngresExecutionFactory.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -21,6 +21,8 @@
*/
package org.teiid.translator.jdbc.ingres;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
@@ -28,10 +30,7 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.core.types.DataTypeManager;
import org.teiid.language.Limit;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
@@ -40,7 +39,6 @@
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.FunctionModifier;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
-
@Translator(name="ingres", description="A translator for Ingres Databases")
public class IngresExecutionFactory extends JDBCExecutionFactory {
@@ -78,7 +76,45 @@
registerFunctionModifier(SourceSystemFunctions.RAND, new AliasModifier("random")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("uppercase")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
+
+ addPushDownFunction(INGRES, "bit_add", INTEGER, INTEGER, INTEGER); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "bit_length", INTEGER, INTEGER); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "character_length", STRING, INTEGER); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "charextract", CHAR, STRING, INTEGER); //$NON-NLS-1$
+
+ // uses ingres date??
+ //supportedFunctions.add("date_trunc");
+ //supportedFunctions.add("dow");
+ //supportedFunctions.add("extract");
+ addPushDownFunction(INGRES, "gmt_timestamp", STRING, INTEGER); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "hash", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "hex", STRING, STRING); //$NON-NLS-1$
+
+ // do not have byte[] type
+ //supportedFunctions.add("intextract");
+
+ addPushDownFunction(INGRES, "ln", DOUBLE, DOUBLE); //$NON-NLS-1$
+
+ // see lowercase
+ // supportedFunctions.add("lower");
+ // supportedFunctions.add("upper");
+
+ addPushDownFunction(INGRES, "octet_length", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "randomf", FLOAT); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "session_user", STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "size", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "squeeze", STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "soundex", STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "unhex", STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "usercode", STRING); //$NON-NLS-1$
+ addPushDownFunction(INGRES, "username", STRING); //$NON-NLS-1$
+ // ignore
+ // supportedFunctions.add("uuid_create");
+ // supportedFunctions.add("uuid_compare");
+ // supportedFunctions.add("uuid_from_char");
+ // supportedFunctions.add("uuid_to_char");
+
}
@Override
@@ -123,122 +159,6 @@
}
@Override
- public List<FunctionMethod> getPushDownFunctions(){
- List<FunctionMethod> pushdownFunctions = new ArrayList<FunctionMethod>();
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "bit_add", "bit_add", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer2", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "bit_length", "bit_length", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "character_length", "character_length", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "charextract", "charextract", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.CHAR, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // uses ingres date??
- //supportedFunctions.add("date_trunc");
- //supportedFunctions.add("dow");
- //supportedFunctions.add("extract");
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "gmt_timestamp", "gmt_timestamp", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "hash", "hash", INGRES,//$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "hex", "hex", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // do not have byte[] type
- //supportedFunctions.add("intextract");
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "ln", "ln", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float1", DataTypeManager.DefaultDataTypes.DOUBLE, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DOUBLE, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // see lowercase
- // supportedFunctions.add("lower");
- // supportedFunctions.add("upper");
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "octet_length", "octet_length", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "pad", "pad", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "pad", "pad", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "randomf", "randomf", INGRES, null,//$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "session_user", "session_user", INGRES, null,//$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "size", "size", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "squeeze", "squeeze", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "soundex", "soundex", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "unhex", "unhex", INGRES, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "usercode", "usercode", INGRES, null,//$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INGRES + '.' + "username", "username", INGRES, null,//$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- // ignore
- // supportedFunctions.add("uuid_create");
- // supportedFunctions.add("uuid_compare");
- // supportedFunctions.add("uuid_from_char");
- // supportedFunctions.add("uuid_to_char");
-
- return pushdownFunctions;
- }
-
- @Override
public boolean supportsRowLimit() {
return true;
}
Modified: branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/intersyscache/InterSystemsCacheExecutionFactory.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -21,6 +21,8 @@
*/
package org.teiid.translator.jdbc.intersyscache;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
@@ -28,10 +30,7 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.core.types.DataTypeManager;
import org.teiid.language.Function;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
@@ -111,6 +110,18 @@
return null;
}
});
+
+ addPushDownFunction(INTER_CACHE, "CHARACTER_LENGTH", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "CHAR_LENGTH", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "CHARINDEX", INTEGER, STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "CHARINDEX", INTEGER, STRING, STRING, INTEGER); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "INSTR", INTEGER, STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "INSTR", INTEGER, STRING, STRING, INTEGER); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "IS_NUMERIC", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "REPLICATE", STRING, STRING, INTEGER); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "REVERSE", STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "STUFF", STRING, STRING, STRING, INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(INTER_CACHE, "TRIM", STRING, STRING); //$NON-NLS-1$
}
@Override
@@ -179,80 +190,6 @@
}
@Override
- public List<FunctionMethod> getPushDownFunctions(){
-
- List<FunctionMethod> pushdownFunctions = new ArrayList<FunctionMethod>();
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "CHARACTER_LENGTH", "CHARACTER_LENGTH", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "CHAR_LENGTH", "CHAR_LENGTH", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "CHARINDEX", "CHARINDEX", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "CHARINDEX", "CHARINDEX", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "INSTR", "INSTR", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "INSTR", "INSTR", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "IS_NUMERIC", "IS_NUMERIC", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "REPLICATE", "REPLICATE", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.INTEGER, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "REVERSE", "REVERSE", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "STUFF", "STUFF", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("integer2", DataTypeManager.DefaultDataTypes.INTEGER, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(INTER_CACHE + '.' + "TRIM", "TRIM", INTER_CACHE, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- return pushdownFunctions;
- }
-
-
- @Override
public String translateLiteralDate(Date dateValue) {
return "to_date('" + formatDateValue(dateValue) + "', 'yyyy-mm-dd')"; //$NON-NLS-1$//$NON-NLS-2$
}
Modified: branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/modeshape/ModeShapeExecutionFactory.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -22,6 +22,8 @@
package org.teiid.translator.jdbc.modeshape;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
@@ -29,7 +31,6 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.core.types.DataTypeManager;
import org.teiid.language.Comparison;
import org.teiid.language.Function;
import org.teiid.language.LanguageObject;
@@ -38,8 +39,6 @@
import org.teiid.language.Comparison.Operator;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
@@ -47,7 +46,6 @@
import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
-
/**
* Translator class for accessing the ModeShape JCR repository.
*/
@@ -79,6 +77,12 @@
registerFunctionModifier(JCR_REFERENCE, new IdentifierFunctionModifier());
registerFunctionModifier(JCR_CONTAINS, new IdentifierFunctionModifier());
+ addPushDownFunction(JCR, JCR_ISCHILDNODE, BOOLEAN, STRING, STRING);
+ addPushDownFunction(JCR, JCR_ISDESCENDANTNODE, BOOLEAN, STRING, STRING);
+ addPushDownFunction(JCR, JCR_ISSAMENODE, BOOLEAN, STRING, STRING);
+ addPushDownFunction(JCR, JCR_CONTAINS, BOOLEAN, STRING, STRING);
+ addPushDownFunction(JCR, JCR_REFERENCE, BOOLEAN, STRING);
+
LogManager.logTrace(LogConstants.CTX_CONNECTOR, "ModeShape Translator Started"); //$NON-NLS-1$
}
@@ -112,42 +116,7 @@
return supportedFunctions;
}
-
@Override
- public List<FunctionMethod> getPushDownFunctions(){
- List<FunctionMethod> pushdownFunctions = new ArrayList<FunctionMethod>();
- pushdownFunctions.add(new FunctionMethod(JCR + '.' + JCR_ISCHILDNODE, JCR_ISCHILDNODE, JCR,
- new FunctionParameter[] {
- new FunctionParameter("path1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("path2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(JCR + '.' + JCR_ISDESCENDANTNODE, JCR_ISDESCENDANTNODE, JCR,
- new FunctionParameter[] {
- new FunctionParameter("path1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("path2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(JCR + '.' + JCR_ISSAMENODE, JCR_ISSAMENODE, JCR,
- new FunctionParameter[] {
- new FunctionParameter("path1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("path2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(JCR + '.' + JCR_CONTAINS, JCR_CONTAINS, JCR,
- new FunctionParameter[] {
- new FunctionParameter("selectorOrProperty", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("searchExpr", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(JCR + '.' + JCR_REFERENCE, JCR_REFERENCE, JCR,
- new FunctionParameter[] {
- new FunctionParameter("selectorOrProperty", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
- return pushdownFunctions;
- }
-
- @Override
public List<?> translate(LanguageObject obj, ExecutionContext context) {
if (obj instanceof Comparison) {
Comparison compare = (Comparison)obj;
Modified: branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -22,8 +22,10 @@
/*
*/
-package org.teiid.translator.jdbc.oracle;
+package org.teiid.translator.jdbc.oracle;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Timestamp;
@@ -49,7 +51,6 @@
import org.teiid.language.SetQuery.Operation;
import org.teiid.language.visitor.CollectorVisitor;
import org.teiid.metadata.Column;
-import org.teiid.metadata.FunctionMethod;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
@@ -75,6 +76,15 @@
public final static String DUAL = "DUAL"; //$NON-NLS-1$
public final static String ROWNUM = "ROWNUM"; //$NON-NLS-1$
public final static String SEQUENCE = ":SEQUENCE="; //$NON-NLS-1$
+ /*
+ * Spatial Functions
+ */
+ public static final String RELATE = "sdo_relate"; //$NON-NLS-1$
+ public static final String NEAREST_NEIGHBOR = "sdo_nn"; //$NON-NLS-1$
+ public static final String FILTER = "sdo_filter"; //$NON-NLS-1$
+ public static final String WITHIN_DISTANCE = "sdo_within_distance"; //$NON-NLS-1$
+ public static final String NEAREST_NEIGHBOR_DISTANCE = "sdo_nn_distance"; //$NON-NLS-1$
+ public static final String ORACLE_SDO = "Oracle-SDO"; //$NON-NLS-1$
public void start() throws TranslatorException {
super.start();
@@ -112,10 +122,10 @@
});
//spatial functions
- registerFunctionModifier(OracleSpatialFunctions.RELATE, new OracleSpatialFunctionModifier());
- registerFunctionModifier(OracleSpatialFunctions.NEAREST_NEIGHBOR, new OracleSpatialFunctionModifier());
- registerFunctionModifier(OracleSpatialFunctions.FILTER, new OracleSpatialFunctionModifier());
- registerFunctionModifier(OracleSpatialFunctions.WITHIN_DISTANCE, new OracleSpatialFunctionModifier());
+ registerFunctionModifier(OracleExecutionFactory.RELATE, new OracleSpatialFunctionModifier());
+ registerFunctionModifier(OracleExecutionFactory.NEAREST_NEIGHBOR, new OracleSpatialFunctionModifier());
+ registerFunctionModifier(OracleExecutionFactory.FILTER, new OracleSpatialFunctionModifier());
+ registerFunctionModifier(OracleExecutionFactory.WITHIN_DISTANCE, new OracleSpatialFunctionModifier());
//add in type conversion
ConvertModifier convertModifier = new ConvertModifier();
@@ -171,6 +181,21 @@
convertModifier.addNumericBooleanConversions();
convertModifier.setWideningNumericImplicit(true);
registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
+
+ addPushDownFunction(ORACLE_SDO, RELATE, STRING, STRING, STRING, STRING);
+ addPushDownFunction(ORACLE_SDO, RELATE, STRING, OBJECT, OBJECT, STRING);
+ addPushDownFunction(ORACLE_SDO, RELATE, STRING, STRING, OBJECT, STRING);
+ addPushDownFunction(ORACLE_SDO, RELATE, STRING, OBJECT, STRING, STRING);
+ addPushDownFunction(ORACLE_SDO, NEAREST_NEIGHBOR, STRING, STRING, OBJECT, STRING, INTEGER);
+ addPushDownFunction(ORACLE_SDO, NEAREST_NEIGHBOR, STRING, OBJECT, OBJECT, STRING, INTEGER);
+ addPushDownFunction(ORACLE_SDO, NEAREST_NEIGHBOR, STRING, OBJECT, STRING, STRING, INTEGER);
+ addPushDownFunction(ORACLE_SDO, NEAREST_NEIGHBOR_DISTANCE, INTEGER, INTEGER);
+ addPushDownFunction(ORACLE_SDO, WITHIN_DISTANCE, STRING, OBJECT, OBJECT, STRING);
+ addPushDownFunction(ORACLE_SDO, WITHIN_DISTANCE, STRING, STRING, OBJECT, STRING);
+ addPushDownFunction(ORACLE_SDO, WITHIN_DISTANCE, STRING, OBJECT, STRING, STRING);
+ addPushDownFunction(ORACLE_SDO, FILTER, STRING, OBJECT, STRING, STRING);
+ addPushDownFunction(ORACLE_SDO, FILTER, STRING, OBJECT, OBJECT, STRING);
+ addPushDownFunction(ORACLE_SDO, FILTER, STRING, STRING, OBJECT, STRING);
}
public void handleInsertSequences(Insert insert) throws TranslatorException {
@@ -327,7 +352,7 @@
// If so, the ORDERED hint is added, if not, it isn't
Collection<Function> col = CollectorVisitor.collectObjects(Function.class, command);
for (Function func : col) {
- if (func.getName().equalsIgnoreCase(OracleSpatialFunctions.RELATE)) {
+ if (func.getName().equalsIgnoreCase(OracleExecutionFactory.RELATE)) {
return comment + "/*+ ORDERED */ "; //$NON-NLS-1$
}
}
@@ -456,16 +481,15 @@
supportedFunctions.add("IFNULL"); //$NON-NLS-1$
supportedFunctions.add("NVL"); //$NON-NLS-1$
supportedFunctions.add("COALESCE"); //$NON-NLS-1$
-
+ supportedFunctions.add(RELATE);
+ supportedFunctions.add(NEAREST_NEIGHBOR);
+ supportedFunctions.add(NEAREST_NEIGHBOR_DISTANCE);
+ supportedFunctions.add(WITHIN_DISTANCE);
+ supportedFunctions.add(FILTER);
return supportedFunctions;
}
@Override
- public List<FunctionMethod> getPushDownFunctions(){
- return OracleSpatialFunctions.getOracleSpatialFunctions();
- }
-
- @Override
public String translateLiteralTimestamp(Timestamp timestampValue) {
if (timestampValue.getNanos() == 0) {
String val = formatDateValue(timestampValue);
Deleted: branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctions.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -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 org.teiid.translator.jdbc.oracle;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.core.types.DataTypeManager;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
-
-public class OracleSpatialFunctions {
-
- /*
- * Spatial Functions
- */
- public static final String RELATE = "sdo_relate"; //$NON-NLS-1$
- public static final String NEAREST_NEIGHBOR = "sdo_nn"; //$NON-NLS-1$
- public static final String FILTER = "sdo_filter"; //$NON-NLS-1$
- public static final String WITHIN_DISTANCE = "sdo_within_distance"; //$NON-NLS-1$
- public static final String NEAREST_NEIGHBOR_DISTANCE = "sdo_nn_distance"; //$NON-NLS-1$
- public static final String ORACLE_SDO = "Oracle-SDO"; //$NON-NLS-1$
-
-
- public static List<FunctionMethod> getOracleSpatialFunctions(){
-
- List<FunctionMethod> spatialFuncs = new ArrayList<FunctionMethod>();
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + RELATE, RELATE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + RELATE, RELATE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + RELATE, RELATE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + RELATE, RELATE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + NEAREST_NEIGHBOR, NEAREST_NEIGHBOR, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("NUMBER", DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + NEAREST_NEIGHBOR, NEAREST_NEIGHBOR, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("NUMBER", DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + NEAREST_NEIGHBOR, NEAREST_NEIGHBOR, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("NUMBER", DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + NEAREST_NEIGHBOR_DISTANCE, NEAREST_NEIGHBOR_DISTANCE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("NUMBER", DataTypeManager.DefaultDataTypes.INTEGER, "") }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + WITHIN_DISTANCE, WITHIN_DISTANCE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + WITHIN_DISTANCE, WITHIN_DISTANCE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + WITHIN_DISTANCE, WITHIN_DISTANCE, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + FILTER, FILTER, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + FILTER, FILTER, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- spatialFuncs.add(new FunctionMethod(ORACLE_SDO + '.' + FILTER, FILTER, ORACLE_SDO,
- new FunctionParameter[] {
- new FunctionParameter("GEOM1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("GEOM2", DataTypeManager.DefaultDataTypes.OBJECT, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("PARAMS", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- return spatialFuncs;
- }
-}
Modified: branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -22,6 +22,8 @@
package org.teiid.translator.jdbc.teradata;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
+
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
@@ -29,14 +31,11 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.core.types.DataTypeManager;
import org.teiid.language.ColumnReference;
import org.teiid.language.Expression;
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
import org.teiid.language.Literal;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
@@ -164,7 +163,23 @@
public List<?> translate(Function function) {
return Arrays.asList(function.getParameters().get(0), " MOD ", function.getParameters().get(1)); //$NON-NLS-1$
}
- });
+ });
+
+ addPushDownFunction(TERADATA, "COSH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "TANH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ACOSH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ASINH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ATANH", FLOAT, FLOAT); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "CHAR2HEXINT", STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "INDEX", INTEGER, STRING, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "BYTES", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "OCTET_LENGTH", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHAMP", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHBAKAMP", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHBUCKET", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "HASHROW", INTEGER, STRING); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "NULLIFZERO", BIG_DECIMAL, BIG_DECIMAL); //$NON-NLS-1$
+ addPushDownFunction(TERADATA, "ZEROIFNULL", BIG_DECIMAL, BIG_DECIMAL); //$NON-NLS-1$
}
@Override
@@ -210,106 +225,13 @@
supportedFunctions.add(SourceSystemFunctions.SQRT);
supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
supportedFunctions.add(SourceSystemFunctions.TAN);
- supportedFunctions.add("||"); //$NON-NLS-1$
- supportedFunctions.add("**"); //$NON-NLS-1$
supportedFunctions.add(SourceSystemFunctions.UCASE);
supportedFunctions.add(SourceSystemFunctions.YEAR);
return supportedFunctions;
}
-
@Override
- public List<FunctionMethod> getPushDownFunctions(){
-
- List<FunctionMethod> pushdownFunctions = new ArrayList<FunctionMethod>();
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "COSH", "COSH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic Cos")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "SINH", "SINH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic Sin")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "TANH", "TANH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic Tanh")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "ACOSH", "ACOSH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic ArcCos")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "ASINH", "ASINH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic ArcSin")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "ATANH", "ATANH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("float", DataTypeManager.DefaultDataTypes.FLOAT, "Hyperbolic ArcTan")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.FLOAT, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "CHAR2HEXINT", "CHAR2HEXINT", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "INDEX", "INDEX", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "BYTES", "BYTES", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "OCTET_LENGTH", "OCTET_LENGTH", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "HASHAMP", "HASHAMP", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "HASHBAKAMP", "HASHBAKAMP", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "HASHBUCKET", "HASHBUCKET", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "HASHROW", "HASHROW", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("String2", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "NULLIFZERO", "NULLIFZERO", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("integer", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(TERADATA + '.' + "ZEROIFNULL", "ZEROIFNULL", TERADATA, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
- new FunctionParameter("integer", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BIG_DECIMAL, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- return pushdownFunctions;
- }
-
-
- @Override
public String translateLiteralDate(Date dateValue) {
return "cast('" + formatDateValue(dateValue) + "' AS DATE FORMAT 'yyyy-mm-dd')"; //$NON-NLS-1$//$NON-NLS-2$
}
Modified: branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -36,6 +36,7 @@
import org.mockito.Mockito;
import org.teiid.cdk.api.TranslationUtility;
import org.teiid.cdk.unittest.FakeTranslationFactory;
+import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.language.Command;
import org.teiid.metadata.FunctionMethod;
@@ -72,7 +73,7 @@
public static void loadUDFs(String udf, TranslationUtility util) {
try {
Collection <FunctionMethod> methods = FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream());
- util.setUDF(methods);
+ util.addUDF("foo", methods); //$NON-NLS-1$
} catch (IOException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
} catch (JAXBException e) {
@@ -83,8 +84,11 @@
public static Command helpTranslate(String vdbFileName, String udf, List<FunctionMethod> pushdowns, String sql) {
TranslationUtility util = getTranslationUtility(vdbFileName, null);
- Collection <FunctionMethod> methods = new ArrayList<FunctionMethod>();
+ if (pushdowns != null) {
+ util.addUDF(CoreConstants.SYSTEM_MODEL, pushdowns);
+ }
if (udf != null) {
+ Collection <FunctionMethod> methods = new ArrayList<FunctionMethod>();
try {
methods.addAll(FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream()));
} catch (JAXBException e) {
@@ -92,11 +96,8 @@
} catch (IOException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
}
+ util.addUDF("foo", methods); //$NON-NLS-1$
}
- if (pushdowns != null) {
- methods.addAll(pushdowns);
- }
- util.setUDF(methods);
return util.parseCommand(sql);
}
Modified: branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -394,7 +394,15 @@
input, output,
TRANSLATOR);
}
+
+ @Test public void test_sdo_within_distance_pushdownfunction() throws Exception {
+ String input = "SELECT INTKEY FROM BQT1.SMALLA WHERE sdo_within_distance(OBJECTVALUE, 'SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(90.0, -45.0, NULL), NULL, NULL)', 'DISTANCE=25.0 UNIT=NAUT_MILE') = true"; //$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey FROM SmallA WHERE sdo_within_distance(SmallA.ObjectValue, SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(90.0, -45.0, NULL), NULL, NULL), 'DISTANCE=25.0 UNIT=NAUT_MILE') = 'true'"; //$NON-NLS-1$
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output,
+ TRANSLATOR);
+ }
+
/**
* Test a query which uses
* <code>sdo_within_distance(String literal, Object element, String literal)
Modified: branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
===================================================================
--- branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -22,7 +22,9 @@
package org.teiid.translator.salesforce;
+import static org.teiid.translator.TypeFacility.RUNTIME_NAMES.*;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -88,7 +90,9 @@
@Override
public void start() throws TranslatorException {
super.start();
- LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Started"); //$NON-NLS-1$
+ addPushDownFunction(SALESFORCE, INCLUDES, BOOLEAN, STRING, STRING);
+ addPushDownFunction(SALESFORCE, EXCLUDES, BOOLEAN, STRING, STRING);
+ LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Salesforce ExecutionFactory Started"); //$NON-NLS-1$
}
@@ -124,28 +128,11 @@
}
@Override
- public List getSupportedFunctions() {
- return Collections.EMPTY_LIST;
+ public List<String> getSupportedFunctions() {
+ return Arrays.asList(INCLUDES, EXCLUDES);
}
@Override
- public List<FunctionMethod> getPushDownFunctions(){
- List<FunctionMethod> pushdownFunctions = new ArrayList<FunctionMethod>();
- pushdownFunctions.add(new FunctionMethod(SALESFORCE + '.' +INCLUDES, INCLUDES, SALESFORCE,
- new FunctionParameter[] {
- new FunctionParameter("columnName", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("param", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
-
- pushdownFunctions.add(new FunctionMethod(SALESFORCE + '.' + EXCLUDES, EXCLUDES, SALESFORCE,
- new FunctionParameter[] {
- new FunctionParameter("columnName", DataTypeManager.DefaultDataTypes.STRING, ""), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("param", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "") ) ); //$NON-NLS-1$ //$NON-NLS-2$
- return pushdownFunctions;
- }
-
- @Override
public boolean supportsCompareCriteriaEquals() {
return true;
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/LanguageBridgeFactory.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -31,6 +31,7 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidRuntimeException;
@@ -70,8 +71,8 @@
import org.teiid.language.SubqueryComparison.Quantifier;
import org.teiid.metadata.Procedure;
import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.FunctionMethod.PushDown;
import org.teiid.query.metadata.QueryMetadataInterface;
-import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.sql.lang.BatchedUpdateCommand;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.CompareCriteria;
@@ -506,8 +507,15 @@
String name = function.getName();
if (function.getFunctionDescriptor() != null) {
name = function.getFunctionDescriptor().getName();
+ //check for translator pushdown functions, and use the name in source if possible
+ if (function.getFunctionDescriptor().getPushdown() == PushDown.MUST_PUSHDOWN
+ && function.getFunctionDescriptor().getSchema().equalsIgnoreCase(CoreConstants.SYSTEM_MODEL)
+ && function.getFunctionDescriptor().getMethod().getNameInSource() != null) {
+ name = function.getFunctionDescriptor().getMethod().getNameInSource();
+ }
+ } else {
+ name = SingleElementSymbol.getShortName(name);
}
- name = SingleElementSymbol.getShortName(name);
//if there is any ambiguity in the function name it will be up to the translator logic to check the
//metadata
@@ -557,9 +565,7 @@
Object mid = symbol.getMetadataID();
- if(! (mid instanceof TempMetadataID)) {
- element.setMetadataObject(metadataFactory.getElement(mid));
- }
+ element.setMetadataObject(metadataFactory.getElement(mid));
return element;
}
@@ -717,9 +723,6 @@
}
fullGroup = removeSchemaName(fullGroup);
NamedTable group = new NamedTable(fullGroup, alias, null);
- if (symbol.getMetadataID() instanceof TempMetadataID) {
- return group;
- }
try {
group.setMetadataObject(metadataFactory.getGroup(symbol.getMetadataID()));
} catch (QueryMetadataException e) {
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -29,10 +29,12 @@
*/
public class BasicSourceCapabilities implements SourceCapabilities, Serializable {
- private Scope scope = Scope.SCOPE_GLOBAL;
- private Map capabilityMap = new HashMap();
- private Map functionMap = new HashMap();
- private Map propertyMap = new HashMap();
+ private static final long serialVersionUID = -1779069588746365579L;
+
+ private Scope scope = Scope.SCOPE_GLOBAL;
+ private Map<Capability, Boolean> capabilityMap = new HashMap<Capability, Boolean>();
+ private Map<String, Boolean> functionMap = new TreeMap<String, Boolean>(String.CASE_INSENSITIVE_ORDER);
+ private Map<Capability, Object> propertyMap = new HashMap<Capability, Object>();
/**
* Construct a basic capabilities object.
@@ -41,12 +43,12 @@
}
public boolean supportsCapability(Capability capability) {
- Boolean supports = (Boolean) capabilityMap.get(capability);
+ Boolean supports = capabilityMap.get(capability);
return (supports == null) ? false : supports.booleanValue();
}
public boolean supportsFunction(String functionName) {
- Boolean supports = (Boolean) functionMap.get(functionName);
+ Boolean supports = functionMap.get(functionName);
return (supports == null) ? false : supports.booleanValue();
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -354,8 +354,7 @@
* used if the capability FUNCTION is true.
*
* @param functionName
- * The function that may be supported (see MetaMatrix documentation for further definition of the functions and
- * their parameters.)
+ * The function that may be supported
* @return True if function is supported.
*/
public boolean supportsFunction(String functionName);
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -209,14 +209,14 @@
}
//capabilities check is only valid for non-schema scoped functions
- //technically the other functions are scoped to SYS, but that's
+ //technically the other functions are scoped to SYS or their function model, but that's
//not formally part of their metadata yet
Schema schema = function.getFunctionDescriptor().getMethod().getParent();
if (schema == null) {
// Find capabilities
SourceCapabilities caps = getCapabilities(modelID, metadata, capFinder);
- if (!caps.supportsFunction(function.getFunctionDescriptor().getName().toLowerCase())) {
+ if (!caps.supportsFunction(function.getFunctionDescriptor().getName())) {
return false;
}
} else if (!schema.getFullName().equalsIgnoreCase(metadata.getFullName(modelID))) {
@@ -225,7 +225,7 @@
//special check to ensure that special conversions are not pushed down (this can be removed after we support type based function pushdown)
if (FunctionLibrary.isConvert(function)) {
- Class fromType = function.getArg(0).getType();
+ Class<?> fromType = function.getArg(0).getType();
//object or clob to anything cannot be pushed down
if (DataTypeManager.DefaultDataClasses.OBJECT.equals(fromType)
|| DataTypeManager.DefaultDataClasses.CLOB.equals(fromType)
Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -22,11 +22,11 @@
package org.teiid.dqp.internal.process;
+import static org.junit.Assert.*;
+
import java.util.ArrayList;
-import java.util.List;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
@@ -34,26 +34,18 @@
import org.teiid.dqp.internal.datamgr.CapabilitiesConverter;
import org.teiid.dqp.internal.datamgr.ConnectorManager;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
-import org.teiid.metadata.FunctionMethod;
-import org.teiid.metadata.FunctionParameter;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.TranslatorException;
/**
*/
-public class TestConnectorCapabilitiesFinder extends TestCase {
+@SuppressWarnings("nls")
+public class TestConnectorCapabilitiesFinder {
- /**
- * Constructor for TestConnectorCapabilitiesFinder.
- * @param name
- */
- public TestConnectorCapabilitiesFinder(String name) {
- super(name);
- }
-
- public void testFind() throws Exception {
+ @Test public void testFind() throws Exception {
String modelName = "model"; //$NON-NLS-1$
String functionName = "fakeFunction"; //$NON-NLS-1$
@@ -84,19 +76,17 @@
}
- public void testPushdownFunctionSupport() throws Exception {
+ @Test public void testPushdownFunctionSupport() throws Exception {
ExecutionFactory<Object, Object> ef = new ExecutionFactory<Object, Object>(){
- public List<FunctionMethod> getPushDownFunctions(){
- ArrayList<FunctionMethod> list = new ArrayList<FunctionMethod>();
- list.add(new FunctionMethod("ns.func", "function", "misc", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {
- new FunctionParameter("param", DataTypeManager.DefaultDataTypes.STRING, "")}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, "" ) )); //$NON-NLS-1$ //$NON-NLS-2$
- return list;
- }
+
+ @Override
+ public void start() throws TranslatorException {
+ super.start();
+ addPushDownFunction("ns", "func", DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING);
+ }
};
-
+ ef.start();
BasicSourceCapabilities bsc = CapabilitiesConverter.convertCapabilities(ef, "conn"); //$NON-NLS-1$
- assertEquals("Did not get expected capabilities", true, bsc.supportsFunction("ns.func")); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("Did not get expected capabilities", bsc.supportsFunction("ns.func")); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Modified: branches/7.4.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
===================================================================
--- branches/7.4.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java 2011-05-25 02:55:47 UTC (rev 3195)
+++ branches/7.4.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java 2011-05-25 19:53:24 UTC (rev 3196)
@@ -24,7 +24,9 @@
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.List;
import org.teiid.cdk.CommandBuilder;
import org.teiid.dqp.internal.datamgr.RuntimeMetadataImpl;
@@ -53,25 +55,36 @@
public class TranslationUtility {
private QueryMetadataInterface metadata;
+ private FunctionLibrary functionLibrary;
/**
* Construct a utility instance with a given vdb file.
* @param vdbFile The .vdb file name representing metadata for the connector
*/
public TranslationUtility(String vdbFile) {
- metadata = VDBMetadataFactory.getVDBMetadata(vdbFile);
+ initWrapper(VDBMetadataFactory.getVDBMetadata(vdbFile));
}
+
+ private void initWrapper(QueryMetadataInterface acutalMetadata) {
+ functionLibrary = acutalMetadata.getFunctionLibrary();
+ metadata = new BasicQueryMetadataWrapper(acutalMetadata) {
+ @Override
+ public FunctionLibrary getFunctionLibrary() {
+ return functionLibrary;
+ }
+ };
+ }
public TranslationUtility(URL url) {
try {
- metadata = VDBMetadataFactory.getVDBMetadata(url, null);
+ initWrapper(VDBMetadataFactory.getVDBMetadata(url, null));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public TranslationUtility(QueryMetadataInterface metadata) {
- this.metadata = metadata;
+ initWrapper(metadata);
}
public Command parseCommand(String sql, boolean generateAliases, boolean supportsGroupAliases) {
@@ -98,14 +111,13 @@
public RuntimeMetadata createRuntimeMetadata() {
return new RuntimeMetadataImpl(metadata);
}
+
+ private List<FunctionTree> functions = new ArrayList<FunctionTree>();
+
+ public void addUDF(String schema, Collection<FunctionMethod> methods) {
+ this.functions.add(new FunctionTree(schema, new UDFSource(methods)));
+ SystemFunctionManager sfm = new SystemFunctionManager();
+ functionLibrary = new FunctionLibrary(sfm.getSystemFunctions(), this.functions.toArray(new FunctionTree[this.functions.size()]));
+ }
- public void setUDF(final Collection<FunctionMethod> methods) {
- this.metadata = new BasicQueryMetadataWrapper(this.metadata) {
- @Override
- public FunctionLibrary getFunctionLibrary() {
- SystemFunctionManager sfm = new SystemFunctionManager();
- return new FunctionLibrary(sfm.getSystemFunctions(), new FunctionTree("foo", new UDFSource(methods))); //$NON-NLS-1$
- }
- };
- }
}
13 years, 7 months
teiid SVN: r3195 - in branches/7.4.x: api/src/main/java/org/teiid and 18 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-05-24 22:55:47 -0400 (Tue, 24 May 2011)
New Revision: 3195
Added:
branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/
branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/_NetworkInterface.java
Modified:
branches/7.4.x/api/pom.xml
branches/7.4.x/api/src/main/java/org/teiid/CommandContext.java
branches/7.4.x/api/src/main/java/org/teiid/logging/AuditMessage.java
branches/7.4.x/api/src/main/java/org/teiid/logging/LogMessage.java
branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionContext.java
branches/7.4.x/build/kits/jboss-container/teiid-releasenotes.html
branches/7.4.x/client/src/main/java/org/teiid/adminapi/Session.java
branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
branches/7.4.x/client/src/main/java/org/teiid/net/TeiidURL.java
branches/7.4.x/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java
branches/7.4.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java
branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml
branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/FromClause.java
branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/JoinPredicate.java
branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/TableFunctionReference.java
branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java
branches/7.4.x/engine/src/main/java/org/teiid/query/util/CommandContext.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
branches/7.4.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
branches/7.4.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
branches/7.4.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java
Log:
TEIID-1586 increasing audit information by adding a client reported hardware address, and updating the context objects to include more information.
Modified: branches/7.4.x/api/pom.xml
===================================================================
--- branches/7.4.x/api/pom.xml 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/api/pom.xml 2011-05-25 02:55:47 UTC (rev 3195)
@@ -7,8 +7,8 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>teiid-api</artifactId>
- <name>Teiid Translator API</name>
- <description>API for creating Translators and other common extenders in Teiid</description>
+ <name>Teiid API</name>
+ <description>API for creating Translators and other extensions to Teiid</description>
<dependencies>
<dependency>
@@ -19,6 +19,12 @@
<dependency>
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
<artifactId>teiid-common-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
Modified: branches/7.4.x/api/src/main/java/org/teiid/CommandContext.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/CommandContext.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/api/src/main/java/org/teiid/CommandContext.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -22,35 +22,100 @@
package org.teiid;
+import java.io.Serializable;
import java.util.Properties;
import java.util.TimeZone;
import javax.security.auth.Subject;
+import org.teiid.adminapi.Session;
+
/**
* Context information for the currently executing command.
* Can be used as an argument to UDFs.
*/
public interface CommandContext {
+ /**
+ * Get the current user name
+ * @return
+ */
String getUserName();
+ /**
+ * Get the current vdb name
+ * @return
+ */
String getVdbName();
+ /**
+ * Get the current vdb version
+ * @return
+ */
int getVdbVersion();
+ /**
+ * Get the connection id
+ * @return
+ */
String getConnectionID();
+ /**
+ * Get the environment properties. The returned properties are associated only with the currently executing command.
+ * The only built-in key/value in the properties is the key "sessionid" with the same value as getConnectionID()
+ * @return
+ * @deprecated
+ */
Properties getEnvironmentProperties();
+ /**
+ * Get the next random double value
+ * @return
+ */
double getNextRand();
+ /**
+ * Sets the seed value and returns the next random double value.
+ * Additional calls to {@link #getNextRand()} will be based upon the seed value.
+ * @param seed
+ * @return
+ */
double getNextRand(long seed);
+ /**
+ * Get the processor batch size set on the BufferManager
+ * @return
+ */
int getProcessorBatchSize();
+ /**
+ * Get the server {@link TimeZone}
+ * @return
+ */
TimeZone getServerTimeZone();
+ /**
+ * Get the current subject
+ * @return
+ */
Subject getSubject();
+ /**
+ * Get the current session
+ * @return
+ */
+ Session getSession();
+
+ /**
+ * Get the current command payload
+ * @return may be null if the client did not set a payload
+ */
+ Serializable getCommandPayload();
+
+ /**
+ * Get the current request id
+ * @return
+ */
+ String getRequestId();
+
}
Modified: branches/7.4.x/api/src/main/java/org/teiid/logging/AuditMessage.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/logging/AuditMessage.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/api/src/main/java/org/teiid/logging/AuditMessage.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -24,20 +24,22 @@
import java.util.Arrays;
+import org.teiid.CommandContext;
+
/**
* Log format for auditing.
*/
public class AuditMessage {
private String context;
private String activity;
- private String principal;
- private Object[] resources;
+ private String[] resources;
+ private CommandContext commandContext;
- public AuditMessage(String context, String activity, String principal, String[] resources ) {
+ public AuditMessage(String context, String activity, String[] resources, CommandContext commandContext) {
this.context = context;
this.activity = activity;
- this.principal = principal;
this.resources = resources;
+ this.commandContext = commandContext;
}
public String getContext() {
@@ -49,15 +51,20 @@
}
public String getPrincipal() {
- return this.principal;
+ return this.commandContext.getUserName();
}
- public Object[] getResources() {
+ public String[] getResources() {
return this.resources;
}
-
+
+ public CommandContext getCommandContext() {
+ return commandContext;
+ }
+
public String toString() {
StringBuffer msg = new StringBuffer();
+ msg.append( this.commandContext.getRequestId());
msg.append(" ["); //$NON-NLS-1$
msg.append( getPrincipal() );
msg.append("] <"); //$NON-NLS-1$
Modified: branches/7.4.x/api/src/main/java/org/teiid/logging/LogMessage.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/logging/LogMessage.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/api/src/main/java/org/teiid/logging/LogMessage.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -27,6 +27,8 @@
public class LogMessage implements Serializable{
+ private static final long serialVersionUID = -134503344442009940L;
+
private Object[] msgParts;
public LogMessage(Object[] msgParts) {
Modified: branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionContext.java
===================================================================
--- branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionContext.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/api/src/main/java/org/teiid/translator/ExecutionContext.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -26,8 +26,10 @@
import javax.security.auth.Subject;
+import org.teiid.adminapi.Session;
+
/**
* The security context provides information about the user context in which
* this query is being run.
@@ -138,4 +140,10 @@
* @return
*/
boolean isTransactional();
+
+ /**
+ * Get the current session.
+ * @return
+ */
+ Session getSession();
}
Modified: branches/7.4.x/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/7.4.x/build/kits/jboss-container/teiid-releasenotes.html 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/build/kits/jboss-container/teiid-releasenotes.html 2011-05-25 02:55:47 UTC (rev 3195)
@@ -52,7 +52,7 @@
</UL>
<LI><B>Enhanced Sort Join</B> - the partitioned merge join was replaced with an enhanced sort join. The enhanced sort join will use the actual row counts from each side of the relation to perform a index based join if one side is small enough, a partial sort of the larger side and a repeated merge join if the tuples are unbalanced but one side is not small enough to form an index, or a standard sort merge join if the tuples are balanced.
<LI><B>JDK1.5 JDBC Client JAR</B> - A retro-translated Teiid client JDBC jar now available to use with JDK 1.5 VM. Note only the JDBC API is supported, not the Admin API, or retrieving query plans as XML.
- <LI><B>Security Improvements</B> - UDF and pushdown functions can now be protected with data roles. Also the CommandContext can provide the Subject for custom security checks in UDFs.
+ <LI><B>Security Improvements</B> - UDF and pushdown functions can now be protected with data roles. Also the CommandContext/ExecutionContext have access to the org.teiid.adminapi.Session and JAAS Subject for custom security checks in UDFs.
<LI><B>Cache Invalidation</B> - Prepared plan and result set caches have will invalidate entries based upon metadata and data changes respectively. See the cache configuration maxStaleness setting and the Admin and Developer Guides for more.
<LI><B>Runtime Updates of Metadata</B> - ALTER statements have been added to change view/procedure/INSTEAD OF trigger (update procedure) definitions. A CREATE TRIGGER statement is also available to add an INSTEAD OF trigger (update procedures) to views.
System procedures were added to set extension metadata and stat values. By default all effects of metadata updates happen only on running vdbs across the cluster. To make the changes persistent see the Developers Guide Runtime Updates section.
Modified: branches/7.4.x/client/src/main/java/org/teiid/adminapi/Session.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/adminapi/Session.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/client/src/main/java/org/teiid/adminapi/Session.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -24,12 +24,11 @@
/**
- * A Session is a lasting connection between a client and a Teiid System.
+ * A Session represents a single connection between a client and the server.
*
- * A user may be allowed to have multiple sessions active simultaneously.
- *
+ * A user is allowed to have multiple sessions active simultaneously.
*/
-public interface Session extends AdminObject {
+public interface Session extends AdminObject {
/**
* Get the Last time Client has check to see if the server is still available
@@ -90,6 +89,12 @@
public String getClientHostName();
/**
+ * Get the client hardware (typically MAC) address. Note this value is reported from the client.
+ * @return the hardware address as a hex string or null if not available.
+ */
+ public String getClientHardwareAddress();
+
+ /**
* Get the time the {@link Session} was created.
* @return
*/
Modified: branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadata.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -35,7 +35,10 @@
/**
* Add and delete properties also in the Mapper class for correct wrapping for profile service.
+ *
*/
+/* TODO: it would probably be good to let ipAddress denote the connecting address
+ and add clientIpAdress as the client reported value */
@MetaMapping(SessionMetadataMapper.class)
public class SessionMetadata extends AdminObjectImpl implements Session {
@@ -45,6 +48,7 @@
private long createdTime;
private String ipAddress;
private String clientHostName;
+ private String clientHardwareAddress;
private String userName;
private String vdbName;
private int vdbVersion;
@@ -59,7 +63,7 @@
private transient boolean embedded;
@Override
- @ManagementProperty(description="Application assosiated with Session", readOnly=true)
+ @ManagementProperty(description="Application associated with Session", readOnly=true)
public String getApplicationName() {
return this.applicationName;
}
@@ -89,7 +93,7 @@
}
@Override
- @ManagementProperty(description="IP address from where session is created", readOnly=true)
+ @ManagementProperty(description="IP address of session client", readOnly=true)
public String getIPAddress() {
return this.ipAddress;
}
@@ -119,7 +123,7 @@
}
@Override
- @ManagementProperty(description="User name assosiated with session", readOnly=true)
+ @ManagementProperty(description="User name associated with session", readOnly=true)
public String getUserName() {
return this.userName;
}
@@ -129,7 +133,7 @@
}
@Override
- @ManagementProperty(description="VDB name assosiated with session", readOnly=true)
+ @ManagementProperty(description="VDB name associated with session", readOnly=true)
public String getVDBName() {
return this.vdbName;
}
@@ -139,7 +143,7 @@
}
@Override
- @ManagementProperty(description="VDB version name assosiated with session", readOnly=true)
+ @ManagementProperty(description="VDB version name associated with session", readOnly=true)
public int getVDBVersion() {
return this.vdbVersion;
}
@@ -168,6 +172,7 @@
str.append("; createdTime=").append(new Date(createdTime));
str.append("; applicationName=").append(applicationName);
str.append("; clientHostName=").append(clientHostName);
+ str.append("; clientHardwareAddress=").append(clientHardwareAddress);
str.append("; IPAddress=").append(ipAddress);
str.append("; securityDomain=").append(securityDomain);
str.append("; lastPingTime=").append(new Date(lastPingTime));
@@ -218,4 +223,14 @@
return embedded;
}
+ @Override
+ @ManagementProperty(description="Hardware address reported by the client", readOnly=true)
+ public String getClientHardwareAddress() {
+ return this.clientHardwareAddress;
+ }
+
+ public void setClientHardwareAddress(String clientHardwareAddress) {
+ this.clientHardwareAddress = clientHardwareAddress;
+ }
+
}
Modified: branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/client/src/main/java/org/teiid/adminapi/impl/SessionMetadataMapper.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -43,6 +43,7 @@
private static final String LAST_PING_TIME = "lastPingTime"; //$NON-NLS-1$
private static final String IP_ADDRESS = "IPAddress"; //$NON-NLS-1$
private static final String CLIENT_HOST_NAME = "clientHostName"; //$NON-NLS-1$
+ private static final String CLIENT_MAC = "clientMAC"; //$NON-NLS-1$
private static final String CREATED_TIME = "createdTime"; //$NON-NLS-1$
private static final String APPLICATION_NAME = "applicationName"; //$NON-NLS-1$
private static final MutableCompositeMetaType metaType;
@@ -60,6 +61,7 @@
metaType.addItem(VDB_NAME, VDB_NAME, SimpleMetaType.STRING);
metaType.addItem(VDB_VERSION, VDB_VERSION, SimpleMetaType.INTEGER_PRIMITIVE);
metaType.addItem(SECURITY_DOMAIN, SECURITY_DOMAIN, SimpleMetaType.STRING);
+ metaType.addItem(CLIENT_MAC, CLIENT_MAC, SimpleMetaType.STRING);
metaType.freeze();
}
@@ -91,7 +93,7 @@
session.set(VDB_NAME,SimpleValueSupport.wrap(object.getVDBName()));
session.set(VDB_VERSION, SimpleValueSupport.wrap(object.getVDBVersion()));
session.set(SECURITY_DOMAIN, SimpleValueSupport.wrap(object.getSecurityDomain()));
-
+ session.set(CLIENT_MAC, SimpleValueSupport.wrap(object.getSecurityDomain()));
return session;
}
throw new IllegalArgumentException("Cannot convert session " + object); //$NON-NLS-1$
@@ -116,6 +118,7 @@
session.setVDBName((String) metaValueFactory.unwrap(compositeValue.get(VDB_NAME)));
session.setVDBVersion((Integer) metaValueFactory.unwrap(compositeValue.get(VDB_VERSION)));
session.setSecurityDomain((String) metaValueFactory.unwrap(compositeValue.get(SECURITY_DOMAIN)));
+ session.setClientHardwareAddress((String) metaValueFactory.unwrap(compositeValue.get(CLIENT_MAC)));
return session;
}
throw new IllegalStateException("Unable to unwrap session " + metaValue); //$NON-NLS-1$
Modified: branches/7.4.x/client/src/main/java/org/teiid/net/TeiidURL.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/net/TeiidURL.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/client/src/main/java/org/teiid/net/TeiidURL.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -51,6 +51,7 @@
public static interface CONNECTION {
public static final String CLIENT_IP_ADDRESS = "clientIpAddress"; //$NON-NLS-1$
public static final String CLIENT_HOSTNAME = "clientHostName"; //$NON-NLS-1$
+ public static final String CLIENT_MAC = "clientMAC"; //$NON-NLS-1$
/**
* If true, will automatically select a new server instance after a communication exception.
* @since 5.6
Modified: branches/7.4.x/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java
===================================================================
--- branches/7.4.x/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/client/src/main/java/org/teiid/net/socket/SocketServerConnectionFactory.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -30,6 +30,8 @@
import java.lang.reflect.Proxy;
import java.net.InetAddress;
import java.net.MalformedURLException;
+import java.net.NetworkInterface;
+import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -323,8 +325,19 @@
InetAddress addr = InetAddress.getLocalHost();
connectionProperties.put(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS, addr.getHostAddress());
connectionProperties.put(TeiidURL.CONNECTION.CLIENT_HOSTNAME, addr.getCanonicalHostName());
+ NetworkInterface ni = NetworkInterface.getByInetAddress(addr);
+ if (ni != null && ni.getHardwareAddress() != null) {
+ StringBuilder sb = new StringBuilder();
+ for (byte b : ni.getHardwareAddress()) {
+ sb.append(PropertiesUtils.toHex(b >> 4));
+ sb.append(PropertiesUtils.toHex(b));
+ }
+ connectionProperties.put(TeiidURL.CONNECTION.CLIENT_MAC, sb.toString());
+ }
} catch (UnknownHostException err1) {
connectionProperties.put(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS, "UnknownClientAddress"); //$NON-NLS-1$
+ } catch (SocketException e) {
+
}
}
Added: branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/_NetworkInterface.java
===================================================================
--- branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/_NetworkInterface.java (rev 0)
+++ branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/_NetworkInterface.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -0,0 +1,35 @@
+/*
+ * 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 net.sf.retrotranslator.runtime.java.net;
+
+import java.net.NetworkInterface;
+import java.net.SocketException;
+
+public class _NetworkInterface {
+
+ @SuppressWarnings("unused")
+ public static byte[] getHardwareAddress(NetworkInterface ni) throws SocketException {
+ return null;
+ }
+
+}
Property changes on: branches/7.4.x/client-jdk15/src/main/java/net/sf/retrotranslator/runtime/java/net/_NetworkInterface.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/7.4.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java
===================================================================
--- branches/7.4.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/common-core/src/main/java/org/teiid/core/util/PropertiesUtils.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -716,7 +716,7 @@
* Convert a nibble to a hex character
* @param nibble the nibble to convert.
*/
- private static char toHex(int nibble) {
+ public static char toHex(int nibble) {
return hexDigit[(nibble & 0xF)];
}
Modified: branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml
===================================================================
--- branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/logging.xml 2011-05-25 02:55:47 UTC (rev 3195)
@@ -33,19 +33,73 @@
<title>Command Logging API</title>
<para>
If you want to build a custom appender for command logging that will have access to
- log4j "LoggingEvents" to the "COMMAND_LOG" context, it will have a message that is an instance of
- <code>org.teiid.logging.CommandLogMessage</code> defined in the <code>teiid-api-&versionNumber;.jar</code>
- use these class in your development. The CommmdLogMessage include information about vdb, session, command-sql etc.
+ log4j "LoggingEvents" to the "COMMAND_LOG" contextthe appender will receive a message that is an instance of
+ <code>org.teiid.logging.CommandLogMessage</code> wrapped in a <code>org.teiid.logging.LogMessage</code>. The relevant Teiid classes are defined in the <code>teiid-api-&versionNumber;.jar</code>.
+ The CommmdLogMessage includes information about vdb, session, command sql, etc. CommandLogMessages are logged at the DEBUG level.
</para>
+ <example>
+ <title>Sample CommandLogMessage Usage</title>
+ <programlisting language="Java" role="JAVA"><![CDATA[package org.something;
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.spi.LoggingEvent;
+import org.teiid.logging.*;
+
+public class CustomAppender extends AppenderSkeleton
+{
+
+ protected void append(LoggingEvent event) {
+ if (event.getMessage() instanceof LogMessage) {
+ LogMessage logMessage = (LogMessage)event.getMessage();
+ if (logMessage.getMessageParts()[0] instanceof CommandLogMessage) {
+ CommandLogMessage clMessage = (CommandLogMessage)logMessage.getMessageParts()[0];
+ String sql = clMessage.getSql();
+ ...
+ //log to a database, trigger an email, etc.
+ }
+ }
+ ...
+ }
+
+ ...
+
+}]]></programlisting>
+ </example>
</section>
<section id="audit_logging">
<title>Audit Logging API</title>
<para>If you want to build a custom appender for command logging that will have access to
- log4j "LoggingEvents" to the "AUDIT_LOG" context, it will have a message that is an instance of
- <code>org.teiid.logging.AuditMessage</code> defined in the <code>teiid-api-&versionNumber;.jar</code>
- use this class in your development. AuditMessage include information about user, the action, and the
- target(s) of the action.</para>
+ log4j "LoggingEvents" to the "org.teiid.AUDIT_LOG" context, the appender will receive a message that is an instance of
+ <code>org.teiid.logging.AuditMessage</code> wrapped in a <code>org.teiid.logging.LogMessage</code>. The relevant Teiid classes are defined in the <code>teiid-api-&versionNumber;.jar</code>. The <code>AuditMessage</code> includes information about user, the action, and the
+ target(s) of the action. AuditMessages are logged at the DEBUG level.
+ </para>
+ <example>
+ <title>Sample AuditMessage Usage</title>
+ <programlisting language="Java" role="JAVA"><![CDATA[package org.something;
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.spi.LoggingEvent;
+import org.teiid.logging.*;
+
+public class CustomAppender extends AppenderSkeleton
+{
+
+ protected void append(LoggingEvent event) {
+ if (event.getMessage() instanceof LogMessage) {
+ LogMessage logMessage = (LogMessage)event.getMessage();
+ if (logMessage.getMessageParts()[0] instanceof AuditMessage) {
+ AuditMessage auditMessage = (AuditMessage)logMessage.getMessageParts()[0];
+ String activity = auditMessage.getActivity();
+ ...
+ //log to a database, trigger an email, etc.
+ }
+ }
+ ...
+ }
+
+ ...
+
+}]]></programlisting>
+ </example>
</section>
</section>
</chapter>
\ No newline at end of file
Modified: branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml
===================================================================
--- branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/documentation/developer-guide/src/main/docbook/en-US/content/udf.xml 2011-05-25 02:55:47 UTC (rev 3195)
@@ -161,7 +161,7 @@
<para>Code Requirements</para>
<listitem>
<para>The java class containing the function method must be defined
- public.
+ public. <note><para>As many UDF methods as you want can be declared on the same class.</para></note>
</para>
</listitem>
<listitem>
@@ -184,7 +184,7 @@
</itemizedlist>
<para>You may optionally add an additional <code>org.teiid.CommandContext</code> argument as the first parameter.
The <code>CommandContext</code> interface provides access to information about the current command, such as the executing user, Subject, the vdb, the session id, etc.
- This <code>CommandContext</code> parameter does not need to be delared in the function metadata.</para>
+ This <code>CommandContext</code> parameter should not be delared in the function metadata.</para>
<example>
<title>Sample code</title>
<programlisting language="Java" role="JAVA"><![CDATA[package org.something;
@@ -207,6 +207,23 @@
}
}]]></programlisting>
</example>
+ <example>
+ <title>Sample CommandContext Usage</title>
+ <programlisting language="Java" role="JAVA"><![CDATA[package org.something;
+
+public class SessionInfo
+{
+ /**
+ * @param context
+ * @return the created Timestamp
+ */
+ public static Timestamp sessionCreated(CommandContext context)
+ {
+ return new Timestamp(context.getSession().getCreatedTime());
+ }
+}]]></programlisting>
+ <para>The corresponding UDF would be declared as Timestamp sessionCreated().</para>
+ </example>
</section>
<section>
<title>Post Code Activities</title>
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ConnectorWorkItem.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -100,6 +100,7 @@
);
this.securityContext.setUser(requestMsg.getWorkContext().getSubject());
this.securityContext.setBatchSize(this.requestMsg.getFetchSize());
+ this.securityContext.setSession(requestMsg.getWorkContext().getSession());
this.connector = manager.getExecutionFactory();
VDBMetaData vdb = requestMsg.getWorkContext().getVDB();
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/datamgr/ExecutionContextImpl.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -30,6 +30,7 @@
import javax.security.auth.Subject;
+import org.teiid.adminapi.Session;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.util.HashCodeUtil;
import org.teiid.translator.ExecutionContext;
@@ -64,6 +65,7 @@
private int batchSize = BufferManager.DEFAULT_CONNECTOR_BATCH_SIZE;
private List<Exception> warnings = new LinkedList<Exception>();
+ private Session session;
public ExecutionContextImpl(String vdbName, int vdbVersion, Serializable executionPayload,
String originalConnectionID, String connectorName, String requestId, String partId, String execCount) {
@@ -204,4 +206,13 @@
warnings.clear();
return result;
}
+
+ @Override
+ public Session getSession() {
+ return this.session;
+ }
+
+ public void setSession(Session session) {
+ this.session = session;
+ }
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidationVisitor.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -34,7 +34,9 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.CommandContext;
import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.Session;
import org.teiid.adminapi.DataPolicy.PermissionType;
import org.teiid.adminapi.impl.DataPolicyMetadata;
import org.teiid.api.exception.query.QueryMetadataException;
@@ -86,13 +88,13 @@
}
private HashMap<String, DataPolicy> allowedPolicies;
- private String userName;
private boolean allowCreateTemporaryTablesDefault = true;
private boolean allowFunctionCallsByDefault = true;
+ private CommandContext commandContext;
- public AuthorizationValidationVisitor(HashMap<String, DataPolicy> policies, String user) {
+ public AuthorizationValidationVisitor(HashMap<String, DataPolicy> policies, CommandContext commandContext) {
this.allowedPolicies = policies;
- this.userName = user;
+ this.commandContext = commandContext;
}
public void setAllowCreateTemporaryTablesDefault(
@@ -150,7 +152,7 @@
logResult(resources, context, allowed);
if (!allowed) {
handleValidationError(
- QueryPlugin.Util.getString("ERR.018.005.0095", userName, "CREATE_TEMPORARY_TABLES"), //$NON-NLS-1$ //$NON-NLS-2$
+ QueryPlugin.Util.getString("ERR.018.005.0095", commandContext.getUserName(), "CREATE_TEMPORARY_TABLES"), //$NON-NLS-1$ //$NON-NLS-2$
symbols);
}
}
@@ -158,7 +160,7 @@
private void logRequest(Set<String> resources, Context context) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
// Audit - request
- AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-request", this.userName, resources.toArray(new String[resources.size()])); //$NON-NLS-1$
+ AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-request", resources.toArray(new String[resources.size()]), commandContext); //$NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
}
}
@@ -374,7 +376,7 @@
// is not authorized in the exception message
handleValidationError(
- QueryPlugin.Util.getString("ERR.018.005.0095", userName, actionCode), //$NON-NLS-1$
+ QueryPlugin.Util.getString("ERR.018.005.0095", commandContext.getUserName(), actionCode), //$NON-NLS-1$
inaccessibleSymbols);
}
@@ -409,10 +411,10 @@
boolean granted) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_AUDITLOGGING, MessageLevel.DETAIL)) {
if (granted) {
- AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-granted all", this.userName, resources.toArray(new String[resources.size()])); //$NON-NLS-1$
+ AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-granted all", resources.toArray(new String[resources.size()]), commandContext); //$NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
} else {
- AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-denied", this.userName, resources.toArray(new String[resources.size()])); //$NON-NLS-1$
+ AuditMessage msg = new AuditMessage(context.name(), "getInaccessibleResources-denied", resources.toArray(new String[resources.size()]), commandContext); //$NON-NLS-1$
LogManager.logDetail(LogConstants.CTX_AUDITLOGGING, msg);
}
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/AuthorizationValidator.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -26,6 +26,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
/**
* Defines a validator that checks for proper authorization.
@@ -33,7 +34,7 @@
public interface AuthorizationValidator {
void validate(Command command, QueryMetadataInterface metadata,
- DQPWorkContext workContext) throws QueryValidatorException, TeiidComponentException;
+ DQPWorkContext workContext, CommandContext commandContext) throws QueryValidatorException, TeiidComponentException;
boolean hasRole(String roleName, DQPWorkContext workContext);
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRoleAuthorizationValidator.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -26,6 +26,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
/**
* The default Teiid authorization validator
@@ -44,9 +45,9 @@
}
@Override
- public void validate(Command command, QueryMetadataInterface metadata, DQPWorkContext workContext) throws QueryValidatorException, TeiidComponentException {
+ public void validate(Command command, QueryMetadataInterface metadata, DQPWorkContext workContext, CommandContext commandContext) throws QueryValidatorException, TeiidComponentException {
if (useEntitlements && !workContext.getVDB().getDataPolicies().isEmpty()) {
- AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(workContext.getAllowedDataPolicies(), workContext.getUserName());
+ AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(workContext.getAllowedDataPolicies(), commandContext);
visitor.setAllowCreateTemporaryTablesDefault(allowCreateTemporaryTablesByDefault);
visitor.setAllowFunctionCallsByDefault(allowFunctionCallsByDefault);
Request.validateWithVisitor(visitor, metadata, command);
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -158,8 +158,6 @@
processPlan = cachedPlan.clone();
//already in cache. obtain the values from cache
analysisRecord = prepPlan.getAnalysisRecord();
-
- createCommandContext();
}
if (requestMsg.isBatchedUpdate()) {
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -205,9 +205,9 @@
this.metadata = tma;
}
- protected void createCommandContext() throws QueryValidatorException {
- boolean returnsResultSet = userCommand.returnsResultSet();
- this.returnsUpdateCount = !(userCommand instanceof StoredProcedure) && !returnsResultSet;
+ protected void createCommandContext(Command command) throws QueryValidatorException {
+ boolean returnsResultSet = command.returnsResultSet();
+ this.returnsUpdateCount = !(command instanceof StoredProcedure) && !returnsResultSet;
if ((this.requestMsg.getResultsMode() == ResultsMode.UPDATECOUNT && !returnsUpdateCount)
|| (this.requestMsg.getResultsMode() == ResultsMode.RESULTSET && !returnsResultSet)) {
throw new QueryValidatorException(QueryPlugin.Util.getString(this.requestMsg.getResultsMode()==ResultsMode.RESULTSET?"Request.no_result_set":"Request.result_set")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -252,6 +252,8 @@
context.setResultSetCacheEnabled(this.resultSetCacheEnabled);
context.setUserRequestSourceConcurrency(this.userRequestConcurrency);
context.setSubject(workContext.getSubject());
+ this.context.setSession(workContext.getSession());
+ this.context.setRequestId(this.requestId);
}
@Override
@@ -381,11 +383,9 @@
this.analysisRecord = new AnalysisRecord(requestMsg.getShowPlan() != ShowPlan.OFF, requestMsg.getShowPlan() == ShowPlan.DEBUG);
resolveCommand(command);
-
+
validateAccess(userCommand);
- createCommandContext();
-
Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(command, true);
for (GroupSymbol groupSymbol : groups) {
if (groupSymbol.isTempTable()) {
@@ -464,7 +464,8 @@
}
protected void validateAccess(Command command) throws QueryValidatorException, TeiidComponentException {
- this.authorizationValidator.validate(command, metadata, workContext);
+ createCommandContext(command);
+ this.authorizationValidator.validate(command, metadata, workContext, context);
}
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/FromClause.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/FromClause.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/FromClause.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -26,6 +26,7 @@
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.sql.visitor.SQLStringVisitor;
@@ -50,7 +51,7 @@
}
public abstract void acceptVisitor(LanguageVisitor visitor);
- public abstract void collectGroups(Collection groups);
+ public abstract void collectGroups(Collection<GroupSymbol> groups);
public abstract Object clone();
public boolean isMakeDep() {
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/JoinPredicate.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/JoinPredicate.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/JoinPredicate.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -30,6 +30,7 @@
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.GroupSymbol;
/**
@@ -165,7 +166,7 @@
* Collect all GroupSymbols for this from clause.
* @param groups Groups to add to
*/
- public void collectGroups(Collection groups) {
+ public void collectGroups(Collection<GroupSymbol> groups) {
if(this.leftClause != null) {
this.leftClause.collectGroups(groups);
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/TableFunctionReference.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/TableFunctionReference.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/TableFunctionReference.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -83,7 +83,7 @@
public ProjectedColumn copyTo(ProjectedColumn copy) {
copy.name = this.name;
copy.type = this.type;
- copy.symbol = (ElementSymbol)this.symbol.clone();
+ copy.symbol = this.symbol.clone();
return copy;
}
@@ -101,14 +101,14 @@
}
public void copy(TableFunctionReference copy) {
- copy.symbol = (GroupSymbol)this.symbol.clone();
+ copy.symbol = this.symbol.clone();
if (correlatedReferences != null) {
copy.correlatedReferences = correlatedReferences.clone();
}
}
@Override
- public void collectGroups(Collection groups) {
+ public void collectGroups(Collection<GroupSymbol> groups) {
groups.add(getGroupSymbol());
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -2,7 +2,6 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import net.sf.saxon.sxpath.XPathExpression;
@@ -195,11 +194,6 @@
}
@Override
- public void collectGroups(Collection groups) {
- groups.add(getGroupSymbol());
- }
-
- @Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/util/CommandContext.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/util/CommandContext.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -33,6 +33,7 @@
import javax.security.auth.Subject;
+import org.teiid.adminapi.Session;
import org.teiid.api.exception.query.QueryProcessingException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
@@ -40,6 +41,7 @@
import org.teiid.dqp.internal.process.PreparedPlan;
import org.teiid.dqp.internal.process.SessionAwareCache;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
+import org.teiid.dqp.message.RequestID;
import org.teiid.metadata.FunctionMethod.Determinism;
import org.teiid.query.QueryPlugin;
import org.teiid.query.eval.SecurityFunctionEvaluator;
@@ -117,6 +119,10 @@
private int userRequestSourceConcurrency;
private Subject subject;
private HashSet<Object> dataObjects;
+
+ public Session session;
+
+ public RequestID requestId;
}
private GlobalState globalState = new GlobalState();
@@ -567,4 +573,22 @@
this.dataObjects = dataObjectsAccessed;
}
+ @Override
+ public Session getSession() {
+ return this.globalState.session;
+ }
+
+ public void setSession(Session session) {
+ this.globalState.session = session;
+ }
+
+ @Override
+ public String getRequestId() {
+ return this.globalState.requestId.toString();
+ }
+
+ public void setRequestId(RequestID requestId) {
+ this.globalState.requestId = requestId;
+ }
+
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -29,11 +29,13 @@
import java.util.HashSet;
import java.util.Set;
+import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.teiid.adminapi.DataPolicy;
import org.teiid.adminapi.DataPolicy.PermissionType;
import org.teiid.adminapi.impl.DataPolicyMetadata;
+import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
import org.teiid.api.exception.query.QueryParserException;
@@ -47,6 +49,7 @@
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.unittest.RealMetadataFactory;
+import org.teiid.query.util.CommandContext;
import org.teiid.query.validator.Validator;
import org.teiid.query.validator.ValidatorFailure;
import org.teiid.query.validator.ValidatorReport;
@@ -55,6 +58,11 @@
public class TestAuthorizationValidationVisitor {
public static final String CONN_ID = "connID"; //$NON-NLS-1$
+ private static CommandContext context = new CommandContext();
+
+ @BeforeClass public static void oneTimeSetup() {
+ context.setSession(new SessionMetadata());
+ }
PermissionMetaData addResource(PermissionType type, boolean flag, String resource) {
PermissionMetaData p = new PermissionMetaData();
@@ -172,7 +180,7 @@
HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
policies.put(policy.getName(), policy);
- AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(policies, "test"); //$NON-NLS-1$
+ AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(policies, context); //$NON-NLS-1$
visitor.setAllowFunctionCallsByDefault(false);
ValidatorReport report = Validator.validate(command, metadata, visitor);
if(report.hasItems()) {
@@ -321,7 +329,7 @@
private void helpTestLookupVisibility(boolean visible) throws QueryParserException, QueryValidatorException, TeiidComponentException {
VDBMetaData vdb = RealMetadataFactory.example1VDB();
vdb.getModel("pm1").setVisible(visible); //$NON-NLS-1$
- AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(new HashMap<String, DataPolicy>(), "test"); //$NON-NLS-1$
+ AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(new HashMap<String, DataPolicy>(), context); //$NON-NLS-1$
String sql = "select lookup('pm1.g1', 'e1', 'e2', 1)"; //$NON-NLS-1$
Command command = QueryParser.getQueryParser().parseCommand(sql);
Request.validateWithVisitor(mvvv, RealMetadataFactory.example1Cached(), command);
Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -30,6 +30,7 @@
import org.teiid.client.RequestMessage;
import org.teiid.client.RequestMessage.StatementType;
import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
@@ -79,7 +80,7 @@
RequestMessage message = new RequestMessage();
DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
- request.initialize(message, null, null,new FakeTransactionService(), TEMP_TABLE_STORE, workContext, null);
+ request.initialize(message, BufferManagerFactory.getStandaloneBufferManager(), null,new FakeTransactionService(), TEMP_TABLE_STORE, workContext, null);
request.initMetadata();
request.setAuthorizationValidator(new DataRoleAuthorizationValidator(true, true, true));
request.validateAccess(command);
Modified: branches/7.4.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -185,6 +185,7 @@
newSession.setApplicationName(applicationName);
newSession.setClientHostName(properties.getProperty(TeiidURL.CONNECTION.CLIENT_HOSTNAME));
newSession.setIPAddress(properties.getProperty(TeiidURL.CONNECTION.CLIENT_IP_ADDRESS));
+ newSession.setClientHardwareAddress(properties.getProperty(TeiidURL.CONNECTION.CLIENT_MAC));
newSession.setSecurityDomain(securityDomain);
if (vdb != null) {
newSession.setVDBName(vdb.getName());
@@ -195,7 +196,7 @@
newSession.setLoginContext(loginContext);
newSession.setSecurityContext(securityContext);
newSession.setVdb(vdb);
- LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon successful for \"", userName, "\" - created SessionID \"", newSession.getSessionToken().getSessionID(), "\"" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon successful, created", newSession }); //$NON-NLS-1$
this.sessionCache.put(newSession.getSessionId(), newSession);
return newSession;
}
Modified: branches/7.4.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -118,7 +118,6 @@
this.loginContext.login();
this.userName = baseUsername+AT+domain;
this.securitydomain = domain;
- LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon successful for \"", username, "\""}); //$NON-NLS-1$ //$NON-NLS-2$
return;
} catch (LoginException e) {
LogManager.logDetail(LogConstants.CTX_SECURITY,e, e.getMessage());
Modified: branches/7.4.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2011-05-24 20:46:38 UTC (rev 3194)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2011-05-25 02:55:47 UTC (rev 3195)
@@ -60,7 +60,7 @@
public LogonResult logon(Properties connProps) throws LogonException,
ComponentNotFoundException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
- SessionToken oldToken = workContext.getSessionToken();
+ String oldSessionId = workContext.getSessionId();
String applicationName = connProps.getProperty(TeiidURL.CONNECTION.APP_NAME);
// user may be null if using trustedToken to log on
String user = connProps.getProperty(TeiidURL.CONNECTION.USER_NAME, CoreConstants.DEFAULT_ANON_USERNAME);
@@ -78,9 +78,9 @@
if (DQPWorkContext.getWorkContext().getClientAddress() == null) {
sessionInfo.setEmbedded(true);
}
- if (oldToken != null) {
+ if (oldSessionId != null) {
try {
- this.service.closeSession(oldToken.getSessionID());
+ this.service.closeSession(oldSessionId);
} catch (InvalidSessionException e) {
}
}
13 years, 7 months
teiid SVN: r3194 - in branches/7.4.x/engine/src: test/java/org/teiid/query/optimizer and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-05-24 16:46:38 -0400 (Tue, 24 May 2011)
New Revision: 3194
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
Log:
TEIID-1603 fix for invalid rewrite of <> ANY
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-05-24 14:04:16 UTC (rev 3193)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-05-24 20:46:38 UTC (rev 3194)
@@ -1589,26 +1589,29 @@
*/
private Criteria rewriteCriteria(SubqueryCompareCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
- if (criteria.getCommand().getProcessorPlan() == null && criteria.getPredicateQuantifier() != SubqueryCompareCriteria.ALL) {
- if (criteria.getOperator() == CompareCriteria.EQ || criteria.getOperator() == CompareCriteria.NE) {
+ if (criteria.getCommand().getProcessorPlan() == null) {
+ if ((criteria.getOperator() == CompareCriteria.EQ && criteria.getPredicateQuantifier() != SubqueryCompareCriteria.ALL)
+ || (criteria.getOperator() == CompareCriteria.NE && criteria.getPredicateQuantifier() == SubqueryCompareCriteria.ALL)) {
SubquerySetCriteria result = new SubquerySetCriteria(criteria.getLeftExpression(), criteria.getCommand());
result.setNegated(criteria.getOperator() == CompareCriteria.NE);
return rewriteCriteria(result);
}
- CompareCriteria cc = new CompareCriteria();
- cc.setLeftExpression(criteria.getLeftExpression());
- Query q = createInlineViewQuery(new GroupSymbol("X"), criteria.getCommand(), metadata, criteria.getCommand().getProjectedSymbols()); //$NON-NLS-1$
- SingleElementSymbol ses = q.getProjectedSymbols().get(0);
- Expression expr = SymbolMap.getExpression(ses);
- q.getSelect().clearSymbols();
- AggregateSymbol.Type type = Type.MAX;
- if (criteria.getOperator() == CompareCriteria.GT || criteria.getOperator() == CompareCriteria.GE) {
- type = Type.MIN;
+ if (criteria.getPredicateQuantifier() != SubqueryCompareCriteria.ALL && criteria.getOperator() != CompareCriteria.EQ && criteria.getOperator() != CompareCriteria.NE) {
+ CompareCriteria cc = new CompareCriteria();
+ cc.setLeftExpression(criteria.getLeftExpression());
+ Query q = createInlineViewQuery(new GroupSymbol("X"), criteria.getCommand(), metadata, criteria.getCommand().getProjectedSymbols()); //$NON-NLS-1$
+ SingleElementSymbol ses = q.getProjectedSymbols().get(0);
+ Expression expr = SymbolMap.getExpression(ses);
+ q.getSelect().clearSymbols();
+ AggregateSymbol.Type type = Type.MAX;
+ if (criteria.getOperator() == CompareCriteria.GT || criteria.getOperator() == CompareCriteria.GE) {
+ type = Type.MIN;
+ }
+ q.getSelect().addSymbol(new AggregateSymbol(ses.getName(), type.name(), false, expr));
+ cc.setRightExpression(new ScalarSubquery(q));
+ cc.setOperator(criteria.getOperator());
+ return rewriteCriteria(cc);
}
- q.getSelect().addSymbol(new AggregateSymbol(ses.getName(), type.name(), false, expr));
- cc.setRightExpression(new ScalarSubquery(q));
- cc.setOperator(criteria.getOperator());
- return rewriteCriteria(cc);
}
Expression leftExpr = rewriteExpressionDirect(criteria.getLeftExpression());
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2011-05-24 14:04:16 UTC (rev 3193)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2011-05-24 20:46:38 UTC (rev 3194)
@@ -836,6 +836,22 @@
TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where pm3.g1.e2 = all (select e2 FROM pm1.g1 where pm3.g1.e1 = e1)", "SELECT e1 FROM pm3.g1 WHERE pm3.g1.e2 = ALL (SELECT e2 FROM pm1.g1 WHERE e1 = pm3.g1.e1)", RealMetadataFactory.example4());
}
+ @Test public void testRewriteSubqueryCompare() throws Exception {
+ TestQueryRewriter.helpTestRewriteCommand("select e1 from pm1.g1 where e1 <> ANY (select e1 from pm1.g1)", "SELECT e1 FROM pm1.g1 WHERE e1 <> SOME (SELECT e1 FROM pm1.g1)", RealMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRewriteSubqueryCompare1() throws Exception {
+ TestQueryRewriter.helpTestRewriteCommand("select e1 from pm1.g1 where e1 <> ALL (select e1 from pm1.g1)", "SELECT e1 FROM pm1.g1 WHERE e1 NOT IN (SELECT e1 FROM pm1.g1)", RealMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRewriteSubqueryCompare2() throws Exception {
+ TestQueryRewriter.helpTestRewriteCommand("select e1 from pm1.g1 where e1 = ANY (select e1 from pm1.g1)", "SELECT e1 FROM pm1.g1 WHERE e1 IN (SELECT e1 FROM pm1.g1)", RealMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRewriteSubqueryCompare3() throws Exception {
+ TestQueryRewriter.helpTestRewriteCommand("select e1 from pm1.g1 where e1 = ALL (select e1 from pm1.g1)", "SELECT e1 FROM pm1.g1 WHERE e1 = ALL (SELECT e1 FROM pm1.g1)", RealMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
@Test public void testSubqueryExpressionJoin() throws Exception {
System.setProperty(RuleMergeCriteria.UNNEST_DEFAULT, Boolean.TRUE.toString());
TestQueryRewriter.helpTestRewriteCommand("Select e1 from pm3.g1 where pm3.g1.e2 < (Select max(e2) from pm2.g2 where e1 = pm3.g1.e1 having convert(min(e2), string) > pm3.g1.e1)", "SELECT e1 FROM pm3.g1, (SELECT MAX(e2) AS MAX, e1, MIN(e2) AS MIN FROM pm2.g2 GROUP BY e1) AS X__1 WHERE (convert(X__1.MIN, string) > pm3.g1.e1) AND (pm3.g1.e2 < X__1.MAX) AND (pm3.g1.e1 = X__1.e1)", RealMetadataFactory.example4());
13 years, 7 months
teiid SVN: r3193 - branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-05-24 10:04:16 -0400 (Tue, 24 May 2011)
New Revision: 3193
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
Log:
TEIID-1601 adding the translator instance name as a prefix to translator exceptions
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2011-05-24 13:48:27 UTC (rev 3192)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2011-05-24 14:04:16 UTC (rev 3193)
@@ -409,7 +409,7 @@
if (exception.getCause() instanceof TeiidProcessingException) {
throw (TeiidProcessingException)exception.getCause();
}
- throw new TeiidProcessingException(exception);
+ throw new TeiidProcessingException(exception, this.getConnectorName() + ": " + exception.getMessage()); //$NON-NLS-1$
}
void receiveResults(AtomicResultsMessage response) {
13 years, 7 months
teiid SVN: r3192 - in branches/7.4.x/engine/src: test/java/org/teiid/query/resolver and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-05-24 09:48:27 -0400 (Tue, 24 May 2011)
New Revision: 3192
Modified:
branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties
branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java
branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
Log:
TEIID-1597 minor update to the exception message to cover both tables and procedures
Modified: branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties 2011-05-24 02:00:12 UTC (rev 3191)
+++ branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties 2011-05-24 13:48:27 UTC (rev 3192)
@@ -697,7 +697,7 @@
XMLQueryResolver.xml_only_valid_alone=If any symbol in SELECT clause is ''xml'' or group.''xml'' , then no other element is allowed.
ResolveVariablesVisitor.datatype_for_the_expression_not_resolvable=The datatype for the expression was not resolvable.
TempTableResolver.unqualified_name_required=Cannot create temporary table "{0}". Local temporary tables must be created with unqualified names.
-TempTableResolver.table_already_exists=Cannot create temporary table "{0}". A schema entry with the same name already exists.
+TempTableResolver.table_already_exists=Cannot create temporary table "{0}". An object with the same name already exists.
ValidationVisitor.drop_of_nontemptable=Cannot drop a non temporary table "{0}".
ValidationVisitor.orderby_expression_xml=XML queries cannot order by an expression.
ValidationVisitor.text_table_invalid_width=For a fixed width text table, all columns must have width set.
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java 2011-05-24 02:00:12 UTC (rev 3191)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java 2011-05-24 13:48:27 UTC (rev 3192)
@@ -1389,7 +1389,7 @@
String userUpdateStr = "UPDATE vm1.g1 SET e1='x'"; //$NON-NLS-1$
- helpFailUpdateProcedure(proc.toString(), userUpdateStr, Table.TriggerEvent.UPDATE, "Cannot create temporary table \"loopCursor\". A table with the same name already exists."); //$NON-NLS-1$
+ helpFailUpdateProcedure(proc.toString(), userUpdateStr, Table.TriggerEvent.UPDATE, "Cannot create temporary table \"loopCursor\". An object with the same name already exists."); //$NON-NLS-1$
}
@Test public void testProcedureCreateDrop() {
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-05-24 02:00:12 UTC (rev 3191)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2011-05-24 13:48:27 UTC (rev 3192)
@@ -2352,7 +2352,7 @@
@Test public void testCreateAlreadyExists() {
String sql = "CREATE LOCAL TEMPORARY TABLE g1 (column1 string)"; //$NON-NLS-1$
- helpResolveException(sql, "Cannot create temporary table \"g1\". A table with the same name already exists."); //$NON-NLS-1$
+ helpResolveException(sql, "Cannot create temporary table \"g1\". An object with the same name already exists."); //$NON-NLS-1$
}
@Test public void testCreateImplicitName() {
@@ -2362,7 +2362,7 @@
}
@Test public void testCreateInProc() throws Exception{
- helpResolveException("CREATE VIRTUAL PROCEDURE BEGIN create local temporary table g1(c1 string); end", "Cannot create temporary table \"g1\". A table with the same name already exists.");//$NON-NLS-1$ //$NON-NLS-2$
+ helpResolveException("CREATE VIRTUAL PROCEDURE BEGIN create local temporary table g1(c1 string); end", "Cannot create temporary table \"g1\". An object with the same name already exists.");//$NON-NLS-1$ //$NON-NLS-2$
}
//this was the old virt.agg procedure. It was defined in such a way that relied on the scope leak of #temp
13 years, 7 months
teiid SVN: r3191 - in branches/7.4.x: jboss-integration/src/main/java/org/teiid/jboss/deployers and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-05-23 22:00:12 -0400 (Mon, 23 May 2011)
New Revision: 3191
Modified:
branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/events/jboss/JGroupsEventDistributor.java
branches/7.4.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
Log:
TEIID-1592 changes to ensure that events are distributed correctly
Modified: branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/events/jboss/JGroupsEventDistributor.java
===================================================================
--- branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/events/jboss/JGroupsEventDistributor.java 2011-05-24 00:42:29 UTC (rev 3190)
+++ branches/7.4.x/cache-jbosscache/src/main/java/org/teiid/events/jboss/JGroupsEventDistributor.java 2011-05-24 02:00:12 UTC (rev 3191)
@@ -117,7 +117,9 @@
}
channel = this.channelFactory.createMultiplexerChannel(this.multiplexerStack, "teiid-events"); //$NON-NLS-1$
channel.connect(this.clusterName);
-
+ if (channel.getView() != null) {
+ viewAccepted(channel.getView());
+ }
proxyEventDistributor = (EventDistributor) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {EventDistributor.class}, new ProxyHandler());
//wrap the local in a proxy to prevent unintended methods from being called
rpcDispatcher = new RpcDispatcher(channel, this, this, Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {EventDistributor.class}, new InvocationHandler() {
Modified: branches/7.4.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/7.4.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-05-24 00:42:29 UTC (rev 3190)
+++ branches/7.4.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-05-24 02:00:12 UTC (rev 3191)
@@ -22,6 +22,7 @@
package org.teiid.jboss.deployers;
import java.io.Serializable;
+import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@@ -151,6 +152,7 @@
private String eventDistributorName;
private transient EventDistributor eventDistributor;
+ private transient EventDistributor eventDistributorProxy;
public RuntimeEngineDeployer() {
// TODO: this does not belong here
@@ -183,6 +185,18 @@
this.dqpCore.setMetadataRepository(this.vdbRepository.getMetadataRepository());
this.dqpCore.setEventDistributor(this.eventDistributor);
this.dqpCore.start(this);
+ this.eventDistributorProxy = (EventDistributor)Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {EventDistributor.class}, new InvocationHandler() {
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ method.invoke(RuntimeEngineDeployer.this, args);
+ if (eventDistributor != null) {
+ method.invoke(eventDistributor, args);
+ }
+ return null;
+ }
+ });
// create the necessary services
createClientServices();
@@ -684,7 +698,7 @@
}
long ts = System.currentTimeMillis();
for (String name:objectNames) {
- Table table = s.getTables().get(name);
+ Table table = s.getTables().get(name.toUpperCase());
if (table == null) {
continue;
}
@@ -799,10 +813,7 @@
@Override
public EventDistributor getEventDistributor() {
- if (this.eventDistributor != null) {
- return eventDistributor;
- }
- return this;
+ return this.eventDistributorProxy;
}
}
13 years, 7 months
teiid SVN: r3190 - branches/7.4.x/engine/src/main/resources/org/teiid/query.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-05-23 20:42:29 -0400 (Mon, 23 May 2011)
New Revision: 3190
Modified:
branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties
Log:
TEIID-1597 minor update to the exception message to cover both tables and procedures
Modified: branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties 2011-05-23 19:33:57 UTC (rev 3189)
+++ branches/7.4.x/engine/src/main/resources/org/teiid/query/i18n.properties 2011-05-24 00:42:29 UTC (rev 3190)
@@ -697,7 +697,7 @@
XMLQueryResolver.xml_only_valid_alone=If any symbol in SELECT clause is ''xml'' or group.''xml'' , then no other element is allowed.
ResolveVariablesVisitor.datatype_for_the_expression_not_resolvable=The datatype for the expression was not resolvable.
TempTableResolver.unqualified_name_required=Cannot create temporary table "{0}". Local temporary tables must be created with unqualified names.
-TempTableResolver.table_already_exists=Cannot create temporary table "{0}". A table with the same name already exists.
+TempTableResolver.table_already_exists=Cannot create temporary table "{0}". A schema entry with the same name already exists.
ValidationVisitor.drop_of_nontemptable=Cannot drop a non temporary table "{0}".
ValidationVisitor.orderby_expression_xml=XML queries cannot order by an expression.
ValidationVisitor.text_table_invalid_width=For a fixed width text table, all columns must have width set.
13 years, 7 months
teiid SVN: r3189 - in branches/7.4.x: jboss-integration/src/main/java/org/teiid/jboss/deployers and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-05-23 15:33:57 -0400 (Mon, 23 May 2011)
New Revision: 3189
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
branches/7.4.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
Log:
TEIID-1592 changes to ensure that the metadata repository is correctly initialized
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2011-05-23 19:32:30 UTC (rev 3188)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DQPConfiguration.java 2011-05-23 19:33:57 UTC (rev 3189)
@@ -25,7 +25,6 @@
import org.teiid.cache.CacheConfiguration;
import org.teiid.client.RequestMessage;
import org.teiid.core.util.ApplicationInfo;
-import org.teiid.metadata.MetadataRepository;
public class DQPConfiguration{
@@ -228,10 +227,6 @@
this.authorizationValidator = authorizationValidator;
}
- public MetadataRepository getMetadataRepository() {
- return null;
- }
-
public CacheConfiguration getPreparedPlanCacheConfig() {
return preparedPlanCacheConfig;
}
Modified: branches/7.4.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/7.4.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-05-23 19:32:30 UTC (rev 3188)
+++ branches/7.4.x/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-05-23 19:33:57 UTC (rev 3189)
@@ -105,7 +105,6 @@
import org.teiid.metadata.AbstractMetadataRecord;
import org.teiid.metadata.Column;
import org.teiid.metadata.ColumnStats;
-import org.teiid.metadata.MetadataRepository;
import org.teiid.metadata.Procedure;
import org.teiid.metadata.Schema;
import org.teiid.metadata.Table;
@@ -181,6 +180,7 @@
LogManager.logDetail(LogConstants.CTX_RUNTIME, ne, IntegrationPlugin.Util.getString("jndi_failed", new Date(System.currentTimeMillis()).toString())); //$NON-NLS-1$
}
}
+ this.dqpCore.setMetadataRepository(this.vdbRepository.getMetadataRepository());
this.dqpCore.setEventDistributor(this.eventDistributor);
this.dqpCore.start(this);
// create the necessary services
@@ -805,8 +805,4 @@
return this;
}
- @Override
- public MetadataRepository getMetadataRepository() {
- return this.vdbRepository.getMetadataRepository();
- }
}
13 years, 7 months