Author: shawkins
Date: 2010-07-12 21:29:08 -0400 (Mon, 12 Jul 2010)
New Revision: 2334
Added:
trunk/test-integration/db/src/test/java/org/teiid/internal/
trunk/test-integration/db/src/test/java/org/teiid/internal/core/
trunk/test-integration/db/src/test/java/org/teiid/internal/core/xml/
Removed:
trunk/build/kits/jboss-container/teiid-docs/licenses/JDOM-LICENSE.txt
trunk/engine/src/main/java/org/teiid/internal/core/xml/
trunk/engine/src/test/java/org/teiid/internal/core/xml/
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
trunk/engine/pom.xml
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingLoader.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java
trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
trunk/pom.xml
trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
Log:
TEIID-1154 removing jdom and fixing an issue with function metadata
Deleted: trunk/build/kits/jboss-container/teiid-docs/licenses/JDOM-LICENSE.txt
===================================================================
--- trunk/build/kits/jboss-container/teiid-docs/licenses/JDOM-LICENSE.txt 2010-07-12
20:59:02 UTC (rev 2333)
+++ trunk/build/kits/jboss-container/teiid-docs/licenses/JDOM-LICENSE.txt 2010-07-13
01:29:08 UTC (rev 2334)
@@ -1,56 +0,0 @@
-/*--
-
- $Id: LICENSE.txt,v 1.11 2004/02/06 09:32:57 jhunter Exp $
-
- Copyright (C) 2000-2004 Jason Hunter & Brett McLaughlin.
- All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions, and the following disclaimer.
-
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions, and the disclaimer that follows
- these conditions in the documentation and/or other materials
- provided with the distribution.
-
- 3. The name "JDOM" must not be used to endorse or promote products
- derived from this software without prior written permission. For
- written permission, please contact <request_AT_jdom_DOT_org>.
-
- 4. Products derived from this software may not be called "JDOM", nor
- may "JDOM" appear in their name, without prior written permission
- from the JDOM Project Management <request_AT_jdom_DOT_org>.
-
- In addition, we request (but do not require) that you include in the
- end-user documentation provided with the redistribution and/or in the
- software itself an acknowledgement equivalent to the following:
- "This product includes software developed by the
- JDOM Project (
http://www.jdom.org/)."
- Alternatively, the acknowledgment may be graphical using the logos
- available at
http://www.jdom.org/images/logos.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- SUCH DAMAGE.
-
- This software consists of voluntary contributions made by many
- individuals on behalf of the JDOM Project and was originally
- created by Jason Hunter <jhunter_AT_jdom_DOT_org> and
- Brett McLaughlin <brett_AT_jdom_DOT_org>. For more information
- on the JDOM Project, please see <
http://www.jdom.org/>.
-
- */
-
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-12 20:59:02 UTC (rev
2333)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2010-07-13 01:29:08 UTC (rev
2334)
@@ -27,6 +27,7 @@
<H2><A NAME="Highlights"></A>Highlights</H2>
<UL>
<LI><B>SQL Support</B> - added NULLS FIST/LAST handling - including
pushdown support and enhanced numeric stat aggregate functions STDDEV_POP, STDDEV_SAMP,
VAR_POP, VAR_SAMP. Added support for the boolean aggregate functions ANY, SOME, EVERY.
+ <LI><B>Parallel Source Queries</B> - reestablished parallel
execution of source queries within a query plan along with a prioritized work system to
help prevent resource contention.
</UL>
<h2><a name="Compatibility">Compatibility
Issues</a></h2>
@@ -71,7 +72,6 @@
<h4>From 6.2</h4>
<ul>
<li>Start time is now significantly longer due to the container deployment.
However many operations can be performed on configruation files that will trigger a
redeployment without the need for a restart.
- <li>Parallel execution of source queries within a query plan has been temporarily
disabled.
<li>Inversion of parse, format, and convert system functions is not used if it
can be narrowing. In situations where a predicate has the form: parseTime(column,
'format') = {t 'time value'} may lead to reduced performance, since
the parseTime function cannot be pushed down. This should be addressed in future
releases.
</ul>
@@ -99,6 +99,17 @@
<h2><a name="LibraryUpdates">Thirdparty Library
Updates</a></h2>
The following components have been updated:
+<h4>From 7.0</h4>
+<ul>
+ <li>JDOM was removed.
+</ul>
+<h4>From 6.2</h4>
+<ul>
+ <li>Netty was upgraded to 3.1.5
+ <li>Saxon was upgraded to 9.1.0.8
+ <li>A 5.1 container's version of Arjuna is newer than what was previously
included in Teiid 6.x.
+ <li>Various other dependencies have been removed as they are no longer needed or
now provided by the container.
+</ul>
<h2><a name="Details">Detailed Release Notes</a></h2>
Detailed Release Notes - Teiid - Version 7.1
Modified:
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
===================================================================
---
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2010-07-12
20:59:02 UTC (rev 2333)
+++
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2010-07-13
01:29:08 UTC (rev 2334)
@@ -27,6 +27,8 @@
import java.io.IOException;
import java.util.Collection;
+import javax.xml.bind.JAXBException;
+
import junit.framework.Assert;
import org.mockito.Mockito;
@@ -65,6 +67,8 @@
util.setUDF(methods);
} catch (IOException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
+ } catch (JAXBException e) {
+ throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
}
}
return util.parseCommand(sql);
Modified: trunk/engine/pom.xml
===================================================================
--- trunk/engine/pom.xml 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/engine/pom.xml 2010-07-13 01:29:08 UTC (rev 2334)
@@ -78,11 +78,6 @@
</dependency>
<dependency>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- </dependency>
-
- <dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
</dependency>
Modified:
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2010-07-12
20:59:02 UTC (rev 2333)
+++
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2010-07-13
01:29:08 UTC (rev 2334)
@@ -1,126 +1,28 @@
-/*
- * 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.function.metadata;
-import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.Namespace;
-import org.teiid.internal.core.xml.JdomHelper;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
-
-
-/**
- * This class is reader for the UDF xmi file. This class reads a xmi file and loads the
functions
- */
+@XmlType
+@XmlRootElement(namespace="http://www.omg.org/XMI", name="XMI")
public class FunctionMetadataReader {
-
- private static final String NOT_ALLOWED = "NOT_ALLOWED"; //$NON-NLS-1$
- private static final String ALLOWED = "ALLOWED"; //$NON-NLS-1$
- private static final String REQUIRED = "REQUIRED"; //$NON-NLS-1$
- private static final String RETURN_PARAMETER = "returnParameter";
//$NON-NLS-1$
- private static final String TYPE = "type"; //$NON-NLS-1$
- private static final String INPUT_PARAMETERS = "inputParameters";
//$NON-NLS-1$
- private static final String DETERMINISTIC = "deterministic"; //$NON-NLS-1$
- private static final String PUSH_DOWN = "pushDown"; //$NON-NLS-1$
- private static final String INVOCATION_METHOD = "invocationMethod";
//$NON-NLS-1$
- private static final String INVOCATION_CLASS = "invocationClass";
//$NON-NLS-1$
- private static final String CATEGORY = "category"; //$NON-NLS-1$
- private static final String DESCRIPTION = "description"; //$NON-NLS-1$
- private static final String NAME = "name"; //$NON-NLS-1$
- private static final String SCALAR_FUNCTION = "ScalarFunction"; //$NON-NLS-1$
- private static final String NS_MMFUNCTION = "mmfunction"; //$NON-NLS-1$
- public static List<FunctionMethod> loadFunctionMethods(InputStream source) throws
IOException {
- try {
- List<FunctionMethod> methods = new ArrayList<FunctionMethod>();
-
- Document doc = JdomHelper.buildDocument(source);
- Element rootElement = doc.getRootElement();
-
- // read the xmi file and load the functions
- Namespace ns = rootElement.getNamespace(NS_MMFUNCTION);
- List<Element> functionElements = rootElement.getChildren(SCALAR_FUNCTION, ns);
- for (Element functionElement:functionElements) {
-
- String name = functionElement.getAttributeValue(NAME);
- String description = functionElement.getAttributeValue(DESCRIPTION);
- String category = functionElement.getAttributeValue(CATEGORY);
- String invocationClass = functionElement.getAttributeValue(INVOCATION_CLASS);
- String invocationMethod = functionElement.getAttributeValue(INVOCATION_METHOD);
- int pushdown= decodePushDownType(functionElement.getAttributeValue(PUSH_DOWN));
- boolean deterministic =
Boolean.parseBoolean(functionElement.getAttributeValue(DETERMINISTIC));
-
- // read input parameters
- List<FunctionParameter> inParamters = new
ArrayList<FunctionParameter>();
- List<Element> inputParameterElements =
functionElement.getChildren(INPUT_PARAMETERS);
- for (Element inputElement:inputParameterElements) {
- inParamters.add(new FunctionParameter(inputElement.getAttributeValue(NAME),
inputElement.getAttributeValue(TYPE), inputElement.getAttributeValue(DESCRIPTION)));
- }
-
- // read return for the function
- FunctionParameter returnParameter = null;
- Element returnElement = functionElement.getChild(RETURN_PARAMETER);
- if (returnElement != null) {
- returnParameter = new
FunctionParameter(FunctionParameter.OUTPUT_PARAMETER_NAME,returnElement.getAttributeValue(TYPE),
returnElement.getAttributeValue(DESCRIPTION));
- }
-
- FunctionMethod function = new FunctionMethod(
- name,
- description,
- category,
- pushdown,
- invocationClass,
- invocationMethod,
- inParamters.toArray(new FunctionParameter[inParamters.size()]),
- returnParameter,
- true,
- deterministic ? FunctionMethod.DETERMINISTIC: FunctionMethod.NONDETERMINISTIC);
-
- methods.add(function);
- }
- return methods;
- } catch (JDOMException e) {
- throw new IOException(e);
- }
+ @XmlElement(namespace="http://www.metamatrix.com/metamodels/MetaMatrixFunction",
name="ScalarFunction")
+ List<FunctionMethod> functionMethods = new ArrayList<FunctionMethod>();
+
+ public static List<FunctionMethod> loadFunctionMethods(InputStream source) throws
JAXBException {
+ JAXBContext jc = JAXBContext.newInstance(new Class<?>[]
{FunctionMetadataReader.class});
+ Unmarshaller marshaller = jc.createUnmarshaller();
+ FunctionMetadataReader md = (FunctionMetadataReader) marshaller.unmarshal(source);
+ return md.functionMethods;
}
-
- private static int decodePushDownType(String pushdown) {
- if (pushdown != null) {
- if (pushdown.equals(REQUIRED)) {
- return FunctionMethod.CAN_PUSHDOWN;
- } else if (pushdown.equals(ALLOWED)) {
- return FunctionMethod.MUST_PUSHDOWN;
- } else if (pushdown.equals(NOT_ALLOWED)) {
- return FunctionMethod.CANNOT_PUSHDOWN;
- }
- }
- return FunctionMethod.CAN_PUSHDOWN;
- }
-
+
}
Modified:
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java 2010-07-12
20:59:02 UTC (rev 2333)
+++
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java 2010-07-13
01:29:08 UTC (rev 2334)
@@ -25,6 +25,9 @@
import java.io.Serializable;
import java.util.Arrays;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
import org.teiid.core.util.HashCodeUtil;
@@ -53,6 +56,10 @@
* @see FunctionCategoryConstants
*/
public class FunctionMethod implements Serializable {
+
+ private static final String NOT_ALLOWED = "NOT_ALLOWED"; //$NON-NLS-1$
+ private static final String ALLOWED = "ALLOWED"; //$NON-NLS-1$
+ private static final String REQUIRED = "REQUIRED"; //$NON-NLS-1$
public static final int CAN_PUSHDOWN = 0;
public static final int CANNOT_PUSHDOWN = 1;
@@ -188,6 +195,7 @@
* Return name of method
* @return Name
*/
+ @XmlAttribute
public String getName() {
return this.name;
}
@@ -204,6 +212,7 @@
* Get description of method
* @return Description
*/
+ @XmlAttribute
public String getDescription() {
return this.description;
}
@@ -221,6 +230,7 @@
* @return Category
* @see FunctionCategoryConstants
*/
+ @XmlAttribute
public String getCategory() {
return this.category;
}
@@ -250,10 +260,26 @@
this.pushdown = pushdown;
}
+ @XmlAttribute
+ public void setPushDown(String pushdown) {
+ if (pushdown != null) {
+ if (pushdown.equals(REQUIRED)) {
+ this.pushdown = FunctionMethod.MUST_PUSHDOWN;
+ } else if (pushdown.equals(ALLOWED)) {
+ this.pushdown = FunctionMethod.CAN_PUSHDOWN;
+ } else if (pushdown.equals(NOT_ALLOWED)) {
+ this.pushdown = FunctionMethod.CANNOT_PUSHDOWN;
+ }
+ } else {
+ this.pushdown = FunctionMethod.CAN_PUSHDOWN;
+ }
+ }
+
/**
* Get invocation class name
* @return Invocation class name
*/
+ @XmlAttribute
public String getInvocationClass() {
return this.invocationClass;
}
@@ -270,6 +296,7 @@
* Get invocation method name
* @return Invocation method name
*/
+ @XmlAttribute
public String getInvocationMethod() {
return this.invocationMethod;
}
@@ -297,6 +324,7 @@
* Get input parameters
* @return Array of input parameters, may be null if 0 parameters
*/
+ @XmlElement
public FunctionParameter[] getInputParameters() {
return this.inputParameters;
}
@@ -313,6 +341,7 @@
* Get ouput parameter.
* @return Output parameter or return argument
*/
+ @XmlElement(name="returnParameter")
public FunctionParameter getOutputParameter() {
return this.outputParameter;
}
@@ -321,7 +350,10 @@
* Set ouput parameter.
* @param param Output Parameter
*/
- public void setOutputParameter(FunctionParameter param) {
+ public void setOutputParameter(FunctionParameter param) {
+ if (param != null) {
+ param.setName(FunctionParameter.OUTPUT_PARAMETER_NAME);
+ }
this.outputParameter = param;
}
@@ -464,7 +496,12 @@
public int getDeterministic() {
return this.deterministic;
}
-
+
+ @XmlAttribute(name="deterministic")
+ public void setDeterministicBoolean(boolean deterministic) {
+ this.deterministic = deterministic ? FunctionMethod.DETERMINISTIC :
FunctionMethod.NONDETERMINISTIC;
+ }
+
public void setDeterministic(int deterministic) {
this.deterministic = deterministic;
}
Modified:
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java 2010-07-12
20:59:02 UTC (rev 2333)
+++
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java 2010-07-13
01:29:08 UTC (rev 2334)
@@ -24,6 +24,8 @@
import java.io.Serializable;
+import javax.xml.bind.annotation.XmlAttribute;
+
/**
* A function parameter defines the name and description of an input or output
* parameter for a function. The name should not be null, but that is not
@@ -76,6 +78,7 @@
* Return name of parameter.
* @return Name
*/
+ @XmlAttribute
public String getName() {
return this.name;
}
@@ -92,6 +95,7 @@
* Get description of parameter
* @return Description
*/
+ @XmlAttribute
public String getDescription() {
return this.description;
}
@@ -109,6 +113,7 @@
* @return Type name
* @see org.teiid.core.types.DataTypeManager.DefaultDataTypes
*/
+ @XmlAttribute
public String getType() {
return this.type;
}
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingLoader.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingLoader.java 2010-07-12
20:59:02 UTC (rev 2333)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingLoader.java 2010-07-13
01:29:08 UTC (rev 2334)
@@ -22,21 +22,27 @@
package org.teiid.query.mapping.xml;
-import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-import org.teiid.internal.core.xml.SAXBuilderHelper;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
import org.teiid.query.QueryPlugin;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
/**
@@ -62,26 +68,23 @@
*/
public MappingDocument loadDocument(InputStream stream) throws MappingException {
try {
- SAXBuilder builder = SAXBuilderHelper.createSAXBuilder( false ); // Do not
validate XML
- Document doc = builder.build(stream);
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setValidating(false);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(stream);
return loadContents(doc);
- } catch (JDOMException e) {
- throw new MappingException(e);
} catch (IOException e) {
throw new MappingException(e);
- }
+ } catch (ParserConfigurationException e) {
+ throw new MappingException(e);
+ } catch (SAXException e) {
+ throw new MappingException(e);
+ }
}
- public MappingDocument loadDocument(String fileName) throws MappingException {
- try {
- SAXBuilder builder = SAXBuilderHelper.createSAXBuilder( false ); // Do not
validate XML
- Document doc = builder.build(new File(fileName) );
- return loadContents(doc);
- } catch (JDOMException e) {
- throw new MappingException(e);
- } catch (IOException e) {
- throw new MappingException(e);
- }
+ public MappingDocument loadDocument(String fileName) throws MappingException,
FileNotFoundException {
+ FileInputStream fis = new FileInputStream(fileName);
+ return loadDocument(fis);
}
/**
@@ -90,10 +93,10 @@
MappingDocument loadContents(Document document) throws MappingException {
MappingDocument doc = new MappingDocument(false);
- loadDocumentProperties(doc, document.getRootElement());
+ loadDocumentProperties(doc, document.getDocumentElement());
// now load all the children
- Collection mappingChildren =
document.getRootElement().getChildren(MappingNodeConstants.Tags.MAPPING_NODE_NAME);
+ Collection mappingChildren = getChildren(document.getDocumentElement(),
MappingNodeConstants.Tags.MAPPING_NODE_NAME);
doc = (MappingDocument)recursiveLoadContents(mappingChildren, doc);
return doc;
}
@@ -107,11 +110,34 @@
node = processMappingNode(elem, parent);
- Collection childrenMappingNodes =
elem.getChildren(MappingNodeConstants.Tags.MAPPING_NODE_NAME);
+ Collection childrenMappingNodes = getChildren(elem,
MappingNodeConstants.Tags.MAPPING_NODE_NAME);
recursiveLoadContents(childrenMappingNodes, node);
}
return parent;
}
+
+ public Collection<Element> getChildren(Element elem, String name) {
+ NodeList children = elem.getChildNodes();
+ LinkedList<Element> results = new LinkedList<Element>();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ if (node instanceof Element && node.getNodeName().equals(name)) {
+ results.add((Element)node);
+ }
+ }
+ return results;
+ }
+
+ public Element getChild(Element elem, String name) {
+ NodeList children = elem.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ if (node instanceof Element && node.getNodeName().equals(name)) {
+ return (Element)node;
+ }
+ }
+ return null;
+ }
/**
* Load a "sequence" node from the mapping document
@@ -379,64 +405,66 @@
*/
private Namespace[] getNamespaceDeclarations(Element element) {
ArrayList namespaces = new ArrayList();
- Iterator elements = this.getElements(element,
MappingNodeConstants.Tags.NAMESPACE_DECLARATION).iterator();
+ Iterator elements = getChildren(element,
MappingNodeConstants.Tags.NAMESPACE_DECLARATION).iterator();
while (elements.hasNext()){
Element namespace = (Element)elements.next();
Element prefixEl = getElement(namespace,
MappingNodeConstants.Tags.NAMESPACE_DECLARATION_PREFIX);
Element uriEl = getElement(namespace,
MappingNodeConstants.Tags.NAMESPACE_DECLARATION_URI);
- String prefix = (prefixEl != null ? prefixEl.getTextTrim() :
MappingNodeConstants.DEFAULT_NAMESPACE_PREFIX);
- String uri = uriEl.getTextTrim();
+ String prefix = (prefixEl != null ? getTextTrim(prefixEl) :
MappingNodeConstants.DEFAULT_NAMESPACE_PREFIX);
+ String uri = getTextTrim(uriEl);
namespaces.add(new Namespace(prefix, uri));
}
return (Namespace[])namespaces.toArray(new Namespace[namespaces.size()]);
}
+
+ static String getTextTrim(Element element) {
+ if (element == null) {
+ return null;
+ }
+ String result = element.getTextContent();
+ if (result != null) {
+ return result.trim();
+ }
+ return result;
+ }
/**
* Get a specific child element of an element.
*/
Element getElement( Element element, String childName ) {
- return element.getChild(childName);
+ return getChild(element, childName);
}
String getElementValue( Element element, String childName ) {
- Element child = element.getChild(childName);
- if (child != null) {
- return child.getTextTrim();
- }
- return null;
+ Element child = getChild(element, childName);
+ return getTextTrim(child);
}
String getElementValue( Element element, String childName , String defalt) {
- Element child = element.getChild(childName);
- if (child != null) {
- return child.getTextTrim();
+ Element child = getChild(element, childName);
+ String result = getTextTrim(child);
+ if (result == null) {
+ return defalt;
}
- return defalt;
+ return result;
}
int getIntElementValue( Element element, String childName , int defalt) {
- Element child = element.getChild(childName);
+ Element child = getChild(element, childName);
if (child != null) {
- return Integer.valueOf(child.getTextTrim()).intValue();
+ return Integer.valueOf(getTextTrim(child)).intValue();
}
return defalt;
}
boolean getBooleanElementValue( Element element, String childName , boolean defalt)
{
- Element child = element.getChild(childName);
+ Element child = getChild(element, childName);
if (child != null) {
- return Boolean.valueOf(child.getTextTrim()).booleanValue();
+ return Boolean.valueOf(getTextTrim(child)).booleanValue();
}
return defalt;
}
- /**
- * Get Collection of specifically-named child element of an element.
- */
- Collection getElements( Element element, String childName ) {
- return element.getChildren(childName);
- }
-
String getName(Element element) {
return getElementValue(element, MappingNodeConstants.Tags.NAME);
}
@@ -531,10 +559,10 @@
List getStagingTableNames(Element element) {
ArrayList cacheGroups = new ArrayList();
- Collection tempGroupElements = getElements(element,
MappingNodeConstants.Tags.TEMP_GROUP_NAME);
+ Collection tempGroupElements = getChildren(element,
MappingNodeConstants.Tags.TEMP_GROUP_NAME);
for (Iterator i = tempGroupElements.iterator(); i.hasNext();) {
Element tempGroup = (Element)i.next();
- cacheGroups.add(tempGroup.getTextTrim());
+ cacheGroups.add(getTextTrim(tempGroup));
}
return cacheGroups;
}
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java 2010-07-12
20:59:02 UTC (rev 2333)
+++
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java 2010-07-13
01:29:08 UTC (rev 2334)
@@ -30,11 +30,10 @@
import java.util.Map;
import java.util.Properties;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.Namespace;
-import org.jdom.output.XMLOutputter;
-import org.teiid.internal.core.xml.JdomHelper;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
import org.teiid.query.QueryPlugin;
import org.teiid.query.util.ErrorMessageKeys;
@@ -49,43 +48,36 @@
*/
public class MappingOutputter {
- private static final String NS_NAME = null;
- private static final String NS_URL = null;
private static final String ELEM_ROOT =
MappingNodeConstants.Tags.MAPPING_ROOT_NAME;
private static final String ELEM_NODE =
MappingNodeConstants.Tags.MAPPING_NODE_NAME;
+
+ XMLStreamWriter writer;
- /** The namespace for the XML mapping document. */
- private Namespace namespace = Namespace.getNamespace( NS_NAME, NS_URL );
-
/**
- * <p>Ouput the current JDOM <code>Document</code> to the output
stream.</p>
- *
* @param stream The output stream
*
* @throws IOException if there are problems writing to the file.
*/
public void write(MappingDocument doc, PrintWriter stream) throws IOException {
- write(doc, stream,false,false);
+ try {
+ XMLOutputFactory xof = XMLOutputFactory.newInstance();
+ writer = xof.createXMLStreamWriter(stream);
+ writer.writeStartDocument("UTF-8", "1.0"); //$NON-NLS-1$
//$NON-NLS-2$
+ writer.writeStartElement(ELEM_ROOT);
+ writeElement(MappingNodeConstants.Tags.DOCUMENT_ENCODING,
doc.getDocumentEncoding());
+ writeElement(MappingNodeConstants.Tags.FORMATTED_DOCUMENT,
Boolean.toString(doc.isFormatted()));
+ loadNode(doc.getRootNode());
+ writer.writeEndElement();
+ writer.writeEndDocument();
+ } catch (XMLStreamException e) {
+ throw new IOException(e);
+ }
}
-
- /**
- * <p>Ouput the current JDOM <code>Document</code> to the output
stream.</p>
- *
- * @param stream The output stream
- * @param newlines true if the output should contain newline characters, or false
otherwise
- * @param indent true if the output should be indented, or false otherwise.
- *
- * @throws IOException if there are problems writing to the file.
- */
- public void write(MappingDocument doc, PrintWriter stream, final boolean newlines,
final boolean indent )
- throws IOException {
-
- String indentString = ""; //$NON-NLS-1$
- if (indent) {
- indentString = " "; //$NON-NLS-1$
- }
- XMLOutputter outputter = new XMLOutputter(JdomHelper.getFormat(indentString,
newlines));
- outputter.output( loadDocument(doc), stream );
+
+ void writeElement(String name, String content) throws XMLStreamException {
+ writer.writeStartElement(name);
+ writer.writeCharacters(content);
+ writer.writeEndElement();
}
// =========================================================================
@@ -94,112 +86,76 @@
/**
* <p>Load XML document from domain object. </p>
+ * @throws XMLStreamException
*/
- Document loadDocument(MappingDocument mappingDoc) {
- Document xmlDoc = new Document(new Element(ELEM_ROOT, namespace));
- setDocumentProperties(mappingDoc, xmlDoc.getRootElement());
-
- loadNode(mappingDoc.getRootNode(), xmlDoc.getRootElement());
- return xmlDoc;
- }
+ void loadNode( MappingNode node ) throws XMLStreamException {
+ writer.writeStartElement(ELEM_NODE);
- /**
- * Set the document spefic properties
- */
- void setDocumentProperties(MappingDocument mappingDoc, Element rootElement) {
- rootElement.addContent(new
Element(MappingNodeConstants.Tags.DOCUMENT_ENCODING).setText(mappingDoc.getDocumentEncoding()));
- rootElement.addContent(new
Element(MappingNodeConstants.Tags.FORMATTED_DOCUMENT).setText(Boolean.toString(mappingDoc.isFormatted())));
- }
-
- /**
- * <p>Load XML document from domain object. </p>
- */
- void loadNode( MappingNode node, Element parentElement ) {
-
- Element element = processNode( node, parentElement );
-
- Iterator children = node.getChildren().iterator();
- while ( children.hasNext() ) {
- MappingNode child = (MappingNode)children.next();
- loadNode( child, element );
- }
- }
-
- /**
- * Process a mapping node, creating an XML element for it.
- */
- Element processNode( MappingNode node, Element parentElement ) {
-
- Element element = new Element( ELEM_NODE, namespace );
- parentElement.addContent( element );
-
//namespace declarations have to be handled specially
Properties namespaces =
(Properties)node.getProperty(MappingNodeConstants.Properties.NAMESPACE_DECLARATIONS);
if (namespaces != null){
- addNamespaceDeclarations(element, namespaces);
+ addNamespaceDeclarations(namespaces);
}
// Only get the property values actually stored in the MappingNode, not
// default values also
Map properties = node.getNodeProperties();
- addElementProperties( element, properties );
+ addElementProperties(properties );
- return element;
+ Iterator children = node.getChildren().iterator();
+ while ( children.hasNext() ) {
+ MappingNode child = (MappingNode)children.next();
+ loadNode( child );
+ }
+ writer.writeEndElement();
}
- private void addNamespaceDeclarations(Element element, Properties namespaces){
+ private void addNamespaceDeclarations(Properties namespaces) throws
XMLStreamException{
Enumeration e = namespaces.propertyNames();
while (e.hasMoreElements()){
String prefix = (String)e.nextElement();
String uri = namespaces.getProperty(prefix);
- Element namespaceDeclaration = new
Element(MappingNodeConstants.Tags.NAMESPACE_DECLARATION, namespace);
+ writer.writeStartElement(MappingNodeConstants.Tags.NAMESPACE_DECLARATION);
if (!prefix.equals(MappingNodeConstants.DEFAULT_NAMESPACE_PREFIX)){
- namespaceDeclaration.addContent( new
Element(MappingNodeConstants.Tags.NAMESPACE_DECLARATION_PREFIX).setText(prefix) );
+ writeElement(MappingNodeConstants.Tags.NAMESPACE_DECLARATION_PREFIX,
prefix);
}
- namespaceDeclaration.addContent( new
Element(MappingNodeConstants.Tags.NAMESPACE_DECLARATION_URI).setText(uri) );
- element.addContent( namespaceDeclaration);
+ writeElement(MappingNodeConstants.Tags.NAMESPACE_DECLARATION_URI, uri);
+ writer.writeEndElement();
}
}
/**
- * Utility to put a property into a map only if the value is not null.
- */
- void addProperty( Map map, String name, Object value ) {
- if ( value != null ) {
- map.put( name, value );
- }
- }
-
- /**
* Add a set of properties to an XML node.
+ * @throws XMLStreamException
*/
- void addElementProperties( Element element, Map properties ) {
+ void addElementProperties(Map properties ) throws XMLStreamException {
Iterator propNames =
MappingNodeConstants.Tags.OUTPUTTER_PROPERTY_TAGS.iterator();
while ( propNames.hasNext() ) {
String propName = (String)propNames.next();
Integer propKey = MappingNodeConstants.getPropertyInteger(propName);
if ( properties.containsKey(propKey) ) {
Object value = properties.get(propKey);
- addElementProperty( element, propName, value );
+ addElementProperty( propName, value );
}
}
}
/**
* Add a single property to an XML node.
+ * @throws XMLStreamException
*/
- void addElementProperty( Element element, String name, Object value ) {
+ void addElementProperty(String name, Object value ) throws XMLStreamException {
if ( value == null ) {
throw new IllegalArgumentException(
QueryPlugin.Util.getString(ErrorMessageKeys.MAPPING_0010, name) );
}
if (value instanceof Collection){
Iterator i = ((Collection)value).iterator();
while (i.hasNext()) {
- element.addContent( new
Element(name,namespace).setText(getXMLText(i.next())));
+ writeElement(name, getXMLText(i.next()));
}
} else {
- element.addContent( new Element(name,namespace).setText(getXMLText(value)));
+ writeElement(name, getXMLText(value));
}
}
Modified:
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java 2010-07-12
20:59:02 UTC (rev 2333)
+++
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java 2010-07-13
01:29:08 UTC (rev 2334)
@@ -26,14 +26,13 @@
import java.io.FileInputStream;
import java.util.List;
+import junit.framework.TestCase;
+
import org.teiid.core.util.UnitTestUtil;
import org.teiid.query.function.metadata.FunctionMetadataReader;
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.function.metadata.FunctionParameter;
-
-import junit.framework.TestCase;
-
public class TestFunctionMetadataReader extends TestCase {
public void testLoadFunctionMethods() throws Exception {
Modified:
trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java 2010-07-12
20:59:02 UTC (rev 2333)
+++
trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java 2010-07-13
01:29:08 UTC (rev 2334)
@@ -29,8 +29,6 @@
import net.sf.saxon.trans.XPathException;
-import org.jdom.Attribute;
-import org.jdom.Element;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -61,43 +59,6 @@
return XMLSystemFunctions.xpathValue(xmlContent,xpath);
}
- public void helpCheckElement(final Object jdomNode, final String name, final String
prefix, final String namespaceUri,
- final String textContent) {
- assertTrue("Supplied JDOM node is not an Element", jdomNode instanceof
Element); //$NON-NLS-1$
- final Element element = (Element)jdomNode;
- assertEquals(name, element.getName());
- assertEquals(prefix, element.getNamespacePrefix());
- assertEquals(namespaceUri, element.getNamespaceURI());
-
- final String actualTextContent = element.getText();
- if (textContent == null) {
- assertEquals(0, actualTextContent.length());
- } else {
- assertEquals(textContent, actualTextContent);
- }
- }
-
- public void helpCheckElement(final Object jdomNode, final String name, final String
prefix, final String namespaceUri) {
- assertTrue("Supplied JDOM node is not an Element", jdomNode instanceof
Element); //$NON-NLS-1$
- final Element element = (Element)jdomNode;
- assertEquals(name, element.getName());
- assertEquals(prefix, element.getNamespacePrefix());
- assertEquals(namespaceUri, element.getNamespaceURI());
- }
-
- public void helpCheckAttribute(final Object jdomNode, final String name,
- final String prefix, final String namespaceUri,
- final String value ) {
- assertTrue("Supplied JDOM node is not an Attribute",jdomNode instanceof
Attribute); //$NON-NLS-1$
- final Attribute attribute = (Attribute)jdomNode;
- assertEquals(name,attribute.getName());
- assertEquals(prefix,attribute.getNamespacePrefix());
- assertEquals(namespaceUri,attribute.getNamespaceURI());
-
- final String actualTextContent = attribute.getValue();
- assertEquals(value,actualTextContent);
- }
-
@Test public void testElement() throws Exception {
String doc = "<?xml version=\"1.0\"
encoding=\"utf-8\"
?><a><b><c>test</c></b></a>"; //$NON-NLS-1$
String xpath = "a/b/c"; //$NON-NLS-1$
Modified:
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java 2010-07-12
20:59:02 UTC (rev 2333)
+++
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java 2010-07-13
01:29:08 UTC (rev 2334)
@@ -29,6 +29,8 @@
import java.io.StringWriter;
import java.util.ArrayList;
+import javax.xml.bind.JAXBException;
+
import org.teiid.query.mapping.xml.MappingAttribute;
import org.teiid.query.mapping.xml.MappingChoiceNode;
import org.teiid.query.mapping.xml.MappingCriteriaNode;
Modified: trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
---
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-07-12
20:59:02 UTC (rev 2333)
+++
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-07-13
01:29:08 UTC (rev 2334)
@@ -31,6 +31,8 @@
import java.util.Arrays;
import java.util.Collection;
+import javax.xml.bind.JAXBException;
+
import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.FileUtils;
@@ -84,6 +86,8 @@
return vdbmetadata;
} catch (URISyntaxException e) {
throw new IOException(e);
+ } catch (JAXBException e) {
+ throw new IOException(e);
}
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-07-12 20:59:02 UTC (rev 2333)
+++ trunk/pom.xml 2010-07-13 01:29:08 UTC (rev 2334)
@@ -355,11 +355,6 @@
<!-- External dependencies -->
<dependency>
- <groupId>jdom</groupId>
- <artifactId>jdom</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
<groupId>javax.resource</groupId>
<artifactId>connector-api</artifactId>
<version>1.5</version>
Modified: trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2010-07-12 20:59:02
UTC (rev 2333)
+++ trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2010-07-13 01:29:08
UTC (rev 2334)
@@ -26,6 +26,8 @@
import java.util.Collection;
import java.util.HashMap;
+import javax.xml.bind.JAXBException;
+
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.virtual.VirtualFile;
import org.teiid.query.function.metadata.FunctionMetadataReader;
@@ -44,7 +46,7 @@
}
- void buildFunctionModelFile(String name) throws IOException {
+ void buildFunctionModelFile(String name) throws IOException, JAXBException {
VirtualFile file = this.files.get(name);
if (file != null) {
this.methods.addAll(FunctionMetadataReader.loadFunctionMethods(file.openStream()));
Copied: trunk/test-integration/db/src/test/java/org/teiid/internal/core/xml (from rev
2323, trunk/engine/src/main/java/org/teiid/internal/core/xml)