Author: shawkins
Date: 2010-06-10 00:01:14 -0400 (Thu, 10 Jun 2010)
New Revision: 2212
Added:
trunk/api/src/main/java/org/teiid/translator/WSConnection.java
trunk/connectors/connector-file/src/main/resources/org/
trunk/connectors/connector-file/src/main/resources/org/teiid/
trunk/connectors/connector-file/src/main/resources/org/teiid/resource/
trunk/connectors/connector-file/src/main/resources/org/teiid/resource/adapter/
trunk/connectors/connector-file/src/main/resources/org/teiid/resource/adapter/file/
trunk/connectors/connector-file/src/main/resources/org/teiid/resource/adapter/file/i18n.properties
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
trunk/connectors/connector-ws/src/main/resources/org/
trunk/connectors/connector-ws/src/main/resources/org/teiid/
trunk/connectors/connector-ws/src/main/resources/org/teiid/resource/
trunk/connectors/connector-ws/src/main/resources/org/teiid/resource/adapter/
trunk/connectors/connector-ws/src/main/resources/org/teiid/resource/adapter/ws/
trunk/connectors/connector-ws/src/main/resources/org/teiid/resource/adapter/ws/i18n.properties
trunk/connectors/translator-ws/
trunk/connectors/translator-ws/pom.xml
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
trunk/connectors/translator-ws/src/main/resources/org/teiid/translator/ws/
trunk/connectors/translator-ws/src/main/resources/org/teiid/translator/ws/i18n.properties
trunk/documentation/client-developers-guide/
trunk/documentation/client-developers-guide/pom.xml
trunk/documentation/client-developers-guide/src/
trunk/documentation/client-developers-guide/src/main/
trunk/documentation/client-developers-guide/src/main/docbook/
trunk/documentation/client-developers-guide/src/main/docbook/en-US/
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/ssl.xml
trunk/engine/src/main/java/org/teiid/query/sql/symbol/QueryString.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStuff.java
trunk/test-integration/db/src/test/java/com/
Removed:
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnection.java
trunk/connectors/translator-ws/pom.xml
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/SAXFilterProvider.java
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/XMLExecutionFactory.java
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/XMLProcedureExecution.java
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/xml/
trunk/connectors/translator-ws/src/main/resources/org/teiid/translator/xml/
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/MockQueryPreprocessor.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/ProxyObjectFactory.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestCartesianCriteriaGenerator.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestCriteriaDesc.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestElementCollector.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestExecutionInfo.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestOutputXPathDesc.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestParameterDescriptor.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestQueryAnalyzer.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestXMLCapabilities.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestXMLReaderFactory.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestXPathSplitter.java
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/file/
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/streaming/
trunk/connectors/translator-ws/src/test/resources/BookCollection.xml
trunk/connectors/translator-ws/src/test/resources/cis.vdb
trunk/connectors/translator-ws/src/test/resources/documents/
trunk/connectors/translator-ws/src/test/resources/xmltest.vdb
trunk/connectors/translator-xml/
Modified:
trunk/api/src/main/java/org/teiid/language/SQLConstants.java
trunk/api/src/main/java/org/teiid/logging/LogConstants.java
trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java
trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
trunk/build/assembly/jboss-container/dist.xml
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/portfolio-dynamic-vdb.xml
trunk/client/src/main/java/org/teiid/client/util/ExceptionHolder.java
trunk/client/src/main/java/org/teiid/net/socket/SocketUtil.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectInputStream.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java
trunk/common-core/src/main/java/org/teiid/core/TeiidException.java
trunk/connectors/connector-file/src/main/java/org/teiid/resource/adapter/file/FileManagedConnectionFactory.java
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml
trunk/connectors/pom.xml
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/LocateFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
trunk/connectors/translator-ws/src/main/resources/META-INF/jboss-beans.xml
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataStore.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLAttributes.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLForest.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLSerialize.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/main/java/org/teiid/query/xquery/saxon/PathMapFilter.java
trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java
trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestOrderByRewrite.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
Log:
TEIID-1114 converting translator-xml to translator-ws with a flexible invoke procedure.
anding xml name escaping and more validation. also minor cleanups to javadocs
Modified: trunk/api/src/main/java/org/teiid/language/SQLConstants.java
===================================================================
--- trunk/api/src/main/java/org/teiid/language/SQLConstants.java 2010-06-09 16:37:31 UTC
(rev 2211)
+++ trunk/api/src/main/java/org/teiid/language/SQLConstants.java 2010-06-10 04:01:14 UTC
(rev 2212)
@@ -82,6 +82,8 @@
public static final String RETURNING = "RETURNING"; //$NON-NLS-1$
public static final String SEQUENCE = "SEQUENCE"; //$NON-NLS-1$
public static final String EMPTY = "EMPTY"; //$NON-NLS-1$
+
+ public static final String QUERYSTRING = "QUERYSTRING"; //$NON-NLS-1$
}
public interface Reserved {
Modified: trunk/api/src/main/java/org/teiid/logging/LogConstants.java
===================================================================
--- trunk/api/src/main/java/org/teiid/logging/LogConstants.java 2010-06-09 16:37:31 UTC
(rev 2211)
+++ trunk/api/src/main/java/org/teiid/logging/LogConstants.java 2010-06-10 04:01:14 UTC
(rev 2212)
@@ -41,4 +41,6 @@
public static final String CTX_QUERY_RESOLVER = CTX_QUERY_PLANNER +
".RESOLVER"; //$NON-NLS-1$
public static final String CTX_XML_PLANNER = CTX_QUERY_PLANNER +
".XML_PLANNER"; //$NON-NLS-1$
public static final String CTX_XML_PLAN = CTX_DQP + ".XML_PLAN";
//$NON-NLS-1$
+
+ public static final String CTX_WS = LogConstants.CTX_CONNECTOR + ".WS";
//$NON-NLS-1$
}
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java 2010-06-09 16:37:31
UTC (rev 2211)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionContext.java 2010-06-10 04:01:14
UTC (rev 2212)
@@ -135,14 +135,14 @@
/**
* Get a item that has been placed previously from cache. If no such object then a null
will be returned.
- * The item is placed in {@link CacheScope.REQUEST} scope.
+ * The item is placed in {@link CacheScope#REQUEST} scope.
* @param key
* @return
*/
Object get(Object key);
/**
- * Place a item in the Cache in {@link CacheScope.REQUEST} scope.
+ * Place a item in the Cache in {@link CacheScope#REQUEST} scope.
* @param key
* @param value
*/
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2010-06-09 16:37:31
UTC (rev 2211)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2010-06-10 04:01:14
UTC (rev 2212)
@@ -162,6 +162,7 @@
} catch (ResourceException e) {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, e, "Error closing");
//$NON-NLS-1$
}
+ return;
}
throw new AssertionError("A connection was created, but no implementation provided
for closeConnection"); //$NON-NLS-1$
}
Added: trunk/api/src/main/java/org/teiid/translator/WSConnection.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/WSConnection.java
(rev 0)
+++ trunk/api/src/main/java/org/teiid/translator/WSConnection.java 2010-06-10 04:01:14 UTC
(rev 2212)
@@ -0,0 +1,78 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import javax.resource.cci.Connection;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+
+/**
+ * Simple {@link Connection} interface for web services
+ */
+public interface WSConnection extends Connection {
+
+ <T> Dispatch<T> createDispatch(String binding, String endpoint,
Class<T> type, Service.Mode mode);
+
+ public static class Util {
+
+ public static String appendQueryString(String endpoint, String param) {
+ return endpoint + (endpoint.indexOf('?') >= 0?'&':'?')
+ param;
+ }
+
+ public static String httpURLEncode(String s) {
+ try {
+ return URLEncoder.encode(s, "UTF-8").replaceAll("\\+",
"%20"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void closeSource(final Source source) {
+ if (!(source instanceof StreamSource)) {
+ return;
+ }
+
+ StreamSource stream = (StreamSource)source;
+ try {
+ if (stream.getInputStream() != null) {
+ stream.getInputStream().close();
+ }
+ } catch (IOException e) {
+ }
+ try {
+ if (stream.getReader() != null) {
+ stream.getReader().close();
+ }
+ } catch (IOException e) {
+ }
+ }
+
+ }
+
+}
Property changes on: trunk/api/src/main/java/org/teiid/translator/WSConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/build/assembly/jboss-container/dist.xml
===================================================================
--- trunk/build/assembly/jboss-container/dist.xml 2010-06-09 16:37:31 UTC (rev 2211)
+++ trunk/build/assembly/jboss-container/dist.xml 2010-06-10 04:01:14 UTC (rev 2212)
@@ -90,7 +90,7 @@
<include>org.jboss.teiid.connectors:translator-salesforce</include>
<include>org.jboss.teiid.connectors:connector-salesforce:rar</include>
<include>org.jboss.teiid.connectors:connector-ws:rar</include>
- <include>org.jboss.teiid.connectors:translator-xml</include>
+ <include>org.jboss.teiid.connectors:translator-ws</include>
</includes>
<binaries>
Modified:
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/portfolio-dynamic-vdb.xml
===================================================================
---
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/portfolio-dynamic-vdb.xml 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/build/kits/jboss-container/teiid-examples/dynamicvdb-portfolio/portfolio-dynamic-vdb.xml 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<vdb name="DynamicPortfolio" version="1">
- <description>A VDB to test transactions</description>
+ <description>A Dynamic</description>
<!--
Setting to use connector supplied metadata. Can be "true" or
"cached".
Modified: trunk/client/src/main/java/org/teiid/client/util/ExceptionHolder.java
===================================================================
--- trunk/client/src/main/java/org/teiid/client/util/ExceptionHolder.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/client/src/main/java/org/teiid/client/util/ExceptionHolder.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -148,7 +148,7 @@
Throwable result = null;
for (String className : classNames) {
try {
- result = (Throwable)ReflectionHelper.create(className, args,
Thread.currentThread().getContextClassLoader());
+ result = (Throwable)ReflectionHelper.create(className, args,
ExceptionHolder.class.getClassLoader());
result.setStackTrace(stackTrace);
break;
} catch (TeiidException e1) {
@@ -177,7 +177,7 @@
// only for top level we would have the contents as not null.
if (contents != null) {
ByteArrayInputStream bais = new ByteArrayInputStream(contents);
- ObjectInputStream ois = new ObjectInputStreamWithClassloader(bais,
Thread.currentThread().getContextClassLoader());
+ ObjectInputStream ois = new ObjectInputStreamWithClassloader(bais,
ExceptionHolder.class.getClassLoader());
try {
return (Throwable)ois.readObject();
} catch (ClassNotFoundException e) {
Modified: trunk/client/src/main/java/org/teiid/net/socket/SocketUtil.java
===================================================================
--- trunk/client/src/main/java/org/teiid/net/socket/SocketUtil.java 2010-06-09 16:37:31
UTC (rev 2211)
+++ trunk/client/src/main/java/org/teiid/net/socket/SocketUtil.java 2010-06-10 04:01:14
UTC (rev 2212)
@@ -208,7 +208,7 @@
public static KeyStore loadKeyStore(String name, String password, String type) throws
IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException {
// Check in the classpath
- InputStream stream =
Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
+ InputStream stream =
SocketUtil.class.getClassLoader().getResourceAsStream(name);
if (stream == null) {
try {
stream = new FileInputStream(name);
Modified:
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectInputStream.java
===================================================================
---
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectInputStream.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectInputStream.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -75,7 +75,7 @@
if (classLoader == null) {
clazz = Class.forName(
className, true,
- Thread.currentThread().getContextClassLoader());
+ CompactObjectInputStream.class.getClassLoader());
} else {
clazz = Class.forName(className, true, classLoader);
}
Modified:
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java
===================================================================
---
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectEncoderOutputStream.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -33,8 +33,7 @@
/**
- * An {@link ObjectOutput} which is interoperable with {@link ObjectDecoder}
- * and {@link ObjectDecoderInputStream}.
+ * An {@link ObjectOutput} which is interoperable with {@link ObjectDecoderInputStream}.
*
* @author The Netty Project (netty-dev(a)lists.jboss.org)
* @author Trustin Lee (tlee(a)redhat.com)
Modified: trunk/common-core/src/main/java/org/teiid/core/TeiidException.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/TeiidException.java 2010-06-09 16:37:31
UTC (rev 2211)
+++ trunk/common-core/src/main/java/org/teiid/core/TeiidException.java 2010-06-10 04:01:14
UTC (rev 2212)
@@ -154,7 +154,8 @@
* Get the exception which is linked to this exception.
*
* @return The linked exception
- * @deprecated - {@see #getCause()}
+ * @see #getCause()
+ * @deprecated
*/
public Throwable getChild() {
return super.getCause();
Modified:
trunk/connectors/connector-file/src/main/java/org/teiid/resource/adapter/file/FileManagedConnectionFactory.java
===================================================================
---
trunk/connectors/connector-file/src/main/java/org/teiid/resource/adapter/file/FileManagedConnectionFactory.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/connectors/connector-file/src/main/java/org/teiid/resource/adapter/file/FileManagedConnectionFactory.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -24,6 +24,7 @@
import javax.resource.ResourceException;
import javax.resource.spi.InvalidPropertyException;
+import org.teiid.core.BundleUtil;
import org.teiid.resource.spi.BasicConnection;
import org.teiid.resource.spi.BasicConnectionFactory;
import org.teiid.resource.spi.BasicManagedConnectionFactory;
@@ -31,13 +32,14 @@
public class FileManagedConnectionFactory extends BasicManagedConnectionFactory{
private static final long serialVersionUID = -1495488034205703625L;
+ public static final BundleUtil UTIL =
BundleUtil.getBundleUtil(FileManagedConnectionFactory.class);
private String parentDirectory;
@Override
public Object createConnectionFactory() throws ResourceException {
if (this.parentDirectory == null) {
- throw new InvalidPropertyException("ParentDirectory is not set");
+ throw new
InvalidPropertyException(UTIL.getString("parentdirectory_not_set"));
//$NON-NLS-1$
}
return new BasicConnectionFactory() {
Added:
trunk/connectors/connector-file/src/main/resources/org/teiid/resource/adapter/file/i18n.properties
===================================================================
---
trunk/connectors/connector-file/src/main/resources/org/teiid/resource/adapter/file/i18n.properties
(rev 0)
+++
trunk/connectors/connector-file/src/main/resources/org/teiid/resource/adapter/file/i18n.properties 2010-06-10
04:01:14 UTC (rev 2212)
@@ -0,0 +1,23 @@
+#
+# 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.
+#
+
+parentdirectory_not_set=ParentDirectory is not set
\ No newline at end of file
Property changes on:
trunk/connectors/connector-file/src/main/resources/org/teiid/resource/adapter/file/i18n.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnection.java
===================================================================
---
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnection.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnection.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,203 +0,0 @@
-package org.teiid.resource.adapter.ws;
-
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Future;
-
-import javax.resource.ResourceException;
-import javax.xml.namespace.QName;
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Binding;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.Dispatch;
-import javax.xml.ws.EndpointReference;
-import javax.xml.ws.Response;
-import javax.xml.ws.Service;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.http.HTTPBinding;
-import javax.xml.ws.soap.SOAPBinding;
-
-import org.jboss.ws.core.ConfigProvider;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.resource.adapter.ws.WSManagedConnectionFactory.InvocationType;
-import org.teiid.resource.spi.BasicConnection;
-
-public class WSConnection extends BasicConnection implements Dispatch<Source>{
- private static QName svcQname = new QName("http://teiid.org",
"teiid"); //$NON-NLS-1$ //$NON-NLS-2$
- private static QName portQName = new QName("http://teiid.org",
"teiid");//$NON-NLS-1$ //$NON-NLS-2$
-
- private Dispatch<Source> delegate;
- private WSManagedConnectionFactory mcf;
-
- public WSConnection(WSManagedConnectionFactory mcf) {
- this.mcf = mcf;
- createDelegate();
- }
-
- private void createDelegate() {
- if (mcf.getInvocationType() == WSManagedConnectionFactory.InvocationType.HTTP_GET) {
- this.delegate = createHTTPDispatch("GET"); //$NON-NLS-1$
- }
- else if (mcf.getInvocationType() ==
WSManagedConnectionFactory.InvocationType.HTTP_POST) {
- this.delegate = createHTTPDispatch("POST"); //$NON-NLS-1$
- } else {
- this.delegate = createSOAPDispatch();
- }
- }
-
- private Dispatch<Source> createHTTPDispatch(String requestMethod){
- Service svc = Service.create(svcQname);
- svc.addPort(portQName, HTTPBinding.HTTP_BINDING, mcf.getEndPoint());
-
- Dispatch<Source> dispatch = svc.createDispatch(portQName, Source.class,
Service.Mode.PAYLOAD);
- dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, requestMethod);
- if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.HTTPBasic){
- dispatch.getRequestContext().put(Dispatch.USERNAME_PROPERTY, mcf.getAuthUserName());
- dispatch.getRequestContext().put(Dispatch.PASSWORD_PROPERTY, mcf.getAuthPassword());
- }
-
- Map<String, List<String>> httpHeaders = (Map<String,
List<String>>)dispatch.getRequestContext().get(MessageContext.HTTP_REQUEST_HEADERS);
- if(httpHeaders == null) {
- httpHeaders = new HashMap<String, List<String>>();
- }
- httpHeaders.put("Content-Type",
Collections.singletonList("text/xml; charset=utf-8"));//$NON-NLS-1$
//$NON-NLS-2$
- httpHeaders.put("User-Agent", Collections.singletonList("Teiid
Server"));//$NON-NLS-1$ //$NON-NLS-2$
- dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,
httpHeaders);
-
- return dispatch;
- }
-
- private Dispatch<Source> createSOAPDispatch() {
- Service svc = Service.create(svcQname);
-
- svc.addPort(portQName, mcf.getInvocationType() == InvocationType.SOAP11 ?
SOAPBinding.SOAP11HTTP_BINDING : SOAPBinding.SOAP12HTTP_BINDING, mcf.getEndPoint());
-
- Dispatch<Source> dispatch = svc.createDispatch(portQName, Source.class,
Service.Mode.PAYLOAD);
- if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity) {
- // JBoss WS-Security
- ((ConfigProvider) this.delegate).setSecurityConfig(mcf.getWsSecurityConfigURL());
- ((ConfigProvider) delegate).setConfigName(mcf.getWsSecurityConfigName());
- }
- return dispatch;
- }
-
- public Binding getBinding() {
- return delegate.getBinding();
- }
-
- public EndpointReference getEndpointReference() {
- return delegate.getEndpointReference();
- }
-
- public <T extends EndpointReference> T getEndpointReference(Class<T> clazz)
{
- return delegate.getEndpointReference(clazz);
- }
-
- public Map<String, Object> getRequestContext() {
- return delegate.getRequestContext();
- }
-
- public Map<String, Object> getResponseContext() {
- return delegate.getResponseContext();
- }
-
-
- /**
- * NOTE: the source msg from the teiid translator going to be SOAP. If execution is
different from
- * soap then fix it now.
- */
- @Override
- public Source invoke(Source msg) {
-
- String xmlPayload = null;
- Map<String, Object> map =
(Map)getRequestContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
- if (map != null) {
- xmlPayload = (String)map.remove("xml"); //$NON-NLS-1$
- }
-
- if (this.mcf.getInvocationType() == WSManagedConnectionFactory.InvocationType.HTTP_GET)
{
- if (this.mcf.getXMLParamName() != null) {
- if (xmlPayload != null) {
- try {
- getRequestContext().put(MessageContext.QUERY_STRING,
this.mcf.getXMLParamName()+"="+URLEncoder.encode(xmlPayload,
"UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
- } else {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "XML Param specified, but no
request document was generated."); //$NON-NLS-1$
- }
- }
- else if (getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY) == null)
{
-
- String path = (String)getRequestContext().get(MessageContext.PATH_INFO);
- String queryString = (String)getRequestContext().get(MessageContext.QUERY_STRING);
- String url = this.mcf.getEndPoint();
- if (path != null) {
- url = url + "/" + path; //$NON-NLS-1$
- }
- if (queryString != null) {
- url = url + "?" + queryString; //$NON-NLS-1$
- }
- getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
- }
- msg = null;
- }
- else if (this.mcf.getInvocationType() ==
WSManagedConnectionFactory.InvocationType.HTTP_POST) {
- getRequestContext().put(MessageContext.QUERY_STRING, ""); //$NON-NLS-1$
- if (xmlPayload != null) {
- msg = new StreamSource(new StringReader(xmlPayload));
- }
- else {
- msg = null;
- }
- }
- else {
- // JBossWS native adds the null based address property somewhere and results in error
if this
- // is corrected
- if (getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY) == null) {
- getRequestContext().remove(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
- }
- }
-
- if (msg == null) {
- // JBoss Native DispatchImpl throws exception when the source is null
- msg = new StreamSource(new StringReader("<none/>")); //$NON-NLS-1$
- }
- return delegate.invoke(msg);
- }
-
- @Override
- public Future invokeAsync(Source msg, AsyncHandler<Source> handler) {
- return delegate.invokeAsync(msg, handler);
- }
-
- @Override
- public Response<Source> invokeAsync(Source msg) {
- return delegate.invokeAsync(msg);
- }
-
- @Override
- public void invokeOneWay(Source msg) {
- delegate.invokeOneWay(msg);
- }
-
- @Override
- public void close() throws ResourceException {
- this.delegate = null;
- }
-
- @Override
- public void cleanUp() {
- //recreate to ensure the proper state
- //this isn't really a heavy-weight operation
- createDelegate();
- }
-}
Added:
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
===================================================================
---
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
(rev 0)
+++
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -0,0 +1,112 @@
+package org.teiid.resource.adapter.ws;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.resource.ResourceException;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.http.HTTPBinding;
+
+import org.jboss.ws.core.ConfigProvider;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.logging.MessageLevel;
+import org.teiid.resource.spi.BasicConnection;
+import org.teiid.translator.WSConnection;
+
+/**
+ * WebService connection implementation.
+ *
+ * TODO: set a handler chain
+ */
+public class WSConnectionImpl extends BasicConnection implements WSConnection {
+ private static QName svcQname = new QName("http://teiid.org",
"teiid"); //$NON-NLS-1$ //$NON-NLS-2$
+ private static QName portQName = new QName("http://teiid.org",
"teiid");//$NON-NLS-1$ //$NON-NLS-2$
+
+ private WSManagedConnectionFactory mcf;
+
+ public WSConnectionImpl(WSManagedConnectionFactory mcf) {
+ this.mcf = mcf;
+ }
+
+ public <T> Dispatch<T> createDispatch(String binding, String endpoint,
Class<T> type, Mode mode) {
+ Service svc = Service.create(svcQname);
+ if (endpoint != null) {
+ try {
+ new URL(endpoint);
+ //valid url, just use the endpoint
+ } catch (MalformedURLException e) {
+ //otherwise it should be a relative value
+ //but we should still preserve the base path and query string
+ String defaultEndpoint = mcf.getEndPoint();
+ String defaultQueryString = null;
+ String defaultFragment = null;
+ String[] parts = defaultEndpoint.split("\\?", 2); //$NON-NLS-1$
+ defaultEndpoint = parts[0];
+ if (parts.length > 1) {
+ defaultQueryString = parts[1];
+ parts = defaultQueryString.split("#"); //$NON-NLS-1$
+ defaultQueryString = parts[0];
+ if (parts.length > 1) {
+ defaultFragment = parts[1];
+ }
+ }
+ if (endpoint.startsWith("?") || endpoint.startsWith("/")) {
//$NON-NLS-1$ //$NON-NLS-2$
+ endpoint = defaultEndpoint + endpoint;
+ } else {
+ endpoint = defaultEndpoint + "/" + endpoint; //$NON-NLS-1$
+ }
+ if (defaultQueryString != null && defaultQueryString.trim().length() > 0)
{
+ endpoint = WSConnection.Util.appendQueryString(endpoint, defaultQueryString);
+ }
+ if (defaultFragment != null && endpoint.indexOf('#') < 0) {
+ endpoint = endpoint + '#' + defaultFragment;
+ }
+ }
+ } else {
+ endpoint = mcf.getEndPoint();
+ }
+
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_WS, "Creating a dispatch with
endpoint", endpoint); //$NON-NLS-1$
+ }
+
+ svc.addPort(portQName, binding, endpoint);
+
+ Dispatch<T> dispatch = svc.createDispatch(portQName, type, mode);
+
+ if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.HTTPBasic){
+ dispatch.getRequestContext().put(Dispatch.USERNAME_PROPERTY, mcf.getAuthUserName());
+ dispatch.getRequestContext().put(Dispatch.PASSWORD_PROPERTY, mcf.getAuthPassword());
+ }
+
+ if (HTTPBinding.HTTP_BINDING.equals(binding)) {
+ Map<String, List<String>> httpHeaders = (Map<String,
List<String>>)dispatch.getRequestContext().get(MessageContext.HTTP_REQUEST_HEADERS);
+ if(httpHeaders == null) {
+ httpHeaders = new HashMap<String, List<String>>();
+ }
+ httpHeaders.put("Content-Type",
Collections.singletonList("text/xml; charset=utf-8"));//$NON-NLS-1$
//$NON-NLS-2$
+ httpHeaders.put("User-Agent", Collections.singletonList("Teiid
Server"));//$NON-NLS-1$ //$NON-NLS-2$
+ dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS,
httpHeaders);
+ } else if (mcf.getSecurityType() == WSManagedConnectionFactory.SecurityType.WSSecurity)
{
+ // JBoss WS-Security
+ ((ConfigProvider) dispatch).setSecurityConfig(mcf.getWsSecurityConfigURL());
+ ((ConfigProvider) dispatch).setConfigName(mcf.getWsSecurityConfigName());
+ }
+ return dispatch;
+ }
+
+ @Override
+ public void close() throws ResourceException {
+
+ }
+
+}
Property changes on:
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSConnectionImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java
===================================================================
---
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/connectors/connector-ws/src/main/java/org/teiid/resource/adapter/ws/WSManagedConnectionFactory.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -23,6 +23,7 @@
import javax.resource.ResourceException;
+import org.teiid.core.BundleUtil;
import org.teiid.resource.spi.BasicConnection;
import org.teiid.resource.spi.BasicConnectionFactory;
import org.teiid.resource.spi.BasicManagedConnectionFactory;
@@ -30,38 +31,28 @@
public class WSManagedConnectionFactory extends BasicManagedConnectionFactory {
private static final long serialVersionUID = -2998163922934555003L;
+
+ public static final BundleUtil UTIL =
BundleUtil.getBundleUtil(WSManagedConnectionFactory.class);
- public enum InvocationType {HTTP_GET, HTTP_POST, SOAP11, SOAP12};
public enum SecurityType {None,HTTPBasic,WSSecurity}
- private String invocationType = InvocationType.SOAP12.name();
private String endPoint;
-
private String securityType = SecurityType.None.name(); // None, HTTPBasic, WS-Security
private String wsSecurityConfigURL; // path to the "jboss-wsse-client.xml"
file
private String wsSecurityConfigName; // ws-security config name in the above file
private String authPassword; // httpbasic - password
private String authUserName; // httpbasic - username
- private String xmlParamName; // used only in the http get invocation
@Override
- public Object createConnectionFactory() throws ResourceException {
+ public BasicConnectionFactory createConnectionFactory() throws ResourceException {
return new BasicConnectionFactory() {
@Override
public BasicConnection getConnection() throws ResourceException {
- return new WSConnection(WSManagedConnectionFactory.this);
+ return new WSConnectionImpl(WSManagedConnectionFactory.this);
}
};
}
- public InvocationType getInvocationType() {
- return InvocationType.valueOf(invocationType);
- }
-
- public void setInvocationType(String invocationType) {
- this.invocationType = invocationType;
- }
-
public String getAuthPassword() {
return this.authPassword;
}
@@ -110,11 +101,4 @@
this.wsSecurityConfigName = wsSecurityConfigName;
}
- public String getXMLParamName() {
- return xmlParamName;
- }
-
- public void setXMLParamName(String xMLParamName) {
- this.xmlParamName = xMLParamName;
- }
}
Modified: trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml
===================================================================
--- trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml 2010-06-09 16:37:31 UTC
(rev 2211)
+++ trunk/connectors/connector-ws/src/main/rar/META-INF/ra.xml 2010-06-10 04:01:14 UTC
(rev 2212)
@@ -7,7 +7,7 @@
version="1.5">
<vendor-name>Red Hat Middleware LLC</vendor-name>
- <eis-type>Teiid XML SOAP Connector</eis-type>
+ <eis-type>Teiid WS Connector</eis-type>
<resourceadapter-version>1.0</resourceadapter-version>
<license>
<description>
@@ -41,13 +41,6 @@
<managedconnectionfactory-class>org.teiid.resource.adapter.ws.WSManagedConnectionFactory</managedconnectionfactory-class>
<config-property>
- <description>{$display:"Invocation
Type",$description:"Service Invocation type (HTTP or SOAP)",
$allowed="HTTP_GET, HTTP_POST, SOAP11, SOAP12", $required="true",
$defaultValue="SOAP12"}</description>
- <config-property-name>InvocationType</config-property-name>
-
<config-property-type>java.lang.String</config-property-type>
- <config-property-value>SOAP12</config-property-value>
- </config-property>
-
- <config-property>
<description>{$display:"URL, End
Point",$description:"URL for HTTP, Service Endpoint for
SOAP",$required="true"}</description>
<config-property-name>EndPoint</config-property-name>
<config-property-type>java.lang.String</config-property-type>
@@ -83,12 +76,6 @@
<config-property-name>WsSecurityConfigName</config-property-name>
<config-property-type>java.lang.String</config-property-type>
</config-property>
-
- <config-property>
- <description>{$display:"XML Parameter Name",
$description="only required for HTTP_GET with an XML based
request"}</description>
- <config-property-name>XMLParamName</config-property-name>
-
<config-property-type>java.lang.String</config-property-type>
- </config-property>
<connectionfactory-interface>javax.resource.cci.ConnectionFactory</connectionfactory-interface>
<connectionfactory-impl-class>org.teiid.resource.spi.WrappedConnectionFactory</connectionfactory-impl-class>
Added:
trunk/connectors/connector-ws/src/main/resources/org/teiid/resource/adapter/ws/i18n.properties
===================================================================
---
trunk/connectors/connector-ws/src/main/resources/org/teiid/resource/adapter/ws/i18n.properties
(rev 0)
+++
trunk/connectors/connector-ws/src/main/resources/org/teiid/resource/adapter/ws/i18n.properties 2010-06-10
04:01:14 UTC (rev 2212)
@@ -0,0 +1,22 @@
+#
+# 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.
+#
+
Property changes on:
trunk/connectors/connector-ws/src/main/resources/org/teiid/resource/adapter/ws/i18n.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/connectors/pom.xml
===================================================================
--- trunk/connectors/pom.xml 2010-06-09 16:37:31 UTC (rev 2211)
+++ trunk/connectors/pom.xml 2010-06-10 04:01:14 UTC (rev 2212)
@@ -90,11 +90,6 @@
<module>sandbox</module>
- <module>translator-xml</module>
- <!--
- <module>connector-xml-file</module>
- <module>connector-xml-soap</module>
- <module>connector-xml-http</module>
- -->
+ <module>translator-ws</module>
</modules>
</project>
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/LocateFunctionModifier.java
===================================================================
---
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/LocateFunctionModifier.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/LocateFunctionModifier.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -78,8 +78,7 @@
private boolean sourceStringFirst;
/**
- * Constructs a {@link BasicFunctionModifier} object that can be used to
- * translate the scalar function LOCATE() to a source specific scalar
+ * Translates the scalar function LOCATE() to a source specific scalar
* function or expression.
*
* @param langFactory the language factory associated with translation
@@ -89,8 +88,7 @@
}
/**
- * Constructs a {@link BasicFunctionModifier} object that can be used to
- * translate the scalar function LOCATE() to a source specific scalar
+ * Translates the scalar function LOCATE() to a source specific scalar
* function or expression.
*
* @param langFactory the language factory associated with translation
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -164,8 +164,8 @@
Command command = tu.parseCommand("select max(x) from bar");
//$NON-NLS-1$
TranslationHelper.helpTestVisitor("SELECT MAX(cast(bar.x as char(36))) FROM
bar", trans, command); //$NON-NLS-1$
- command = tu.parseCommand("select * from (select max(x) from bar) x");
//$NON-NLS-1$
- TranslationHelper.helpTestVisitor("SELECT x.MAX FROM (SELECT MAX(cast(bar.x
as char(36))) FROM bar) x", trans, command); //$NON-NLS-1$
+ command = tu.parseCommand("select * from (select max(x) as max from bar)
x"); //$NON-NLS-1$
+ TranslationHelper.helpTestVisitor("SELECT x.max FROM (SELECT MAX(cast(bar.x
as char(36))) AS max FROM bar) x", trans, command); //$NON-NLS-1$
}
}
Copied: trunk/connectors/translator-ws (from rev 2192, trunk/connectors/translator-xml)
Deleted: trunk/connectors/translator-ws/pom.xml
===================================================================
--- trunk/connectors/translator-xml/pom.xml 2010-06-08 14:41:59 UTC (rev 2192)
+++ trunk/connectors/translator-ws/pom.xml 2010-06-10 04:01:14 UTC (rev 2212)
@@ -1,81 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <parent>
- <artifactId>connectors</artifactId>
- <groupId>org.jboss.teiid</groupId>
- <version>7.0.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>translator-xml</artifactId>
- <groupId>org.jboss.teiid.connectors</groupId>
- <name>XML Translator</name>
- <description>This translator consumes the XML documents from Web
- service and transforms the document into a relational
structure.</description>
- <dependencies>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.resource</groupId>
- <artifactId>connector-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>xom</groupId>
- <artifactId>xom</artifactId>
- <version>1.2</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>nux</groupId>
- <artifactId>nux</artifactId>
- <version>1.6</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <outputDirectory>target/classes</outputDirectory>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- <include>**/*.properties</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>false</filtering>
- <excludes>
- <exclude>**/*.xml</exclude>
- <exclude>**/*.properties</exclude>
- </excludes>
- </resource>
- </resources>
- </build>
-
-</project>
Copied: trunk/connectors/translator-ws/pom.xml (from rev 2202,
trunk/connectors/translator-xml/pom.xml)
===================================================================
--- trunk/connectors/translator-ws/pom.xml (rev 0)
+++ trunk/connectors/translator-ws/pom.xml 2010-06-10 04:01:14 UTC (rev 2212)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <parent>
+ <artifactId>connectors</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>7.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>translator-ws</artifactId>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <name>Web ervice Translator</name>
+ <description>This translator provides access to Web
Services.</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>jdom</groupId>
+ <artifactId>jdom</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <outputDirectory>target/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>**/*.xml</exclude>
+ <exclude>**/*.properties</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
+
+</project>
Copied: trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws (from rev
2202, trunk/connectors/translator-xml/src/main/java/org/teiid/translator/ws)
Deleted:
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/SAXFilterProvider.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/ws/SAXFilterProvider.java 2010-06-08
19:11:59 UTC (rev 2202)
+++
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/SAXFilterProvider.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,29 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.ws;
-
-import org.xml.sax.XMLFilter;
-
-public interface SAXFilterProvider {
- XMLFilter[] getExtendedFilters();
-}
Copied:
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
(from rev 2202,
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/ws/XMLExecutionFactory.java)
===================================================================
---
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
(rev 0)
+++
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -0,0 +1,112 @@
+/*
+ * 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.ws;
+
+import java.sql.SQLXML;
+import java.util.Collections;
+import java.util.List;
+
+import javax.resource.cci.ConnectionFactory;
+import javax.xml.transform.Source;
+import javax.xml.ws.Service.Mode;
+
+import org.teiid.core.BundleUtil;
+import org.teiid.language.Call;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.ProcedureParameter.Type;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.WSConnection;
+
+@Translator(name="ws")
+public class WSExecutionFactory extends ExecutionFactory<ConnectionFactory,
WSConnection> {
+
+ public static BundleUtil UTIL = BundleUtil.getBundleUtil(WSExecutionFactory.class);
+
+ private Mode defaultServiceMode = Mode.PAYLOAD;
+ private String xmlParamName;
+
+ @TranslatorProperty(description="Contols request/response message wrapping - set to
MESSAGE for full control over SOAP messages.", display="Default Service
Mode")
+ public Mode getDefaultServiceMode() {
+ return defaultServiceMode;
+ }
+
+ public void setDefaultServiceMode(Mode mode) {
+ this.defaultServiceMode = mode;
+ }
+
+ public String getXmlParamName() {
+ return xmlParamName;
+ }
+
+ public void setXmlParamName(String xmlParamName) {
+ this.xmlParamName = xmlParamName;
+ }
+
+ @Override
+ public ProcedureExecution createProcedureExecution(Call command, ExecutionContext
executionContext, RuntimeMetadata metadata, WSConnection connection)
+ throws TranslatorException {
+ return new WSProcedureExecution(command, metadata, executionContext, this,
connection);
+ }
+
+ public SQLXML convertToXMLType(Source value) {
+ return (SQLXML)getTypeFacility().convertToRuntimeType(value);
+ }
+
+ @Override
+ public final List getSupportedFunctions() {
+ return Collections.EMPTY_LIST;
+ }
+
+ @Override
+ public void getMetadata(MetadataFactory metadataFactory,
+ WSConnection conn) throws TranslatorException {
+ Procedure p = metadataFactory.addProcedure("invoke"); //$NON-NLS-1$
+
+ //can be one of HTTP, SOAP11, SOAP12
+ ProcedureParameter param = metadataFactory.addProcedureParameter("style",
TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
+ param.setNullType(NullType.Nullable);
+
+ param = metadataFactory.addProcedureParameter("action",
TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
+ param.setNullType(NullType.Nullable);
+
+ //can be one of string, xml, clob
+ param = metadataFactory.addProcedureParameter("request",
TypeFacility.RUNTIME_NAMES.OBJECT, Type.In, p); //$NON-NLS-1$
+ param.setNullType(NullType.Nullable);
+
+ param = metadataFactory.addProcedureParameter("endpoint",
TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
+ param.setNullType(NullType.Nullable);
+
+ metadataFactory.addProcedureParameter("result",
TypeFacility.RUNTIME_NAMES.XML, Type.ReturnValue, p); //$NON-NLS-1$
+ }
+
+}
Copied:
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
(from rev 2202,
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/ws/XMLProcedureExecution.java)
===================================================================
---
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
(rev 0)
+++
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -0,0 +1,209 @@
+/*
+ * 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.ws;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.sql.Clob;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.http.HTTPBinding;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.teiid.core.types.ClobType;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.logging.MessageLevel;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.WSConnection;
+import org.teiid.translator.WSConnection.Util;
+
+/**
+ * A soap call executor - handles all styles doc/literal, rpc/encoded etc.
+ */
+public class WSProcedureExecution implements ProcedureExecution {
+
+ public enum InvocationType {
+ HTTP(HTTPBinding.HTTP_BINDING),
+ SOAP11(SOAPBinding.SOAP11HTTP_BINDING),
+ SOAP12(SOAPBinding.SOAP12HTTP_BINDING);
+
+ private String bindingId;
+
+ private InvocationType(String bindingId) {
+ this.bindingId = bindingId;
+ }
+
+ public String getBindingId() {
+ return bindingId;
+ }
+ };
+
+ RuntimeMetadata metadata;
+ ExecutionContext context;
+ private Call procedure;
+ private SQLXML returnValue;
+ private WSConnection conn;
+ private WSExecutionFactory executionFactory;
+
+ /**
+ * @param env
+ */
+ public WSProcedureExecution(Call procedure, RuntimeMetadata metadata,
ExecutionContext context, WSExecutionFactory executionFactory, WSConnection conn) {
+ this.metadata = metadata;
+ this.context = context;
+ this.procedure = procedure;
+ this.conn = conn;
+ this.executionFactory = executionFactory;
+ }
+
+ public void execute() throws TranslatorException {
+ List<Argument> arguments = this.procedure.getArguments();
+
+ String style = (String)arguments.get(0).getArgumentValue().getValue();
+ String action = (String)arguments.get(1).getArgumentValue().getValue();
+ Object docObject = arguments.get(2).getArgumentValue().getValue();
+ Source source = null;
+ try {
+ if (docObject instanceof SQLXML) {
+ SQLXML xml = (SQLXML)docObject;
+ source = xml.getSource(null);
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS,
MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Request " +
xml.getString()); //$NON-NLS-1$
+ }
+ } else if (docObject instanceof Clob) {
+ Clob clob = (Clob)docObject;
+ source = new StreamSource(clob.getCharacterStream());
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL))
{
+ try {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "WebService Request: " +
ClobType.getString(clob)); //$NON-NLS-1$
+ } catch (IOException e) {
+ }
+ }
+ } else if (docObject instanceof String) {
+ String string = (String)docObject;
+ source = new StreamSource(new StringReader(string));
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL))
{
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Request " + string);
//$NON-NLS-1$
+ }
+ } else if (docObject != null) {
+ throw new
TranslatorException(WSExecutionFactory.UTIL.getString("unknown_doc_type"));
//$NON-NLS-1$
+ }
+ String endpoint = (String)arguments.get(3).getArgumentValue().getValue();
+
+ if (style == null) {
+ style = InvocationType.SOAP12.getBindingId();
+ } else {
+ try {
+ InvocationType type = InvocationType.valueOf(style.toUpperCase());
+ style = type.getBindingId();
+ } catch (IllegalArgumentException e) {
+ throw new
TranslatorException(WSExecutionFactory.UTIL.getString("invalid_invocation",
Arrays.toString(InvocationType.values()))); //$NON-NLS-1$
+ }
+ }
+
+ Dispatch<Source> dispatch = conn.createDispatch(style, endpoint,
Source.class, executionFactory.getDefaultServiceMode());
+
+ if (InvocationType.HTTP.getBindingId().equals(style)) {
+ if (action == null) {
+ action = "POST"; //$NON-NLS-1$
+ }
+ dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, action);
+ if (source != null && !"POST".equalsIgnoreCase(action)) {
//$NON-NLS-1$
+ if (this.executionFactory.getXmlParamName() == null) {
+ throw new
WebServiceException(WSExecutionFactory.UTIL.getString("http_usage_error"));
//$NON-NLS-1$
+ }
+ try {
+ Transformer t = TransformerFactory.newInstance().newTransformer();
+ StringWriter writer = new StringWriter();
+ //TODO: prevent this from being too large
+ t.transform(source, new StreamResult(writer));
+ String param =
Util.httpURLEncode(this.executionFactory.getXmlParamName())+"="+Util.httpURLEncode(writer.toString());
//$NON-NLS-1$
+ endpoint = WSConnection.Util.appendQueryString(endpoint, param);
+ } catch (TransformerException e) {
+ throw new WebServiceException(e);
+ }
+ }
+ } else {
+ if (action != null) {
+ dispatch.getRequestContext().put(Dispatch.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
+ dispatch.getRequestContext().put(Dispatch.SOAPACTION_URI_PROPERTY, action);
+ }
+ }
+
+ if (source == null) {
+ // JBoss Native DispatchImpl throws exception when the source is null
+ source = new StreamSource(new StringReader("<none/>"));
//$NON-NLS-1$
+ }
+ Source result = dispatch.invoke(source);
+ this.returnValue = this.executionFactory.convertToXMLType(result);
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
+ try {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "WebService Response: " +
this.returnValue.getString()); //$NON-NLS-1$
+ } catch (SQLException e) {
+ }
+ }
+ } catch (SQLException e) {
+ throw new TranslatorException(e);
+ } finally {
+ Util.closeSource(source);
+ }
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ return null;
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws TranslatorException {
+ return Arrays.asList(returnValue);
+ }
+
+ public void close() {
+
+ }
+
+ public void cancel() throws TranslatorException {
+ // no-op
+ }
+}
Deleted:
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/XMLExecutionFactory.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/ws/XMLExecutionFactory.java 2010-06-08
19:11:59 UTC (rev 2202)
+++
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/XMLExecutionFactory.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,145 +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.ws;
-
-import java.sql.SQLXML;
-import java.util.Collections;
-import java.util.List;
-
-import javax.resource.cci.ConnectionFactory;
-import javax.xml.transform.Source;
-import javax.xml.ws.Dispatch;
-
-import org.teiid.core.BundleUtil;
-import org.teiid.language.Call;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.logging.MessageLevel;
-import org.teiid.metadata.MetadataFactory;
-import org.teiid.metadata.Procedure;
-import org.teiid.metadata.ProcedureParameter;
-import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.metadata.BaseColumn.NullType;
-import org.teiid.metadata.ProcedureParameter.Type;
-import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.ExecutionFactory;
-import org.teiid.translator.ProcedureExecution;
-import org.teiid.translator.Translator;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.TranslatorProperty;
-import org.teiid.translator.TypeFacility;
-
-@Translator(name="ws")
-public class XMLExecutionFactory extends ExecutionFactory<ConnectionFactory,
Dispatch<Source>> {
-
- public static BundleUtil UTIL = BundleUtil.getBundleUtil(XMLExecutionFactory.class);
-
- private String saxFilterProviderClass;
- private String encoding = "ISO-8859-1"; //$NON-NLS-1$
- private boolean logRequestResponseDocs = false;
-
- @TranslatorProperty(description="Encoding of the XML documents",
display="Encoding Scheme")
- public String getCharacterEncodingScheme() {
- return this.encoding;
- }
-
- public void setCharacterEncodingScheme(String encoding) {
- this.encoding = encoding;
- }
-
- @TranslatorProperty(description="Must be extension of
org.teiid.translator.xml.SAXFilterProvider class", display="SAX Filter Provider
Class")
- public String getSaxFilterProviderClass() {
- return this.saxFilterProviderClass;
- }
-
- public void setSaxFilterProviderClass(String saxFilterProviderClass) {
- this.saxFilterProviderClass = saxFilterProviderClass;
- }
-
- // Can we get rid of this?
- private String inputStreamFilterClass;
-
- public String getInputStreamFilterClass() {
- return this.inputStreamFilterClass;
- }
-
- public void setInputStreamFilterClass(String inputStreamFilterClass) {
- this.inputStreamFilterClass = inputStreamFilterClass;
- }
-
- @TranslatorProperty(description="Log the XML request/response documents",
display="Log Request/Response Documents")
- public boolean isLogRequestResponseDocs() {
- return logRequestResponseDocs &&
LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL);
- }
-
- public void setLogRequestResponseDocs(boolean logRequestResponseDocs) {
- this.logRequestResponseDocs = logRequestResponseDocs;
- }
-
- @Override
- public ProcedureExecution createProcedureExecution(Call command, ExecutionContext
executionContext, RuntimeMetadata metadata, Dispatch<Source> connection)
- throws TranslatorException {
- return new XMLProcedureExecution(command, metadata, executionContext, this,
connection);
- }
-
- public SAXFilterProvider getSaxFilterProvider() throws TranslatorException {
- if (getSaxFilterProviderClass() == null) {
- return null;
- }
- return getInstance(SAXFilterProvider.class, getSaxFilterProviderClass(), null, null);
- }
-
- public SQLXML convertToXMLType(Source value) {
- /*XMLReader reader = XMLReaderFactory.createXMLReader();
-
- if (getSaxFilterProvider() != null) {
- XMLFilter[] filters = getSaxFilterProvider().getExtendedFilters();
- for(int i = 0; i < filters.length; i++) {
- XMLFilter filter = filters[i];
- filter.setParent(reader);
- reader = filter;
- }
- }
-
- SAXSource saxSource = new SAXSource(reader, inputSource);*/
-
- return (SQLXML)getTypeFacility().convertToRuntimeType(value);
- }
-
- @Override
- public final List getSupportedFunctions() {
- return Collections.EMPTY_LIST;
- }
-
- @Override
- public void getMetadata(MetadataFactory metadataFactory,
- Dispatch<Source> conn) throws TranslatorException {
- Procedure p = metadataFactory.addProcedure("invoke"); //$NON-NLS-1$
- metadataFactory.addProcedureParameter("request",
TypeFacility.RUNTIME_NAMES.OBJECT, Type.In, p); //$NON-NLS-1$
- ProcedureParameter param = metadataFactory.addProcedureParameter("endpoint",
TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
- param.setNullType(NullType.Nullable);
- param = metadataFactory.addProcedureParameter("soapaction",
TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
- param.setNullType(NullType.Nullable);
- }
-
-}
Deleted:
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/XMLProcedureExecution.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/ws/XMLProcedureExecution.java 2010-06-08
19:11:59 UTC (rev 2202)
+++
trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/XMLProcedureExecution.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,154 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.ws;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.sql.Clob;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.ws.Dispatch;
-
-import org.teiid.core.types.ClobType;
-import org.teiid.language.Argument;
-import org.teiid.language.Call;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.DataNotAvailableException;
-import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.ProcedureExecution;
-import org.teiid.translator.TranslatorException;
-
-/**
- * A soap call executor - handles all styles doc/literal, rpc/encoded etc.
- */
-public class XMLProcedureExecution implements ProcedureExecution {
-
- RuntimeMetadata metadata;
- ExecutionContext context;
- private Call procedure;
- private boolean returnedResult;
- private SQLXML returnValue;
- private Dispatch<Source> dispatch;
- private XMLExecutionFactory executionFactory;
-
- /**
- * @param env
- */
- public XMLProcedureExecution(Call procedure, RuntimeMetadata metadata,
ExecutionContext context, XMLExecutionFactory executionFactory, Dispatch<Source>
dispatch) {
- this.metadata = metadata;
- this.context = context;
- this.procedure = procedure;
- this.dispatch = dispatch;
- this.executionFactory = executionFactory;
- }
-
- /**
- * @see
org.teiid.connector.api.ProcedureExecution#execute(org.teiid.connector.language.Call,
int)
- */
- public void execute() throws TranslatorException {
- List<Argument> arguments = this.procedure.getArguments();
-
- Object docObject = (Object)arguments.get(0).getArgumentValue().getValue();
- Source source = null;
- try {
- if (docObject instanceof SQLXML) {
- SQLXML xml = (SQLXML)docObject;
- source = xml.getSource(null);
- if (executionFactory.isLogRequestResponseDocs()) {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Request " +
xml.getString()); //$NON-NLS-1$
- }
- } else if (docObject instanceof Clob) {
- Clob clob = (Clob)docObject;
- source = new StreamSource(clob.getCharacterStream());
- if (executionFactory.isLogRequestResponseDocs()) {
- try {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Request " +
ClobType.getString(clob)); //$NON-NLS-1$
- } catch (IOException e) {
- }
- }
- } else if (docObject instanceof String) {
- String string = (String)docObject;
- source = new StreamSource(new StringReader(string));
- if (executionFactory.isLogRequestResponseDocs()) {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Request " + string);
//$NON-NLS-1$
- }
- } else if (docObject != null) {
- throw new TranslatorException("Unknown document type, should be one of
XML, CLOB, String");
- }
- } catch (SQLException e) {
- throw new TranslatorException(e);
- }
-
- String endpoint = (String)arguments.get(1).getArgumentValue().getValue();
- String soapAction = (String)arguments.get(2).getArgumentValue().getValue();
-
- if (soapAction != null) {
- dispatch.getRequestContext().put(Dispatch.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
- dispatch.getRequestContext().put(Dispatch.SOAPACTION_URI_PROPERTY, soapAction);
- }
-
- if (endpoint != null) {
- this.dispatch.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY, endpoint);
- }
-
- // execute the request
- Source result = this.dispatch.invoke(source);
- this.returnValue = this.executionFactory.convertToXMLType(result);
- if (executionFactory.isLogRequestResponseDocs()) {
- try {
- LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Response " +
this.returnValue.getString()); //$NON-NLS-1$
- } catch (SQLException e) {
- }
- }
- }
-
- @Override
- public List<?> next() throws TranslatorException, DataNotAvailableException {
- if (!returnedResult) {
- returnedResult = true;
- return Arrays.asList(this.returnValue);
- }
- return null;
- }
-
- @Override
- public List<?> getOutputParameterValues() throws TranslatorException {
- return Collections.emptyList();
- }
-
- public void close() {
-
- }
-
- public void cancel() throws TranslatorException {
- // no-op
- }
-}
Modified: trunk/connectors/translator-ws/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/translator-xml/src/main/resources/META-INF/jboss-beans.xml 2010-06-08
14:41:59 UTC (rev 2192)
+++ trunk/connectors/translator-ws/src/main/resources/META-INF/jboss-beans.xml 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <bean name="translator-xml-template"
class="org.teiid.templates.TranslatorDeploymentTemplate">
- <property name="info"><inject
bean="translator-xml"/></property>
+ <bean name="translator-ws-template"
class="org.teiid.templates.TranslatorDeploymentTemplate">
+ <property name="info"><inject
bean="translator-ws"/></property>
<property name="managedObjectFactory"><inject
bean="ManagedObjectFactory"/></property>
</bean>
- <bean name="translator-xml"
class="org.teiid.templates.TranslatorTemplateInfo">
+ <bean name="translator-ws"
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.translator.xml.XMLExecutionFactory</parameter>
- <parameter
class="java.lang.String">translator-xml</parameter>
- <parameter class="java.lang.String">xml</parameter>
+ <parameter
class="java.lang.Class">org.teiid.translator.ws.WSExecutionFactory</parameter>
+ <parameter
class="java.lang.String">translator-ws</parameter>
+ <parameter class="java.lang.String">ws</parameter>
</constructor>
</bean>
Added:
trunk/connectors/translator-ws/src/main/resources/org/teiid/translator/ws/i18n.properties
===================================================================
---
trunk/connectors/translator-ws/src/main/resources/org/teiid/translator/ws/i18n.properties
(rev 0)
+++
trunk/connectors/translator-ws/src/main/resources/org/teiid/translator/ws/i18n.properties 2010-06-10
04:01:14 UTC (rev 2212)
@@ -0,0 +1,25 @@
+#
+# JBoss, Home of Professional Open Source.
+# See the COPYRIGHT.txt file distributed with this work for information
+# regarding copyright ownership. Some portions may be licensed
+# to Red Hat, Inc. under one or more contributor license agreements.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+
+http_usage_error=In HTTP invocation mode, a non-POST method was specified with a request
document. Either the document should be added to the query string or POST should be used
as the method.
+unknown_doc_type=Unknown document object type, should be one of XML, CLOB, String
+invalid_invocation=Invalid invocation style specified, should be one of {0}
\ No newline at end of file
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/MockQueryPreprocessor.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/MockQueryPreprocessor.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/MockQueryPreprocessor.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,42 +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.xml;
-
-import org.teiid.language.Select;
-import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.xml.RequestPreprocessor;
-
-public class MockQueryPreprocessor implements RequestPreprocessor {
-
- public MockQueryPreprocessor() {
- super();
- }
-
- public Select preprocessQuery(Select query, RuntimeMetadata m_metadata, ExecutionContext
exeContext) {
- return query;
- }
-
-}
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/ProxyObjectFactory.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/ProxyObjectFactory.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/ProxyObjectFactory.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,215 +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.xml;
-
-import java.io.File;
-import java.io.StringReader;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.jdom.Document;
-import org.jdom.input.SAXBuilder;
-import org.mockito.Mockito;
-import org.teiid.language.Select;
-import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.ExecutionContext;
-
-import com.metamatrix.cdk.api.TranslationUtility;
-/**
- *
- */
-public class ProxyObjectFactory {
-
- public static final String JMS_DESTINATION = "dynamicQueues/topic1";
- public static final String INITIAL_CONTEXT_FACTORY =
"org.apache.activemq.jndi.ActiveMQInitialContextFactory";
- private static String docFolder = null;
-
-
- private ProxyObjectFactory() {
-
- }
-
-
-// public static HTTPManagedConnectionFactory
getHTTPTestConnectorEnvironment(Properties props) {
-// if (props == null) {
-// props = getDefaultHTTPProps();
-// }
-// HTTPManagedConnectionFactory env = new HTTPManagedConnectionFactory();
-// PropertiesUtils.setBeanProperties(env, props, null);
-// return env;
-// }
-
- public static ExecutionContext getDefaultSecurityContext() {
- return Mockito.mock(ExecutionContext.class);
- }
-
- public static ExecutionContext getDefaultExecutionContext() {
- ExecutionContext ec = Mockito.mock(ExecutionContext.class);
- Mockito.stub(ec.getRequestIdentifier()).toReturn("request");
- Mockito.stub(ec.getPartIdentifier()).toReturn("testPartId");
-
- return ec;
- }
-
- public static ExecutionContext getExecutionContext(String requestID, String partId)
{
- ExecutionContext ec = Mockito.mock(ExecutionContext.class);
- Mockito.stub(ec.getRequestIdentifier()).toReturn(requestID);
- Mockito.stub(ec.getPartIdentifier()).toReturn(partId);
-
- return ec;
- }
-
-
-//
-// public static Properties getDefaultHTTPProps() {
-// Properties testHTTPProps = new Properties();
-// testHTTPProps.setProperty(XMLConnectorStateImpl.CACHE_ENABLED,
Boolean.TRUE.toString());
-// testHTTPProps.setProperty(HTTPConnectorState.URI,
"http://localhost:8673"); //$NON-NLS-1$
-// testHTTPProps.setProperty(HTTPConnectorState.REQUEST_TIMEOUT, "60");
//$NON-NLS-1$
-// testHTTPProps.setProperty(XMLConnectorState.STATE_CLASS_PROP,
"com.metamatrix.connector.xml.http.HTTPConnectorState"); //$NON-NLS-1$
-// testHTTPProps.setProperty(HTTPConnectorState.HTTP_BASIC_USER, "");
-// testHTTPProps.setProperty(HTTPConnectorState.HTTP_BASIC_PASSWORD,
"");
-// testHTTPProps.setProperty(SecureConnectorState.SECURITY_DESERIALIZER_CLASS,
"com.metamatrix.connector.xml.http.DefaultTrustDeserializer");
-// testHTTPProps.setProperty(HTTPConnectorState.PARAMETER_METHOD,
HTTPConnectorState.PARAMETER_NAME_VALUE);
-// testHTTPProps.setProperty(HTTPConnectorState.ACCESS_METHOD,
HTTPConnectorState.GET);
-// return testHTTPProps;
-// }
-
-
-//
-// public static Properties getDefaultNameValueRequestProps() {
-// Properties defaultHTTPProps = getDefaultHttpProps();
-// defaultHTTPProps.setProperty(HTTPConnectorState.PARAMETER_METHOD,
HTTPConnectorState.PARAMETER_NAME_VALUE);
-// return defaultHTTPProps;
-// }
-
-// public static Properties getDefaultHttpProps() {
-// Properties testHTTPProps = new Properties();
-// testHTTPProps.put(XMLConnectorStateImpl.CACHE_ENABLED, Boolean.TRUE);
-// testHTTPProps.put(XMLConnectorStateImpl.CONNECTOR_CAPABILITES,
"com.metamatrix.connector.xml.base.XMLCapabilities");
-// testHTTPProps.setProperty(XMLConnectorState.STATE_CLASS_PROP,
"com.metamatrix.connector.xml.http.HTTPConnectorState");
-// testHTTPProps.setProperty(XMLConnectorStateImpl.QUERY_PREPROCESS_CLASS,
"com.metamatrix.connector.xml.base.NoQueryPreprocessing");
-// testHTTPProps.setProperty(XMLConnectorStateImpl.SAX_FILTER_PROVIDER_CLASS,
"com.metamatrix.connector.xml.base.NoExtendedFilters");
-// testHTTPProps.setProperty(HTTPConnectorState.ACCESS_METHOD,
HTTPConnectorState.GET);
-// testHTTPProps.setProperty(HTTPConnectorState.PARAMETER_METHOD,
HTTPConnectorState.PARAMETER_XML_REQUEST);
-// testHTTPProps.setProperty(HTTPConnectorState.URI,
"http://0.0.0.0:8673");
-// //testHTTPProps.setProperty(HTTPConnectorState.PROXY_URI,
"http://0.0.0.0:8673");
-// testHTTPProps.setProperty(HTTPConnectorState.REQUEST_TIMEOUT,
"60");
-// testHTTPProps.setProperty(HTTPConnectorState.XML_PARAMETER_NAME,
"XMLRequest");
-// testHTTPProps.setProperty(HTTPConnectorState.HTTP_BASIC_USER, "");
-// testHTTPProps.setProperty(HTTPConnectorState.HTTP_BASIC_PASSWORD,
"");
-// testHTTPProps.setProperty(SecureConnectorState.SECURITY_DESERIALIZER_CLASS,
"com.metamatrix.connector.xml.http.DefaultTrustDeserializer");
-// return testHTTPProps;
-// }
-
-
-
-
-// public static XMLConnector getDefaultXMLConnector() {
-// XMLConnector conn;
-// try {
-// conn = new XMLConnector();
-// conn.initialize(getDefaultTestConnectorEnvironment());
-// } catch (ConnectorException ce) {
-// ce.printStackTrace();
-// conn = null;
-// }
-// return conn;
-// }
-
-// public static XMLConnector getDefaultHTTPConnector(Properties props) {
-// XMLConnector conn;
-// try {
-// conn = new XMLConnector();
-// conn.initialize(getHTTPTestConnectorEnvironment(props));
-// } catch (ConnectorException ce) {
-// ce.printStackTrace();
-// conn = null;
-// }
-// return conn;
-// }
-//
-// public static XMLConnectionImpl getDefaultXMLConnection() {
-// XMLConnectionImpl connection;
-// try {
-// ExecutionContext ctx = getDefaultSecurityContext();
-// connection = (XMLConnectionImpl) getDefaultXMLConnector().getConnection();
-// } catch (ConnectorException ce) {
-// connection = null;
-// } catch (NullPointerException ne) {
-// connection = null;
-// }
-// return connection;
-// }
-//
-// private static XMLConnectionImpl getHTTPXMLConnection(Properties props) {
-// XMLConnectionImpl connection;
-// try {
-// ExecutionContext ctx = getDefaultSecurityContext();
-// connection = (XMLConnectionImpl)
getDefaultHTTPConnector(props).getConnection();
-// } catch (ConnectorException ce) {
-// connection = null;
-// } catch (NullPointerException ne) {
-// connection = null;
-// }
-// return connection;
-// }
-
-
- public static Select getDefaultIQuery(String vdbPath, String queryString) {
- TranslationUtility transUtil = new TranslationUtility(vdbPath);
- Select query = (Select) transUtil.parseCommand(queryString);
- return query;
- }
-
- public static RuntimeMetadata getDefaultRuntimeMetadata(String vdbPath) {
- TranslationUtility transUtil = new TranslationUtility(vdbPath);
- RuntimeMetadata meta = transUtil.createRuntimeMetadata();
- return meta;
- }
-
- public static Document getDefaultDocument() throws Exception {
- Document doc = null;
- SAXBuilder builder = new SAXBuilder();
- StringReader reader = new
StringReader("<foo><bar>baz</bar></foo>");
- doc = builder.build(reader);
- return doc;
- }
-
- public static String getStateCollegeVDBLocation() {
- return getDocumentsFolder() + "/UnitTests.vdb";
- }
-
- public static String getDocumentsFolder() {
- //is the test running locally or in CruiseControl?
- if (docFolder == null) {
- URL url =
ProxyObjectFactory.class.getClassLoader().getResource("documents");
- try {
- docFolder = new File(url.toURI()).toString();
- } catch (URISyntaxException e) {
- }
- }
- return docFolder;
- }
-
-}
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestCartesianCriteriaGenerator.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestCartesianCriteriaGenerator.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestCartesianCriteriaGenerator.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,119 +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.xml;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-import org.teiid.metadata.Column;
-
-
-@SuppressWarnings("nls")
-public class TestCartesianCriteriaGenerator {
-
- @Test
- public void testCartesian() throws Exception {
- String[] validValues = {"ACE", "ADE", "BCE",
"BDE", "ACF", "ADF", "BCF", "BDF"};
-
- List<CriteriaDesc> list = new ArrayList<CriteriaDesc>();
-
- Column c1 = new Column();
- c1.setName("c1");
-
- Column c2 = new Column();
- c2.setName("c2");
-
- Column c3 = new Column();
- c3.setName("c3");
-
- CriteriaDesc desc1 = new CriteriaDesc(c1, Arrays.asList(new String[] {"A",
"B"}));
- CriteriaDesc desc2 = new CriteriaDesc(c2, Arrays.asList(new String[] {"C",
"D"}));
- CriteriaDesc desc3 = new CriteriaDesc(c3, Arrays.asList(new String[] {"E",
"F"}));
- list.add(desc1);
- list.add(desc2);
- list.add(desc3);
-
- List<List<CriteriaDesc>> catesianProduct =
CartesienCriteriaGenerator.generateCartesianCriteria(list);
-
- assertEquals(8, catesianProduct.size());
- for (List<CriteriaDesc> cds:catesianProduct) {
- assertEquals(3, cds.size());
-
- String value = "";
- for (CriteriaDesc cd:cds) {
- List values = cd.getValues();
- for (Object v:values) {
- value = value+v.toString();
- }
- }
- assertTrue(Arrays.asList(validValues).contains(value));
- }
- }
-
-
- @Test
- public void testCartesianWithMultiValue() throws Exception {
- // the brackets represent the grouping, how they come as multi values.
- String[] validValues = {"[A][C][EF]", "[A][D][EF]",
"[B][C][EF]", "[B][D][EF]"};
-
- List<CriteriaDesc> list = new ArrayList<CriteriaDesc>();
-
- Column c1 = new Column();
- c1.setName("c1");
-
- Column c2 = new Column();
- c2.setName("c2");
-
- // make this column takes multi values
- Column c3 = new Column();
- c3.setName("c3");
- c3.setProperty(CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME,
CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_MULTI_ELEMENT_NAME);
-
- CriteriaDesc desc1 = new CriteriaDesc(c1, Arrays.asList(new String[] {"[A]",
"[B]"}));
- CriteriaDesc desc2 = new CriteriaDesc(c2, Arrays.asList(new String[] {"[C]",
"[D]"}));
- CriteriaDesc desc3 = new CriteriaDesc(c3, Arrays.asList(new String[] {"[E",
"F]"}));
- list.add(desc1);
- list.add(desc2);
- list.add(desc3);
-
- List<List<CriteriaDesc>> catesianProduct =
CartesienCriteriaGenerator.generateCartesianCriteria(list);
-
- assertEquals(4, catesianProduct.size());
- for (List<CriteriaDesc> cds:catesianProduct) {
- assertEquals(3, cds.size());
-
- String value = "";
- for (CriteriaDesc cd:cds) {
- List values = cd.getValues();
- for (Object v:values) {
- value = value+v.toString();
- }
- }
- assertTrue(Arrays.asList(validValues).contains(value));
- }
- }
-
-}
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestCriteriaDesc.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestCriteriaDesc.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestCriteriaDesc.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,608 +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.xml;
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.teiid.language.BaseInCondition;
-import org.teiid.language.ColumnReference;
-import org.teiid.language.Comparison;
-import org.teiid.language.Condition;
-import org.teiid.language.DerivedColumn;
-import org.teiid.language.Expression;
-import org.teiid.language.LanguageUtil;
-import org.teiid.language.Select;
-import org.teiid.metadata.Column;
-import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.xml.CriteriaDesc;
-
-
-/**
- *
- */
-public class TestCriteriaDesc extends TestCase {
-
- private static String vdbPath;
- private static final String QUERY = "select RequiredDefaultedParam from
CriteriaDescTable " //$NON-NLS-1$
- + "where RequiredDefaultedParam in ('foo') order by
RequiredDefaultedParam"; //$NON-NLS-1$
- private static final String VALUE = "value1"; //$NON-NLS-1$
-
-
-
- static {
- vdbPath = ProxyObjectFactory.getStateCollegeVDBLocation();
- }
-
- public void testGetCriteriaDescForColumn() throws Exception {
- //case 1: values provided
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredDefaultedParam from CriteriaDescTable where
RequiredDefaultedParam in ('foo')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnDefaultedValue() throws Exception {
- //case 2: param, required, defaulted
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredDefaultedParam from CriteriaDescTable";
//$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnNoCriteria() throws Exception {
- //case 3: param, not required, not defaulted, not allowed empty
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select OptionalNotAllowedEmptyParam from
CriteriaDescTable"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNull("CriteriaDesc is not null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnAllowEmpty() throws Exception {
- //case 4: param, not required, not defaulted, allowed empty
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select OptionalAllowedEmptyParam from CriteriaDescTable";
//$NON-NLS-1$
- final int colLocation = 0;
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnError() {
- //case 5: param, required, not defaulted
- try {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredUndefaultedParam from
CriteriaDescTable"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- fail("exception not thrown"); //$NON-NLS-1$
- } catch (TranslatorException ce) {
- }
- }
-
- public void testGetCriteriaDescForColumnNotParam() throws Exception {
- //case 6: not a param
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select OutputColumn from CriteriaDescTable";
//$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNull("CriteriaDesc is not null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnCompare() throws Exception {
- //case 7: compare criteria
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredDefaultedParam from CriteriaDescTable where
RequiredDefaultedParam = 'foo'"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
-
- public void testGetCriteriaDescForColumnMultiElement() throws Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select MultiElementParam from CriteriaDescTable where
MultiElementParam in ('foo','bar')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- String multiplicityStr = elem.getProperties().get(
- CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnDelimited() throws Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select DelimitedParam from CriteriaDescTable where
DelimitedParam in ('foo','bar')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- String multiplicityStr = elem.getProperties().get(
- CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnLikeSearchable() {
- try {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select LikeSearchableParam from CriteriaDescTable where
LikeSearchableParam in ('foo')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- String multiplicityStr = elem.getProperties().get(
- CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- fail("should not be able to handle default value"); //$NON-NLS-1$
- } catch (TranslatorException ce) {
- }
- }
-
- public void testGetCriteriaDescForColumnUnlikeSearchable() throws Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select UnlikeSearchableParam from CriteriaDescTable where
UnlikeSearchableParam in ('foo')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- String multiplicityStr = elem.getProperties().get(
- CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- }
-
- public void testGetCriteriaDescForColumnUnsearchable() {
- try {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select UnsearchableParam from CriteriaDescTable where
UnsearchableParam in ('foo','bar')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- String multiplicityStr = elem.getProperties().get(
- CriteriaDesc.PARM_HAS_MULTIPLE_VALUES_COLUMN_PROPERTY_NAME);
- CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- fail("should not be able to handle default value"); //$NON-NLS-1$
- } catch (TranslatorException ce) {
- }
- }
-
- public void testGetCriteriaDescForColumnLike() throws Exception {
- //case 1: values provided
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredDefaultedParam from CriteriaDescTable where
RequiredDefaultedParam like 'foo'"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnNotEquals() throws Exception {
- //case 1: values provided
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredDefaultedParam from CriteriaDescTable where
RequiredDefaultedParam != 'foo'"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnLiteral() throws Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredDefaultedParam from CriteriaDescTable where
concat(RequiredDefaultedParam, 'bar') in('foo')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnNameMatchFailure() throws Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredDefaultedParam from CriteriaDescTable where
AttributeParam in('foo')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
-
- public void testGetCriteriaDescForColumnLeftLiteral() throws Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredDefaultedParam from CriteriaDescTable "
//$NON-NLS-1$
- + "where concat('bar', 'foo') = concat('bar',
RequiredDefaultedParam)"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnTwoElements() throws Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredDefaultedParam from CriteriaDescTable where
OutputColumn = RequiredDefaultedParam"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnLeftElementEqualsLiteral() throws Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredDefaultedParam from CriteriaDescTable where
AttributeParam = 'foo'"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetCriteriaDescForColumnLeftElementEqualsNonLiteral() throws
Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select RequiredDefaultedParam from CriteriaDescTable
where" //$NON-NLS-1$
- + " RequiredDefaultedParam = concat('foo', OutputColumn)";
//$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertNotNull("CriteriaDesc is null", desc); //$NON-NLS-1$
- }
-
- public void testGetInputXPathNoXpath() throws Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select BadNoInputXpath from CriteriaDescTable where
BadNoInputXpath in ('foo')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertEquals(desc.getColumnName(), desc.getInputXpath());
- }
-
-
- public void testGetInputXPathEmptyXpath() throws Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select BadEmptyInputXPath from CriteriaDescTable where
BadEmptyInputXPath in ('foo')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertEquals(desc.getColumnName(), desc.getInputXpath());
- }
-
- public void testGetDataAttributeNameEmptyName() throws Exception {
- assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
- String query = "select BadNoDataAttributeName from CriteriaDescTable where
BadNoDataAttributeName in ('foo')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertEquals("", desc.getDataAttributeName()); //$NON-NLS-1$
- }
-
- public void testGetInputXpath() throws TranslatorException {
- String query = "select RequiredDefaultedParam from CriteriaDescTable";
//$NON-NLS-1$
- String inputXPath = "/req/default/value"; //$NON-NLS-1$
- CriteriaDesc desc = createCriteriaDesc(query);
- assertNotNull("CriteriaDesc is null", desc.getInputXpath());
//$NON-NLS-1$
- assertEquals(inputXPath, desc.getInputXpath());
- }
-
- public void testIsUnlimited() throws TranslatorException {
- CriteriaDesc desc = createCriteriaDesc(QUERY);
- assertFalse("Criteria is flagged as unlimited", desc.isUnlimited());
//$NON-NLS-1$
- }
-
- public void testIsAutoIncrement() throws TranslatorException {
- CriteriaDesc desc = createCriteriaDesc(QUERY);
- assertFalse("criterion is flagged as autoIncrement",
desc.isAutoIncrement()); //$NON-NLS-1$
- }
-
- public void testIsParentAttribute() throws TranslatorException {
- CriteriaDesc desc = createCriteriaDesc(QUERY);
- //before its inited
- assertFalse("criterion is flagged as an attribute",
desc.isParentAttribute()); //$NON-NLS-1$
- //and after for code coverage
- assertFalse("criterion is flagged as an attribute",
desc.isParentAttribute()); //$NON-NLS-1$
- }
-
- public void testIsEnumeratedAttribute() throws TranslatorException {
- CriteriaDesc desc = createCriteriaDesc(QUERY);
- assertFalse("criterion is an enumerated attribute",
desc.isEnumeratedAttribute()); //$NON-NLS-1$
- }
-
- public void testAllowEmptyValueFalse() throws TranslatorException {
- String query = "select OptionalNotAllowedEmptyParam from
CriteriaDescTable"; //$NON-NLS-1$
- CriteriaDesc desc = createCriteriaDesc(query);
- assertFalse("criterion should not allow for empty values",
desc.allowEmptyValue()); //$NON-NLS-1$
- }
-
- public void testAllowEmptyValueTrue() throws TranslatorException {
- String query = "select OptionalAllowedEmptyParam from CriteriaDescTable";
//$NON-NLS-1$
- CriteriaDesc desc = createCriteriaDesc(query);
- //before init
- assertTrue("criterion should allow for empty values",
desc.allowEmptyValue()); //$NON-NLS-1$
- //and after for code coverage
- assertTrue("criterion should allow for empty values",
desc.allowEmptyValue()); //$NON-NLS-1$
- }
-
- public void testIsDataInAttributeFalse() throws TranslatorException {
- CriteriaDesc desc = createCriteriaDesc(QUERY);
- assertFalse("criterion is flagged as data in attribute",
desc.isDataInAttribute()); //$NON-NLS-1$
- }
-
- public void testIsDataInAttributeTrue() throws TranslatorException {
- String query = "select AttributeParam from CriteriaDescTable where
AttributeParam in ('foo')"; //$NON-NLS-1$
- CriteriaDesc desc = createCriteriaDesc(query);
- assertTrue("criterion is not flagged as data in attribute",
desc.isDataInAttribute()); //$NON-NLS-1$
- }
-
- public void testGetDataAttributeName() throws TranslatorException {
- String query = "select AttributeColumn from TestTable where AttributeColumn in
('foo')"; //$NON-NLS-1$
- Column elem = getElement(query);
- String attributeName = "myAttribute"; //$NON-NLS-1$
- ArrayList list = new ArrayList();
- list.add(VALUE);
- CriteriaDesc desc = new CriteriaDesc(elem, list);
- assertNotNull("CriteriaDesc is null", desc.getDataAttributeName());
//$NON-NLS-1$
- assertTrue("column name mismatch - expected " + attributeName
//$NON-NLS-1$
- + " returned " + desc.getDataAttributeName(), //$NON-NLS-1$
- desc.getDataAttributeName().equals(attributeName));
- }
-
- public void testGetValues() throws TranslatorException {
- CriteriaDesc desc = createCriteriaDesc(QUERY);
- List values = desc.getValues();
- assertNotNull("Values list is null", values); //$NON-NLS-1$
- assertEquals(values.get(0), VALUE);
- }
-
- public void testGetNumberOfValues() throws TranslatorException {
- CriteriaDesc desc = createCriteriaDesc(QUERY);
- assertEquals(1, desc.getNumberOfValues());
- }
-
- public void testGetCurrentIndexValue() throws TranslatorException {
- CriteriaDesc desc = createCriteriaDesc(QUERY);
- assertEquals(VALUE, desc.getCurrentIndexValue());
- }
-
- public void testGetCurrentIndexValueEnumerated() throws Exception {
- String query = "select DelimitedParam from CriteriaDescTable where
DelimitedParam in ('foo', 'bar')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertEquals("There should be two values" , 2,
desc.getNumberOfValues()); //$NON-NLS-1$
- assertEquals("foo", desc.getCurrentIndexValue()); //$NON-NLS-1$
- desc.incrementIndex();
- assertEquals("bar", desc.getCurrentIndexValue()); //$NON-NLS-1$
- }
-
- public void testIncrementIndexEnumerated() throws Exception {
- String query = "select DelimitedParam from CriteriaDescTable where
DelimitedParam in ('foo', 'bar')"; //$NON-NLS-1$
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
- Column elem = ((ColumnReference) expr).getMetadataObject();
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
- assertTrue("We should be able to increment this CriteriaDesc",
desc.incrementIndex()); //$NON-NLS-1$
- }
-
- public void testGetCurrentIndexValueNoValue() throws Exception {
- final String query = "select OptionalAllowedEmptyParam from
CriteriaDescTable"; //$NON-NLS-1$
- Column elem = getElement(query);
- ArrayList list = new ArrayList();
- CriteriaDesc desc = new CriteriaDesc(elem, list);
- assertEquals("", desc.getCurrentIndexValue()); //$NON-NLS-1$
- }
-
- public void testGetCurrentIndexValueNoValueNotEmpty() throws Exception {
- final String query = "select OptionalNotAllowedEmptyParam from
CriteriaDescTable"; //$NON-NLS-1$
- Column elem = getElement(query);
- ArrayList list = new ArrayList();
- CriteriaDesc desc = new CriteriaDesc(elem, list);
- assertNull(desc.getCurrentIndexValue());
- }
-
- public void testIncrementIndex() throws Exception {
- final String value2 = "value2"; //$NON-NLS-1$
- String query = "select MultiCol from MultiTable where MultiCol in
('" + VALUE + "', '" + value2 + "')";
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Column elem = getElement(query);
- ArrayList list = new ArrayList();
- list.add(VALUE);
- list.add(value2);
- CriteriaDesc desc = new CriteriaDesc(elem, list);
- assertEquals(VALUE, desc.getCurrentIndexValue());
- assertTrue("index increment failed", desc.incrementIndex());
//$NON-NLS-1$
- assertEquals(value2, desc.getCurrentIndexValue());
- assertFalse("index went beyond number of values",
desc.incrementIndex()); //$NON-NLS-1$
- }
-
- public void testResetIndex() throws Exception {
- CriteriaDesc desc = createCriteriaDesc(QUERY);
- desc.resetIndex();
- }
-
- public void testNameMatch() {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- Condition crit = query.getWhere();
- List criteriaList = LanguageUtil.separateCriteriaByAnd(crit);
- Iterator criteriaIter = criteriaList.iterator();
- Expression expr = null;
- while (criteriaIter.hasNext()) {
- Condition criteriaSeg = (Condition) criteriaIter.next();
- if (criteriaSeg instanceof Comparison) {
- Comparison compCriteria = (Comparison) criteriaSeg;
- expr = compCriteria.getLeftExpression();
- break;
- } else if (criteriaSeg instanceof BaseInCondition) {
- expr = ((BaseInCondition) criteriaSeg).getLeftExpression();
- break;
- }
- }
- final String column = "CriteriaDescTable.RequiredDefaultedParam";
//$NON-NLS-1$
- assertTrue("column name mismatch - expected " + column + "
returned " + expr, //$NON-NLS-1$ //$NON-NLS-2$
- CriteriaDesc.nameMatch(expr, column));
- }
-
- public void testStringifyCriteria() {
- String withQuotes = "'foodle doodle'"; //$NON-NLS-1$
- String withoutQuotes = "foodle doodle"; //$NON-NLS-1$
- assertEquals("stringify failed", withoutQuotes,
CriteriaDesc.stringifyCriteria(withQuotes)); //$NON-NLS-1$
- }
-
- public void testStringifyCriteriaDoubleQuotes() {
- String control = "foodle doodle"; //$NON-NLS-1$
- String test = "\"foodle doodle\""; //$NON-NLS-1$
- assertEquals("stringify failed", control,
CriteriaDesc.stringifyCriteria(test)); //$NON-NLS-1$
- }
-
- public void testStringifyCriteriaSingleQuote() {
- String test = "'ello govnor."; //$NON-NLS-1$
- assertEquals("stringify failed", test,
CriteriaDesc.stringifyCriteria(test)); //$NON-NLS-1$
- }
-
- public void testStringifyCriteriaSingleDoubleQuote() {
- String test = "\"ello govnor."; //$NON-NLS-1$
- assertEquals("stringify failed", test,
CriteriaDesc.stringifyCriteria(test)); //$NON-NLS-1$
- }
-
-
- public void testBadTableSelect() throws TranslatorException {
- String tempVdbpath = vdbPath;
- vdbPath = ProxyObjectFactory.getDocumentsFolder() + "/UnitTests.vdb";
//$NON-NLS-1$
- try {
- createCriteriaDesc("select BadCol1 from BadTable"); //$NON-NLS-1$
- } finally {
- vdbPath = tempVdbpath;
- }
- }
-
- public void testElementAllowsEmpty() throws TranslatorException {
- String tempVdbpath = vdbPath;
- vdbPath = ProxyObjectFactory.getDocumentsFolder() + "/UnitTests.vdb";
//$NON-NLS-1$
- String strQuery = "Select Balance from Response"; //$NON-NLS-1$
- try {
- Column elem = getElement(strQuery);
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
- CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, query);
- } finally {
- vdbPath = tempVdbpath;
- }
- }
-
-
- private CriteriaDesc createCriteriaDesc(String query) throws TranslatorException {
- Column elem = getElement(query);
- ArrayList list = new ArrayList();
- list.add(VALUE);
- CriteriaDesc desc = new CriteriaDesc(elem, list);
- return desc;
- }
-
- private Column getElement(String query) throws TranslatorException {
- return getElement(query, 0);
- }
-
- private Column getElement(String query, int colLocation)
- throws TranslatorException {
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- Column elem = ((ColumnReference) expr).getMetadataObject();
- return elem;
- }
-
-}
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestElementCollector.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestElementCollector.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestElementCollector.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,82 +0,0 @@
-package org.teiid.translator.xml;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.sql.SQLXML;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.teiid.core.types.InputStreamFactory;
-import org.teiid.core.types.SQLXMLImpl;
-import org.teiid.language.Select;
-import org.teiid.translator.xml.streaming.ElementProcessor;
-import org.teiid.translator.xml.streaming.ReaderFactory;
-import org.teiid.translator.xml.streaming.StreamingRowCollector;
-
-
-@SuppressWarnings("nls")
-public class TestElementCollector extends TestCase {
-
- StreamingRowCollector builder;
- String filename = ProxyObjectFactory.getDocumentsFolder() +
"/purchaseOrders.xml";
- String vdbPath = ProxyObjectFactory.getDocumentsFolder() +
"/File/purchase_orders.vdb";
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- Map prefixes = new HashMap<String, String>();
- prefixes.put("po", "http://www.example.com/PO1");
- prefixes.put("xsd", "http://www.w3.org/2001/XMLSchema");
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, "SELECT * FROM
po_list.ITEM");
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- analyzer.analyze();
- ExecutionInfo info = analyzer.getExecutionInfo();
- ElementProcessor processor = new ElementProcessor(info);
- builder = new StreamingRowCollector(prefixes, ReaderFactory.getXMLReader(null),
processor);
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- builder = null;
- }
-
- public void testGetTables1() {
- String path = "/po:purchaseOrders/order/items/item";
- int itemCount = 5968;
- try {
- StremableDocument doc = new StremableDocument(getSQLXML(new
FileInputStream(filename)), "foo");
- List result = builder.getElements(doc, Arrays.asList(path));
- assertEquals(itemCount, result.size());
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- public void testGetRoot() {
- String path = "/";
- int itemCount = 1;
- try {
- StremableDocument doc = new StremableDocument(getSQLXML(new
FileInputStream(filename)), "foo");
- List result = builder.getElements(doc, Arrays.asList(path));
- assertEquals(itemCount, result.size());
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-
- SQLXML getSQLXML(final InputStream in) {
- InputStreamFactory isf = new InputStreamFactory("ISO-8859-1") {
- @Override
- public InputStream getInputStream() throws IOException {
- return in;
- }
- };
- return new SQLXMLImpl(isf);
- }
-}
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestExecutionInfo.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestExecutionInfo.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestExecutionInfo.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,191 +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.xml;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.teiid.language.Select;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.xml.ExecutionInfo;
-import org.teiid.translator.xml.QueryAnalyzer;
-
-/**
- *
- */
-public class TestExecutionInfo extends TestCase {
-
- /**
- * Constructor for ExecutionInfoTest.
- * @param arg0
- */
-
- private static final String QUERY = "select Company_id from Company where
Company_id = 'MetaMatrix' order by Company_id";
-
- private ExecutionInfo m_info;
-
- //removing hansel while testing clover
-/*
- public static Test suite() {
- return new CoverageDecorator(ExecutionInfoTest.class, new Class[]
{ExecutionInfo.class});
-
- }
-*/
-
- public TestExecutionInfo(String arg0) {
- super(arg0);
- }
-
- @Override
- public void setUp() throws TranslatorException {
- String vdbPath = ProxyObjectFactory.getStateCollegeVDBLocation();
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- analyzer.analyze();
- m_info = analyzer.getExecutionInfo();
-
- }
-
- @Override
- public void tearDown() {
- m_info = null;
- }
-
- public void testExecutionInfo() {
- ExecutionInfo info = new ExecutionInfo();
- assertNotNull("ExecutionInfo is null", info);
- assertEquals(0, info.getColumnCount());
- assertNotNull(info.getCriteria());
- assertNotNull(info.getOtherProperties());
- assertNotNull(info.getParameters());
- assertNotNull(info.getRequestedColumns());
- assertNotNull(info.getTableXPath());
- }
-
- public void testGetTableXPath() {
- assertEquals("/Mydata/company", m_info.getTableXPath());
- }
-
- public void testGetRequestedColumns() {
- List columns = m_info.getRequestedColumns();
- assertNotNull("requestedColumns list is null", columns);
- assertEquals(1, columns.size());
- }
-
- public void testGetColumnCount() {
- assertEquals(1, m_info.getColumnCount());
- }
-
- public void testGetParameters() {
- List params = m_info.getParameters();
- assertNotNull("Param list is null", params);
- assertEquals(0, params.size());
- }
-
- public void testGetCriteria() {
- String vdbPath = ProxyObjectFactory.getStateCollegeVDBLocation();
- //String query = "Select AttributeColumn from TestTable where AttributeColumn
in ('foo')";
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- try {
- QueryAnalyzer analyzer = new QueryAnalyzer(iquery);
- analyzer.analyze();
- ExecutionInfo info = analyzer.getExecutionInfo();
- List crits = info.getCriteria();
- assertNotNull("Criteria list is null", crits);
- assertEquals(1, crits.size());
- } catch (TranslatorException ce) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
- }
-
- public void testGetOtherProperties() throws TranslatorException {
- String vdbPath = ProxyObjectFactory.getDocumentsFolder() +
"/UnitTests.vdb";
- String strQuery = "select * from Response";
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- analyzer.analyze();
- ExecutionInfo info = analyzer.getExecutionInfo();
- Map<String, String> props = info.getOtherProperties();
- assertFalse("properties are empty", props.isEmpty());
- info.setOtherProperties(null);
- assertNotNull(info.getOtherProperties());
- }
-
- public void testSetTableXPath() {
- String xpath = "/new/path";
- m_info.setTableXPath(xpath);
- assertEquals(xpath, m_info.getTableXPath());
- m_info.setTableXPath("");
- assertNull(m_info.getTableXPath());
- }
-
- public void testSetRequestedColumns() {
- String reqCol = "Company_id";
- ArrayList reqCols = new ArrayList();
- reqCols.add(reqCol);
- m_info.setRequestedColumns(reqCols);
- assertEquals(reqCol, m_info.getRequestedColumns().get(0));
- }
-
- public void testSetColumnCount() {
- final int count = 3;
- m_info.setColumnCount(count);
- assertEquals(count, m_info.getColumnCount());
-
- }
-
- public void testSetParameters() {
- String param = "[Company_id]";
- ArrayList params = new ArrayList();
- params.add(param);
- m_info.setParameters(params);
- assertEquals(param, m_info.getParameters().get(0));
- }
-
- public void testSetCriteria() {
- String crit = "Company_id";
- ArrayList crits = new ArrayList();
- crits.add(crit);
- m_info.setParameters(crits);
- assertEquals(crit, m_info.getParameters().get(0));
- }
-
- public void testSetOtherProperties() {
- String prop = "myProp";
- String key = "foo";
- Map<String, String> props = new HashMap<String, String>();
- props.put(key, prop);
- m_info.setOtherProperties(props);
- assertEquals(prop, m_info.getOtherProperties().get(key));
-
- m_info.setOtherProperties(null);
- assertNotNull("OtherProerties was set to null",
m_info.getOtherProperties());
- assertEquals(0, m_info.getOtherProperties().size());
- }
-
-}
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestOutputXPathDesc.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestOutputXPathDesc.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestOutputXPathDesc.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,172 +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.xml;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.teiid.language.ColumnReference;
-import org.teiid.language.Comparison;
-import org.teiid.language.Condition;
-import org.teiid.language.DerivedColumn;
-import org.teiid.language.Expression;
-import org.teiid.language.LanguageUtil;
-import org.teiid.language.Literal;
-import org.teiid.language.Select;
-import org.teiid.metadata.Column;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.xml.OutputXPathDesc;
-
-
-/**
- *
- */
-public class TestOutputXPathDesc extends TestCase {
-
-
- private static String vdbPath;
- private static final String QUERY = "select OutputColumn from CriteriaDescTable
where"
- + " OutputColumn in ('foo') order by OutputColumn";
-
- static {
- vdbPath = ProxyObjectFactory.getStateCollegeVDBLocation();
- }
-
-// removing hansel while testing clover
-
-/*
- public static Test suite() {
- return new CoverageDecorator(OutputXPathDescTest.class, new Class[]
{OutputXPathDesc.class});
- }
-*/
-
- /**
- * Constructor for OutputXPathDescTest.
- * @param arg0
- */
- public TestOutputXPathDesc(String arg0) {
- super(arg0);
- }
-
- /*
- * Class under test for void OutputXPathDesc(Element)
- */
- public void testOutputXPathDescElement() throws Exception {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- List symbols = query.getDerivedColumns();
- DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
- Expression expr = selectSymbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- Column element = ((ColumnReference) expr).getMetadataObject();
- OutputXPathDesc desc = new OutputXPathDesc(element);
- assertNull(desc.getCurrentValue());
- assertNotNull(desc.getDataType());;
- }
-
- public void testOutputXPathDescParam() throws Exception {
- String query = "select RequiredDefaultedParam from CriteriaDescTable where
RequiredDefaultedParam in ('foo')";
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- Column element = ((ColumnReference) expr).getMetadataObject();
- OutputXPathDesc desc = new OutputXPathDesc(element);
- assertNotNull("OutputXPathDesc is null", desc);
- }
-
-
- public void testOutputXPathDescNoXPath() throws Exception {
- try {
- String query = "select OutputColumnNoXPath from CriteriaDescTable";
- Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- final int colLocation = 0;
- DerivedColumn symbol = (DerivedColumn)
iquery.getDerivedColumns().get(colLocation);
- Expression expr = symbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- Column element = ((ColumnReference) expr).getMetadataObject();
- OutputXPathDesc desc = new OutputXPathDesc(element);
- fail("should not be able to create OuputXPathDesc with no XPath");
- } catch (TranslatorException ce) {
- return;
- }
- }
- /*
- * Class under test for void OutputXPathDesc(ILiteral)
- */
- public void testOutputXPathDescILiteral() throws Exception {
- String strLiteral = "MetaMatrix";
- String strQuery = "Select Company_id from Company where Company_id =
'" + strLiteral + "'";
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
- Condition crits = query.getWhere();
- List criteriaList = LanguageUtil.separateCriteriaByAnd(crits);
- Comparison compCriteria = (Comparison) criteriaList.get(0);
- Literal literal = (Literal) compCriteria.getRightExpression();
- OutputXPathDesc desc = new OutputXPathDesc(literal);
- assertNotNull(desc);
- assertEquals(strLiteral, desc.getCurrentValue().toString());
- assertEquals(strLiteral.getClass(), desc.getDataType());
- }
-
- public void testOutputXPathDescILiteralNullValue() throws Exception {
- String strLiteral = "MetaMatrix";
- String strQuery = "Select Company_id from Company where Company_id =
'" + strLiteral + "'";
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
- Condition crits = query.getWhere();
- List criteriaList = LanguageUtil.separateCriteriaByAnd(crits);
- Comparison compCriteria = (Comparison) criteriaList.get(0);
- Literal literal = (Literal) compCriteria.getRightExpression();
- literal.setValue(null);
- OutputXPathDesc desc = new OutputXPathDesc(literal);
- assertNotNull(desc);
- assertNull(desc.getCurrentValue());
- assertEquals(strLiteral.getClass(), desc.getDataType());
- }
-
- public void testSetAndGetCurrentValue() throws Exception {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- List symbols = query.getDerivedColumns();
- DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
- Expression expr = selectSymbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- Column element = ((ColumnReference) expr).getMetadataObject();
- OutputXPathDesc desc = new OutputXPathDesc(element);
- String myVal = "myValue";
- desc.setCurrentValue(myVal);
- assertEquals(myVal, desc.getCurrentValue());
- }
-
- public void testGetDataType() throws Exception {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- List symbols = query.getDerivedColumns();
- DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
- Expression expr = selectSymbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- Column element = ((ColumnReference) expr).getMetadataObject();
- OutputXPathDesc desc = new OutputXPathDesc(element);
- assertNotNull(desc.getDataType());
- assertEquals(String.class, desc.getDataType());
- }
-
-}
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestParameterDescriptor.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestParameterDescriptor.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestParameterDescriptor.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,200 +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.xml;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.teiid.language.ColumnReference;
-import org.teiid.language.DerivedColumn;
-import org.teiid.language.Expression;
-import org.teiid.language.Select;
-import org.teiid.metadata.Column;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.xml.ParameterDescriptor;
-
-
-/**
- *
- */
-public class TestParameterDescriptor extends TestCase {
-
- private static String vdbPath;
- private static final String QUERY = "select OutputColumn from CriteriaDescTable
where"
- + " OutputColumn in ('MetaMatrix') order by OutputColumn";
-
-
- static {
- vdbPath = ProxyObjectFactory.getStateCollegeVDBLocation();
- }
-
-
-// removing hansel while testing clover
-/*
- public static Test suite() {
- return new CoverageDecorator(ParameterDescriptorTest.class, new Class[]
{ParameterDescriptor.class});
- }
-
-*/
- /**
- * Constructor for ParameterDescriptorTest.
- * @param arg0
- */
- public TestParameterDescriptor(String arg0) {
- super(arg0);
- }
-
- /*
- * Class under test for void ParameterDescriptor(Element)
- */
- public void testParameterDescriptorElement() throws Exception {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- List symbols = query.getDerivedColumns();
- DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
- Expression expr = selectSymbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- Column element = ((ColumnReference) expr).getMetadataObject();
- ParameterDescriptor desc = new ParameterDescriptorImpl(element);
- assertNotNull(desc);
- }
-
-
- public void testParameterDescriptorElementParameter() throws Exception {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, "select
RequiredDefaultedParam from CriteriaDescTable");
- List symbols = query.getDerivedColumns();
- DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
- Expression expr = selectSymbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- Column element = ((ColumnReference) expr).getMetadataObject();
- ParameterDescriptor desc = new ParameterDescriptorImpl(element);
- assertNotNull(desc);
- }
-
-
-
- public void testParameterDescriptorElementSpaceXPath() throws Exception {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, "select
OutputColumnSpaceXPath from CriteriaDescTable");
- List symbols = query.getDerivedColumns();
- DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
- Expression expr = selectSymbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- Column element = ((ColumnReference) expr).getMetadataObject();
- ParameterDescriptor desc = new ParameterDescriptorImpl(element);
- assertNotNull(desc);
- }
-
- /*
- * Class under test for void ParameterDescriptor(ILiteral)
- */
- public void testParameterDescriptor() {
- ParameterDescriptor desc = new ParameterDescriptorImpl();
- assertNotNull(desc);
- assertNull(desc.getXPath());
- assertFalse(desc.isParameter());
- assertNull(desc.getColumnName());
- }
-
- public void testSetGetXPath() throws Exception {
- ParameterDescriptor desc = getParameterDescriptor();
- String xpath = "/foo";
- desc.setXPath(xpath);
- assertEquals(xpath, desc.getXPath());
- }
-
- public void testSetIsParameter() throws Exception {
- ParameterDescriptor desc = getParameterDescriptor();
- boolean is = !desc.isParameter();
- desc.setIsParameter(is);
- assertEquals(is, desc.isParameter());
- }
-
- public void testSetGetColumnName() throws Exception {
- ParameterDescriptor desc = getParameterDescriptor();
- String name = "myColumn";
- desc.setColumnName(name);
- assertEquals(name, desc.getColumnName());
- }
-
- public void testSetGetColumnNumber() throws Exception {
- ParameterDescriptor desc = getParameterDescriptor();
- int number = desc.getColumnNumber() + 1;
- desc.setColumnNumber(number);
- assertEquals(number, desc.getColumnNumber());
- }
-
- public void testGetElement() throws Exception {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- List symbols = query.getDerivedColumns();
- DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
- Expression expr = selectSymbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- Column element = ((ColumnReference) expr).getMetadataObject();
- ParameterDescriptor desc = new ParameterDescriptorImpl(element);
- assertEquals(element, desc.getElement());
- }
-
- public void testTestForParam() throws Exception {
- String trueQuery = "select EmptyCol from EmptyTable where EmptyCol =
'foo'";
- String falseQuery = "select Company_id from Company";
-
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, trueQuery);
- List symbols = query.getDerivedColumns();
- DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
- Expression expr = selectSymbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- Column element = ((ColumnReference) expr).getMetadataObject();
- assertTrue(ParameterDescriptor.testForParam(element));
-
- query = ProxyObjectFactory.getDefaultIQuery(vdbPath, falseQuery);
- symbols = query.getDerivedColumns();
- selectSymbol = (DerivedColumn) symbols.get(0);
- expr = selectSymbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- element = ((ColumnReference) expr).getMetadataObject();
- assertFalse(ParameterDescriptor.testForParam(element));
- }
-
- private ParameterDescriptor getParameterDescriptor() throws Exception {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- List symbols = query.getDerivedColumns();
- DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
- Expression expr = selectSymbol.getExpression();
- assertTrue(expr instanceof ColumnReference);
- Column element = ((ColumnReference) expr).getMetadataObject();
- ParameterDescriptor desc = new ParameterDescriptorImpl(element);
- assertNotNull(desc);
- return desc;
- }
-
- private class ParameterDescriptorImpl extends ParameterDescriptor {
- public ParameterDescriptorImpl() {
- super();
- }
-
- public ParameterDescriptorImpl(Column element) throws TranslatorException {
- super(element);
- }
-
- }
-}
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestQueryAnalyzer.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestQueryAnalyzer.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestQueryAnalyzer.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,165 +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.xml;
-
-
-
-import junit.framework.TestCase;
-
-import org.teiid.language.Select;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.xml.ExecutionInfo;
-import org.teiid.translator.xml.QueryAnalyzer;
-
-/**
- *
- */
-public class TestQueryAnalyzer extends TestCase {
-
- private static String vdbPath;
- private static final String QUERY = "select SimpleOutput from SimpleTable where
SimpleOutput = 'MetaMatrix' order by SimpleOutput";
-
- static {
- vdbPath = ProxyObjectFactory.getStateCollegeVDBLocation();
- }
-
-// removing hansel while testing clover
-/*
- public static Test suite() {
- return new CoverageDecorator(QueryAnalyzerTest.class, new Class[]
{QueryAnalyzer.class});
- }
-
-*/
- /**
- * Constructor for QueryAnalyzerTest.
- * @param arg0
- */
- public TestQueryAnalyzer(String arg0) {
- super(arg0);
- }
-
- public void testQueryAnalyzer() {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- try {
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- assertNotNull("analyzer is null", analyzer);
- } catch (TranslatorException e) {
- fail(e.getMessage());
- }
- }
-
- public void testAnalyze() {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- try {
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- analyzer.analyze();
- } catch (TranslatorException e) {
- fail(e.getMessage());
- }
- }
-
- public void testAnalyzeSimpleSelect() {
- String strQuery = "select SimpleOutput from SimpleTable";
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
- try {
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- analyzer.analyze();
- } catch (TranslatorException e) {
- fail(e.getMessage());
- }
- }
-
- public void testAnalyzeLiteralSelect() {
- String strQuery = "select SimpleOutput, 'foo' from SimpleTable";
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
- try {
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- analyzer.analyze();
- } catch (TranslatorException e) {
- fail(e.getMessage());
- }
- }
-
- public void testAnalyzeFunctionSelect() {
- String strQuery = "select concat(SimpleOutput, 'foo') from
SimpleTable";
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
- try {
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- analyzer.analyze();
- } catch (TranslatorException e) {
- fail(e.getMessage());
- }
- }
-
- public void testAnalyzeParameterSelect() {
- String strQuery = "select SimpleParam from SimpleInput where SimpleParam in
('foo')";
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
- try {
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- analyzer.analyze();
- } catch (TranslatorException e) {
- fail(e.getMessage());
- }
- }
-
- public void testAnalyzeComplexQuery() {
- String strQuery = "select SimpleOut from SimpleInput where SimpleParam in
('foo')";
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
- try {
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- analyzer.analyze();
- } catch (TranslatorException e) {
- fail(e.getMessage());
- }
- }
-
- public void testAnalyzeComplexQuery2() {
- String strQuery = "select SimpleOut from SimpleInput where SimpleParam in
('foo') and OtherOut in ('bar')";
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
- try {
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- analyzer.analyze();
- } catch (TranslatorException e) {
- fail(e.getMessage());
- }
- }
-
- public void testGetExecutionInfo() {
- Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- try {
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- assertNotNull("analyzer is null", analyzer);
- ExecutionInfo base = analyzer.getExecutionInfo();
- assertEquals(1, base.getColumnCount());
- analyzer.analyze();
- ExecutionInfo post = analyzer.getExecutionInfo();
- assertTrue(post.getColumnCount() > 0);
- assertEquals(1, post.getCriteria().size());
- assertEquals(1, post.getRequestedColumns().size());
- assertNotNull(post.getTableXPath());
- } catch (TranslatorException e) {
- fail(e.getMessage());
- }
-
- }
-}
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestXMLCapabilities.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestXMLCapabilities.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestXMLCapabilities.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,195 +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.xml;
-
-import org.teiid.translator.xml.XMLExecutionFactory;
-
-import junit.framework.TestCase;
-
-
-/**
- *
- */
-public class TestXMLCapabilities extends TestCase {
-
-
- private XMLExecutionFactory m_caps = null;
- /**
- * Constructor for XMLCapabilitiesTest.
- * @param arg0
- */
- public TestXMLCapabilities(String arg0) {
- super(arg0);
- }
-
- @Override
- public void setUp() {
- m_caps = new XMLExecutionFactory();
-
- }
-
- public void testGetMaxInCriteriaSize() {
- assertEquals(Integer.MAX_VALUE, m_caps.getMaxInCriteriaSize());
- }
-
- public void testSupportsCompareCriteriaEquals() {
- assertTrue(m_caps.supportsCompareCriteriaEquals());
- }
-
- public void testSupportsInCriteria() {
- assertTrue(m_caps.supportsInCriteria());
- }
-
- public void testXMLCapabilities() {
- XMLExecutionFactory caps = new XMLExecutionFactory();
- assertNotNull(caps);
- }
-
- /*
- * Class under test for List getSupportedFunctions()
- */
- public void testGetSupportedFunctions() {
- assertNotNull(m_caps.getSupportedFunctions());
- }
-
- public void testSupportsSelectDistinct() {
- assertFalse(m_caps.supportsSelectDistinct());
- }
-
- public void testSupportsAliasedGroup() {
- assertFalse(m_caps.supportsAliasedTable());
- }
-
- public void testSupportsJoins() {
- assertFalse(m_caps.supportsInnerJoins());
- }
-
- public void testSupportsSelfJoins() {
- assertFalse(m_caps.supportsSelfJoins());
- }
-
- public void testSupportsOuterJoins() {
- assertFalse(m_caps.supportsOuterJoins());
- }
-
- public void testSupportsFullOuterJoins() {
- assertFalse(m_caps.supportsFullOuterJoins());
- }
-
- public void testSupportsBetweenCriteria() {
- assertFalse(m_caps.supportsBetweenCriteria());
- }
-
- public void testSupportsLikeCriteria() {
- assertFalse(m_caps.supportsLikeCriteria());
- }
-
- public void testSupportsLikeCriteriaEscapeCharacter() {
- assertFalse(m_caps.supportsLikeCriteriaEscapeCharacter());
- }
-
- public void testSupportsInCriteriaSubquery() {
- assertFalse(m_caps.supportsInCriteriaSubquery());
- }
-
- public void testSupportsIsNullCriteria() {
- assertFalse(m_caps.supportsIsNullCriteria());
- }
-
- public void testSupportsOrCriteria() {
- assertFalse(m_caps.supportsOrCriteria());
- }
-
- public void testSupportsNotCriteria() {
- assertFalse(m_caps.supportsNotCriteria());
- }
-
- public void testSupportsExistsCriteria() {
- assertFalse(m_caps.supportsExistsCriteria());
- }
-
- public void testSupportsQuantifiedCompareCriteriaSome() {
- assertFalse(m_caps.supportsQuantifiedCompareCriteriaSome());
- }
-
- public void testSupportsQuantifiedCompareCriteriaAll() {
- assertFalse(m_caps.supportsQuantifiedCompareCriteriaAll());
- }
-
- public void testSupportsOrderBy() {
- assertFalse(m_caps.supportsOrderBy());
- }
-
- public void testSupportsAggregatesSum() {
- assertFalse(m_caps.supportsAggregatesSum());
- }
-
- public void testSupportsAggregatesAvg() {
- assertFalse(m_caps.supportsAggregatesAvg());
- }
-
- public void testSupportsAggregatesMin() {
- assertFalse(m_caps.supportsAggregatesMin());
- }
-
- public void testSupportsAggregatesMax() {
- assertFalse(m_caps.supportsAggregatesMax());
- }
-
- public void testSupportsAggregatesCount() {
- assertFalse(m_caps.supportsAggregatesCount());
- }
-
- public void testSupportsAggregatesCountStar() {
- assertFalse(m_caps.supportsAggregatesCountStar());
- }
-
- public void testSupportsAggregatesDistinct() {
- assertFalse(m_caps.supportsAggregatesDistinct());
- }
-
- public void testSupportsScalarSubqueries() {
- assertFalse(m_caps.supportsScalarSubqueries());
- }
-
- public void testSupportsCorrelatedSubqueries() {
- assertFalse(m_caps.supportsCorrelatedSubqueries());
- }
-
- public void testSupportsCaseExpressions() {
- assertFalse(m_caps.supportsCaseExpressions());
- }
-
- public void testSupportsSearchedCaseExpressions() {
- assertFalse(m_caps.supportsSearchedCaseExpressions());
- }
-
- public void testSupportsInlineViews() {
- assertFalse(m_caps.supportsInlineViews());
- }
-
- public void testSupportsUnions() {
- assertFalse(m_caps.supportsUnions());
- }
-
-}
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestXMLReaderFactory.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestXMLReaderFactory.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestXMLReaderFactory.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,19 +0,0 @@
-package org.teiid.translator.xml;
-
-import junit.framework.TestCase;
-
-import org.teiid.translator.xml.streaming.ReaderFactory;
-import org.xml.sax.XMLReader;
-
-
-public class TestXMLReaderFactory extends TestCase {
-
- public void testGetSAXBuilder() {
- try {
- XMLReader reader = ReaderFactory.getXMLReader(null);
- assertNotNull(reader);
- } catch (Exception e) {
- fail(e.getMessage());
- }
- }
-}
Deleted:
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestXPathSplitter.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestXPathSplitter.java 2010-06-08
14:41:59 UTC (rev 2192)
+++
trunk/connectors/translator-ws/src/test/java/org/teiid/translator/xml/TestXPathSplitter.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,88 +0,0 @@
-package org.teiid.translator.xml;
-
-import java.util.List;
-
-import org.teiid.translator.xml.streaming.InvalidPathException;
-import org.teiid.translator.xml.streaming.XPathSplitter;
-
-import junit.framework.TestCase;
-
-
-public class TestXPathSplitter extends TestCase {
-
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /**
- * ((((/po:purchaseOrder) | (/po:purchaseOrders/order))/items) |
(/po:purchaseOrder/items3) | (/po:purchaseOrders/order/items4))/item
- *
- * becomes
- * /po:purchaseOrder/items/item
- * /po:purchaseOrders/order/items/item
- * /po:purchaseOrder/items/item
- * /po:purchaseOrders/order/items/item
- * becomes
- *
- * /po:purchaseOrder/items/item
- * /po:purchaseOrders/order/items/item
- */
- public void testSplit() {
- XPathSplitter splitter = new XPathSplitter();
- try {
- List paths = splitter.split("((((/po:purchaseOrder) |
(/po:purchaseOrders/order))/items) | (/po:purchaseOrder/items) |
(/po:purchaseOrders/order/items))/item");
- assertEquals(2, paths.size());
- } catch (InvalidPathException e) {
- fail(e.getMessage());
- }
- }
-
- public void testSplitSimple() {
- XPathSplitter splitter = new XPathSplitter();
- try {
- List paths = splitter.split("/po:purchaseOrders/order/items/item");
- assertEquals(1, paths.size());
- } catch (InvalidPathException e) {
- fail(e.getMessage());
- }
- }
-
- public void testSplitCompund() {
- XPathSplitter splitter = new XPathSplitter();
- try {
- List paths =
splitter.split("(/po:purchaseOrders/order/items/item)|(/po:purchaseOrders/order/items)");
- assertEquals(2, paths.size());
- } catch (InvalidPathException e) {
- fail(e.getMessage());
- }
- }
-
- public void testSplitCompund2() {
- XPathSplitter splitter = new XPathSplitter();
- try {
- List paths =
splitter.split("(/po:purchaseOrders/order/items/item)|((/po:purchaseOrders/order/items)|(/po:purchaseOrders/order/item))");
- assertEquals(3, paths.size());
- } catch (InvalidPathException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- *
((/po:purchaseOrders/order/items)|(/po:purchaseOrders/order/item))|((/po:purchaseOrders/order/items)|(/po:purchaseOrders/order/item))
- *
- * /po:purchaseOrders/order/items
- * /po:purchaseOrders/order/item
- *
- */
- public void testSplitCompund3() {
- XPathSplitter splitter = new XPathSplitter();
- try {
- List paths =
splitter.split("((/po:purchaseOrders/order/items)|(/po:purchaseOrders/order/item))|((/po:purchaseOrders/order/items)|(/po:purchaseOrders/order/item))");
- assertEquals(2, paths.size());
- } catch (InvalidPathException e) {
- fail(e.getMessage());
- }
- }
-}
Deleted: trunk/connectors/translator-ws/src/test/resources/BookCollection.xml
===================================================================
--- trunk/connectors/translator-xml/src/test/resources/BookCollection.xml 2010-06-08
14:41:59 UTC (rev 2192)
+++ trunk/connectors/translator-ws/src/test/resources/BookCollection.xml 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1,543 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?><Books:bookCollection
xmlns:Books="http://www.metamatrix.com/XMLSchema/DataSets/Books"...
-<!--
-
- 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.
-
--->
-
- <book isbn="0-7356-0877-7">
- <title>After the Gold Rush</title>
- <subtitle>Creating a True Profession of Software
Engineering</subtitle>
- <edition>1</edition>
- <authors>
- <author>McConnell</author>
- </authors>
- <publishingInformation>
- <publisher>Microsoft Press</publisher>
- <publishDate>1999</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-55615-484-4">
- <title>Code Complete</title>
- <subtitle>A Practical Handbook of Software Construction</subtitle>
- <edition>1</edition>
- <authors>
- <author>McConnell</author>
- </authors>
- <publishingInformation>
- <publisher>Microsoft Press</publisher>
- <publishDate>1993</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-556-15900-5">
- <title>Rapid Development</title>
- <subtitle>Taming Wild Software Schedules</subtitle>
- <edition>1</edition>
- <authors>
- <author>McConnell</author>
- </authors>
- <publishingInformation>
- <publisher>Microsoft Press</publisher>
- <publishDate>1996</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-7356-0631-5">
- <title>Software Requirements</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Wiegers</author>
- </authors>
- <publishingInformation>
- <publisher>Microsoft Press</publisher>
- <publishDate>1999</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-57231-621-7">
- <title>Software Project Survival Guide</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>McConnell</author>
- </authors>
- <publishingInformation>
- <publisher>Microsoft Press</publisher>
- <publishDate>1998</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-201-43287-0">
- <title>Automated Software Testing</title>
- <subtitle>Introduction, Management, and Performance</subtitle>
- <edition>1</edition>
- <authors>
- <author>Dustin</author>
- <author>Rashka</author>
- <author>Paul</author>
- </authors>
- <publishingInformation>
- <publisher>Addison-Wesley</publisher>
- <publishDate>1999</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-201-31000-7">
- <title>Inside Java 2 Security</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Gong</author>
- </authors>
- <publishingInformation>
- <publisher>Addison-Wesley</publisher>
- <publishDate>1999</publishDate>
- </publishingInformation>
- </book>
- <book isbn="020130998X">
- <title>The Unified Modeling Language Reference Manual</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Rumbaugh</author>
- <author>Jacobson</author>
- <author>Booch</author>
- </authors>
- <publishingInformation>
- <publisher>Addison-Wesley</publisher>
- <publishDate>1998</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-201-70225-8">
- <title>Writing Effective Use Cases</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Cockburn</author>
- </authors>
- <publishingInformation>
- <publisher>Addison-Wesley</publisher>
- <publishDate>2001</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0201877562">
- <title>Software Testing in the Real World</title>
- <subtitle>Improving the Process</subtitle>
- <edition>1</edition>
- <authors>
- <author>Kit</author>
- <author>Finzi</author>
- </authors>
- <publishingInformation>
- <publisher>Addison-Wesley</publisher>
- <publishDate>1995</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-201-43336-2">
- <title>SQL Queries for Mere Mortals</title>
- <subtitle>A Hands-on Guide to Data Manipulation in SQL</subtitle>
- <edition>1</edition>
- <authors>
- <author>Hernandez</author>
- <author>Viescas</author>
- </authors>
- <publishingInformation>
- <publisher>Addison-Wesley</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-201-65758-9">
- <title>LDAP Programming with Java</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Weltman</author>
- <author>Dahbura</author>
- </authors>
- <publishingInformation>
- <publisher>Addison-Wesley</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-201-44787-8">
- <title>The Practical SQL Handbook</title>
- <subtitle>Using Structured Query Language</subtitle>
- <edition>1</edition>
- <authors>
- <author>Bowman</author>
- <author>Emerson</author>
- <author>Darnovsky</author>
- </authors>
- <publishingInformation>
- <publisher>Addison-Wesley</publisher>
- <publishDate>1996</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-201-10088-6">
- <title>Compilers</title>
- <subtitle>Principles, Techniques, and Tools</subtitle>
- <edition>1</edition>
- <authors>
- <author>Aho</author>
- <author>Sethi</author>
- <author>Ullman</author>
- </authors>
- <publishingInformation>
- <publisher>Addison-Wesley</publisher>
- <publishDate>1985</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-201-31009-0">
- <title>Concurrent Programming in Java</title>
- <subtitle>Design Principles and Patterns</subtitle>
- <edition>2</edition>
- <authors>
- <author>Lea</author>
- </authors>
- <publishingInformation>
- <publisher>Addison-Wesley</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-471-98710-7">
- <title>Concurrency State Models & Java Programs</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Kramer</author>
- <author>Magee</author>
- </authors>
- <publishingInformation>
- <publisher>Wiley</publisher>
- <publishDate>1999</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-471355232">
- <title>Building and Managing the Meta Data Repository</title>
- <subtitle>A Full Life-Cycle Guide</subtitle>
- <edition>1</edition>
- <authors>
- <author>Marco</author>
- </authors>
- <publishingInformation>
- <publisher>Wiley</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-7897-2271-2">
- <title>Complete Idiot's Guide to Project Management with Microsoft
Project 2000</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Black</author>
- </authors>
- <publishingInformation>
- <publisher>Que</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-932633-33-1">
- <title>Creating a Software Engineering Culture</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Wiegers</author>
- </authors>
- <publishingInformation>
- <publisher>Dorset House Publishing</publisher>
- <publishDate>1996</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-932633-43-9">
- <title>Peopleware</title>
- <subtitle>Productive Projects and Teams</subtitle>
- <edition>2</edition>
- <authors>
- <author>DeMarco</author>
- <author>Lister</author>
- </authors>
- <publishingInformation>
- <publisher>Dorset House Publishing</publisher>
- <publishDate>1999</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1558605150">
- <title>Database Design for Smarties</title>
- <subtitle>Using UML for Data Modeling</subtitle>
- <edition>1</edition>
- <authors>
- <author>Muller</author>
- </authors>
- <publishingInformation>
- <publisher>Morgan Kaufman</publisher>
- <publishDate>1999</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-558-60190-2">
- <title>Transaction Processing</title>
- <subtitle>Concepts and Techniques</subtitle>
- <edition>1</edition>
- <authors>
- <author>Gray</author>
- </authors>
- <publishingInformation>
- <publisher>Morgan Kaufman</publisher>
- <publishDate>1992</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-55860-415-4">
- <title>Principles of Transaction Processing</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Bernstein</author>
- <author>Newcomer</author>
- </authors>
- <publishingInformation>
- <publisher>Morgan Kaufman</publisher>
- <publishDate>1997</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1558605231">
- <title>Readings in Database Systems</title>
- <subtitle/>
- <edition>3</edition>
- <authors>
- <author>Stonebraker</author>
- <author>Hellerstein</author>
- </authors>
- <publishingInformation>
- <publisher>Morgan Kaufman</publisher>
- <publishDate>1998</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-13-239856-7">
- <title>How to Run Successful Projects II</title>
- <subtitle/>
- <edition>2</edition>
- <authors>
- <author>O'Connell</author>
- </authors>
- <publishingInformation>
- <publisher>Prentice Hall</publisher>
- <publishDate>1996</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-13-014714-1">
- <title>The XML Handbook</title>
- <subtitle/>
- <edition>2</edition>
- <authors>
- <author>Goldfarb</author>
- <author>Prescod</author>
- </authors>
- <publishingInformation>
- <publisher>Prentice Hall</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0130273635">
- <title>Thinking in Java</title>
- <subtitle/>
- <edition>2</edition>
- <authors>
- <author>Eckel</author>
- </authors>
- <publishingInformation>
- <publisher>Prentice Hall</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="130402648">
- <title>Database System Implementation</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Ullman</author>
- <author>Garcia-Molina</author>
- <author>Widom</author>
- </authors>
- <publishingInformation>
- <publisher>Prentice Hall</publisher>
- <publishDate>1999</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-596-00016-2">
- <title>Java and XML</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>McLaughlin</author>
- <author>Loukides</author>
- </authors>
- <publishingInformation>
- <publisher>O'Reilly</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-56592-487-8">
- <title>Java in a Nutshell</title>
- <subtitle/>
- <edition>3</edition>
- <authors>
- <author>Flanagan</author>
- </authors>
- <publishingInformation>
- <publisher>O'Reilly</publisher>
- <publishDate>1999</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-56592-483-5">
- <title>Java Enterprise in a Nutshell</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Flanagan</author>
- </authors>
- <publishingInformation>
- <publisher>O'Reilly</publisher>
- <publishDate>1999</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-672-31602-1">
- <title>Java Security Handbook</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Jaworski</author>
- <author>Perrone</author>
- </authors>
- <publishingInformation>
- <publisher>Sams</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-672-31983-7">
- <title>Software Testing</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Patton</author>
- </authors>
- <publishingInformation>
- <publisher>Sams</publisher>
- <publishDate>2001</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-861002-77-7">
- <title>Professional Java Server Programming</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Ayers</author>
- <author>Bergsten</author>
- <author>Diamond</author>
- </authors>
- <publishingInformation>
- <publisher>Wrox</publisher>
- <publishDate>1999</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-861-00506-7">
- <title>XSLT Programmer's Reference</title>
- <subtitle/>
- <edition>2</edition>
- <authors>
- <author>Kay</author>
- </authors>
- <publishingInformation>
- <publisher>Wrox</publisher>
- <publishDate>2001</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-861-00312-9">
- <title>XSLT Programmer's Reference</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Kay</author>
- </authors>
- <publishingInformation>
- <publisher>Wrox</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-818-68300-7">
- <title>The Software Project Manager's Handbook</title>
- <subtitle>Principles that Work</subtitle>
- <edition>1</edition>
- <authors>
- <author>Phillips</author>
- </authors>
- <publishingInformation>
- <publisher>IEEE Computer Society</publisher>
- <publishDate>1998</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-884777-84-8">
- <title>Swing</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Robinson</author>
- <author>Vorobiev</author>
- </authors>
- <publishingInformation>
- <publisher>Manning</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-893115-10-0">
- <title>Taming Java Threads</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Holub</author>
- </authors>
- <publishingInformation>
- <publisher>Apress</publisher>
- <publishDate>2000</publishDate>
- </publishingInformation>
- </book>
- <book isbn="1-57870-070-1">
- <title>Understanding and Deploying LDAP Directory Services</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Howes</author>
- <author>Smith</author>
- <author>Good</author>
- </authors>
- <publishingInformation>
- <publisher>Macmillan</publisher>
- <publishDate>1990</publishDate>
- </publishingInformation>
- </book>
- <book isbn="0-7821-1148-3">
- <title>SQL Instant Reference</title>
- <subtitle/>
- <edition>1</edition>
- <authors>
- <author>Gruber</author>
- </authors>
- <publishingInformation>
- <publisher>Sybex</publisher>
- <publishDate>1993</publishDate>
- </publishingInformation>
- </book>
-</Books:bookCollection>
\ No newline at end of file
Deleted: trunk/connectors/translator-ws/src/test/resources/cis.vdb
===================================================================
(Binary files differ)
Deleted: trunk/connectors/translator-ws/src/test/resources/xmltest.vdb
===================================================================
(Binary files differ)
Added: trunk/documentation/client-developers-guide/pom.xml
===================================================================
--- trunk/documentation/client-developers-guide/pom.xml (rev 0)
+++ trunk/documentation/client-developers-guide/pom.xml 2010-06-10 04:01:14 UTC (rev
2212)
@@ -0,0 +1,70 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.jboss.teiid.documentation</groupId>
+ <artifactId>documentation</artifactId>
+ <version>7.0.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>client-developers-guide</artifactId>
+ <packaging>jdocbook</packaging>
+ <name>Teiid Client Developers Guide</name>
+ <description>The Client Developers Guide</description>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.1.2</version>
+ <extensions>true</extensions>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-docbook-xslt</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-jdocbook-style</artifactId>
+ <version>1.1.0</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+ <configuration>
+ <sourceDocumentName>DataCaching.xml</sourceDocumentName>
+ <imageResource>
+ <directory>${basedir}/src/main/docbook/en-US</directory>
+ <excludes>
+ <exclude>*.xml</exclude>
+ <exclude>**/*.xml</exclude>
+ <exclude>*.zargo</exclude>
+ <exclude>**/*.zargo</exclude>
+ </excludes>
+ </imageResource>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+
<stylesheetResource>classpath:/xslt/org/jboss/pdf.xsl</stylesheetResource>
+ <finalName>client_developers_guide.pdf</finalName>
+ </format>
+ <!-- <format>
+ <formatName>html_single</formatName>
+
<stylesheetResource>classpath:/xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format> -->
+ <format>
+ <formatName>html</formatName>
+
<stylesheetResource>classpath:/xslt/org/jboss/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <localeSeparator>-</localeSeparator>
+ <useRelativeImageUris>false</useRelativeImageUris>
+ </options>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Property changes on: trunk/documentation/client-developers-guide/pom.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/ssl.xml
===================================================================
Property changes on:
trunk/documentation/client-developers-guide/src/main/docbook/en-US/content/ssl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
---
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1035,6 +1035,18 @@
<para>x in {string}</para>
</entry>
</row>
+ <row>
+ <entry>
+ <para>QUERYSTRING(path [, expr [AS name] ...])</para>
+ </entry>
+ <entry>
+ <para>Returns a properly encoded query string appended to the given
path. Null valued expressions are omitted, and a null path is treated as
''.</para>
+ <para>e.g. QUERYSTRING('path', 'value' as
"&x", ' & ' as y, null as z) returns
'path?%26x=value&y=%20%26%20'</para>
+ </entry>
+ <entry>
+ <para>path, expr in {string}. name is an identifier</para>
+ </entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
===================================================================
---
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-06-10
04:01:14 UTC (rev 2212)
@@ -832,7 +832,7 @@
<para>
Usage:
<synopsis label="Usage">XMLTABLE([<NSP>,]
xquery-expression [<PASSING>] [COLUMNS <COLUMN>, ... )] AS
name</synopsis>
- <synopsis label="Usage">COLUMN := name (FOR ORDINALITY |
(datatype [PATH string] [DEFAULT expression]))</synopsis>
+ <synopsis label="Usage">COLUMN := name (FOR ORDINALITY |
(datatype [DEFAULT expression] [PATH string]))</synopsis>
</para>
<para>See XMLELEMENT for the definition of NSP - <link
linkend="xmlnamespaces">XMLNAMESPACES</link>.</para>
<para>See XMLQUERY for the definition of <link
linkend="passing">PASSING</link>.</para>
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -133,7 +133,7 @@
MetadataFactory factory = new MetadataFactory(modelName, datatypes, importProperties);
ExecutionFactory executionFactory = getExecutionFactory();
Object connectionFactory = getConnectionFactory();
- Object connection = executionFactory.getConnection(executionFactory);
+ Object connection = executionFactory.getConnection(connectionFactory);
try {
executionFactory.getMetadata(factory, connection);
} finally {
Modified: trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2010-06-09 16:37:31 UTC
(rev 2211)
+++ trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2010-06-10 04:01:14 UTC
(rev 2212)
@@ -57,7 +57,6 @@
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.function.source.XMLSystemFunctions;
-import org.teiid.query.function.source.XMLSystemFunctions.NameValuePair;
import org.teiid.query.processor.ProcessorDataManager;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.lang.AbstractSetCriteria;
@@ -83,6 +82,7 @@
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.QueryString;
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.symbol.ScalarSubquery;
import org.teiid.query.sql.symbol.SearchedCaseExpression;
@@ -98,11 +98,22 @@
import org.teiid.query.util.CommandContext;
import org.teiid.query.util.ErrorMessageKeys;
import org.teiid.query.xquery.saxon.SaxonXQueryExpression;
+import org.teiid.translator.WSConnection.Util;
public class Evaluator {
- private final static char[] REGEX_RESERVED = new char[] {'$', '(',
')', '*', '.', '?', '[', '\\',
']', '^', '{', '|', '}'}; //in sorted order
+ public static class NameValuePair<T> {
+ public String name;
+ public T value;
+
+ public NameValuePair(String name, T value) {
+ this.name = name;
+ this.value = value;
+ }
+ }
+
+ private final static char[] REGEX_RESERVED = new char[] {'$', '(',
')', '*', '.', '?', '[', '\\',
']', '^', '{', '|', '}'}; //in sorted order
private final static MatchCriteria.PatternTranslator LIKE_TO_REGEX = new
MatchCriteria.PatternTranslator(".*", ".", REGEX_RESERVED,
'\\'); //$NON-NLS-1$ //$NON-NLS-2$
private Map elements;
@@ -580,71 +591,122 @@
} else if(expression instanceof ScalarSubquery) {
return evaluate((ScalarSubquery) expression, tuple);
} else if (expression instanceof XMLElement){
- XMLElement function = (XMLElement)expression;
- List<Expression> content = function.getContent();
+ return evaluateXMLElement(tuple, (XMLElement)expression);
+ } else if (expression instanceof XMLForest){
+ return evaluateXMLForest(tuple, (XMLForest)expression);
+ } else if (expression instanceof XMLSerialize){
+ return evaluateXMLSerialize(tuple, (XMLSerialize)expression);
+ } else if (expression instanceof XMLQuery) {
+ return evaluateXMLQuery(tuple, (XMLQuery)expression);
+ } else if (expression instanceof QueryString) {
+ return evaluateQueryString(tuple, (QueryString)expression);
+ } else {
+ throw new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0016,
QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0016,
expression.getClass().getName()));
+ }
+ }
+
+ //TODO: exception if length is too long?
+ private Object evaluateQueryString(List tuple, QueryString queryString)
+ throws ExpressionEvaluationException, BlockedException,
+ TeiidComponentException {
+ Evaluator.NameValuePair<Object>[] pairs = getNameValuePairs(tuple,
queryString.getArgs(), false);
+ String path = (String)internalEvaluate(queryString.getPath(), tuple);
+ if (path == null) {
+ path = ""; //$NON-NLS-1$
+ }
+ boolean appendedAny = false;
+ StringBuilder result = new StringBuilder();
+ for (Evaluator.NameValuePair<Object> nameValuePair : pairs) {
+ if (nameValuePair.value == null) {
+ continue;
+ }
+ if (appendedAny) {
+ result.append('&');
+ }
+ appendedAny = true;
+ result.append(Util.httpURLEncode(nameValuePair.name)).append('=').append(Util.httpURLEncode((String)nameValuePair.value));
+ }
+ if (!appendedAny) {
+ return path;
+ }
+ result.insert(0, '?');
+ result.insert(0, path);
+ return result.toString();
+ }
+
+ private Object evaluateXMLQuery(List tuple, XMLQuery xmlQuery)
+ throws BlockedException, TeiidComponentException,
+ FunctionExecutionException {
+ boolean emptyOnEmpty = true;
+ if (xmlQuery.getEmptyOnEmpty() != null) {
+ emptyOnEmpty = xmlQuery.getEmptyOnEmpty();
+ }
+ try {
+ SequenceIterator iter = evaluateXQuery(xmlQuery.getXQueryExpression(),
xmlQuery.getPassing(), tuple);
+ return xmlQuery.getXQueryExpression().createXMLType(iter, emptyOnEmpty);
+ } catch (TeiidProcessingException e) {
+ throw new FunctionExecutionException(e,
QueryPlugin.Util.getString("Evaluator.xmlquery", e.getMessage()));
//$NON-NLS-1$
+ } catch (XPathException e) {
+ throw new FunctionExecutionException(e,
QueryPlugin.Util.getString("Evaluator.xmlquery", e.getMessage()));
//$NON-NLS-1$
+ }
+ }
+
+ private Object evaluateXMLSerialize(List tuple, XMLSerialize xs)
+ throws ExpressionEvaluationException, BlockedException,
+ TeiidComponentException, FunctionExecutionException {
+ XMLType value = (XMLType) internalEvaluate(xs.getExpression(), tuple);
+ if (value == null) {
+ return null;
+ }
+ try {
+ if (!xs.isDocument()) {
+ return DataTypeManager.transformValue(value, xs.getType());
+ }
+ if (value.getType() == Type.UNKNOWN) {
+ Type type = StringToSQLXMLTransform.isXml(value.getCharacterStream());
+ value.setType(type);
+ }
+ if (value.getType() == Type.DOCUMENT || value.getType() == Type.ELEMENT) {
+ return DataTypeManager.transformValue(value, xs.getType());
+ }
+ } catch (SQLException e) {
+ throw new FunctionExecutionException(e, e.getMessage());
+ } catch (TransformationException e) {
+ throw new FunctionExecutionException(e, e.getMessage());
+ }
+ throw new
FunctionExecutionException(QueryPlugin.Util.getString("Evaluator.xmlserialize"));
//$NON-NLS-1$
+ }
+
+ private Object evaluateXMLForest(List tuple, XMLForest function)
+ throws ExpressionEvaluationException, BlockedException,
+ TeiidComponentException, FunctionExecutionException {
+ List<DerivedColumn> args = function.getArgs();
+ Evaluator.NameValuePair<Object>[] nameValuePairs = getNameValuePairs(tuple, args,
true);
+
+ try {
+ return XMLSystemFunctions.xmlForest(context, namespaces(function.getNamespaces()),
nameValuePairs);
+ } catch (TeiidProcessingException e) {
+ throw new FunctionExecutionException(e, e.getMessage());
+ }
+ }
+
+ private Object evaluateXMLElement(List tuple, XMLElement function)
+ throws ExpressionEvaluationException, BlockedException,
+ TeiidComponentException, FunctionExecutionException {
+ List<Expression> content = function.getContent();
List<Object> values = new ArrayList<Object>(content.size());
for (Expression exp : content) {
values.add(internalEvaluate(exp, tuple));
}
try {
- NameValuePair<Object>[] attributes = null;
+ Evaluator.NameValuePair<Object>[] attributes = null;
if (function.getAttributes() != null) {
- attributes = getNameValuePairs(tuple, function.getAttributes().getArgs());
+ attributes = getNameValuePairs(tuple, function.getAttributes().getArgs(), true);
}
return XMLSystemFunctions.xmlElement(context, function.getName(),
namespaces(function.getNamespaces()), attributes, values);
} catch (TeiidProcessingException e) {
throw new FunctionExecutionException(e, e.getMessage());
}
- } else if (expression instanceof XMLForest){
- XMLForest function = (XMLForest)expression;
- List<DerivedColumn> args = function.getArgs();
- NameValuePair<Object>[] nameValuePairs = getNameValuePairs(tuple, args);
-
- try {
- return XMLSystemFunctions.xmlForest(context, namespaces(function.getNamespaces()),
nameValuePairs);
- } catch (TeiidProcessingException e) {
- throw new FunctionExecutionException(e, e.getMessage());
- }
- } else if (expression instanceof XMLSerialize){
- XMLSerialize xs = (XMLSerialize)expression;
- XMLType value = (XMLType) internalEvaluate(xs.getExpression(), tuple);
- if (value == null) {
- return null;
- }
- try {
- if (!xs.isDocument()) {
- return DataTypeManager.transformValue(value, xs.getType());
- }
- if (value.getType() == Type.UNKNOWN) {
- Type type = StringToSQLXMLTransform.isXml(value.getCharacterStream());
- value.setType(type);
- }
- if (value.getType() == Type.DOCUMENT || value.getType() == Type.ELEMENT) {
- return DataTypeManager.transformValue(value, xs.getType());
- }
- } catch (SQLException e) {
- throw new FunctionExecutionException(e, e.getMessage());
- } catch (TransformationException e) {
- throw new FunctionExecutionException(e, e.getMessage());
- }
- throw new
FunctionExecutionException(QueryPlugin.Util.getString("Evaluator.xmlserialize"));
//$NON-NLS-1$
- } else if (expression instanceof XMLQuery) {
- XMLQuery xmlQuery = (XMLQuery)expression;
- boolean emptyOnEmpty = true;
- if (xmlQuery.getEmptyOnEmpty() != null) {
- emptyOnEmpty = xmlQuery.getEmptyOnEmpty();
- }
- try {
- SequenceIterator iter = evaluateXQuery(xmlQuery.getXQueryExpression(),
xmlQuery.getPassing(), tuple);
- return xmlQuery.getXQueryExpression().createXMLType(iter, emptyOnEmpty);
- } catch (TeiidProcessingException e) {
- throw new FunctionExecutionException(e,
QueryPlugin.Util.getString("Evaluator.xmlquery", e.getMessage()));
//$NON-NLS-1$
- } catch (XPathException e) {
- throw new FunctionExecutionException(e,
QueryPlugin.Util.getString("Evaluator.xmlquery", e.getMessage()));
//$NON-NLS-1$
- }
- } else {
- throw new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0016,
QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0016,
expression.getClass().getName()));
- }
}
public SequenceIterator evaluateXQuery(SaxonXQueryExpression xquery,
List<DerivedColumn> cols, List<?> tuple)
@@ -662,30 +724,33 @@
return xquery.evaluateXQuery(contextItem, parameters);
}
- private NameValuePair<Object>[] getNameValuePairs(List tuple,
List<DerivedColumn> args)
+ private Evaluator.NameValuePair<Object>[] getNameValuePairs(List tuple,
List<DerivedColumn> args, boolean xmlNames)
throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
- NameValuePair<Object>[] nameValuePairs = new NameValuePair[args.size()];
+ Evaluator.NameValuePair<Object>[] nameValuePairs = new
Evaluator.NameValuePair[args.size()];
for (int i = 0; i < args.size(); i++) {
DerivedColumn symbol = args.get(i);
String name = symbol.getAlias();
Expression ex = symbol.getExpression();
if (name == null && ex instanceof ElementSymbol) {
name = ((ElementSymbol)ex).getShortName();
+ if (xmlNames) {
+ name = XMLSystemFunctions.escapeName(name, true);
+ }
}
- nameValuePairs[i] = new NameValuePair<Object>(name, internalEvaluate(ex,
tuple));
+ nameValuePairs[i] = new Evaluator.NameValuePair<Object>(name,
internalEvaluate(ex, tuple));
}
return nameValuePairs;
}
- private NameValuePair<String>[] namespaces(XMLNamespaces namespaces) {
+ private Evaluator.NameValuePair<String>[] namespaces(XMLNamespaces namespaces) {
if (namespaces == null) {
return null;
}
List<NamespaceItem> args = namespaces.getNamespaceItems();
- NameValuePair<String>[] nameValuePairs = new NameValuePair[args.size()];
+ Evaluator.NameValuePair<String>[] nameValuePairs = new
Evaluator.NameValuePair[args.size()];
for(int i=0; i < args.size(); i++) {
NamespaceItem item = args.get(i);
- nameValuePairs[i] = new NameValuePair<String>(item.getPrefix(),
item.getUri());
+ nameValuePairs[i] = new Evaluator.NameValuePair<String>(item.getPrefix(),
item.getUri());
}
return nameValuePairs;
}
Modified:
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -57,6 +57,7 @@
import javax.xml.xpath.XPathExpressionException;
import net.sf.saxon.om.Item;
+import net.sf.saxon.om.Name11Checker;
import net.sf.saxon.sxpath.XPathEvaluator;
import net.sf.saxon.sxpath.XPathExpression;
import net.sf.saxon.trans.XPathException;
@@ -72,9 +73,11 @@
import org.teiid.core.types.XMLTranslator;
import org.teiid.core.types.XMLType;
import org.teiid.core.types.XMLType.Type;
+import org.teiid.query.eval.Evaluator;
import org.teiid.query.function.FunctionMethods;
import org.teiid.query.processor.xml.XMLUtil;
import org.teiid.query.util.CommandContext;
+import org.teiid.translator.WSConnection.Util;
/**
@@ -84,17 +87,7 @@
*/
public class XMLSystemFunctions {
- public static class NameValuePair<T> {
- String name;
- T value;
-
- public NameValuePair(String name, T value) {
- this.name = name;
- this.value = value;
- }
- }
-
- //YEAR 0 in the server timezone. used to determine negative years
+ //YEAR 0 in the server timezone. used to determine negative years
public static long YEAR_ZERO;
static String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
//$NON-NLS-1$
@@ -131,34 +124,14 @@
}, Streamable.STREAMING_BATCH_SIZE_IN_BYTES);
return DataTypeManager.transformValue(new XMLType(result),
DataTypeManager.DefaultDataClasses.CLOB);
} finally {
- closeSource(styleSource);
- closeSource(xmlSource);
+ Util.closeSource(styleSource);
+ Util.closeSource(xmlSource);
}
}
- private static void closeSource(final Source source) {
- if (!(source instanceof StreamSource)) {
- return;
- }
-
- StreamSource stream = (StreamSource)source;
- try {
- if (stream.getInputStream() != null) {
- stream.getInputStream().close();
- }
- } catch (IOException e) {
- }
- try {
- if (stream.getReader() != null) {
- stream.getReader().close();
- }
- } catch (IOException e) {
- }
- }
-
- public static XMLType xmlForest(final CommandContext context, final NameValuePair[]
namespaces, final NameValuePair[] values) throws TeiidComponentException,
TeiidProcessingException {
+ public static XMLType xmlForest(final CommandContext context, final
Evaluator.NameValuePair[] namespaces, final Evaluator.NameValuePair[] values) throws
TeiidComponentException, TeiidProcessingException {
boolean valueExists = false;
- for (NameValuePair nameValuePair : values) {
+ for (Evaluator.NameValuePair nameValuePair : values) {
if (nameValuePair.value != null) {
valueExists = true;
break;
@@ -177,7 +150,7 @@
XMLOutputFactory factory = XMLOutputFactory.newInstance();
XMLEventWriter eventWriter = factory.createXMLEventWriter(writer);
XMLEventFactory eventFactory = XMLEventFactory.newInstance();
- for (NameValuePair nameValuePair : values) {
+ for (Evaluator.NameValuePair nameValuePair : values) {
if (nameValuePair.value == null) {
continue;
}
@@ -202,7 +175,7 @@
* @throws TeiidProcessingException
*/
public static XMLType xmlElement(CommandContext context, final String name,
- final NameValuePair<String>[] namespaces, final NameValuePair<?>[]
attributes, final List<?> contents) throws TeiidComponentException,
TeiidProcessingException {
+ final Evaluator.NameValuePair<String>[] namespaces, final
Evaluator.NameValuePair<?>[] attributes, final List<?> contents) throws
TeiidComponentException, TeiidProcessingException {
XMLType result = new XMLType(XMLUtil.saveToBufferManager(context.getBufferManager(),
new XMLTranslator() {
@Override
@@ -224,10 +197,10 @@
}
private static void addElement(final String name, Writer writer, XMLEventWriter
eventWriter, XMLEventFactory eventFactory,
- NameValuePair<String> namespaces[], NameValuePair<?> attributes[],
List<?> contents) throws XMLStreamException, IOException, TransformerException {
+ Evaluator.NameValuePair<String> namespaces[], Evaluator.NameValuePair<?>
attributes[], List<?> contents) throws XMLStreamException, IOException,
TransformerException {
eventWriter.add(eventFactory.createStartElement("", null, name));
//$NON-NLS-1$
if (namespaces != null) {
- for (NameValuePair<String> nameValuePair : namespaces) {
+ for (Evaluator.NameValuePair<String> nameValuePair : namespaces) {
if (nameValuePair.name == null) {
if (nameValuePair.value == null) {
eventWriter.add(eventFactory.createNamespace(XMLConstants.NULL_NS_URI));
@@ -240,7 +213,7 @@
}
}
if (attributes != null) {
- for (NameValuePair<?> nameValuePair : attributes) {
+ for (Evaluator.NameValuePair<?> nameValuePair : attributes) {
if (nameValuePair.value != null) {
eventWriter.add(eventFactory.createAttribute(new QName(nameValuePair.name),
getStringValue(nameValuePair.value)));
}
@@ -464,7 +437,7 @@
// Return string representation of non-node value
return o.toString();
} finally {
- closeSource(s);
+ Util.closeSource(s);
}
}
@@ -483,4 +456,51 @@
eval.createExpression(xpath);
}
+ public static String escapeName(String name, boolean fully) {
+ StringBuilder sb = new StringBuilder();
+ char[] chars = name.toCharArray();
+ int i = 0;
+ if (fully && name.regionMatches(true, 0, "xml", 0, 3)) {
//$NON-NLS-1$
+ sb.append(escapeChar(name.charAt(0)));
+ sb.append(chars, 1, 2);
+ i = 3;
+ }
+ for (; i < chars.length; i++) {
+ char chr = chars[i];
+ switch (chr) {
+ case ':':
+ if (fully || i == 0) {
+ sb.append(escapeChar(chr));
+ continue;
+ }
+ break;
+ case '_':
+ if (chars.length > i && chars[i+1] == 'x') {
+ sb.append(escapeChar(chr));
+ continue;
+ }
+ break;
+ default:
+ //TODO: there should be handling for surrogates
+ // and invalid chars
+ if (i == 0) {
+ if (!Name11Checker.getInstance().isNCNameStartChar(chr)) {
+ sb.append(escapeChar(chr));
+ continue;
+ }
+ } else if (!Name11Checker.getInstance().isNCNameChar(chr)) {
+ sb.append(escapeChar(chr));
+ continue;
+ }
+ break;
+ }
+ sb.append(chr);
+ }
+ return sb.toString();
+ }
+
+ private static String escapeChar(char chr) {
+ return "_u00" + Integer.toHexString(chr).toUpperCase() + "_";
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataStore.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataStore.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -122,7 +122,7 @@
private TempMetadataID createElementSymbol(String tempName, SingleElementSymbol
symbol, boolean isTempTable) {
// Create new element name
- String elementName = tempName + SingleElementSymbol.SEPARATOR +
symbol.getShortCanonicalName();
+ String elementName = tempName + SingleElementSymbol.SEPARATOR +
symbol.getShortName();
Object metadataID = null;
Modified:
trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -49,7 +49,7 @@
}
/**
- * If the result set named rsName does not exist yet in the {@link
ProcessorEnvironment}, then
+ * If the result set named rsName does not exist yet in the {@link ProcedurePlan},
then
* this instruction will define that result set. It will then throw a
BlockedException if
* this result set is selecting from other than temp groups (because those results
will be
* delivered asynchronously). IF the result set named rsName does already exist,
this
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -243,6 +243,10 @@
return null;
}
+ if (!(constant.getValue() instanceof Comparable)) {
+ return null; //this is the case for xml constants
+ }
+
Constant reverse = getProperlyTypedConstant(result.getValue(),
constant.getType());
if (((Comparable)constant.getValue()).compareTo(reverse.getValue()) == 0) {
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -58,10 +58,12 @@
import org.teiid.query.sql.navigator.PostOrderNavigator;
import org.teiid.query.sql.symbol.CaseExpression;
import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.DerivedColumn;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.Function;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.QueryString;
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.symbol.SearchedCaseExpression;
import org.teiid.query.sql.symbol.XMLQuery;
@@ -348,6 +350,18 @@
handleException(e);
}
}
+
+ @Override
+ public void visit(QueryString obj) {
+ try {
+ obj.setPath(ResolverUtil.convertExpression(obj.getPath(),
DataTypeManager.DefaultDataTypes.STRING, metadata));
+ for (DerivedColumn col : obj.getArgs()) {
+ col.setExpression(ResolverUtil.convertExpression(col.getExpression(),
DataTypeManager.DefaultDataTypes.STRING, metadata));
+ }
+ } catch (QueryResolverException e) {
+ handleException(new QueryResolverException(e,
QueryPlugin.Util.getString("XMLQuery.resolvingError", obj))); //$NON-NLS-1$
+ }
+ }
public TeiidComponentException getComponentException() {
return this.componentException;
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -134,6 +134,7 @@
import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.Function;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.QueryString;
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.symbol.ScalarSubquery;
import org.teiid.query.sql.symbol.SearchedCaseExpression;
@@ -1912,6 +1913,8 @@
rewriteExpressions(expression);
} else if (expression instanceof XMLQuery) {
rewriteExpressions(expression);
+ } else if (expression instanceof QueryString) {
+ rewriteExpressions(expression);
}
if(dataMgr == null) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -134,4 +134,5 @@
public void visit(DerivedColumn obj) {}
public void visit(XMLSerialize obj) {}
public void visit(XMLQuery obj) {}
+ public void visit(QueryString obj) {}
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java 2010-06-09 16:37:31
UTC (rev 2211)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/XMLTable.java 2010-06-10 04:01:14
UTC (rev 2212)
@@ -172,6 +172,7 @@
@Override
public XMLTable clone() {
XMLTable clone = new XMLTable();
+ this.copy(clone);
for (XMLColumn column : columns) {
clone.getColumns().add(column.clone());
}
Modified:
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -91,6 +91,7 @@
import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.Function;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.QueryString;
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.symbol.ScalarSubquery;
import org.teiid.query.sql.symbol.SearchedCaseExpression;
@@ -584,6 +585,14 @@
postVisitVisitor(obj);
}
+ @Override
+ public void visit(QueryString obj) {
+ preVisitVisitor(obj);
+ visitNode(obj.getPath());
+ visitNodes(obj.getArgs());
+ postVisitVisitor(obj);
+ }
+
public static void doVisit(LanguageObject object, LanguageVisitor visitor, boolean
order) {
PreOrPostOrderNavigator nav = new PreOrPostOrderNavigator(visitor, order);
object.acceptVisitor(nav);
Added: trunk/engine/src/main/java/org/teiid/query/sql/symbol/QueryString.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/QueryString.java
(rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/QueryString.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.sql.symbol;
+
+import java.util.List;
+
+import org.teiid.core.types.DataTypeManager.DefaultDataClasses;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
+/**
+ * Represents XMLATTRIBUTES name value pairs
+ */
+public class QueryString implements Expression {
+
+ private static final long serialVersionUID = -3348922701950966494L;
+ private List<DerivedColumn> args;
+ private Expression path;
+
+ public QueryString(Expression path, List<DerivedColumn> args) {
+ this.args = args;
+ this.path = path;
+ }
+
+ public List<DerivedColumn> getArgs() {
+ return args;
+ }
+
+ @Override
+ public QueryString clone() {
+ QueryString clone = new QueryString((Expression)path.clone(),
LanguageObject.Util.deepClone(args, DerivedColumn.class));
+ return clone;
+ }
+
+ @Override
+ public int hashCode() {
+ return path.hashCode();
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof QueryString)) {
+ return false;
+ }
+ QueryString other = (QueryString)obj;
+ return path.equals(other.path) && args.equals(other.args);
+ }
+
+ @Override
+ public void acceptVisitor(LanguageVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public Expression getPath() {
+ return path;
+ }
+
+ public void setPath(Expression path) {
+ this.path = path;
+ }
+
+ @Override
+ public String toString() {
+ return SQLStringVisitor.getSQLString(this);
+ }
+
+ @Override
+ public Class<?> getType() {
+ return DefaultDataClasses.STRING;
+ }
+
+ @Override
+ public boolean isResolved() {
+ for (DerivedColumn col : args) {
+ if (!col.getExpression().isResolved()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
Property changes on:
trunk/engine/src/main/java/org/teiid/query/sql/symbol/QueryString.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLAttributes.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLAttributes.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLAttributes.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -24,7 +24,6 @@
import java.util.List;
-import org.teiid.core.util.HashCodeUtil;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.LanguageVisitor;
import org.teiid.query.sql.visitor.SQLStringVisitor;
@@ -54,7 +53,7 @@
@Override
public int hashCode() {
- return HashCodeUtil.hashCode(args.hashCode());
+ return args.hashCode();
}
public boolean equals(Object obj) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLForest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLForest.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLForest.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -25,6 +25,7 @@
import java.util.List;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.LanguageVisitor;
@@ -75,6 +76,9 @@
@Override
public XMLForest clone() {
XMLForest clone = new XMLForest(LanguageObject.Util.deepClone(args,
DerivedColumn.class));
+ if (namespaces != null) {
+ clone.namespaces = namespaces.clone();
+ }
return clone;
}
@@ -91,7 +95,7 @@
return false;
}
XMLForest other = (XMLForest)obj;
- return args.equals(other.args);
+ return args.equals(other.args) && EquivalenceUtil.areEqual(namespaces,
other.namespaces);
}
@Override
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLSerialize.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLSerialize.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLSerialize.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -84,6 +84,10 @@
@Override
public XMLSerialize clone() {
XMLSerialize clone = new XMLSerialize();
+ clone.document = this.document;
+ clone.expression = (Expression)this.expression.clone();
+ clone.typeString = this.typeString;
+ clone.type = this.type;
return clone;
}
Modified:
trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -61,6 +61,7 @@
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.QueryString;
import org.teiid.query.sql.symbol.SearchedCaseExpression;
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.symbol.XMLElement;
@@ -327,6 +328,11 @@
obj.setValue(replaceExpression(obj.getValue()));
}
+ @Override
+ public void visit(QueryString obj) {
+ obj.setPath(replaceExpression(obj.getPath()));
+ }
+
/**
* The object is modified in place, so is not returned.
* @param obj Language object
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -111,6 +111,7 @@
import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.Function;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.QueryString;
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.symbol.ScalarSubquery;
import org.teiid.query.sql.symbol.SearchedCaseExpression;
@@ -1722,18 +1723,18 @@
parts.add(NonReserved.ORDINALITY);
} else {
parts.add(col.getType());
+ if (col.getDefaultExpression() != null) {
+ parts.add(SPACE);
+ parts.add(DEFAULT);
+ parts.add(SPACE);
+ parts.add(registerNode(col.getDefaultExpression()));
+ }
if (col.getPath() != null) {
parts.add(SPACE);
parts.add(NonReserved.PATH);
parts.add(SPACE);
parts.add(new Constant(col.getPath()));
}
- if (col.getDefaultExpression() != null) {
- parts.add(SPACE);
- parts.add(DEFAULT);
- parts.add(SPACE);
- parts.add(registerNode(col.getDefaultExpression()));
- }
}
if (cols.hasNext()) {
parts.add(","); //$NON-NLS-1$
@@ -1807,6 +1808,19 @@
}
parts.add(Tokens.RPAREN);
}
+
+ @Override
+ public void visit(QueryString obj) {
+ parts.add(NonReserved.QUERYSTRING);
+ parts.add("("); //$NON-NLS-1$
+ parts.add(registerNode(obj.getPath()));
+ if (!obj.getArgs().isEmpty()) {
+ parts.add(","); //$NON-NLS-1$
+ parts.add(SPACE);
+ registerNodes(obj.getArgs(), 0);
+ }
+ parts.add(")"); //$NON-NLS-1$
+ }
public static String escapeSinglePart(String part) {
if(isReservedWord(part)) {
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -31,6 +31,8 @@
import java.util.Map;
import java.util.Set;
+import net.sf.saxon.om.Name11Checker;
+import net.sf.saxon.om.QNameException;
import net.sf.saxon.trans.XPathException;
import org.teiid.api.exception.query.ExpressionEvaluationException;
@@ -101,9 +103,11 @@
import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.Function;
import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.QueryString;
import org.teiid.query.sql.symbol.Reference;
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.symbol.XMLAttributes;
+import org.teiid.query.sql.symbol.XMLElement;
import org.teiid.query.sql.symbol.XMLForest;
import org.teiid.query.sql.symbol.XMLNamespaces;
import org.teiid.query.sql.symbol.XMLQuery;
@@ -1140,23 +1144,63 @@
@Override
public void visit(XMLForest obj) {
+ validateDerivedColumnNames(obj, obj.getArgs());
for (DerivedColumn dc : obj.getArgs()) {
+ if (dc.getAlias() == null) {
+ continue;
+ }
+ validateQName(obj, dc.getAlias());
+ }
+ }
+
+ private String[] validateQName(LanguageObject obj, String name) {
+ try {
+ return Name11Checker.getInstance().getQNameParts(name);
+ } catch (QNameException e) {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.xml_invalid_qname",
name), obj); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ private void validateDerivedColumnNames(LanguageObject obj, List<DerivedColumn>
cols) {
+ for (DerivedColumn dc : cols) {
if (dc.getAlias() == null && !(dc.getExpression() instanceof
ElementSymbol)) {
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.expression_requires_name"),
obj); //$NON-NLS-1$
- }
+ }
}
- }
+ }
@Override
public void visit(XMLAttributes obj) {
+ validateDerivedColumnNames(obj, obj.getArgs());
for (DerivedColumn dc : obj.getArgs()) {
- if (dc.getAlias() == null && !(dc.getExpression() instanceof
ElementSymbol)) {
-
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.expression_requires_name"),
obj); //$NON-NLS-1$
- }
+ if (dc.getAlias() == null) {
+ continue;
+ }
+ if ("xmlns".equals(dc.getAlias())) { //$NON-NLS-1$
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.xml_attributes_reserved"),
obj); //$NON-NLS-1$
+ }
+ String[] parts = validateQName(obj, dc.getAlias());
+ if (parts == null) {
+ continue;
+ }
+ if ("xmlns".equals(parts[0])) { //$NON-NLS-1$
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.xml_attributes_reserved",
dc.getAlias()), obj); //$NON-NLS-1$
+ }
}
}
@Override
+ public void visit(XMLElement obj) {
+ validateQName(obj, obj.getName());
+ }
+
+ @Override
+ public void visit(QueryString obj) {
+ validateDerivedColumnNames(obj, obj.getArgs());
+ }
+
+ @Override
public void visit(XMLTable obj) {
List<DerivedColumn> passing = obj.getPassing();
validatePassing(obj, obj.getXQueryExpression(), passing);
Modified: trunk/engine/src/main/java/org/teiid/query/xquery/saxon/PathMapFilter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/xquery/saxon/PathMapFilter.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/main/java/org/teiid/query/xquery/saxon/PathMapFilter.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -9,7 +9,6 @@
import net.sf.saxon.expr.PathMap.PathMapNode;
import net.sf.saxon.expr.PathMap.PathMapRoot;
import net.sf.saxon.om.Axis;
-import net.sf.saxon.om.Item;
import net.sf.saxon.pattern.NodeTest;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.type.Type;
@@ -186,9 +185,4 @@
}
}
- @Override
- public void append(Item item, int locationId,
- int copyNamespaces) throws XPathException {
- super.append(item, locationId, copyNamespaces);
- }
}
\ No newline at end of file
Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-06-09 16:37:31
UTC (rev 2211)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-06-10 04:01:14
UTC (rev 2212)
@@ -2162,12 +2162,12 @@
}
) | (
datatype = dataType()
+ [
+ <DEFAULT_KEYWORD> defaultExpr = expression(info)
+ ]
[
nonReserved("PATH") path = stringVal()
]
- [
- <DEFAULT_KEYWORD> defaultExpr = expression(info)
- ]
{
return new XMLTable.XMLColumn(name, (String)datatype.getValue(), path, defaultExpr);
}
@@ -3226,7 +3226,7 @@
expression = null;
}
<RPAREN>
- )
+ )
|
LOOKAHEAD(<ID>, {matchesAny(getToken(1).image, "timestampadd",
"timestampdiff") != null}) (
funcName = nonReserved("TIMESTAMPADD", "TIMESTAMPDIFF")
@@ -3249,8 +3249,13 @@
expression = null;
}
<RPAREN>
- )
+ )
|
+ LOOKAHEAD(<ID>, {getToken(1).image.equalsIgnoreCase("querystring")})
expression = queryString(info)
+ {
+ return expression;
+ }
+ |
(
(funcToken = <LEFT> | funcToken = <RIGHT> | funcToken = <CHAR> |
funcToken = <USER>
| funcToken = <YEAR> | funcToken = <MONTH> | funcToken
= <HOUR>
@@ -3380,6 +3385,27 @@
}
}
+QueryString queryString(ParseInfo info) :
+{
+ Expression path = null;
+ DerivedColumn arg = null;
+ ArrayList<DerivedColumn> args = new ArrayList<DerivedColumn>();
+}
+{
+ nonReserved("QUERYSTRING") <LPAREN>
+ path = expression(info)
+ (<COMMA> arg=derivedColumn(info)
+ {
+ args.add(arg);
+ arg = null;
+ }
+ )*
+ <RPAREN>
+ {
+ return new QueryString(path, args);
+ }
+}
+
XMLElement xmlElement(ParseInfo info) :
{
String name = null;
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-06-09 16:37:31
UTC (rev 2211)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-06-10 04:01:14
UTC (rev 2212)
@@ -279,7 +279,7 @@
ERR.015.012.0025 = Command must project at least one symbol
ERR.015.012.0026 = Expressions of type OBJECT, CLOB, BLOB, or XML cannot be used in
SELECT DISTINCT, ORDER BY, GROUP BY, or non-all set queries: [{0}]
ERR.015.012.0027 = Expressions of type OBJECT, CLOB, BLOB, or XML cannot be used in
comparison: {0}.
-ValidationVisitor.expression_requires_name = Non-column expressions require a name in
XMLATTRIBUTES, XMLFOREST, or XMLTABLE
+ValidationVisitor.expression_requires_name = Non-column expressions require a name in
XMLATTRIBUTES, XMLFOREST, or QUERYSTRING
ValidationVisitor.invalid_lookup_key=Expressions of type OBJECT, CLOB, BLOB, or XML
cannot be used as LOOKUP key columns: {0}.
ValidationVisitor.limit_not_valid_for_xml=The limit clause cannot be used on an XML
document query.
ValidationVisitor.translated_or=Translated user criteria must not contain OR criteria
@@ -816,6 +816,7 @@
ExpressionEvaluator.Must_push=Function {0} is marked in the function metadata as a
function that must be evaluated at the source.
ExpressionEvaluator.Eval_failed=Unable to evaluate {0}: {1}
XMLSerialize.resolvingError=XMLSerialize is valid only for XML expressions: {0}
+QueryString.resolvingError=All query string expressions must be convertable to string.
Evaluator.xmlserialize=XMLSerialize: data exception - not an xml document
Evaluator.xmlquery=Error evaluating XMLQuery: {0}
Evaluator.xmlquery_content=XQuery evaluation was expected to return content, but it
returned a sequence.
@@ -893,7 +894,9 @@
ValidationVisitor.text_table_delimiter=Text table DELIMITER cannot be the same as the
QUOTE or ESCAPE characters.
ValidationVisitor.text_table_newline=Text table DELIMITER, QUOTE, and ESCAPE characters
cannot be the new line character.
ValidationVisitor.xml_namespaces=At most only one NO DEFAULT or DEFAULT namespace may be
specified.
-ValidationVisitor.xml_namespaces_reserved=At most only one NO DEFAULT or DEFAULT
namespace may be specified.
+ValidationVisitor.xml_namespaces_reserved=The namespaces xmlns and xml are reserved.
+ValidationVisitor.xml_attributes_reserved=The namespace xmlns is reserved.
+ValidationVisitor.xml_invalid_qname=The qname "{0}" is invalid.
ValidationVisitor.context_item_type=XMLTABLE or XMLQUERY PASSING context item must be an
XML value.
ValidationVisitor.passing_requires_name=XMLTABLE or XMLQUERY PASSING clause can only
contain at most 1 unnamed item.
ValidationVisitor.duplicate_passing=XMLTABLE or XMLQUERY PASSING clause duplicate item
name "{0}".
Modified:
trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -25,8 +25,6 @@
import static org.junit.Assert.*;
import java.io.File;
-import java.io.Reader;
-import java.io.StringReader;
import java.sql.Timestamp;
import java.util.TimeZone;
@@ -203,6 +201,14 @@
assertEquals("1969-12-31T18:00:00", XMLSystemFunctions.getStringValue(new
Timestamp(0)));
}
+ @Test public void testNameEscaping() throws Exception {
+ assertEquals("_u003A_b", XMLSystemFunctions.escapeName(":b",
true));
+ }
+
+ @Test public void testNameEscaping1() throws Exception {
+ assertEquals("a_u005F_x", XMLSystemFunctions.escapeName("a_x",
true));
+ }
+
@BeforeClass static public void setUpOnce() {
TimeZone.setDefault(TimeZone.getTimeZone("GMT-6:00"));
}
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2010-06-09 16:37:31
UTC (rev 2211)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2010-06-10 04:01:14
UTC (rev 2212)
@@ -135,6 +135,7 @@
assertEquals("Parse string does not match: ", expectedString, actualString);
//$NON-NLS-1$
assertEquals("Command objects do not match: ", expectedCommand,
actualCommand); //$NON-NLS-1$
+ assertEquals("Cloned command objects do not match: ", expectedCommand,
actualCommand.clone()); //$NON-NLS-1$
}
static void helpTestExpression(String sql, String expectedString, Expression expected)
throws QueryParserException {
@@ -143,6 +144,7 @@
assertEquals("Parse string does not match: ", expectedString, actualString);
//$NON-NLS-1$
assertEquals("Command objects do not match: ", expected, actual);
//$NON-NLS-1$
+ assertEquals("Cloned command objects do not match: ", expected,
actual.clone()); //$NON-NLS-1$
}
static void helpException(String sql) {
@@ -200,7 +202,7 @@
new ElementSymbol("g1.a1"), //$NON-NLS-1$
CompareCriteria.EQ,
new ElementSymbol("g2.a2")); //$NON-NLS-1$
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(jcrit);
JoinPredicate jp = new JoinPredicate(g1, g2, JoinType.JOIN_INNER, crits);
From from = new From();
@@ -398,7 +400,7 @@
new ElementSymbol("g2.a"), //$NON-NLS-1$
CompareCriteria.EQ,
new ElementSymbol("g3.a")); //$NON-NLS-1$
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(jcrit);
JoinPredicate jp = new JoinPredicate(g2, g3, JoinType.JOIN_INNER, crits);
From from = new From();
@@ -425,7 +427,7 @@
new ElementSymbol("myG.x"), //$NON-NLS-1$
CompareCriteria.EQ,
new ElementSymbol("myH.x")); //$NON-NLS-1$
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(jcrit);
JoinPredicate jp = new JoinPredicate(g, h, JoinType.JOIN_RIGHT_OUTER, crits);
From from = new From();
@@ -452,7 +454,7 @@
new ElementSymbol("myG.x"), //$NON-NLS-1$
CompareCriteria.EQ,
new ElementSymbol("myH.x")); //$NON-NLS-1$
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(jcrit);
JoinPredicate jp = new JoinPredicate(g, h, JoinType.JOIN_RIGHT_OUTER, crits);
From from = new From();
@@ -479,7 +481,7 @@
new ElementSymbol("myG.x"), //$NON-NLS-1$
CompareCriteria.EQ,
new ElementSymbol("myH.x")); //$NON-NLS-1$
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(jcrit);
JoinPredicate jp = new JoinPredicate(g, h, JoinType.JOIN_LEFT_OUTER, crits);
From from = new From();
@@ -506,7 +508,7 @@
new ElementSymbol("myG.x"), //$NON-NLS-1$
CompareCriteria.EQ,
new ElementSymbol("myH.x")); //$NON-NLS-1$
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(jcrit);
JoinPredicate jp = new JoinPredicate(g, h, JoinType.JOIN_LEFT_OUTER, crits);
From from = new From();
@@ -533,7 +535,7 @@
new ElementSymbol("myG.x"), //$NON-NLS-1$
CompareCriteria.EQ,
new ElementSymbol("myH.x")); //$NON-NLS-1$
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(jcrit);
JoinPredicate jp = new JoinPredicate(g, h, JoinType.JOIN_FULL_OUTER, crits);
From from = new From();
@@ -560,7 +562,7 @@
new ElementSymbol("g.x"), //$NON-NLS-1$
CompareCriteria.EQ,
new ElementSymbol("h.x")); //$NON-NLS-1$
- ArrayList crits = new ArrayList();
+ ArrayList<Criteria> crits = new ArrayList<Criteria>();
crits.add(jcrit);
JoinPredicate jp = new JoinPredicate(g, h, JoinType.JOIN_FULL_OUTER, crits);
From from = new From();
@@ -6736,7 +6738,7 @@
@Test public void testXmlNamespaces() throws Exception {
XMLForest f = new XMLForest(Arrays.asList(new DerivedColumn("table", new
ElementSymbol("a"))));
- f.setNamespaces(new XMLNamespaces(Arrays.asList(new XMLNamespaces.NamespaceItem(),
new XMLNamespaces.NamespaceItem("x", "http://foo"))));
+ f.setNamespaces(new XMLNamespaces(Arrays.asList(new XMLNamespaces.NamespaceItem(),
new XMLNamespaces.NamespaceItem("http://foo", "x"))));
helpTestExpression("xmlforest(xmlnamespaces(no default, 'http://foo' as
x), a as \"table\")", "XMLFOREST(XMLNAMESPACES(NO DEFAULT,
'http://foo' AS x), a AS \"table\")", f);
}
@@ -6792,7 +6794,7 @@
}
@Test public void testXMLTable() throws Exception {
- String sql = "SELECT * from xmltable(xmlnamespaces(no default), '/'
columns x for ordinality, y date path '@date' default {d'2000-01-01'}) as
x"; //$NON-NLS-1$
+ String sql = "SELECT * from xmltable(xmlnamespaces(no default), '/'
columns x for ordinality, y date default {d'2000-01-01'} path '@date') as
x"; //$NON-NLS-1$
Query query = new Query();
query.setSelect(new Select(Arrays.asList(new AllSymbol())));
XMLTable xt = new XMLTable();
@@ -6804,7 +6806,7 @@
columns.add(new XMLTable.XMLColumn("y", "date",
"@date", new Constant(Date.valueOf("2000-01-01"))));
xt.setColumns(columns);
query.setFrom(new From(Arrays.asList(xt)));
- helpTest(sql, "SELECT * FROM XMLTABLE(XMLNAMESPACES(NO DEFAULT), '/'
COLUMNS x FOR ORDINALITY, y date PATH '@date' DEFAULT {d'2000-01-01'}) AS
x", query);
+ helpTest(sql, "SELECT * FROM XMLTABLE(XMLNAMESPACES(NO DEFAULT), '/'
COLUMNS x FOR ORDINALITY, y date DEFAULT {d'2000-01-01'} PATH '@date') AS
x", query);
}
@Test public void testXmlSerialize() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2010-06-09
16:37:31 UTC (rev 2211)
+++
trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -27,8 +27,8 @@
import java.util.Arrays;
import java.util.List;
+import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.core.TeiidProcessingException;
import org.teiid.query.unittest.FakeMetadataFactory;
@SuppressWarnings({"nls", "unchecked"})
@@ -41,12 +41,7 @@
Arrays.asList("<foo><bar><bar1/></foo>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
/**
@@ -60,15 +55,10 @@
Arrays.asList("<foo><bar><bar1></bar1></foo>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlElement() {
+ @Test public void testXmlElement() throws Exception {
String sql = "SELECT xmlelement(e1, e2) from pm1.g1 order by e1, e2";
//$NON-NLS-1$
List<?>[] expected = new List<?>[] {
@@ -80,15 +70,10 @@
Arrays.asList("<e1>1</e1>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlElementWithConcat() {
+ @Test public void testXmlElementWithConcat() throws Exception {
String sql = "SELECT xmlelement(e1, e2, xmlconcat(xmlelement(x),
xmlelement(y, e3))) from pm1.g1 order by e1, e2"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
@@ -100,15 +85,10 @@
Arrays.asList("<e1>1<x></x><y>true</y></e1>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlElementWithForest() {
+ @Test public void testXmlElementWithForest() throws Exception {
String sql = "SELECT xmlelement(x, xmlforest(e1, e2, '1' as val))
from pm1.g1 order by e1, e2 limit 2"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
@@ -116,15 +96,10 @@
Arrays.asList("<x><e1>a</e1><e2>0</e2><val>1</val></x>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlElementWithAttributes() {
+ @Test public void testXmlElementWithAttributes() throws Exception {
String sql = "SELECT xmlelement(x, xmlattributes(e1, e2, '1' as
val)) from pm1.g1 order by e1, e2 limit 2"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
@@ -132,30 +107,20 @@
Arrays.asList("<x e1=\"a\" e2=\"0\"
val=\"1\"></x>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlElementWithPi() {
+ @Test public void testXmlElementWithPi() throws Exception {
String sql = "SELECT xmlelement(x, xmlpi(name e1, ' 1'))";
//$NON-NLS-1$
List<?>[] expected = new List<?>[] {
Arrays.asList("<x><?e1 1?></x>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlElementWithNamespaces() {
+ @Test public void testXmlElementWithNamespaces() throws Exception {
String sql = "SELECT xmlelement(x, xmlnamespaces(no default,
'http://foo' as x, 'http://foo1' as y), xmlattributes(e1), e2) from pm1.g1
order by e1, e2 limit 2"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
@@ -163,60 +128,40 @@
Arrays.asList("<x xmlns=\"\" xmlns:x=\"http://foo\"
xmlns:y=\"http://foo1\" e1=\"a\">0</x>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlAgg() {
+ @Test public void testXmlAgg() throws Exception {
String sql = "SELECT xmlelement(parent, xmlAgg(xmlelement(x,
xmlattributes(e1, e2)))) from pm1.g1"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
Arrays.asList("<parent><x e1=\"a\"
e2=\"0\"></x><x e2=\"1\"></x><x
e1=\"a\" e2=\"3\"></x><x e1=\"c\"
e2=\"1\"></x><x e1=\"b\"
e2=\"2\"></x><x e1=\"a\"
e2=\"0\"></x></parent>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlAggOrderBy() {
+ @Test public void testXmlAggOrderBy() throws Exception {
String sql = "SELECT xmlelement(parent, xmlAgg(xmlelement(x,
xmlattributes(e1, e2)) order by e2)) from pm1.g1"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
Arrays.asList("<parent><x e1=\"a\"
e2=\"0\"></x><x e1=\"a\"
e2=\"0\"></x><x e2=\"1\"></x><x
e1=\"c\" e2=\"1\"></x><x e1=\"b\"
e2=\"2\"></x><x e1=\"a\"
e2=\"3\"></x></parent>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlSerialize() {
+ @Test public void testXmlSerialize() throws Exception {
String sql = "SELECT xmlserialize(document xmlelement(parent) as string)";
//$NON-NLS-1$
List<?>[] expected = new List<?>[] {
Arrays.asList("<parent></parent>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlTable() {
+ @Test public void testXmlTable() throws Exception {
String sql = "select * from xmltable('/a/b' passing
convert('<a><b>first</b><b
x=\"attr\">second</b></a>', xml) columns x string path
'@x', val string path '/.') as x"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
@@ -224,31 +169,21 @@
Arrays.asList("attr", "second"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlTableDefaultAndParent() {
- String sql = "select * from xmltable('/a/b' passing
convert('<a y=\"rev\"><b>first</b><b
x=\"1\">second</b></a>', xml) columns x integer path
'@x' default -1, val string path '../@y') as x"; //$NON-NLS-1$
+ @Test public void testXmlTableDefaultAndParent() throws Exception {
+ String sql = "select * from xmltable('/a/b' passing
convert('<a y=\"rev\"><b>first</b><b
x=\"1\">second</b></a>', xml) columns x integer default -1
path '@x' , val string path '../@y') as x"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
Arrays.asList(-1, "rev"),
Arrays.asList(1, "rev"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlTableReturnXml() {
+ @Test public void testXmlTableReturnXml() throws Exception {
String sql = "select * from xmltable('/a/b' passing
convert('<a><b>first</b><b
x=\"1\">second</b></a>', xml) columns val xml path
'.') as x"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
@@ -256,45 +191,30 @@
Arrays.asList("<b x=\"1\">second</b>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlTableNoColumns() {
+ @Test public void testXmlTableNoColumns() throws Exception {
String sql = "select * from xmltable('/a' passing
convert('<a><b>first</b><b
x=\"1\">second</b></a>', xml)) as x"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
Arrays.asList("<a><b>first</b><b
x=\"1\">second</b></a>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlTablePassing() {
+ @Test public void testXmlTablePassing() throws Exception {
String sql = "select * from xmltable('<root>{for $x in $a/a/b
return <c>{$x}</c>}</root>' passing
convert('<a><b>first</b><b
x=\"1\">second</b></a>', xml) as a columns x xml path
'c[1]/b') as x"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
Arrays.asList("<b>first</b>"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlTableForOrdinalityAndDefaultPath() {
+ @Test public void testXmlTableForOrdinalityAndDefaultPath() throws Exception {
String sql = "select * from xmltable('/a/b' passing
convert('<a><b><c>1</c></b><b>1</b><b><c>1</c></b><b>1</b></a>',
xml) columns x for ordinality, c integer) as x"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
@@ -304,42 +224,27 @@
Arrays.asList(4, null),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlTableDescendantPath() {
+ @Test public void testXmlTableDescendantPath() throws Exception {
String sql = "select * from xmltable('<a>{for $i in (1 to 5)
return $i}</a>' columns x string path '//text()') as x";
//$NON-NLS-1$
List<?>[] expected = new List<?>[] {
Arrays.asList("1 2 3 4 5"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
- @Test public void testXmlQuery() {
+ @Test public void testXmlQuery() throws Exception {
String sql = "select xmlquery('for $i in (1 to 5) return $i')";
//$NON-NLS-1$
List<?>[] expected = new List<?>[] {
Arrays.asList("1 2 3 4 5"),
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
+ process(sql, expected);
}
@Test public void testXmlQueryEmptyNull() throws Exception {
@@ -349,12 +254,29 @@
Arrays.asList((String)null)
};
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
+ process(sql, expected);
+ }
+
+ @Test public void testXmlNameEscaping() throws Exception {
+ String sql = "select xmlforest(\"xml\") from (select 1 as
\"xml\") x"; //$NON-NLS-1$
+ List<?>[] expected = new List<?>[] {
+ Arrays.asList("<_u0078_ml>1</_u0078_ml>")
+ };
+
+ process(sql, expected);
+ }
+
+ private static FakeDataManager dataManager = new FakeDataManager();
+
+ @BeforeClass public static void oneTimeSetUp() {
+ sampleData1(dataManager);
+ }
+
+ private void process(String sql, List<?>[] expected) throws Exception {
ProcessorPlan plan = helpGetPlan(helpParse(sql),
FakeMetadataFactory.example1Cached());
helpProcess(plan, createCommandContext(), dataManager, expected);
- }
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -953,11 +953,11 @@
List elements = (List)
ElementCollectorVisitor.getElements(resolvedQuery.getSelect(), false);
ElementSymbol elem1 = (ElementSymbol)elements.get(0);
- assertEquals("Did not get expected element", "X.E1",
elem1.getName() ); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Did not get expected element", "X.e1",
elem1.getName() ); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Did not get expected type",
DataTypeManager.DefaultDataClasses.STRING, elem1.getType()); //$NON-NLS-1$
ElementSymbol elem2 = (ElementSymbol)elements.get(1);
- assertEquals("Did not get expected element", "X.E2",
elem2.getName() ); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Did not get expected element", "X.e2",
elem2.getName() ); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("Did not get expected type",
DataTypeManager.DefaultDataClasses.INTEGER, elem2.getType()); //$NON-NLS-1$
}
@@ -2719,7 +2719,7 @@
Command cmd = helpResolve(proc.toString());
- String sExpected = "CREATE VIRTUAL PROCEDURE\nBEGIN\nCREATE LOCAL TEMPORARY
TABLE #matt (x integer);\nINSERT INTO #matt (#MATT.X) VALUES (1);\nEND\n\tCREATE LOCAL
TEMPORARY TABLE #matt (x integer)\n\tINSERT INTO #matt (#MATT.X) VALUES (1)\n";
//$NON-NLS-1$
+ String sExpected = "CREATE VIRTUAL PROCEDURE\nBEGIN\nCREATE LOCAL TEMPORARY
TABLE #matt (x integer);\nINSERT INTO #matt (#MATT.x) VALUES (1);\nEND\n\tCREATE LOCAL
TEMPORARY TABLE #matt (x integer)\n\tINSERT INTO #matt (#MATT.x) VALUES (1)\n";
//$NON-NLS-1$
String sActual = cmd.printCommandTree();
assertEquals( sExpected, sActual );
}
@@ -2946,4 +2946,8 @@
assertEquals(1, command.getProjectedSymbols().size());
}
+ @Test public void testQueryString() throws Exception {
+ helpResolveException("select querystring({x '<a/>'})");
+ }
+
}
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestOrderByRewrite.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestOrderByRewrite.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestOrderByRewrite.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -309,7 +309,7 @@
@Test public void testOrderByExpression() throws Exception {
Query resolvedQuery = (Query) getCommand("SELECT 0 AS SOMEINT, pm1.g1.e2 as y
FROM pm1.g1 ORDER BY e2 || e1, e3"); //$NON-NLS-1$
- assertEquals("SELECT X_1.SOMEINT, X_1.Y FROM (SELECT 0 AS SOMEINT, pm1.g1.e2
AS y, (e2 || e1) AS EXPR1, e3 FROM pm1.g1) AS X_1 ORDER BY X_1.EXPR1, X_1.E3",
resolvedQuery.toString()); //$NON-NLS-1$
+ assertEquals("SELECT X_1.SOMEINT, X_1.y FROM (SELECT 0 AS SOMEINT, pm1.g1.e2
AS y, (e2 || e1) AS EXPR1, e3 FROM pm1.g1) AS X_1 ORDER BY X_1.EXPR1, X_1.e3",
resolvedQuery.toString()); //$NON-NLS-1$
}
@Test public void testRewiteOrderBy() {
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -1931,7 +1931,7 @@
@Test public void testRewriteSelectInto() {
String sql = "select distinct pm1.g1.e1 into #temp from pm1.g1";
//$NON-NLS-1$
- String expected = "INSERT INTO #temp (#TEMP.E1) SELECT DISTINCT pm1.g1.e1
FROM pm1.g1"; //$NON-NLS-1$
+ String expected = "INSERT INTO #temp (#TEMP.e1) SELECT DISTINCT pm1.g1.e1
FROM pm1.g1"; //$NON-NLS-1$
helpTestRewriteCommand(sql, expected);
}
@@ -1941,7 +1941,7 @@
*/
@Test public void testRewriteSelectInto1() {
String sql = "select distinct e2, e2, e3, e4 into pm1.g1 from pm1.g2";
//$NON-NLS-1$
- String expected = "INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2, pm1.g1.e3,
pm1.g1.e4) SELECT PM1_G1_1.E2 AS e1, PM1_G1_1.E2_0 AS e2, PM1_G1_1.E3, PM1_G1_1.E4 FROM
(SELECT DISTINCT e2, e2 AS E2_0, e3, e4 FROM pm1.g2) AS pm1_g1_1"; //$NON-NLS-1$
+ String expected = "INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2, pm1.g1.e3,
pm1.g1.e4) SELECT PM1_G1_1.e2 AS e1, PM1_G1_1.E2_0 AS e2, PM1_G1_1.e3, PM1_G1_1.e4 FROM
(SELECT DISTINCT e2, e2 AS E2_0, e3, e4 FROM pm1.g2) AS pm1_g1_1"; //$NON-NLS-1$
helpTestRewriteCommand(sql, expected);
}
@@ -1998,7 +1998,7 @@
procedure += "Select x from temp;\n"; //$NON-NLS-1$
procedure += "END\n"; //$NON-NLS-1$
- helpTestRewriteCommand(procedure, "CREATE VIRTUAL PROCEDURE\nBEGIN\nCREATE
LOCAL TEMPORARY TABLE temp (x string, y integer, z integer);\nINSERT INTO temp (TEMP.X,
TEMP.Y, TEMP.Z) SELECT TEMP_1.E2 AS X, TEMP_1.X AS Y, TEMP_1.X_0 AS Z FROM (SELECT
pm1.g1.e2, 1 AS x, 2 AS X_0 FROM pm1.g1 ORDER BY pm1.g1.e2 LIMIT 1) AS temp_1;\nSELECT x
FROM temp;\nEND"); //$NON-NLS-1$
+ helpTestRewriteCommand(procedure, "CREATE VIRTUAL PROCEDURE\nBEGIN\nCREATE
LOCAL TEMPORARY TABLE temp (x string, y integer, z integer);\nINSERT INTO temp (TEMP.x,
TEMP.y, TEMP.z) SELECT TEMP_1.e2 AS x, TEMP_1.x AS y, TEMP_1.X_0 AS z FROM (SELECT
pm1.g1.e2, 1 AS x, 2 AS X_0 FROM pm1.g1 ORDER BY pm1.g1.e2 LIMIT 1) AS temp_1;\nSELECT x
FROM temp;\nEND"); //$NON-NLS-1$
}
@Test public void testRewriteNot() {
@@ -2290,5 +2290,11 @@
QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
helpTestRewriteCommand(original, "SELECT * FROM XMLTABLE('/' PASSING 2
AS a COLUMNS x string DEFAULT curdate()) AS x", metadata);
}
+
+ @Test public void testRewriteQueryString() throws Exception {
+ String original = "querystring('path', 'value' as
\"&x\", ' & ' as y, null as z)"; //$NON-NLS-1$
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+ helpTestRewriteExpression(original,
"'path?%26x=value&y=%20%26%20'", metadata);
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-06-09
16:37:31 UTC (rev 2211)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -2022,5 +2022,13 @@
@Test public void testXMLQueryPassingContextType() {
helpValidate("select xmlquery('/' passing 2)", new String[]
{"XMLQUERY('/' PASSING 2)"}, FakeMetadataFactory.example1Cached());
}
+
+ @Test public void testQueryString() {
+ helpValidate("select querystring('/', '1')", new String[]
{"QUERYSTRING('/', '1')"},
FakeMetadataFactory.example1Cached());
+ }
+ @Test public void testXmlNameValidation() throws Exception {
+ helpValidate("select xmlelement(\":\")", new String[]
{"XMLELEMENT(NAME \":\")"}, FakeMetadataFactory.example1Cached());
+ }
+
}
Added: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStuff.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStuff.java
(rev 0)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStuff.java 2010-06-10
04:01:14 UTC (rev 2212)
@@ -0,0 +1,61 @@
+/*
+ * 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.jdbc;
+
+import static org.junit.Assert.*;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.teiid.jdbc.util.ResultSetUtil;
+@SuppressWarnings("nls")
+public class TestStuff {
+
+ @Ignore
+ @Test public void testNoExec() throws Exception {
+ Connection c =
DriverManager.getConnection("jdbc:teiid:tpcrperf@mm://localhost:31000",
"admin", "teiid");
+ Statement s = c.createStatement();
+ long start = System.currentTimeMillis();
+ //s.execute("set noexec on");
+ s.execute("set showplan debug");
+ DatabaseMetaData dmd = c.getMetaData();
+
+ //ResultSetUtil.printResultSet(s.executeQuery("select * from
TPCR01_OraclePhys.NATION"), 20, false, System.out);
+ ResultSetUtil.printResultSet(s.executeQuery("select * from tables"), 20,
false, System.out);
+
+ //ResultSet rs = s.executeQuery("SELECT ORDERS.O_ORDERKEY, ORDERS.O_ORDERDATE,
ORDERS.O_CLERK, CUSTOMER.C_CUSTKEY, CUSTOMER.C_NAME FROM
TPCR01_SqlServerVirt.TPCR01.ORDERS,TPCR01_SqlServerVirt.TPCR01.CUSTOMER WHERE
(CUSTOMER.C_CUSTKEY = ORDERS.O_CUSTKEY) AND (O_ORDERKEY < 2)");
+ System.out.println(System.currentTimeMillis() - start);
+
+ System.out.println(s.unwrap(TeiidStatement.class).getDebugLog());
+ System.out.println(s.unwrap(TeiidStatement.class).getPlanDescription());
+ s.close();
+ c.close();
+ }
+
+
+}
Property changes on:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestStuff.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain