Author: van.halbert
Date: 2012-04-24 12:22:56 -0400 (Tue, 24 Apr 2012)
New Revision: 4029
Added:
branches/7.7.x/connectors/translator-object/
branches/7.7.x/connectors/translator-object/Notes.txt
branches/7.7.x/connectors/translator-object/pom.xml
branches/7.7.x/connectors/translator-object/src/
branches/7.7.x/connectors/translator-object/src/main/
branches/7.7.x/connectors/translator-object/src/main/java/
branches/7.7.x/connectors/translator-object/src/main/java/org/
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecution.java
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecutionFactory.java
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectMethodManager.java
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectPlugin.java
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectProjections.java
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectSourceProxy.java
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectTranslator.java
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheExecutionFactory.java
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheObjectVisitor.java
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheProxy.java
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/util/
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/util/ObjectMethodUtil.java
branches/7.7.x/connectors/translator-object/src/main/resources/
branches/7.7.x/connectors/translator-object/src/main/resources/org/
branches/7.7.x/connectors/translator-object/src/main/resources/org/teiid/
branches/7.7.x/connectors/translator-object/src/main/resources/org/teiid/translator/
branches/7.7.x/connectors/translator-object/src/main/resources/org/teiid/translator/object/
branches/7.7.x/connectors/translator-object/src/main/resources/org/teiid/translator/object/i18n.properties
branches/7.7.x/connectors/translator-object/src/test/
branches/7.7.x/connectors/translator-object/src/test/java/
branches/7.7.x/connectors/translator-object/src/test/java/org/
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/BaseObjectTest.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectExecution.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectExecutionFactory.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectMethodManager.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectProjections.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectTranslator.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/example/
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/example/TestMapCacheIntegration.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/example/TestMapCacheVisitor.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Leg.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Trade.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/TradesCacheSource.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Transaction.java
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/VDBUtility.java
branches/7.7.x/connectors/translator-object/src/test/resources/
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetColumns.expected
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTableTypes.expected
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables.expected
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables_for3ClassNames.expected
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables_ofSpecificTableType.expected
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor1Class.expected
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor2Classes.expected
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor3Classes.expected
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/Trade.vdb
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/Trade_Object.xmi
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/Trade_View.xmi
branches/7.7.x/connectors/translator-object/src/test/resources/testQueryIncludeLegs.expected
Log:
TEIID-1992 initial commit that provides the core infrastructure for translating objects
into results
Added: branches/7.7.x/connectors/translator-object/Notes.txt
===================================================================
--- branches/7.7.x/connectors/translator-object/Notes.txt (rev 0)
+++ branches/7.7.x/connectors/translator-object/Notes.txt 2012-04-24 16:22:56 UTC (rev
4029)
@@ -0,0 +1,51 @@
+Notes:
+
+Limitations -
+
+1. There is no current support for 2 or more classes named the same (but different
packages) in the same model.
+ The table name will be the name of the class, not the full classname.
+
+
+
+
+Modeling -
+
+- JavaBean convention is used. The column name (or nameinsource if used) are used in
finding the get/is method.
+
+ Example:
+ Object: Trade
+ Attribute: TradeId (getter/setter: getTradeId/setTradeId)
+
+ in the Designer, if the column name is not the name of the a attribute, then the
nameInSource will have to be set to the Attribute name
+ example: columnName: TRADE_ID
+ nameInSource: TradeId
+
+ The process of getting the trade id value from the Trade object will take the
nameInSource (if not provided, then use column name) and prepend "get".
+ Therefore, the method name: getTradeId must exist on the Trade object.
+
+
+- A model should have the hierarchical structure of a class normalized. Meaning, any
container based objects
+ (i.e., Collections, Arrays, etc.) must have a separate table defined and have a foreign
key relationship to
+ its parent table/object.
+- The table defined for the root object must have a primary key defined, which is the
key to it being found in the cache
+- If an object has children, then the following must occur:
+ a. parent and child tables need a primary key
+ b. if the child object does not contain a reference to the parent object, then the
child table will need to have
+ a column added that can be used in the creation of the foreign key (see "c"
below) and used in joins
+ NOTE: set these properties on the new column:
+ - Searchability=UNSEARCHABLE
+ - Selectable=false
+ - Updateable=false
+ c. create the foreign key relationship between parent child, where the NameInSource for
the FK being the method
+ to access child objects.
+ d. the attribute on an object that is the container object, should not be modeled as an
attribute in the table.
+ This is because its not directly queryable. It should have a related child table,
which has a foreign key
+ (see b and c above).
+
+
+
+
+TODO:
+
+- when importing metadata, make the Object types (of return types, collections, etc)
non-selectable, because they need
+ to have their own table created and then a foreign key back to the parent table.
\ No newline at end of file
Added: branches/7.7.x/connectors/translator-object/pom.xml
===================================================================
--- branches/7.7.x/connectors/translator-object/pom.xml (rev 0)
+++ branches/7.7.x/connectors/translator-object/pom.xml 2012-04-24 16:22:56 UTC (rev
4029)
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>connectors</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>7.7.1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>translator-object</artifactId>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <name>Object Translator</name>
+ <description>This is the translator for Object(s)</description>
+ <properties>
+ <version.infinispan>5.1.2.FINAL</version.infinispan>
+ <version.hibernate.search>4.1.0.CR1</version.hibernate.search>
+ </properties>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-client</artifactId>
+ <type>test-jar</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-metadata</artifactId>
+ <type>test-jar</type>
+ <scope>provided</scope>
+ </dependency>
+
+<!--
+ <dependency>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-core</artifactId>
+ <version>${version.infinispan}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-query</artifactId>
+ <version>${version.infinispan}</version>
+ </dependency>
+ -->
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-search</artifactId>
+ <version>${version.hibernate.search}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <outputDirectory>target/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>**/*.xml</exclude>
+ <exclude>**/*.properties</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
+
+</project>
Added:
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecution.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecution.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecution.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.object;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.language.Command;
+import org.teiid.language.Select;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorException;
+
+
+/**
+ * Execution of the SELECT Command
+ */
+public class ObjectExecution implements ResultSetExecution {
+
+ private Select query;
+ private ObjectSourceProxy proxy;
+ private ObjectExecutionFactory factory;
+
+ @SuppressWarnings("rawtypes")
+ private Iterator resultsIt = null;
+
+ public ObjectExecution(Command query, RuntimeMetadata metadata, ObjectSourceProxy
connproxy, ObjectExecutionFactory factory) {
+ this.query = (Select) query;
+ this.proxy = connproxy;
+ this.factory = factory;
+ }
+
+ @Override
+ public void execute() throws TranslatorException {
+
+ LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Object executing command:
" + query.toString()); //$NON-NLS-1$
+
+ List<Object> objects = executeQuery();
+
+ List<List<?>> results = null;
+ if (objects != null && objects.size() > 0) {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "ObjectExecution number of
objects from proxy is : " + objects.size()); //$NON-NLS-1$
+
+ ObjectProjections op = new ObjectProjections(query);
+
+ results = ObjectTranslator.translateObjects(objects, op,
factory.getObjectMethodManager());
+
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "ObjectExecution number of rows
from translation : " + results.size()); //$NON-NLS-1$
+
+ } else {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "ObjectExecution number of
objects from proxy is : 0"); //$NON-NLS-1$
+
+ results = Collections.emptyList();
+ }
+
+
+ this.resultsIt = results.iterator();
+ }
+
+ protected List<Object> executeQuery()
+ throws TranslatorException {
+
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "ObjectExecution calling
proxy : " + this.proxy.getClass().getName()); //$NON-NLS-1$
+
+ return this.proxy.get(query);
+
+ }
+
+ @Override
+ public List<Object> next() throws TranslatorException,
DataNotAvailableException {
+ // create and return one row at a time for your resultset.
+ if (resultsIt.hasNext()) {
+ return (List<Object>) resultsIt.next();
+ }
+ return null;
+ }
+
+
+ @Override
+ public void close() {
+ this.proxy.close();
+ this.proxy = null;
+
+ }
+
+ @Override
+ public void cancel() throws TranslatorException {
+ //TODO: initiate the "abort" of execution
+ }
+
+
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecutionFactory.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecutionFactory.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecutionFactory.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.object;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.teiid.language.QueryExpression;
+import org.teiid.language.Select;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TranslatorProperty;
+
+/**
+ * The ObjectExecutionFactory is a base implementation of the ExecutionFactory.
+ * For each implementor, the {@link #createProxy(Object)} method will need to be
+ * implemented in order to provide the data source specific implementation for
+ * query execution.
+ *
+ *
+ * @author vhalbert
+ *
+ */
+
+public abstract class ObjectExecutionFactory extends ExecutionFactory<Object,
Object> {
+ public static final int MAX_SET_SIZE = 100;
+
+ /*
+ * ObjectMethodManager is the cache of methods used on the objects.
+ * Each ExecutionFactory instance will maintain its own method cache.
+ */
+ private ObjectMethodManager objectMethods=null;
+
+ private boolean columnNameFirstLetterUpperCase = true;
+
+
+ public ObjectExecutionFactory() {
+ super();
+ init();
+ }
+
+ protected void init() {
+ this.setMaxInCriteriaSize(MAX_SET_SIZE);
+ this.setMaxDependentInPredicates(1);
+ this.setSourceRequired(false);
+ this.setSupportsOrderBy(false);
+ this.setSupportsSelectDistinct(false);
+ this.setSupportsInnerJoins(true);
+ this.setSupportsFullOuterJoins(false);
+ this.setSupportsOuterJoins(true);
+ }
+
+ @Override
+ public void start() throws TranslatorException {
+ objectMethods = ObjectMethodManager.initialize(isColumnNameFirstLetterUpperCase(),
this.getClass().getClassLoader());
+ }
+
+ @Override
+ public ResultSetExecution createResultSetExecution(QueryExpression command,
ExecutionContext executionContext, RuntimeMetadata metadata, Object connection)
+ throws TranslatorException {
+ return new ObjectExecution((Select)command, metadata, createProxy(connection),
this);
+ }
+
+ public List getSupportedFunctions() {
+ return Collections.EMPTY_LIST;
+ }
+
+ public boolean supportsCompareCriteriaEquals() {
+ return true;
+ }
+
+
+ /**
+ * <p>
+ * The {@link #getColumnNameFirstLetterUpperCase() option, when
<code>false</code>, indicates that the column name (or nameInSource when
specified)
+ * will start with a lower case. This is an option because some users prefer (or
standardize) on names being lower case or have a
+ * different case naming structure.
+ * <p/>
+ * <p>
+ * The case matters for the following reasons:
+ * <li>Deriving the "getter/setter" method on the object to read the
value. Because JavaBean naming convention
+ * is used.</li>
+ * <li>Building criteria logic for searching the datasource. This one is
functionality specific (i.e., Hibernate Search)
+ * as to how it maps the column name to an indexed field. </li>
+ * </p>
+ * @return boolean indicating if the case of the first letter of the column name (or
nameInSource when specified), default <code>true</code>
+ */
+ @TranslatorProperty(display="ColumnNameFirstLetterUpperCase", advanced=true)
+ public boolean isColumnNameFirstLetterUpperCase() {
+ return this.columnNameFirstLetterUpperCase;
+ }
+
+ /**
+ * <p>
+ * The {@link #columnNameFirstLetterUpperCase} option, when
<code>false</code>, indicates that the column name (or nameInSource when
specified)
+ * will start with a lower case. This is an option because some users prefer (or
standardize) on names being lower case or have a
+ * different case naming structure.
+ * <p/>
+ * <p>
+ * The case matters for the following reasons:
+ * <li>Deriving the "getter/setter" method on the object to read the
value. Because JavaBean naming convention
+ * is used.</li>
+ * <li>Building criteria logic for searching the datasource. This one is
functionality specific (i.e., Hibernate Search)
+ * as to how it maps the column name to an indexed field. </li>
+ * </p>
+ * @param firstLetterUpperCase indicates the case of the first letter in the column name
(or nameInSource when specified), default <code>true</code>
+ * @return
+ */
+ public void setColumnNameFirstLetterUpperCase(boolean firstLetterUpperCase) {
+ this.columnNameFirstLetterUpperCase = firstLetterUpperCase;
+ }
+
+
+ @Override
+ public void getMetadata(MetadataFactory metadataFactory, Object conn)
+ throws TranslatorException {
+ if (objectMethods != null) {
+ objectMethods = ObjectMethodManager.initialize(isColumnNameFirstLetterUpperCase(),
this.getClass().getClassLoader());
+ }
+ }
+
+
+
+ public ObjectMethodManager getObjectMethodManager() {
+ return this.objectMethods;
+ }
+
+ /**
+ * Implement to return an instance of {@link ObjectSourceProxy proxy} that is used
+ * by {@link ObjectExecution execution} to issue requests.
+ * @param connection
+ * @return IObjectConnectionProxy
+ * @throws TranslatorException
+ */
+ protected abstract ObjectSourceProxy createProxy(Object connection) throws
TranslatorException ;
+
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectMethodManager.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectMethodManager.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectMethodManager.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,275 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.object;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.teiid.core.util.StringUtil;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.object.util.ObjectMethodUtil;
+
+/**
+ * ObjectMethodManager caches the methods for the classes that
+ * are being utilized, and provides utility methods for finding a method
+ * and executing.
+ */
+public class ObjectMethodManager extends ConcurrentHashMap<String, Object> { //
className, ClassMethods
+ public static final String GET = "get";
+ public static final String SET = "set";
+ public static final String IS = "is";
+
+ public final class ClassMethods {
+
+ private Class<?> clz = null;
+ private Map<String, Method> getters = new HashMap<String, Method>(10);
+ private Map<String, Method> setters = new HashMap<String, Method>(10);
+ private Map<String, Method> is = new HashMap<String, Method>(5);
+
+ ClassMethods(final Class<?> clzz) {
+ this.clz = clzz;
+ }
+
+ String getClassName() {
+ return this.clz.getName();
+ }
+
+ public Map<String, Method> getGetters() {
+ return getters;
+ }
+
+ void addGetter(String methodName, Method g) {
+ this.getters.put(methodName, g);
+ }
+
+ Method getGetMethod(String name) {
+ return this.getters.get(name);
+ }
+
+ public Map<String, Method> getSetters() {
+ return setters;
+ }
+
+ void addSetter(String methodName, Method s) {
+ this.setters.put(methodName, s);
+ }
+
+ Method getSetMethod(String name) {
+ return this.setters.get(name);
+ }
+
+ public Map<String, Method> getIses() {
+ return this.is;
+ }
+
+ void addIsMethod(String methodName, Method i) {
+ this.is.put(methodName, i);
+ }
+
+ Method getIsMethod(String name) {
+ return this.is.get(name);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public static ObjectMethodManager initialize(boolean firstLetterUpperCaseInColumName,
ClassLoader classloader) throws TranslatorException {
+ return loadClassMethods(Collections.EMPTY_LIST, firstLetterUpperCaseInColumName,
classloader);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static ObjectMethodManager initialize(String commaSeparatedNames, boolean
firstLetterUpperCaseInColumName, ClassLoader classloader) throws TranslatorException {
+ List<String> classNames = null;
+ if (commaSeparatedNames != null) {
+ classNames = StringUtil.getTokens(commaSeparatedNames, ",");
+ } else {
+ classNames = Collections.EMPTY_LIST;
+ }
+ return loadClassMethods(classNames, firstLetterUpperCaseInColumName, classloader);
+ }
+
+ public static ObjectMethodManager loadClassMethods(List<String> classNames,
boolean firstLetterUpperCaseInColumName, ClassLoader classloader) throws
TranslatorException {
+
+ ObjectMethodManager osmm = new ObjectMethodManager(firstLetterUpperCaseInColumName);
+
+ for (String clzName: classNames) {
+ osmm.loadClassByName(clzName, classloader);
+ }
+
+ return osmm;
+ }
+
+ public Class<?> loadClassByName(String className, ClassLoader classLoader) throws
TranslatorException {
+ ClassMethods clzzMethods = getClassMethods(className);
+ if (clzzMethods == null) {
+ Class<?> clz = loadClass(className, classLoader);
+ clzzMethods = loadClassMethods(clz);
+ return clz;
+ }
+ return clzzMethods.getClass();
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8576602118928356693L;
+
+ private ObjectMethodManager(boolean firstLetterUpperCaseInColumName) {
+ this.firstLetterUpperCaseInColumName = firstLetterUpperCaseInColumName;
+ }
+
+ private ClassMethods loadClassMethods(Class<?> clzz) {
+ Method[] methods = clzz.getDeclaredMethods();
+ ClassMethods clzMethods = new ClassMethods(clzz);
+
+ for (int i=0; i<methods.length; i++) {
+ Method m = methods[i];
+ if (m.getName().startsWith(GET)) {
+ clzMethods.addGetter(m.getName(), m);
+ // commenting out the caching of the setter methods
+// } else if (m.getName().startsWith(SET)) {
+// clzMethods.addSetter(m.getName(), m);
+ } else if (m.getName().startsWith(IS)) {
+ clzMethods.addIsMethod(m.getName(), m);
+ }
+ }
+ this.put(clzz.getName(), clzMethods);
+ return clzMethods;
+ }
+
+ public Object getIsValue(String methodName, Object object)
+ throws TranslatorException {
+
+ final Method m = findIsMethod(object.getClass(), methodName);
+ if (m == null) {
+ throw new TranslatorException(
+ ObjectPlugin.Util
+ .getString(
+ "ObjectMethodManager.noMethodFound", new Object[] { methodName,
object.getClass().getName() })); //$NON-NLS-1$
+ }
+ return ObjectMethodUtil.executeMethod(m, object, (Object[]) null);
+ }
+
+ public Object getGetValue(String methodName, Object object)
+ throws TranslatorException {
+
+ final Method m = findGetterMethod(object.getClass(), methodName);
+ if (m == null) {
+ throw new TranslatorException(
+ ObjectPlugin.Util
+ .getString(
+ "ObjectMethodManager.noMethodFound", new Object[] {methodName,
object.getClass().getName()})); //$NON-NLS-1$
+ }
+ return ObjectMethodUtil.executeMethod(m, object, (Object[]) null);
+ }
+
+ public Object setValue(String methodName, Object object)
+ throws TranslatorException {
+
+ final Method m = findSetterMethod(object.getClass(), methodName);
+ if (m == null) {
+ throw new TranslatorException(
+ ObjectPlugin.Util
+ .getString(
+ "ObjectMethodManager.noMethodFound", new Object[] { methodName,
object.getClass().getName() })); //$NON-NLS-1$
+ }
+ List<Object> parms = new ArrayList<Object>(1);
+ parms.add(object);
+ return ObjectMethodUtil.executeMethod(m, object, parms);
+ }
+
+ public Method findGetterMethod(Class<?> api, String methodName) throws
TranslatorException {
+ return getClassMethods(api).getGetMethod(methodName);
+ }
+
+ public Method findSetterMethod(Class<?> api, String methodName) throws
TranslatorException {
+ return getClassMethods(api).getSetMethod(methodName);
+ }
+
+ public Method findIsMethod(Class<?> api, String methodName) throws
TranslatorException {
+ return getClassMethods(api).getIsMethod(methodName);
+ }
+
+
+ /**
+ * Call to format the method name based on how the columnName (NameInSource) is being
modeled.
+ * If its not UpperCase, then the first character will be UpperCased. This is done so
that the
+ * method name follows the JavaBeans naming convention (i.e., getMethod or setMethod)
+ * @param prefix it the value is the fist part of the method name (i.e, get,set,is)
+ * @param columnName is the attribute to calling get,set or is on the object
+ * @param columNameStartsWithUpperCase is a boolean, indicating if the first character
is UpperCased.
+ * @return
+ * @see ObjectExecutionFactory#firstLetterUpperCaseInColumName()
+ */
+ public String formatMethodName(String prefix, String columnName) {
+ if (this.firstLetterUpperCaseInColumName) return prefix + columnName;
+
+ return prefix + columnName.substring(0, 1).toUpperCase() + columnName.substring(1);
+ }
+
+
+ public boolean isFirstLetterUpperCaseInColumName() {
+ return this.firstLetterUpperCaseInColumName;
+ }
+
+ public static final Class<?> loadClass(final String className,
+ final ClassLoader classLoader) throws TranslatorException {
+ try {
+ Class<?> cls = null;
+ if (classLoader == null) {
+ cls = Class.forName(className.trim());
+ } else {
+ cls = Class.forName(className.trim(), true, classLoader);
+ }
+ return cls;
+
+ } catch (ClassNotFoundException e) {
+ throw new TranslatorException(
+ ObjectPlugin.Util
+ .getString(
+ "ObjectMethodManager.objectClassNotFound", new Object[] {className}));
//$NON-NLS-1$
+ }
+
+ }
+
+ public ClassMethods getClassMethods(String className) {
+ return (ClassMethods) this.get(className);
+ }
+
+ private ClassMethods getClassMethods(Class<?> api) throws TranslatorException {
+ ClassMethods clzMethods = getClassMethods(api.getName());
+ if (clzMethods == null) {
+ loadClassMethods(api);
+ clzMethods = this.getClassMethods(api);
+ }
+ return clzMethods;
+
+ }
+ private boolean firstLetterUpperCaseInColumName = true;
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectPlugin.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectPlugin.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectPlugin.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object;
+
+import java.util.ResourceBundle;
+
+import org.teiid.core.BundleUtil;
+
+
+/**
+ * CoherencePlugin
+ */
+public class ObjectPlugin {
+
+ public static final String PLUGIN_ID = "org.teiid.translator.object" ;
//$NON-NLS-1$
+
+ /**
+ * Provides access to the plugin's log and to it's resources.
+ */
+ public static final BundleUtil Util = new BundleUtil(PLUGIN_ID, PLUGIN_ID +
".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$
//$NON-NLS-2$
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectProjections.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectProjections.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectProjections.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,194 @@
+package org.teiid.translator.object;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.core.util.StringUtil;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Select;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.ForeignKey;
+import org.teiid.metadata.KeyRecord;
+import org.teiid.metadata.Table;
+import org.teiid.translator.TranslatorException;
+
+public class ObjectProjections {
+ // Columns that are in the select clause
+ protected Column[] columns = null; // columnNameToUse, Column in select
+ // The columnNameToUse could be either
+ // - name in source
+ // - if its a child column, then it will be {FK name in source}.{name in source}
+ protected String[] columnNamesToUse = null;
+
+ protected List<String>[] nameNodes = null;
+ protected int[] nodeDepth = null; // values are zero based, anything greater than zero
indicates there children involved
+
+ // this is the number of children deep this query is requesting information
+ protected int childrenDepth = -1; //
+ protected List<String> childrenNodes = null;
+
+ protected List<String> exceptionMessages = new ArrayList<String>(2);
+
+
+ public ObjectProjections(Select query) {
+ parse(query);
+ }
+
+ public Column[] getColumns() {
+ return this.columns;
+ }
+
+ public String[] getColumnNamesToUse() {
+ return this.columnNamesToUse;
+ }
+
+ public boolean hasChildren() {
+ return (childrenDepth > -1);
+ }
+
+ @SuppressWarnings("unchecked")
+ private void parse(Select query) {
+
+ Iterator<DerivedColumn> selectSymbolItr = query.getDerivedColumns().iterator();
+
+ int s = query.getDerivedColumns().size();
+ columns = new Column[s];
+ columnNamesToUse = new String[s];
+ nameNodes = new ArrayList[s];
+ nodeDepth = new int[s];
+
+ String maxDepthColumnNameToUse = null;
+
+ int i=0;
+ while(selectSymbolItr.hasNext()) {
+ columns[i] = getColumnFromSymbol(selectSymbolItr.next());
+ columnNamesToUse[i] = getColumnNameToUse(columns[i]);
+
+ nameNodes[i] = StringUtil.getTokens(columnNamesToUse[i], ".");
+ nodeDepth[i] = nameNodes[i].size() - 1; // if one node name, then depth is zero, and
incremented from there
+
+ // only when there are multiple node names will a container be involved
+ if (nodeDepth[i] > 0) {
+ if (childrenDepth == -1) {
+ childrenDepth = nodeDepth[i];
+ // strip off the the child node names (excluding the last node, which is the value
call)
+ maxDepthColumnNameToUse = columnNamesToUse[i].substring(0,
columnNamesToUse[i].lastIndexOf("."));
+ childrenNodes = nameNodes[i];
+ } else {
+ // if the columns are not on the same path, then this is an error,
+ // can only support one child path per query
+ if (!columnNamesToUse[i].startsWith(maxDepthColumnNameToUse)) {
+ addException(maxDepthColumnNameToUse, columnNamesToUse[i],
columns[i].getParent().getName());
+ }
+
+ if ( nodeDepth[i] > childrenDepth) {
+ childrenDepth = nodeDepth[i];
+ childrenNodes = nameNodes[i];
+ }
+
+ }
+ }
+
+ i++;
+ }
+
+ }
+
+
+ private void addException(String columnNameToUse1,
+ String columnNameToUse2, String table) {
+ exceptionMessages.add(
+ "Query Error: multiple collections found between columns "
+ + columnNameToUse1 + " and " + columnNameToUse2
+ + " (table: " + table + " ) ");
+ }
+
+ protected void throwExceptionIfFound() throws TranslatorException {
+ if (!exceptionMessages.isEmpty())
+ throw new TranslatorException("ObjectProjections Exception: " +
exceptionMessages.toString());
+ }
+
+ public String getColumnNameToUse(Column column) {
+ String nis = getNameInSourceForObjectHierarchy(column);
+ if (nis == null) return column.getName();
+ return nis;
+ }
+
+ /**
+ * Method to build the nameInSource nodes to be used to lookup a value, starting with
the root object.
+ * If the column is associated with a table that has a foreign key (i.e, is contained
within), use the nameInSource
+ * of the foreign key as a prefix node in the nameInSource. The process will climb the
foreign key hierarchy tree to
+ * combine to make the NameInSource for the column.
+ * Example: Object hierarchy: "A" = getLegs => "B" =
getTransactions => "C"
+ * The column object would start with "C" and find a foreign key to
"B", having nameInSource of "Transactions"
+ * current nodes in the name are: Transactions."C"
+ *
+ * The process then takes object "B" and determines it has a foreign key to
"A", its nameInSource is "Legs", which is prefixed on the nodes
names.
+ * current nodes in the name are: Legs.Transactions."C"
+ *
+ * The node name structure will allow the object reflection process to traverse the root
object to get to "C" by taking the first node, Legs,
+ * and calling "A".getLegs(), and then processing each object in the
collection by calling "B".getTransations().
+ *
+ * @param e the supplied Element
+ * @return the name
+ */
+ // GHH 20080326 - found that code to fall back on Name if NameInSource
+ // was null wasn't working properly, so replaced with tried and true
+ // code from another custom connector.
+ protected String getNameInSourceForObjectHierarchy(Column e) {
+ String nis = getNameInSourceFromColumn(e);
+
+ Object p = e.getParent();
+ // if the column comes from a table that has a foreign key, then
+ // preprend the nameInSource with the foreign key nameInSource
+ //NOTE: the foreign key NIS should be the name of the container method to find the
column
+ String parentNodeName = null;
+ if (p instanceof Table) {
+ parentNodeName = getForeignKeyNodeName((Table) p);
+ }
+
+ return (parentNodeName != null ? parentNodeName + "." : "") + nis;
+ }
+
+
+ protected String getNameInSourceFromColumn(Column c) {
+ String name = c.getNameInSource();
+ if(name == null || name.equals("")) { //$NON-NLS-1$
+ return c.getName();
+ }
+ return name;
+ }
+
+
+ protected String getForeignKeyNodeName(Table t) {
+ if (t == null) return null;
+
+ if (t.getForeignKeys() != null && !t.getForeignKeys().isEmpty()) {
+ ForeignKey fk = (ForeignKey) t.getForeignKeys().get(0);
+ String fk_nis = fk.getNameInSource();
+
+ KeyRecord kr = fk.getPrimaryKey();
+ if (kr.getParent() != null) {
+ String parentNIS = getForeignKeyNodeName(kr.getParent());
+
+ return (parentNIS != null ? parentNIS + "." : "") + fk_nis;
+ }
+ return fk_nis;
+ }
+
+ return null;
+ }
+
+ /**
+ * Helper method for getting {@link org.teiid.metadata.Column} from a
+ * {@link org.teiid.language.DerivedColumn}.
+ * @param symbol Input ISelectSymbol
+ * @return Element returned metadata runtime Element
+ */
+ protected Column getColumnFromSymbol(DerivedColumn symbol) {
+ ColumnReference expr = (ColumnReference) symbol.getExpression();
+ return expr.getMetadataObject();
+ }
+}
Added:
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectSourceProxy.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectSourceProxy.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectSourceProxy.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object;
+
+import java.util.List;
+
+import org.teiid.language.Command;
+import org.teiid.translator.TranslatorException;
+
+/**
+ * <p>
+ * ObjectSourceProxy interface is how the translator will ask for objects from the cache
based on
+ * the {@link Command}. The visitor will provide a parsed query such that the
+ * the proxy implementor can use the criteria to perform vendor specific logic to obtain
+ * objects from the cache.
+ * </p>
+ * <p>
+ * The specific proxy implementation will be instantiated by {@link
ObjectExecutionFactory}.
+ * Passing in the connection object and ObjectExecutionFactory.
+ * </P
+ *
+ * @author vhalbert
+ *
+ */
+
+public interface ObjectSourceProxy {
+
+ /**
+ * Called by {@link ObjectExecution}, passing in the sql
<code>command</code>, to obtain the objects from
+ * the cache based. The implementor will need to parse the command and interpret the
criteria according
+ * to data source query syntax.
+ * @param command is the SELECT command to query the data source
+ * @return List of objects found in the cache.
+ * @throws TranslatorException is thrown if there are issues querying the data source
+ */
+ List<Object> get(Command command) throws TranslatorException;
+
+
+ /**
+ * Called when this instance has completed its logical task. This may include closing
the connection, if that makes sence.
+ */
+ void close();
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectTranslator.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectTranslator.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectTranslator.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,295 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.object;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.teiid.translator.TranslatorException;
+
+/**
+ * The ObjectTranslator is the responsible for introspection of an object and turning it
into rows.
+ *
+ * This will use reflections, based on model metadata, to invoke methods on the objects
+ *
+ * @author vhalbert
+ *
+ */
+public class ObjectTranslator {
+
+ public enum CONTAINER_TYPE {
+ COLLECTION,
+ ARRAY,
+ MAP
+ }
+
+ /**
+ * <p>
+ * Called to translate the list of <code>objects</code> returned from the
+ * cache. The <code>projections</code> will be used to drive what
information on
+ * the objects that will be obtained.
+ * </p>
+ * <p>
+ * The assumptions in converting objects to relational are as follows:
+ * <li>its assumed the objects have been normalized when modeled, not
de-normalized. The object is de-normalized
+ * if table or view is defined to have multiple container objects (ie., Maps, List,
etc.) returned
+ * in the same source query.
+ * <p> Example:
+ * Object X
+ * Attributes: Name
+ * Addresses (List)
+ * Phones (List)
+ * Object X is mapped to Table A
+ * Name
+ * Street
+ * City
+ * State
+ * Phone_Number
+ *
+ * To model this correctly, you would create 2 Tables (A and B):
+ * Table A
+ * Name, Street, City, State
+ * Table B
+ * Name, Phone_Number
+ *
+ * If the user wants a cross-product result, then allow the Teiid engine to perform
that logic, but the Translator
+ * will only traverse one container path per result set. I say container path,
because it will be possible for
+ * an object in a container to define another container object, and so on.
Theoretically, there is no depth limit.
+ * <li></li>
+ * @param objects is the List of objects from the cache
+ * @param projections are the columns to be returned in the result set
+ * @param objectManager is responsible for providing the object methods used for
traversing an object and/or
+ * obtaining the data from an object
+ * @return List<List<?>> that represent the rows and columns in the result
set
+ */
+ public static List<List<?>> translateObjects(List<Object> objects,
ObjectProjections projections, ObjectMethodManager objectManager) throws
TranslatorException {
+
+ projections.throwExceptionIfFound();
+
+ List<List<?>> rows = new
ArrayList<List<?>>(objects.size());
+
+ // if no container objects required in the results, then
+ // perform simple logic for building a row
+ int numCols = projections.columnNamesToUse.length;
+
+ if (!projections.hasChildren()) {
+ for (Iterator<Object> it = objects.iterator(); it.hasNext();) {
+ // each object represent 1 row
+ Object o = (Object) it.next();
+
+ List<Object> row = new ArrayList<Object>(numCols);
+ for (int i = 0; i < numCols; i++) {
+ Object value = getValue(o, i, 0, projections, objectManager);
+
+ row.add(value);
+ }
+
+ rows.add(row);
+ }
+
+ return rows;
+ }
+
+ for (Iterator<Object> it = objects.iterator(); it.hasNext();) {
+ // each object represent 1 row, but will be expanded, if a
+ // collection is found in its results
+ Object o = (Object) it.next();
+
+ List<List<Object>> containerRows = processContainer(o, 0, projections,
objectManager);
+
+ rows.addAll(containerRows);
+ }
+
+ return rows;
+ }
+
+ /**
+ * This is a recursively called method to traverse the container calls. The logic
+ * will traverse to the last node in the node names and as it returns up the chain
+ * of names, it will build the rows.
+ *
+ * @param holder
+ * @param cachedObject
+ * @param level
+ * @param objectManager
+ * @return
+ * @throws TranslatorException
+ */
+ @SuppressWarnings("unchecked")
+ private static List<List<Object>> processContainer(Object parentObject,
+ int level, ObjectProjections projections, ObjectMethodManager objectManager) throws
TranslatorException {
+
+ List<List<Object>> containerRows = new
ArrayList<List<Object>>();
+ // if there another container depth, then process it first
+ // this will be recursive
+ if (level < projections.childrenDepth) {
+ String containerMethodName = projections.childrenNodes.get(level);
+
+ final String methodName = objectManager.formatMethodName(
+ ObjectMethodManager.GET, containerMethodName);
+
+ Object containerValue = objectManager.getGetValue(
+ methodName, parentObject);
+
+ if (containerValue != null) {
+
+ CONTAINER_TYPE type = getContainerType(containerValue);
+
+
+ Iterator<Object> colIt = null;
+ switch (type) {
+ case ARRAY:
+ List<Object> listRows = Arrays.asList((Object[]) containerValue);
+ colIt = listRows.iterator();
+ break;
+ case COLLECTION:
+ @SuppressWarnings("rawtypes")
+ Collection<Object> colRows = (Collection) containerValue;
+ colIt = colRows.iterator();
+ break;
+ case MAP:
+ @SuppressWarnings("rawtypes")
+ Map<?,Object> mapRows = (Map) containerValue;
+ colIt = mapRows.values().iterator();
+ break;
+ default:
+
+ }
+
+ if (colIt != null) {
+ while (colIt.hasNext()) {
+ Object colt = (Object) colIt.next();
+
+ final List<List<Object>> rows = processContainer(colt, level+1,
projections, objectManager);
+ containerRows.addAll(rows);
+ }
+ } else {
+ final List<List<Object>> rows = processContainer(containerValue,
level+1, projections, objectManager);
+
+ containerRows.addAll(rows);
+ }
+ }
+
+ }
+
+ if (containerRows.isEmpty()) {
+ containerRows = new ArrayList<List<Object>>(1);
+ List<Object> row = new
ArrayList<Object>(projections.columnNamesToUse.length);
+ for (int i = 0; i < projections.columnNamesToUse.length; i++) {
+ // the column must have as many nodes as the level being processed
+ // in order to obtain the value at the current level
+ if (projections.nameNodes[i].size() >= (level + 1)) { // level is zero based
+ Object value = getValue(parentObject, i, level, projections, objectManager);
+
+ row.add(value);
+ } else {
+ row.add(null);
+ }
+ }
+
+ containerRows.add(row);
+ return containerRows;
+
+ }
+
+
+ List<List<Object>> expandedRows = new
ArrayList<List<Object>>();
+ for (List<Object> row: containerRows) {
+
+ List<Object> newrow = new
ArrayList<Object>(projections.columnNamesToUse.length);
+
+ for (int col=0; col<projections.columnNamesToUse.length; ++col) {
+ // only make method calls for columns that are being processed at the same level,
+ // columns at other node depths will be loaded when its level is processed
+
+ final Object colObject = row.get(col);
+
+ if (projections.nodeDepth[col] == level) {
+
+ if (colObject != null) throw new TranslatorException("Program Error: column
object was not null for column " + projections.columnNamesToUse[col] + " at
level " + level);
+
+ final Object value = getValue(parentObject, col, level, projections,
objectManager);
+
+ newrow.add(value);
+
+ } else {
+ newrow.add(colObject);
+ }
+
+ }
+
+ expandedRows.add(newrow);
+ }
+ return expandedRows;
+ }
+
+ private static Object getValue(Object cachedObject, int columnIdx, int methodIdx,
ObjectProjections projections, ObjectMethodManager objectManager) throws
TranslatorException {
+
+
+ // only the last parsed name can be where the boolean call can be made
+ // example: x.y.z z will be where "is" is called
+ // or x x could be where "is" is called
+ Class<?> clzType = projections.columns[columnIdx].getJavaType();
+
+
+ Object value = null;
+
+ if (clzType != null && clzType == Boolean.class) {
+ final String methodName = objectManager.formatMethodName(
+ ObjectMethodManager.IS, projections.nameNodes[columnIdx].get(methodIdx) );
+
+ value = objectManager.getIsValue(
+ methodName, cachedObject);
+ } else {
+ final String methodName = objectManager.formatMethodName(
+ ObjectMethodManager.GET, projections.nameNodes[columnIdx].get(methodIdx) );
+
+ value = objectManager.getGetValue(
+ methodName, cachedObject);
+
+ }
+
+ return value;
+ }
+
+
+ private static CONTAINER_TYPE getContainerType(Object o) {
+ if (o.getClass().isArray()) {
+ return ObjectTranslator.CONTAINER_TYPE.ARRAY;
+ }
+
+ if (o instanceof Collection) {
+ return ObjectTranslator.CONTAINER_TYPE.COLLECTION;
+ }
+
+ if (o instanceof Map) {
+ return ObjectTranslator.CONTAINER_TYPE.MAP;
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
Added:
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheExecutionFactory.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheExecutionFactory.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheExecutionFactory.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object.example;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.Map;
+
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.object.ObjectExecutionFactory;
+import org.teiid.translator.object.ObjectMethodManager;
+import org.teiid.translator.object.ObjectSourceProxy;
+import org.teiid.translator.object.util.ObjectMethodUtil;
+
+@Translator(name="mapCacheExample", description="The Example Map Cache
Factory")
+public class MapCacheExecutionFactory extends ObjectExecutionFactory {
+ private static final String LOADCACHE_METHOD_NAME = "loadCache";
+ private String cacheLoaderClassName = null;
+
+ private Map<Object, Object> cache = null;
+
+ @Override
+ public void start() throws TranslatorException {
+ if (cacheLoaderClassName == null) {
+ throw new TranslatorException("CacheLoaderClassName has not been set");
+ }
+
+ super.start();
+
+ Class<?> clzz = ObjectMethodManager.loadClass(cacheLoaderClassName,
+ this.getClass().getClassLoader());
+ Method m = null;
+ try {
+ // because the method is static, pass in null for the object api
+ Class<?>[] parms = null;
+ m = clzz.getMethod(LOADCACHE_METHOD_NAME, parms);
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ throw new TranslatorException("Method " + LOADCACHE_METHOD_NAME
+ + " was not defined on class " + cacheLoaderClassName);
+ }
+
+ try {
+ cache = (Map) ObjectMethodUtil.executeMethod(m, null, Collections.EMPTY_LIST);
+ } catch (Throwable e) {
+ throw new TranslatorException(e);
+ }
+
+ }
+
+
+ /**
+ * <p>
+ * Returns the name of the class used to load the map cache.
+ * </P
+ * @return String name of class to use to load the map cache
+ */
+ @TranslatorProperty(display="CacheLoaderClassName", advanced=true)
+ public String getCacheLoaderClassName() {
+ return this.cacheLoaderClassName;
+ }
+
+ /**
+ * <p>
+ * Set the name of the class used to load the cache map. The only requirement of the
class
+ * is it must define a <b>static method</b> called <code>{@literal
#LOADCACHE_METHOD_NAME}</code>
+ * and return <code>Map</code> of the cache.
+ * </p>
+ * @param String name of class to use to load the map cache
+ */
+ public void setCacheLoaderClassName(String cacheLoaderClassName) {
+ this.cacheLoaderClassName = cacheLoaderClassName;
+ }
+
+ protected Map<Object, Object> getCache() {
+ return this.cache;
+ }
+
+ @Override
+ protected ObjectSourceProxy createProxy(Object connection)
+ throws TranslatorException {
+
+ return new MapCacheProxy(connection, this);
+ }
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheObjectVisitor.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheObjectVisitor.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheObjectVisitor.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,331 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.object.example;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Comparison;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.In;
+import org.teiid.language.Like;
+import org.teiid.language.Literal;
+import org.teiid.language.ScalarSubquery;
+import org.teiid.language.SearchedCase;
+import org.teiid.language.visitor.HierarchyVisitor;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.Table;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.object.ObjectPlugin;
+
+/**
+ * This is an example of extending ObjectVisitor, providing query access to a local Map
object cache
+ */
+public class MapCacheObjectVisitor extends HierarchyVisitor {
+
+ protected TranslatorException exception;
+ public String tableName;
+ public String columnName;
+ public Object value;
+ public Class<?> classType;
+ public List<Object> parms;
+ public Operator op;
+
+ public boolean like = false;
+ public boolean compare = false;
+ public boolean in = false;
+
+ /**
+ *
+ */
+ public MapCacheObjectVisitor() {
+ super();
+ }
+
+
+ public void addCompareCriteria(String tableName,
+ String columnName, Object value, Operator op,
+ Class<?> type) throws TranslatorException {
+ this.tableName = tableName;
+ this.columnName = columnName;
+ this.op = op;
+ this.value = value;
+ this.compare = true;
+ this.classType = type;
+ }
+
+ public void addLikeCriteria(String tableName,
+ String columnName, Object value)
+ throws TranslatorException {
+ this.tableName = tableName;
+ this.columnName = columnName;
+ this.value = value;
+ this.like = true;
+ }
+
+ public void addInCriteria(String tableName, String columnName,
+ List<Object> parms, Class<?> type)
+ throws TranslatorException {
+ this.tableName = tableName;
+ this.columnName = columnName;
+ this.parms = parms;
+ this.in = true;
+ this.classType = type;
+ }
+
+ public TranslatorException getException() {
+ return this.exception;
+ }
+
+
+ public void visit(Comparison obj) {
+ LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing Comparison
criteria."); //$NON-NLS-1$
+ try {
+
+ Comparison.Operator op = ((Comparison) obj).getOperator();
+
+ Expression lhs = ((Comparison) obj).getLeftExpression();
+ Expression rhs = ((Comparison) obj).getRightExpression();
+
+ // comparison between the ojbects is not usable, because the nameInSource and its
parent(s)
+ // will be how the child objects are obtained
+ if (lhs instanceof ColumnReference && rhs instanceof ColumnReference) {
+ return;
+ }
+
+
+ String lhsString = getExpressionString(lhs);
+ String rhsString = getExpressionString(rhs);
+ if(lhsString == null || rhsString == null) {
+ final String msg =
ObjectPlugin.Util.getString("ObjectVisitor.missingComparisonExpression");
//$NON-NLS-1$
+ exception = new TranslatorException(msg);
+ }
+
+ if (rhs instanceof Literal || lhs instanceof Literal) {
+ if(rhs instanceof Literal) {
+ Literal literal = (Literal) rhs;
+ String tableName = getTableNameFromColumnObject(lhs);
+ addCompareCriteria(tableName, lhsString, literal.getValue(), op,
literal.getType());
+
+ } else {
+ Literal literal = (Literal) lhs;
+ String tableName = getTableNameFromColumnObject(rhs);
+ addCompareCriteria(tableName, rhsString, literal.getValue(), op,
literal.getType());
+
+
+ }
+ }
+ }catch (TranslatorException t) {
+ exception = t;
+ }
+ }
+
+
+ public void visit(Like obj) {
+
+ LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing LIKE criteria.");
//$NON-NLS-1$
+// isNegated = ((Like) criteria).isNegated();
+ // Convert LIKE to Equals, where any "%" symbol is replaced with
"*".
+ try {
+
+ Comparison.Operator op = Operator.EQ;
+ Expression lhs = ((Like) obj).getLeftExpression();
+ Expression rhs = ((Like) obj).getRightExpression();
+
+ String tableName = getTableNameFromColumnObject(lhs);
+ if (tableName == null) {
+ tableName = getTableNameFromColumnObject(rhs);
+ }
+
+ String lhsString = getExpressionString(lhs);
+ String rhsString = getExpressionString(rhs);
+
+ addLikeCriteria(tableName, lhsString, rhsString);
+
+ }catch (TranslatorException t) {
+ exception = t;
+ }
+ }
+
+
+ public void visit(In obj) {
+ LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing IN criteria.");
//$NON-NLS-1$
+// isNegated = ((In) criteria).isNegated();
+ try {
+
+ Expression lhs = ((In)obj).getLeftExpression();
+
+ String tableName = getTableNameFromColumnObject(lhs);
+ String colName = getExpressionString(lhs);
+
+ List<Expression> rhsList = ((In)obj).getRightExpressions();
+
+ Class type = lhs.getType();
+ List parms = new ArrayList(rhsList.size());
+ Iterator iter = rhsList.iterator();
+ while(iter.hasNext()) {
+
+ Expression expr = (Expression) iter.next();
+ type = addParmFromExpression(expr, parms);
+
+ }
+ addInCriteria(tableName, colName, parms, type);
+
+ }catch (TranslatorException t) {
+ exception = t;
+ }
+
+ }
+
+ protected String getTableNameFromColumnObject(Object e) {
+ Column col = null;
+ if(e instanceof ColumnReference) {
+ col = ((ColumnReference)e).getMetadataObject();
+ } else if (e instanceof Column) {
+ col = (Column) e;
+ }
+
+ Object p = col.getParent();
+ if (p instanceof Table) {
+ Table t = (Table)p;
+ return t.getName();
+ }
+
+ return null;
+
+ }
+
+ protected Class addParmFromExpression(Expression expr, List parms ) {
+ Class type = null;
+ if(expr instanceof Literal) {
+ Long longparm = null;
+ Literal literal = (Literal) expr;
+
+ parms.add(literal);
+
+ type = literal.getType();
+
+ } else {
+ this.exception = new
TranslatorException("ObjectVisitor.Unsupported_expression" + expr);
//$NON-NLS-1$
+ }
+
+ return type;
+
+ }
+
+
+ // GHH 20080326 - found that code to fall back on Name if NameInSource
+ // was null wasn't working properly, so replaced with tried and true
+ // code from another custom connector.
+ private String getExpressionString(Expression e) throws TranslatorException {
+ String expressionName = null;
+ // GHH 20080326 - changed around the IElement handling here
+ // - the rest of this method is unchanged
+ if(e instanceof ColumnReference) {
+ Column mdIDElement = ((ColumnReference)e).getMetadataObject();
+ expressionName = getNameInSourceFromColumn(mdIDElement);
+// expressionName = mdIDElement.getNameInSource();
+// if(expressionName == null || expressionName.equals("")) { //$NON-NLS-1$
+// expressionName = mdIDElement.getName();
+// }
+ } else if(e instanceof Literal) {
+// try {
+// if(((Literal)e).getType().equals(Class.forName(Timestamp.class.getName()))) {
+// LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Found an expression that
uses timestamp; converting to LDAP string format."); //$NON-NLS-1$
+// Timestamp ts = (Timestamp)((Literal)e).getValue();
+// Date dt = new Date(ts.getTime());
+// //TODO: Fetch format if provided.
+// SimpleDateFormat sdf = new
SimpleDateFormat(LDAPConnectorConstants.ldapTimestampFormat);
+// expressionName = sdf.format(dt);
+// LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Timestamp to stsring is:
" + expressionName); //$NON-NLS-1$
+// }
+// else {
+// expressionName = ((Literal)e).getValue().toString();
+// }
+
+ expressionName = ((Literal)e).getValue().toString();
+// } catch (ClassNotFoundException cce) {
+// final String msg =
LDAPPlugin.Util.getString("IQueryToLdapSearchParser.timestampClassNotFoundError");
//$NON-NLS-1$
+// throw new TranslatorException(cce, msg);
+// }
+//
+ } else {
+ if(e instanceof AggregateFunction) {
+ LogManager.logError(LogConstants.CTX_CONNECTOR, "Received IAggregate, but it is
not supported. Check capabilities."); //$NON-NLS-1$
+ } else if(e instanceof Function) {
+ LogManager.logError(LogConstants.CTX_CONNECTOR, "Received IFunction, but it is
not supported. Check capabilties."); //$NON-NLS-1$
+ } else if(e instanceof ScalarSubquery) {
+ LogManager.logError(LogConstants.CTX_CONNECTOR, "Received IScalarSubquery, but
it is not supported. Check capabilties."); //$NON-NLS-1$
+ } else if (e instanceof SearchedCase) {
+ LogManager.logError(LogConstants.CTX_CONNECTOR, "Received
ISearchedCaseExpression, but it is not supported. Check capabilties.");
//$NON-NLS-1$
+ }
+ final String msg =
ObjectPlugin.Util.getString("ObjectVisitor.unsupportedElementError" ,
e.toString()); //$NON-NLS-1$
+ throw new TranslatorException(msg);
+ }
+ expressionName = escapeReservedChars(expressionName);
+ return expressionName;
+ }
+
+ protected String getNameInSourceFromColumn(Column c) {
+ String name = c.getNameInSource();
+ if(name == null || name.equals("")) { //$NON-NLS-1$
+ return c.getName();
+ }
+ return name;
+ }
+
+ protected static String escapeReservedChars(final String expr) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < expr.length(); i++) {
+ char curChar = expr.charAt(i);
+ switch (curChar) {
+ case '\\':
+ sb.append("\\5c"); //$NON-NLS-1$
+ break;
+ case '*':
+ sb.append("\\2a"); //$NON-NLS-1$
+ break;
+ case '(':
+ sb.append("\\28"); //$NON-NLS-1$
+ break;
+ case ')':
+ sb.append("\\29"); //$NON-NLS-1$
+ break;
+ case '\u0000':
+ sb.append("\\00"); //$NON-NLS-1$
+ break;
+ default:
+ sb.append(curChar);
+ }
+ }
+ return sb.toString();
+ }
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheProxy.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheProxy.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/example/MapCacheProxy.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object.example;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.teiid.language.Command;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.object.ObjectSourceProxy;
+
+public class MapCacheProxy implements ObjectSourceProxy {
+ private MapCacheObjectVisitor visitor = new MapCacheObjectVisitor();
+ private Object connection;
+ private MapCacheExecutionFactory factory;
+
+
+ public MapCacheProxy(Object connection, MapCacheExecutionFactory factory) {
+ this.connection = connection;
+ this.factory = factory;
+ }
+
+
+ private Map<Object, Object> getCache() {
+ return factory.getCache();
+ }
+
+
+ @Override
+ public List<Object> get(Command command) throws TranslatorException {
+ visitor.visitNode(command);
+
+ List<Object> results = null;
+ if (visitor.compare) {
+ results = new ArrayList<Object>(1);
+ results.add(getCache().get(visitor.value));
+ return results;
+
+ } else {
+ results = new ArrayList<Object>();
+ results.addAll(getCache().values());
+ return results;
+
+ }
+ }
+
+
+
+ @Override
+ public void close() {
+
+ }
+
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/util/ObjectMethodUtil.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/util/ObjectMethodUtil.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/java/org/teiid/translator/object/util/ObjectMethodUtil.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.object.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+import org.teiid.core.util.ReflectionHelper;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.translator.TranslatorException;
+
+/**
+ * ObjectMethodUtil provides utility methods
+ */
+public final class ObjectMethodUtil {
+
+ /**
+ * Call to execute the method
+ *
+ * @param m
+ * is the method to execute
+ * @param api
+ * is the object to execute the method on
+ * @param parms
+ * are the parameters to pass when the method is executed
+ * @return Object return value
+ * @throws Exception
+ */
+ public static Object executeMethod(Method m, Object api, Object[] parms)
+ throws TranslatorException {
+ try {
+ return m.invoke(api, parms);
+ } catch (InvocationTargetException x) {
+ x.printStackTrace();
+ Throwable cause = x.getCause();
+ System.err.format("invocation of %s failed: %s%n",
+ "set" + m.getName(), cause.getMessage());
+ LogManager.logError(LogConstants.CTX_CONNECTOR, "Error calling "
+ + m.getName() + ":" + cause.getMessage());
+ throw new TranslatorException(x.getMessage());
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new TranslatorException(e.getMessage());
+ }
+ }
+
+ /**
+ * Call to execute the method
+ *
+ * @param m
+ * is the method to execute
+ * @param api
+ * is the object to execute the method on
+ * @param parms
+ * are the parameters to pass when the method is executed
+ * @return Object return value
+ * @throws Exception
+ */
+ public static Object executeMethod(Method m, Object api, List<Object> parms)
+ throws TranslatorException {
+ try {
+ if (parms != null) {
+ return m.invoke(api, parms.toArray());
+ }
+ return m.invoke(api, (Object[]) null);
+ } catch (InvocationTargetException x) {
+ x.printStackTrace();
+ Throwable cause = x.getCause();
+ System.err.format("invocation of %s failed: %s%n",
+ "set" + m.getName(), cause.getMessage());
+ LogManager.logError(LogConstants.CTX_CONNECTOR, "Error calling "
+ + m.getName() + ":" + cause.getMessage());
+ throw new TranslatorException(x.getMessage());
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new TranslatorException(e.getMessage());
+ }
+ }
+
+
+
+ public static Object createObject(String objectClassName,
+ Collection<?> ctors, ClassLoader loader) throws TranslatorException {
+ try {
+
+ return ReflectionHelper.create(objectClassName, ctors, loader);
+ } catch (Exception e1) {
+ throw new TranslatorException(e1);
+ }
+ }
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/main/resources/org/teiid/translator/object/i18n.properties
===================================================================
---
branches/7.7.x/connectors/translator-object/src/main/resources/org/teiid/translator/object/i18n.properties
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/main/resources/org/teiid/translator/object/i18n.properties 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,34 @@
+#
+# 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.
+#
+
+
+ObjectDriver.urlFormat=The required url format is
jdbc:object:classNames=name1[,name2,...n]
+
+
+ObjectExecutionFactory.rootClassNameUndefined=ObjectExecutionFatory is invalid,
RootClassName is not defined
+
+ObjectVisitor.missingComparisonExpression=Missing either left or right expression in
comparison
+ObjectVisitor.Unsupported_expressionr=Unsupported element {0}
+
+ObjectMethodManager.noMethodFound=Method {0} was not found for class {1}
+
+ObjectMethodManager.objectClassNotFound=Class {0} not found to load
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/BaseObjectTest.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/BaseObjectTest.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/BaseObjectTest.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,191 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.jdbc.util.ResultSetUtil;
+
+
+public abstract class BaseObjectTest {
+
+ protected static boolean REPLACE_EXPECTED = false;
+ protected static boolean WRITE_ACTUAL_RESULTS_TO_FILE = false;
+ protected static boolean PRINT_RESULTSETS_TO_CONSOLE = false;
+
+ private static final int MAX_COL_WIDTH = 65;
+
+ public static void writeActualResultsToFile(boolean write) {
+ WRITE_ACTUAL_RESULTS_TO_FILE = write;
+ }
+
+
+ public static void compareResultSet(ResultSet... rs) throws IOException, SQLException
{
+ StackTraceElement ste = new Exception().getStackTrace()[1];
+ String testName = ste.getMethodName();
+ String className = ste.getClassName();
+ className = className.substring(className.lastIndexOf('.') + 1);
+ testName = className + "/" + testName; //$NON-NLS-1$
+ compareResultSet(testName, rs);
+ }
+
+ public static void compareResultSet(String testName, ResultSet... rs)
+ throws FileNotFoundException, SQLException, IOException {
+ FileOutputStream actualOut = null;
+ BufferedReader expectedIn = null;
+ PrintStream stream = null;
+ try {
+ if (REPLACE_EXPECTED) {
+ File actual = new File(UnitTestUtil.getTestDataPath() + "/"
+testName+".expected"); //$NON-NLS-1$ //$NON-NLS-2$
+ actualOut = new FileOutputStream(actual);
+ } else {
+ if (WRITE_ACTUAL_RESULTS_TO_FILE) {
+ File actual = new File(UnitTestUtil.getTestDataPath() + "/"
+testName+".actual"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (!actual.getParentFile().exists()) {
+ actual.getParentFile().mkdir();
+ }
+ actualOut = new FileOutputStream(actual);
+
+
+ } else {
+ File expected = new File(UnitTestUtil.getTestDataPath() +
"/"+testName+".expected"); //$NON-NLS-1$ //$NON-NLS-2$
+ expectedIn = new BufferedReader(new FileReader(expected));
+ }
+
+
+ }
+ PrintStream defaultStream = null;
+ if (PRINT_RESULTSETS_TO_CONSOLE) {
+ defaultStream = new PrintStream(System.out) {
+ // SYS.out should be protected from being closed.
+ public void close() {}
+ };
+ }
+ stream = ResultSetUtil.getPrintStream(actualOut, expectedIn, defaultStream);
+ for (int i = 0; i < rs.length; i++) {
+ ResultSetUtil.printResultSet(rs[i], MAX_COL_WIDTH, true, stream);
+ }
+ assertEquals("Actual data did not match expected", //$NON-NLS-1$
+ Collections.EMPTY_LIST,
+ ResultSetUtil.getUnequalLines(stream));
+ } finally {
+ if (stream != null) {
+ stream.close();
+ }
+ if (actualOut != null) {
+ actualOut.close();
+ }
+ if (expectedIn != null) {
+ expectedIn.close();
+ }
+ }
+ }
+
+
+ public static void compareResultSet(String testName, List<Object>... rs)
+ throws FileNotFoundException, SQLException, IOException {
+ FileOutputStream actualOut = null;
+ BufferedReader expectedIn = null;
+ PrintStream stream = null;
+ try {
+ if (REPLACE_EXPECTED) {
+ File actual = new File(UnitTestUtil.getTestDataPath()
+ + "/" + testName + ".expected"); //$NON-NLS-1$ //$NON-NLS-2$
+ actualOut = new FileOutputStream(actual);
+ } else {
+ if (WRITE_ACTUAL_RESULTS_TO_FILE) {
+ File actual = new File(UnitTestUtil.getTestDataPath()
+ + "/" + testName + ".actual"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (!actual.getParentFile().exists()) {
+ actual.getParentFile().mkdir();
+ }
+ actualOut = new FileOutputStream(actual);
+
+// ObjectOutput oo = null;
+// oo = new ObjectOutputStream(actualOut);
+
+ for (int i = 0; i < rs.length; i++) {
+ List<Object> r = rs[i];
+ actualOut.write( new String("ROW_" + i).getBytes());
+ for (Iterator it=r.iterator(); it.hasNext();) {
+ Object o = it.next();
+ actualOut.write( o.toString().getBytes());
+ actualOut.write( new String("\t").getBytes());
+ }
+ //ExternalizeUtil.writeList(oo, rs[i]);
+ }
+
+ return;
+
+
+ } else {
+ File expected = new File(UnitTestUtil.getTestDataPath()
+ + "/" + testName + ".expected"); //$NON-NLS-1$ //$NON-NLS-2$
+ expectedIn = new BufferedReader(new FileReader(expected));
+ }
+
+ }
+ PrintStream defaultStream = null;
+ if (PRINT_RESULTSETS_TO_CONSOLE) {
+ defaultStream = new PrintStream(System.out) {
+ // SYS.out should be protected from being closed.
+ public void close() {
+ }
+ };
+ }
+ stream = ResultSetUtil.getPrintStream(actualOut, expectedIn,
+ defaultStream);
+// for (int i = 0; i < rs.length; i++) {
+// ResultSetUtil.printResultSet(rs[i], MAX_COL_WIDTH, true, stream);
+// }
+ assertEquals(
+ "Actual data did not match expected", //$NON-NLS-1$
+ Collections.EMPTY_LIST,
+ ResultSetUtil.getUnequalLines(stream));
+ } finally {
+ if (stream != null) {
+ stream.close();
+ }
+ if (actualOut != null) {
+ actualOut.close();
+ }
+ if (expectedIn != null) {
+ expectedIn.close();
+ }
+ }
+ }
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectExecution.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectExecution.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectExecution.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.language.Select;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.object.ObjectExecution;
+import org.teiid.translator.object.ObjectExecutionFactory;
+import org.teiid.translator.object.ObjectSourceProxy;
+import org.teiid.translator.object.testdata.TradesCacheSource;
+import org.teiid.translator.object.testdata.VDBUtility;
+
+@SuppressWarnings("nls")
+public class TestObjectExecution {
+
+ private static TradesCacheSource source;
+
+ @BeforeClass
+ public static void beforeEach() throws Exception {
+ source = TradesCacheSource.loadCache();
+ }
+
+
+ @Test public void testQueryRootObject() throws Exception {
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select *
From Trade_Object.Trade"); //$NON-NLS-1$
+ this.runCommand(command, 3);
+
+ }
+
+ @Test public void testQueryIncludeLegs() throws Exception {
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select
T.TradeId, T.Name as TradeName, L.Name as LegName From Trade_Object.Trade as T,
Trade_Object.Leg as L Where T.TradeId = L.TradeId"); //$NON-NLS-1$
+ runCommand(command, 30);
+
+ }
+
+ private void runCommand(Select command, int expected) throws Exception {
+
+ ExecutionContext context = Mockito.mock(ExecutionContext.class);
+
+ ObjectSourceProxy proxy = Mockito.mock(ObjectSourceProxy.class);
+
+ Mockito.stub(proxy.get(command)).toReturn(source.getAll());
+
+
+ ObjectExecutionFactory factory = new ObjectExecutionFactory() {
+
+ @Override
+ protected ObjectSourceProxy createProxy(Object connection)
+ throws TranslatorException {
+
+ return (ObjectSourceProxy) connection;
+ }
+
+ };
+
+ factory.start();
+
+ ObjectExecution exec = (ObjectExecution) factory.createExecution(command, context,
VDBUtility.RUNTIME_METADATA, proxy);
+
+ exec.execute();
+
+ int cnt = 0;
+ List<?> row = exec.next();
+
+ while (row != null) {
+ ++cnt;
+ row = exec.next();
+ }
+ assertEquals("Did not get expected number of rows", expected, cnt);
//$NON-NLS-1$
+
+ exec.close();
+
+ }
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectExecutionFactory.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectExecutionFactory.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectExecutionFactory.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.language.Select;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.object.ObjectExecution;
+import org.teiid.translator.object.ObjectExecutionFactory;
+import org.teiid.translator.object.ObjectSourceProxy;
+import org.teiid.translator.object.testdata.VDBUtility;
+
+@SuppressWarnings("nls")
+public class TestObjectExecutionFactory {
+
+ @Test public void testFactory() throws Exception {
+
+ Select command = Mockito.mock(Select.class);
+
+ ExecutionContext context = Mockito.mock(ExecutionContext.class);
+
+ ObjectSourceProxy proxy = Mockito.mock(ObjectSourceProxy.class);
+
+ ObjectExecutionFactory factory = new ObjectExecutionFactory() {
+
+ @Override
+ protected ObjectSourceProxy createProxy(Object connection)
+ throws TranslatorException {
+
+ return (ObjectSourceProxy) connection;
+ }
+
+ };
+
+ factory.setColumnNameFirstLetterUpperCase(false);
+
+ factory.start();
+
+ ObjectExecution exec = (ObjectExecution) factory.createExecution(command, context,
VDBUtility.RUNTIME_METADATA, proxy);
+
+ assertNotNull(exec);
+ assertNotNull(factory.getObjectMethodManager());
+ assertEquals(factory.isColumnNameFirstLetterUpperCase(), false);
+
+ }
+
+
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectMethodManager.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectMethodManager.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectMethodManager.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import javax.transaction.Transaction;
+
+import org.junit.Test;
+import org.teiid.translator.object.ObjectMethodManager;
+import org.teiid.translator.object.testdata.Leg;
+import org.teiid.translator.object.testdata.Trade;
+
+@SuppressWarnings("nls")
+public class TestObjectMethodManager {
+
+ @Test public void testInitializationNoClassesLoaded() throws Exception {
+
+ ObjectMethodManager omm = ObjectMethodManager.initialize(true,
this.getClass().getClassLoader());
+
+ // should not fail
+ assertEquals(omm.size(), 0);
+ assertNull(omm.get("test"));
+ assertNull(omm.getClassMethods("class.not.in.here"));
+
+ // when trying to find a method,and the class isn't loaded yet, this should
trigger
+ // the loading of the class
+ assertNotNull(omm.findGetterMethod(Trade.class, "getName"));
+
+ }
+
+ @Test public void testInitializationLoading1Class() throws Exception {
+
+ ObjectMethodManager omm = ObjectMethodManager.initialize(Trade.class.getName(), true,
this.getClass().getClassLoader());
+
+ // should not fail
+ assertEquals(omm.size(), 1);
+ assertNotNull(omm.get(Trade.class.getName()));
+ assertNotNull(omm.getClassMethods(Trade.class.getName()));
+ assertNotNull(omm.findGetterMethod(Trade.class, "getName"));
+
+ }
+
+ @Test public void testInitializationLoadingMulitipleClasses() throws Exception {
+
+ ObjectMethodManager omm = ObjectMethodManager.initialize(Trade.class.getName() +
","
+ + Leg.class.getName()
+ + ","
+ + Transaction.class.getName()
+ , true, this.getClass().getClassLoader());
+
+ // should not fail
+ assertEquals(omm.size(), 3);
+ assertNotNull(omm.getClassMethods(Trade.class.getName()));
+ assertNotNull(omm.getClassMethods(Leg.class.getName()));
+ assertNotNull(omm.getClassMethods(Transaction.class.getName()));
+ assertNotNull(omm.findGetterMethod(Trade.class, "getName"));
+ assertNotNull(omm.findGetterMethod(Leg.class, "getName"));
+// assertNotNull(omm.findGetterMethod(Transaction.class, "getLineItem"));
+
+ }
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectProjections.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectProjections.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectProjections.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.teiid.language.Select;
+import org.teiid.translator.object.testdata.VDBUtility;
+
+@SuppressWarnings("nls")
+public class TestObjectProjections {
+
+
+ @Test public void testQueryRootObject() throws Exception {
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select *
From Trade_Object.Trade"); //$NON-NLS-1$
+
+ ObjectProjections op = new ObjectProjections(command);
+
+ validateArrays(4, op);
+
+
+ }
+
+ @Test public void testQueryIncludeLegs() throws Exception {
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select
T.TradeId, T.Name as TradeName, L.Name as LegName From Trade_Object.Trade as T,
Trade_Object.Leg as L Where T.TradeId = L.TradeId"); //$NON-NLS-1$
+
+ ObjectProjections op = new ObjectProjections(command);
+ validateArrays(3, op);
+ }
+
+ @Test public void testQueryGetAllTransactions() throws Exception {
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select
T.TradeId, T.Name as TradeName, L.Name as LegName, " +
+ " N.LineItem " +
+ " From Trade_Object.Trade as T, Trade_Object.Leg as L, Trade_Object.Transaction
as N " +
+ " Where T.TradeId = L.TradeId and L.LegId = N.LegId"); //$NON-NLS-1$
+ ObjectProjections op = new ObjectProjections(command);
+ validateArrays(4, op);
+
+
+ }
+
+ private void validateArrays(int size, ObjectProjections op) throws Exception {
+ op.throwExceptionIfFound();
+
+ assertEquals(size, op.getColumnNamesToUse().length);
+ assertEquals(size, op.getColumns().length);
+
+ // confirm the arrays match
+ for (int i = 0; i < op.getColumns().length; i++) {
+ assertEquals(op.getColumnNamesToUse()[i],
op.getColumnNameToUse(op.getColumns()[i]));
+ System.out.println("ColumnToUse: " + op.getColumnNamesToUse()[i]);
+ }
+ }
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectTranslator.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectTranslator.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/TestObjectTranslator.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.teiid.language.Select;
+import org.teiid.translator.object.testdata.TradesCacheSource;
+import org.teiid.translator.object.testdata.VDBUtility;
+
+@SuppressWarnings("nls")
+public class TestObjectTranslator {
+
+ private static TradesCacheSource source;
+
+ @BeforeClass
+ public static void beforeEach() throws Exception {
+ source = TradesCacheSource.loadCache();
+ }
+
+ @Test public void testQueryGetAllTrades() throws Exception {
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select *
From Trade_Object.Trade"); //$NON-NLS-1$
+
+ runTest(command, 3, 4);
+ }
+
+ @Test public void testQueryGetAllLegs() throws Exception {
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select
T.TradeId, T.Name as TradeName, L.Name as LegName From Trade_Object.Trade as T,
Trade_Object.Leg as L Where T.TradeId = L.TradeId"); //$NON-NLS-1$
+ runTest(command, 30, 3);
+ }
+
+ @Test public void testQueryGetAllTransactions() throws Exception {
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select
T.TradeId, T.Name as TradeName, L.Name as LegName, " +
+ " N.LineItem " +
+ " From Trade_Object.Trade as T, Trade_Object.Leg as L, Trade_Object.Transaction
N " +
+ " Where T.TradeId = L.TradeId and L.LegId = N.LegId"); //$NON-NLS-1$
+ runTest(command, 150, 4);
+
+
+ }
+
+
+ private void runTest(Select command, int rows, int columns) throws Exception {
+ ObjectProjections op = new ObjectProjections(command);
+
+ ObjectMethodManager omm = ObjectMethodManager.initialize(true,
this.getClass().getClassLoader());
+
+
+ List<List<?>> results = ObjectTranslator.translateObjects(source.getAll(),
op, omm);
+
+ assertEquals(rows, results.size());
+
+ // check the number of columns
+ List<?> row1 = results.get(0);
+ assertEquals(columns, row1.size());
+
+ }
+
+
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/example/TestMapCacheIntegration.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/example/TestMapCacheIntegration.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/example/TestMapCacheIntegration.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object.example;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.language.Select;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.object.BaseObjectTest;
+import org.teiid.translator.object.ObjectExecution;
+import org.teiid.translator.object.example.MapCacheExecutionFactory;
+import org.teiid.translator.object.testdata.VDBUtility;
+
+@SuppressWarnings("nls")
+public class TestMapCacheIntegration extends BaseObjectTest {
+
+ private static boolean print = false;
+
+ @Test public void testQueryIncludeLegs() throws Exception {
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select
T.TradeId, T.Name as TradeName, L.Name as LegName From Trade_Object.Trade as T,
Trade_Object.Leg as L Where T.TradeId = L.TradeId"); //$NON-NLS-1$
+
+ ExecutionContext context = Mockito.mock(ExecutionContext.class);
+
+ MapCacheExecutionFactory factory = new MapCacheExecutionFactory();
+ factory.setCacheLoaderClassName("org.teiid.translator.object.testdata.TradesCacheSource");
+ factory.start();
+
+ ObjectExecution exec = (ObjectExecution) factory.createExecution(command, context,
VDBUtility.RUNTIME_METADATA, new Object());
+
+ exec.execute();
+
+ int cnt = 0;
+ List<Object> row = exec.next();
+
+// BaseObjectTest.compareResultSet("testQueryIncludeLegs", row);
+
+ while (row != null) {
+ ++cnt;
+ row = exec.next();
+ printRow(cnt, row);
+ }
+
+
+ assertEquals("Did not get expected number of rows", 30, cnt); //$NON-NLS-1$
+
+ exec.close();
+
+ }
+
+ @Ignore
+ @Test public void testQueryGetTrades() throws Exception {
+ WRITE_ACTUAL_RESULTS_TO_FILE = true;
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select *
From Trade_Object.Trade"); //$NON-NLS-1$
+
+ ExecutionContext context = Mockito.mock(ExecutionContext.class);
+
+ MapCacheExecutionFactory factory = new MapCacheExecutionFactory();
+ factory.setCacheLoaderClassName("org.teiid.translator.object.testdata.TradesCacheSource");
+ factory.start();
+
+ ObjectExecution exec = (ObjectExecution) factory.createExecution(command, context,
VDBUtility.RUNTIME_METADATA, new Object());
+
+ exec.execute();
+
+ int cnt = 0;
+ List<Object> row = exec.next();
+
+// BaseObjectTest.compareResultSet("testQueryIncludeLegs", row);
+
+ while (row != null) {
+ ++cnt;
+ row = exec.next();
+ printRow(cnt, row);
+ }
+
+
+ assertEquals("Did not get expected number of rows", 30, cnt); //$NON-NLS-1$
+
+ exec.close();
+
+ }
+
+ @Ignore
+ @Test public void testQueryGetTransaction() throws Exception {
+ WRITE_ACTUAL_RESULTS_TO_FILE = true;
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select *
From Trade_Object.Transaction"); //$NON-NLS-1$
+
+ ExecutionContext context = Mockito.mock(ExecutionContext.class);
+
+ MapCacheExecutionFactory factory = new MapCacheExecutionFactory();
+ factory.setCacheLoaderClassName("org.teiid.translator.object.testdata.TradesCacheSource");
+ factory.start();
+
+ ObjectExecution exec = (ObjectExecution) factory.createExecution(command, context,
VDBUtility.RUNTIME_METADATA, new Object());
+
+ exec.execute();
+
+ int cnt = 0;
+ List<Object> row = exec.next();
+
+// BaseObjectTest.compareResultSet("testQueryIncludeLegs", row);
+
+ while (row != null) {
+ ++cnt;
+ row = exec.next();
+ printRow(cnt, row);
+ }
+
+
+ assertEquals("Did not get expected number of rows", 50, cnt); //$NON-NLS-1$
+
+ exec.close();
+
+ }
+
+ private void printRow(int rownum, List<?> row) {
+ if (!print) return;
+ if (row == null) {
+ System.out.println("Row " + rownum + " is null");
+ return;
+ }
+ int i = 0;
+ for(Object o:row) {
+ System.out.println("Row " + rownum + " Col " + i + " - "
+ o.toString());
+ ++i;
+ }
+
+ }
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/example/TestMapCacheVisitor.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/example/TestMapCacheVisitor.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/example/TestMapCacheVisitor.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object.example;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.language.Select;
+import org.teiid.metadata.Column;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.object.ObjectProjections;
+import org.teiid.translator.object.testdata.Trade;
+import org.teiid.translator.object.testdata.VDBUtility;
+
+
+@SuppressWarnings("nls")
+public class TestMapCacheVisitor {
+
+ private static int CNT = 0;
+ @Before public void setup() {
+ CNT = 0;
+ }
+
+ @Test public void testIN() throws Exception {
+
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select *
From Trade_Object.Trade where Trade_Object.Trade.TradeID IN (1,2,3)"); //$NON-NLS-1$
+ ObjectProjections op = new ObjectProjections(command);
+
+ MapCacheObjectVisitor visitor =new MapCacheObjectVisitor() {
+ @Override
+ public void addInCriteria(String objectName, String attributeName,
+ List<Object> parms, Class<?> type)
+ throws TranslatorException {
+ CNT+=parms.size();
+ }
+
+ };
+
+ visitor.visit(command);
+
+ validateSelectVisitorAllRootTableColumns(op);
+ assertEquals("In Criteria", 3, CNT);
+
+ }
+
+ @Test public void test1Equals() throws Exception {
+
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select *
From Trade_Object.Trade where Trade_Object.Trade.TradeID = 1"); //$NON-NLS-1$
+ ObjectProjections op = new ObjectProjections(command);
+
+ MapCacheObjectVisitor visitor =new MapCacheObjectVisitor() {
+
+ @Override
+ public void addCompareCriteria(String objectName,
+ String attributeName, Object value, Operator op,
+ Class<?> type) throws TranslatorException {
+
+ if (value.toString().equals("1")) {
+ ++CNT;
+ }
+ }
+
+ };
+
+ visitor.visit(command);
+
+ validateSelectVisitorAllRootTableColumns(op);
+ assertEquals("Equals Criteria", 1, CNT);
+ }
+
+ @Test public void testLike() throws Exception {
+
+ Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select *
From Trade_Object.Trade where Trade_Object.Trade.Name like 'Test%'");
//$NON-NLS-1$
+ ObjectProjections op = new ObjectProjections(command);
+ MapCacheObjectVisitor visitor =new MapCacheObjectVisitor() {
+
+ @Override
+ public void addLikeCriteria(String objectName,
+ String attributeName, Object value)
+ throws TranslatorException {
+
+ if (value.toString().equals("Test%")) {
+ ++CNT;
+ }
+ }
+
+ };
+
+ visitor.visit(command);
+
+ validateSelectVisitorAllRootTableColumns(op);
+ assertEquals("Like Criteria", 1, CNT);
+ }
+
+ private void validateSelectVisitorAllRootTableColumns(ObjectProjections visitor) throws
Exception {
+
+ Column[] columns = visitor.getColumns();
+ String[] columnNamesToUse = visitor.getColumnNamesToUse();
+
+// String[] colnames = visitor.getColumnNames();
+
+ assertNotNull("ColumnNames", columns);
+ assertEquals("Column Names", Trade.NUM_ATTRIBUTES, columns.length);
+ assertEquals("Column Names", columnNamesToUse.length, columns.length);
+
+
+ boolean hasName = false;
+ boolean hasTradeId = false;
+ for (int i=0; i<columns.length; i++) {
+ Column col = columns[i];
+ if (col.getName().equalsIgnoreCase("Name")) hasName = true;
+ else if (col.getName().equalsIgnoreCase("TradeId")) hasTradeId = true;
+ // don't validate NIS, because it can be null
+// assertNotNull("Column NIS", visitor.getColumnNameInSource(colnames[i]));
+ assertNotNull("Column Type", col.getDatatype());
+ assertNotNull("Column Java Type", col.getJavaType());
+ assertNotNull("Column Name to Use", columnNamesToUse[i]);
+ assertNotNull("Column Native Type", col.getNativeType());
+
+ assertNotNull("Column Table Name", col.getParent().getName());
+
+
+ }
+
+ assertTrue("Missing NAME column", hasName);
+ assertTrue("Missing TRADEID column", hasTradeId);
+ }
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Leg.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Leg.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Leg.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object.testdata;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.List;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.ProvidedId;
+
+@Indexed @ProvidedId
+public class Leg implements Serializable {
+
+ // 4 attributes, transactions is not selectable
+ public static int NUM_ATTRIBUTES = 4;
+
+ private static final long serialVersionUID = 7683272638393477962L;
+
+private @Field double notational;
+private @Field long id;
+private @Field String name;
+private @Field Calendar createdDateTime;
+
+private @IndexedEmbedded List<Transaction> transactions = null;
+
+ public Leg() {
+ super();
+ }
+
+ public Leg(long legId, String name, double notional, Calendar date) {
+ this.notational = notional;
+ this.id=legId;
+ this.name=name;
+ this.createdDateTime=date;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public long getLegId() {
+ return id;
+ }
+
+ public void setLegId(long id) {
+ this.id = id;
+ }
+
+
+ public void setNotational(double notional) {
+ this.notational = notional;
+ }
+
+ public double getNotational() {
+ return notational;
+ }
+
+ public void setCreatedDateTime(Calendar ts) {
+ this.createdDateTime = ts;
+ }
+ public Calendar getCreatedDateTime() {
+ return this.createdDateTime;
+ }
+
+ public void setTransations(List<Transaction> transactions) {
+ this.transactions = transactions;
+ }
+
+ public List<Transaction> getTransactions() {
+ return this.transactions;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer("Leg:");
+ sb.append(" id " + getLegId());
+ sb.append(" name " + getName());
+ sb.append(" notational " + getNotational());
+ sb.append(" createdDate " + getCreatedDateTime());
+ sb.append(" numTransactions " + getTransactions());
+
+
+
+ return sb.toString();
+ }
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Trade.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Trade.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Trade.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object.testdata;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.IndexedEmbedded;
+import org.hibernate.search.annotations.ProvidedId;
+
+
+@Indexed @ProvidedId
+public class Trade implements Serializable {
+
+ // 4 attributes, legs is not selectable
+ public static int NUM_ATTRIBUTES = 4;
+
+ private static final long serialVersionUID = 8611785625511714561L;
+
+private @IndexedEmbedded Map<Object, Object> legs;
+private @Field long tradeId;
+private @Field String name;
+private @Field Date tradeDate;
+private @Field boolean settled;
+
+ public Trade() {
+ }
+
+ public Trade(long tradeId, String name, Map<Object, Object> legs, Date
tradeDate) {
+ this.legs = legs;
+ this.tradeId = tradeId;
+ this.name = name;
+ this.tradeDate=tradeDate;
+ }
+
+ public long getTradeId() {
+ return tradeId;
+ }
+
+ public void setTradeId(long id) {
+ this.tradeId = id;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public Date getTradeDate() {
+ return this.tradeDate;
+ }
+
+ public boolean isSettled() {
+ return this.settled;
+ }
+
+ public void setTradeDate(Date date) {
+ this.tradeDate = date;
+ }
+
+ public void setLegs(Map<Object, Object> legs) {
+ this.legs = legs;
+ }
+
+ public void setSettled(boolean isSettled) {
+ this.settled = isSettled;
+ }
+
+ public Map<Object, Object> getLegs() {
+ if (legs == null) {
+ legs = new HashMap();
+ }
+ return legs;
+ }
+
+ public String toString() {
+
+ StringBuffer sb = new StringBuffer("Trade:");
+ sb.append(" id " + getTradeId());
+ sb.append(" name " + getName());
+ sb.append(" settled " + isSettled());
+ sb.append(" tradeDate " + getTradeDate());
+ sb.append(" numLegs " + getLegs().size());
+
+ return sb.toString();
+ }
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/TradesCacheSource.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/TradesCacheSource.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/TradesCacheSource.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object.testdata;
+
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * Sample cache of objects
+ *
+ * @author vhalbert
+ *
+ */
+@SuppressWarnings("rawtypes")
+public class TradesCacheSource extends HashMap <Object, Object> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -727553658250070494L;
+
+
+ public static final String TRADE_CLASS_NAME = Trade.class.getName();
+ public static final String LEG_CLASS_NAME = Leg.class.getName();
+ public static final String TRANSACTION_CLASS_NAME = Transaction.class.getName();
+
+
+ public static final int NUMLEGS = 10;
+ public static final int NUMTRADES = 3;
+ public static final int NUMTRANSACTIONS = 5;
+
+
+ public static void loadCache(Map<Object, Object> cache) {
+ for (int i = 1; i <= NUMTRADES; i++) {
+
+ Map legsMap = new HashMap();
+ double d = 0;
+ for (int j = 1; j <= NUMLEGS; j++) {
+
+ Leg leg = new Leg(j, "LegName " + j, d * j * 3.14,
Calendar.getInstance());
+
+ List trans = new ArrayList(NUMTRANSACTIONS);
+ for (int x = 1; x <= NUMTRANSACTIONS; x++) {
+ Transaction t = new Transaction();
+ t.setLineItem("Leg " + j + ", transaction line item " + x);
+ trans.add(t);
+ }
+
+ leg.setTransations(trans);
+ leg.setNotational(i * 7 / 3.14);
+
+ legsMap.put(j, leg);
+ }
+
+ Trade trade = new Trade(i, "TradeName " + i, legsMap, new Date());
+
+ // even trades set settled to true
+ if ( i % 2 == 0) {
+ trade.setSettled(true);
+ }
+
+ cache.put(i, trade);
+
+ }
+ }
+
+ public static TradesCacheSource loadCache() {
+ TradesCacheSource tcs = new TradesCacheSource();
+ loadCache(tcs);
+ return tcs;
+ }
+
+ public List<Object> getAll() {
+ return new ArrayList<Object>(this.values());
+ }
+
+ public List<Object> get(int key) {
+ List<Object> objs = new ArrayList<Object>(1);
+ objs.add(this.get(key));
+ return objs;
+ }
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Transaction.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Transaction.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/Transaction.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.object.testdata;
+
+import java.io.Serializable;
+
+import org.hibernate.search.annotations.Field;
+import org.hibernate.search.annotations.Indexed;
+import org.hibernate.search.annotations.ProvidedId;
+
+@Indexed @ProvidedId
+public class Transaction implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private @Field Object li = null;
+
+ @Indexed @ProvidedId
+ final class LineItem implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ @Field String description = null;
+
+
+ public String toString() {
+ return description;
+ }
+ }
+
+ public void setLineItem(Object description) {
+ LineItem item = new LineItem();
+ item.description = description.toString();
+ li = item;
+ }
+
+ public Object getLineItem() {
+ return li;
+ }
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/VDBUtility.java
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/VDBUtility.java
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/java/org/teiid/translator/object/testdata/VDBUtility.java 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */package org.teiid.translator.object.testdata;
+
+import java.io.File;
+
+import org.teiid.cdk.api.TranslationUtility;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.metadata.RuntimeMetadata;
+
+
+public class VDBUtility {
+
+ public static TranslationUtility TRANSLATION_UTILITY = null;
+
+ public static RuntimeMetadata RUNTIME_METADATA = null;
+
+ static {
+ File f = new File(UnitTestUtil.getTestDataPath() +
"/ObjectProject/Trade.vdb");
+ System.out.println("TestDataPath " + f.getAbsolutePath());
+ try {
+ TRANSLATION_UTILITY = new TranslationUtility(f.toURI().toURL());
+ } catch (Throwable e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+
+ RUNTIME_METADATA = VDBUtility.TRANSLATION_UTILITY.createRuntimeMetadata();
+ }
+
+
+}
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetColumns.expected
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetColumns.expected
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetColumns.expected 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,30 @@
+string string
string
string
long string
long long long long
long string
string long
long long long string
string
string
string long
+TABLE_CAT TABLE_SCHEM
TABLE_NAME
COLUMN_NAME
DATA_TYPE TYPE_NAME
COLUMN_SIZE BUFFER_LENGTH DECIMAL_DIGITS NUM_PREC_RADIX
NULLABLE REMARKS
COLUMN_DEF SQL_DATA_TYPE
SQL_DATETIME_SUB CHAR_OCTET_LENGTH ORDINAL_POSITION IS_NULLABLE
SCOPE_CATLOG
SCOPE_SCHEMA
SCOPE_TABLE SOURCE_DATA_TYPE
+<null> NULL
Trade
getTradeDate
2000 java.lang.Object
0 NULL 0 0 2
NULL
0 0
0 1 YES
NULL
NULL NULL
0
+<null> NULL
Trade
getName
12 java.lang.String
0 NULL 0 0 2
NULL
0 0
0 2 YES
NULL
NULL NULL
0
+<null> NULL
Trade
getTradeId
2000 java.lang.Object
0 NULL 0 0 2
NULL
0 0
0 3 YES
NULL
NULL NULL
0
+<null> NULL
Trade
getLegs
2000 java.lang.Object
0 NULL 0 0 2
NULL
0 0
0 4 YES
NULL
NULL NULL
0
+Row Count : 4
+getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel
getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision
getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable
isReadOnly isSearchable isSigned isWritable
+TABLE_CAT 12 <null> java.lang.String TABLE_CAT
string <null> <null> 4000
4000 0 false false false false
1 true false false false
+TABLE_SCHEM 12 <null> java.lang.String TABLE_SCHEM
string <null> <null> 4000
4000 0 false false false false
1 true false false false
+TABLE_NAME 12 <null> java.lang.String TABLE_NAME
string <null> <null> 4000
4000 0 false false false false
0 true false false false
+COLUMN_NAME 12 <null> java.lang.String COLUMN_NAME
string <null> <null> 4000
4000 0 false false false false
0 true false false false
+DATA_TYPE -5 <null> java.lang.Long DATA_TYPE
long <null> <null> 20 19
0 false false false false 0
true false false false
+TYPE_NAME 12 <null> java.lang.String TYPE_NAME
string <null> <null> 4000
4000 0 false false false false
0 true false false false
+COLUMN_SIZE -5 <null> java.lang.Long COLUMN_SIZE
long <null> <null> 20 19
0 false false false false 0
true false false false
+BUFFER_LENGTH -5 <null> java.lang.Long BUFFER_LENGTH
long <null> <null> 20 19
0 false false false false 1
true false false false
+DECIMAL_DIGITS -5 <null> java.lang.Long
DECIMAL_DIGITS long <null> <null> 20
19 0 false false false false
0 true false false false
+NUM_PREC_RADIX -5 <null> java.lang.Long
NUM_PREC_RADIX long <null> <null> 20
19 0 false false false false
0 true false false false
+NULLABLE -5 <null> java.lang.Long NULLABLE
long <null> <null> 20 19
0 false false false false 0
true false false false
+REMARKS 12 <null> java.lang.String REMARKS
string <null> <null> 4000
4000 0 false false false false
1 true false false false
+COLUMN_DEF 12 <null> java.lang.String COLUMN_DEF
string <null> <null> 4000
4000 0 false false false false
1 true false false false
+SQL_DATA_TYPE -5 <null> java.lang.Long SQL_DATA_TYPE
long <null> <null> 20 19
0 false false false false 0
true false false false
+SQL_DATETIME_SUB -5 <null> java.lang.Long
SQL_DATETIME_SUB long <null> <null> 20
19 0 false false false false
0 true false false false
+CHAR_OCTET_LENGTH -5 <null> java.lang.Long
CHAR_OCTET_LENGTH long <null> <null> 20
19 0 false false false false
0 true false false false
+ORDINAL_POSITION -5 <null> java.lang.Long
ORDINAL_POSITION long <null> <null> 20
19 0 false false false false
0 true false false false
+IS_NULLABLE 12 <null> java.lang.String IS_NULLABLE
string <null> <null> 4000
4000 0 false false false false
1 true false false false
+SCOPE_CATLOG 12 <null> java.lang.String SCOPE_CATLOG
string <null> <null> 4000
4000 0 false false false false
1 true false false false
+SCOPE_SCHEMA 12 <null> java.lang.String SCOPE_SCHEMA
string <null> <null> 4000
4000 0 false false false false
1 true false false false
+SCOPE_TABLE 12 <null> java.lang.String SCOPE_TABLE
string <null> <null> 4000
4000 0 false false false false
1 true false false false
+SOURCE_DATA_TYPE -5 <null> java.lang.Long
SOURCE_DATA_TYPE long <null> <null> 20
19 0 false false false false
0 true false false false
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTableTypes.expected
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTableTypes.expected
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTableTypes.expected 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,6 @@
+string
+TABLE_TYPE
+TABLE
+Row Count : 1
+getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel
getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision
getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable
isReadOnly isSearchable isSigned isWritable
+TABLE_TYPE 12 <null> java.lang.String TABLE_TYPE
string <null> <null> 4000 4000
0 false false false false 0
true false false false
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables.expected
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables.expected
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables.expected 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,17 @@
+string string
string
string
string string
string
string
string string
+TABLE_CAT TABLE_SCHEM
TABLE_NAME
TABLE_TYPE
REMARKS TYPE_CAT
TYPE_SCHEM
TYPE_NAME
SELF_REFERENCING_COL_NAME REF_GENERATION
+NULL NULL
Trade
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+NULL NULL
Leg
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+NULL NULL
Transaction
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+Row Count : 3
+getColumnName getColumnType getCatalogName getColumnClassName
getColumnLabel getColumnTypeName getSchemaName getTableName
getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency
isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
+TABLE_CAT 12 <null> java.lang.String
TABLE_CAT string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_SCHEM 12 <null> java.lang.String
TABLE_SCHEM string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_NAME 12 <null> java.lang.String
TABLE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TABLE_TYPE 12 <null> java.lang.String
TABLE_TYPE string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REMARKS 12 <null> java.lang.String
REMARKS string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_CAT 12 <null> java.lang.String
TYPE_CAT string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_SCHEM 12 <null> java.lang.String
TYPE_SCHEM string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_NAME 12 <null> java.lang.String
TYPE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+SELF_REFERENCING_COL_NAME 12 <null> java.lang.String
SELF_REFERENCING_COL_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REF_GENERATION 12 <null> java.lang.String
REF_GENERATION string <null> <null>
4000 4000 0 false false false
false 0 true false false false
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables_for3ClassNames.expected
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables_for3ClassNames.expected
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables_for3ClassNames.expected 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,17 @@
+string string
string
string
string string
string
string
string string
+TABLE_CAT TABLE_SCHEM
TABLE_NAME
TABLE_TYPE
REMARKS TYPE_CAT
TYPE_SCHEM
TYPE_NAME
SELF_REFERENCING_COL_NAME REF_GENERATION
+NULL NULL
Trade
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+NULL NULL
Leg
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+NULL NULL
Transaction
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+Row Count : 3
+getColumnName getColumnType getCatalogName getColumnClassName
getColumnLabel getColumnTypeName getSchemaName getTableName
getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency
isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
+TABLE_CAT 12 <null> java.lang.String
TABLE_CAT string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_SCHEM 12 <null> java.lang.String
TABLE_SCHEM string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_NAME 12 <null> java.lang.String
TABLE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TABLE_TYPE 12 <null> java.lang.String
TABLE_TYPE string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REMARKS 12 <null> java.lang.String
REMARKS string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_CAT 12 <null> java.lang.String
TYPE_CAT string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_SCHEM 12 <null> java.lang.String
TYPE_SCHEM string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_NAME 12 <null> java.lang.String
TYPE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+SELF_REFERENCING_COL_NAME 12 <null> java.lang.String
SELF_REFERENCING_COL_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REF_GENERATION 12 <null> java.lang.String
REF_GENERATION string <null> <null>
4000 4000 0 false false false
false 0 true false false false
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables_ofSpecificTableType.expected
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables_ofSpecificTableType.expected
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDatabaseMetaDataTest/testGetTables_ofSpecificTableType.expected 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,17 @@
+string string
string
string
string string
string
string
string string
+TABLE_CAT TABLE_SCHEM
TABLE_NAME
TABLE_TYPE
REMARKS TYPE_CAT
TYPE_SCHEM
TYPE_NAME
SELF_REFERENCING_COL_NAME REF_GENERATION
+NULL NULL
Trade
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+NULL NULL
Leg
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+NULL NULL
Transaction
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+Row Count : 3
+getColumnName getColumnType getCatalogName getColumnClassName
getColumnLabel getColumnTypeName getSchemaName getTableName
getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency
isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
+TABLE_CAT 12 <null> java.lang.String
TABLE_CAT string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_SCHEM 12 <null> java.lang.String
TABLE_SCHEM string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_NAME 12 <null> java.lang.String
TABLE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TABLE_TYPE 12 <null> java.lang.String
TABLE_TYPE string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REMARKS 12 <null> java.lang.String
REMARKS string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_CAT 12 <null> java.lang.String
TYPE_CAT string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_SCHEM 12 <null> java.lang.String
TYPE_SCHEM string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_NAME 12 <null> java.lang.String
TYPE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+SELF_REFERENCING_COL_NAME 12 <null> java.lang.String
SELF_REFERENCING_COL_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REF_GENERATION 12 <null> java.lang.String
REF_GENERATION string <null> <null>
4000 4000 0 false false false
false 0 true false false false
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor1Class.expected
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor1Class.expected
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor1Class.expected 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,15 @@
+string string
string
string
string string
string
string
string string
+TABLE_CAT TABLE_SCHEM
TABLE_NAME
TABLE_TYPE
REMARKS TYPE_CAT
TYPE_SCHEM
TYPE_NAME
SELF_REFERENCING_COL_NAME REF_GENERATION
+NULL NULL
Trade
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+Row Count : 1
+getColumnName getColumnType getCatalogName getColumnClassName
getColumnLabel getColumnTypeName getSchemaName getTableName
getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency
isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
+TABLE_CAT 12 <null> java.lang.String
TABLE_CAT string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_SCHEM 12 <null> java.lang.String
TABLE_SCHEM string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_NAME 12 <null> java.lang.String
TABLE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TABLE_TYPE 12 <null> java.lang.String
TABLE_TYPE string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REMARKS 12 <null> java.lang.String
REMARKS string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_CAT 12 <null> java.lang.String
TYPE_CAT string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_SCHEM 12 <null> java.lang.String
TYPE_SCHEM string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_NAME 12 <null> java.lang.String
TYPE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+SELF_REFERENCING_COL_NAME 12 <null> java.lang.String
SELF_REFERENCING_COL_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REF_GENERATION 12 <null> java.lang.String
REF_GENERATION string <null> <null>
4000 4000 0 false false false
false 0 true false false false
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor2Classes.expected
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor2Classes.expected
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor2Classes.expected 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,16 @@
+string string
string
string
string string
string
string
string string
+TABLE_CAT TABLE_SCHEM
TABLE_NAME
TABLE_TYPE
REMARKS TYPE_CAT
TYPE_SCHEM
TYPE_NAME
SELF_REFERENCING_COL_NAME REF_GENERATION
+NULL NULL
Trade
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+NULL NULL
Leg
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+Row Count : 2
+getColumnName getColumnType getCatalogName getColumnClassName
getColumnLabel getColumnTypeName getSchemaName getTableName
getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency
isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
+TABLE_CAT 12 <null> java.lang.String
TABLE_CAT string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_SCHEM 12 <null> java.lang.String
TABLE_SCHEM string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_NAME 12 <null> java.lang.String
TABLE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TABLE_TYPE 12 <null> java.lang.String
TABLE_TYPE string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REMARKS 12 <null> java.lang.String
REMARKS string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_CAT 12 <null> java.lang.String
TYPE_CAT string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_SCHEM 12 <null> java.lang.String
TYPE_SCHEM string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_NAME 12 <null> java.lang.String
TYPE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+SELF_REFERENCING_COL_NAME 12 <null> java.lang.String
SELF_REFERENCING_COL_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REF_GENERATION 12 <null> java.lang.String
REF_GENERATION string <null> <null>
4000 4000 0 false false false
false 0 true false false false
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor3Classes.expected
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor3Classes.expected
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectDriverIntegrationTest/getTablesFor3Classes.expected 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,17 @@
+string string
string
string
string string
string
string
string string
+TABLE_CAT TABLE_SCHEM
TABLE_NAME
TABLE_TYPE
REMARKS TYPE_CAT
TYPE_SCHEM
TYPE_NAME
SELF_REFERENCING_COL_NAME REF_GENERATION
+NULL NULL
Trade
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+NULL NULL
Leg
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+NULL NULL
Transaction
TABLE
NULL NULL
NULL
NULL NULL
DERIVED
+Row Count : 3
+getColumnName getColumnType getCatalogName getColumnClassName
getColumnLabel getColumnTypeName getSchemaName getTableName
getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency
isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
+TABLE_CAT 12 <null> java.lang.String
TABLE_CAT string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_SCHEM 12 <null> java.lang.String
TABLE_SCHEM string <null> <null>
4000 4000 0 false false false
false 1 true false false false
+TABLE_NAME 12 <null> java.lang.String
TABLE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TABLE_TYPE 12 <null> java.lang.String
TABLE_TYPE string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REMARKS 12 <null> java.lang.String
REMARKS string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_CAT 12 <null> java.lang.String
TYPE_CAT string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_SCHEM 12 <null> java.lang.String
TYPE_SCHEM string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+TYPE_NAME 12 <null> java.lang.String
TYPE_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+SELF_REFERENCING_COL_NAME 12 <null> java.lang.String
SELF_REFERENCING_COL_NAME string <null> <null>
4000 4000 0 false false false
false 0 true false false false
+REF_GENERATION 12 <null> java.lang.String
REF_GENERATION string <null> <null>
4000 4000 0 false false false
false 0 true false false false
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/Trade.vdb
===================================================================
(Binary files differ)
Property changes on:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/Trade.vdb
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/Trade_Object.xmi
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/Trade_Object.xmi
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/Trade_Object.xmi 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="ASCII"?>
+<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:diagram="http://www.metamatrix.com/metamodels/Diagram"
xmlns:jdbc="http://www.metamatrix.com/metamodels/JDBC"
xmlns:mmcore="http://www.metamatrix.com/metamodels/Core"
xmlns:relational="http://www.metamatrix.com/metamodels/Relational&qu...
+ <mmcore:ModelAnnotation
xmi:uuid="mmuuid:abbd65a2-2896-4819-9428-fa8ba13a1b71"
primaryMetamodelUri="http://www.metamatrix.com/metamodels/Relational...
modelType="PHYSICAL" ProducerName="Teiid Designer"
ProducerVersion="7.7.0.v20120327-0117-H1030-Beta2">
+ <modelImports xmi:uuid="mmuuid:7c40d324-5eca-472f-a7a8-c20b01f5d848"
name="SimpleDatatypes-instance"
modelLocation="http://www.metamatrix.com/metamodels/SimpleDatatypes-...
modelType="TYPE"
primaryMetamodelUri="http://www.eclipse.org/xsd/2002/XSD"/>
+ <modelImports xmi:uuid="mmuuid:ec47f017-3602-4c78-b25f-64d1611529f2"
name="XMLSchema"
modelLocation="http://www.w3.org/2001/XMLSchema"
modelType="TYPE"
primaryMetamodelUri="http://www.eclipse.org/xsd/2002/XSD"/>
+ </mmcore:ModelAnnotation>
+ <diagram:DiagramContainer
xmi:uuid="mmuuid:060329df-f071-436c-91d8-8de84f4a38b3">
+ <diagram xmi:uuid="mmuuid:0d512295-f6e7-418d-8409-f7e689137c68"
type="packageDiagramType"
target="mmuuid/abbd65a2-2896-4819-9428-fa8ba13a1b71">
+ <diagramEntity xmi:uuid="mmuuid:0556cf27-0b7f-4670-ba1d-f958c70d1619"
name="Trade" modelObject="mmuuid/5b23705c-0091-412a-9e79-c61ed02bd618"
xPosition="131" yPosition="57"/>
+ <diagramEntity xmi:uuid="mmuuid:ada12275-d21b-4036-bcc9-c869229899ab"
name="Leg" modelObject="mmuuid/3c3beef7-0a75-4bbb-9aaa-7ea240da41f3"
xPosition="495" yPosition="69"/>
+ <diagramEntity xmi:uuid="mmuuid:38199303-f03d-43ea-b506-a3d7e0be856b"
modelObject="mmuuid/6c111154-eb05-4aca-ae33-d5a7d0c67e46"/>
+ </diagram>
+ </diagram:DiagramContainer>
+ <relational:BaseTable
xmi:uuid="mmuuid:5b23705c-0091-412a-9e79-c61ed02bd618" name="Trade"
nameInSource=""Trade"">
+ <columns xmi:uuid="mmuuid:1a601c6c-979c-4a8a-9128-ac1c9cf853a8"
name="TradeDate" nameInSource="TradeDate"
nativeType="java.util.Date" fixedLength="true"
nullable="NULLABLE_UNKNOWN" defaultValue="NULL"
caseSensitive="false" searchability="ALL_EXCEPT_LIKE">
+ <type
href="http://www.w3.org/2001/XMLSchema#date"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:139a5ee2-44dc-4b5f-b3d0-68a269ffd7a1"
name="Name" nameInSource="Name"
nativeType="java.lang.String" length="4000"
nullable="NULLABLE_UNKNOWN" defaultValue="NULL">
+ <type
href="http://www.w3.org/2001/XMLSchema#string"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:9ac8e953-1818-4ce6-a9d8-14d1a8539370"
name="TradeId" nameInSource="TradeId" nativeType="long"
fixedLength="true" nullable="NULLABLE_UNKNOWN"
defaultValue="NULL" caseSensitive="false"
searchability="ALL_EXCEPT_LIKE"
uniqueKeys="mmuuid/ac210048-f093-4ed3-9af4-90669fc99c3c">
+ <type
href="http://www.w3.org/2001/XMLSchema#long"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:6aa63e1e-d16b-4d6c-b927-ca19a96cb619"
name="Legs" nameInSource="Legs" nativeType="java.util.Map"
fixedLength="true" nullable="NULLABLE_UNKNOWN"
defaultValue="NULL" selectable="false" updateable="false"
caseSensitive="false" searchability="UNSEARCHABLE">
+ <type
href="http://www.metamatrix.com/metamodels/SimpleDatatypes-instance#...
+ </columns>
+ <columns xmi:uuid="mmuuid:7f3823ba-96f9-43d6-9155-e2e707babccc"
name="Settled" nameInSource="Settled" nativeType="boolean"
fixedLength="true" nullable="NULLABLE_UNKNOWN"
defaultValue="NULL" caseSensitive="false"
searchability="ALL_EXCEPT_LIKE">
+ <type
href="http://www.w3.org/2001/XMLSchema#boolean"/>
+ </columns>
+ <primaryKey xmi:uuid="mmuuid:ac210048-f093-4ed3-9af4-90669fc99c3c"
name="TradeId_PK"
columns="mmuuid/9ac8e953-1818-4ce6-a9d8-14d1a8539370"
foreignKeys="mmuuid/3a3196cd-3e6c-48bf-aa02-e6c99fb1fafe"/>
+ </relational:BaseTable>
+ <relational:BaseTable
xmi:uuid="mmuuid:3c3beef7-0a75-4bbb-9aaa-7ea240da41f3" name="Leg"
nameInSource=""Leg"">
+ <columns xmi:uuid="mmuuid:3ad9207c-b90f-4aca-bd66-8cd9b3a0e2a3"
name="LegId" nameInSource="LegId" nativeType="long"
fixedLength="true" nullable="NULLABLE_UNKNOWN"
defaultValue="NULL" caseSensitive="false"
searchability="ALL_EXCEPT_LIKE"
uniqueKeys="mmuuid/ea715b26-57e0-4245-b3a4-d326dcde47aa">
+ <type
href="http://www.w3.org/2001/XMLSchema#long"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:19abbb02-6270-4e16-8daa-539e4d024808"
name="Name" nameInSource="Name"
nativeType="java.lang.String" length="4000"
nullable="NULLABLE_UNKNOWN" defaultValue="NULL">
+ <type
href="http://www.w3.org/2001/XMLSchema#string"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:90f53b02-1ff3-4275-ab86-20465b5e0b77"
name="Transactions" nameInSource="Transactions"
nativeType="java.util.List" fixedLength="true"
nullable="NULLABLE_UNKNOWN" defaultValue="NULL"
selectable="false" updateable="false" caseSensitive="false"
searchability="UNSEARCHABLE">
+ <type
href="http://www.metamatrix.com/metamodels/SimpleDatatypes-instance#...
+ </columns>
+ <columns xmi:uuid="mmuuid:e542a4df-c982-42b7-9f15-ccda9006762c"
name="CreatedDateTime" nameInSource="CreatedDateTime"
nativeType="java.util.Calendar" fixedLength="true"
nullable="NULLABLE_UNKNOWN" defaultValue="NULL"
caseSensitive="false" searchability="ALL_EXCEPT_LIKE">
+ <type
href="http://www.w3.org/2001/XMLSchema#string"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:3ef7317b-0b54-4bbe-b634-aee7910cc5ca"
name="Notational" nameInSource="Notational"
nativeType="double" fixedLength="true"
nullable="NULLABLE_UNKNOWN" defaultValue="NULL"
caseSensitive="false" searchability="ALL_EXCEPT_LIKE">
+ <type
href="http://www.w3.org/2001/XMLSchema#double"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:e08030b0-2255-4f9e-a61f-f3d3a419f9f9"
name="TradeId" nameInSource="TradeId" nativeType="long"
fixedLength="true" nullable="NULLABLE_UNKNOWN"
defaultValue="NULL" selectable="false" updateable="false"
caseSensitive="false" searchability="UNSEARCHABLE"
foreignKeys="mmuuid/3a3196cd-3e6c-48bf-aa02-e6c99fb1fafe">
+ <type
href="http://www.w3.org/2001/XMLSchema#long"/>
+ </columns>
+ <foreignKeys xmi:uuid="mmuuid:3a3196cd-3e6c-48bf-aa02-e6c99fb1fafe"
name="LegToTrade_FK" nameInSource="Legs"
primaryKeyMultiplicity="ZERO_TO_MANY"
columns="mmuuid/e08030b0-2255-4f9e-a61f-f3d3a419f9f9"
uniqueKey="mmuuid/ac210048-f093-4ed3-9af4-90669fc99c3c"/>
+ <primaryKey xmi:uuid="mmuuid:ea715b26-57e0-4245-b3a4-d326dcde47aa"
name="LegID_PK" columns="mmuuid/3ad9207c-b90f-4aca-bd66-8cd9b3a0e2a3"
foreignKeys="mmuuid/63d1f569-9637-421f-b1c1-489cbd759315"/>
+ </relational:BaseTable>
+ <mmcore:AnnotationContainer
xmi:uuid="mmuuid:146acc5c-ec00-4c47-b40f-bcde7a260d72">
+ <annotations xmi:uuid="mmuuid:01b2c46c-61f1-416d-8fea-e21204a8b5d0"
description="NULL"
annotatedObject="mmuuid/3c3beef7-0a75-4bbb-9aaa-7ea240da41f3"/>
+ <annotations xmi:uuid="mmuuid:a6eeddb2-f866-4e9d-8fce-d81ac06fd133"
description="NULL"
annotatedObject="mmuuid/6c111154-eb05-4aca-ae33-d5a7d0c67e46"/>
+ <annotations xmi:uuid="mmuuid:be09e12b-a29d-491e-9819-e968dc67eb38"
description="NULL"
annotatedObject="mmuuid/5b23705c-0091-412a-9e79-c61ed02bd618"/>
+ </mmcore:AnnotationContainer>
+ <relational:BaseTable
xmi:uuid="mmuuid:6c111154-eb05-4aca-ae33-d5a7d0c67e46"
name="Transaction" nameInSource=""Transaction"">
+ <columns xmi:uuid="mmuuid:ed5c696c-a021-4a05-b5d1-61e398931773"
name="LineItem" nameInSource="LineItem"
nativeType="java.lang.Object" fixedLength="true"
nullable="NULLABLE_UNKNOWN" defaultValue="NULL"
caseSensitive="false" searchability="UNSEARCHABLE">
+ <type
href="http://www.w3.org/2001/XMLSchema#string"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:4065954d-91fc-45e2-8893-8221644a7719"
name="LegId" nameInSource="TradeId" nativeType="long"
fixedLength="true" nullable="NULLABLE_UNKNOWN"
defaultValue="NULL" selectable="false" updateable="false"
caseSensitive="false" searchability="UNSEARCHABLE"
foreignKeys="mmuuid/63d1f569-9637-421f-b1c1-489cbd759315">
+ <type
href="http://www.w3.org/2001/XMLSchema#long"/>
+ </columns>
+ <foreignKeys xmi:uuid="mmuuid:63d1f569-9637-421f-b1c1-489cbd759315"
name="TransToLeg_FK" nameInSource="Transactions"
primaryKeyMultiplicity="ZERO_TO_MANY"
columns="mmuuid/4065954d-91fc-45e2-8893-8221644a7719"
uniqueKey="mmuuid/ea715b26-57e0-4245-b3a4-d326dcde47aa"/>
+ </relational:BaseTable>
+ <jdbc:JdbcSource xmi:uuid="mmuuid:700653fe-5c8f-46f2-abb5-343af1927615"
name="Object JDBC" driverName="Object JDBC Driver"
driverClass="org.teiid.translator.object.jdbcdriver.ObjectDriver"
username="user"
url="jdbc:object:classNames=org.teiid.translator.object.testdata.Trade,org.teiid.translator.object.testdata.Leg,org.teiid.translator.object.testdata.Transaction">
+ <importSettings xmi:uuid="mmuuid:2d204a81-1586-4bee-aedf-0bb09155a701"
createCatalogsInModel="false" createSchemasInModel="false"
includeIndexes="false" includeApproximateIndexes="false">
+ <includedTableTypes>TABLE</includedTableTypes>
+ </importSettings>
+ </jdbc:JdbcSource>
+</xmi:XMI>
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/Trade_View.xmi
===================================================================
---
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/Trade_View.xmi
(rev 0)
+++
branches/7.7.x/connectors/translator-object/src/test/resources/ObjectProject/Trade_View.xmi 2012-04-24
16:22:56 UTC (rev 4029)
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="ASCII"?>
+<xmi:XMI xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:diagram="http://www.metamatrix.com/metamodels/Diagram"
xmlns:mmcore="http://www.metamatrix.com/metamodels/Core"
xmlns:relational="http://www.metamatrix.com/metamodels/Relational"
xmlns:transformation="http://www.metamatrix.com/metamodels/Transform...
+ <mmcore:ModelAnnotation
xmi:uuid="mmuuid:5a3d4831-477f-42b8-bb8e-62a895f62365"
primaryMetamodelUri="http://www.metamatrix.com/metamodels/Relational...
modelType="VIRTUAL" ProducerName="Teiid Designer"
ProducerVersion="7.7.0.v20120327-0117-H1030-Beta2">
+ <modelImports xmi:uuid="mmuuid:d3b3585d-b97d-4f9f-885f-b653f01daddc"
name="Trade_Object" modelLocation="Trade_Object.xmi"
uuid="mmuuid:abbd65a2-2896-4819-9428-fa8ba13a1b71"
modelType="PHYSICAL"
primaryMetamodelUri="http://www.metamatrix.com/metamodels/Relational...
+ <modelImports xmi:uuid="mmuuid:48862877-960f-45c6-90fe-d97b49508ddd"
name="XMLSchema"
modelLocation="http://www.w3.org/2001/XMLSchema"
modelType="TYPE"
primaryMetamodelUri="http://www.eclipse.org/xsd/2002/XSD"/>
+ </mmcore:ModelAnnotation>
+ <mmcore:AnnotationContainer
xmi:uuid="mmuuid:376f12cd-a07c-430a-89f6-72c21a43f334"/>
+ <transformation:TransformationContainer
xmi:uuid="mmuuid:82fc8a9d-fa7a-4f42-bd2c-435128e99bf2">
+ <transformationMappings
xsi:type="transformation:SqlTransformationMappingRoot"
xmi:uuid="mmuuid:e1683238-ae62-4ea5-9862-d89aa6a618c1"
outputs="mmuuid/d1202de2-c370-42ad-851b-5cfb89fb19de"
target="mmuuid/d1202de2-c370-42ad-851b-5cfb89fb19de">
+ <helper xsi:type="transformation:SqlTransformation"
xmi:uuid="mmuuid:e347fd3e-3a26-4942-82cc-e219f8f90d5f">
+ <nested xsi:type="transformation:SqlTransformation"
xmi:uuid="mmuuid:c1e16e72-4ca7-4c2d-9eea-8554bd7bc304"
selectSql="SELECT
		Trade_Object.Trade.TradeId,
Trade_Object.Trade.Name, Trade_Object.Leg.LegId, Trade_Object.Leg.Notational,
Trade_Object.Leg.Name AS LegName,
Trade_Object.Trade.Settled
	FROM
		Trade_Object.Trade,
Trade_Object.Leg"/>
+ <aliases xmi:uuid="mmuuid:4e39271e-ea0b-4419-ab90-75aa072e4475"
alias="Trade">
+ <aliasedObject
href="Trade_Object.xmi#mmuuid/5b23705c-0091-412a-9e79-c61ed02bd618"/>
+ </aliases>
+ <aliases xmi:uuid="mmuuid:60a538ba-5ecd-4ccc-afd7-0a359d2a8180"
alias="Leg">
+ <aliasedObject
href="Trade_Object.xmi#mmuuid/3c3beef7-0a75-4bbb-9aaa-7ea240da41f3"/>
+ </aliases>
+ </helper>
+ <nested xsi:type="transformation:TransformationMapping"
xmi:uuid="mmuuid:21b5cb8c-f40e-4b98-b6f1-1a53c2dfb568"
outputs="mmuuid/6a07d2c3-b0ee-4b29-85ee-bfc9e874cb10">
+ <inputs
href="Trade_Object.xmi#mmuuid/9ac8e953-1818-4ce6-a9d8-14d1a8539370"/>
+ </nested>
+ <nested xsi:type="transformation:TransformationMapping"
xmi:uuid="mmuuid:01039342-1945-4db0-b0f2-bfbe8488dc71"
outputs="mmuuid/7a44decb-8083-4a9c-acfa-8ed71d1cc308">
+ <inputs
href="Trade_Object.xmi#mmuuid/139a5ee2-44dc-4b5f-b3d0-68a269ffd7a1"/>
+ </nested>
+ <nested xsi:type="transformation:TransformationMapping"
xmi:uuid="mmuuid:245d2337-8396-43f0-a75e-ac6037d22baf"
outputs="mmuuid/0fb2cad2-eaee-4b73-8411-994eb7eb3fd0">
+ <inputs
href="Trade_Object.xmi#mmuuid/3ad9207c-b90f-4aca-bd66-8cd9b3a0e2a3"/>
+ </nested>
+ <nested xsi:type="transformation:TransformationMapping"
xmi:uuid="mmuuid:7101182e-04c9-4d12-8141-ca2fdaa90ad1"
outputs="mmuuid/77da2470-3fc1-4fdf-94b4-de43b30b5f25">
+ <inputs
href="Trade_Object.xmi#mmuuid/3ef7317b-0b54-4bbe-b634-aee7910cc5ca"/>
+ </nested>
+ <nested xsi:type="transformation:TransformationMapping"
xmi:uuid="mmuuid:bd02fb13-86c7-4af7-a439-d76739b85bb9"
outputs="mmuuid/e62074a4-0366-4332-b6a4-8fbe855a96ca">
+ <inputs
href="Trade_Object.xmi#mmuuid/19abbb02-6270-4e16-8daa-539e4d024808"/>
+ </nested>
+ <nested xsi:type="transformation:TransformationMapping"
xmi:uuid="mmuuid:411dcb19-5da1-4ecc-9980-fe4e1b6f63fc"
outputs="mmuuid/c4fe20fa-2936-4131-9df1-79f0347e19ca">
+ <inputs
href="Trade_Object.xmi#mmuuid/7f3823ba-96f9-43d6-9155-e2e707babccc"/>
+ </nested>
+ <inputs
href="Trade_Object.xmi#mmuuid/5b23705c-0091-412a-9e79-c61ed02bd618"/>
+ <inputs
href="Trade_Object.xmi#mmuuid/3c3beef7-0a75-4bbb-9aaa-7ea240da41f3"/>
+ </transformationMappings>
+ </transformation:TransformationContainer>
+ <diagram:DiagramContainer
xmi:uuid="mmuuid:e3ea76b1-8edd-4f68-8fea-346d5ceb2a0c">
+ <diagram xmi:uuid="mmuuid:cd1589b7-71af-4fba-bbac-15c75732b75a"
type="packageDiagramType"
target="mmuuid/5a3d4831-477f-42b8-bb8e-62a895f62365">
+ <diagramEntity xmi:uuid="mmuuid:3927d9a9-77fd-4662-8029-4127e7b0f87c"
modelObject="mmuuid/d1202de2-c370-42ad-851b-5cfb89fb19de"/>
+ </diagram>
+ <diagram xmi:uuid="mmuuid:e009ec34-e8c3-419d-bb0c-c4ab6fc9511a"
type="transformationDiagramType"
target="mmuuid/d1202de2-c370-42ad-851b-5cfb89fb19de">
+ <diagramEntity xmi:uuid="mmuuid:aaa3adb9-255e-4b77-a560-69eb0d65de26"
name="Trades_View"
modelObject="mmuuid/d1202de2-c370-42ad-851b-5cfb89fb19de"
xPosition="30" yPosition="50"/>
+ <diagramEntity xmi:uuid="mmuuid:a403e12c-a40a-48fc-8677-31f0b0319c60"
name="T" modelObject="mmuuid/e1683238-ae62-4ea5-9862-d89aa6a618c1"
xPosition="211" yPosition="50"/>
+ <diagramEntity xmi:uuid="mmuuid:8db4da4d-2983-463a-a929-44fd158c1c37"
xPosition="261" yPosition="50">
+ <modelObject
href="Trade_Object.xmi#mmuuid/5b23705c-0091-412a-9e79-c61ed02bd618"/>
+ </diagramEntity>
+ <diagramEntity xmi:uuid="mmuuid:74af4ac8-e4ae-4853-8d45-638b1b5813bc"
xPosition="434" yPosition="50">
+ <modelObject
href="Trade_Object.xmi#mmuuid/3c3beef7-0a75-4bbb-9aaa-7ea240da41f3"/>
+ </diagramEntity>
+ </diagram>
+ </diagram:DiagramContainer>
+ <relational:BaseTable
xmi:uuid="mmuuid:d1202de2-c370-42ad-851b-5cfb89fb19de"
name="Trades_View" supportsUpdate="false">
+ <columns xmi:uuid="mmuuid:6a07d2c3-b0ee-4b29-85ee-bfc9e874cb10"
name="TradeID">
+ <type
href="http://www.w3.org/2001/XMLSchema#long"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:7a44decb-8083-4a9c-acfa-8ed71d1cc308"
name="Name" length="4000" caseSensitive="false">
+ <type
href="http://www.w3.org/2001/XMLSchema#string"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:0fb2cad2-eaee-4b73-8411-994eb7eb3fd0"
name="LegID">
+ <type
href="http://www.w3.org/2001/XMLSchema#long"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:77da2470-3fc1-4fdf-94b4-de43b30b5f25"
name="Notational">
+ <type
href="http://www.w3.org/2001/XMLSchema#double"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:e62074a4-0366-4332-b6a4-8fbe855a96ca"
name="LegName" length="4000">
+ <type
href="http://www.w3.org/2001/XMLSchema#string"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:c4fe20fa-2936-4131-9df1-79f0347e19ca"
name="Settled" fixedLength="true"
nullable="NULLABLE_UNKNOWN" defaultValue="NULL"
caseSensitive="false" searchability="ALL_EXCEPT_LIKE">
+ <type
href="http://www.w3.org/2001/XMLSchema#boolean"/>
+ </columns>
+ </relational:BaseTable>
+</xmi:XMI>
Added:
branches/7.7.x/connectors/translator-object/src/test/resources/testQueryIncludeLegs.expected
===================================================================
(Binary files differ)
Property changes on:
branches/7.7.x/connectors/translator-object/src/test/resources/testQueryIncludeLegs.expected
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream