Author: rareddy
Date: 2010-05-19 16:01:26 -0400 (Wed, 19 May 2010)
New Revision: 2142
Added:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/CartesienCriteriaGenerator.java
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/CompositeExecution.java
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestCartesianCriteriaGenerator.java
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestBaseStreamingExecution.java
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestSoapExecution.java
trunk/connectors/translator-xml/src/test/resources/cis.vdb
Modified:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/QueryAnalyzer.java
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLExecutionFactory.java
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/BaseStreamingExecution.java
trunk/metadata/src/test/java/com/metamatrix/cdk/api/ConnectorHost.java
Log:
TEIID-1077: adding the fix for the single request spaning the multiple requests based on
the cartesian join of the criteria
Added:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/CartesienCriteriaGenerator.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/CartesienCriteriaGenerator.java
(rev 0)
+++
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/CartesienCriteriaGenerator.java 2010-05-19
20:01:26 UTC (rev 2142)
@@ -0,0 +1,95 @@
+/*
+ * 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.List;
+
+/**
+ * creates a Cartesian product of the Criteria descriptions based on their values.
+ */
+public class CartesienCriteriaGenerator {
+
+ public static List<List<CriteriaDesc>>
generateCartesianCriteria(List<CriteriaDesc> params) {
+ List<List<CriteriaDesc>> cartesianProduct = new
ArrayList<List<CriteriaDesc>>();
+
+ for (CriteriaDesc desc : params) {
+ createCartesionProduct(cartesianProduct, desc);
+ }
+
+ return cartesianProduct;
+ }
+
+ static void createCartesionProduct(List<List<CriteriaDesc>>
cartesianProduct, CriteriaDesc desc) {
+
+ List<CriteriaDesc> firstLevel = new ArrayList<CriteriaDesc>();
+ if (desc.isUnlimited()) {
+ firstLevel.add(desc);
+ }
+ else {
+ for (Object value: desc.getValues()) {
+ CriteriaDesc cd = desc.cloneWithoutValues();
+ cd.setValue(0, value);
+ firstLevel.add(cd);
+ }
+ }
+
+ if (cartesianProduct.isEmpty()) {
+ for (CriteriaDesc cd:firstLevel) {
+ List<CriteriaDesc> secondLevel = new ArrayList<CriteriaDesc>();
+ secondLevel.add(cd);
+ cartesianProduct.add(secondLevel);
+ }
+ }
+ else {
+ List<List<CriteriaDesc>> newcartesianProduct = new
ArrayList<List<CriteriaDesc>>();
+
+ for (CriteriaDesc cd:firstLevel) {
+ for (List<CriteriaDesc> secondLevel:cartesianProduct) {
+
+ List<CriteriaDesc> colnedSecondLevel = makeClone(secondLevel);
+ colnedSecondLevel.add(cd);
+ newcartesianProduct.add(colnedSecondLevel);
+ }
+ }
+ cartesianProduct.clear();
+ cartesianProduct.addAll(newcartesianProduct);
+ }
+ }
+
+ private static List<CriteriaDesc> makeClone(List<CriteriaDesc> original){
+ List<CriteriaDesc> clonedList = new ArrayList<CriteriaDesc>();
+
+ for (CriteriaDesc cd:original) {
+ CriteriaDesc clone = cd.cloneWithoutValues();
+ int i = 0;
+ for (Object value:cd.getValues()) {
+ clone.setValue(i++, value);
+ }
+ clonedList.add(clone);
+ }
+ return clonedList;
+ }
+}
Property changes on:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/CartesienCriteriaGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/CompositeExecution.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/CompositeExecution.java
(rev 0)
+++
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/CompositeExecution.java 2010-05-19
20:01:26 UTC (rev 2142)
@@ -0,0 +1,85 @@
+/*
+ * 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.List;
+
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorException;
+
+public class CompositeExecution implements ResultSetExecution {
+
+ private boolean closed = false;
+ private List<ResultSetExecution> executions = new
ArrayList<ResultSetExecution>();
+ private int currentExecutionNumber = 0;
+ private ResultSetExecution currentExecution;
+
+ public void addExecution(ResultSetExecution execution) {
+ if (this.closed) {
+ throw new IllegalStateException("This execution is already closed");
//$NON-NLS-1$
+ }
+ this.executions.add(execution);
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ List result = null;
+ if (this.currentExecution != null) {
+ result = this.currentExecution.next();
+ }
+
+ if (result == null) {
+ if(this.currentExecutionNumber < this.executions.size()) {
+ this.currentExecution = this.executions.get(this.currentExecutionNumber++);
+ result = this.currentExecution.next();
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public void cancel() throws TranslatorException {
+ this.closed = true;
+ for(ResultSetExecution exec:this.executions) {
+ exec.cancel();
+ }
+ }
+
+ @Override
+ public void close() throws TranslatorException {
+ this.closed = true;
+ for(ResultSetExecution exec:this.executions) {
+ exec.close();
+ }
+ }
+
+ @Override
+ public void execute() throws TranslatorException {
+ this.closed = true;
+ for(ResultSetExecution exec:this.executions) {
+ exec.execute();
+ }
+ }
+
+}
Property changes on:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/CompositeExecution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java 2010-05-18
20:59:49 UTC (rev 2141)
+++
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/FileResultSetExecution.java 2010-05-19
20:01:26 UTC (rev 2142)
@@ -31,7 +31,6 @@
import java.util.List;
import org.teiid.core.types.InputStreamFactory;
-import org.teiid.language.Select;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.FileConnection;
import org.teiid.translator.ResultSetExecution;
@@ -54,10 +53,9 @@
private int currentRow = 0;
- public FileResultSetExecution(Select query, XMLExecutionFactory executionFactory,
FileConnection connection) throws TranslatorException {
+ public FileResultSetExecution(List<CriteriaDesc> requestParams, ExecutionInfo
executionInfo, XMLExecutionFactory executionFactory, FileConnection connection) throws
TranslatorException {
- QueryAnalyzer analyzer = new QueryAnalyzer(query);
- this.executionInfo = analyzer.getExecutionInfo();
+ this.executionInfo = executionInfo;
String tableName = this.executionInfo.getLocation();
if (tableName == null) {
@@ -67,14 +65,8 @@
this.content = connection.getFiles(tableName);
validateParams();
- List<CriteriaDesc[]> requestPerms = analyzer.getRequestPerms();
- if (requestPerms.size() > 1) {
- throw new AssertionError("The QueryAnalyzer produced > 1 request
permutation"); //$NON-NLS-1$
- }
-
- List<CriteriaDesc> criteriaList = Arrays.asList(requestPerms.get(0));
- this.executionInfo.setParameters(criteriaList);
+ this.executionInfo.setParameters(requestParams);
this.executionFactory = executionFactory;
this.streamProducer = new StreamingResultsProducer(this.executionInfo,
this.executionFactory.getSaxFilterProvider());
}
Modified:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/QueryAnalyzer.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/QueryAnalyzer.java 2010-05-18
20:59:49 UTC (rev 2141)
+++
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/QueryAnalyzer.java 2010-05-19
20:01:26 UTC (rev 2142)
@@ -63,7 +63,7 @@
return this.executionInfo;
}
- private void setGroupInfo() throws TranslatorException {
+ private void setGroupInfo() {
List<TableReference> fromItems = command.getFrom();
//Can only be one because we do not support joins
NamedTable group = (NamedTable) fromItems.get(0);
@@ -197,12 +197,12 @@
}
}
- private void setProperties() throws TranslatorException {
+ private void setProperties() {
this.executionInfo.setOtherProperties(table.getProperties());
}
- public List<CriteriaDesc[]> getRequestPerms() {
- return RequestGenerator.getRequests(this.executionInfo.getParameters());
+ public List<List<CriteriaDesc>> getRequestPerms() {
+ return
CartesienCriteriaGenerator.generateCartesianCriteria(this.executionInfo.getParameters());
}
}
Modified:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLExecutionFactory.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLExecutionFactory.java 2010-05-18
20:59:49 UTC (rev 2141)
+++
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/XMLExecutionFactory.java 2010-05-19
20:01:26 UTC (rev 2142)
@@ -23,6 +23,7 @@
package org.teiid.translator.xml;
import java.sql.SQLXML;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -54,7 +55,7 @@
private String saxFilterProviderClass;
private String encoding = "ISO-8859-1"; //$NON-NLS-1$
- private Map<String, SQLXML> responses = new ConcurrentHashMap<String,
SQLXML>();
+ private Map<String, List<SQLXML>> responses = new
ConcurrentHashMap<String, List<SQLXML>>();
private boolean logRequestResponseDocs = false;
private String queryPreprocessorClass;
@@ -105,15 +106,20 @@
this.logRequestResponseDocs = logRequestResponseDocs;
}
- public SQLXML getResponse(String key) {
+ public List<SQLXML> getResponse(String key) {
return this.responses.get(key);
}
public void setResponse(String key, SQLXML xml) {
- this.responses.put(key, xml);
+ List<SQLXML> results = this.responses.get(key);
+ if (results == null) {
+ results = new ArrayList<SQLXML>();
+ this.responses.put(key, results);
+ }
+ results.add(xml);
}
- public SQLXML removeResponse(String key) {
+ public List<SQLXML> removeResponse(String key) {
return this.responses.remove(key);
}
@@ -147,19 +153,35 @@
command = preProcessor.preprocessQuery((Select)command, metadata,
executionContext);
}
+ QueryAnalyzer analyzer = new QueryAnalyzer((Select)command);
+ ExecutionInfo executionInfo = analyzer.getExecutionInfo();
+ List<List<CriteriaDesc>> requestPerms = analyzer.getRequestPerms();
+
+ if (requestPerms.size() > 1) {
+ CompositeExecution compasiteExecution = new CompositeExecution();
+ for (List<CriteriaDesc> cds: requestPerms) {
+ compasiteExecution.addExecution(createExecution(cds, executionInfo,
executionContext,connectionFactory));
+ }
+ return compasiteExecution;
+ }
+ return createExecution(requestPerms.get(0), executionInfo,
executionContext,connectionFactory);
+ }
+
+ private ResultSetExecution createExecution(List<CriteriaDesc> cds, ExecutionInfo
executionInfo, ExecutionContext executionContext, Object connectionFactory)
+ throws TranslatorException {
try {
ConnectionFactory cf = (ConnectionFactory)connectionFactory;
Connection connection = cf.getConnection();
if (connection instanceof FileConnection) {
- return new FileResultSetExecution((Select)command, this,
(FileConnection)connection);
+ return new FileResultSetExecution(cds, executionInfo, this,
(FileConnection)connection);
}
else if (connection instanceof Dispatch<?>) {
- return new BaseStreamingExecution((Select)command, metadata, executionContext, this,
(Dispatch)connection);
+ return new BaseStreamingExecution(cds, executionInfo, executionContext, this,
(Dispatch)connection);
}
- return null;
} catch (ResourceException e) {
throw new TranslatorException(e);
}
+ return null;
}
private RequestPreprocessor getRequestPreProcessor() throws TranslatorException {
Modified:
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/BaseStreamingExecution.java
===================================================================
---
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/BaseStreamingExecution.java 2010-05-18
20:59:49 UTC (rev 2141)
+++
trunk/connectors/translator-xml/src/main/java/org/teiid/translator/xml/streaming/BaseStreamingExecution.java 2010-05-19
20:01:26 UTC (rev 2142)
@@ -22,8 +22,10 @@
package org.teiid.translator.xml.streaming;
import java.io.StringReader;
+import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URLEncoder;
import java.sql.SQLException;
import java.sql.SQLXML;
import java.util.ArrayList;
@@ -40,11 +42,10 @@
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.Assertion;
-import org.teiid.language.Select;
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.ResultSetExecution;
@@ -56,14 +57,14 @@
import org.teiid.translator.xml.ExecutionInfo;
import org.teiid.translator.xml.OutputXPathDesc;
import org.teiid.translator.xml.ParameterDescriptor;
-import org.teiid.translator.xml.QueryAnalyzer;
-import org.teiid.translator.xml.RequestGenerator;
import org.teiid.translator.xml.XMLExecutionFactory;
import org.teiid.translator.xml.XMLPlugin;
public class BaseStreamingExecution implements ResultSetExecution {
- public static final String PARM_INPUT_XPATH_TABLE_PROPERTY_NAME =
"XPathRootForInput"; //$NON-NLS-1$
+ private static final String DOT_SLASH = "./"; //$NON-NLS-1$
+ private static final String SLASH = "/"; //$NON-NLS-1$
+ public static final String PARM_INPUT_XPATH_TABLE_PROPERTY_NAME =
"XPathRootForInput"; //$NON-NLS-1$
public static final String PARM_INPUT_NAMESPACE_TABLE_PROPERTY_NAME =
"NamespaceForDocument"; //$NON-NLS-1$
public final static String soapNSLabel = "SOAP-ENV"; //$NON-NLS-1$
public static final String soapHeader= "Header"; //$NON-NLS-1$
@@ -75,47 +76,36 @@
private int resultIndex = 0;
// injected state
- protected RuntimeMetadata metadata;
protected ExecutionContext context;
protected XMLExecutionFactory executionFactory;
Dispatch<Source> dispatch;
ExecutionInfo executionInfo;
- private Source soapPayload;
+ Source soapPayload;
Iterator<Document> resultsIterator;
- public BaseStreamingExecution(Select command, RuntimeMetadata rtMetadata,
ExecutionContext context, XMLExecutionFactory executionFactory, Dispatch<Source>
dispatch) throws TranslatorException {
- this.metadata = rtMetadata;
+ public BaseStreamingExecution(List<CriteriaDesc> requestParams, ExecutionInfo
executionInfo, ExecutionContext context, XMLExecutionFactory executionFactory,
Dispatch<Source> dispatch) throws TranslatorException {
this.context = context;
this.executionFactory = executionFactory;
this.dispatch = dispatch;
-
- QueryAnalyzer analyzer = new QueryAnalyzer(command);
- this.executionInfo = analyzer.getExecutionInfo();
- List<CriteriaDesc[]> requestPerms = analyzer.getRequestPerms();
+ this.executionInfo = executionInfo;
- for (CriteriaDesc[] criteria : requestPerms) {
- processOutputXPathDescs(this.executionInfo.getRequestedColumns(),
Arrays.asList(criteria));
- }
+ processOutputXPathDescs(this.executionInfo.getRequestedColumns(), requestParams);
- if (checkIfRequestIsNeeded(this.executionInfo)) {
- for (CriteriaDesc[] criteria : requestPerms) {
- List<CriteriaDesc[]> parameters =
RequestGenerator.getRequests(Arrays.asList(criteria));
-
- // Build a query String for http
- String queryString = buildQueryString(parameters);
- this.dispatch.getRequestContext().put(MessageContext.QUERY_STRING,
queryString);
-
- String endpoint = buildAlternateEndpoint(this.executionInfo);
- if (endpoint == null) {
- this.dispatch.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY,
endpoint);
- }
- else {
- String pathInfo = buildPath(this.executionInfo);
- if (pathInfo != null) {
- this.dispatch.getRequestContext().put(MessageContext.PATH_INFO,
pathInfo);
- }
- }
- }
+ if (checkIfRequestIsNeeded(this.executionInfo)) {
+ // Build a query String for http
+ String queryString = buildQueryString(requestParams);
+ this.dispatch.getRequestContext().put(MessageContext.QUERY_STRING,
queryString);
+
+ String endpoint = buildAlternateEndpoint(this.executionInfo);
+ if (endpoint == null) {
+ this.dispatch.getRequestContext().put(Dispatch.ENDPOINT_ADDRESS_PROPERTY,
endpoint);
+ }
+ else {
+ String pathInfo = buildPath(this.executionInfo);
+ if (pathInfo != null) {
+ this.dispatch.getRequestContext().put(MessageContext.PATH_INFO, pathInfo);
+ }
+ }
String soapAction =
this.executionInfo.getOtherProperties().get("SOAPAction"); //$NON-NLS-1$
if (soapAction != null) {
@@ -126,7 +116,7 @@
try {
// Build XML string for HTTP
- String xmlPayload = buildSimpleXML(requestPerms);
+ String xmlPayload = buildSimpleXML(requestParams);
if (xmlPayload != null) {
Map<String, Object> map =
(Map)this.dispatch.getRequestContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
if (map == null) {
@@ -144,7 +134,7 @@
try {
// Build XML for SOAP
- String soapIn = buildSOAPInput(requestPerms);
+ String soapIn = buildSOAPInput(requestParams);
if(soapIn != null) {
this.soapPayload = new StreamSource(new StringReader(soapIn));
if (executionFactory.isLogRequestResponseDocs()) {
@@ -161,15 +151,16 @@
}
- private String buildQueryString(List<CriteriaDesc[]> parameters) throws
TranslatorException{
+ private String buildQueryString(List<CriteriaDesc> parameters) throws
TranslatorException{
StringBuilder sb = new StringBuilder();
-
- for (CriteriaDesc[] query: parameters) {
- for(CriteriaDesc cd: query) {
- String name = (cd.getInputXpath() == null || cd.getInputXpath().length()
== 0) ? cd.getColumnName() : cd.getInputXpath();
-
sb.append(name).append("=").append(cd.getCurrentIndexValue()).append("&");
//$NON-NLS-1$ //$NON-NLS-2$
- }
- }
+ try {
+ for(CriteriaDesc cd: parameters) {
+ String name = (cd.getInputXpath() == null || cd.getInputXpath().length() == 0) ?
cd.getColumnName() : cd.getInputXpath();
+ sb.append(URLEncoder.encode(name,
"UTF-8")).append("=").append(URLEncoder.encode(cd.getCurrentIndexValue(),
"UTF-8")).append("&"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//$NON-NLS-4$
+ }
+ } catch (UnsupportedEncodingException e) {
+ throw new TeiidRuntimeException(e);
+ }
return sb.toString();
}
@@ -234,9 +225,7 @@
@Override
public void execute() throws TranslatorException {
- ArrayList<Document> result = new ArrayList<Document>();
- result.add(getDocumentStream(this.executionInfo));
- this.resultsIterator = result.iterator();
+ this.resultsIterator = getDocumentStream(this.executionInfo).iterator();
}
/**
@@ -319,16 +308,18 @@
}
- private Document getDocumentStream(ExecutionInfo executionInfo) {
- Document document;
+ private List<Document> getDocumentStream(ExecutionInfo executionInfo) {
+ ArrayList<Document> docs = new ArrayList<Document>();
// Is this a request part joining across a document
CriteriaDesc criterion = executionInfo.getResponseIDCriterion();
if (criterion != null) {
String responseid = (String) (criterion.getValues().get(0));
- SQLXML xml = this.executionFactory.getResponse(responseid);
- Assertion.isNotNull(xml);
- document = new DocumentImpl(xml, responseid);
+ List<SQLXML> xmls = this.executionFactory.getResponse(responseid);
+ for (SQLXML xml:xmls) {
+ Assertion.isNotNull(xml);
+ docs.add(new DocumentImpl(xml, responseid));
+ }
} else {
// Not a join, but might still be cached.
// Not cached, so make the request
@@ -341,21 +332,17 @@
}
}
this.executionFactory.setResponse(this.context.getExecutionCountIdentifier(),
responseBody);
- document = new DocumentImpl(responseBody,
this.context.getExecutionCountIdentifier());
+ docs.add(new DocumentImpl(responseBody,
this.context.getExecutionCountIdentifier()));
}
- return document;
+ return docs;
}
- private String buildSOAPInput(List<CriteriaDesc[]> params) throws
TranslatorException {
- List<CriteriaDesc[]> requestPerms =
RequestGenerator.getRequests(Arrays.asList(params.get(0)));
- CriteriaDesc[] parameters = requestPerms.get(0);
-
- List<CriteriaDesc> queryList = new
ArrayList<CriteriaDesc>(Arrays.asList(parameters));
+ private String buildSOAPInput(List<CriteriaDesc> params) throws
TranslatorException {
List<CriteriaDesc> headerParams = new ArrayList<CriteriaDesc>();
List<CriteriaDesc> bodyParams = new ArrayList<CriteriaDesc>();
- for (CriteriaDesc desc : queryList) {
+ for (CriteriaDesc desc : params) {
if (desc.getInputXpath().startsWith(soapNSLabel+ ":" + soapHeader)) {
//$NON-NLS-1$
headerParams.add(desc);
} else {
@@ -369,15 +356,13 @@
DocumentBuilder builder = new DocumentBuilder();
//TODO: always set to encoded false - rareddy
builder.setUseTypeAttributes(false);
- final String slash = "/"; //$NON-NLS-1$
- final String dotSlash = "./"; //$NON-NLS-1$
boolean hasDummy = false;
- if (inputParmsXPath.equals(dotSlash) || inputParmsXPath.equals(slash) ||
inputParmsXPath.equals("")) { //$NON-NLS-1$
+ if (inputParmsXPath == null || inputParmsXPath.equals(DOT_SLASH) ||
inputParmsXPath.equals(SLASH) || inputParmsXPath.equals("")) { //$NON-NLS-1$
inputParmsXPath = DUMMY_NS_PREFIX + ":dummy"; //$NON-NLS-1$
namespacePrefixes = namespacePrefixes + " xmlns:" + DUMMY_NS_PREFIX +
"=\"" + DUMMY_NS_NAME + "\""; //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
hasDummy = true;
}
- org.jdom.Document doc = builder.buildDocument(Arrays.asList(parameters),
inputParmsXPath, namespacePrefixes);
+ org.jdom.Document doc = builder.buildDocument(params, inputParmsXPath,
namespacePrefixes);
if (hasDummy) {
// Since there is no real root - these should all be elements
Element element = (Element) doc.getRootElement().getChildren().get(0);
@@ -387,18 +372,18 @@
return new XMLOutputter().outputString(doc);
}
- private String buildSimpleXML(List<CriteriaDesc[]> params) throws
TranslatorException{
- List<CriteriaDesc[]> requestPerms =
RequestGenerator.getRequests(Arrays.asList(params.get(0)));
- CriteriaDesc[] parameters = requestPerms.get(0);
-
+ private String buildSimpleXML(List<CriteriaDesc> params) throws
TranslatorException{
DocumentBuilder builder = new DocumentBuilder();
Map<String, String> props = executionInfo.getOtherProperties();
String inputParmsXPath =
props.get(DocumentBuilder.PARM_INPUT_XPATH_TABLE_PROPERTY_NAME);
String namespacePrefixes = props.get(Constants.NAMESPACE_PREFIX_PROPERTY_NAME);
+
+ if(inputParmsXPath.equals(SLASH)) {
+ inputParmsXPath = "SLASH"; //$NON-NLS-1$
+ }
- org.jdom.Document inputXMLDoc = builder.buildDocument(Arrays.asList(parameters),
inputParmsXPath,namespacePrefixes);
+ org.jdom.Document inputXMLDoc = builder.buildDocument(params,
inputParmsXPath,namespacePrefixes);
XMLOutputter out = new XMLOutputter();
return out.outputString(inputXMLDoc).trim();
}
-
}
\ No newline at end of file
Added:
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestCartesianCriteriaGenerator.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestCartesianCriteriaGenerator.java
(rev 0)
+++
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestCartesianCriteriaGenerator.java 2010-05-19
20:01:26 UTC (rev 2142)
@@ -0,0 +1,119 @@
+/*
+ * 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));
+ }
+ }
+
+}
Property changes on:
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/TestCartesianCriteriaGenerator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestBaseStreamingExecution.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestBaseStreamingExecution.java
(rev 0)
+++
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestBaseStreamingExecution.java 2010-05-19
20:01:26 UTC (rev 2142)
@@ -0,0 +1,83 @@
+/*
+ * 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.streaming;
+
+import java.util.Map;
+
+import javax.xml.ws.handler.MessageContext;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.language.Select;
+import org.teiid.metadata.index.VDBMetadataFactory;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.xml.XMLExecutionFactory;
+
+import com.metamatrix.cdk.api.TranslationUtility;
+
+import static org.junit.Assert.*;
+
+@SuppressWarnings("nls")
+public class TestBaseStreamingExecution {
+
+ @Test
+ public void testXMLGeneration() throws Exception {
+
+ XMLExecutionFactory factory = new XMLExecutionFactory();
+
+ String vdbPath = UnitTestUtil.getTestDataPath()+"/cis.vdb";
+ TranslationUtility util = new
TranslationUtility(VDBMetadataFactory.getVDBMetadata(vdbPath));
+
+ String sql = "SELECT FullCountryInfoSoapRequest.ResponseOut FROM
FullCountryInfoSoapRequest WHERE FullCountryInfoSoapRequest.sCountryISOCode =
'US'";
+
+ ExecutionContext context = Mockito.mock(ExecutionContext.class);
+ Mockito.stub(context.getExecutionCountIdentifier()).toReturn("1.1");
+
+ ResultSetExecution exec =
factory.createResultSetExecution((Select)util.parseCommand(sql), context,
util.createRuntimeMetadata(), TestSoapExecution.getCF());
+ assertTrue(exec instanceof BaseStreamingExecution);
+
+ BaseStreamingExecution bse = (BaseStreamingExecution)exec;
+ String soapRequest = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?><tns:FullCountryInfo
xmlns:tns=\"http://www.oorsprong.org/websamples.countryinfo\"&g...;
+ assertEquals(soapRequest, TestSoapExecution.getContent(bse.soapPayload));
+
+ Map<String, Object> map =
(Map)bse.dispatch.getRequestContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
+
+ String xmlRequest = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\r\n"+
+ "<SLASH
xmlns:mmn0=\"http://www.oorsprong.org/websamples.countryinfo\"
xmlns:tns=\"http://www.oorsprong.org/websamples.countryinfo\"&g...;
+ assertEquals(xmlRequest, map.get("xml"));
+
+ assertEquals("tns%3AFullCountryInfo%2Ftns%3AsCountryISOCode=US&",
bse.dispatch.getRequestContext().get(MessageContext.QUERY_STRING));
+
+ // response doc; nothing gets generated for this guy..
+ sql = "SELECT * FROM FullCountryInfoSoapResponse WHERE
FullCountryInfoSoapResponse.ResponseIn = '1.1'";
+ exec = factory.createResultSetExecution((Select)util.parseCommand(sql), context,
util.createRuntimeMetadata(), TestSoapExecution.getCF());
+ assertTrue(exec instanceof BaseStreamingExecution);
+ bse = (BaseStreamingExecution)exec;
+ assertNull(bse.soapPayload);
+ assertNull(bse.dispatch.getRequestContext().get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS));
+ assertNull(bse.dispatch.getRequestContext().get(MessageContext.QUERY_STRING));
+ }
+
+
+}
Property changes on:
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestBaseStreamingExecution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestSoapExecution.java
===================================================================
---
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestSoapExecution.java
(rev 0)
+++
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestSoapExecution.java 2010-05-19
20:01:26 UTC (rev 2142)
@@ -0,0 +1,244 @@
+/*
+ * 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.streaming;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Future;
+
+import javax.resource.ResourceException;
+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.Dispatch;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.Response;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.resource.spi.BasicConnection;
+import org.teiid.resource.spi.BasicConnectionFactory;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.xml.XMLExecutionFactory;
+
+import com.metamatrix.cdk.api.ConnectorHost;
+
+@SuppressWarnings("nls")
+public class TestSoapExecution {
+
+ public static BasicConnectionFactory getCF() {
+ BasicConnectionFactory cf = new BasicConnectionFactory() {
+ @Override
+ public BasicConnection getConnection() throws ResourceException {
+ String usResult = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>"
+ + "<m:FullCountryInfoResponse
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:FullCountryInfoResult>"
+ + "<m:sISOCode
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sName
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
States</m:sName>"
+ + "<m:sCapitalCity
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sPhoneCode
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sContinentCode
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sCurrencyISOCode
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sCountryFlag
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:Languages
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:tLanguage
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sISOCode
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sName
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "</m:tLanguage>"
+ + "</m:Languages>"
+ + "</m:FullCountryInfoResult>"
+ + "</m:FullCountryInfoResponse>";
+
+ String jpResult = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>"
+ + "<m:FullCountryInfoResponse
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:FullCountryInfoResult>"
+ + "<m:sISOCode
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sName
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sCapitalCity
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sPhoneCode
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sContinentCode
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sCurrencyISOCode
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sCountryFlag
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:Languages
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:tLanguage
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sISOCode
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "<m:sName
xmlns:m=\"http://www.oorsprong.org/websamples.countryinfo\">...
+ + "</m:tLanguage>"
+ + "</m:Languages>"
+ + "</m:FullCountryInfoResult>"
+ + "</m:FullCountryInfoResponse>";
+
+ HashMap<String, String> map = new HashMap<String, String>();
+ map.put("US", usResult);
+ map.put("JP", jpResult);
+ return new MyDispatch(map);
+ }
+
+ };
+ return cf;
+ }
+
+ //@Test
+ public void testSOAPSingleRequest() throws Exception {
+
+ XMLExecutionFactory factory = new XMLExecutionFactory();
+
+ String vdbPath = UnitTestUtil.getTestDataPath()+"/cis.vdb";
+ ConnectorHost host = new ConnectorHost(factory, getCF(), vdbPath);
+ ExecutionContext context = Mockito.mock(ExecutionContext.class);
+ Mockito.stub(context.getExecutionCountIdentifier()).toReturn("1.1");
+ host.setExecutionContext(context);
+
+ List result = host.executeCommand("SELECT FullCountryInfoSoapRequest.ResponseOut
FROM FullCountryInfoSoapRequest WHERE FullCountryInfoSoapRequest.sCountryISOCode =
'US'", false);
+ assertEquals(1, result.size());
+ assertEquals("1.1", ((List)result.get(0)).get(0));
+
+ result = host.executeCommand("SELECT * FROM FullCountryInfoSoapResponse WHERE
FullCountryInfoSoapResponse.ResponseIn = '1.1'");
+
+ List row = (List)result.get(0);
+ assertEquals("1.1", row.get(0));
+ assertEquals("/m:FullCountryInfoResponse[0]", row.get(1));
+ assertEquals("US", row.get(2));
+ assertEquals("United States", row.get(3));
+ }
+
+
+ @Test
+ public void testSOAPMultipleRequests() throws Exception {
+
+ XMLExecutionFactory factory = new XMLExecutionFactory();
+
+
+ String vdbPath = UnitTestUtil.getTestDataPath()+"/cis.vdb";
+ ConnectorHost host = new ConnectorHost(factory, getCF(), vdbPath);
+ ExecutionContext context = Mockito.mock(ExecutionContext.class);
+ Mockito.stub(context.getExecutionCountIdentifier()).toReturn("1.2");
+ host.setExecutionContext(context);
+
+ List result = host.executeCommand("SELECT FullCountryInfoSoapRequest.ResponseOut
FROM FullCountryInfoSoapRequest WHERE FullCountryInfoSoapRequest.sCountryISOCode
IN('US', 'JP')", false);
+ assertEquals(2, result.size());
+ assertEquals("1.2", ((List)result.get(0)).get(0));
+
+
+ result = host.executeCommand("SELECT * FROM FullCountryInfoSoapResponse WHERE
FullCountryInfoSoapResponse.ResponseIn = '1.2'");
+ assertEquals(2, result.size());
+
+ List row = (List)result.get(0);
+ assertEquals("1.2", row.get(0));
+ assertEquals("/m:FullCountryInfoResponse[0]", row.get(1));
+ assertEquals("US", row.get(2));
+ assertEquals("United States", row.get(3));
+
+ row = (List)result.get(1);
+ assertEquals("1.2", row.get(0));
+ assertEquals("/m:FullCountryInfoResponse[0]", row.get(1));
+ assertEquals("JP", row.get(2));
+ assertEquals("Japan", row.get(3));
+ }
+
+
+ static class MyDispatch extends BasicConnection implements Dispatch<Source>{
+ private Map<String, Object> requestContext = new HashMap<String,
Object>();
+ private Map<String, String> result;
+
+ public MyDispatch(Map<String, String> result) {
+ this.result = result;
+ }
+
+ @Override
+ public Source invoke(Source msg) {
+ String content = getContent(msg);
+ if
(content.indexOf("<tns:sCountryISOCode>US</tns:sCountryISOCode>") !=
-1){
+ return new StreamSource(new StringReader(this.result.get("US")));
+ }
+ if
(content.indexOf("<tns:sCountryISOCode>JP</tns:sCountryISOCode>") !=
-1){
+ return new StreamSource(new StringReader(this.result.get("JP")));
+ }
+ return null;
+ }
+
+ @Override
+ public Response<Source> invokeAsync(Source msg) {
+ return null;
+ }
+
+ @Override
+ public Future<?> invokeAsync(Source msg, AsyncHandler<Source> handler) {
+ return null;
+ }
+
+ @Override
+ public void invokeOneWay(Source msg) {
+ }
+
+ @Override
+ public Binding getBinding() {
+ return null;
+ }
+
+ @Override
+ public EndpointReference getEndpointReference() {
+ return null;
+ }
+
+ @Override
+ public <T extends EndpointReference> T getEndpointReference(Class<T> clazz)
{
+ return null;
+ }
+
+ @Override
+ public Map<String, Object> getRequestContext() {
+ return this.requestContext;
+ }
+
+ @Override
+ public Map<String, Object> getResponseContext() {
+ return null;
+ }
+
+ @Override
+ public void close() throws ResourceException {
+ }
+ }
+
+ public static String getContent(Source msg) {
+ StreamSource ss = (StreamSource)msg;
+ BufferedReader reader = new BufferedReader(ss.getReader());
+ String line = null;
+ String content = "";
+ try {
+ while ((line = reader.readLine()) != null) {
+ content = content + line;
+ }
+ } catch (IOException e) {
+ }
+ return content;
+ }
+}
Property changes on:
trunk/connectors/translator-xml/src/test/java/org/teiid/translator/xml/streaming/TestSoapExecution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/connectors/translator-xml/src/test/resources/cis.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/connectors/translator-xml/src/test/resources/cis.vdb
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/metadata/src/test/java/com/metamatrix/cdk/api/ConnectorHost.java
===================================================================
--- trunk/metadata/src/test/java/com/metamatrix/cdk/api/ConnectorHost.java 2010-05-18
20:59:49 UTC (rev 2141)
+++ trunk/metadata/src/test/java/com/metamatrix/cdk/api/ConnectorHost.java 2010-05-19
20:01:26 UTC (rev 2142)
@@ -73,22 +73,30 @@
Command command = getCommand(query);
RuntimeMetadata runtimeMetadata = getRuntimeMetadata();
- return executeCommand(command, runtimeMetadata);
+ return executeCommand(command, runtimeMetadata, true);
}
+ public List executeCommand(String query, boolean close) throws TranslatorException {
+ Command command = getCommand(query);
+ RuntimeMetadata runtimeMetadata = getRuntimeMetadata();
+
+ return executeCommand(command, runtimeMetadata, close);
+ }
+
public List executeCommand(Command command) throws TranslatorException {
RuntimeMetadata runtimeMetadata = getRuntimeMetadata();
- return executeCommand(command, runtimeMetadata);
+ return executeCommand(command, runtimeMetadata, true);
}
- private List executeCommand(Command command, RuntimeMetadata runtimeMetadata)
+ private List executeCommand(Command command, RuntimeMetadata runtimeMetadata, boolean
close)
throws TranslatorException {
Execution exec = connector.createExecution(command, this.executionContext,
runtimeMetadata, this.connectionFactory);
exec.execute();
List results = readResultsFromExecution(exec);
- exec.close();
-
+ if (close) {
+ exec.close();
+ }
return results;
}
@@ -103,7 +111,7 @@
}
public int[] executeBatchedUpdates(Command[] commands, RuntimeMetadata
runtimeMetadata) throws TranslatorException {
- List<List> result = executeCommand(new
BatchedUpdates(Arrays.asList(commands)), runtimeMetadata);
+ List<List> result = executeCommand(new
BatchedUpdates(Arrays.asList(commands)), runtimeMetadata, true);
int[] counts = new int[result.size()];
for (int i = 0; i < counts.length; i++) {
counts[i] = ((Integer)result.get(i).get(0)).intValue();