Author: van.halbert
Date: 2012-09-28 08:43:11 -0400 (Fri, 28 Sep 2012)
New Revision: 4485
Removed:
trunk/connectors/translator-object/.settings/org.eclipse.jdt.core.prefs
trunk/connectors/translator-object/.settings/org.maven.ide.eclipse.prefs
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/util/ObjectUtil.java
Modified:
trunk/connectors/translator-object/
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecution.java
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecutionFactory.java
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectPlugin.java
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanBaseExecutionFactory.java
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanConnectionImpl.java
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanExecutionFactory.java
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanRemoteExecutionFactory.java
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/search/LuceneSearch.java
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/search/SearchByKey.java
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/mapcache/MapCacheExecutionFactory.java
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/search/BasicKeySearchCriteria.java
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/search/SearchCriterion.java
trunk/connectors/translator-object/src/main/resources/org/teiid/translator/object/i18n.properties
trunk/connectors/translator-object/src/test/example_vdbs/infinispancache-vdb.xml
trunk/connectors/translator-object/src/test/example_vdbs/infinispanremotecache-vdb.xml
trunk/connectors/translator-object/src/test/example_vdbs/mapcache-vdb.xml
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/infinispan/TestInfinispanJndiILuceneSearch.java
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/infinispan/TestInfinispanJndiKeySearch.java
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/mapcache/TestMapCacheKeySearch.java
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/search/TestBasicKeySearchCriteria.java
Log:
TEIID-2210 - general generic/cast/nls cleanup, increasing MAX_SET_SIZE to 10000, and
corrrections to BasicKeySearchCriteria based on assumption that only a PK can be used to
query the cache
Property changes on: trunk/connectors/translator-object
___________________________________________________________________
Modified: svn:ignore
- target
+ .settings
Deleted: trunk/connectors/translator-object/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/connectors/translator-object/.settings/org.eclipse.jdt.core.prefs 2012-09-28
12:02:37 UTC (rev 4484)
+++ trunk/connectors/translator-object/.settings/org.eclipse.jdt.core.prefs 2012-09-28
12:43:11 UTC (rev 4485)
@@ -1,6 +0,0 @@
-#Wed Jan 25 12:40:49 CST 2012
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.6
Deleted: trunk/connectors/translator-object/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- trunk/connectors/translator-object/.settings/org.maven.ide.eclipse.prefs 2012-09-28
12:02:37 UTC (rev 4484)
+++ trunk/connectors/translator-object/.settings/org.maven.ide.eclipse.prefs 2012-09-28
12:43:11 UTC (rev 4485)
@@ -1,6 +0,0 @@
-#Wed Jan 25 12:40:49 CST 2012
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
-org.eclipse.jdt.core.compiler.source=1.6
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecution.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecution.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecution.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -81,7 +81,7 @@
LogConstants.CTX_CONNECTOR,
"ObjectExecution calling search strategy : " +
connection.getClass().getName()); //$NON-NLS-1$
- return connection.performSearch((Select) query);
+ return connection.performSearch(query);
}
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecutionFactory.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecutionFactory.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectExecutionFactory.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -22,8 +22,6 @@
package org.teiid.translator.object;
-import java.util.Collections;
-import java.util.List;
import java.util.Map;
import javax.naming.Context;
@@ -51,7 +49,7 @@
public abstract class ObjectExecutionFactory extends
ExecutionFactory<ConnectionFactory, ObjectConnection> {
- public static final int MAX_SET_SIZE = 1000;
+ public static final int MAX_SET_SIZE = 10000;
// rootClassName identifies the name of the class that is identified by the
// unique key in the cache
@@ -81,9 +79,9 @@
if (this.getRootClassName() == null
|| this.getRootClassName().trim().length() == -1) {
String msg = ObjectPlugin.Util.getString(
- "ObjectExecutionFactory.rootClassNameNotDefined",
+ "ObjectExecutionFactory.rootClassNameNotDefined", //$NON-NLS-1$
new Object[] {});
- throw new TranslatorException(msg); //$NON-NLS-1$
+ throw new TranslatorException(msg);
}
try {
@@ -92,9 +90,9 @@
} catch (ClassNotFoundException e) {
String msg = ObjectPlugin.Util.getString(
- "ObjectExecutionFactory.rootClassNotFound",
+ "ObjectExecutionFactory.rootClassNotFound", //$NON-NLS-1$
new Object[] { this.rootClassName });
- throw new TranslatorException(msg); //$NON-NLS-1$
+ throw new TranslatorException(msg);
}
}
@@ -109,12 +107,6 @@
}
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- public List getSupportedFunctions() {
- return Collections.EMPTY_LIST;
- }
-
@Override
public boolean supportsInnerJoins() {
return false;
@@ -143,10 +135,6 @@
return true;
}
- public boolean supportsOrCriteria() {
- return true;
- }
-
@Override
public boolean supportsLikeCriteria() {
// at this point, i've been unable to get the Like to work.
@@ -189,11 +177,8 @@
*
* @param rootClassName
*/
- public synchronized void setRootClassName(String rootClassName) {
- if (this.rootClassName == null) {
- this.rootClassName = rootClassName;
-
- }
+ public void setRootClassName(String rootClassName) {
+ this.rootClassName = rootClassName;
}
/**
@@ -213,9 +198,7 @@
* @param jndiName the JNDI name of the {@link Map cache} instance that should be
used
* @see #setCacheJndiName(String)
*/
- public synchronized void setCacheJndiName( String jndiName ) {
- if (this.cacheJndiName == jndiName || this.cacheJndiName != null
- && this.cacheJndiName.equals(jndiName)) return; // unchanged
+ public void setCacheJndiName( String jndiName ) {
this.cacheJndiName = jndiName;
}
@@ -241,28 +224,31 @@
if (jndiName != null && jndiName.trim().length() != 0) {
try {
Context context = null;
- if (context == null) {
- try {
- context = new InitialContext();
- } catch (NamingException err) {
- throw new TranslatorException(err);
- }
- }
+ try {
+ context = new InitialContext();
+ } catch (NamingException err) {
+ throw new TranslatorException(err);
+ }
cache = context.lookup(jndiName);
if (cache == null) {
String msg = ObjectPlugin.Util.getString(
- "ObjectExecutionFactory.cacheNotFoundinJNDI",
+ "ObjectExecutionFactory.cacheNotFoundinJNDI", //$NON-NLS-1$
new Object[] { jndiName });
- throw new TranslatorException(msg); //$NON-NLS-1$
+ throw new TranslatorException(msg);
}
- } catch (Throwable err) {
+ } catch (Exception err) {
if (err instanceof RuntimeException) throw (RuntimeException)err;
throw new TranslatorException(err);
}
}
return cache;
}
+
+ @Override
+ public boolean supportsOnlyLiteralComparison() {
+ return true;
+ }
}
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectPlugin.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectPlugin.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/ObjectPlugin.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -39,9 +39,5 @@
public static final BundleUtil Util = new BundleUtil(PLUGIN_ID, PLUGIN_ID +
".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$
//$NON-NLS-2$
public static enum Event implements BundleUtil.Event {
- TEIID12001, // unsupported capability
- TEIID12005,
- TEIID12006,
- TEIID12007,
}
}
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanBaseExecutionFactory.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanBaseExecutionFactory.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanBaseExecutionFactory.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -21,10 +21,6 @@
*/
package org.teiid.translator.object.infinispan;
-import java.io.File;
-import java.io.IOException;
-import java.util.Properties;
-
import javax.resource.cci.ConnectionFactory;
import org.infinispan.Cache;
@@ -32,9 +28,11 @@
import org.infinispan.api.BasicCacheContainer;
import org.infinispan.manager.CacheContainer;
import org.infinispan.manager.DefaultCacheManager;
+import org.teiid.metadata.MetadataFactory;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.TranslatorException;
import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.object.JavaBeanMetadataProcessor;
import org.teiid.translator.object.ObjectConnection;
import org.teiid.translator.object.ObjectExecutionFactory;
import org.teiid.translator.object.ObjectPlugin;
@@ -45,8 +43,6 @@
*
*/
public abstract class InfinispanBaseExecutionFactory extends ObjectExecutionFactory {
- public static final String PROPERTIES_FILE = "META-INF" + File.separator
- + "datagrid.properties";
private String cacheName = null;
private String configurationFileName = null;
@@ -60,10 +56,8 @@
super.start();
if (this.getCacheName() == null || this.getCacheName().isEmpty()) {
- String msg = ObjectPlugin.Util.getString(
- "InfinispanBaseExecutionFactory.cacheNameNotDefined",
- new Object[] {});
- throw new TranslatorException(msg); //$NON-NLS-1$
+ String msg =
ObjectPlugin.Util.getString("InfinispanBaseExecutionFactory.cacheNameNotDefined");
//$NON-NLS-1$
+ throw new TranslatorException(msg);
}
}
@@ -164,15 +158,26 @@
if (cache == null) {
String msg = ObjectPlugin.Util.getString(
- "InfinispanBaseExecutionFactory.cacheNotFound", new Object[] {
(getCacheName() != null ? getCacheName()
- : "DefaultCache") });
- throw new TranslatorException(msg); //$NON-NLS-1$
+ "InfinispanBaseExecutionFactory.cacheNotFound", new Object[] {
(getCacheName() != null ? getCacheName() //$NON-NLS-1$
+ : "DefaultCache") }); //$NON-NLS-1$
+ throw new TranslatorException(msg);
}
return cache;
}
+ @Override
+ public void getMetadata(MetadataFactory metadataFactory, ObjectConnection conn)
+ throws TranslatorException {
+ if (this.isFullTextSearchingSupported()) {
+
+ } else {
+ JavaBeanMetadataProcessor processor = new JavaBeanMetadataProcessor();
+ processor.getMetadata(metadataFactory, this);
+ }
+ }
+
@Override
public ObjectConnection getConnection(ConnectionFactory factory,
@@ -181,18 +186,12 @@
return new InfinispanConnectionImpl(this);
}
- protected String jdgProperty(String name) {
- Properties props = new Properties();
- try {
- props.load(this.getClass().getClassLoader()
- .getResourceAsStream(PROPERTIES_FILE));
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- }
- return props.getProperty(name);
- }
-
public void cleanUp() {
}
+
+ @Override
+ public boolean supportsOrCriteria() {
+ return isFullTextSearchingSupported();
+ }
}
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanConnectionImpl.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanConnectionImpl.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanConnectionImpl.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -91,10 +91,8 @@
throws TranslatorException {
if (factory.isFullTextSearchingSupported()) {
return LuceneSearch.performSearch(command, this);
- } else {
- return SearchByKey.performSearch(command, this);
}
-
+ return SearchByKey.performSearch(command, this);
}
public BasicCache<String, Object> getCache()
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanExecutionFactory.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanExecutionFactory.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanExecutionFactory.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -21,9 +21,7 @@
*/
package org.teiid.translator.object.infinispan;
-import java.io.File;
import java.io.IOException;
-import java.util.Properties;
import org.infinispan.api.BasicCacheContainer;
import org.infinispan.manager.DefaultCacheManager;
@@ -56,9 +54,6 @@
*/
@Translator(name = "infinispan-cache", description = "The Infinispan Cache
Translator")
public class InfinispanExecutionFactory extends InfinispanBaseExecutionFactory {
- public static final String PROPERTIES_FILE = "META-INF" + File.separator
- + "datagrid.properties";
-
private boolean supportsLuceneSearching = false;
protected BasicCacheContainer cacheContainer = null;
@@ -78,8 +73,8 @@
if (configFile == null || configFile.trim().length() == 0) {
String msg = ObjectPlugin.Util
.getString(
- "InfinispanExecutionFactory.undefinedHowToGetCache");
- throw new TranslatorException(msg); //$NON-NLS-1$
+ "InfinispanExecutionFactory.undefinedHowToGetCache"); //$NON-NLS-1$
+ throw new TranslatorException(msg);
}
useJndi = false;
@@ -147,10 +142,10 @@
return (BasicCacheContainer) object;
}
String msg = ObjectPlugin.Util.getString(
- "InfinispanExecutionFactory.unsupportedContainerType",
+ "InfinispanExecutionFactory.unsupportedContainerType", //$NON-NLS-1$
new Object[] { object.getClass().getName(),
- "BasicCacheContainer" });
- throw new TranslatorException(msg); //$NON-NLS-1$
+ "BasicCacheContainer" }); //$NON-NLS-1$
+ throw new TranslatorException(msg);
}
@@ -167,17 +162,6 @@
return container;
}
- protected String jdgProperty(String name) {
- Properties props = new Properties();
- try {
- props.load(this.getClass().getClassLoader()
- .getResourceAsStream(PROPERTIES_FILE));
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- }
- return props.getProperty(name);
- }
-
public void cleanUp() {
this.cacheContainer = null;
}
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanRemoteExecutionFactory.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanRemoteExecutionFactory.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/InfinispanRemoteExecutionFactory.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -115,7 +115,7 @@
} else {
if (this.getRemoteServerList() == null
|| this.getRemoteServerList().isEmpty()
- || this.getRemoteServerList().equals("")) {
+ || this.getRemoteServerList().equals("")) { //$NON-NLS-1$
container = new RemoteCacheManager();
LogManager
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/search/LuceneSearch.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/search/LuceneSearch.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/search/LuceneSearch.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -31,16 +31,7 @@
import org.infinispan.query.CacheQuery;
import org.infinispan.query.Search;
import org.infinispan.query.SearchManager;
-import org.teiid.language.AndOr;
-import org.teiid.language.ColumnReference;
-import org.teiid.language.Comparison;
-import org.teiid.language.Condition;
-import org.teiid.language.Exists;
-import org.teiid.language.Expression;
-import org.teiid.language.In;
-import org.teiid.language.Like;
-import org.teiid.language.Literal;
-import org.teiid.language.Select;
+import org.teiid.language.*;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.Column;
@@ -64,7 +55,7 @@
throws TranslatorException {
SearchManager searchManager = Search
- .getSearchManager((Cache) connection.getCache() );
+ .getSearchManager((Cache<?, ?>) connection.getCache() );
QueryBuilder queryBuilder = searchManager.buildQueryBuilderForClass(
connection.getFactory().getRootClass()).get();
@@ -145,7 +136,7 @@
default:
final String msg = ObjectPlugin.Util
- .getString("LuceneSearch.invalidOperator", new Object[] { op, "And,
Or" }); //$NON-NLS-1$
+ .getString("LuceneSearch.invalidOperator", new Object[] { op, "And,
Or" }); //$NON-NLS-1$ //$NON-NLS-2$
throw new TranslatorException(msg);
}
@@ -179,10 +170,10 @@
LogManager.logTrace(LogConstants.CTX_CONNECTOR,
"Parsing Comparison criteria."); //$NON-NLS-1$
- Comparison.Operator op = ((Comparison) obj).getOperator();
+ Comparison.Operator op = obj.getOperator();
- Expression lhs = ((Comparison) obj).getLeftExpression();
- Expression rhs = ((Comparison) obj).getRightExpression();
+ Expression lhs = obj.getLeftExpression();
+ Expression rhs = obj.getRightExpression();
// joins between the objects in the same cache is not usable
if ((lhs instanceof ColumnReference && rhs instanceof ColumnReference)
@@ -231,7 +222,7 @@
default:
final String msg = ObjectPlugin.Util
- .getString("LuceneSearch.invalidOperator", new Object[] { op, "NE,
EQ, GT, LT" }); //$NON-NLS-1$
+ .getString("LuceneSearch.invalidOperator", new Object[] { op, "NE,
EQ, GT, LT" }); //$NON-NLS-1$ //$NON-NLS-2$
throw new TranslatorException(msg);
}
return true;
@@ -241,11 +232,11 @@
public static boolean visit(In obj, BooleanJunction<BooleanJunction> junction,
QueryBuilder queryBuilder) throws TranslatorException {
LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing IN criteria.");
//$NON-NLS-1$
- Expression lhs = ((In) obj).getLeftExpression();
+ Expression lhs = obj.getLeftExpression();
Column mdIDElement = ((ColumnReference) lhs).getMetadataObject();
- List<Expression> rhsList = ((In) obj).getRightExpressions();
+ List<Expression> rhsList = obj.getRightExpressions();
boolean createdQuery = false;
for (Expression expr : rhsList) {
@@ -259,8 +250,8 @@
createdQuery = true;
} else {
String msg = ObjectPlugin.Util.getString(
- "LuceneSearch.Unsupported_expression",
- new Object[] { expr, "IN" });
+ "LuceneSearch.Unsupported_expression", //$NON-NLS-1$
+ new Object[] { expr, "IN" }); //$NON-NLS-1$
throw new TranslatorException(msg);
}
}
@@ -271,8 +262,8 @@
LogManager.logTrace(LogConstants.CTX_CONNECTOR,
"Parsing LIKE criteria."); //$NON-NLS-1$
- Expression lhs = ((Like) obj).getLeftExpression();
- Expression rhs = ((Like) obj).getRightExpression();
+ Expression lhs = obj.getLeftExpression();
+ Expression rhs = obj.getRightExpression();
Column c = null;
Expression literalExp = null;
@@ -289,11 +280,11 @@
value = (String) escapeReservedChars(((Literal) literalExp)
.getValue());
- createLikeQuery(c, value.replaceAll("%", ""), junction,
queryBuilder); // "*"
+ createLikeQuery(c, value.replaceAll("%", ""), junction,
queryBuilder); // "*" //$NON-NLS-1$ //$NON-NLS-2$
} else {
final String msg = ObjectPlugin.Util.getString(
- "LuceneSearch.Unsupported_expression",
- new Object[] { literalExp.toString(), "LIKE" });
+ "LuceneSearch.Unsupported_expression", //$NON-NLS-1$
+ new Object[] { literalExp.toString(), "LIKE" }); //$NON-NLS-1$
throw new TranslatorException(msg);
}
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/search/SearchByKey.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/search/SearchByKey.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/infinispan/search/SearchByKey.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -56,30 +56,22 @@
}
private static List<Object> get(SearchCriterion criterion,
- BasicCache<String, Object> cache, Class rootClass)
+ BasicCache<String, Object> cache, Class<?> rootClass)
throws TranslatorException {
List<Object> results = null;
if (criterion.getOperator() == SearchCriterion.Operator.ALL) {
-
- if (cache instanceof RemoteCache) {
+ Map<String, Object> map = cache;
+ if (cache instanceof RemoteCache<?, ?>) {
RemoteCache<?, ?> rc = (RemoteCache<?, ?>) cache;
- Map<?, ?> c = rc.getBulk();
- results = new ArrayList<Object>();
- for (Iterator it = c.keySet().iterator(); it.hasNext();) {
- Object v = cache.get(it.next());
- addValue(v, results, rootClass);
- }
-
- } else {
- Set keys = cache.keySet();
- results = new ArrayList<Object>();
- for (Iterator it = keys.iterator(); it.hasNext();) {
- Object v = cache.get(it.next());
- addValue(v, results, rootClass);
- }
+ map = (Map<String, Object>) rc.getBulk();
}
-
+ Set<String> keys = map.keySet();
+ results = new ArrayList<Object>();
+ for (Iterator<?> it = keys.iterator(); it.hasNext();) {
+ Object v = cache.get(it.next());
+ addValue(v, results, rootClass);
+ }
return results;
}
@@ -91,7 +83,6 @@
results = new ArrayList<Object>();
}
-
if (criterion.getOperator().equals(SearchCriterion.Operator.EQUALS)) {
Object value = criterion.getValue();
@@ -120,7 +111,7 @@
}
- private static void addValue(Object value, List<Object> results, Class
rootNodeType) {
+ private static void addValue(Object value, List<Object> results, Class<?>
rootNodeType) {
if (value != null && value.getClass().equals(rootNodeType)) {
if (value.getClass().isArray()) {
@@ -129,13 +120,13 @@
return;
}
- if (value instanceof Collection) {
- results.addAll((Collection) value);
+ if (value instanceof Collection<?>) {
+ results.addAll((Collection<?>) value);
return;
}
- if (value instanceof Map) {
- Map<?, Object> mapRows = (Map) value;
+ if (value instanceof Map<?, ?>) {
+ Map<?, ?> mapRows = (Map<?, ?>) value;
results.addAll(mapRows.values());
return;
}
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/mapcache/MapCacheExecutionFactory.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/mapcache/MapCacheExecutionFactory.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/mapcache/MapCacheExecutionFactory.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -27,9 +27,11 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.metadata.MetadataFactory;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.Translator;
import org.teiid.translator.TranslatorException;
+import org.teiid.translator.object.JavaBeanMetadataProcessor;
import org.teiid.translator.object.ObjectConnection;
import org.teiid.translator.object.ObjectExecutionFactory;
import org.teiid.translator.object.ObjectPlugin;
@@ -58,26 +60,19 @@
if (jndiName == null || jndiName.trim().length() == 0) {
String msg = ObjectPlugin.Util
.getString(
- "MapCacheExecutionFactory.undefinedJndiName", new Object[] { });
- throw new TranslatorException(msg); //$NON-NLS-1$
+ "MapCacheExecutionFactory.undefinedJndiName"); //$NON-NLS-1$
+ throw new TranslatorException(msg);
}
}
- @Override
- public boolean supportsOnlyLiteralComparison() {
- return true;
- }
-
-
protected synchronized Map<?,?> getCache() throws TranslatorException {
if (this.cache != null) return this.cache;
Object object = findCacheUsingJNDIName();
- Map<?,?> cache = null;
- if (object instanceof Map) {
+ if (object instanceof Map<?,?>) {
cache = (Map<?,?>)object;
@@ -85,14 +80,12 @@
} else {
String msg = ObjectPlugin.Util.getString(
- "MapCacheExecutionFactory.unexpectedCacheType",
- new Object[] { (object == null ? "nullObject" :
object.getClass().getName()), "Map" });
- throw new TranslatorException(msg); //$NON-NLS-1$
+ "MapCacheExecutionFactory.unexpectedCacheType", //$NON-NLS-1$
+ new Object[] { (object == null ? "nullObject" :
object.getClass().getName()), "Map" }); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new TranslatorException(msg);
}
- this.cache = cache;
return this.cache;
-
}
@@ -104,4 +97,11 @@
return new MapCacheConnection(this);
}
+
+ @Override
+ public void getMetadata(MetadataFactory metadataFactory, ObjectConnection conn)
+ throws TranslatorException {
+ JavaBeanMetadataProcessor processor = new JavaBeanMetadataProcessor();
+ processor.getMetadata(metadataFactory, this);
+ }
}
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/search/BasicKeySearchCriteria.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/search/BasicKeySearchCriteria.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/search/BasicKeySearchCriteria.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -24,25 +24,19 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.language.AggregateFunction;
import org.teiid.language.ColumnReference;
import org.teiid.language.Command;
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.Literal;
-import org.teiid.language.ScalarSubquery;
-import org.teiid.language.SearchedCase;
import org.teiid.language.Select;
+import org.teiid.language.Comparison.Operator;
import org.teiid.language.visitor.HierarchyVisitor;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.Column;
-import org.teiid.translator.TranslatorException;
import org.teiid.translator.object.ObjectExecutionFactory;
-import org.teiid.translator.object.ObjectPlugin;
/**
* The BasicKeySearchCriteria parses the {@link Command select} and creates
@@ -58,17 +52,14 @@
// search criteria based on the WHERE clause
private SearchCriterion criterion;
- private List<String> exceptionMessages = new ArrayList<String>(2);
-
private BasicKeySearchCriteria(ObjectExecutionFactory factory) {
}
public static BasicKeySearchCriteria getInstance(
ObjectExecutionFactory factory,
- Select command) throws TranslatorException {
+ Select command) {
BasicKeySearchCriteria visitor = new BasicKeySearchCriteria(factory);
visitor.visitNode(command);
- visitor.throwExceptionIfFound();
return visitor;
}
@@ -80,11 +71,8 @@
* @return
*/
public SearchCriterion getCriterion() {
- if (this.criterion != null) {
-
- } else {
+ if (this.criterion == null) {
this.criterion = new SearchCriterion();
-
}
return this.criterion;
@@ -92,123 +80,58 @@
@Override
public void visit(Comparison obj) {
-
+ if (!(obj.getRightExpression() instanceof Literal)) {
+ //the translator does not support joins, but the unit tests assume that it does
+ return;
+ }
LogManager.logTrace(LogConstants.CTX_CONNECTOR,
"Parsing Comparison criteria."); //$NON-NLS-1$
- Comparison.Operator op = ((Comparison) obj).getOperator();
+ Comparison.Operator op = obj.getOperator();
- Expression lhs = ((Comparison) obj).getLeftExpression();
- Expression rhs = ((Comparison) obj).getRightExpression();
+ Expression lhs = obj.getLeftExpression();
+ Expression rhs = 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)
- || (lhs instanceof Literal && rhs instanceof Literal)) {
- return;
- }
+ Literal literal = (Literal)rhs;
+ Column mdIDElement = ((ColumnReference) lhs).getMetadataObject();
- Object value = null;
- Column mdIDElement = null;
- Literal literal = null;
- if (lhs instanceof ColumnReference && isValidExpression(rhs)) {
- mdIDElement = ((ColumnReference) lhs).getMetadataObject();
- literal = (Literal) rhs;
- value = literal.getValue();
-
- } else if (rhs instanceof ColumnReference && isValidExpression(lhs)) {
- mdIDElement = ((ColumnReference) rhs).getMetadataObject();
- literal = (Literal) lhs;
- value = literal.getValue();
-
- }
-
- if (mdIDElement == null || value == null) {
- String msg = ObjectPlugin.Util
- .getString(
- "BasicKeySearchCriteria.missingComparisonExpression", new Object[] { });
- addException(msg);
- return;
- }
-
addCompareCriteria(mdIDElement,
- escapeReservedChars(literal.getValue()), op);
+ literal.getValue(), op);
}
public void visit(In obj) {
LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Parsing IN criteria.");
//$NON-NLS-1$
- Expression lhs = ((In) obj).getLeftExpression();
- isValidExpression(lhs);
+ Expression lhs = obj.getLeftExpression();
Column mdIDElement = ((ColumnReference) lhs).getMetadataObject();
- List<Expression> rhsList = ((In) obj).getRightExpressions();
+ List<Expression> rhsList = obj.getRightExpressions();
- Class<?> type = lhs.getType();
List<Object> parms = new ArrayList<Object>(rhsList.size());
for (Expression expr : rhsList) {
+ Literal literal = (Literal) expr;
- if (expr instanceof Literal) {
- Literal literal = (Literal) expr;
-
- parms.add(escapeReservedChars(literal.getValue()));
-
- type = literal.getType();
-
- } else {
- String msg = ObjectPlugin.Util
- .getString(
- "BasicKeySearchCriteria.Unsupported_expression", new Object[] {expr });
- addException(msg);
- return;
- }
-
+ parms.add(literal.getValue());
}
- addInCriteria(mdIDElement, parms, type);
+ addInCriteria(mdIDElement, parms);
}
private void addCompareCriteria(Column column, Object value, Operator op) {
- SearchCriterion sc = new SearchCriterion(column, value, op.toString(),
- SearchCriterion.Operator.EQUALS, column.getRuntimeType());
+ SearchCriterion sc = new SearchCriterion(column, value,
SearchCriterion.Operator.EQUALS,
+ column.getRuntimeType());
addSearchCriterion(sc);
}
- private void addInCriteria(Column column, List<Object> parms, Class<?> type)
{
- SearchCriterion sc = new SearchCriterion(column, parms, "in",
- SearchCriterion.Operator.IN, column.getRuntimeType());
+ private void addInCriteria(Column column, List<Object> parms) {
+ SearchCriterion sc = new SearchCriterion(column, parms, SearchCriterion.Operator.IN,
+ column.getRuntimeType());
addSearchCriterion(sc);
-
}
- private boolean isValidExpression(Expression e) {
- if (e instanceof ColumnReference) {
- return true;
- } else if (e instanceof Literal) {
- return true;
-
- } else {
- String msg = null;
- if (e instanceof AggregateFunction) {
- msg = ObjectPlugin.Util.gs(ObjectPlugin.Event.TEIID12001);
- } else if (e instanceof Function) {
- msg = ObjectPlugin.Util.gs(ObjectPlugin.Event.TEIID12005);
- } else if (e instanceof ScalarSubquery) {
- msg = ObjectPlugin.Util.gs(ObjectPlugin.Event.TEIID12006);
- } else if (e instanceof SearchedCase) {
- msg = ObjectPlugin.Util.gs(ObjectPlugin.Event.TEIID12007);
- }
- LogManager.logError(LogConstants.CTX_CONNECTOR, msg + e.toString());
- addException(msg + e.toString());
- }
- return false;
-
- }
-
private void addSearchCriterion(SearchCriterion searchCriteria) {
// only searching on primary key is part of the criteria sent for cache
// lookup
@@ -218,51 +141,10 @@
assert (searchCriteria.getField() != null);
if (this.criterion != null) {
- searchCriteria.addOrCriterion(this.criterion);
+ throw new AssertionError("There should not be more than one predicate against the
primary key"); //$NON-NLS-1$
}
this.criterion = searchCriteria;
}
- protected static Object escapeReservedChars(final Object value) {
- if (value instanceof String) {
- String expr = (String) value;
- 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();
- }
- return value;
- }
-
- private void addException(String msg) {
- exceptionMessages.add(msg);
- }
-
- protected void throwExceptionIfFound() throws TranslatorException {
- if (!exceptionMessages.isEmpty())
- throw new TranslatorException("ObjectProjections Exception: "
- + exceptionMessages.toString());
- }
-
}
Modified:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/search/SearchCriterion.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/search/SearchCriterion.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/search/SearchCriterion.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -22,6 +22,7 @@
package org.teiid.translator.object.search;
import org.teiid.metadata.Column;
+import org.teiid.metadata.ColumnSet;
import org.teiid.metadata.Table;
public class SearchCriterion {
@@ -37,7 +38,6 @@
private boolean isAnd = false;
private Operator operator;
- private String operatorString;
private Column column;
private Object value;
private String runtimeType;
@@ -46,21 +46,17 @@
this.operator = Operator.ALL;
}
- public SearchCriterion(Column column, Object value, String operaterString,
- String type) {
+ public SearchCriterion(Column column, Object value, String type) {
this.column = column;
this.value = value;
- this.operatorString = operaterString;
this.runtimeType = type;
this.operator = Operator.EQUALS;
-
}
- public SearchCriterion(Column column, Object value, String operaterString,
- Operator operator, String type) {
- this(column, value, operaterString, type);
+ public SearchCriterion(Column column, Object value, Operator operator,
+ String type) {
+ this(column, value, type);
this.operator = operator;
-
}
public Column getColumn() {
@@ -68,16 +64,12 @@
}
public String getTableName() {
- Object p = column.getParent();
+ ColumnSet<?> p = column.getParent();
if (p instanceof Table) {
Table t = (Table) p;
return t.getName();
- } else {
- // don't this would happen, but just in case at the moment
- assert (p.getClass().getName() != null);
}
-
- return null;
+ throw new AssertionError();
}
public String getField() {
@@ -100,15 +92,6 @@
this.operator = operator;
}
- public String getOperatorString() {
- return this.operatorString;
- }
-
- public void setOperatorString(String operatorString) {
- this.operatorString = operatorString;
-
- }
-
public String getRuntimeType() {
return this.runtimeType;
}
Deleted:
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/util/ObjectUtil.java
===================================================================
---
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/util/ObjectUtil.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/java/org/teiid/translator/object/util/ObjectUtil.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.translator.object.util;
-
-import java.util.Collection;
-
-import org.teiid.core.util.ReflectionHelper;
-import org.teiid.translator.TranslatorException;
-
-public class ObjectUtil {
-
- 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);
- }
- }
-
- public static Object createObject(String objectClassName,
- Object[] ctorObjs, Class<?>[] argTypes, ClassLoader loader) throws
TranslatorException {
- try {
-
- return ReflectionHelper.create(objectClassName, ctorObjs, argTypes, loader);
- } catch (Exception e1) {
- e1.printStackTrace();
- throw new TranslatorException(e1);
- }
- }
-
-
-}
Modified:
trunk/connectors/translator-object/src/main/resources/org/teiid/translator/object/i18n.properties
===================================================================
---
trunk/connectors/translator-object/src/main/resources/org/teiid/translator/object/i18n.properties 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/main/resources/org/teiid/translator/object/i18n.properties 2012-09-28
12:43:11 UTC (rev 4485)
@@ -19,12 +19,6 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA.
#
-TEIID12001=Received IAggregate, but it is not supported. Check capabilities.
-TEIID12005=Received IFunction, but it is not supported. Check capabilities.
-TEIID12006=Received IScalarSubquery, but it is not supported. Check capabilities.
-TEIID12007=Received ISearchedCaseExpression, but it is not supported. Check
capabilities.
-
-
ObjectExecutionFactory.rootClassNameNotDefined=RootClassName is undefined
ObjectExecutionFactory.rootClassNotFound=RootClass {0} not found to load
ObjectExecutionFactory.cacheNotFoundinJNDI=Cache was not found using JNDI name {0}
Modified:
trunk/connectors/translator-object/src/test/example_vdbs/infinispancache-vdb.xml
===================================================================
---
trunk/connectors/translator-object/src/test/example_vdbs/infinispancache-vdb.xml 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/test/example_vdbs/infinispancache-vdb.xml 2012-09-28
12:43:11 UTC (rev 4485)
@@ -23,7 +23,7 @@
PlayerName varchar(255)
)
AS
- SELECT o.TeamName, y.Name FROM (Select TeamObject from Team) as T,
OBJECTTABLE('x' PASSING T.TeamObject AS x COLUMNS TeamName varchar(255)
'teiid_row.name', players object 'teiid_row.players') as o,
OBJECTTABLE('m' PASSING o.players as m COLUMNS Name string 'teiid_row') as
y;
+ SELECT o.TeamName, y.Name FROM Team as T, OBJECTTABLE('x' PASSING
T.TeamObject AS x COLUMNS TeamName varchar(255) 'teiid_row.name', players object
'teiid_row.players') as o, OBJECTTABLE('m' PASSING o.players as m COLUMNS
Name string 'teiid_row') as y;
]]> </metadata>
</model>
Modified:
trunk/connectors/translator-object/src/test/example_vdbs/infinispanremotecache-vdb.xml
===================================================================
---
trunk/connectors/translator-object/src/test/example_vdbs/infinispanremotecache-vdb.xml 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/test/example_vdbs/infinispanremotecache-vdb.xml 2012-09-28
12:43:11 UTC (rev 4485)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<vdb name="team" version="1">
- <description>Shows how to call Web Services</description>
+ <description>Shows how to call a remoteInfinispan Cache</description>
<property name="UseConnectorMetadata" value="cached" />
<!-- connection-jndi-name="dummy" -->
@@ -23,7 +23,7 @@
PlayerName varchar(255)
)
AS
- SELECT o.TeamName, y.Name FROM (Select TeamObject from Team) as T,
OBJECTTABLE('x' PASSING T.TeamObject AS x COLUMNS TeamName varchar(255)
'teiid_row.name', players object 'teiid_row.players') as o,
OBJECTTABLE('m' PASSING o.players as m COLUMNS Name string 'teiid_row') as
y;
+ SELECT o.TeamName, y.Name FROM Team as T, OBJECTTABLE('x' PASSING
T.TeamObject AS x COLUMNS TeamName varchar(255) 'teiid_row.name', players object
'teiid_row.players') as o, OBJECTTABLE('m' PASSING o.players as m COLUMNS
Name string 'teiid_row') as y;
]]> </metadata>
</model>
Modified: trunk/connectors/translator-object/src/test/example_vdbs/mapcache-vdb.xml
===================================================================
--- trunk/connectors/translator-object/src/test/example_vdbs/mapcache-vdb.xml 2012-09-28
12:02:37 UTC (rev 4484)
+++ trunk/connectors/translator-object/src/test/example_vdbs/mapcache-vdb.xml 2012-09-28
12:43:11 UTC (rev 4485)
@@ -23,7 +23,7 @@
PlayerName varchar(255)
)
AS
- SELECT o.TeamName, y.Name FROM (Select TeamObject from Team) as T,
OBJECTTABLE('x' PASSING T.TeamObject AS x COLUMNS TeamName varchar(255)
'teiid_row.name', players object 'teiid_row.players') as o,
OBJECTTABLE('m' PASSING o.players as m COLUMNS Name string 'teiid_row') as
y;
+ SELECT o.TeamName, y.Name FROM Team as T, OBJECTTABLE('x' PASSING
T.TeamObject AS x COLUMNS TeamName varchar(255) 'teiid_row.name', players object
'teiid_row.players') as o, OBJECTTABLE('m' PASSING o.players as m COLUMNS
Name string 'teiid_row') as y;
]]> </metadata>
</model>
Modified:
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/infinispan/TestInfinispanJndiILuceneSearch.java
===================================================================
---
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/infinispan/TestInfinispanJndiILuceneSearch.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/infinispan/TestInfinispanJndiILuceneSearch.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -21,8 +21,8 @@
*/
package org.teiid.translator.object.infinispan;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.List;
@@ -36,9 +36,7 @@
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.TranslatorException;
import org.teiid.translator.object.BasicSearchTest;
-import org.teiid.translator.object.ObjectConnection;
import org.teiid.translator.object.ObjectExecution;
-import org.teiid.translator.object.infinispan.search.LuceneSearch;
import org.teiid.translator.object.util.TradesCacheSource;
import org.teiid.translator.object.util.VDBUtility;
Modified:
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/infinispan/TestInfinispanJndiKeySearch.java
===================================================================
---
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/infinispan/TestInfinispanJndiKeySearch.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/infinispan/TestInfinispanJndiKeySearch.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -21,28 +21,21 @@
*/
package org.teiid.translator.object.infinispan;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.List;
-import javax.naming.Context;
-
import org.infinispan.manager.CacheContainer;
import org.infinispan.manager.DefaultCacheManager;
import org.junit.Before;
import org.junit.BeforeClass;
-import org.mockito.Mock;
import org.teiid.language.Select;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.TranslatorException;
import org.teiid.translator.object.BasicSearchTest;
-import org.teiid.translator.object.ObjectConnection;
import org.teiid.translator.object.ObjectExecution;
-import org.teiid.translator.object.infinispan.search.SearchByKey;
import org.teiid.translator.object.util.TradesCacheSource;
import org.teiid.translator.object.util.VDBUtility;
Modified:
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/mapcache/TestMapCacheKeySearch.java
===================================================================
---
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/mapcache/TestMapCacheKeySearch.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/mapcache/TestMapCacheKeySearch.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -27,19 +27,26 @@
import static org.mockito.Mockito.when;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import javax.naming.Context;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Test;
import org.mockito.Mock;
import org.teiid.language.Select;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.Table;
+import org.teiid.query.metadata.SystemMetadata;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.TranslatorException;
import org.teiid.translator.object.BasicSearchTest;
import org.teiid.translator.object.ObjectExecution;
+import org.teiid.translator.object.ObjectExecutionFactory;
import org.teiid.translator.object.util.TradesCacheSource;
import org.teiid.translator.object.util.VDBUtility;
@@ -112,6 +119,30 @@
return rows;
}
+ @Test public void testGetMetadata() throws Exception {
+
+ Map dts = SystemMetadata.getInstance().getSystemStore().getDatatypes();
+
+ MetadataFactory mfactory = new MetadataFactory("TestVDB", 1,
"Trade", dts, new Properties(), null);
+
+ MapCacheExecutionFactory factory = new MapCacheExecutionFactory() {
+
+ };
+
+ factory.setCacheJndiName(JNDI_NAME);
+ factory.setRootClassName(TradesCacheSource.TRADE_CLASS_NAME);
+ factory.start();
+
+ factory.getMetadata(mfactory, null);
+
+ Map<String, Table> tables = mfactory.getSchema().getTables();
+ for (Iterator<Table> it=tables.values().iterator(); it.hasNext();) {
+ Table t = it.next();
+ System.out.println(t.getName() + " - " + (t.getSelectTransformation() !=
null ? t.getSelectTransformation() : t.getSQLString()));
+ }
+
+ }
+
}
Modified:
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/search/TestBasicKeySearchCriteria.java
===================================================================
---
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/search/TestBasicKeySearchCriteria.java 2012-09-28
12:02:37 UTC (rev 4484)
+++
trunk/connectors/translator-object/src/test/java/org/teiid/translator/object/search/TestBasicKeySearchCriteria.java 2012-09-28
12:43:11 UTC (rev 4485)
@@ -21,11 +21,10 @@
*/
package org.teiid.translator.object.search;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.teiid.language.Select;
import org.teiid.translator.object.ObjectExecutionFactory;
@@ -70,6 +69,7 @@
}
+ @Ignore(value="Or is unnecessary as the optimizer will use IN and it was not
implemented correctly (the results were not cumulative and we have to restict pushdown
support of comparisions to only the primary key as no post filtering is performed")
@Test public void test5Equals() throws Exception {
Select command = (Select)VDBUtility.TRANSLATION_UTILITY.parseCommand("select *
From Trade_Object.Trade where Trade_Object.Trade.Name = 'MyName' and
(Trade_Object.Trade.TradeId = '2' or Trade_Object.Trade.Settled = 'true')
or (Trade_Object.Trade.Settled = 'false' and Trade_Object.Trade.TradeId = 3)
"); //$NON-NLS-1$
@@ -78,7 +78,6 @@
validateSearchCriteria(criteria.getCriterion(), 5, false, true);
}
-
@Test public void testQueryIncludeLegsNoCriteria() 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$
@@ -141,7 +140,6 @@
assertNotNull(criteria.getColumn());
assertNotNull(criteria.getField());
assertNotNull(criteria.getOperator());
- assertNotNull(criteria.getOperatorString());
assertNotNull(criteria.getTableName());
assertNotNull(criteria.getRuntimeType());
assertNotNull(criteria.getValue());