teiid SVN: r2237 - in trunk: api/src/main/java/org/teiid/translator and 26 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-06-16 15:02:47 -0400 (Wed, 16 Jun 2010)
New Revision: 2237
Modified:
trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java
trunk/common-core/src/main/java/org/teiid/core/types/BaseLob.java
trunk/common-core/src/main/java/org/teiid/core/types/InputStreamFactory.java
trunk/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java
trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java
trunk/common-core/src/main/java/org/teiid/core/util/Base64.java
trunk/common-core/src/main/java/org/teiid/core/util/ReaderInputStream.java
trunk/common-core/src/test/java/org/teiid/core/util/TestReaderInputStream.java
trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java
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/i18n.properties
trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.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/documentation/reference/src/main/docbook/en-US/content/translators.xml
trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/DocumentInProgress.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLUtil.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLSerialize.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/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/TestFunctionLibrary.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAccessPatternValidation.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/validator/TestValidator.java
trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java
trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
Log:
TEIID-1021 adding support for clob<->blob conversions based upon charset encodings (this will also be used by xmlserialize, but that was not added yet). Also started reorganizing the scalar functions reference.
Modified: trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
===================================================================
--- trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -607,9 +607,7 @@
if(Number.class.isAssignableFrom(type)) {
buffer.append(val);
} else if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
- buffer.append("{b '") //$NON-NLS-1$
- .append(val)
- .append("'}"); //$NON-NLS-1$
+ buffer.append(obj.getValue().equals(Boolean.TRUE) ? TRUE : FALSE);
} else if(type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
buffer.append("{ts '") //$NON-NLS-1$
.append(val)
Modified: trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -40,6 +40,8 @@
public static final String ASCII = "ascii"; //$NON-NLS-1$
public static final String CHAR = "char"; //$NON-NLS-1$
public static final String CONCAT = "concat"; //$NON-NLS-1$
+ public static final String DECODE = "decode"; //$NON-NLS-1$
+ public static final String ENCODE = "encode"; //$NON-NLS-1$
//public static final String DIFFERENCE = "difference";
public static final String INITCAP = "initcap"; //$NON-NLS-1$
public static final String INSERT = "insert"; //$NON-NLS-1$
Modified: trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -678,7 +678,7 @@
public void setAsciiStream(int parameterIndex, final InputStream x)
throws SQLException {
- this.setObject(parameterIndex, new ClobImpl(new InputStreamFactory("US-ASCII") { //$NON-NLS-1$
+ this.setObject(parameterIndex, new ClobImpl(new InputStreamFactory() {
@Override
public InputStream getInputStream() throws IOException {
return x;
@@ -726,7 +726,7 @@
}
public void setClob(int parameterIndex, final Reader reader) throws SQLException {
- this.setObject(parameterIndex, new ClobImpl(new InputStreamFactory(Streamable.ENCODING) {
+ this.setObject(parameterIndex, new ClobImpl(new InputStreamFactory() {
@Override
public InputStream getInputStream() throws IOException {
Modified: trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -295,15 +295,16 @@
}
}
if(currentValue instanceof ClobType){
- currentValue = new ClobImpl(createInputStreamFactory((ClobType)currentValue, null), ((ClobType)currentValue).getLength());
+ currentValue = new ClobImpl(createInputStreamFactory((ClobType)currentValue), ((ClobType)currentValue).getLength());
}
else if (currentValue instanceof BlobType) {
- InputStreamFactory isf = createInputStreamFactory((BlobType)currentValue, null);
+ InputStreamFactory isf = createInputStreamFactory((BlobType)currentValue);
isf.setLength(((BlobType)currentValue).getLength());
currentValue = new BlobImpl(isf);
}
else if (currentValue instanceof XMLType) {
- currentValue = new SQLXMLImpl(createInputStreamFactory((XMLType)currentValue, ((XMLType)currentValue).getEncoding()));
+ currentValue = new SQLXMLImpl(createInputStreamFactory((XMLType)currentValue));
+ ((SQLXMLImpl)currentValue).setEncoding(((XMLType)currentValue).getEncoding());
}
}
else if (currentValue instanceof java.util.Date) {
@@ -316,12 +317,9 @@
return currentValue;
}
- private InputStreamFactory createInputStreamFactory(Streamable<?> type, String encoding) {
- if (encoding == null) {
- encoding = Streamable.ENCODING;
- }
+ private InputStreamFactory createInputStreamFactory(Streamable<?> type) {
final StreamingLobChunckProducer.Factory factory = new StreamingLobChunckProducer.Factory(this.statement.getDQP(), this.requestID, type);
- InputStreamFactory isf = new InputStreamFactory(encoding) {
+ InputStreamFactory isf = new InputStreamFactory() {
@Override
public InputStream getInputStream() throws IOException {
return new LobChunkInputStream(factory.getLobChunkProducer());
Modified: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java
===================================================================
--- trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -25,6 +25,7 @@
import java.io.Externalizable;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
@@ -196,7 +197,7 @@
references.add(sfr);
return sfr;
} else if (obj instanceof SQLXML) {
- streams.add(new ReaderInputStream(((SQLXML)obj).getCharacterStream(), Charset.forName(Streamable.ENCODING)));
+ streams.add(((SQLXML)obj).getBinaryStream());
StreamFactoryReference sfr = new SQLXMLImpl();
references.add(sfr);
return sfr;
@@ -273,7 +274,7 @@
@Override
public int read(char[] cbuf, int off, int len) throws IOException {
if (r == null) {
- r = isf.getCharacterStream();
+ r = new InputStreamReader(isf.getInputStream(), Streamable.ENCODING);
}
return r.read(cbuf, off, len);
}
Modified: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java
===================================================================
--- trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/ObjectDecoderInputStream.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -38,7 +38,6 @@
import java.util.List;
import org.teiid.core.types.InputStreamFactory;
-import org.teiid.core.types.Streamable;
import org.teiid.core.types.InputStreamFactory.StreamFactoryReference;
import org.teiid.core.util.ExternalizeUtil;
@@ -104,7 +103,7 @@
if (stream == null) {
final File f = File.createTempFile("teiid", null); //$NON-NLS-1$
StreamFactoryReference sfr = streams.get(streamIndex);
- sfr.setStreamFactory(new InputStreamFactory(Streamable.ENCODING) {
+ sfr.setStreamFactory(new InputStreamFactory() {
@Override
public InputStream getInputStream() throws IOException {
Modified: trunk/common-core/src/main/java/org/teiid/core/types/BaseLob.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/BaseLob.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/common-core/src/main/java/org/teiid/core/types/BaseLob.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -3,9 +3,11 @@
import java.io.Externalizable;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Reader;
+import java.nio.charset.Charset;
import java.sql.SQLException;
import org.teiid.core.types.InputStreamFactory.StreamFactoryReference;
@@ -15,6 +17,7 @@
private static final long serialVersionUID = -1586959324208959519L;
private InputStreamFactory streamFactory;
+ private String encoding;
public BaseLob() {
@@ -35,6 +38,14 @@
return streamFactory;
}
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
public void free() throws SQLException {
if (this.streamFactory != null) {
try {
@@ -50,12 +61,20 @@
public Reader getCharacterStream() throws SQLException {
try {
- return this.getStreamFactory().getCharacterStream();
+ Reader r = this.getStreamFactory().getCharacterStream();
+ if (r != null) {
+ return r;
+ }
} catch (IOException e) {
SQLException ex = new SQLException(e.getMessage());
ex.initCause(e);
throw ex;
}
+ String enc = getEncoding();
+ if (enc == null) {
+ enc = Streamable.ENCODING;
+ }
+ return new InputStreamReader(getBinaryStream(), Charset.forName(enc));
}
public InputStream getBinaryStream() throws SQLException {
Modified: trunk/common-core/src/main/java/org/teiid/core/types/InputStreamFactory.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/InputStreamFactory.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/common-core/src/main/java/org/teiid/core/types/InputStreamFactory.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -27,7 +27,6 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
import java.sql.Blob;
@@ -47,31 +46,15 @@
}
- private String encoding;
private String systemId;
private long length = -1;
- public InputStreamFactory() {
- }
-
- public InputStreamFactory(String encoding) {
- this.encoding = encoding;
- }
-
/**
* Get a new InputStream
* @return
*/
public abstract InputStream getInputStream() throws IOException;
- public String getEncoding() {
- return encoding;
- }
-
- public void setEncoding(String encoding) {
- this.encoding = encoding;
- }
-
@Override
public String getSystemId() {
return this.systemId;
@@ -95,11 +78,7 @@
}
public Reader getCharacterStream() throws IOException {
- String enc = this.getEncoding();
- if (enc == null) {
- enc = Charset.defaultCharset().displayName();
- }
- return new InputStreamReader(this.getInputStream(), enc);
+ return null;
}
public static class FileInputStreamFactory extends InputStreamFactory {
@@ -107,11 +86,6 @@
private File f;
public FileInputStreamFactory(File f) {
- this(f, null);
- }
-
- public FileInputStreamFactory(File f, String encoding) {
- super(encoding);
this.f = f;
this.setSystemId(f.toURI().toASCIIString());
}
@@ -131,16 +105,24 @@
public static class ClobInputStreamFactory extends InputStreamFactory {
private Clob clob;
+ private Charset charset = Charset.forName(Streamable.ENCODING);
public ClobInputStreamFactory(Clob clob) {
- super(Streamable.ENCODING);
this.clob = clob;
}
+ public Charset getCharset() {
+ return charset;
+ }
+
+ public void setCharset(Charset charset) {
+ this.charset = charset;
+ }
+
@Override
public InputStream getInputStream() throws IOException {
try {
- return new ReaderInputStream(clob.getCharacterStream(), Charset.forName(Streamable.ENCODING));
+ return new ReaderInputStream(clob.getCharacterStream(), charset);
} catch (SQLException e) {
throw new IOException(e);
}
Modified: trunk/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -26,7 +26,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.io.Reader;
import java.io.Writer;
import java.nio.charset.Charset;
import java.sql.SQLException;
@@ -57,9 +56,7 @@
* read operations.
*/
public class SQLXMLImpl extends BaseLob implements SQLXML {
-
- private boolean inMemory;
-
+
public SQLXMLImpl() {
}
@@ -69,13 +66,13 @@
* @param bytes
*/
public SQLXMLImpl(final byte[] bytes) {
- super(new InputStreamFactory(Streamable.ENCODING) {
+ super(new InputStreamFactory() {
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(bytes);
}
});
- inMemory = true;
+ setEncoding(Streamable.ENCODING);
}
public SQLXMLImpl(final String str) {
@@ -87,22 +84,21 @@
}
@Override
- public Reader getCharacterStream() throws SQLException {
- setEncoding();
- return super.getCharacterStream();
- }
-
- private void setEncoding() throws SQLException {
- String encoding = XMLType.getEncoding(this);
- if (encoding != null) {
- this.getStreamFactory().setEncoding(encoding);
+ public String getEncoding() {
+ String enc = super.getEncoding();
+ if (enc != null) {
+ return enc;
+ }
+ try {
+ enc = XMLType.getEncoding(this.getBinaryStream());
+ if (enc != null) {
+ setEncoding(enc);
+ }
+ } catch (SQLException e) {
}
- }
+ return Streamable.ENCODING;
+ }
- public boolean isInMemory() {
- return inMemory;
- }
-
@SuppressWarnings("unchecked")
public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException {
if (sourceClass == null || sourceClass == StreamSource.class) {
@@ -160,4 +156,5 @@
throws SQLException {
throw SqlUtil.createFeatureNotSupportedException();
}
+
}
Modified: trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -108,13 +108,6 @@
this.type = type;
}
- public Boolean isInMemory() {
- if (this.reference instanceof SQLXMLImpl) {
- return (((SQLXMLImpl) this.reference).isInMemory());
- }
- return null;
- }
-
public String getEncoding() {
return encoding;
}
@@ -145,32 +138,35 @@
* @return
*/
public static String getEncoding(SQLXML xml) {
- InputStream is = null;
try {
if (xml instanceof XMLType) {
XMLType type = (XMLType)xml;
+ if (type.encoding != null) {
+ return type.encoding;
+ }
xml = type.reference;
}
if (xml instanceof SQLXMLImpl) {
- String encoding = ((SQLXMLImpl)xml).getStreamFactory().getEncoding();
- if (encoding != null) {
- return encoding;
- }
+ return ((SQLXMLImpl)xml).getEncoding();
}
- XMLInputFactory factory = XMLInputFactory.newInstance();
- is = xml.getBinaryStream();
- XMLStreamReader reader = factory.createXMLStreamReader(is);
- return reader.getEncoding();
+ return getEncoding(xml.getBinaryStream());
} catch (SQLException e) {
return null;
+ }
+ }
+
+ public static String getEncoding(InputStream is) {
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ XMLStreamReader reader;
+ try {
+ reader = factory.createXMLStreamReader(is);
+ return reader.getEncoding();
} catch (XMLStreamException e) {
return null;
} finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- }
+ try {
+ is.close();
+ } catch (IOException e) {
}
}
}
Modified: trunk/common-core/src/main/java/org/teiid/core/util/Base64.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/Base64.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/common-core/src/main/java/org/teiid/core/util/Base64.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -413,23 +413,13 @@
* @return the decoded data
* @since 1.4
*/
- public static byte[] decode( String s )
+ public static byte[] decode( CharSequence s )
{
- byte[] source;
- try
- {
- source = s.getBytes( PREFERRED_ENCODING );
- } // end try
- catch( java.io.UnsupportedEncodingException uee )
- {
- source = s.getBytes();
- } // end catch
- //</change>
- if (source.length % 4 != 0) {
+ if (s.length() % 4 != 0) {
throw new IllegalArgumentException("Source bytes are not valid"); //$NON-NLS-1$
}
byte[] DECODABET = _STANDARD_DECODABET;
- int len = source.length;
+ int len = s.length();
byte[] outBuff = new byte[ len * 3 / 4 ]; // Upper limit on size of output
int outBuffPosn = 0;
@@ -440,7 +430,7 @@
byte sbiDecode = 0;
for( i = 0; i < len; i++ )
{
- sbiCrop = (byte)(source[i] & 0x7f); // Only the low seven bits
+ sbiCrop = (byte)(s.charAt(i) & 0x7f); // Only the low seven bits
sbiDecode = DECODABET[ sbiCrop ];
if( sbiDecode >= WHITE_SPACE_ENC ) // White space, Equals sign or better
Modified: trunk/common-core/src/main/java/org/teiid/core/util/ReaderInputStream.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/ReaderInputStream.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/common-core/src/main/java/org/teiid/core/util/ReaderInputStream.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -27,25 +27,27 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStreamWriter;
import java.io.Reader;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
+import java.io.Writer;
import java.nio.charset.Charset;
import org.teiid.core.types.DataTypeManager;
+/**
+ * Implements a buffered {@link InputStream} for a given {@link Reader} and {@link Charset}
+ */
public class ReaderInputStream extends InputStream {
+ //even though we're dealing with chars, we'll use the same default
private static final int DEFAULT_BUFFER_SIZE = DataTypeManager.MAX_LOB_MEMORY_BYTES;
private final Reader reader;
- private final Charset charSet;
+ private Writer writer;
private char[] charBuffer;
-
+ private AccessibleByteArrayOutputStream out = new AccessibleByteArrayOutputStream();
private boolean hasMore = true;
- private ByteBuffer currentBuffer;
- private int prefixBytes;
- private boolean needsPrefix = true;
+ private int pos = 0;
public ReaderInputStream(Reader reader, Charset charSet) {
this(reader, charSet, DEFAULT_BUFFER_SIZE);
@@ -53,31 +55,27 @@
public ReaderInputStream(Reader reader, Charset charSet, int bufferSize) {
this.reader = reader;
- this.charSet = charSet;
+ this.writer = new OutputStreamWriter(out, charSet);
this.charBuffer = new char[bufferSize];
- if (charSet.displayName().equalsIgnoreCase("UTF-16")) { //$NON-NLS-1$
- prefixBytes = 2;
- }
}
@Override
public int read() throws IOException {
- if (currentBuffer == null || !currentBuffer.hasRemaining()) {
- if (!hasMore) {
- return -1;
- }
+ if (!hasMore) {
+ return -1;
+ }
+ while (pos >= out.getCount()) {
+ out.reset();
+ pos = 0;
int charsRead = reader.read(charBuffer);
if (charsRead == -1) {
hasMore = false;
return -1;
}
- currentBuffer = charSet.encode(CharBuffer.wrap(charBuffer, 0, charsRead));
- if (!needsPrefix) {
- currentBuffer.position(prefixBytes);
- }
- needsPrefix = false;
+ writer.write(charBuffer, 0, charsRead);
+ writer.flush();
}
- return currentBuffer.get() & 0xff;
+ return out.getBuffer()[pos++] & 0xff;
}
@Override
Modified: trunk/common-core/src/test/java/org/teiid/core/util/TestReaderInputStream.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/util/TestReaderInputStream.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/common-core/src/test/java/org/teiid/core/util/TestReaderInputStream.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -22,19 +22,18 @@
package org.teiid.core.util;
+import static org.junit.Assert.*;
+
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.StringReader;
import java.nio.charset.Charset;
-import org.teiid.core.util.ReaderInputStream;
+import org.junit.Test;
-import junit.framework.TestCase;
-
-
-public class TestReaderInputStream extends TestCase {
+public class TestReaderInputStream {
- public void testUTF8() throws Exception {
+ @Test public void testUTF8() throws Exception {
FileInputStream fis = new FileInputStream(UnitTestUtil.getTestDataFile("legal_notice.xml")); //$NON-NLS-1$
ReaderInputStream ris = new ReaderInputStream(new FileReader(UnitTestUtil.getTestDataFile("legal_notice.xml")), Charset.forName("UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -48,8 +47,7 @@
}
}
- //the encoding strategy is roughly equivalent to utf-16
- public void testUTF16() throws Exception {
+ @Test public void testUTF16() throws Exception {
String actual = "!?abc"; //$NON-NLS-1$
ReaderInputStream ris = new ReaderInputStream(new StringReader(actual), Charset.forName("UTF-16"), 1); //$NON-NLS-1$
byte[] result = new byte[(actual.length()) * 2 + 2];
@@ -58,7 +56,7 @@
assertEquals(resultString, actual);
}
- public void testASCII() throws Exception {
+ @Test public void testASCII() throws Exception {
String actual = "!?abc"; //$NON-NLS-1$
ReaderInputStream ris = new ReaderInputStream(new StringReader(actual), Charset.forName("US-ASCII"), 1); //$NON-NLS-1$
byte[] result = new byte[actual.length()];
Modified: trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java
===================================================================
--- trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/connectors/translator-file/src/main/java/org/teiid/translator/file/FileExecutionFactory.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -104,11 +104,13 @@
}
ArrayList<Object> result = new ArrayList<Object>(2);
final File file = files[index++];
- FileInputStreamFactory isf = new FileInputStreamFactory(file, encoding);
+ FileInputStreamFactory isf = new FileInputStreamFactory(file);
isf.setLength(file.length());
Object value = null;
if (isText) {
- value = new ClobType(new ClobImpl(isf, -1));
+ ClobImpl clob = new ClobImpl(isf, -1);
+ clob.setEncoding(encoding);
+ value = new ClobType(clob);
} else {
value = new BlobType(new BlobImpl(isf));
}
Modified: trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java
===================================================================
--- trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSExecutionFactory.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -127,12 +127,12 @@
param.setNullType(NullType.Nullable);
param = metadataFactory.addProcedureParameter("action", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
- param.setAnnotation("With a SOAP invocation, action sets the SOAPAction. With HTTP it sets the HTTP Method (GET, POST, etc.).");
+ param.setAnnotation("With a SOAP invocation, action sets the SOAPAction. With HTTP it sets the HTTP Method (GET, POST - default, etc.).");
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.setAnnotation("The String, XML, or CLOB value containing an XML document or fragment that represents the request (valid with SOAP or HTTP/POST invocations). If the ExecutionFactory is configured in with a DefaultServiceMode or MESSAGE then SOAP request must contain the entire SOAP message.");
+ param = metadataFactory.addProcedureParameter("request", TypeFacility.RUNTIME_NAMES.XML, Type.In, p); //$NON-NLS-1$
+ param.setAnnotation("The XML document or root element that represents the request. If the ExecutionFactory is configured in with a DefaultServiceMode or MESSAGE then SOAP request must contain the entire SOAP message.");
param.setNullType(NullType.Nullable);
param = metadataFactory.addProcedureParameter("endpoint", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
@@ -141,9 +141,24 @@
metadataFactory.addProcedureParameter("result", TypeFacility.RUNTIME_NAMES.XML, Type.ReturnValue, p); //$NON-NLS-1$
- //invokeHttp
+ /*p = metadataFactory.addProcedure("invokeHttp"); //$NON-NLS-1$
+ p.setAnnotation("Invokes a webservice that returns an binary result");
+
+ param = metadataFactory.addProcedureParameter("method", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
+ param.setAnnotation("Sets the HTTP Method (GET, POST - default, etc.).");
+ 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.setAnnotation("The String, XML, BLOB, or CLOB value containing a payload request.");
+ param.setNullType(NullType.Nullable);
+ param = metadataFactory.addProcedureParameter("endpoint", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
+ param.setAnnotation("The relative or abolute endpoint to use. May be set or allowed to default to null to use the default endpoint address.");
+ param.setNullType(NullType.Nullable);
+ metadataFactory.addProcedureParameter("result", TypeFacility.RUNTIME_NAMES.BLOB, Type.ReturnValue, p); //$NON-NLS-1$
+ metadataFactory.addProcedureParameter("contentType", TypeFacility.RUNTIME_NAMES.STRING, Type.Out, p); //$NON-NLS-1$*/
}
}
Modified: trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java
===================================================================
--- trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/connectors/translator-ws/src/main/java/org/teiid/translator/ws/WSProcedureExecution.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -22,10 +22,8 @@
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;
@@ -41,7 +39,7 @@
import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.MessageContext;
-import org.teiid.core.types.ClobType;
+import org.teiid.core.types.XMLType;
import org.teiid.language.Argument;
import org.teiid.language.Call;
import org.teiid.logging.LogConstants;
@@ -84,33 +82,10 @@
String style = (String)arguments.get(0).getArgumentValue().getValue();
String action = (String)arguments.get(1).getArgumentValue().getValue();
- Object docObject = arguments.get(2).getArgumentValue().getValue();
+ XMLType docObject = (XMLType)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$
- }
+ source = converToSource(docObject);
String endpoint = (String)arguments.get(3).getArgumentValue().getValue();
if (style == null) {
@@ -173,6 +148,16 @@
Util.closeSource(source);
}
}
+
+ private StreamSource converToSource(SQLXML xml) throws SQLException {
+ if (xml == null) {
+ return null;
+ }
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_WS, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Request " + xml.getString()); //$NON-NLS-1$
+ }
+ return xml.getSource(StreamSource.class);
+ }
@Override
public List<?> next() throws TranslatorException, DataNotAvailableException {
Modified: 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 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/connectors/translator-ws/src/main/resources/org/teiid/translator/ws/i18n.properties 2010-06-16 19:02:47 UTC (rev 2237)
@@ -21,5 +21,4 @@
#
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
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2010-06-16 19:02:47 UTC (rev 2237)
@@ -276,7 +276,7 @@
<entry>clob</entry>
<entry>char, boolean, byte, short, integer, long,
biginteger, float, double, bigdecimal, xml<footnote>
- <para>See also <link linkend="xmlparse">XMLPARSE</link></para>
+ <para>string to xml is equivlant to XMLPARSE(DOCUMENT exp) - See also <link linkend="xmlparse">XMLPARSE</link></para>
</footnote></entry>
</row>
<row>
@@ -350,7 +350,7 @@
<entry>xml</entry>
<entry></entry>
<entry>string<footnote>
- <para>See also <link linkend="xmlserialize">XMLSERIALIZE</link></para>
+ <para>xml to string is equivalent to XMLSERIALIZE(exp AS STRING) - see also <link linkend="xmlserialize">XMLSERIALIZE</link></para>
</footnote></entry>
</row>
</tbody>
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-16 15:26:50 UTC (rev 2236)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-06-16 19:02:47 UTC (rev 2237)
@@ -920,6 +920,19 @@
</row>
<row>
<entry>
+ <para>(7.0+) 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>Names are optional for column reference expressions.</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>
+ <row>
+ <entry>
<para>REPEAT(str1,instances)</para>
</entry>
<entry>
@@ -1035,19 +1048,6 @@
<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>Names are optional for column reference expressions.</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>
@@ -1191,6 +1191,18 @@
</row>
<row>
<entry>
+ <para>FROM_UNIXTIME (unix_timestamp)</para>
+ </entry>
+ <entry>
+ <para>Return the Unix timestamp (in seconds) as a Timestamp value
+ </para>
+ </entry>
+ <entry>
+ <para>Unix timestamp (in seconds)</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
<para>HOUR(x)</para>
</entry>
<entry>
@@ -1213,32 +1225,44 @@
</row>
<row>
<entry>
- <para>MONTH(x)</para>
+ <para>MODIFYTIMEZONE (timestamp, startTimeZone,
+ endTimeZone)</para>
</entry>
<entry>
- <para>Return month</para>
+ <para>Returns a timestamp based upon the incoming timestamp
+ adjusted for the differential between the start and end time
+ zones. i.e. if the server is in GMT-6, then modifytimezone({ts
+ '2006-01-10 04:00:00.0'},'GMT-7', 'GMT-8') will return the
+ timestamp {ts '2006-01-10 05:00:00.0'} as read in GMT-6. The
+ value has been adjusted 1 hour ahead to compensate for the
+ difference between GMT-7 and GMT-8.</para>
</entry>
<entry>
- <para>x in {date, timestamp}, returns integer</para>
+ <para>startTimeZone and endTimeZone are strings,
+ returns a timestamp</para>
</entry>
</row>
<row>
<entry>
- <para>MONTHNAME(x)</para>
+ <para>MODIFYTIMEZONE (timestamp, endTimeZone)</para>
</entry>
<entry>
- <para>Return name of month</para>
+ <para>Return a timestamp in the same manner as
+ modifytimezone(timestamp, startTimeZone, endTimeZone), but will
+ assume that the startTimeZone is the same as the server process.
+ </para>
</entry>
<entry>
- <para>x in {date, timestamp}, returns string</para>
+ <para>Timestamp is a timestamp; endTimeZone is a string,
+ returns a timestamp</para>
</entry>
</row>
<row>
<entry>
- <para>QUARTER(x)</para>
+ <para>MONTH(x)</para>
</entry>
<entry>
- <para>Return quarter</para>
+ <para>Return month</para>
</entry>
<entry>
<para>x in {date, timestamp}, returns integer</para>
@@ -1246,6 +1270,17 @@
</row>
<row>
<entry>
+ <para>MONTHNAME(x)</para>
+ </entry>
+ <entry>
+ <para>Return name of month</para>
+ </entry>
+ <entry>
+ <para>x in {date, timestamp}, returns string</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
<para>PARSEDATE(x, y)</para>
</entry>
<entry>
@@ -1279,6 +1314,17 @@
</row>
<row>
<entry>
+ <para>QUARTER(x)</para>
+ </entry>
+ <entry>
+ <para>Return quarter</para>
+ </entry>
+ <entry>
+ <para>x in {date, timestamp}, returns integer</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
<para>SECOND(x)</para>
</entry>
<entry>
@@ -1385,52 +1431,6 @@
<para>x in {date, timestamp}, returns integer</para>
</entry>
</row>
- <row>
- <entry>
- <para>MODIFYTIMEZONE (timestamp, startTimeZone,
- endTimeZone)</para>
- </entry>
- <entry>
- <para>Returns a timestamp based upon the incoming timestamp
- adjusted for the differential between the start and end time
- zones. i.e. if the server is in GMT-6, then modifytimezone({ts
- '2006-01-10 04:00:00.0'},'GMT-7', 'GMT-8') will return the
- timestamp {ts '2006-01-10 05:00:00.0'} as read in GMT-6. The
- value has been adjusted 1 hour ahead to compensate for the
- difference between GMT-7 and GMT-8.</para>
- </entry>
- <entry>
- <para>startTimeZone and endTimeZone are strings,
- returns a timestamp</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>MODIFYTIMEZONE (timestamp, endTimeZone)</para>
- </entry>
- <entry>
- <para>Return a timestamp in the same manner as
- modifytimezone(timestamp, startTimeZone, endTimeZone), but will
- assume that the startTimeZone is the same as the server process.
- </para>
- </entry>
- <entry>
- <para>Timestamp is a timestamp; endTimeZone is a string,
- returns a timestamp</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>FROM_UNIXTIME (unix_timestamp)</para>
- </entry>
- <entry>
- <para>Return the Unix timestamp (in seconds) as a Timestamp value
- </para>
- </entry>
- <entry>
- <para>Unix timestamp (in seconds)</para>
- </entry>
- </row>
</tbody>
</tgroup>
</informaltable>
@@ -1578,6 +1578,17 @@
</row>
<row>
<entry>
+ <para>COALESCE(x,y+)</para>
+ </entry>
+ <entry>
+ <para>Returns the first non-null parameter</para>
+ </entry>
+ <entry>
+ <para>x and all y's can be any compatible types</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
<para>IFNULL(x,y)</para>
</entry>
<entry>
@@ -1611,17 +1622,6 @@
<para>param1 and param2 must be compatable comparable types</para>
</entry>
</row>
- <row>
- <entry>
- <para>COALESCE(x,y+)</para>
- </entry>
- <entry>
- <para>Returns the first non-null parameter</para>
- </entry>
- <entry>
- <para>x and all y's can be any compatible types</para>
- </entry>
- </row>
</tbody>
</tgroup>
</informaltable>
@@ -1870,24 +1870,26 @@
<tbody>
<row>
<entry>
- <para><code>USER()</code></para>
+ <para><code>COMMANDPAYLOAD()</code></para>
</entry>
<entry>
- <para>Retrieve the name of the user executing the
- query</para>
+ <para>Retrieve the string form of the command payload
+ or null if no command payload was specified. The command
+ payload is set by a method on the Teiid JDBC API
+ extensions on a per-query basis.</para>
</entry>
<entry>
- <para>return is string</para>
+ <para>Returns a string</para>
</entry>
</row>
<row>
<entry>
- <para><code>ENV(key)</code></para>
+ <para><code>COMMANDPAYLOAD(key)</code></para>
</entry>
<entry>
- <para>Retrieve an environment property. The only key
- currently allowed is ‘sessionid’, although this will expand
- in the future.</para>
+ <para>Cast the command payload object to a
+ java.util.Properties object and look up the specified key in
+ the object</para>
</entry>
<entry>
<para>key in {string}, return is string</para>
@@ -1895,29 +1897,27 @@
</row>
<row>
<entry>
- <para><code>COMMANDPAYLOAD()</code></para>
+ <para><code>ENV(key)</code></para>
</entry>
<entry>
- <para>Retrieve the string form of the command payload
- or null if no command payload was specified. The command
- payload is set by a method on the Teiid JDBC API
- extensions on a per-query basis.</para>
+ <para>Retrieve an environment property. The only key
+ currently allowed is ‘sessionid’, although this will expand
+ in the future.</para>
</entry>
<entry>
- <para>Returns a string</para>
+ <para>key in {string}, return is string</para>
</entry>
</row>
<row>
<entry>
- <para><code>COMMANDPAYLOAD(key)</code></para>
+ <para><code>USER()</code></para>
</entry>
<entry>
- <para>Cast the command payload object to a
- java.util.Properties object and look up the specified key in
- the object</para>
+ <para>Retrieve the name of the user executing the
+ query</para>
</entry>
<entry>
- <para>key in {string}, return is string</para>
+ <para>return is string</para>
</entry>
</row>
</tbody>
@@ -1959,7 +1959,7 @@
</row>
<row>
<entry>
- <para><code>XSLTRANSFORM(doc, xsl)</code></para>
+ <para><code>(7.0+) XSLTRANSFORM(doc, xsl)</code></para>
</entry>
<entry>
<para>Applies an xsl stylesheet to the given document. If either argument is null, the result is null.</para>
@@ -1971,7 +1971,7 @@
</row>
<row id="xmlquery">
<entry>
- <para><code>XMLQUERY([<NSP>] xquery [<PASSING>] [(NULL|EMPTY) ON EMPTY]]</code></para>
+ <para><code>(7.0+) XMLQUERY([<NSP>] xquery [<PASSING>] [(NULL|EMPTY) ON EMPTY]]</code></para>
<para>PASSING:=<code>PASSING exp [AS name] [, exp [AS name]]*</code></para>
</entry>
<entry>
@@ -2067,11 +2067,11 @@
</row>
<row>
<entry id="xmlserialize">
- <para><code>XMLSERIALIZE((DOCUMENT|CONTENT) exp [AS datatype])</code></para>
+ <para><code>XMLSERIALIZE([(DOCUMENT|CONTENT)] exp [AS datatype])</code></para>
</entry>
<entry>
<para>Returns a character type representation of the exp expression.
- Only a character type (string, clob) may be specified as the datatype.
+ Only a character type (string, varchar, clob) may be specified as the datatype. CONTENT is the default.
If DOCUMENT is specified and the xml is not a valid document or fragment, then an exception is raised.
</para>
</entry>
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-16 15:26:50 UTC (rev 2236)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-06-16 19:02:47 UTC (rev 2237)
@@ -724,7 +724,7 @@
</note>
<sect3 id="nested_table">
<title>Nested Table Reference</title>
- <para>Nested tables may appear in the FROM clause with the TABLE
+ <para>(7.0+) Nested tables may appear in the FROM clause with the TABLE
keyword. They are an alternative to using a view with normal join
semantics. The columns projected from the command contained in the nested table
may be used just as any of the other FROM clause projected columns in join criteria, the where clause, etc.
@@ -748,7 +748,7 @@
</sect3>
<sect3 id="texttable">
<title>TEXTTABLE</title>
- <para>The TEXTTABLE funciton processes character input to produce tabular ouptut. It supports both fixed and delimited file format parsing.
+ <para>(7.0+) The TEXTTABLE funciton processes character input to produce tabular ouptut. It supports both fixed and delimited file format parsing.
The function itself defines what columns it projects.
The TEXTTABLE function is implicitly a nested table and may be correlated to preceeding FROM clause entries.
</para>
@@ -826,8 +826,8 @@
</sect3>
<sect3 id="xmltable">
<title>XMLTABLE</title>
- <para>The XMLTABLE funciton uses XQuery to produce tabular ouptut.
- The XMLTABLE function is implicitly a nested table and may be correlated to preceeding FROM clause entries.
+ <para>(7.0+) The XMLTABLE funciton uses XQuery to produce tabular ouptut.
+ The XMLTABLE function is implicitly a nested table and may be correlated to preceeding FROM clause entries. XMLTABLE is part of the SQL/XML 2006 specification.
</para>
<para>
Usage:
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2010-06-16 19:02:47 UTC (rev 2237)
@@ -97,6 +97,7 @@
</tbody>
</tgroup>
</table>
+<para>There are file importer settings, but it does provide metadata for dynamic vdbs.</para>
<sect3><title>Usage</title>
<para>Retrieve all files as BLOBs with the given extension at the given path. <programlisting>call getFiles('path/*.ext')</programlisting>
If the extension pattern is not specified and the path is a directory, then all files in the directory will be returned. If the path or filename doesn't exist, then no results will be returned.
@@ -360,7 +361,7 @@
</tbody>
</tgroup>
</table>
-<para>There are no import settings for the Loopback translator.</para>
+<para>There are no import settings for the Loopback translator; it also does not provide metadata - it should be used as a testing stub.</para>
</sect2>
<sect2>
<title>Salesforce Translator</title>
@@ -687,14 +688,15 @@
</tbody>
</tgroup>
</table>
+<para>There are ws importer settings, but it does provide metadata for dynamic vdbs.</para>
<sect3><title>Usage</title>
<para>The main procedure, invoke, allows for multiple binding, or protocol modes, including HTTP, SOAP11, and SOAP12.
-<programlisting>Procedure invoke(binding in STRING, action in STRING, request in OBJECT, endpoint in STRING) returns XML</programlisting>
+<programlisting>Procedure invoke(binding in STRING, action in STRING, request in XML, endpoint in STRING) returns XML</programlisting>
</para>
<para>The binding may be one of null (to use the default) HTTP, SOAP11, or SOAP12. Action with a SOAP binding indicates the SOAPAction value. Action with a HTTP binding indicates the HTTP method (GET, POST, etc.), which defaults to POST.</para>
<para>A null value for the binding or endpoint will use the default value. The default endpoint is specified in the WS resource adapter configuration. The endpoint URL may be absolute or relative. If it's relative then it will be combined with the default endpoint.</para>
<para>Since multiple parameters are not required to have values, it is often more clear to call the invoke procedure with named parameter syntax. e.g. <programlisting>call invoke(binding='HTTP', action='GET')</programlisting></para>
-<para>The request can be an XML, STRING, or CLOB value and should be a valid XML document.</para>
+<para>The request XML should be a valid XML document or root element.</para>
<para>See the ws-weather example in the kit and database metadata for a full description of invoke.</para>
</sect3>
</sect2>
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-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -23,13 +23,12 @@
package org.teiid.query.eval;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringReader;
-import java.nio.charset.Charset;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.SQLException;
+import java.sql.SQLXML;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -53,6 +52,7 @@
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.BaseLob;
+import org.teiid.core.types.BlobType;
import org.teiid.core.types.ClobImpl;
import org.teiid.core.types.ClobType;
import org.teiid.core.types.DataTypeManager;
@@ -114,7 +114,6 @@
import org.teiid.query.xquery.saxon.SaxonXQueryExpression;
import org.teiid.translator.WSConnection.Util;
-
public class Evaluator {
private final class SequenceReader extends Reader {
@@ -671,11 +670,12 @@
return null;
}
XMLType.Type type = Type.DOCUMENT;
- XMLType result = null;
+ SQLXMLImpl result = null;
try {
if (value instanceof String) {
String string = (String)value;
- result = new XMLType(new SQLXMLImpl(string));
+ result = new SQLXMLImpl(string);
+ result.setEncoding(Streamable.ENCODING);
if (!xp.isWellFormed()) {
Reader r = new StringReader(string);
type = validate(xp, r);
@@ -683,49 +683,36 @@
} else {
InputStreamFactory isf = null;
Streamable<?> s = (Streamable<?>)value;
- if (s.getReference() instanceof BaseLob) {
- BaseLob baseLob = (BaseLob)s.getReference();
- isf = baseLob.getStreamFactory();
- } else {
- if (s instanceof Clob) {
- isf = new InputStreamFactory.ClobInputStreamFactory((Clob)s.getReference());
- } else {
- isf = new InputStreamFactory.BlobInputStreamFactory((Blob)s.getReference());
- }
- }
- result = new XMLType(new SQLXMLImpl(isf));
+ isf = getInputStreamFactory(s);
+ result = new SQLXMLImpl(isf);
if (!xp.isWellFormed()) {
- String encoding = null;
- Reader r = null;
- if (s instanceof Clob) {
- r = isf.getCharacterStream();
- } else {
- encoding = XMLType.getEncoding(result); //look for the xml declaration
- if (encoding == null) {
- encoding = "UTF-8"; //$NON-NLS-1$
- }
- r = new InputStreamReader(isf.getInputStream(), encoding);
- }
+ Reader r = result.getCharacterStream();
type = validate(xp, r);
- if (encoding != null) {
- isf.setEncoding(encoding);
- }
}
}
} catch (TransformationException e) {
throw new ExpressionEvaluationException(e, e.getMessage());
- } catch (IOException e) {
- throw new ExpressionEvaluationException(e, e.getMessage());
} catch (SQLException e) {
throw new ExpressionEvaluationException(e, e.getMessage());
}
if (!xp.isDocument()) {
type = Type.CONTENT;
}
- result.setType(type);
- return result;
+ XMLType xml = new XMLType(result);
+ xml.setType(type);
+ return xml;
}
+ //TODO: determine when wrapping is not needed
+ public static InputStreamFactory getInputStreamFactory(Streamable<?> s) {
+ if (s instanceof ClobType) {
+ return new InputStreamFactory.ClobInputStreamFactory((Clob)s.getReference());
+ } else if (s instanceof BlobType){
+ return new InputStreamFactory.BlobInputStreamFactory((Blob)s.getReference());
+ }
+ return new InputStreamFactory.SQLXMLInputStreamFactory((SQLXML)s.getReference());
+ }
+
private Type validate(final XMLParse xp, Reader r)
throws TransformationException {
if (!xp.isDocument()) {
@@ -792,7 +779,7 @@
return null;
}
try {
- if (!xs.isDocument()) {
+ if (xs.isDocument() == null || !xs.isDocument()) {
return serialize(xs, value);
}
if (value.getType() == Type.UNKNOWN) {
@@ -810,18 +797,11 @@
throw new FunctionExecutionException(QueryPlugin.Util.getString("Evaluator.xmlserialize")); //$NON-NLS-1$
}
- private Object serialize(XMLSerialize xs, XMLType value)
- throws SQLException, TransformationException {
+ private Object serialize(XMLSerialize xs, XMLType value) throws TransformationException {
if (xs.getType() == DataTypeManager.DefaultDataClasses.STRING) {
return DataTypeManager.transformValue(value, xs.getType());
}
- InputStreamFactory isf = null;
- if (value.getReference() instanceof BaseLob) {
- BaseLob baseLob = (BaseLob)value.getReference();
- isf = baseLob.getStreamFactory();
- } else {
- isf = new InputStreamFactory.SQLXMLInputStreamFactory(value.getReference());
- }
+ InputStreamFactory isf = getInputStreamFactory(value);
return new ClobType(new ClobImpl(isf, -1));
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -87,11 +87,6 @@
public static final String COALESCE = "coalesce"; //$NON-NLS-1$
public static final String SPACE = "space"; //$NON-NLS-1$
-
- public static final String XMLFOREST = "XMLFOREST"; //$NON-NLS-1$
- public static final String XMLATTRIBUTES = "XMLATTRIBUTES"; //$NON-NLS-1$
- public static final String XMLNAMESPACES = "XMLNAMESPACES"; //$NON-NLS-1$
- public static final String XMLELEMENT = "XMLELEMENT"; //$NON-NLS-1$
// Function tree for system functions (never reloaded)
private FunctionTree systemFunctions;
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -25,6 +25,13 @@
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetEncoder;
+import java.nio.charset.CoderResult;
+import java.sql.Blob;
+import java.sql.Clob;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DateFormat;
@@ -38,8 +45,15 @@
import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.types.BlobImpl;
+import org.teiid.core.types.BlobType;
+import org.teiid.core.types.ClobImpl;
+import org.teiid.core.types.ClobType;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.TransformationException;
+import org.teiid.core.types.InputStreamFactory.BlobInputStreamFactory;
+import org.teiid.core.types.InputStreamFactory.ClobInputStreamFactory;
+import org.teiid.core.util.Base64;
import org.teiid.core.util.TimestampWithTimezone;
import org.teiid.language.SQLConstants.NonReserved;
import org.teiid.query.QueryPlugin;
@@ -1246,4 +1260,102 @@
return TimestampWithTimezone.createTimestamp(value, context.getServerTimeZone(), cal);
}
+ public static Blob decode(ClobType value, String encoding) {
+ /*if ("HEX".equalsIgnoreCase(encoding)) {
+
+ }
+ if ("BASE64".equalsIgnoreCase(encoding)) {
+
+ }*/
+ ClobInputStreamFactory cisf = new ClobInputStreamFactory(value.getReference());
+ cisf.setCharset(Charset.forName(encoding));
+ return new BlobType(new BlobImpl(cisf));
+ }
+
+ public static Clob encode(BlobType value, String encoding) {
+ /*if ("HEX".equalsIgnoreCase(encoding)) {
+
+ }
+ if ("BASE64".equalsIgnoreCase(encoding)) {
+
+ }*/
+ BlobInputStreamFactory bisf = new BlobInputStreamFactory(value.getReference());
+ ClobImpl clob = new ClobImpl(bisf, -1);
+ clob.setEncoding(encoding);
+ return new ClobType(clob);
+ }
+
+ public static class Base64Encoder extends CharsetEncoder {
+
+ private CharBuffer cb = CharBuffer.wrap(new char[4]);
+
+ protected Base64Encoder() {
+ super(Charset.forName("US-ASCII"), .75f, 1); //$NON-NLS-1$
+ }
+
+ @Override
+ protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
+ while (in.hasRemaining()) {
+ cb.put(in.get());
+ if (!cb.hasRemaining()) {
+ if (!out.hasRemaining()) {
+ return CoderResult.OVERFLOW;
+ }
+ cb.position(0);
+ out.put(Base64.decode(cb));
+ cb.clear();
+ }
+ }
+ return CoderResult.UNDERFLOW;
+ }
+
+ @Override
+ protected CoderResult implFlush(ByteBuffer out) {
+ if (cb.position() != 0) {
+ return CoderResult.unmappableForLength(cb.position());
+ }
+ return super.implFlush(out);
+ }
+ }
+
+/* This does not seem to work, since the flush is never called
+ public static class Base64Decoder extends CharsetDecoder {
+
+ private ByteBuffer bb = ByteBuffer.wrap(new byte[3]);
+
+ protected Base64Decoder() {
+ super(Charset.forName("US-ASCII"), 1.25f, 3); //$NON-NLS-1$
+ }
+
+ @Override
+ protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
+ while (in.hasRemaining()) {
+ bb.put(in.get());
+ if (!bb.hasRemaining()) {
+ if (!out.hasRemaining()) {
+ return CoderResult.OVERFLOW;
+ }
+ bb.position(0);
+ out.put(Base64.encodeBytes(bb.array()));
+ bb.clear();
+ }
+ }
+ return CoderResult.UNDERFLOW;
+ }
+
+ @Override
+ protected CoderResult implFlush(CharBuffer out) {
+ if (bb.position() != 0) {
+ if (!out.hasRemaining()) {
+ return CoderResult.OVERFLOW;
+ }
+ byte[] bytes = Arrays.copyOf(bb.array(), bb.position());
+ out.put(Base64.encodeBytes(bytes));
+ bb.clear();
+ }
+ return super.implFlush(out);
+ }
+ }
+*/
+
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -144,6 +144,9 @@
addClobFunction("lower", QueryPlugin.Util.getString("SystemSource.LowerClob_result"), "lowerCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
addClobFunction("upper", QueryPlugin.Util.getString("SystemSource.UpperClob_result"), "upperCase", DataTypeManager.DefaultDataTypes.CLOB); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ addEncodeFunction();
+ addDecodeFunction();
+
// conversion
addConversionFunctions();
@@ -576,7 +579,25 @@
new FunctionParameter("str2", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Insert_arg4")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Insert_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
-
+
+ private void addEncodeFunction() {
+ functions.add(
+ new FunctionMethod("encode", QueryPlugin.Util.getString("SystemSource.encode_desc"), CONVERSION, FUNCTION_CLASS, "encode", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionParameter[] {
+ new FunctionParameter("value", DataTypeManager.DefaultDataTypes.BLOB, QueryPlugin.Util.getString("SystemSource.encode_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("encoding", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.encode_arg2"))}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.CLOB, QueryPlugin.Util.getString("SystemSource.encode_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ private void addDecodeFunction() {
+ functions.add(
+ new FunctionMethod("decode", QueryPlugin.Util.getString("SystemSource.decode_desc"), CONVERSION, FUNCTION_CLASS, "decode", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new FunctionParameter[] {
+ new FunctionParameter("value", DataTypeManager.DefaultDataTypes.CLOB, QueryPlugin.Util.getString("SystemSource.decode_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("encoding", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.decode_arg2"))}, //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BLOB, QueryPlugin.Util.getString("SystemSource.decode_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
private void addAsciiFunction() {
functions.add(
new FunctionMethod(SourceSystemFunctions.ASCII, QueryPlugin.Util.getString("SystemSource.Ascii_desc"), STRING, FUNCTION_CLASS, "ascii", //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/DocumentInProgress.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/DocumentInProgress.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/DocumentInProgress.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -52,22 +52,23 @@
private Element currentParent;
private Element currentObject;
private boolean finished;
- private String documentEncoding = MappingNodeConstants.Defaults.DEFAULT_DOCUMENT_ENCODING;
private boolean isFormatted = MappingNodeConstants.Defaults.DEFAULT_FORMATTED_DOCUMENT.booleanValue();
private SQLXMLImpl xml;
public DocumentInProgress(FileStore store, String encoding) throws TeiidComponentException{
final FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(store, encoding);
this.xml = new SQLXMLImpl(fsisf);
+ this.xml.setEncoding(encoding);
SAXTransformerFactory factory = new TransformerFactoryImpl();
try {
//SAX2.0 ContentHandler
handler = factory.newTransformerHandler();
- handler.setResult(new StreamResult(fsisf.getOuptStream()));
+ handler.setResult(new StreamResult(fsisf.getOuputStream()));
} catch (Exception e) {
throw new TeiidComponentException(e);
}
transformer = handler.getTransformer();
+ transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
}
public SQLXMLImpl getSQLXML() {
@@ -75,13 +76,6 @@
}
/**
- * @see org.teiid.query.processor.xml.DocumentInProgress#setDocumentEncoding(java.lang.String)
- */
- public void setDocumentEncoding(String documentEncoding) {
- this.documentEncoding = documentEncoding;
- }
-
- /**
* @see org.teiid.query.processor.xml.DocumentInProgress#setDocumentFormat(boolean)
*/
public void setDocumentFormat(boolean isFormatted) {
@@ -287,7 +281,6 @@
private void startDocument() throws SAXException{
showState( "startDocument - TOP" ); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.ENCODING, documentEncoding);
if(isFormatted){
transformer.setOutputProperty(OutputKeys.INDENT, "yes");//$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLUtil.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLUtil.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -28,8 +28,8 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
import java.io.Writer;
+import java.nio.charset.Charset;
import javax.xml.transform.TransformerException;
@@ -52,9 +52,10 @@
public static final class FileStoreInputStreamFactory extends InputStreamFactory {
private final FileStore lobBuffer;
private final FileStoreOutputStream fsos;
+ private String encoding;
public FileStoreInputStreamFactory(FileStore lobBuffer, String encoding) {
- super(encoding);
+ this.encoding = encoding;
this.lobBuffer = lobBuffer;
fsos = lobBuffer.createOutputStream(DataTypeManager.MAX_LOB_MEMORY_BYTES);
this.lobBuffer.setCleanupReference(this);
@@ -75,14 +76,10 @@
}
public Writer getWriter() {
- try {
- return new OutputStreamWriter(fsos, Streamable.ENCODING);
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
+ return new OutputStreamWriter(fsos, Charset.forName(encoding));
}
- public OutputStream getOuptStream() {
+ public OutputStream getOuputStream() {
return fsos;
}
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-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLSerialize.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -30,7 +30,7 @@
private static final long serialVersionUID = -6574662238317329252L;
- private boolean document;
+ private Boolean document;
private Expression expression;
private String typeString;
private Class<?> type;
@@ -51,11 +51,11 @@
return expression;
}
- public boolean isDocument() {
+ public Boolean isDocument() {
return document;
}
- public void setDocument(boolean document) {
+ public void setDocument(Boolean document) {
this.document = document;
}
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-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -24,7 +24,6 @@
import static org.teiid.language.SQLConstants.Reserved.*;
-import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -33,7 +32,6 @@
import java.util.List;
import org.teiid.core.types.DataTypeManager;
-import org.teiid.core.types.XMLType;
import org.teiid.core.util.StringUtil;
import org.teiid.language.SQLConstants;
import org.teiid.language.SQLConstants.NonReserved;
@@ -1156,15 +1154,6 @@
constantParts = new Object[] { "{t'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
} else if(type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
constantParts = new Object[] { "{d'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
- } else if(type.equals(DataTypeManager.DefaultDataClasses.XML)){
- XMLType value = (XMLType)obj.getValue();
- if (Boolean.TRUE.equals(value.isInMemory())) {
- try {
- constantParts = new Object[] { "{x '", escapeStringValue(value.getString(), "'"), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } catch (SQLException e) {
-
- }
- }
}
if (constantParts == null) {
String strValue = obj.getValue().toString();
@@ -1571,7 +1560,7 @@
@Override
public void visit(XMLAttributes obj) {
- parts.add(FunctionLibrary.XMLATTRIBUTES);
+ parts.add(XMLATTRIBUTES);
parts.add("("); //$NON-NLS-1$
registerNodes(obj.getArgs(), 0);
parts.add(")"); //$NON-NLS-1$
@@ -1579,7 +1568,7 @@
@Override
public void visit(XMLElement obj) {
- parts.add(FunctionLibrary.XMLELEMENT);
+ parts.add(XMLELEMENT);
parts.add("(NAME "); //$NON-NLS-1$
outputDisplayName(obj.getName());
if (obj.getNamespaces() != null) {
@@ -1599,7 +1588,7 @@
@Override
public void visit(XMLForest obj) {
- parts.add(FunctionLibrary.XMLFOREST);
+ parts.add(XMLFOREST);
parts.add("("); //$NON-NLS-1$
if (obj.getNamespaces() != null) {
parts.add(registerNode(obj.getNamespaces()));
@@ -1611,7 +1600,7 @@
@Override
public void visit(XMLNamespaces obj) {
- parts.add(FunctionLibrary.XMLNAMESPACES);
+ parts.add(XMLNAMESPACES);
parts.add("("); //$NON-NLS-1$
for (Iterator<NamespaceItem> items = obj.getNamespaceItems().iterator(); items.hasNext();) {
NamespaceItem item = items.next();
@@ -1804,12 +1793,14 @@
public void visit(XMLSerialize obj) {
parts.add(XMLSERIALIZE);
parts.add(Tokens.LPAREN);
- if (obj.isDocument()) {
- parts.add(NonReserved.DOCUMENT);
- } else {
- parts.add(NonReserved.CONTENT);
+ if (obj.isDocument() != null) {
+ if (obj.isDocument()) {
+ parts.add(NonReserved.DOCUMENT);
+ } else {
+ parts.add(NonReserved.CONTENT);
+ }
+ parts.add(SPACE);
}
- parts.add(SPACE);
parts.add(registerNode(obj.getExpression()));
if (obj.getTypeString() != null) {
parts.add(SPACE);
@@ -1882,5 +1873,5 @@
}
return SQLConstants.isReservedWord(string);
}
-
+
}
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-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -22,6 +22,7 @@
package org.teiid.query.validator;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -347,7 +348,13 @@
handleValidationError(QueryPlugin.Util.getString("QueryResolver.invalid_xpath", e.getMessage()), obj); //$NON-NLS-1$
}
}
- }
+ } else if(obj.getFunctionDescriptor().getName().equalsIgnoreCase(SourceSystemFunctions.ENCODE) || obj.getFunctionDescriptor().getName().equalsIgnoreCase(SourceSystemFunctions.DECODE)) {
+ try {
+ Charset.forName((String)((Constant)obj.getArg(1)).getValue());
+ } catch (IllegalArgumentException e) {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.invalid_encoding", obj.getArg(1)), obj); //$NON-NLS-1$
+ }
+ }
}
// ############### Visitor methods for stored procedure lang objects ##################
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-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-06-16 19:02:47 UTC (rev 2237)
@@ -368,7 +368,6 @@
| < TIMETYPE: "{" "t" >
| < TIMESTAMPTYPE: "{" "ts" >
| < BOOLEANTYPE: "{" "b" >
-| < XMLTYPE: "{" "x" >
| < INTEGERVAL: (<MINUS>)?(<DIGIT>)+ >
| < FLOATVAL: (<MINUS>)? (<DIGIT>)* <PERIOD> (<DIGIT>)+
@@ -1919,7 +1918,7 @@
}
{
<XMLSERIALIZE> <LPAREN>
- doc = nonReserved("DOCUMENT", "CONTENT")
+ [LOOKAHEAD(<ID>, {matchesAny(getToken(1).image, "document", "content") != null}) doc = nonReserved("DOCUMENT", "CONTENT")]
expr = expression(info)
[
<AS> (t = <STRING> | t = <VARCHAR> | t = <CLOB>)
@@ -1928,7 +1927,9 @@
{
XMLSerialize result = new XMLSerialize();
result.setExpression(expr);
- result.setDocument("document".equalsIgnoreCase(doc));
+ if (doc != null) {
+ result.setDocument("document".equalsIgnoreCase(doc));
+ }
if (t != null) {
result.setTypeString(t.image);
}
@@ -3228,6 +3229,23 @@
<RPAREN>
)
|
+ LOOKAHEAD(<ID>, {matchesAny(getToken(1).image, "encode", "decode") != null}) (
+ funcName = nonReserved("ENCODE", "DECODE")
+ <LPAREN>
+ expression = expression(info)
+ {
+ args.add(expression);
+ expression = null;
+ }
+ <COMMA>
+ expression = stringConstant()
+ {
+ args.add(expression);
+ expression = null;
+ }
+ <RPAREN>
+ )
+ |
LOOKAHEAD(<ID>, {matchesAny(getToken(1).image, "timestampadd", "timestampdiff") != null}) (
funcName = nonReserved("TIMESTAMPADD", "TIMESTAMPDIFF")
<LPAREN>
@@ -3389,6 +3407,17 @@
}
}
+Constant stringConstant() :
+{
+ String val = null;
+}
+{
+ val = stringVal()
+ {
+ return new Constant(val);
+ }
+}
+
XMLParse xmlParse(ParseInfo info) :
{
Expression expr = null;
@@ -3699,8 +3728,7 @@
( (<BOOLEANTYPE> { escapeType=DataTypeManager.DefaultDataClasses.BOOLEAN; } |
<TIMESTAMPTYPE> { escapeType=DataTypeManager.DefaultDataClasses.TIMESTAMP; } |
<DATETYPE> { escapeType=DataTypeManager.DefaultDataClasses.DATE; } |
- <TIMETYPE> { escapeType=DataTypeManager.DefaultDataClasses.TIME; } |
- <XMLTYPE> { escapeType=DataTypeManager.DefaultDataClasses.XML; }) strVal=stringVal() {
+ <TIMETYPE> { escapeType=DataTypeManager.DefaultDataClasses.TIME; }) strVal=stringVal() {
try {
constant = new Constant(DataTypeManager.transformValue(strVal, escapeType), escapeType);
} catch (TransformationException e) {
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2010-06-16 19:02:47 UTC (rev 2237)
@@ -811,6 +811,14 @@
SystemSource.coalesce_description=Returns the first non-null parameter
SystemSource.coalesce_param1=parameter
SystemSource.coalesce_result=The first non-null parameter
+SystemSource.encode_desc=Encodes the given Blob to a Clob
+SystemSource.encode_arg1=Blob
+SystemSource.encode_arg2=The encoding
+SystemSource.encode_result=The Clob
+SystemSource.decode_desc=Decodes a Clob to a Blob
+SystemSource.decode_arg1=Clob
+SystemSource.decode_arg2=The encoding
+SystemSource.decode_result=The Blob
TempMetadataAdapter.Element_____{0}_____not_found._1=Element ''{0}'' not found.
TempMetadataAdapter.Group_____{0}_____not_found._1=Group ''{0}'' not found.
ExpressionEvaluator.Must_push=Function {0} is marked in the function metadata as a function that must be evaluated at the source.
@@ -905,6 +913,7 @@
ValidationVisitor.invalid_default=XMLTABLE DEFAULT expression is invalid: "{0}"
ValidationVisitor.context_required=The XQuery requires a context item, but none exists in the PASSING clause.
ValidationVisitor.xmlserialize_type=XMLSERIALIZE expects a STRING, CLOB, or BLOB value.
+ValidationVisitor.invalid_encoding=Encoding {0} is not valid.
UpdateProcedureResolver.only_variables=Element symbol "{0}" cannot be assigned a value. Only declared VARIABLES can be assigned values.
wrong_result_type=No results found; or non-XML result object has been produced as a result of the execution of XQuery expression. Please note that only XML type results are supported.
MappingLoader.unknown_node_type=Unknown Node Type "{0}" being loaded by the XML mapping document.
Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -26,6 +26,8 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.sql.Blob;
+import java.sql.Clob;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
@@ -36,15 +38,20 @@
import java.util.Properties;
import java.util.TimeZone;
+import javax.sql.rowset.serial.SerialBlob;
+import javax.sql.rowset.serial.SerialClob;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.teiid.api.exception.query.FunctionExecutionException;
import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.types.BlobType;
import org.teiid.core.types.ClobType;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.NullType;
import org.teiid.core.types.XMLType;
+import org.teiid.core.types.DataTypeManager.DefaultDataClasses;
import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.TimestampWithTimezone;
import org.teiid.language.SQLConstants.NonReserved;
@@ -1361,4 +1368,15 @@
assertEquals("<!--comment-->", xml);
}
+ @Test public void testEncode() throws Exception {
+ Clob result = (Clob)helpInvokeMethod("encode", new Class[] {DefaultDataClasses.BLOB, DefaultDataClasses.STRING}, new Object[] { new BlobType(new SerialBlob("hello world".getBytes("ASCII"))), "ASCII" }, null); //$NON-NLS-1$
+ String string = result.getSubString(1, (int)result.length());
+ assertEquals("hello world", string);
+ }
+
+ @Test public void testDecode() throws Exception {
+ Blob result = (Blob)helpInvokeMethod("decode", new Class[] {DefaultDataClasses.CLOB, DefaultDataClasses.STRING}, new Object[] { new ClobType(new SerialClob("hello world".toCharArray())), "UTF32" }, null); //$NON-NLS-1$
+ assertEquals(44, result.length()); //4 bytes / char
+ }
+
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -24,9 +24,6 @@
import static org.junit.Assert.*;
-import java.util.ArrayList;
-import java.util.Collection;
-
import org.junit.Test;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
@@ -44,7 +41,6 @@
import org.teiid.query.parser.QueryParser;
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.sql.lang.Command;
-import org.teiid.query.sql.visitor.GroupCollectorVisitor;
import org.teiid.query.unittest.FakeMetadataFacade;
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -67,8 +63,7 @@
* be below the access node after the rule is run
*/
private void helpTestAccessPatternValidation(String command) throws Exception {
- Collection groups = new ArrayList();
- PlanNode node = this.helpPlan(command, groups);
+ PlanNode node = this.helpPlan(command);
if(DEBUG) {
System.out.println("\nfinal plan node:\n"+node); //$NON-NLS-1$
@@ -85,13 +80,10 @@
* @param groups Collection to add parsed and resolved GroupSymbols to
* @return the root PlanNode of the query plan
*/
- private PlanNode helpPlan(String command, Collection groups) throws Exception {
+ private PlanNode helpPlan(String command) throws Exception {
Command query = QueryParser.getQueryParser().parseCommand(command);
QueryResolver.resolveCommand(query, METADATA);
- //save groups for later
- GroupCollectorVisitor.getGroups(query, groups);
-
//Generate canonical plan
RelationalPlanner p = new RelationalPlanner();
p.initialize(query, null, METADATA, FINDER, null, null);
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-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -6833,5 +6833,12 @@
f.setWellFormed(true);
helpTestExpression("xmlparse(document x wellformed)", "XMLPARSE(DOCUMENT x WELLFORMED)", f);
}
+
+ @Test public void testXmlSerialize1() throws Exception {
+ XMLSerialize f = new XMLSerialize();
+ f.setExpression(new ElementSymbol("x"));
+ f.setTypeString("CLOB");
+ helpTestExpression("xmlserialize(x as CLOB)", "XMLSERIALIZE(x AS CLOB)", f);
+ }
}
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-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -256,7 +256,7 @@
}
@Test public void testXmlQueryEmptyNull() throws Exception {
- String sql = "select xmlquery('/a' passing {x '<x/>'} null on empty)"; //$NON-NLS-1$
+ String sql = "select xmlquery('/a' passing xmlparse(document '<x/>') null on empty)"; //$NON-NLS-1$
List<?>[] expected = new List<?>[] {
Arrays.asList((String)null)
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-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -2947,7 +2947,7 @@
}
@Test public void testQueryString() throws Exception {
- helpResolveException("select querystring({x '<a/>'})");
+ helpResolveException("select querystring(xmlparse(document '<a/>'))");
}
}
\ No newline at end of file
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-16 15:26:50 UTC (rev 2236)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -1999,7 +1999,7 @@
}
@Test public void testXMLTablePassingMultipleContext() {
- helpValidate("select * from pm1.g1, xmltable('/' passing {x '<a/>'}, {x '<b/>'}) as x", new String[] {"XMLTABLE('/' PASSING {x '<a/>'}, {x '<b/>'}) AS x"}, FakeMetadataFactory.example1Cached());
+ helpValidate("select * from pm1.g1, xmltable('/' passing xmlparse(DOCUMENT '<a/>'), xmlparse(DOCUMENT '<b/>')) as x", new String[] {"XMLTABLE('/' PASSING XMLPARSE(DOCUMENT '<a/>'), XMLPARSE(DOCUMENT '<b/>')) AS x"}, FakeMetadataFactory.example1Cached());
}
@Ignore("this is actually handled by saxon and will show up during resolving")
@@ -2012,7 +2012,7 @@
}
@Test public void testXMLTableMultipleOrdinals() {
- helpValidate("select * from pm1.g1, xmltable('/' passing {x '<a/>'} columns x for ordinality, y for ordinality) as x", new String[] {"XMLTABLE('/' PASSING {x '<a/>'} COLUMNS x FOR ORDINALITY, y FOR ORDINALITY) AS x"}, FakeMetadataFactory.example1Cached());
+ helpValidate("select * from pm1.g1, xmltable('/' passing XMLPARSE(DOCUMENT '<a/>') columns x for ordinality, y for ordinality) as x", new String[] {"XMLTABLE('/' PASSING XMLPARSE(DOCUMENT '<a/>') COLUMNS x FOR ORDINALITY, y FOR ORDINALITY) AS x"}, FakeMetadataFactory.example1Cached());
}
@Test public void testXMLTableContextRequired() {
@@ -2034,4 +2034,9 @@
@Test public void testXmlParse() throws Exception {
helpValidate("select xmlparse(content e2) from pm1.g1", new String[] {"XMLPARSE(CONTENT e2)"}, FakeMetadataFactory.example1Cached());
}
+
+ @Test public void testDecode() throws Exception {
+ helpValidate("select decode(e1, '?') from pm1.g1", new String[] {"decode(e1, '?')"}, FakeMetadataFactory.example1Cached());
+ }
+
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -42,7 +42,6 @@
import org.teiid.common.buffer.FileStore;
import org.teiid.common.buffer.StorageManager;
import org.teiid.core.types.InputStreamFactory;
-import org.teiid.core.types.Streamable;
import org.teiid.core.types.InputStreamFactory.StreamFactoryReference;
import org.teiid.core.util.ExternalizeUtil;
import org.teiid.netty.handler.codec.serialization.CompactObjectInputStream;
@@ -146,7 +145,7 @@
store = storageManager.createFileStore("temp-stream"); //$NON-NLS-1$
StreamFactoryReference sfr = streams.get(streamIndex);
store.setCleanupReference(sfr);
- sfr.setStreamFactory(new InputStreamFactory(Streamable.ENCODING) {
+ sfr.setStreamFactory(new InputStreamFactory() {
FileStore fs = store;
@Override
public InputStream getInputStream() throws IOException {
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-06-16 15:26:50 UTC (rev 2236)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-06-16 19:02:47 UTC (rev 2237)
@@ -252,7 +252,7 @@
assertEquals(expected, getString(TestLiteralImpl.example("string'Literal"))); //$NON-NLS-1$
expected = "1000"; //$NON-NLS-1$
assertEquals(expected, getString(TestLiteralImpl.example(new Integer(1000))));
- expected = "{b 'true'}"; //$NON-NLS-1$
+ expected = "TRUE"; //$NON-NLS-1$
assertEquals(expected, getString(TestLiteralImpl.example(Boolean.TRUE)));
long now = System.currentTimeMillis();
Date date = new Date(now);
14 years, 6 months
teiid SVN: r2236 - trunk/documentation/admin-guide/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-06-16 11:26:50 -0400 (Wed, 16 Jun 2010)
New Revision: 2236
Modified:
trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
Log:
misc: minor changes
Modified: trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-06-15 21:49:19 UTC (rev 2235)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-06-16 15:26:50 UTC (rev 2236)
@@ -18,21 +18,25 @@
<title>By Copying the File</title>
<para>Copy the VDB file into the "<jboss-install>/server/<profile>/deploy" directory.
Make sure that there are no other VDB files with the same name. If a VDB already exists with
- the same name, then this VDB will be replaced with the new VDB. T
- his is the simplest way to deploy a VDB.</para>
+ the same name, then this VDB will be replaced with the new VDB. This is the simplest way to deploy a VDB. This is mostly
+ designed for quick deployment during development, when the Teiid server is available
+ locally on the developer machine.</para>
</sect2>
<sect2>
<title>By Using Admin API</title>
<para>The Admin API (look in org.teiid.adminpi.*) provides Java API methods that
- let's a user connect to a Teiid runtime and deploy a VDB. If you need to programmatically deploy a VDB use this method.</para>
+ lets a user connect to a Teiid runtime and deploy a VDB. If you need to programmatically
+ deploy a VDB use this method. This method is preferable for OEM users, who are trying to extend the
+ Teiid's capabilities through their applications.</para>
</sect2>
<sect2>
<title>By Using Admin Shell</title>
<para>Teiid provides "groovy" based Admin Shell scripting tool, which can be used to deploy
a VDB. Check out the "deployVDB" method. Check out more information about <emphasis>Admin Shell</emphasis>
- <link linkend="adminshell_introduction">here</link>. </para>
+ <link linkend="adminshell_introduction">here</link>. Note that using the AdminShell scripting, you can automate
+ the deployment of artifacts in your environment.</para>
</sect2>
<sect2>
@@ -42,7 +46,11 @@
<programlisting><![CDATA[
http://<host>:<port>/admin-console
- ]]></programlisting>
+ ]]></programlisting>
+
+ <para>More details for this can be found <link linkend="vdb_deploy">here.</link> This is preferred way
+ to deploy a VDB, when the Teiid server is shared among multiple users and/or Teiid Server is in a remote
+ location.</para>
</sect2>
</sect1>
14 years, 6 months
teiid SVN: r2235 - trunk/client/src/main/resources.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-06-15 17:49:19 -0400 (Tue, 15 Jun 2010)
New Revision: 2235
Modified:
trunk/client/src/main/resources/vdb-deployer.xsd
Log:
misc: Adding documentation to the vdb schema file.
Modified: trunk/client/src/main/resources/vdb-deployer.xsd
===================================================================
--- trunk/client/src/main/resources/vdb-deployer.xsd 2010-06-15 19:52:00 UTC (rev 2234)
+++ trunk/client/src/main/resources/vdb-deployer.xsd 2010-06-15 21:49:19 UTC (rev 2235)
@@ -9,11 +9,23 @@
<xs:element name="description" type="xs:string" minOccurs="0"/>
<xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="model" maxOccurs="unbounded" minOccurs="0">
+ <xs:annotation>
+ <xs:documentation>A model defines the alias for the Schema the data being integrated. In the Designer
+ built VDB, the Schema for this model is defined by external index files. In the "Dynamic VDB"
+ this defines the importer properties along with "source" information the Schema
+ is generated at deploy time.</xs:documentation>
+ </xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string" minOccurs="0"/>
<xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="source" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>A source defines access to physical data source with its connection-jndi-name.
+ translator-name defines a translator. Translator is a layer between Teiid engine and data source
+ that knows how to convert and execute commands native to source. Teiid offers various
+ pre-built translators.</xs:documentation>
+ </xs:annotation>
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="translator-name" type="xs:string" use="required"/>
@@ -21,6 +33,10 @@
</xs:complexType>
</xs:element>
<xs:element name="validation-error" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>When Schema files for model defined by Designer, the validation-errors define
+ any errors in the schema. This is not applicable in the Dynamic VDB scenario.</xs:documentation>
+ </xs:annotation>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
@@ -45,6 +61,10 @@
</xs:complexType>
</xs:element>
<xs:element name="translator" maxOccurs="unbounded" minOccurs="0">
+ <xs:annotation>
+ <xs:documentation>When the pre-built translator's behavior need to be altered, this optional element need to
+ be used to override them.</xs:documentation>
+ </xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="property" type="property" minOccurs="0" maxOccurs="unbounded"/>
@@ -54,6 +74,13 @@
</xs:complexType>
</xs:element>
<xs:element name="data-policy" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>This defines a security policy on the Schema. The "resource-name" element defines fully qualified
+ name for a Table, procedure etc. The "allows-*" elements define the security access. The "mapped-role-name" defines
+ the "role" name that user must have before they have access to this data. The "role" name matches to the
+ JAAS based role that user has.</xs:documentation>
+ </xs:annotation>
+
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string" minOccurs="0"/>
@@ -74,6 +101,10 @@
</xs:complexType>
</xs:element>
<xs:element name="entry" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>With Designer based VDBs, this element is used to define extra files that are
+ defined inside the VDB archive. Not applicable for Dynamic VDBs</xs:documentation>
+ </xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="description" type="xs:string" minOccurs="0"/>
14 years, 6 months
teiid SVN: r2234 - in trunk/documentation/admin-guide: src/main/docbook/en-US and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-06-15 15:52:00 -0400 (Tue, 15 Jun 2010)
New Revision: 2234
Added:
trunk/documentation/admin-guide/src/main/docbook/en-US/admin_guide.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/admin-console.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/adminshell-introduction.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/images/
trunk/documentation/admin-guide/src/main/docbook/en-US/images/admin_console.png
Removed:
trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml
trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml
Modified:
trunk/documentation/admin-guide/pom.xml
Log:
misc: Adding chapters on installation, admin-console and VDB deployment to the "admin-guide".
Modified: trunk/documentation/admin-guide/pom.xml
===================================================================
--- trunk/documentation/admin-guide/pom.xml 2010-06-15 16:49:28 UTC (rev 2233)
+++ trunk/documentation/admin-guide/pom.xml 2010-06-15 19:52:00 UTC (rev 2234)
@@ -36,7 +36,7 @@
</dependency>
</dependencies>
<configuration>
- <sourceDocumentName>adminshell_guide.xml</sourceDocumentName>
+ <sourceDocumentName>admin_guide.xml</sourceDocumentName>
<imageResource>
<directory>${basedir}/src/main/docbook/en-US</directory>
<excludes>
Copied: trunk/documentation/admin-guide/src/main/docbook/en-US/admin_guide.xml (from rev 2230, trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml)
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/admin_guide.xml (rev 0)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/admin_guide.xml 2010-06-15 19:52:00 UTC (rev 2234)
@@ -0,0 +1,59 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!--
+
+ JBoss, Home of Professional Open Source.
+ Copyright (C) 2008 Red Hat, Inc.
+ Licensed to Red Hat, Inc. under one or more contributor
+ license agreements. See the copyright.txt file in the
+ distribution for a full listing of individual contributors.
+
+ 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.
+
+-->
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+<!ENTITY % CustomDTD SYSTEM "../../../../../docbook/custom.dtd">
+%CustomDTD;
+]>
+
+<book>
+
+ <bookinfo>
+ <title>Teiid - Scalable Information Integration</title>
+ <subtitle>Teiid Administrator's Guide</subtitle>
+ <releaseinfo>&versionNumber;</releaseinfo>
+ <productnumber>&versionNumber;</productnumber>
+ <issuenum>1</issuenum>
+ <copyright>
+ <year>©rightYear;</year>
+ <holder>©rightHolder;</holder>
+ </copyright>
+ <xi:include href="../../../../../docbook/en-US/legal_notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ </bookinfo>
+
+ <toc/>
+
+ <xi:include href="content/installation.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/vdb-deployment.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/admin-console.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/adminshell-introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/getting-started.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/working-with-scripts.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/connection-management.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/appendix-a.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="content/appendix-b.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+</book>
+
Deleted: trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml 2010-06-15 16:49:28 UTC (rev 2233)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/adminshell_guide.xml 2010-06-15 19:52:00 UTC (rev 2234)
@@ -1,56 +0,0 @@
-<?xml version='1.0' encoding="UTF-8"?>
-<!--
-
- JBoss, Home of Professional Open Source.
- Copyright (C) 2008 Red Hat, Inc.
- Licensed to Red Hat, Inc. under one or more contributor
- license agreements. See the copyright.txt file in the
- distribution for a full listing of individual contributors.
-
- 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.
-
--->
-<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
-<!ENTITY % CustomDTD SYSTEM "../../../../../docbook/custom.dtd">
-%CustomDTD;
-]>
-
-<book>
-
- <bookinfo>
- <title>Teiid - Scalable Information Integration</title>
- <subtitle>Teiid Admin Shell User Guide</subtitle>
- <releaseinfo>&versionNumber;</releaseinfo>
- <productnumber>&versionNumber;</productnumber>
- <issuenum>1</issuenum>
- <copyright>
- <year>©rightYear;</year>
- <holder>©rightHolder;</holder>
- </copyright>
- <xi:include href="../../../../../docbook/en-US/legal_notice.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- </bookinfo>
-
- <toc/>
-
- <xi:include href="content/introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/getting-started.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/working-with-scripts.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/connection-management.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/appendix-a.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- <xi:include href="content/appendix-b.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
-
-</book>
-
Added: trunk/documentation/admin-guide/src/main/docbook/en-US/content/admin-console.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/admin-console.xml (rev 0)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/admin-console.xml 2010-06-15 19:52:00 UTC (rev 2234)
@@ -0,0 +1,93 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="admin-console">
+ <title>Teiid Admin Console</title>
+ <para>Teiid admin console is a web based administrative and monitoring tool for Teiid.
+ This is built using the <ulink url="http://www.jboss.org/embjopr">Embedded JOPR</ulink> library that is built to manage the
+ JBoss AS instances. Teiid adds a additional plugin into the Embeeded JOPR program already available in the
+ <ulink url="http://www.jboss.org/jbossas">JBoss AS</ulink>, to provide the Teiid specific functionality.</para>
+
+ <sect1>
+ <title>What can be monitored and/or configured?</title>
+ <para>Here are the steps to follow to install Teiid</para>
+
+ <orderedlist>
+ <listitem> <para><emphasis>The Teiid Runtime Engine</emphasis> (Data Services node in the tree)</para> </listitem>
+ <listitem> <para><emphasis>VDBs</emphasis> - Virtual databases</para>
+ <orderedlist>
+ <listitem> <para><emphasis>Models</emphasis></para>
+ <orderedlist>
+ <listitem> <para><emphasis>Source</emphasis>- these are physical sources</para></listitem>
+ <listitem> <para><emphasis>Multi-source</emphasis> - these are multiple sourced models</para></listitem>
+ <listitem> <para><emphasis>Logical</emphasis> - these are virtual sources</para></listitem>
+ </orderedlist>
+ </listitem>
+ <listitem> <para><emphasis>Translator instances</emphasis>- any Translator instances defined for use by this VDB</para> </listitem>
+ </orderedlist>
+ </listitem>
+ <listitem> <para>Translators - These are the extensions to supported datasources that come with Teiid out-of-the-box.</para> </listitem>
+ </orderedlist>
+
+ <note>
+ <para>The creation/modification of the datasource is managed by the JBossAS plugin.</para>
+ </note>
+
+ <mediaobject>
+ <imageobject>
+ <imagedata fileref="../images/admin_console.png"/>
+ </imageobject>
+ </mediaobject>
+
+ <sect2>
+ <title>Configuration</title>
+ <orderedlist>
+ <listitem> <para>Runtime Engine properties</para> </listitem>
+ <listitem> <para>Buffer Service</para> </listitem>
+ <listitem> <para>Jdbc Socket configuration</para> </listitem>
+ <listitem> <para>Session Service</para> </listitem>
+ </orderedlist>
+ </sect2>
+
+ <sect2>
+ <title>Metrics</title>
+ <orderedlist>
+ <listitem> <para>Long Running Query count</para> </listitem>
+ <listitem> <para>Active Query count</para> </listitem>
+ <listitem> <para>Active Session count</para> </listitem>
+ </orderedlist>
+ </sect2>
+
+ <sect2>
+ <title>Control (Operations)</title>
+ <orderedlist>
+ <listitem> <para>View Long Running Queries</para> </listitem>
+ <listitem> <para>View Current Sessions</para> </listitem>
+ <listitem> <para>Terminate Session</para> </listitem>
+ <listitem> <para>View Current Requests</para> </listitem>
+ <listitem> <para>Terminate requests</para> </listitem>
+ <listitem> <para>View Current Transactions</para> </listitem>
+ <listitem> <para>Terminate Transaction</para> </listitem>
+ </orderedlist>
+ </sect2>
+
+ <sect2 id="vdb_deploy">
+ <title>Deploying the VDB</title>
+ <para>VDB archive files created it the Designer Tool or Dynamic VDBs can be deployed into Teiid server using
+ this "admin-console" tool.</para>
+
+ <orderedlist>
+ <listitem> <para>Select the Virtual Database node in the Admin Console tree and click the Add New Resource button.</para> </listitem>
+ <listitem> <para>Select the VDB archive file from the file system and click continue.</para> </listitem>
+ <listitem> <para>The VDB will deploy if no fatal errors are found in the archive. The status of
+ the VDB will be UP if no errors are found with the models in the VDB.</para> </listitem>
+ <listitem> <para>If there are model errors, the VDB will be deployed with a status of DOWN and the errors will be
+ listed on the configuration tab of the VDB. VDBs that are not UP will be marked with a red X in the tree.</para> </listitem>
+ </orderedlist>
+
+ <para>Only Model's "connection-jndi-name" can be modified using this tool by clicking on the "configuration"
+ tab, all other proeprties are read-only.</para>
+ </sect2>
+
+ </sect1>
+
+</chapter>
\ No newline at end of file
Property changes on: trunk/documentation/admin-guide/src/main/docbook/en-US/content/admin-console.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/documentation/admin-guide/src/main/docbook/en-US/content/adminshell-introduction.xml (from rev 2230, trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml)
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/adminshell-introduction.xml (rev 0)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/adminshell-introduction.xml 2010-06-15 19:52:00 UTC (rev 2234)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="adminshell_introduction">
+ <title>Introduction to Admin Tools</title>
+ <para>
+ AdminShell provides scripting based programming environments that enable user to access, monitor and control a Teiid
+ Server. The Shell and Console tools are built on ones provide by the Groovy (
+ <ulink url="http://groovy.codehaus.org/">http://groovy.codehaus.org/</ulink>
+ ) project. The AdminShell tools be used in ad-hoc scripting or to run pre-defined scripts.
+ </para>
+ <orderedlist>
+ <title>AdminShell features:</title>
+ <listitem>
+ <para>fully functional programming environment with resource flow control and exception
+ management. See <ulink url="http://groovy.codehaus.org/">Groovy</ulink> docs for the full power of the language.</para>
+ </listitem>
+ <listitem>
+ <para>quick administrative tool. The user can connect to a running Teiid Server and invoke any of
+ the Admin API methods, such as "deployVDB" or "stopConnectionFactory", to control Teiid System.
+ Since this can be script driven, these tasks can be automated and re-run at a later time.</para>
+ </listitem>
+ <listitem>
+ <para>simplified data access tool. The user can connect to a VDB, issue any SQL commands, and view the
+ results of the query via <ulink url="http://groovy.codehaus.org/Database+features">Groovy Sql</ulink> extensions.</para>
+ </listitem>
+ <listitem>
+ <para>migration tool. This can be used to develop scripts like moving the Virtual Databases
+ (VDB), Connection Factories, and Configuration from one development environment to another. This will
+ enable users to test and automate their migration scripts before production deployments.</para>
+ </listitem>
+ <listitem>
+ <para>testing tool. The JUnit (
+ <ulink url="http://junit.org/">http://junit.org</ulink>
+ ) test framework is built in, see <ulink url="http://groovy.codehaus.org/Unit+Testing">Groovy Unit Tests</ulink>. User can write regression tests for checking system health, or data
+ integrity that can be used to validate a system functionality automatically instead of manual
+ verification by QA personnel.
+ </para>
+ </listitem>
+ </orderedlist>
+ <sect1>
+ <title>Where can you find AdminShell?</title>
+ <para>AdminShell is distributed along with other Teiid downloads under "teiid-{version}-adminshell-dist.zip" name. Download and unzip this
+ file to any directory. Once you have unzipped the file, in root directory
+ you will find "adminshell" and "adminconsole" executable scripts.</para>
+ <para>Windows: Double click or execute "adminshell.cmd"</para>
+ <para>*nix: Execute the "adminshell.sh" script</para>
+ </sect1>
+</chapter>
\ No newline at end of file
Added: trunk/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml (rev 0)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml 2010-06-15 19:52:00 UTC (rev 2234)
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="installation">
+ <title>Installation Guide</title>
+ <para>Teiid 7.0 installation is entirely different from previous versions. Previously Teiid could be installed
+ as a standalone or embedded server. Starting with this release Teiid needs to be installed into an
+ existing JBoss AS installation. Teiid does not support the "embedded" mode in 7.0 version. ("embedded" version
+ will be coming in a future release soon).
+ </para>
+
+ <sect1>
+ <title>Installation:</title>
+ <para>Here are the steps to follow to install Teiid</para>
+ <orderedlist numeration="arabic">
+ <listitem>
+ <para>Download the <ulink url="http://www.jboss.org/jbossas/downloads.html">JBoss AS 5.1.0</ulink> application server.
+ Install the server by unzipping into a known location. Ex: /apps/jboss-5.1.0</para>
+ </listitem>
+ <listitem>
+ <para>Download <ulink url="http://www.jboss.org/teiid/downloads.html">Teiid 7.0</ulink>. Unzip the downloaded artifact inside any "profiles"
+ inside the JBoss AS installation. We suggest using either "default" or "all".
+ Teiid 7.0 for the administrative purposes uses a service called "profile service" that
+ is only installed in "default" and "all" profiles, so installing into one of these
+ profiles is required. Ex: /apps/jboss-5.10/server/default</para>
+ </listitem>
+
+ <listitem>
+ <para>Start the JBoss AS server by executing "/apps/jboss-5.1.0/bin/run.sh" if you installed in the
+ "default" profile. Other wise use "/apps/jboss-5.1.0/bin/run.sh -c <profilename>"
+ </para>
+ </listitem>
+
+ <listitem>
+ <para>That it!. JBoss AS and Teiid are now installed and running. See below instructions to customize various settings.</para>
+ </listitem>
+
+ <listitem>
+ <para>Users can now connect their JDBC applications to Teiid. If you need help on connecting your application to the
+ Teiid using JDBC check out the "Client Developer's Guide".
+ </para>
+ </listitem>
+ </orderedlist>
+ </sect1>
+ <sect1>
+ <title>Directory Structure Explained</title>
+ <para>The below file structure shows the contents of the Teiid 7.0 deployment. This directory
+ structure is "exactly" same as what is under any JBoss profile directory structure like "default"</para>
+
+ <programlisting><![CDATA[
+ teiid
+ /conf
+ /props
+ teiid-security-roles.properties
+ teiid-security-users.properties
+ jboss-teiid-log4j.xml
+ /deploy
+ /teiid
+ /connectors
+ teiid-jboss-beans.xml
+ teiid-connector-templates-jboss-beans.xml
+ admin-console.war
+ /deployers
+ /teiid.deployer
+ /lib
+ /teiid-examples
+ ]]></programlisting>
+
+ <sect2>
+ <title>/deploy/teiid/teiid-jboss-beans.xml</title>
+ <para>Master configuration file for Teiid system. This file contains its own documentation,
+ so refer to the file for all the available properties to configure.</para>
+ </sect2>
+
+ <sect2>
+ <title>/deploy/teiid/connectors</title>
+ <para>This directory contains all the connector RAR files that are supplied as part of the Teiid installation.</para>
+ </sect2>
+
+ <sect2>
+ <title>/conf/props</title>
+ <para> /teiid-security-users.properties</para>
+ <para> /teiid-security-roles.properties</para>
+ <para>These files define the allowed users and their defined roles in Teiid using the default security domain. Edit these
+ files to add uses. If you want to use a different security domain look for details in main configuration file.</para>
+ </sect2>
+
+ <sect2>
+ <title>/conf/jboss-teiid-log4j.xml</title>
+ <para>This file contains the Teiid specific logging contexts to be included in the "jboss-log4j.xml" file.
+ If you need to turn ON or OFF specific logging in Teiid,
+ then copy the contents of this file into "jboss-log4j.xml" in the
+ installation directory. See the Server Extension Guide for more on logging.</para>
+ </sect2>
+
+ <sect2>
+ <title>admin-console.war</title>
+ <para>This file has the required files for Teiid JOPR plugin. To see the
+ Teiid's "admin-console", go to http://<host>:<port>/admin-console</para>
+ </sect2>
+
+ <sect2>
+ <title>/deployers/teiid.deployer</title>
+ <para>This directory contains all the connector RAR files that are supplied as part of the Teiid installation.</para>
+ </sect2>
+
+ <sect2>
+ <title>/deploy/teiid/connectors</title>
+ <para>This directory contains Teiid runtime specific configuration files and its libraries.
+ These configuration files define VDB deployers, connector binding deployers etc.
+ Typically user never need to edit any files in this directory.</para>
+ </sect2>
+
+ <sect2>
+ <title>lib</title>
+ <para>This directory contains Teiid client libraries. It has the Teiid JDBC driver jar, "teiid-{version}-client.jar",
+ and also contains "teiid-hibernate-dialect-{version}.jar" that contains Teiid's Hibernate dialect.</para>
+ </sect2>
+
+ <sect2>
+ <title>teiid-examples</title>
+ <para>This directory contains some examples of how Teiid can be used. Contains artifacts
+ need by the Getting Started Guide. Also contains some sample XML files to define the connectors.</para>
+ </sect2>
+
+ <sect2>
+ <title>teiid-docs</title>
+ <para>This directory contains the PDF documents related Teiid and Teiid development. </para>
+ </sect2>
+
+ </sect1>
+
+</chapter>
\ No newline at end of file
Property changes on: trunk/documentation/admin-guide/src/main/docbook/en-US/content/installation.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml 2010-06-15 16:49:28 UTC (rev 2233)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/introduction.xml 2010-06-15 19:52:00 UTC (rev 2234)
@@ -1,48 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-<chapter id="introduction">
- <title>Introduction to Admin Tools</title>
- <para>
- AdminShell provides scripting based programming environments that enable user to access, monitor and control a Teiid
- Server. The Shell and Console tools are built on ones provide by the Groovy (
- <ulink url="http://groovy.codehaus.org/">http://groovy.codehaus.org/</ulink>
- ) project. The AdminShell tools be used in ad-hoc scripting or to run pre-defined scripts.
- </para>
- <orderedlist>
- <title>AdminShell features:</title>
- <listitem>
- <para>fully functional programming environment with resource flow control and exception
- management. See <ulink url="http://groovy.codehaus.org/">Groovy</ulink> docs for the full power of the language.</para>
- </listitem>
- <listitem>
- <para>quick administrative tool. The user can connect to a running Teiid Server and invoke any of
- the Admin API methods, such as "deployVDB" or "stopConnectionFactory", to control Teiid System.
- Since this can be script driven, these tasks can be automated and re-run at a later time.</para>
- </listitem>
- <listitem>
- <para>simplified data access tool. The user can connect to a VDB, issue any SQL commands, and view the
- results of the query via <ulink url="http://groovy.codehaus.org/Database+features">Groovy Sql</ulink> extensions.</para>
- </listitem>
- <listitem>
- <para>migration tool. This can be used to develop scripts like moving the Virtual Databases
- (VDB), Connection Factories, and Configuration from one development environment to another. This will
- enable users to test and automate their migration scripts before production deployments.</para>
- </listitem>
- <listitem>
- <para>testing tool. The JUnit (
- <ulink url="http://junit.org/">http://junit.org</ulink>
- ) test framework is built in, see <ulink url="http://groovy.codehaus.org/Unit+Testing">Groovy Unit Tests</ulink>. User can write regression tests for checking system health, or data
- integrity that can be used to validate a system functionality automatically instead of manual
- verification by QA personnel.
- </para>
- </listitem>
- </orderedlist>
- <sect1>
- <title>Where can you find AdminShell?</title>
- <para>AdminShell is distributed along with other Teiid downloads under "teiid-{version}-adminshell-dist.zip" name. Download and unzip this
- file to any directory. Once you have unzipped the file, in root directory
- you will find "adminshell" and "adminconsole" executable scripts.</para>
- <para>Windows: Double click or execute "adminshell.cmd"</para>
- <para>*nix: Execute the "adminshell.sh" script</para>
- </sect1>
-</chapter>
\ No newline at end of file
Added: trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
===================================================================
--- trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml (rev 0)
+++ trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml 2010-06-15 19:52:00 UTC (rev 2234)
@@ -0,0 +1,131 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<chapter id="vdb-deployment">
+ <title>Deploying VDBs in Teiid 7</title>
+ <para>
+ A <ulink url="http://www.jboss.org/teiid/basics/virtualdatabases.html">VDB</ulink>is the primary means to define a
+ Virtual Database in Teiid. A user can create a VDB using
+ <ulink url="http://www.jboss.org/teiiddesigner.html">Teiid Designer</ulink> or follow the instructions in the "reference" guide
+ create a "Dynamic VDB" without Designer for data integration purposes. If you do not know what a VDB is,
+ then please start with these <ulink url="http://www.jboss.org/teiid/basics/virtualdatabases.html">documents</ulink>
+ </para>
+
+ <sect1>
+ <title>Deploying a VDB</title>
+ <para>Once you have a "VDB" built it can be deployed in Teiid runtime in different ways.</para>
+
+ <sect2>
+ <title>By Copying the File</title>
+ <para>Copy the VDB file into the "<jboss-install>/server/<profile>/deploy" directory.
+ Make sure that there are no other VDB files with the same name. If a VDB already exists with
+ the same name, then this VDB will be replaced with the new VDB. T
+ his is the simplest way to deploy a VDB.</para>
+ </sect2>
+
+ <sect2>
+ <title>By Using Admin API</title>
+ <para>The Admin API (look in org.teiid.adminpi.*) provides Java API methods that
+ let's a user connect to a Teiid runtime and deploy a VDB. If you need to programmatically deploy a VDB use this method.</para>
+ </sect2>
+
+ <sect2>
+ <title>By Using Admin Shell</title>
+ <para>Teiid provides "groovy" based Admin Shell scripting tool, which can be used to deploy
+ a VDB. Check out the "deployVDB" method. Check out more information about <emphasis>Admin Shell</emphasis>
+ <link linkend="adminshell_introduction">here</link>. </para>
+ </sect2>
+
+ <sect2>
+ <title>By Using Admin-Console (JOPR Based Web tool )</title>
+ <para>Use the JOPR-based web console configuration system, which will enable users to connect
+ to a running Teiid and provide a way to deploy a VDB. Check out the JOPR plugin at:</para>
+
+ <programlisting><![CDATA[
+ http://<host>:<port>/admin-console
+ ]]></programlisting>
+ </sect2>
+ </sect1>
+
+ <para>Option 1 can be used for local development VDB deployment or deployment in a
+ manually controlled environment. Options 2, 3 and 4 can be used when your Teiid runtime
+ instance is a remote instance or if you need a programmatic way to control your deployment.</para>
+
+ <sect1>
+ <title>Deploying VDB Dependencies</title>
+ <para>Apart from deploying the VDB, the user is also responsible for providing all the necessary
+ dependent libraries, configuration for creating the data sources that are needed by the Schemas (models)
+ defined in "META-INF/vdb.xml" file inside your VDB. This section shows you a sample VDB configuration needed.</para>
+
+ <para>For example, if you are trying to integrate Oracle and File sources in your VDB, then you are responsible for
+ providing the JDBC driver for the Oracle source, and any necessary documents and configuration that are needed by the File Translator.</para>
+
+ <sect2>
+ <title>Creating Oracle Data source</title>
+ <orderedlist>
+ <listitem> <para>Copy the Oracle JDBC JAR file into "<jboss-install>/server/<profile>/lib" directory </para> </listitem>
+ <listitem> <para>Create a "data source" to the Oracle instance in the JBoss container. This typically
+ done by creating "xxx-ds.xml" file and copying this file to the "<jboss-install>/server/%lt;profile>/deploy"
+ directory. The following shows a "-ds.xml" file template for Oracle. You can also use admin-console to create this data source. </para>
+ <programlisting><![CDATA[
+ <?xml version="1.0" encoding="UTF-8"?>
+ <datasources>
+ <xa-datasource>
+ <jndi-name>OracleDS</jndi-name>
+ <!-- uncomment to enable interleaving <interleaving/> -->
+ <isSameRM-override-value>false</isSameRM-override-value>
+ <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+ <xa-datasource-property name="URL">jdbc:oracle:oci8:@tc</xa-datasource-property>
+ <xa-datasource-property name="User">scott</xa-datasource-property>
+ <xa-datasource-property name="Password">tiger</xa-datasource-property>
+ <!-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -->
+ <!--valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker</valid-connection-checker-class-name-->
+ <!-- Checks the Oracle error codes and messages for fatal errors -->
+ <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
+ <!-- Oracles XA datasource cannot reuse a connection outside a transaction once enlisted in a global transaction and vice-versa -->
+ <no-tx-separate-pools/>
+ <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
+ <metadata>
+ <type-mapping>Oracle9i</type-mapping>
+ </metadata>
+ </xa-datasource>
+ </datasources>
+ ]]></programlisting>
+ </listitem>
+ </orderedlist>
+ <para>There are templates for all the data sources in the "<jboss-install>/docs/examples/jca" directory.</para>
+
+ </sect2>
+ <sect2>
+ <title>Creating File Data source</title>
+ <para>File data source uses Teiid specific JCA connector. You need to create "-ds.xml" file and copy it to the
+ "<jboss-install>/server/%lt;profile>/deploy" directory. The below is template for creating a File based data source</para>
+
+ <programlisting><![CDATA[
+ <?xml version="1.0" encoding="UTF-8"?>
+ <connection-factories>
+ <no-tx-connection-factory>
+ <jndi-name>text-source</jndi-name>
+ <rar-name>connector-file-{version}.rar</rar-name>
+ <connection-definition>javax.resource.cci.ConnectionFactory</connection-definition>
+ <config-property name="ParentDirectory" type="java.lang.String">path-to-the-directory-of-data-file</config-property>
+ <max-pool-size>1</max-pool-size>
+ </no-tx-connection-factory>
+ </connection-factories>
+ ]]></programlisting>
+ </sect2>
+ </sect1>
+
+ <para>Once the VDB and its dependencies are deployed, then your client application can connect to the
+ deployed VDB using the JDBC API. If there are any errors in the deployment, the connection will not be successful. You can use the
+ <link linkend="admin-console">admin-console</link> tool or check the log files for errors and correct them before proceeding.</para>
+
+ <sect1>
+ <title>Migrating VDBs from 6.x</title>
+ <para>VDBs from prior release contain an older configuration file version that is no longer supported.
+ You can use the migration utility (bin/migrate.sh or bin/migrate.bat) supplied with the
+ <link linkend="adminshell_introduction">Admin Shell</link> download
+ to update these VDBs for use with Teiid 7. Note - XML and File based sources from previous releases are changed, so do not work
+ as is. The VDB models need to be updated for this as these are breaking changes.</para>
+ </sect1>
+
+</chapter>
\ No newline at end of file
Property changes on: trunk/documentation/admin-guide/src/main/docbook/en-US/content/vdb-deployment.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/documentation/admin-guide/src/main/docbook/en-US/images/admin_console.png
===================================================================
(Binary files differ)
Property changes on: trunk/documentation/admin-guide/src/main/docbook/en-US/images/admin_console.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
14 years, 6 months
teiid SVN: r2233 - in trunk: client/src/main/java/org/teiid/jdbc and 32 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-06-15 12:49:28 -0400 (Tue, 15 Jun 2010)
New Revision: 2233
Added:
trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLParse.java
Removed:
trunk/common-core/src/main/java/org/teiid/core/types/basic/ClobToSQLXMLTransform.java
trunk/common-core/src/main/java/org/teiid/core/types/basic/SQLXMLToClobTransform.java
trunk/common-core/src/test/java/org/teiid/api/exception/
trunk/common-core/src/test/java/org/teiid/common/util/
trunk/engine/src/main/java/org/teiid/query/processor/xml/SAXDocumentInProgress.java
Modified:
trunk/api/src/main/java/org/teiid/language/SQLConstants.java
trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java
trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
trunk/common-core/src/main/java/org/teiid/core/types/InputStreamFactory.java
trunk/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java
trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java
trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java
trunk/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java
trunk/common-core/src/main/java/org/teiid/core/util/ReaderInputStream.java
trunk/common-core/src/main/resources/org/teiid/core/i18n.properties
trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java
trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/engine/src/main/java/org/teiid/common/buffer/FileStore.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/ByteLobChunkStream.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/DocumentInProgress.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/InitializeDocumentInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLUtil.java
trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.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/util/CommandContext.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestAddNodeInstruction.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestSAXDocumentInProgress.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-1024 added xmlparse/xmlserialize to augment basic convert support. also ensuring that encoding will be null if it is not known.
Modified: trunk/api/src/main/java/org/teiid/language/SQLConstants.java
===================================================================
--- trunk/api/src/main/java/org/teiid/language/SQLConstants.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/api/src/main/java/org/teiid/language/SQLConstants.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -82,8 +82,10 @@
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$
-
+ //querystring function
public static final String QUERYSTRING = "QUERYSTRING"; //$NON-NLS-1$
+ //xmlparse
+ public static final String WELLFORMED = "WELLFORMED"; //$NON-NLS-1$
}
public interface Reserved {
Modified: trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/client/src/main/java/org/teiid/jdbc/PreparedStatementImpl.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -61,6 +61,7 @@
import org.teiid.core.types.ClobImpl;
import org.teiid.core.types.InputStreamFactory;
import org.teiid.core.types.JDBCSQLTypeInfo;
+import org.teiid.core.types.Streamable;
import org.teiid.core.util.ArgCheck;
import org.teiid.core.util.ReaderInputStream;
import org.teiid.core.util.SqlUtil;
@@ -725,11 +726,11 @@
}
public void setClob(int parameterIndex, final Reader reader) throws SQLException {
- this.setObject(parameterIndex, new ClobImpl(new InputStreamFactory() {
+ this.setObject(parameterIndex, new ClobImpl(new InputStreamFactory(Streamable.ENCODING) {
@Override
public InputStream getInputStream() throws IOException {
- return new ReaderInputStream(reader, Charset.defaultCharset());
+ return new ReaderInputStream(reader, Charset.forName(Streamable.ENCODING));
}
}, -1));
}
Modified: trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java
===================================================================
--- trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/client/src/main/java/org/teiid/jdbc/ResultSetImpl.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -295,15 +295,15 @@
}
}
if(currentValue instanceof ClobType){
- currentValue = new ClobImpl(createInputStreamFactory((ClobType)currentValue), ((ClobType)currentValue).getLength());
+ currentValue = new ClobImpl(createInputStreamFactory((ClobType)currentValue, null), ((ClobType)currentValue).getLength());
}
else if (currentValue instanceof BlobType) {
- InputStreamFactory isf = createInputStreamFactory((BlobType)currentValue);
+ InputStreamFactory isf = createInputStreamFactory((BlobType)currentValue, null);
isf.setLength(((BlobType)currentValue).getLength());
currentValue = new BlobImpl(isf);
}
else if (currentValue instanceof XMLType) {
- currentValue = new SQLXMLImpl(createInputStreamFactory((XMLType)currentValue));
+ currentValue = new SQLXMLImpl(createInputStreamFactory((XMLType)currentValue, ((XMLType)currentValue).getEncoding()));
}
}
else if (currentValue instanceof java.util.Date) {
@@ -315,10 +315,13 @@
}
return currentValue;
}
-
- private InputStreamFactory createInputStreamFactory(Streamable<?> type) {
+
+ private InputStreamFactory createInputStreamFactory(Streamable<?> type, String encoding) {
+ if (encoding == null) {
+ encoding = Streamable.ENCODING;
+ }
final StreamingLobChunckProducer.Factory factory = new StreamingLobChunckProducer.Factory(this.statement.getDQP(), this.requestID, type);
- InputStreamFactory isf = new InputStreamFactory(Streamable.ENCODING) {
+ InputStreamFactory isf = new InputStreamFactory(encoding) {
@Override
public InputStream getInputStream() throws IOException {
return new LobChunkInputStream(factory.getLobChunkProducer());
Modified: trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java
===================================================================
--- trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/client/src/main/java/org/teiid/netty/handler/codec/serialization/CompactObjectOutputStream.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -201,6 +201,7 @@
references.add(sfr);
return sfr;
} else if (obj instanceof Clob) {
+ //TODO: see if this is a ClobImpl and grab the underlying stream
streams.add(new ReaderInputStream(((Clob)obj).getCharacterStream(), Charset.forName(Streamable.ENCODING)));
StreamFactoryReference sfr = new ClobImpl();
references.add(sfr);
Modified: trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/common-core/src/main/java/org/teiid/core/types/DataTypeManager.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -48,7 +48,6 @@
import org.teiid.core.types.basic.AnyToObjectTransform;
import org.teiid.core.types.basic.AnyToStringTransform;
import org.teiid.core.types.basic.BooleanToNumberTransform;
-import org.teiid.core.types.basic.ClobToSQLXMLTransform;
import org.teiid.core.types.basic.FixedNumberToBigDecimalTransform;
import org.teiid.core.types.basic.FixedNumberToBigIntegerTransform;
import org.teiid.core.types.basic.FloatingNumberToBigDecimalTransform;
@@ -62,7 +61,6 @@
import org.teiid.core.types.basic.NumberToLongTransform;
import org.teiid.core.types.basic.NumberToShortTransform;
import org.teiid.core.types.basic.ObjectToAnyTransform;
-import org.teiid.core.types.basic.SQLXMLToClobTransform;
import org.teiid.core.util.ArgCheck;
import org.teiid.core.util.HashCodeUtil;
import org.teiid.core.util.PropertiesUtils;
@@ -135,6 +133,7 @@
private static Map<Class<?>, ValueCache<?>> valueMaps = new HashMap<Class<?>, ValueCache<?>>(128);
public static final int MAX_STRING_LENGTH = 4000;
+ public static final int MAX_LOB_MEMORY_BYTES = 1 << 13;
public static final class DataTypeAliases {
public static final String VARCHAR = "varchar"; //$NON-NLS-1$
@@ -688,11 +687,9 @@
DataTypeManager.addTransform(new org.teiid.core.types.basic.StringToSQLXMLTransform());
DataTypeManager.addTransform(new org.teiid.core.types.basic.ClobToStringTransform());
- DataTypeManager.addTransform(new ClobToSQLXMLTransform());
-
- DataTypeManager.addTransform(new org.teiid.core.types.basic.SQLXMLToStringTransform());
- DataTypeManager.addTransform(new SQLXMLToClobTransform());
+ DataTypeManager.addTransform(new org.teiid.core.types.basic.SQLXMLToStringTransform());
+
for (Class<?> type : getAllDataTypeClasses()) {
if (type != DefaultDataClasses.OBJECT) {
DataTypeManager.addTransform(new AnyToObjectTransform(type));
Modified: trunk/common-core/src/main/java/org/teiid/core/types/InputStreamFactory.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/InputStreamFactory.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/common-core/src/main/java/org/teiid/core/types/InputStreamFactory.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -30,9 +30,15 @@
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.Charset;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.SQLException;
+import java.sql.SQLXML;
import javax.xml.transform.Source;
+import org.teiid.core.util.ReaderInputStream;
+
public abstract class InputStreamFactory implements Source {
public interface StreamFactoryReference {
@@ -46,7 +52,6 @@
private long length = -1;
public InputStreamFactory() {
- this(Charset.defaultCharset().name());
}
public InputStreamFactory(String encoding) {
@@ -63,6 +68,10 @@
return encoding;
}
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
@Override
public String getSystemId() {
return this.systemId;
@@ -86,7 +95,11 @@
}
public Reader getCharacterStream() throws IOException {
- return new InputStreamReader(this.getInputStream(), this.getEncoding());
+ String enc = this.getEncoding();
+ if (enc == null) {
+ enc = Charset.defaultCharset().displayName();
+ }
+ return new InputStreamReader(this.getInputStream(), enc);
}
public static class FileInputStreamFactory extends InputStreamFactory {
@@ -94,7 +107,7 @@
private File f;
public FileInputStreamFactory(File f) {
- this(f, Charset.defaultCharset().displayName());
+ this(f, null);
}
public FileInputStreamFactory(File f, String encoding) {
@@ -115,4 +128,89 @@
}
+ public static class ClobInputStreamFactory extends InputStreamFactory {
+
+ private Clob clob;
+
+ public ClobInputStreamFactory(Clob clob) {
+ super(Streamable.ENCODING);
+ this.clob = clob;
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ try {
+ return new ReaderInputStream(clob.getCharacterStream(), Charset.forName(Streamable.ENCODING));
+ } catch (SQLException e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public Reader getCharacterStream() throws IOException {
+ try {
+ return clob.getCharacterStream();
+ } catch (SQLException e) {
+ throw new IOException(e);
+ }
+ }
+
+ }
+
+ public static class BlobInputStreamFactory extends InputStreamFactory {
+
+ private Blob blob;
+
+ public BlobInputStreamFactory(Blob blob) {
+ this.blob = blob;
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ try {
+ return blob.getBinaryStream();
+ } catch (SQLException e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public long getLength() {
+ try {
+ return blob.length();
+ } catch (SQLException e) {
+ return -1;
+ }
+ }
+
+ }
+
+ public static class SQLXMLInputStreamFactory extends InputStreamFactory {
+
+ private SQLXML sqlxml;
+
+ public SQLXMLInputStreamFactory(SQLXML sqlxml) {
+ this.sqlxml = sqlxml;
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ try {
+ return sqlxml.getBinaryStream();
+ } catch (SQLException e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public Reader getCharacterStream() throws IOException {
+ try {
+ return sqlxml.getCharacterStream();
+ } catch (SQLException e) {
+ throw new IOException(e);
+ }
+ }
+
+ }
+
}
Modified: trunk/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/common-core/src/main/java/org/teiid/core/types/SQLXMLImpl.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -26,24 +26,39 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.Reader;
import java.io.Writer;
import java.nio.charset.Charset;
import java.sql.SQLException;
import java.sql.SQLXML;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamSource;
import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.SqlUtil;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
-
-
/**
* Default SQLXML impl
+ *
+ * NOTE that this representation of XML does not become unreadable after
+ * read operations.
*/
public class SQLXMLImpl extends BaseLob implements SQLXML {
+
+ private boolean inMemory;
public SQLXMLImpl() {
@@ -60,6 +75,7 @@
return new ByteArrayInputStream(bytes);
}
});
+ inMemory = true;
}
public SQLXMLImpl(final String str) {
@@ -70,17 +86,57 @@
super(factory);
}
+ @Override
+ public Reader getCharacterStream() throws SQLException {
+ setEncoding();
+ return super.getCharacterStream();
+ }
+
+ private void setEncoding() throws SQLException {
+ String encoding = XMLType.getEncoding(this);
+ if (encoding != null) {
+ this.getStreamFactory().setEncoding(encoding);
+ }
+ }
+
+ public boolean isInMemory() {
+ return inMemory;
+ }
+
@SuppressWarnings("unchecked")
public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException {
if (sourceClass == null || sourceClass == StreamSource.class) {
return (T)new StreamSource(getBinaryStream(), this.getStreamFactory().getSystemId());
+ } else if (sourceClass == StAXSource.class) {
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ try {
+ return (T) new StAXSource(factory.createXMLStreamReader(getBinaryStream()));
+ } catch (XMLStreamException e) {
+ throw new SQLException(e);
+ }
+ } else if (sourceClass == SAXSource.class) {
+ return (T) new SAXSource(new InputSource(getBinaryStream()));
+ } else if (sourceClass == DOMSource.class) {
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ DocumentBuilder docBuilder = dbf.newDocumentBuilder();
+ Node doc = docBuilder.parse(new InputSource(getBinaryStream()));
+ return (T) new DOMSource(doc);
+ } catch (ParserConfigurationException e) {
+ throw new SQLException(e);
+ } catch (SAXException e) {
+ throw new SQLException(e);
+ } catch (IOException e) {
+ throw new SQLException(e);
+ }
}
throw new SQLException("Unsupported source type " + sourceClass); //$NON-NLS-1$
}
public String getString() throws SQLException {
try {
- return new String(ObjectConverterUtil.convertToByteArray(getBinaryStream()), this.getStreamFactory().getEncoding());
+ return ObjectConverterUtil.convertToString(getCharacterStream());
} catch (IOException e) {
SQLException ex = new SQLException(e.getMessage());
ex.initCause(e);
@@ -100,14 +156,6 @@
throw SqlUtil.createFeatureNotSupportedException();
}
- public String toString() {
- try {
- return getString();
- } catch (SQLException e) {
- throw new RuntimeException(e);
- }
- }
-
public <T extends Result> T setResult(Class<T> resultClass)
throws SQLException {
throw SqlUtil.createFeatureNotSupportedException();
Modified: trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/common-core/src/main/java/org/teiid/core/types/XMLType.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -22,26 +22,27 @@
package org.teiid.core.types;
+import java.io.IOException;
import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.sql.SQLException;
-//## JDBC4.0-begin ##
import java.sql.SQLXML;
-//## JDBC4.0-end ##
-/*## JDBC3.0-JDK1.5-begin ##
-import com.metamatrix.core.jdbc.SQLXML;
-## JDBC3.0-JDK1.5-end ##*/
-
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
/**
- * This class represents the SQLXML object along with the Streamable interface. This is
- * class used everywhere in the MetaMatrix framework, but clients are restricted to use
- * only SQLXML interface on top of this.
+ * This class represents the SQLXML object along with the Streamable interface.
+ *
+ * NOTE that this representation of XML does not become unreadable after
+ * read operations.
*/
public final class XMLType extends Streamable<SQLXML> implements SQLXML {
@@ -52,6 +53,7 @@
private static final long serialVersionUID = -7922647237095135723L;
private transient Type type = Type.UNKNOWN;
+ private String encoding;
public XMLType(){
@@ -106,4 +108,70 @@
this.type = type;
}
+ public Boolean isInMemory() {
+ if (this.reference instanceof SQLXMLImpl) {
+ return (((SQLXMLImpl) this.reference).isInMemory());
+ }
+ return null;
+ }
+
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ @Override
+ public void readExternal(ObjectInput in) throws IOException,
+ ClassNotFoundException {
+ super.readExternal(in);
+ this.encoding = (String)in.readObject();
+ }
+
+ @Override
+ public void writeExternal(ObjectOutput out) throws IOException {
+ super.writeExternal(out);
+ if (this.encoding == null) {
+ this.encoding = getEncoding(this);
+ }
+ out.writeObject(this.encoding);
+ }
+
+ /**
+ * Returns the encoding or null if it cannot be determined
+ * @param xml
+ * @return
+ */
+ public static String getEncoding(SQLXML xml) {
+ InputStream is = null;
+ try {
+ if (xml instanceof XMLType) {
+ XMLType type = (XMLType)xml;
+ xml = type.reference;
+ }
+ if (xml instanceof SQLXMLImpl) {
+ String encoding = ((SQLXMLImpl)xml).getStreamFactory().getEncoding();
+ if (encoding != null) {
+ return encoding;
+ }
+ }
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ is = xml.getBinaryStream();
+ XMLStreamReader reader = factory.createXMLStreamReader(is);
+ return reader.getEncoding();
+ } catch (SQLException e) {
+ return null;
+ } catch (XMLStreamException e) {
+ return null;
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+ }
}
Deleted: trunk/common-core/src/main/java/org/teiid/core/types/basic/ClobToSQLXMLTransform.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/basic/ClobToSQLXMLTransform.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/common-core/src/main/java/org/teiid/core/types/basic/ClobToSQLXMLTransform.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -1,108 +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.core.types.basic;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.nio.charset.Charset;
-import java.sql.SQLException;
-
-import org.teiid.core.CorePlugin;
-import org.teiid.core.types.ClobImpl;
-import org.teiid.core.types.ClobType;
-import org.teiid.core.types.DataTypeManager;
-import org.teiid.core.types.InputStreamFactory;
-import org.teiid.core.types.SQLXMLImpl;
-import org.teiid.core.types.Streamable;
-import org.teiid.core.types.Transform;
-import org.teiid.core.types.TransformationException;
-import org.teiid.core.types.XMLType;
-import org.teiid.core.types.XMLType.Type;
-import org.teiid.core.util.ReaderInputStream;
-
-
-public class ClobToSQLXMLTransform extends Transform {
-
- @Override
- public Class<?> getSourceType() {
- return DataTypeManager.DefaultDataClasses.CLOB;
- }
-
- @Override
- public Class<?> getTargetType() {
- return DataTypeManager.DefaultDataClasses.XML;
- }
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transformDirect(Object value) throws TransformationException {
- final ClobType source = (ClobType)value;
-
- Reader reader = null;
- try {
- reader = source.getCharacterStream();
- XMLType result = null;
- Type type = StringToSQLXMLTransform.isXml(reader);
- if (source.getReference() instanceof ClobImpl) {
- ClobImpl clob = (ClobImpl)source.getReference();
- result = new XMLType(new SQLXMLImpl(clob.getStreamFactory()));
- } else {
- result = new XMLType(new SQLXMLImpl(new InputStreamFactory(Streamable.ENCODING) {
- @Override
- public InputStream getInputStream() throws IOException {
- try {
- return new ReaderInputStream(source.getCharacterStream(), Charset.forName(Streamable.ENCODING));
- } catch (SQLException e) {
- throw new IOException(e);
- }
- }
- }));
- }
- result.setType(type);
- return result;
- } catch (SQLException e) {
- throw new TransformationException(e, CorePlugin.Util.getString("failed_convert", new Object[] {getSourceType().getName(), getTargetType().getName()})); //$NON-NLS-1$
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- }
- }
- }
- }
-
- /**
- * @see org.teiid.core.types.Transform#isExplicit()
- */
- public boolean isExplicit() {
- return true;
- }
-}
Deleted: trunk/common-core/src/main/java/org/teiid/core/types/basic/SQLXMLToClobTransform.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/basic/SQLXMLToClobTransform.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/common-core/src/main/java/org/teiid/core/types/basic/SQLXMLToClobTransform.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -1,92 +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.core.types.basic;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.sql.SQLException;
-
-import org.teiid.core.CorePlugin;
-import org.teiid.core.types.ClobImpl;
-import org.teiid.core.types.ClobType;
-import org.teiid.core.types.DataTypeManager;
-import org.teiid.core.types.InputStreamFactory;
-import org.teiid.core.types.SQLXMLImpl;
-import org.teiid.core.types.Streamable;
-import org.teiid.core.types.Transform;
-import org.teiid.core.types.TransformationException;
-import org.teiid.core.types.XMLType;
-import org.teiid.core.util.ReaderInputStream;
-
-
-public class SQLXMLToClobTransform extends Transform {
-
- @Override
- public Class<?> getSourceType() {
- return DataTypeManager.DefaultDataClasses.XML;
- }
-
- @Override
- public Class<?> getTargetType() {
- return DataTypeManager.DefaultDataClasses.CLOB;
- }
-
- /**
- * This method transforms a value of the source type into a value
- * of the target type.
- * @param value Incoming value of source type
- * @return Outgoing value of target type
- * @throws TransformationException if value is an incorrect input type or
- * the transformation fails
- */
- public Object transformDirect(Object value) throws TransformationException {
- final XMLType source = (XMLType)value;
-
- try {
- if (source.getReference() instanceof SQLXMLImpl) {
- SQLXMLImpl xml = (SQLXMLImpl)source.getReference();
- return new ClobType(new ClobImpl(xml.getStreamFactory(), -1));
- }
- return new ClobType(new ClobImpl(new InputStreamFactory(Streamable.ENCODING) {
- @Override
- public InputStream getInputStream() throws IOException {
- try {
- return new ReaderInputStream(source.getCharacterStream(), Charset.forName(Streamable.ENCODING));
- } catch (SQLException e) {
- throw new IOException(e);
- }
- }
- }, -1));
- } catch (SQLException e) {
- throw new TransformationException(e, CorePlugin.Util.getString("failed_convert", new Object[] {getSourceType().getName(), getTargetType().getName()})); //$NON-NLS-1$
- }
- }
-
- /**
- * @see org.teiid.core.types.Transform#isExplicit()
- */
- public boolean isExplicit() {
- return true;
- }
-}
Modified: trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/common-core/src/main/java/org/teiid/core/types/basic/StringToSQLXMLTransform.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -26,8 +26,8 @@
import java.io.Reader;
import java.io.StringReader;
-import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.XMLEvent;
import org.teiid.core.CorePlugin;
@@ -62,12 +62,13 @@
Type type = Type.ELEMENT;
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
try{
- XMLEventReader xmlReader = inputFactory.createXMLEventReader(reader);
+ XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(reader);
+ int event = xmlReader.getEventType();
+ if (event == XMLEvent.START_DOCUMENT && xmlReader.getLocation().getColumnNumber() != 1) {
+ type = Type.DOCUMENT;
+ }
while (xmlReader.hasNext()) {
- XMLEvent event = xmlReader.nextEvent();
- if (event.isStartDocument() && event.getLocation().getColumnNumber() != 1) {
- type = Type.DOCUMENT;
- }
+ xmlReader.next();
}
} catch (Exception e){
throw new TransformationException(e, CorePlugin.Util.getString("invalid_string")); //$NON-NLS-1$
Modified: trunk/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/common-core/src/main/java/org/teiid/core/util/ObjectConverterUtil.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -109,8 +109,11 @@
writen += l_nbytes;
}
} finally {
- is.close();
- out.close();
+ try {
+ is.close();
+ } finally {
+ out.close();
+ }
}
}
@@ -128,8 +131,11 @@
writen += l_nbytes;
}
} finally {
- is.close();
- out.close();
+ try {
+ is.close();
+ } finally {
+ out.close();
+ }
}
}
Modified: trunk/common-core/src/main/java/org/teiid/core/util/ReaderInputStream.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/ReaderInputStream.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/common-core/src/main/java/org/teiid/core/util/ReaderInputStream.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -32,12 +32,11 @@
import java.nio.CharBuffer;
import java.nio.charset.Charset;
-import org.teiid.core.types.Streamable;
+import org.teiid.core.types.DataTypeManager;
-
public class ReaderInputStream extends InputStream {
- private static final int DEFAULT_BUFFER_SIZE = Streamable.STREAMING_BATCH_SIZE_IN_BYTES;
+ private static final int DEFAULT_BUFFER_SIZE = DataTypeManager.MAX_LOB_MEMORY_BYTES;
private final Reader reader;
private final Charset charSet;
Modified: trunk/common-core/src/main/resources/org/teiid/core/i18n.properties
===================================================================
--- trunk/common-core/src/main/resources/org/teiid/core/i18n.properties 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/common-core/src/main/resources/org/teiid/core/i18n.properties 2010-06-15 16:49:28 UTC (rev 2233)
@@ -314,7 +314,7 @@
lob.invaliddata=Invalid type of data has been retrieved from server.
remote_lob_access=Lob object accessed is from a remote connector; Can not stream data from remote objects;
failed_convert=Failed to convert {0} into {1}
-invalid_string=Not valid String to transform to XML
+invalid_string=Value is not valid XML
ClobImpl.Failed_copy_clob=Failed creating a new clob from the given clob: {0}.
ClobImpl.Invalid_substring_position=The substring position "{0}" is not valid.
Modified: trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/common-core/src/test/java/org/teiid/core/types/TestDataTypeManager.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -26,22 +26,16 @@
import java.sql.Types;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.Set;
import javax.sql.rowset.serial.SerialBlob;
import org.junit.Test;
-import org.teiid.core.types.BlobType;
-import org.teiid.core.types.DataTypeManager;
-import org.teiid.core.types.JDBCSQLTypeInfo;
-import org.teiid.core.types.Transform;
-import org.teiid.core.types.TransformationException;
public class TestDataTypeManager {
- private void helpDetermineDataType(Object value, Class expectedClass) {
- Class actualClass = DataTypeManager.determineDataTypeClass(value);
+ private void helpDetermineDataType(Object value, Class<?> expectedClass) {
+ Class<?> actualClass = DataTypeManager.determineDataTypeClass(value);
assertNotNull("Should never receive null when determining data type of object: " + value); //$NON-NLS-1$
assertEquals("Mismatch in expected and actual MetaMatrix type class for [" + value + "]: ", expectedClass, actualClass); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -81,19 +75,17 @@
/*timestamp*/ { 'I','N','N','N','N','N','N','N','N','N','N','C','C','O','I','N','N','N' },
/*object*/ { 'C','C','C','C','C','C','C','C','C','C','C','C','C','C','O','C','C','C' },
/*blob*/ { 'N','N','N','N','N','N','N','N','N','N','N','N','N','N','I','O','N','N' },
- /*clob*/ { 'C','N','N','N','N','N','N','N','N','N','N','N','N','N','I','N','O','C' },
- /*xml*/ { 'C','N','N','N','N','N','N','N','N','N','N','N','N','N','I','N','C','O' }
+ /*clob*/ { 'C','N','N','N','N','N','N','N','N','N','N','N','N','N','I','N','O','N' },
+ /*xml*/ { 'C','N','N','N','N','N','N','N','N','N','N','N','N','N','I','N','N','O' }
};
// ################################## ACTUAL TESTS ################################
@Test public void testTypeMappings() {
- Set dataTypeNames = DataTypeManager.getAllDataTypeNames();
- Iterator iter = dataTypeNames.iterator();
- while(iter.hasNext()) {
- String dataTypeName = (String) iter.next();
- Class dataTypeClass = DataTypeManager.getDataTypeClass(dataTypeName);
+ Set<String> dataTypeNames = DataTypeManager.getAllDataTypeNames();
+ for (String dataTypeName : dataTypeNames) {
+ Class<?> dataTypeClass = DataTypeManager.getDataTypeClass(dataTypeName);
assertNotNull("Data type class was null for type " + dataTypeName, dataTypeClass); //$NON-NLS-1$
String dataTypeName2 = DataTypeManager.getDataTypeName(dataTypeClass);
assertEquals("Name to class to name not equals: ", dataTypeName, dataTypeName2); //$NON-NLS-1$
@@ -141,15 +133,9 @@
}
@Test public void testCheckAllConversions() {
- Set allTypes = DataTypeManager.getAllDataTypeNames();
- Iterator srcIter = allTypes.iterator();
- while(srcIter.hasNext()) {
- String src = (String) srcIter.next();
-
- Iterator tgtIter = allTypes.iterator();
- while(tgtIter.hasNext()) {
- String tgt = (String) tgtIter.next();
-
+ Set<String> allTypes = DataTypeManager.getAllDataTypeNames();
+ for (String src : allTypes) {
+ for (String tgt : allTypes) {
boolean isImplicit = DataTypeManager.isImplicitConversion(src, tgt);
boolean isExplicit = DataTypeManager.isExplicitConversion(src, tgt);
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2010-06-15 16:49:28 UTC (rev 2233)
@@ -275,7 +275,9 @@
<entry>string</entry>
<entry>clob</entry>
<entry>char, boolean, byte, short, integer, long,
- biginteger, float, double, bigdecimal, xml</entry>
+ biginteger, float, double, bigdecimal, xml<footnote>
+ <para>See also <link linkend="xmlparse">XMLPARSE</link></para>
+ </footnote></entry>
</row>
<row>
<entry>char</entry>
@@ -342,12 +344,14 @@
<row>
<entry>clob</entry>
<entry></entry>
- <entry>string, xml</entry>
+ <entry>string</entry>
</row>
<row>
<entry>xml</entry>
<entry></entry>
- <entry>string, clob</entry>
+ <entry>string<footnote>
+ <para>See also <link linkend="xmlserialize">XMLSERIALIZE</link></para>
+ </footnote></entry>
</row>
</tbody>
</tgroup>
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-15 16:25:38 UTC (rev 2232)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2010-06-15 16:49:28 UTC (rev 2233)
@@ -2066,12 +2066,12 @@
</entry>
</row>
<row>
- <entry>
+ <entry id="xmlserialize">
<para><code>XMLSERIALIZE((DOCUMENT|CONTENT) exp [AS datatype])</code></para>
</entry>
<entry>
- <para>Returns a character type representation of the exp.
- Only a character type (string, varchar, clob) may be specified as the datatype.
+ <para>Returns a character type representation of the exp expression.
+ Only a character type (string, clob) may be specified as the datatype.
If DOCUMENT is specified and the xml is not a valid document or fragment, then an exception is raised.
</para>
</entry>
@@ -2080,6 +2080,22 @@
</para>
</entry>
</row>
+ <row>
+ <entry id="xmlparse">
+ <para><code>XMLPARSE((DOCUMENT|CONTENT) exp [WELLFORMED])</code></para>
+ </entry>
+ <entry>
+ <para>Returns an XML type representation of the exp expression. If DOCIMENT is specfied then the expression must have a single
+ root element and may or may not contain an XML declaration.</para>
+ <para>
+ If WELLFORMED is specified then validation is skipped; this is especially useful for CLOB and BLOB known to already be valid.
+ </para>
+ </entry>
+ <entry>
+ <para>Exp in {string, clob, blob}. Return value is xml.
+ </para>
+ </entry>
+ </row>
</tbody>
</tgroup>
</informaltable>
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/FileStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/FileStore.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/FileStore.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -27,14 +27,12 @@
import java.io.OutputStream;
import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
-import java.util.Arrays;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;
import org.teiid.core.TeiidComponentException;
-
public abstract class FileStore {
private static ReferenceQueue<Object> QUEUE = new ReferenceQueue<Object>();
@@ -94,14 +92,18 @@
}
}
+ public byte[] getBuffer() {
+ return buffer;
+ }
+
+ public int getCount() {
+ return count;
+ }
+
public boolean bytesWritten() {
return bytesWritten;
}
- public byte toByteArray()[] {
- return Arrays.copyOf(buffer, count);
- }
-
@Override
public void close() throws IOException {
if (bytesWritten) {
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -58,7 +58,6 @@
import org.teiid.core.types.SQLXMLImpl;
import org.teiid.core.types.SourceTransform;
import org.teiid.core.types.StandardXMLTranslator;
-import org.teiid.core.types.Streamable;
import org.teiid.core.types.XMLType;
import org.teiid.core.util.Assertion;
import org.teiid.logging.LogConstants;
@@ -376,7 +375,7 @@
StandardXMLTranslator sxt = new StandardXMLTranslator(value);
SQLXMLImpl sqlxml;
try {
- sqlxml = XMLUtil.saveToBufferManager(BufferManagerImpl.this, sxt, Streamable.STREAMING_BATCH_SIZE_IN_BYTES);
+ sqlxml = XMLUtil.saveToBufferManager(BufferManagerImpl.this, sxt);
} catch (TeiidComponentException e) {
throw new TeiidRuntimeException(e);
} catch (TeiidProcessingException e) {
@@ -385,7 +384,6 @@
return new XMLType(sqlxml);
}
});
- XMLUtil.setBufferManager(this);
}
@Override
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/ByteLobChunkStream.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/ByteLobChunkStream.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/ByteLobChunkStream.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -35,7 +35,7 @@
* A wrapper class, given a InputStream object can convert a underlying
* stream into sequence of ByteLobChunk objects of given chunk size.
*/
-public class ByteLobChunkStream implements LobChunkProducer {
+public class ByteLobChunkStream implements LobChunkProducer {
private PushbackInputStream stream;
private int chunkSize;
private boolean closed;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -121,7 +121,7 @@
try {
if (streamable instanceof XMLType) {
XMLType xml = (XMLType)streamable;
- return new ByteLobChunkStream(new ReaderInputStream(xml.getCharacterStream(), Charset.forName(Streamable.ENCODING)), chunkSize);
+ return new ByteLobChunkStream(xml.getBinaryStream(), chunkSize);
}
else if (streamable instanceof ClobType) {
ClobType clob = (ClobType)streamable;
Modified: trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -86,6 +86,34 @@
*/
public class TransformationMetadata extends BasicQueryMetadata implements Serializable {
+ private final class VirtualFileInputStreamFactory extends
+ InputStreamFactory {
+ private final VirtualFile f;
+
+ private VirtualFileInputStreamFactory(VirtualFile f) {
+ this.f = f;
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ return f.openStream();
+ }
+
+ @Override
+ public long getLength() {
+ try {
+ return f.getSize();
+ } catch (IOException e) {
+ }
+ return super.getLength();
+ }
+
+ @Override
+ public void free() throws IOException {
+ f.close();
+ }
+ }
+
public static class Resource {
public Resource(VirtualFile file, boolean visible) {
this.file = file;
@@ -901,13 +929,7 @@
if (f == null) {
return null;
}
- return new ClobImpl(new InputStreamFactory() {
-
- @Override
- public InputStream getInputStream() throws IOException {
- return f.openStream();
- }
- }, -1);
+ return new ClobImpl(new VirtualFileInputStreamFactory(f), -1);
}
public SQLXMLImpl getVDBResourceAsSQLXML(String resourcePath) {
@@ -915,13 +937,7 @@
if (f == null) {
return null;
}
- return new SQLXMLImpl(new InputStreamFactory() {
-
- @Override
- public InputStream getInputStream() throws IOException {
- return f.openStream();
- }
- });
+ return new SQLXMLImpl(new VirtualFileInputStreamFactory(f));
}
public BlobImpl getVDBResourceAsBlob(String resourcePath) {
@@ -929,18 +945,7 @@
if (f == null) {
return null;
}
- InputStreamFactory isf = new InputStreamFactory() {
-
- @Override
- public InputStream getInputStream() throws IOException {
- return f.openStream();
- }
- };
- try {
- isf.setLength(f.getSize());
- } catch (IOException e) {
- }
- return new BlobImpl(isf);
+ return new BlobImpl(new VirtualFileInputStreamFactory(f));
}
private VirtualFile getFile(String resourcePath) {
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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -22,11 +22,19 @@
package org.teiid.query.eval;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringReader;
+import java.nio.charset.Charset;
+import java.sql.Blob;
+import java.sql.Clob;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -44,13 +52,18 @@
import org.teiid.core.ComponentNotFoundException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.BaseLob;
+import org.teiid.core.types.ClobImpl;
+import org.teiid.core.types.ClobType;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.InputStreamFactory;
+import org.teiid.core.types.SQLXMLImpl;
import org.teiid.core.types.Sequencable;
+import org.teiid.core.types.Streamable;
import org.teiid.core.types.TransformationException;
import org.teiid.core.types.XMLType;
import org.teiid.core.types.XMLType.Type;
import org.teiid.core.types.basic.StringToSQLXMLTransform;
-import org.teiid.core.util.Assertion;
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.query.QueryPlugin;
import org.teiid.query.function.FunctionDescriptor;
@@ -90,6 +103,7 @@
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.XMLParse;
import org.teiid.query.sql.symbol.XMLQuery;
import org.teiid.query.sql.symbol.XMLSerialize;
import org.teiid.query.sql.symbol.XMLNamespaces.NamespaceItem;
@@ -103,7 +117,51 @@
public class Evaluator {
- public static class NameValuePair<T> {
+ private final class SequenceReader extends Reader {
+ private LinkedList<Reader> readers;
+ private Reader current = null;
+
+ public SequenceReader(LinkedList<Reader> readers) {
+ this.readers = readers;
+ }
+
+ @Override
+ public void close() throws IOException {
+ for (Reader reader : readers) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+
+ }
+ }
+ }
+
+ @Override
+ public int read(char[] cbuf, int off, int len)
+ throws IOException {
+ if (current == null && !readers.isEmpty()) {
+ current = readers.removeFirst();
+ }
+ if (current == null) {
+ return -1;
+ }
+ int read = current.read(cbuf, off, len);
+ if (read == -1) {
+ current.close();
+ current = null;
+ read = 0;
+ }
+ if (read < len) {
+ int nextRead = read(cbuf, off + read, len - read);
+ if (nextRead > 0) {
+ read += nextRead;
+ }
+ }
+ return read;
+ }
+ }
+
+ public static class NameValuePair<T> {
public String name;
public T value;
@@ -140,13 +198,13 @@
this.dataMgr = dataMgr;
}
- public boolean evaluate(Criteria criteria, List tuple)
+ public boolean evaluate(Criteria criteria, List<?> tuple)
throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
return Boolean.TRUE.equals(evaluateTVL(criteria, tuple));
}
- public Boolean evaluateTVL(Criteria criteria, List tuple)
+ public Boolean evaluateTVL(Criteria criteria, List<?> tuple)
throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
if(criteria instanceof CompoundCriteria) {
@@ -170,7 +228,7 @@
}
}
- public Boolean evaluate(CompoundCriteria criteria, List tuple)
+ public Boolean evaluate(CompoundCriteria criteria, List<?> tuple)
throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
List subCrits = criteria.getCriteria();
@@ -194,7 +252,7 @@
return result;
}
- public Boolean evaluate(NotCriteria criteria, List tuple)
+ public Boolean evaluate(NotCriteria criteria, List<?> tuple)
throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
Criteria subCrit = criteria.getCriteria();
@@ -208,7 +266,7 @@
return Boolean.TRUE;
}
- public Boolean evaluate(CompareCriteria criteria, List tuple)
+ public Boolean evaluate(CompareCriteria criteria, List<?> tuple)
throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
// Evaluate left expression
@@ -265,7 +323,7 @@
return ((Comparable<Object>)leftValue).compareTo(rightValue);
}
- public Boolean evaluate(MatchCriteria criteria, List tuple)
+ public Boolean evaluate(MatchCriteria criteria, List<?> tuple)
throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
boolean result = false;
@@ -330,7 +388,7 @@
}
}
- private Boolean evaluate(AbstractSetCriteria criteria, List tuple)
+ private Boolean evaluate(AbstractSetCriteria criteria, List<?> tuple)
throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
// Evaluate expression
@@ -372,7 +430,7 @@
throw new CriteriaEvaluationException(e, e.getMessage());
}
} else {
- Assertion.failed("unknown set criteria type"); //$NON-NLS-1$
+ throw new AssertionError("unknown set criteria type"); //$NON-NLS-1$
}
while(valueIter.hasNext()) {
Object possibleValue = valueIter.next();
@@ -403,7 +461,7 @@
return Boolean.valueOf(criteria.isNegated());
}
- public boolean evaluate(IsNullCriteria criteria, List tuple)
+ public boolean evaluate(IsNullCriteria criteria, List<?> tuple)
throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
// Evaluate expression
@@ -417,7 +475,7 @@
return (value == null ^ criteria.isNegated());
}
- private Boolean evaluate(SubqueryCompareCriteria criteria, List tuple)
+ private Boolean evaluate(SubqueryCompareCriteria criteria, List<?> tuple)
throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
// Evaluate expression
@@ -528,7 +586,7 @@
return result;
}
- public boolean evaluate(ExistsCriteria criteria, List tuple)
+ public boolean evaluate(ExistsCriteria criteria, List<?> tuple)
throws BlockedException, TeiidComponentException, CriteriaEvaluationException {
ValueIterator valueIter;
@@ -543,7 +601,7 @@
return false;
}
- public Object evaluate(Expression expression, List tuple)
+ public Object evaluate(Expression expression, List<?> tuple)
throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
try {
@@ -553,7 +611,7 @@
}
}
- private Object internalEvaluate(Expression expression, List tuple)
+ private Object internalEvaluate(Expression expression, List<?> tuple)
throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
if(expression instanceof SingleElementSymbol) {
@@ -600,13 +658,88 @@
return evaluateXMLQuery(tuple, (XMLQuery)expression);
} else if (expression instanceof QueryString) {
return evaluateQueryString(tuple, (QueryString)expression);
+ } else if (expression instanceof XMLParse){
+ return evaluateXMLParse(tuple, (XMLParse)expression);
} else {
throw new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0016, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0016, expression.getClass().getName()));
}
}
+ private Object evaluateXMLParse(List<?> tuple, final XMLParse xp) throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
+ Object value = internalEvaluate(xp.getExpression(), tuple);
+ if (value == null) {
+ return null;
+ }
+ XMLType.Type type = Type.DOCUMENT;
+ XMLType result = null;
+ try {
+ if (value instanceof String) {
+ String string = (String)value;
+ result = new XMLType(new SQLXMLImpl(string));
+ if (!xp.isWellFormed()) {
+ Reader r = new StringReader(string);
+ type = validate(xp, r);
+ }
+ } else {
+ InputStreamFactory isf = null;
+ Streamable<?> s = (Streamable<?>)value;
+ if (s.getReference() instanceof BaseLob) {
+ BaseLob baseLob = (BaseLob)s.getReference();
+ isf = baseLob.getStreamFactory();
+ } else {
+ if (s instanceof Clob) {
+ isf = new InputStreamFactory.ClobInputStreamFactory((Clob)s.getReference());
+ } else {
+ isf = new InputStreamFactory.BlobInputStreamFactory((Blob)s.getReference());
+ }
+ }
+ result = new XMLType(new SQLXMLImpl(isf));
+ if (!xp.isWellFormed()) {
+ String encoding = null;
+ Reader r = null;
+ if (s instanceof Clob) {
+ r = isf.getCharacterStream();
+ } else {
+ encoding = XMLType.getEncoding(result); //look for the xml declaration
+ if (encoding == null) {
+ encoding = "UTF-8"; //$NON-NLS-1$
+ }
+ r = new InputStreamReader(isf.getInputStream(), encoding);
+ }
+ type = validate(xp, r);
+ if (encoding != null) {
+ isf.setEncoding(encoding);
+ }
+ }
+ }
+ } catch (TransformationException e) {
+ throw new ExpressionEvaluationException(e, e.getMessage());
+ } catch (IOException e) {
+ throw new ExpressionEvaluationException(e, e.getMessage());
+ } catch (SQLException e) {
+ throw new ExpressionEvaluationException(e, e.getMessage());
+ }
+ if (!xp.isDocument()) {
+ type = Type.CONTENT;
+ }
+ result.setType(type);
+ return result;
+ }
+
+ private Type validate(final XMLParse xp, Reader r)
+ throws TransformationException {
+ if (!xp.isDocument()) {
+ LinkedList<Reader> readers = new LinkedList<Reader>();
+ readers.add(new StringReader("<r>")); //$NON-NLS-1$
+ readers.add(r);
+ readers.add(new StringReader("</r>")); //$NON-NLS-1$
+ r = new SequenceReader(readers);
+ }
+ return StringToSQLXMLTransform.isXml(r);
+ }
+
//TODO: exception if length is too long?
- private Object evaluateQueryString(List tuple, QueryString queryString)
+ private Object evaluateQueryString(List<?> tuple, QueryString queryString)
throws ExpressionEvaluationException, BlockedException,
TeiidComponentException {
Evaluator.NameValuePair<Object>[] pairs = getNameValuePairs(tuple, queryString.getArgs(), false);
@@ -634,7 +767,7 @@
return result.toString();
}
- private Object evaluateXMLQuery(List tuple, XMLQuery xmlQuery)
+ private Object evaluateXMLQuery(List<?> tuple, XMLQuery xmlQuery)
throws BlockedException, TeiidComponentException,
FunctionExecutionException {
boolean emptyOnEmpty = true;
@@ -643,7 +776,7 @@
}
try {
SequenceIterator iter = evaluateXQuery(xmlQuery.getXQueryExpression(), xmlQuery.getPassing(), tuple);
- return xmlQuery.getXQueryExpression().createXMLType(iter, emptyOnEmpty);
+ return xmlQuery.getXQueryExpression().createXMLType(iter, this.context.getBufferManager(), emptyOnEmpty);
} catch (TeiidProcessingException e) {
throw new FunctionExecutionException(e, QueryPlugin.Util.getString("Evaluator.xmlquery", e.getMessage())); //$NON-NLS-1$
} catch (XPathException e) {
@@ -651,7 +784,7 @@
}
}
- private Object evaluateXMLSerialize(List tuple, XMLSerialize xs)
+ private Object evaluateXMLSerialize(List<?> tuple, XMLSerialize xs)
throws ExpressionEvaluationException, BlockedException,
TeiidComponentException, FunctionExecutionException {
XMLType value = (XMLType) internalEvaluate(xs.getExpression(), tuple);
@@ -660,14 +793,14 @@
}
try {
if (!xs.isDocument()) {
- return DataTypeManager.transformValue(value, xs.getType());
+ return serialize(xs, value);
}
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());
+ return serialize(xs, value);
}
} catch (SQLException e) {
throw new FunctionExecutionException(e, e.getMessage());
@@ -677,7 +810,22 @@
throw new FunctionExecutionException(QueryPlugin.Util.getString("Evaluator.xmlserialize")); //$NON-NLS-1$
}
- private Object evaluateXMLForest(List tuple, XMLForest function)
+ private Object serialize(XMLSerialize xs, XMLType value)
+ throws SQLException, TransformationException {
+ if (xs.getType() == DataTypeManager.DefaultDataClasses.STRING) {
+ return DataTypeManager.transformValue(value, xs.getType());
+ }
+ InputStreamFactory isf = null;
+ if (value.getReference() instanceof BaseLob) {
+ BaseLob baseLob = (BaseLob)value.getReference();
+ isf = baseLob.getStreamFactory();
+ } else {
+ isf = new InputStreamFactory.SQLXMLInputStreamFactory(value.getReference());
+ }
+ return new ClobType(new ClobImpl(isf, -1));
+ }
+
+ private Object evaluateXMLForest(List<?> tuple, XMLForest function)
throws ExpressionEvaluationException, BlockedException,
TeiidComponentException, FunctionExecutionException {
List<DerivedColumn> args = function.getArgs();
@@ -690,7 +838,7 @@
}
}
- private Object evaluateXMLElement(List tuple, XMLElement function)
+ private Object evaluateXMLElement(List<?> tuple, XMLElement function)
throws ExpressionEvaluationException, BlockedException,
TeiidComponentException, FunctionExecutionException {
List<Expression> content = function.getContent();
@@ -724,7 +872,7 @@
return xquery.evaluateXQuery(contextItem, parameters);
}
- private Evaluator.NameValuePair<Object>[] getNameValuePairs(List tuple, List<DerivedColumn> args, boolean xmlNames)
+ private Evaluator.NameValuePair<Object>[] getNameValuePairs(List<?> tuple, List<DerivedColumn> args, boolean xmlNames)
throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
Evaluator.NameValuePair<Object>[] nameValuePairs = new Evaluator.NameValuePair[args.size()];
for (int i = 0; i < args.size(); i++) {
@@ -755,7 +903,7 @@
return nameValuePairs;
}
- private Object evaluate(CaseExpression expr, List tuple)
+ private Object evaluate(CaseExpression expr, List<?> tuple)
throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
Object exprVal = internalEvaluate(expr.getExpression(), tuple);
for (int i = 0; i < expr.getWhenCount(); i++) {
@@ -769,7 +917,7 @@
return null;
}
- private Object evaluate(SearchedCaseExpression expr, List tuple)
+ private Object evaluate(SearchedCaseExpression expr, List<?> tuple)
throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
for (int i = 0; i < expr.getWhenCount(); i++) {
try {
@@ -786,7 +934,7 @@
return null;
}
- private Object evaluate(Function function, List tuple)
+ private Object evaluate(Function function, List<?> tuple)
throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
// Get function based on resolved function info
@@ -837,7 +985,7 @@
return result;
}
- private Object evaluate(ScalarSubquery scalarSubquery, List tuple)
+ private Object evaluate(ScalarSubquery scalarSubquery, List<?> tuple)
throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
Object result = null;
@@ -858,7 +1006,7 @@
return result;
}
- protected ValueIterator evaluateSubquery(SubqueryContainer container, List tuple)
+ protected ValueIterator evaluateSubquery(SubqueryContainer container, List<?> tuple)
throws TeiidProcessingException, BlockedException, TeiidComponentException {
throw new UnsupportedOperationException("Subquery evaluation not possible with a base Evaluator"); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -267,6 +267,12 @@
}
result = DataTypeManager.convertToRuntimeType(result);
result = DataTypeManager.transformValue(result, getReturnType());
+ if (result instanceof String) {
+ String s = (String)result;
+ if (s.length() > DataTypeManager.MAX_STRING_LENGTH) {
+ return s.substring(0, DataTypeManager.MAX_STRING_LENGTH);
+ }
+ }
return result;
} catch(InvocationTargetException e) {
throw new FunctionExecutionException(e.getTargetException(), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, getName()));
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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -65,10 +65,10 @@
import org.teiid.api.exception.query.FunctionExecutionException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.ClobImpl;
import org.teiid.core.types.ClobType;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.SQLXMLImpl;
-import org.teiid.core.types.Streamable;
import org.teiid.core.types.TransformationException;
import org.teiid.core.types.XMLTranslator;
import org.teiid.core.types.XMLType;
@@ -113,7 +113,7 @@
final Transformer transformer = factory.newTransformer(styleSource);
//this creates a non-validated sqlxml - it may not be valid xml/root-less xml
- SQLXML result = XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
+ SQLXMLImpl result = XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
@Override
public void translate(Writer writer) throws TransformerException {
@@ -121,8 +121,8 @@
// Feed the resultant I/O stream into the XSLT processor
transformer.transform(xmlParam, new StreamResult(writer));
}
- }, Streamable.STREAMING_BATCH_SIZE_IN_BYTES);
- return DataTypeManager.transformValue(new XMLType(result), DataTypeManager.DefaultDataClasses.CLOB);
+ });
+ return new ClobType(new ClobImpl(result.getStreamFactory(), -1));
} finally {
Util.closeSource(styleSource);
Util.closeSource(xmlSource);
@@ -160,7 +160,7 @@
throw new TransformerException(e);
}
}
- }, context.getStreamingBatchSize()));
+ }));
result.setType(Type.CONTENT);
return result;
}
@@ -191,7 +191,7 @@
}
}
- }, context.getStreamingBatchSize()));
+ }));
result.setType(Type.ELEMENT);
return result;
}
@@ -228,6 +228,27 @@
}
public static XMLType xmlConcat(CommandContext context, final XMLType xml, final Object... other) throws TeiidComponentException, TeiidProcessingException {
+ //determine if there is just a single xml value and return it
+ XMLType singleValue = xml;
+ XMLType.Type type = null;
+ for (Object object : other) {
+ if (object != null) {
+ if (singleValue != null) {
+ type = Type.CONTENT;
+ break;
+ }
+ if (object instanceof XMLType) {
+ singleValue = (XMLType)object;
+ } else {
+ type = Type.CONTENT;
+ break;
+ }
+ }
+ }
+ if (type == null) {
+ return singleValue;
+ }
+
XMLType result = new XMLType(XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
@Override
@@ -245,7 +266,7 @@
throw new TransformerException(e);
}
}
- }, context.getStreamingBatchSize()));
+ }));
result.setType(Type.CONTENT);
return result;
}
@@ -280,11 +301,11 @@
}
}
- static void convertValue(Writer writer, XMLEventWriter eventWriter, XMLEventFactory eventFactory, Object object) throws IOException,
+ static int convertValue(Writer writer, XMLEventWriter eventWriter, XMLEventFactory eventFactory, Object object) throws IOException,
FactoryConfigurationError, XMLStreamException,
TransformerException {
if (object == null) {
- return;
+ return 0;
}
Reader r = null;
try {
@@ -308,6 +329,7 @@
r.close();
}
}
+ return 1;
//TODO: blob - with base64 encoding
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -142,7 +142,7 @@
continue;
}
if (proColumn.getSymbol().getType() == DataTypeManager.DefaultDataClasses.XML) {
- XMLType value = table.getXQueryExpression().createXMLType(pathIter.getAnother(), false);
+ XMLType value = table.getXQueryExpression().createXMLType(pathIter.getAnother(), this.getBufferManager(), false);
tuple.add(value);
continue;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/DocumentInProgress.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/DocumentInProgress.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/DocumentInProgress.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -22,95 +22,326 @@
package org.teiid.query.processor.xml;
+import java.util.Iterator;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.sax.TransformerHandler;
+import javax.xml.transform.stream.StreamResult;
+
+import net.sf.saxon.TransformerFactoryImpl;
+
import org.teiid.common.buffer.FileStore;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.SQLXMLImpl;
+import org.teiid.logging.LogManager;
+import org.teiid.logging.MessageLevel;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.processor.xml.XMLUtil.FileStoreInputStreamFactory;
import org.xml.sax.SAXException;
/**
- * <p>This represents a document in construction. It maintains a reference
- * to the current XML element being worked on, although the nature of that
- * reference is completely hidden from the user. This allows the nastiness
- * of creating the document using some document model to be hidden from the
- * user.</p>
+ * This class is used to build XML document and stream the output as
+ * chunks. The class holds one chunk of the document in memory at one time.
*/
-public interface DocumentInProgress {
+public class DocumentInProgress {
+ private TransformerHandler handler;
+ private Transformer transformer;
+ private Element currentParent;
+ private Element currentObject;
+ private boolean finished;
+ private String documentEncoding = MappingNodeConstants.Defaults.DEFAULT_DOCUMENT_ENCODING;
+ private boolean isFormatted = MappingNodeConstants.Defaults.DEFAULT_FORMATTED_DOCUMENT.booleanValue();
+ private SQLXMLImpl xml;
+
+ public DocumentInProgress(FileStore store, String encoding) throws TeiidComponentException{
+ final FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(store, encoding);
+ this.xml = new SQLXMLImpl(fsisf);
+ SAXTransformerFactory factory = new TransformerFactoryImpl();
+ try {
+ //SAX2.0 ContentHandler
+ handler = factory.newTransformerHandler();
+ handler.setResult(new StreamResult(fsisf.getOuptStream()));
+ } catch (Exception e) {
+ throw new TeiidComponentException(e);
+ }
+ transformer = handler.getTransformer();
+ }
+
+ public SQLXMLImpl getSQLXML() {
+ return xml;
+ }
+
+ /**
+ * @see org.teiid.query.processor.xml.DocumentInProgress#setDocumentEncoding(java.lang.String)
+ */
+ public void setDocumentEncoding(String documentEncoding) {
+ this.documentEncoding = documentEncoding;
+ }
- // Methods for initializing the document
+ /**
+ * @see org.teiid.query.processor.xml.DocumentInProgress#setDocumentFormat(boolean)
+ */
+ public void setDocumentFormat(boolean isFormatted) {
+ this.isFormatted = isFormatted;
+ }
- /**
- * Sets the document encoding property of the XML document,
- * typically something like <code>UTF-8</code>
- * @param document encoding value
- */
- public void setDocumentEncoding(String documentEncoding);
+ /**
+ * Move to the parent of this element. The parent of this element becomes
+ * the current object. Need to process the current and child object before moving
+ * to the parent.
+ * @throws SAXException
+ * @see org.teiid.query.processor.xml.DocumentInProgress#moveToParent()
+ */
+ public boolean moveToParent() throws SAXException {
+ showState( "moveToParent - TOP" ); //$NON-NLS-1$
+
+ endElement(currentObject);
+
+ //move to parent - if parent is null, then stop processing here
+ if(currentParent == null){
+ return false;
+ }
+
+ showState( "moveToParent - before processWorkingElements, second time" ); //$NON-NLS-1$
+ currentObject = currentParent;
+ currentParent = currentParent.getParent();
+ showState( "moveToParent - BOT" ); //$NON-NLS-1$
+ return true;
+ }
+
+ /**
+ * @see org.teiid.query.processor.xml.DocumentInProgress#moveToLastChild()
+ */
+ public boolean moveToLastChild() {
+ showState( "moveToLastChild - TOP" ); //$NON-NLS-1$
+ currentParent = currentObject;
+ currentObject = null;
+ showState( "moveToLastChild - BOT" ); //$NON-NLS-1$
+ return true;
+ }
- /**
- * Sets whether the document will be formatted in human-readable
- * form (multi-line, with tabs) or compact form (no line breaks
- * or tabs).
- * @param isFormatted true for human-readable form, false for
- * compact form
- */
- public void setDocumentFormat(boolean isFormatted);
+ public boolean addElement(NodeDescriptor descriptor, NodeDescriptor nillableDescriptor){
+ return addElement(descriptor, null, nillableDescriptor);
+ }
+
+ public boolean addElement(NodeDescriptor descriptor, String content){
+ return addElement(descriptor, content, null);
+ }
+
+ private boolean addElement(NodeDescriptor descriptor, String content, NodeDescriptor nillableDescriptor){
+ showState( "addElement(2) - TOP" ); //$NON-NLS-1$
+
+ try{
+ if(currentParent == null){
+ //this is the root element, start document first
+ showState( "addElement(2) - before StartDocument()" ); //$NON-NLS-1$
- // Methods for moving the cursor
+ startDocument();
+ }
+ Element element = makeElement(descriptor);
+ if (element != null){
+ if (content != null) {
+ element.setContent(normalizeText(content, descriptor.getTextNormalizationMode()));
+ //mark the element and its parents to be mandatory
+ markAsNonOptional(element);
+ } else {
+ element.setNillableDescriptor(nillableDescriptor);
+ }
+
+ showState( "addElement(2) - before markAsNonOptional()" ); //$NON-NLS-1$
+
+ endElement(currentObject);
+ currentObject = element;
+ return true;
+ }
+ } catch (SAXException e) {
+ LogManager.logError(org.teiid.logging.LogConstants.CTX_XML_PLAN, e, e.getMessage());
+ return false;
+ }
+ showState( "addElement(2) - BOT" ); //$NON-NLS-1$
+ return false;
+ }
- public boolean moveToParent() throws SAXException;
-
- public boolean moveToLastChild();
-
- // Methods for adding data
-
- /**
- * Add an element for the given NodeDescriptor.
- * @param descriptor NodeDescriptor of the element
- * @return whether operation was a success or not
- */
- boolean addElement(NodeDescriptor descriptor, NodeDescriptor nillableDescriptor);
+ private void endElement(Element element) throws SAXException {
+ showState( "endElement(2) - TOP" ); //$NON-NLS-1$
+
+ if (element == null) {
+ return;
+ }
+
+ if (element.isOptional()) {
+ if (element.getParent() != null) {
+ element.getParent().getChildren().remove(element);
+ }
+ return;
+ }
+
+ NodeDescriptor nillableDescriptor = element.getNillableDescriptor();
+
+ if (nillableDescriptor != null) {
+ addAttribute(nillableDescriptor, nillableDescriptor.getDefaultValue(), element);
+ }
+
+ // Optional parents are in control of when their children are emitted.
+ if (element.hadOptionalParent()) {
+ return;
+ }
+
+ startElement(element);
+ processChildren(element);
+ element.endElement();
+
+ if (element.getParent() != null) {
+ element.getParent().getChildren().remove(element);
+ }
+ showState( "endElement(2) - BOT" ); //$NON-NLS-1$
+ }
+
+ private void startElement(Element element) throws SAXException {
+ Element parent = element.getParent();
+ while (parent != null && !parent.isElementStarted()) {
+ parent.setNillableDescriptor(null);
+ startElement(parent);
+ }
+ element.startElement();
+ }
+
+ private void processChildren(Element element) throws SAXException {
+
+ for (Iterator i = element.getChildren().iterator(); i.hasNext();) {
+ Element child = (Element)i.next();
+ i.remove();
+
+ child.startElement();
+ processChildren(child);
+ child.endElement();
+ }
+ }
- /**
- * Add an element with content for the given NodeDescriptor.
- * If the content is either a null or an empty String, use the other
- * {@link #addElement(NodeDescriptor) addElement}
- * method.
- * @param descriptor NodeDescriptor of the element
- * @param content Content of the element
- * @return whether operation was a success or not
- */
- public boolean addElement(NodeDescriptor descriptor, String content);
+ private void markAsNonOptional(Element element) {
- /**
- * Add an attribute with content for the given NodeDescriptor.
- * @param descriptor NodeDescriptor of the attribute
- * @param attributeValue String content of the attribute, this must be a
- * non-null, non-empty String. Otherwise, no attribute will be added.
- * @return whether operation was a success or not
- */
- public boolean addAttribute(NodeDescriptor descriptor, String attributeValue);
+ while(element != null){
+ element.setOptional(false);
+ element = element.getParent();
+ }
+ }
+
+ public boolean addAttribute(NodeDescriptor descriptor, String attributeValue, Element element){
+ element.setAttribute(descriptor, normalizeText(attributeValue,descriptor.getTextNormalizationMode()));
+
+ if (!descriptor.isOptional()){
+ //mark the element and its parents to be mandatory
+ markAsNonOptional(element);
+ }
+ return true;
+ }
/**
- * Adds a comment to the current document node
- * @param commentText text of the comment
- * @return whether operation was a success or not
+ * @see org.teiid.query.processor.xml.DocumentInProgress#addAttribute(java.lang.String, java.lang.String, java.lang.String, boolean)
*/
- public boolean addComment(String commentText);
+ public boolean addAttribute(NodeDescriptor descriptor, String attributeValue){
+ return addAttribute(descriptor, attributeValue, currentParent);
+ }
+ /**
+ * @throws TeiidComponentException
+ * @see org.teiid.query.processor.xml.DocumentInProgress#addComment(java.lang.String)
+ */
+ public boolean addComment(String commentText) {
+ currentParent.setComment(commentText);
+ return true;
+ }
- /**
- * This flag indicates the document is finished and requires no more processing.
- * @see #markAsFinished
+ /**
+ * @see org.teiid.query.processor.xml.DocumentInProgress#isFinished()
+ */
+ public boolean isFinished() {
+ return finished;
+ }
+
+ /**
+ * @see org.teiid.query.processor.xml.DocumentInProgress#markAsFinished()
+ */
+ public void markAsFinished() throws TeiidComponentException{
+ try {
+ endDocument();
+ } catch (SAXException e) {
+ throw new TeiidComponentException(e);
+ }
+ finished = true;
+ }
+
+ private Element makeElement(NodeDescriptor descripter) {
+ showState( "makeElement - TOP" ); //$NON-NLS-1$
+ Element element = new Element(descripter, handler);
+ element.setParent(currentParent);
+ if (currentParent != null) {
+ currentParent.addChild(element);
+ }
+ showState( "makeElement - BOT" ); //$NON-NLS-1$
+ return element;
+ }
+
+ private void startDocument() throws SAXException{
+ showState( "startDocument - TOP" ); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.ENCODING, documentEncoding);
+ if(isFormatted){
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");//$NON-NLS-1$
+ }
+ handler.startDocument();
+ showState( "startDocument - BOT" ); //$NON-NLS-1$
+ }
+
+ private void endDocument() throws SAXException{
+ //special case: only one root element
+ endElement(currentObject);
+ handler.endDocument();
+ }
+
+ /**
+ * @param content
+ * @param textNormalizationMode
+ * preserve No normalization is done, the value is not changed for element content
+ * replace All occurrences of #x9 (tab), #xA (line feed) and #xD (carriage return) are replaced with #x20 (space)
+ * collapse After the processing implied by replace, contiguous sequences of #x20's are collapsed to a single #x20, and leading and trailing #x20's are removed.
+ *
+ * @return
+ * @since 4.3
+
*/
- public boolean isFinished();
+ public static String normalizeText(String content, String textNormalizationMode) {
+ String result = content;
+ String singleSpace = " "; //$NON-NLS-1$
+ if(textNormalizationMode.equalsIgnoreCase(MappingNodeConstants.NORMALIZE_TEXT_REPLACE)) {
+ result = result.replaceAll("\\s", singleSpace); //$NON-NLS-1$
+ }else if(textNormalizationMode.equalsIgnoreCase(MappingNodeConstants.NORMALIZE_TEXT_COLLAPSE)){
+ result = result.replaceAll("\\s+", singleSpace); //$NON-NLS-1$
+ result = result.trim();
+ }
+ return result;
+ }
+
- /**
- * This marks the document as finished, requiring no more processing. (It will not,
- * however, prevent any more processing from being done.)
- * @throws TeiidComponentException if there is any problem ending the document
- * @see #isFinished
- */
- public void markAsFinished() throws TeiidComponentException;
+ private void showState( String sOccasion ) {
+
+ if (LogManager.isMessageToBeRecorded(org.teiid.logging.LogConstants.CTX_XML_PLAN, MessageLevel.TRACE)) {
+ LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"\n [showState] State Vars at: " + sOccasion} ); //$NON-NLS-1$
+ LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent: " + currentParent} ); //$NON-NLS-1$
+ LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentObject: " + currentObject} ); //$NON-NLS-1$
+
+ if ( currentObject != null ) {
+ LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentObject.getNillableDescriptor(): " + currentObject.getNillableDescriptor()}); //$NON-NLS-1$
+ LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] workingElements: " + currentObject.getChildren()}); //$NON-NLS-1$
+ }
+ if ( currentParent != null ) {
+ LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent.getParent(): " + currentParent.getParent()}); //$NON-NLS-1$
+ } else {
+ LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent.getParent(): is NULL "}); //$NON-NLS-1$
+ }
+ }
+ }
- public FileStore getFileStore();
-
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/InitializeDocumentInstruction.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/InitializeDocumentInstruction.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/InitializeDocumentInstruction.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -84,12 +84,10 @@
// program stack (don't want to start a new doc in the middle of
// recursive processing)
if (!env.isRecursiveProgramInStack()) {
- DocumentInProgress doc = new SAXDocumentInProgress(env.getBufferManager().createFileStore("xml")); //$NON-NLS-1$
+ DocumentInProgress doc = new DocumentInProgress(env.getBufferManager().createFileStore("xml"), encoding); //$NON-NLS-1$
//DocumentInProgress doc = new JDOMDocumentInProgress();
env.setDocumentInProgress(doc);
- doc.setDocumentEncoding(encoding);
-
// Override the xml format flag from the model with
// the format specified with the user's query request, if any.
boolean formatted = this.isFormatted;
Deleted: trunk/engine/src/main/java/org/teiid/query/processor/xml/SAXDocumentInProgress.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/SAXDocumentInProgress.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/SAXDocumentInProgress.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -1,348 +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.query.processor.xml;
-
-import java.io.BufferedOutputStream;
-import java.util.Iterator;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-
-import net.sf.saxon.TransformerFactoryImpl;
-
-import org.teiid.common.buffer.FileStore;
-import org.teiid.core.TeiidComponentException;
-import org.teiid.logging.LogManager;
-import org.teiid.logging.MessageLevel;
-import org.teiid.query.mapping.xml.MappingNodeConstants;
-import org.xml.sax.SAXException;
-
-
-/**
- * This class is used to build XML document and stream the output as
- * chunks. The class holds one chunk of the document in memory at one time.
- */
-public class SAXDocumentInProgress implements DocumentInProgress {
- private TransformerHandler handler;
- private Transformer transformer;
- private Element currentParent;
- private Element currentObject;
- private boolean finished;
- private String documentEncoding = MappingNodeConstants.Defaults.DEFAULT_DOCUMENT_ENCODING;
- private boolean isFormatted = MappingNodeConstants.Defaults.DEFAULT_FORMATTED_DOCUMENT.booleanValue();
- private FileStore store;
-
- public SAXDocumentInProgress(FileStore store) throws TeiidComponentException{
- this.store = store;
- SAXTransformerFactory factory = new TransformerFactoryImpl();
- //TODO use standard jaxp to create factory
- //SAXTransformerFactory factory = (SAXTransformerFactory)TransformerFactory.newInstance();
- try {
- //SAX2.0 ContentHandler
- handler = factory.newTransformerHandler();
- handler.setResult(new StreamResult(new BufferedOutputStream(store.createOutputStream())));
- } catch (Exception e) {
- throw new TeiidComponentException(e);
- }
- transformer = handler.getTransformer();
- }
-
- /**
- * @see org.teiid.query.processor.xml.DocumentInProgress#setDocumentEncoding(java.lang.String)
- */
- public void setDocumentEncoding(String documentEncoding) {
- this.documentEncoding = documentEncoding;
- }
-
- /**
- * @see org.teiid.query.processor.xml.DocumentInProgress#setDocumentFormat(boolean)
- */
- public void setDocumentFormat(boolean isFormatted) {
- this.isFormatted = isFormatted;
- }
-
- /**
- * Move to the parent of this element. The parent of this element becomes
- * the current object. Need to process the current and child object before moving
- * to the parent.
- * @throws SAXException
- * @see org.teiid.query.processor.xml.DocumentInProgress#moveToParent()
- */
- public boolean moveToParent() throws SAXException {
- showState( "moveToParent - TOP" ); //$NON-NLS-1$
-
- endElement(currentObject);
-
- //move to parent - if parent is null, then stop processing here
- if(currentParent == null){
- return false;
- }
-
- showState( "moveToParent - before processWorkingElements, second time" ); //$NON-NLS-1$
- currentObject = currentParent;
- currentParent = currentParent.getParent();
- showState( "moveToParent - BOT" ); //$NON-NLS-1$
- return true;
- }
-
- /**
- * @see org.teiid.query.processor.xml.DocumentInProgress#moveToLastChild()
- */
- public boolean moveToLastChild() {
- showState( "moveToLastChild - TOP" ); //$NON-NLS-1$
- currentParent = currentObject;
- currentObject = null;
- showState( "moveToLastChild - BOT" ); //$NON-NLS-1$
- return true;
- }
-
- public boolean addElement(NodeDescriptor descriptor, NodeDescriptor nillableDescriptor){
- return addElement(descriptor, null, nillableDescriptor);
- }
-
- public boolean addElement(NodeDescriptor descriptor, String content){
- return addElement(descriptor, content, null);
- }
-
- private boolean addElement(NodeDescriptor descriptor, String content, NodeDescriptor nillableDescriptor){
- showState( "addElement(2) - TOP" ); //$NON-NLS-1$
-
- try{
- if(currentParent == null){
- //this is the root element, start document first
- showState( "addElement(2) - before StartDocument()" ); //$NON-NLS-1$
-
- startDocument();
- }
- Element element = makeElement(descriptor);
- if (element != null){
- if (content != null) {
- element.setContent(normalizeText(content, descriptor.getTextNormalizationMode()));
- //mark the element and its parents to be mandatory
- markAsNonOptional(element);
- } else {
- element.setNillableDescriptor(nillableDescriptor);
- }
-
- showState( "addElement(2) - before markAsNonOptional()" ); //$NON-NLS-1$
-
- endElement(currentObject);
- currentObject = element;
- return true;
- }
- } catch (SAXException e) {
- LogManager.logError(org.teiid.logging.LogConstants.CTX_XML_PLAN, e, e.getMessage());
- return false;
- }
- showState( "addElement(2) - BOT" ); //$NON-NLS-1$
- return false;
- }
-
- private void endElement(Element element) throws SAXException {
- showState( "endElement(2) - TOP" ); //$NON-NLS-1$
-
- if (element == null) {
- return;
- }
-
- if (element.isOptional()) {
- if (element.getParent() != null) {
- element.getParent().getChildren().remove(element);
- }
- return;
- }
-
- NodeDescriptor nillableDescriptor = element.getNillableDescriptor();
-
- if (nillableDescriptor != null) {
- addAttribute(nillableDescriptor, nillableDescriptor.getDefaultValue(), element);
- }
-
- // Optional parents are in control of when their children are emitted.
- if (element.hadOptionalParent()) {
- return;
- }
-
- startElement(element);
- processChildren(element);
- element.endElement();
-
- if (element.getParent() != null) {
- element.getParent().getChildren().remove(element);
- }
- showState( "endElement(2) - BOT" ); //$NON-NLS-1$
- }
-
- private void startElement(Element element) throws SAXException {
- Element parent = element.getParent();
- while (parent != null && !parent.isElementStarted()) {
- parent.setNillableDescriptor(null);
- startElement(parent);
- }
- element.startElement();
- }
-
- private void processChildren(Element element) throws SAXException {
-
- for (Iterator i = element.getChildren().iterator(); i.hasNext();) {
- Element child = (Element)i.next();
- i.remove();
-
- child.startElement();
- processChildren(child);
- child.endElement();
- }
- }
-
- private void markAsNonOptional(Element element) {
-
- while(element != null){
- element.setOptional(false);
- element = element.getParent();
- }
- }
-
- public boolean addAttribute(NodeDescriptor descriptor, String attributeValue, Element element){
- element.setAttribute(descriptor, normalizeText(attributeValue,descriptor.getTextNormalizationMode()));
-
- if (!descriptor.isOptional()){
- //mark the element and its parents to be mandatory
- markAsNonOptional(element);
- }
- return true;
- }
-
- /**
- * @see org.teiid.query.processor.xml.DocumentInProgress#addAttribute(java.lang.String, java.lang.String, java.lang.String, boolean)
- */
- public boolean addAttribute(NodeDescriptor descriptor, String attributeValue){
- return addAttribute(descriptor, attributeValue, currentParent);
- }
-
- /**
- * @throws TeiidComponentException
- * @see org.teiid.query.processor.xml.DocumentInProgress#addComment(java.lang.String)
- */
- public boolean addComment(String commentText) {
- currentParent.setComment(commentText);
- return true;
- }
-
- /**
- * @see org.teiid.query.processor.xml.DocumentInProgress#isFinished()
- */
- public boolean isFinished() {
- return finished;
- }
-
- /**
- * @see org.teiid.query.processor.xml.DocumentInProgress#markAsFinished()
- */
- public void markAsFinished() throws TeiidComponentException{
- try {
- endDocument();
- } catch (SAXException e) {
- throw new TeiidComponentException(e);
- }
- finished = true;
- }
-
- private Element makeElement(NodeDescriptor descripter) {
- showState( "makeElement - TOP" ); //$NON-NLS-1$
- Element element = new Element(descripter, handler);
- element.setParent(currentParent);
- if (currentParent != null) {
- currentParent.addChild(element);
- }
- showState( "makeElement - BOT" ); //$NON-NLS-1$
- return element;
- }
-
- private void startDocument() throws SAXException{
- showState( "startDocument - TOP" ); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.ENCODING, documentEncoding);
- if(isFormatted){
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");//$NON-NLS-1$
- }
- handler.startDocument();
- showState( "startDocument - BOT" ); //$NON-NLS-1$
- }
-
- private void endDocument() throws SAXException{
- //special case: only one root element
- endElement(currentObject);
- handler.endDocument();
- }
-
- /**
- * @param content
- * @param textNormalizationMode
- * preserve No normalization is done, the value is not changed for element content
- * replace All occurrences of #x9 (tab), #xA (line feed) and #xD (carriage return) are replaced with #x20 (space)
- * collapse After the processing implied by replace, contiguous sequences of #x20's are collapsed to a single #x20, and leading and trailing #x20's are removed.
- *
- * @return
- * @since 4.3
-
- */
- public static String normalizeText(String content, String textNormalizationMode) {
- String result = content;
- String singleSpace = " "; //$NON-NLS-1$
- if(textNormalizationMode.equalsIgnoreCase(MappingNodeConstants.NORMALIZE_TEXT_REPLACE)) {
- result = result.replaceAll("\\s", singleSpace); //$NON-NLS-1$
- }else if(textNormalizationMode.equalsIgnoreCase(MappingNodeConstants.NORMALIZE_TEXT_COLLAPSE)){
- result = result.replaceAll("\\s+", singleSpace); //$NON-NLS-1$
- result = result.trim();
- }
- return result;
- }
-
-
- private void showState( String sOccasion ) {
-
- if (LogManager.isMessageToBeRecorded(org.teiid.logging.LogConstants.CTX_XML_PLAN, MessageLevel.TRACE)) {
- LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"\n [showState] State Vars at: " + sOccasion} ); //$NON-NLS-1$
- LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent: " + currentParent} ); //$NON-NLS-1$
- LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentObject: " + currentObject} ); //$NON-NLS-1$
-
- if ( currentObject != null ) {
- LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentObject.getNillableDescriptor(): " + currentObject.getNillableDescriptor()}); //$NON-NLS-1$
- LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] workingElements: " + currentObject.getChildren()}); //$NON-NLS-1$
- }
- if ( currentParent != null ) {
- LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent.getParent(): " + currentParent.getParent()}); //$NON-NLS-1$
- } else {
- LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"[showState] currentParent.getParent(): is NULL "}); //$NON-NLS-1$
- }
- }
- }
-
- @Override
- public FileStore getFileStore() {
- return this.store;
- }
-
-}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -162,7 +162,7 @@
DocumentInProgress doc = env.getDocumentInProgress();
if (doc != null && doc.isFinished()) {
this.env.setDocumentInProgress(null);
- XMLType xml = new XMLType(XMLUtil.createSQLXML(doc.getFileStore()));
+ XMLType xml = new XMLType(doc.getSQLXML());
// check to see if we need to do any post validation on the document.
if (getContext().validateXML()){
Reader reader;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLUtil.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLUtil.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -23,9 +23,12 @@
package org.teiid.query.processor.xml;
import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
import java.io.Writer;
import javax.xml.transform.TransformerException;
@@ -33,50 +36,77 @@
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.FileStore;
import org.teiid.common.buffer.FileStore.FileStoreOutputStream;
-import org.teiid.common.buffer.impl.BufferManagerImpl;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.InputStreamFactory;
import org.teiid.core.types.SQLXMLImpl;
import org.teiid.core.types.Streamable;
import org.teiid.core.types.XMLTranslator;
-
-
/**
* Utility methods to be used with the XML and XQuery processing.
*/
public class XMLUtil {
- //horrible hack
- private static BufferManager bufferManager;
-
- public static void setBufferManager(BufferManager bufferManager) {
- XMLUtil.bufferManager = bufferManager;
+ public static final class FileStoreInputStreamFactory extends InputStreamFactory {
+ private final FileStore lobBuffer;
+ private final FileStoreOutputStream fsos;
+
+ public FileStoreInputStreamFactory(FileStore lobBuffer, String encoding) {
+ super(encoding);
+ this.lobBuffer = lobBuffer;
+ fsos = lobBuffer.createOutputStream(DataTypeManager.MAX_LOB_MEMORY_BYTES);
+ this.lobBuffer.setCleanupReference(this);
+ }
+
+ @Override
+ public InputStream getInputStream() throws IOException {
+ if (!fsos.bytesWritten()) {
+ return new ByteArrayInputStream(fsos.getBuffer(), 0, fsos.getCount());
+ }
+ //TODO: adjust the buffer size, and/or develop a shared buffer strategy
+ return new BufferedInputStream(lobBuffer.createInputStream(0));
+ }
+
+ @Override
+ public long getLength() {
+ return lobBuffer.getLength();
+ }
+
+ public Writer getWriter() {
+ try {
+ return new OutputStreamWriter(fsos, Streamable.ENCODING);
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public OutputStream getOuptStream() {
+ return fsos;
+ }
+
+ @Override
+ public void free() throws IOException {
+ lobBuffer.remove();
+ }
}
-
- public static SQLXMLImpl saveToBufferManager(XMLTranslator translator) throws TeiidComponentException, TeiidProcessingException {
- return saveToBufferManager(bufferManager, translator, Streamable.STREAMING_BATCH_SIZE_IN_BYTES);
- }
-
+
/**
* This method saves the given XML object to the buffer manager's disk process
* Documents less than the maxMemorySize will be held directly in memory
*/
- public static SQLXMLImpl saveToBufferManager(BufferManager bufferMgr, XMLTranslator translator, int maxMemorySize)
+ public static SQLXMLImpl saveToBufferManager(BufferManager bufferMgr, XMLTranslator translator)
throws TeiidComponentException, TeiidProcessingException {
boolean success = false;
final FileStore lobBuffer = bufferMgr.createFileStore("xml"); //$NON-NLS-1$
+ FileStoreInputStreamFactory fsisf = new FileStoreInputStreamFactory(lobBuffer, Streamable.ENCODING);
try{
- FileStoreOutputStream fsos = lobBuffer.createOutputStream(maxMemorySize);
- Writer writer = new OutputStreamWriter(fsos, Streamable.ENCODING);
+ Writer writer = fsisf.getWriter();
translator.translate(writer);
writer.close();
- if (!fsos.bytesWritten()) {
- return new SQLXMLImpl(fsos.toByteArray());
- }
success = true;
- return createSQLXML(lobBuffer);
+ return new SQLXMLImpl(fsisf);
} catch(IOException e) {
throw new TeiidComponentException(e);
} catch(TransformerException e) {
@@ -88,21 +118,4 @@
}
}
- public static SQLXMLImpl createSQLXML(final FileStore lobBuffer) {
- SQLXMLImpl sqlXML = new SQLXMLImpl(new InputStreamFactory(Streamable.ENCODING) {
- @Override
- public InputStream getInputStream() throws IOException {
- //TODO: adjust the buffer size, and/or develop a shared buffer strategy
- return new BufferedInputStream(lobBuffer.createInputStream(0));
- }
-
- @Override
- public void free() throws IOException {
- lobBuffer.remove();
- }
- });
- lobBuffer.setCleanupReference(sqlXML);
- return sqlXML;
- }
-
}
\ No newline at end of file
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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -135,4 +135,5 @@
public void visit(XMLSerialize obj) {}
public void visit(XMLQuery obj) {}
public void visit(QueryString obj) {}
+ public void visit(XMLParse obj) {}
}
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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -99,6 +99,7 @@
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.XMLParse;
import org.teiid.query.sql.symbol.XMLQuery;
import org.teiid.query.sql.symbol.XMLSerialize;
@@ -593,6 +594,13 @@
postVisitVisitor(obj);
}
+ @Override
+ public void visit(XMLParse obj) {
+ preVisitVisitor(obj);
+ visitNode(obj.getExpression());
+ 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/XMLParse.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLParse.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLParse.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -0,0 +1,108 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.sql.symbol;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
+public class XMLParse implements Expression {
+
+ private static final long serialVersionUID = 1535624727897336538L;
+
+ private boolean document;
+ private Expression expression;
+ private boolean wellFormed;
+
+ @Override
+ public Class<?> getType() {
+ return DataTypeManager.DefaultDataClasses.XML;
+ }
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public boolean isDocument() {
+ return document;
+ }
+
+ public void setDocument(boolean document) {
+ this.document = document;
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+
+ public boolean isWellFormed() {
+ return wellFormed;
+ }
+
+ public void setWellFormed(boolean wellFormed) {
+ this.wellFormed = wellFormed;
+ }
+
+ @Override
+ public boolean isResolved() {
+ return expression.isResolved();
+ }
+
+ @Override
+ public void acceptVisitor(LanguageVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ @Override
+ public XMLParse clone() {
+ XMLParse clone = new XMLParse();
+ clone.document = this.document;
+ clone.expression = (Expression)this.expression.clone();
+ clone.wellFormed = this.wellFormed;
+ return clone;
+ }
+
+ @Override
+ public int hashCode() {
+ return expression.hashCode();
+ }
+
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof XMLParse)) {
+ return false;
+ }
+ XMLParse other = (XMLParse)obj;
+ return document == other.document
+ && this.expression.equals(other.expression)
+ && this.wellFormed == other.wellFormed;
+ }
+
+ @Override
+ public String toString() {
+ return SQLStringVisitor.getSQLString(this);
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLParse.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -65,6 +65,7 @@
import org.teiid.query.sql.symbol.SearchedCaseExpression;
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.symbol.XMLElement;
+import org.teiid.query.sql.symbol.XMLParse;
import org.teiid.query.sql.symbol.XMLSerialize;
@@ -116,6 +117,11 @@
obj.setExpression(replaceExpression(obj.getExpression()));
}
+ @Override
+ public void visit(XMLParse obj) {
+ obj.setExpression(replaceExpression(obj.getExpression()));
+ }
+
private void replaceSymbols(List symbols, boolean alias) {
for (int i = 0; i < symbols.size(); i++) {
Object symbol = symbols.get(i);
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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -24,6 +24,7 @@
import static org.teiid.language.SQLConstants.Reserved.*;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -32,6 +33,7 @@
import java.util.List;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.XMLType;
import org.teiid.core.util.StringUtil;
import org.teiid.language.SQLConstants;
import org.teiid.language.SQLConstants.NonReserved;
@@ -121,6 +123,7 @@
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.XMLParse;
import org.teiid.query.sql.symbol.XMLQuery;
import org.teiid.query.sql.symbol.XMLSerialize;
import org.teiid.query.sql.symbol.XMLNamespaces.NamespaceItem;
@@ -1154,8 +1157,16 @@
} else if(type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
constantParts = new Object[] { "{d'", obj.getValue().toString(), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$
} else if(type.equals(DataTypeManager.DefaultDataClasses.XML)){
- constantParts = new Object[] { "{x '", escapeStringValue(obj.getValue().toString(), "'"), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else {
+ XMLType value = (XMLType)obj.getValue();
+ if (Boolean.TRUE.equals(value.isInMemory())) {
+ try {
+ constantParts = new Object[] { "{x '", escapeStringValue(value.getString(), "'"), "'}" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } catch (SQLException e) {
+
+ }
+ }
+ }
+ if (constantParts == null) {
String strValue = obj.getValue().toString();
strValue = escapeStringValue(strValue, "'"); //$NON-NLS-1$
constantParts = new Object[] { "'", strValue, "'" }; //$NON-NLS-1$ //$NON-NLS-2$
@@ -1821,6 +1832,24 @@
}
parts.add(")"); //$NON-NLS-1$
}
+
+ @Override
+ public void visit(XMLParse obj) {
+ parts.add(XMLPARSE);
+ parts.add(Tokens.LPAREN);
+ if (obj.isDocument()) {
+ parts.add(NonReserved.DOCUMENT);
+ } else {
+ parts.add(NonReserved.CONTENT);
+ }
+ parts.add(SPACE);
+ parts.add(registerNode(obj.getExpression()));
+ if (obj.isWellFormed()) {
+ parts.add(SPACE);
+ parts.add(NonReserved.WELLFORMED);
+ }
+ parts.add(Tokens.RPAREN);
+ }
public static String escapeSinglePart(String part) {
if(isReservedWord(part)) {
Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -32,7 +32,6 @@
import org.teiid.api.exception.query.QueryProcessingException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
-import org.teiid.core.types.Streamable;
import org.teiid.core.util.ArgCheck;
import org.teiid.query.QueryPlugin;
import org.teiid.query.eval.SecurityFunctionEvaluator;
@@ -79,8 +78,6 @@
/** Indicate whether statistics should be collected for relational node processing*/
private boolean collectNodeStatistics;
- private int streamingBatchSize = Streamable.STREAMING_BATCH_SIZE_IN_BYTES;
-
private Random random = null;
private SecurityFunctionEvaluator securityFunctionEvaluator;
@@ -274,19 +271,9 @@
return this.globalState.collectNodeStatistics;
}
- public int getStreamingBatchSize() {
- return globalState.streamingBatchSize;
- }
-
- public void setStreamingBatchSize(int streamingBatchSize) {
- this.globalState.streamingBatchSize = streamingBatchSize;
- }
-
-
public int getConnectorBatchSize() {
return this.globalState.connectorBatchSize;
}
-
public void setConnectorBatchSize(int connectorBatchSize) {
this.globalState.connectorBatchSize = connectorBatchSize;
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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -110,6 +110,7 @@
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.XMLParse;
import org.teiid.query.sql.symbol.XMLQuery;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor;
@@ -1315,5 +1316,14 @@
}
}
}
+
+ @Override
+ public void visit(XMLParse obj) {
+ if (obj.getExpression().getType() != DataTypeManager.DefaultDataClasses.STRING &&
+ obj.getExpression().getType() != DataTypeManager.DefaultDataClasses.CLOB &&
+ obj.getExpression().getType() != DataTypeManager.DefaultDataClasses.BLOB) {
+ handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.xmlserialize_type"), obj); //$NON-NLS-1$
+ }
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -70,6 +70,7 @@
import net.sf.saxon.value.SequenceType;
import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidRuntimeException;
@@ -389,7 +390,7 @@
}
}
- public XMLType createXMLType(final SequenceIterator iter, boolean emptyOnEmpty) throws XPathException, TeiidComponentException, TeiidProcessingException {
+ public XMLType createXMLType(final SequenceIterator iter, BufferManager bufferManager, boolean emptyOnEmpty) throws XPathException, TeiidComponentException, TeiidProcessingException {
Item item = iter.next();
if (item == null && !emptyOnEmpty) {
return null;
@@ -413,7 +414,7 @@
if (next != null) {
type = Type.CONTENT;
}
- SQLXMLImpl xml = XMLUtil.saveToBufferManager(new XMLTranslator() {
+ SQLXMLImpl xml = XMLUtil.saveToBufferManager(bufferManager, new XMLTranslator() {
@Override
public void translate(Writer writer) throws TransformerException,
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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-06-15 16:49:28 UTC (rev 2233)
@@ -3317,7 +3317,11 @@
)*
]
<RPAREN>
- )
+ )
+ | expression = xmlParse(info)
+ {
+ return expression;
+ }
| expression = xmlElement(info)
{
return expression;
@@ -3385,6 +3389,31 @@
}
}
+XMLParse xmlParse(ParseInfo info) :
+{
+ Expression expr = null;
+ String doc = null;
+ boolean wellformed = false;
+}
+{
+ <XMLPARSE><LPAREN>
+ doc = nonReserved("DOCUMENT", "CONTENT")
+ expr = expression(info)
+ [nonReserved("WELLFORMED")
+ {
+ wellformed = true;
+ }
+ ]
+ <RPAREN>
+ {
+ XMLParse result = new XMLParse();
+ result.setDocument("document".equalsIgnoreCase(doc));
+ result.setExpression(expr);
+ result.setWellFormed(wellformed);
+ return result;
+ }
+}
+
QueryString queryString(ParseInfo info) :
{
Expression path = null;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -244,7 +244,7 @@
ConnectorManagerRepository repo = Mockito.mock(ConnectorManagerRepository.class);
Mockito.stub(repo.getConnectorManager(Mockito.anyString())).toReturn(new AutoGenDataService());
- serverRequest.initialize(request, BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(), DEBUG, null, workContext, 101024,repo, false);
+ serverRequest.initialize(request, BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(), DEBUG, null, workContext, repo,false);
serverRequest.setMetadata(capFinder, metadata, null);
serverRequest.processRequest();
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -84,7 +84,7 @@
RequestMessage message = new RequestMessage();
DQPWorkContext workContext = FakeMetadataFactory.buildWorkContext(metadata, FakeMetadataFactory.example1VDB());
- request.initialize(message, null, null,new FakeTransactionService(),false, null, workContext, 101024, repo, false);
+ request.initialize(message, null, null,new FakeTransactionService(),false, null, workContext, repo, false);
request.initMetadata();
request.validateAccess(command);
}
@@ -139,7 +139,7 @@
request.initialize(message, Mockito.mock(BufferManager.class),
new FakeDataManager(), new FakeTransactionService(), false, null, workContext,
- 101024, repo, false);
+ repo, false);
request.processRequest();
return request;
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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -114,6 +114,7 @@
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.XMLParse;
import org.teiid.query.sql.symbol.XMLQuery;
import org.teiid.query.sql.symbol.XMLSerialize;
@@ -6824,5 +6825,13 @@
f.setPassing(Arrays.asList(new DerivedColumn(null, new ElementSymbol("foo"))));
helpTestExpression("xmlquery('/x' passing foo null on empty)", "XMLQUERY('/x' PASSING foo NULL ON EMPTY)", f);
}
+
+ @Test public void testXmlParse() throws Exception {
+ XMLParse f = new XMLParse();
+ f.setDocument(true);
+ f.setExpression(new ElementSymbol("x"));
+ f.setWellFormed(true);
+ helpTestExpression("xmlparse(document x wellformed)", "XMLPARSE(DOCUMENT x WELLFORMED)", f);
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -135,13 +135,15 @@
}
static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) {
- CommandContext context = new CommandContext();
- context.setProcessorBatchSize(2000);
- context.setConnectorBatchSize(2000);
- return helpGetPlan(command, metadata, capFinder, context);
+ CommandContext context = createCommandContext();
+ try {
+ return helpGetPlan(command, metadata, capFinder, context);
+ } catch (TeiidException e) {
+ throw new RuntimeException(e);
+ }
}
- static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context) {
+ static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context) throws TeiidException {
if(DEBUG) System.out.println("\n####################################\n" + command); //$NON-NLS-1$
AnalysisRecord analysisRecord = new AnalysisRecord(false, DEBUG);
try {
@@ -163,10 +165,6 @@
assertNotNull("Output elements of process plan are null", process.getOutputElements()); //$NON-NLS-1$
return process;
- } catch (TeiidComponentException e) {
- throw new RuntimeException(e);
- } catch (TeiidProcessingException e) {
- throw new RuntimeException(e);
} finally {
if(DEBUG) {
System.out.println(analysisRecord.getDebugLog());
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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -24,11 +24,19 @@
import static org.teiid.query.processor.TestProcessor.*;
+import java.io.FileInputStream;
import java.util.Arrays;
import java.util.List;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.core.types.BlobImpl;
+import org.teiid.core.types.BlobType;
+import org.teiid.core.types.InputStreamFactory;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.unittest.FakeMetadataFactory;
@SuppressWarnings({"nls", "unchecked"})
@@ -267,6 +275,75 @@
process(sql, expected);
}
+ @Test public void testXmlParseDoc() throws Exception {
+ String sql = "select xmlparse(document '<a/>')"; //$NON-NLS-1$
+
+ List<?>[] expected = new List<?>[] {
+ Arrays.asList("<a/>")
+ };
+
+ process(sql, expected);
+ }
+
+ @Test(expected=ExpressionEvaluationException.class) public void testXmlParseDocException() throws Exception {
+ String sql = "select xmlparse(document 'a<a/>')"; //$NON-NLS-1$
+
+ List<?>[] expected = new List<?>[] {
+ };
+
+ process(sql, expected);
+ }
+
+ @Test public void testXmlParseContent() throws Exception {
+ String sql = "select xmlparse(content 'a<a/>')"; //$NON-NLS-1$
+
+ List<?>[] expected = new List<?>[] {
+ Arrays.asList("a<a/>")
+ };
+
+ process(sql, expected);
+ }
+
+ @Test(expected=ExpressionEvaluationException.class) public void testXmlParseContentException() throws Exception {
+ String sql = "select xmlparse(content 'a<')"; //$NON-NLS-1$
+
+ List<?>[] expected = new List<?>[] {
+ };
+
+ process(sql, expected);
+ }
+
+ //by pass the validation
+ @Test public void testXmlParseContentWellformed() throws Exception {
+ String sql = "select xmlparse(content 'a<' WELLFORMED)"; //$NON-NLS-1$
+
+ List<?>[] expected = new List<?>[] {
+ Arrays.asList("a<")
+ };
+
+ process(sql, expected);
+ }
+
+ @Test public void testXmlParseClob() throws Exception {
+ String sql = "select xmlparse(document cast(? as clob)) x"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(ObjectConverterUtil.convertToString(new FileInputStream(UnitTestUtil.getTestDataFile("udf.xmi")))),
+ };
+
+ processPreparedStatement(sql, expected, dataManager, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), Arrays.asList(TestTextTable.clobFromFile("udf.xmi")));
+ }
+
+ @Test public void testXmlParseBlob() throws Exception {
+ String sql = "select xmlparse(document cast(? as blob)) x"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(ObjectConverterUtil.convertToString(new FileInputStream(UnitTestUtil.getTestDataFile("udf.xmi")))),
+ };
+
+ processPreparedStatement(sql, expected, dataManager, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), Arrays.asList(blobFromFile("udf.xmi")));
+ }
+
private static FakeDataManager dataManager = new FakeDataManager();
@BeforeClass public static void oneTimeSetUp() {
@@ -274,9 +351,13 @@
}
private void process(String sql, List<?>[] expected) throws Exception {
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(), createCommandContext());
helpProcess(plan, createCommandContext(), dataManager, expected);
}
+
+ public static BlobType blobFromFile(final String file) {
+ return new BlobType(new BlobImpl(new InputStreamFactory.FileInputStreamFactory(UnitTestUtil.getTestDataFile(file))));
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTextTable.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -183,7 +183,7 @@
helpProcess(plan, createCommandContext(), dataManager, expectedResults);
}
- public ClobType clobFromFile(final String file) {
+ public static ClobType clobFromFile(final String file) {
return new ClobType(new ClobImpl(new InputStreamFactory.FileInputStreamFactory(UnitTestUtil.getTestDataFile(file)), -1));
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestAddNodeInstruction.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/xml/TestAddNodeInstruction.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestAddNodeInstruction.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -24,24 +24,18 @@
import java.util.Properties;
+import junit.framework.TestCase;
+
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.common.buffer.FileStore;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.Streamable;
import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.query.mapping.xml.MappingNodeConstants;
-import org.teiid.query.processor.xml.AddNodeInstruction;
-import org.teiid.query.processor.xml.DocumentInProgress;
-import org.teiid.query.processor.xml.NodeDescriptor;
-import org.teiid.query.processor.xml.ProcessorInstruction;
-import org.teiid.query.processor.xml.Program;
-import org.teiid.query.processor.xml.SAXDocumentInProgress;
-import org.teiid.query.processor.xml.XMLContext;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.util.VariableContext;
-import junit.framework.TestCase;
-
/**
* Unit tests {@link AddNodeInstruction} class
*/
@@ -417,7 +411,7 @@
env.pushProgram(program);
FileStore fs = BufferManagerFactory.getStandaloneBufferManager().createFileStore("test"); //$NON-NLS-1$
- DocumentInProgress doc = new SAXDocumentInProgress(fs);
+ DocumentInProgress doc = new DocumentInProgress(fs, Streamable.ENCODING);
env.setDocumentInProgress(doc);
//add fake root, move to child
@@ -431,7 +425,7 @@
doc.moveToParent();
doc.markAsFinished();
- String actualDoc = new String(ObjectConverterUtil.convertToByteArray(fs.createInputStream(0)));
+ String actualDoc = ObjectConverterUtil.convertToString(doc.getSQLXML().getCharacterStream());
return actualDoc;
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestSAXDocumentInProgress.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/xml/TestSAXDocumentInProgress.java 2010-06-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestSAXDocumentInProgress.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -24,9 +24,10 @@
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.common.buffer.FileStore;
+import org.teiid.core.types.Streamable;
import org.teiid.query.mapping.xml.MappingNodeConstants;
import org.teiid.query.processor.xml.NodeDescriptor;
-import org.teiid.query.processor.xml.SAXDocumentInProgress;
+import org.teiid.query.processor.xml.DocumentInProgress;
import junit.framework.TestCase;
@@ -40,7 +41,7 @@
public void testLargeDocument()throws Exception{
FileStore fs = BufferManagerFactory.getStandaloneBufferManager().createFileStore("test"); //$NON-NLS-1$
- SAXDocumentInProgress doc = new SAXDocumentInProgress(fs);
+ DocumentInProgress doc = new DocumentInProgress(fs, Streamable.ENCODING);
//long startTime = System.currentTimeMillis();
doc.setDocumentFormat(true);
NodeDescriptor descriptor = NodeDescriptor.createNodeDescriptor("Root", null, true, null, null, null,false, null, MappingNodeConstants.NORMALIZE_TEXT_PRESERVE);//$NON-NLS-1$
@@ -63,14 +64,14 @@
}
public void testNormalizationPreserve() throws Exception{
- assertEquals(SAXDocumentInProgress.normalizeText(originalText,MappingNodeConstants.NORMALIZE_TEXT_PRESERVE), originalText);
+ assertEquals(DocumentInProgress.normalizeText(originalText,MappingNodeConstants.NORMALIZE_TEXT_PRESERVE), originalText);
}
public void testNormalizationReplace() throws Exception{
String expectedResult = " Hello my tests for preserve, replace, collapse. "; //$NON-NLS-1$
- assertEquals(SAXDocumentInProgress.normalizeText(originalText,MappingNodeConstants.NORMALIZE_TEXT_REPLACE), expectedResult);
+ assertEquals(DocumentInProgress.normalizeText(originalText,MappingNodeConstants.NORMALIZE_TEXT_REPLACE), expectedResult);
}
public void testNormalizationCollapse() throws Exception{
String expectedResult = "Hello my tests for preserve, replace, collapse."; //$NON-NLS-1$
- assertEquals(SAXDocumentInProgress.normalizeText(originalText,MappingNodeConstants.NORMALIZE_TEXT_COLLAPSE), expectedResult);
+ assertEquals(DocumentInProgress.normalizeText(originalText,MappingNodeConstants.NORMALIZE_TEXT_COLLAPSE), expectedResult);
}
}
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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -2268,7 +2268,7 @@
}
@Test public void testRewriteXmlElement() throws Exception {
- String original = "convert(xmlelement(name a, xmlattributes('b' as c)), string)"; //$NON-NLS-1$
+ String original = "xmlserialize(document xmlelement(name a, xmlattributes('b' as c)) as string)"; //$NON-NLS-1$
QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
helpTestRewriteExpression(original, "'<a c=\"b\"></a>'", 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-15 16:25:38 UTC (rev 2232)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-06-15 16:49:28 UTC (rev 2233)
@@ -2031,4 +2031,7 @@
helpValidate("select xmlelement(\":\")", new String[] {"XMLELEMENT(NAME \":\")"}, FakeMetadataFactory.example1Cached());
}
+ @Test public void testXmlParse() throws Exception {
+ helpValidate("select xmlparse(content e2) from pm1.g1", new String[] {"XMLPARSE(CONTENT e2)"}, FakeMetadataFactory.example1Cached());
+ }
}
14 years, 6 months
teiid SVN: r2232 - trunk/adminshell/src/main/resources.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-06-15 12:25:38 -0400 (Tue, 15 Jun 2010)
New Revision: 2232
Modified:
trunk/adminshell/src/main/resources/vdb.xsl
Log:
TEIID-1121: Fixing the migrate script for translator changes
Modified: trunk/adminshell/src/main/resources/vdb.xsl
===================================================================
--- trunk/adminshell/src/main/resources/vdb.xsl 2010-06-15 15:59:48 UTC (rev 2231)
+++ trunk/adminshell/src/main/resources/vdb.xsl 2010-06-15 16:25:38 UTC (rev 2232)
@@ -46,7 +46,97 @@
<xsl:for-each select="//ConnectorBindings/Connector">
<xsl:if test="@Name=$connector-name">
- <xsl:attribute name="translator-name"><xsl:value-of select="translate(substring-before(@ComponentType, ' '), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/></xsl:attribute>
+ <xsl:choose>
+ <xsl:when test="@ComponentType='Oracle Connector'">
+ <xsl:attribute name="translator-name">oracle</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='Oracle XA Connector'">
+ <xsl:attribute name="translator-name">oracle</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='DB2 Connector'">
+ <xsl:attribute name="translator-name">db2</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='DB2 XA Connector'">
+ <xsl:attribute name="translator-name">db2</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='SQL Server Connector'">
+ <xsl:attribute name="translator-name">sqlserver</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='SQL Server XA Connector'">
+ <xsl:attribute name="translator-name">sqlserver</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='MySQL JDBC Connector'">
+ <xsl:attribute name="translator-name">mysql</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='MySQL 5 JDBC Connector'">
+ <xsl:attribute name="translator-name">mysql</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='MySQL JDBC XA Connector'">
+ <xsl:attribute name="translator-name">mysql5</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='MySQL 5 JDBC XA Connector'">
+ <xsl:attribute name="translator-name">mysql5</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='PostgreSQL JDBC Connector'">
+ <xsl:attribute name="translator-name">postgresql</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='PostgreSQL XA JDBC Connector'">
+ <xsl:attribute name="translator-name">postgresql</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='Apache Derby Embedded Connector'">
+ <xsl:attribute name="translator-name">derby</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='Apache Derby Network Connector'">
+ <xsl:attribute name="translator-name">derby</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='Apache Derby XA Network Connector'">
+ <xsl:attribute name="translator-name">derby</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='Teiid 6 JDBC Connector'">
+ <xsl:attribute name="translator-name">teiid</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='JDBC ODBC Connector'">
+ <xsl:attribute name="translator-name">jdbc-ansi</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='MS Access Connector'">
+ <xsl:attribute name="translator-name">jdbc-ansi</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='MS Excel Connector'">
+ <xsl:attribute name="translator-name">jdbc-ansi</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='Loopback Connector'">
+ <xsl:attribute name="translator-name">loopback</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='Salesforce Connector'">
+ <xsl:attribute name="translator-name">salesforce</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='Text File Connector'">
+ <xsl:attribute name="translator-name">file</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='XML Connector'">
+ <xsl:attribute name="translator-name">xml</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='XML File Connector'">
+ <xsl:attribute name="translator-name">xml</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='XML SOAP Connector'">
+ <xsl:attribute name="translator-name">xml</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='XML-Relational File Connector'">
+ <xsl:attribute name="translator-name">xml</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='XML-Relational HTTP Connector'">
+ <xsl:attribute name="translator-name">xml</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@ComponentType='XML-Relational SOAP Connector'">
+ <xsl:attribute name="translator-name">xml</xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="translator-name"><xsl:value-of select="translate(substring-before(@ComponentType, ' '), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/>
+ </xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+
</xsl:if>
</xsl:for-each>
</source>
14 years, 6 months
teiid SVN: r2231 - in trunk/adminshell/src/main: resources and 1 other directory.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-06-15 11:59:48 -0400 (Tue, 15 Jun 2010)
New Revision: 2231
Removed:
trunk/adminshell/src/main/resources/connector.xsl
Modified:
trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java
trunk/adminshell/src/main/resources/vdb.xsl
Log:
TEIID-1121: Fixing the migrate script for translator changes
Modified: trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java
===================================================================
--- trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java 2010-06-14 16:35:03 UTC (rev 2230)
+++ trunk/adminshell/src/main/java/org/teiid/adminshell/MigrationUtil.java 2010-06-15 15:59:48 UTC (rev 2231)
@@ -58,17 +58,14 @@
"\n 7.0 compatible replacement files will be created in the same directory " +
"\n as your file." +
"\n If you supply a vdb, the new vdb file will have a _70.vdb suffix." +
- "\n If you supply a dynamic vdb file, then two new files will be created: " +
- "\n <file name>-vdb.xml and <file name>-bindings.xml" +
- "\n\nNote: this program will only create connector binding connection factories " +
- "\n if the bindings are present in the specified file." +
+ "\n If you supply a dynamic vdb file, <file name>-vdb.xml is created " +
+ "\n\nNote: This program will create translator names by Connector's Component Type name" +
+ "\n As they are not gureented to match; recheck their for their validity" +
"\n\nNote: this program will NOT create the -ds.xml files needed by JBoss to " +
"\n create underlying DataSource connection pools." +
"\n You will need to manually create one -ds.xml for each JDBC DataSource " +
"\n with a JNDI name of <connector binding name>DS, " +
- "\n where any spaces in the name are replace by _" +
- "\n\nNode: depending upon the connectors used, you may need to manually edit the " +
- " -bindings.xml file.");
+ "\n where any spaces in the name are replace by _");
System.exit(-1);
}
File file = new File(args[0]);
@@ -101,7 +98,6 @@
manifest.delete();
}
transformConfig(config, "/vdb.xsl", new StreamResult(new File(metainf, "vdb.xml")));
- transformConfig(config, "/connector.xsl", new StreamResult(new File(file.getParentFile(), fileName + "-bindings-ds.xml")));
config.delete();
FileOutputStream out = new FileOutputStream(new File(file.getParent(), fileName + "_70.vdb"));
ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(out));
@@ -114,7 +110,6 @@
} else if (ext.endsWith("xml") || ext.endsWith("def")){
File parent = file.getParentFile();
transformConfig(file, "/vdb.xsl", new StreamResult(new File(parent, fileName + "-vdb.xml")));
- transformConfig(file, "/connector.xsl", new StreamResult(new File(parent, fileName + "-bindings-ds.xml")));
} else {
System.err.println(fullName + " is not a vdb or xml file. Run with no arguments for help."); //$NON-NLS-1$
System.exit(-1);
Deleted: trunk/adminshell/src/main/resources/connector.xsl
===================================================================
--- trunk/adminshell/src/main/resources/connector.xsl 2010-06-14 16:35:03 UTC (rev 2230)
+++ trunk/adminshell/src/main/resources/connector.xsl 2010-06-15 15:59:48 UTC (rev 2231)
@@ -1,138 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:param name="version">7.0</xsl:param>
- <xsl:output method="xml" indent="yes"/>
- <xsl:strip-space elements="*"/>
- <xsl:template match="VDB">
- <xsl:if test="ConnectorBindings">
- <connection-factories>
- <xsl:for-each select="ConnectorBindings/Connector">
- <no-tx-connection-factory>
- <jndi-name><xsl:value-of select="translate(@Name, ' ', '_')" /></jndi-name>
- <xsl:choose>
- <xsl:when test="@ComponentType='Text File Connector'">
- <rar-name>connector-text-<xsl:value-of select="$version"/>.rar</rar-name>
- </xsl:when>
- <xsl:when test="starts-with(@ComponentType,'Apache ') or starts-with(@ComponentType,'MySQL ')
- or starts-with(@ComponentType,'Oracle ') or starts-with(@ComponentType,'PostgreSQL ')
- or starts-with(@ComponentType,'SQL Server ') or starts-with(@ComponentType,'DB2 ')
- or starts-with(@ComponentType,'MS Access ') or starts-with(@ComponentType,'MS Excel ')
- or starts-with(@ComponentType,'JDBC ') or starts-with(@ComponentType,'Teiid ')
- or starts-with(@ComponentType,'MM ') or starts-with(@ComponentType,'H2 ')
- or starts-with(@ComponentType,'HSQLDB ') or starts-with(@ComponentType,'Sybase ')
- ">
- <rar-name>connector-jdbc-<xsl:value-of select="$version"/>.rar</rar-name>
- </xsl:when>
- <xsl:when test="@ComponentType='LDAP Connector'">
- <rar-name>connector-ldap-<xsl:value-of select="$version"/>.rar</rar-name>
- </xsl:when>
- <xsl:when test="@ComponentType='Loopback Connector'">
- <rar-name>connector-loopback-<xsl:value-of select="$version"/>.rar</rar-name>
- </xsl:when>
- <xsl:when test="@ComponentType='Salesforce Connector'">
- <rar-name>connector-salesforce-<xsl:value-of select="$version"/>.rar</rar-name>
- </xsl:when>
- <xsl:when test="@ComponentType='XML File Connector' or @ComponentType='XML-Relational File Connector'">
- <rar-name>connector-xml-file-<xsl:value-of select="$version"/>.rar</rar-name>
- </xsl:when>
- <xsl:when test="@ComponentType='XML SOAP Connector' or @ComponentType='XML-Relational Soap Connector'">
- <rar-name>connector-xml-soap-<xsl:value-of select="$version"/>.rar</rar-name>
- </xsl:when>
- <xsl:when test="@ComponentType='XML-Relational HTTP Connector'">
- <rar-name>connector-xml-http-<xsl:value-of select="$version"/>.rar</rar-name>
- </xsl:when>
- </xsl:choose>
- <connection-definition>org.teiid.connector.api.Connector</connection-definition>
- <xsl:for-each select="Properties/Property">
- <xsl:choose>
- <xsl:when test="@Name='ConnectorMaxConnections' or @Name='UsePostDelegation'
- or @Name='ConnectorThreadTTL' or @Name='DeployedName'
- or @Name='ConnectorMaxThreads' or @Name='SetCriteriaBatchSize'
- or @Name='ConnectorClassPath' or @Name='SourceConnectionTestInterval'
- or @Name='metamatrix.service.essentialservice' or @Name='ServiceMonitoringEnabled'
- or @Name='ConnectorClass' or @Name='ServiceClassName'
- or @Name='SynchWorkers' or @Name='UseCredentialMap'
- or @Name='ConnectionPoolEnabled' or @Name='AdminConnectionsAllowed'
- or starts-with(@Name,'com.metamatrix.data.pool') or starts-with(@Name, 'getMax')
- or starts-with(@Name, 'supports') or starts-with(@Name, 'getSupported')
- or @Name='requiresCriteria' or @Name='useAnsiJoin'
- or @Name='URL' or @Name='ConnectionSource'
- or @Name='User' or @Name='Password' or starts-with(@Name, 'ResultSetCache')
- or starts-with(@Name, 'Extension') or @Name='Driver'
- or @Name='MaxSQLLength'">
- <xsl:comment><config-property name="<xsl:value-of select="@Name"/>"><xsl:value-of select="text()"/></config-property></xsl:comment>
- </xsl:when>
- <xsl:when test="@Name='MaxResultRows' and text()='0'">
- <config-property>
- <xsl:attribute name="name">
- <xsl:value-of select="@Name"/>
- </xsl:attribute>-1</config-property>
- </xsl:when>
- <xsl:otherwise>
- <config-property>
- <xsl:attribute name="name">
- <xsl:value-of select="@Name"/>
- </xsl:attribute>
- <xsl:value-of select="text()"/>
- </config-property>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- <xsl:if test="starts-with(@ComponentType,'Apache ') or starts-with(@ComponentType,'MySQL ')
- or starts-with(@ComponentType,'Oracle ') or starts-with(@ComponentType,'PostgreSQL ')
- or starts-with(@ComponentType,'SQL Server ') or starts-with(@ComponentType,'DB2 ')
- or starts-with(@ComponentType,'MS Access ') or starts-with(@ComponentType,'MS Excel ')
- or starts-with(@ComponentType,'JDBC ') or starts-with(@ComponentType,'Teiid ')
- or starts-with(@ComponentType,'MM ') or starts-with(@ComponentType,'H2 ')
- or starts-with(@ComponentType,'HSQLDB ') or starts-with(@ComponentType,'Sybase ')
- ">
- <config-property name="SourceJNDIName">java:<xsl:value-of select="translate(@Name, ' ', '_')" />DS</config-property>
- <xsl:message>For connector binding "<xsl:value-of select="@Name" />" of legacy type "<xsl:value-of select="@ComponentType" />", you will need to create a -ds.xml JDBC DataSource with JNDI name <xsl:value-of select="translate(@Name, ' ', '_')" />DS</xsl:message>
- <xsl:choose>
- <xsl:when test="starts-with(@ComponentType,'Apache ')">
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.derby.DerbySQLTranslator</config-property>
- </xsl:when>
- <xsl:when test="starts-with(@ComponentType,'MySQL 5 ')">
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.mysql.MySQL5Translator</config-property>
- </xsl:when>
- <xsl:when test="starts-with(@ComponentType,'MySQL JDBC')">
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.mysql.MySQLTranslator</config-property>
- </xsl:when>
- <xsl:when test="starts-with(@ComponentType,'Oracle')">
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.oracle.OracleSQLTranslator</config-property>
- </xsl:when>
- <xsl:when test="starts-with(@ComponentType,'PostgreSQL')">
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.postgresql.PostgreSQLTranslator</config-property>
- </xsl:when>
- <xsl:when test="starts-with(@ComponentType,'SQL Server')">
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.sqlserver.SQLServerSQLTranslator</config-property>
- </xsl:when>
- <xsl:when test="starts-with(@ComponentType,'DB2')">
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.db2.DB2SQLTranslator</config-property>
- </xsl:when>
- <xsl:when test="starts-with(@ComponentType,'H2')">
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.h2.H2Translator</config-property>
- </xsl:when>
- <xsl:when test="starts-with(@ComponentType,'HSQLDQ')">
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.hsql.HSSQLTranslator</config-property>
- </xsl:when>
- <xsl:when test="starts-with(@ComponentType,'Sybase')">
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.sybase.SybaseSQLTranslator</config-property>
- </xsl:when>
- <xsl:otherwise>
- <config-property name="ExtensionTranslationClassName">org.teiid.connector.jdbc.translator.Translator</config-property>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- <xsl:if test="contains(@ComponentType,'XA')">
- <config-property name="IsXA">true</config-property>
- </xsl:if>
- <xsl:if test="Properties/Property[@Name='ConnectorMaxConnections' or @Name='com.metamatrix.data.pool.max_connections']">
- <max-pool-size><xsl:value-of select="Properties/Property[@Name='ConnectorMaxConnections' or @Name='com.metamatrix.data.pool.max_connections']/text()"/></max-pool-size>
- </xsl:if>
- </no-tx-connection-factory>
- </xsl:for-each>
- </connection-factories>
- </xsl:if>
- </xsl:template>
-</xsl:stylesheet>
Modified: trunk/adminshell/src/main/resources/vdb.xsl
===================================================================
--- trunk/adminshell/src/main/resources/vdb.xsl 2010-06-14 16:35:03 UTC (rev 2230)
+++ trunk/adminshell/src/main/resources/vdb.xsl 2010-06-15 15:59:48 UTC (rev 2231)
@@ -40,8 +40,15 @@
</xsl:for-each>
<xsl:for-each select="ConnectorBindings/Connector">
<source>
+ <xsl:variable name="connector-name" select="@Name"/>
<xsl:attribute name="name"><xsl:value-of select="@Name" /></xsl:attribute>
- <xsl:attribute name="jndi-name"><xsl:value-of select="concat('java:',translate(@Name, ' ', '_'))" /></xsl:attribute>
+ <xsl:attribute name="connection-jndi-name"><xsl:value-of select="concat('java:',translate(@Name, ' ', '_'))" /></xsl:attribute>
+
+ <xsl:for-each select="//ConnectorBindings/Connector">
+ <xsl:if test="@Name=$connector-name">
+ <xsl:attribute name="translator-name"><xsl:value-of select="translate(substring-before(@ComponentType, ' '), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"/></xsl:attribute>
+ </xsl:if>
+ </xsl:for-each>
</source>
</xsl:for-each>
</model>
14 years, 6 months