teiid SVN: r1555 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 15:57:50 -0500 (Mon, 16 Nov 2009)
New Revision: 1555
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java
Log:
Teiid 773 - cleanup and refactoring so that the assumption is there will be 2 datasources required in order to run the test.
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java 2009-11-16 20:57:50 UTC (rev 1555)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.datasource;
+
+import java.sql.Connection;
+import java.sql.Statement;
+
+import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+/**
+ * This class loads the data in the databases specified, to a known state
+ */
+public class DataStore {
+
+ /**
+ * Called at the start of all the tests to initialize the database to ensure
+ * it's in the proper state.
+ *
+ * @param connStrategy
+ */
+ public static void initialize(ConnectionStrategy connStrategy) {
+ try {
+ load(getConnection("pm1", connStrategy));
+
+ load(getConnection("pm2", connStrategy));
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static Connection getConnection(String identifier, ConnectionStrategy connStrategy) throws QueryTestFailedException {
+ Connection conn = connStrategy.createDriverConnection(identifier);
+ // force autocommit back to true, just in case the last user didnt
+ try {
+ conn.setAutoCommit(true);
+ } catch (Exception sqle) {
+ throw new QueryTestFailedException(sqle);
+ }
+
+ return conn;
+ }
+
+ private static void load(Connection c) throws Exception {
+ // DDL
+ // drop table g1;
+ // drop table g2;
+
+ // oracle
+ // create Table g1 (e1 number(5) PRIMARY KEY, e2 varchar2(50));
+ // create Table g2 (e1 number(5) REFERENCES g1, e2 varchar2(50));
+
+ // SQL Server
+ // create Table g1 (e1 int PRIMARY KEY, e2 varchar(50));
+ // create Table g2 (e1 int references g1, e2 varchar(50));
+
+
+ Statement stmt = c.createStatement();
+ stmt.addBatch("delete from g2");
+ stmt.addBatch("delete from g1");
+
+ for (int i = 0; i < 100; i++) {
+ stmt.addBatch("insert into g1 (e1, e2) values("+i+",'"+i+"')");
+ }
+
+
+ for (int i = 0; i < 50; i++) {
+ stmt.addBatch("insert into g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+
+ stmt.executeBatch();
+ stmt.close();
+
+ }
+
+ /**
+ * Called as part of the setup for each test.
+ * This will set the database state as if {@link #initialize(ConnectionStrategy)} was called.
+ * However, for performance reasons, the process goes about removing what's not needed instead of cleaning out everything
+ * and reinstalling.
+ * @param connStrategy
+ */
+ public static void setup(ConnectionStrategy connStrategy) {
+ try {
+ setUpTest(getConnection("pm1", connStrategy));
+
+ setUpTest(getConnection("pm2", connStrategy));
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+
+ }
+
+ private static void setUpTest(Connection c) throws Exception {
+
+ Statement stmt = c.createStatement();
+ stmt.addBatch("delete from g2 where e1 > 50"); //$NON-NLS-1$
+ stmt.addBatch("delete from g1 where e1 > 100");
+
+ stmt.executeBatch();
+ stmt.close();
+
+
+ }
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 1 month
teiid SVN: r1554 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 15:57:31 -0500 (Mon, 16 Nov 2009)
New Revision: 1554
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
Log:
Teiid 773 - cleanup and refactoring so that the assumption is there will be 2 datasources required in order to run the test.
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java 2009-11-16 20:57:15 UTC (rev 1553)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSource.java 2009-11-16 20:57:31 UTC (rev 1554)
@@ -1,7 +1,13 @@
package org.teiid.test.framework.datasource;
+import java.sql.Connection;
import java.util.Properties;
+import javax.sql.XAConnection;
+
+import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
/**
* DataSource represents a single database that was configured by a connection.properties file.
* @author vanhalbert
@@ -17,6 +23,15 @@
private String group;
private String dbtype;
+ // The connections are stored in the datasource and are reused
+ // for the duration of all tests so thats there's not
+ // disconnect/connect being performed over and over
+ private ConnectionStrategy conn;
+ private ConnectionStrategy xaconn;
+
+ public DataSource() {
+ this.name = "notassigned";
+ }
public DataSource(String name, String group, Properties properties) {
this.name = name;
this.group = group;
@@ -49,6 +64,26 @@
return this.dbtype;
}
+
+ public Connection getConnection() throws QueryTestFailedException {
+ if (this.conn == null) return null;
+
+ return this.conn.getConnection();
+ }
+
+ public void setConnection(ConnectionStrategy c) {
+ this.conn = c;
+ }
+
+ public XAConnection getXAConnection() throws QueryTestFailedException {
+ if (this.xaconn == null) return null;
+
+ return this.xaconn.getXAConnection();
+ }
+
+ public void setXAConnection(ConnectionStrategy xaconn) {
+ this.xaconn = xaconn;
+ }
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java 2009-11-16 20:57:15 UTC (rev 1553)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java 2009-11-16 20:57:31 UTC (rev 1554)
@@ -6,12 +6,14 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.exception.QueryTestFailedException;
+import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.util.StringUtil;
@@ -87,16 +89,19 @@
// the DO_NO_USE_DEFAULT will be passed in when the test are run from maven and no property is passed in for UseDataSources
private static final String DO_NOT_USE_DEFAULT="${usedatasources}";
- private ConfigPropertyLoader configprops;
-
+
+ private DataSourceMgr dsmgr = DataSourceMgr.getInstance();
+
+// private ConfigPropertyLoader configprops;
+
+ private Properties configprops;
+
// contains the names of the datasources when the -Dusedatasources option is used
private Map<String, String> useDS = null;
// contains all the datasources available to be used
private Map<String, DataSource> availDS = null;
- // map of the datasources assigned to with model
- private Map<String, DataSource> modelToDatasourceMap = new HashMap<String, DataSource>(); // key = modelname
// contains any dbtype preconditions on a model, which requires a model to be assigned a certain database type
private Map<String, String> requiredDataBaseTypes = null; // key=modelname value=dbtype
@@ -115,10 +120,14 @@
public DataSourceFactory(ConfigPropertyLoader config) {
- this.configprops = config;
+ this.configprops = PropertiesUtils.clone(config.getProperties());
this.requiredDataBaseTypes = config.getModelAssignedDatabaseTypes();
config();
}
+
+ public Properties getConfigProperties() {
+ return this.configprops;
+ }
/**
* config is called at the start / setup of the {@link
@@ -135,10 +144,24 @@
private void config() {
System.out.println("Configure Datasource Factory ");
- Map<String, DataSource> availDatasources = DataSourceMgr.getInstance().getDataSources();
+ Map<String, DataSource> availDatasources = dsmgr.getDataSources();
availDS = new HashMap<String, DataSource>(availDatasources.size());
+ String usedstypeprop = configprops
+ .getProperty(ConfigPropertyNames.USE_DATASOURCE_TYPES_PROP);
+
+ Set<String> useDBTypes = null;
+
+ if (usedstypeprop != null && usedstypeprop.length() > 0) {
+ List<String> eprops = StringUtil.split(usedstypeprop, ",");
+ useDBTypes = new HashSet<String>(eprops.size());
+ useDBTypes.addAll(eprops);
+ System.out.println("EXCLUDE datasources: " + usedstypeprop);
+ } else {
+ useDBTypes = Collections.EMPTY_SET;
+ }
+
String excludeprop = configprops
.getProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
@@ -180,43 +203,23 @@
} else {
for (Iterator<DataSource> it = availDatasources.values().iterator(); it.hasNext(); ) {
DataSource ds = it.next();
+ // if the datasource type is not excluded, then consider for usages
if (!excludedDBTypes.contains(ds.getDBType())) {
+
+ // if use a specific db type is specified, then it must match,
+ // otherwise add it to the available list
+ if (useDBTypes.size() > 0 && usedstypeprop.contains(ds.getDBType())) {
+ availDS.put(ds.getName(), ds);
+ } else {
availDS.put(ds.getName(), ds);
-
- // availDS.putAll(availDatasources);
+ }
+
}
}
+
+
}
-// String excludeprop = configprops
-// .getProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP);
-//
-// Set<String> excludedDBTypes = null;
-//
-// if (excludeprop != null && excludeprop.length() > 0) {
-// List<String> eprops = StringUtil.split(excludeprop, ",");
-// excludedDBTypes = new HashSet<String>(eprops.size());
-// excludedDBTypes.addAll(eprops);
-// System.out.println("EXCLUDE datasources: " + excludeprop);
-//
-// Iterator<DataSource> it = availDS.values().iterator();
-//
-// // go thru all the datasources and remove those that are excluded
-// while (it.hasNext()) {
-// DataSource checkit = it.next();
-//
-// if (excludedDBTypes.contains(checkit.getDBType())) {
-// it.remove();
-//
-// if (useDS != null) {
-// useDS
-// }
-// }
-//
-//
-// }
-//
-// }
if (requiredDataBaseTypes != null) {
@@ -239,7 +242,8 @@
if (ds.getDBType().equalsIgnoreCase(rdbtype)) {
assignedDataSources.add(ds.getName());
- modelToDatasourceMap.put(modelName, ds);
+ dsmgr.setDataSource(modelName, ds);
+ // modelToDatasourceMap.put(modelName, ds);
metDBRequiredTypes = true;
}
@@ -280,8 +284,10 @@
// so that all future request using that group name for a specified
// model
// will use the same datasource
- if (modelToDatasourceMap.containsKey(key)) {
- return modelToDatasourceMap.get(key);
+
+ ds = dsmgr.getDataSource(key);
+ if (ds != null) {
+ return ds;
}
if (this.hasRequiredDBTypes) {
@@ -373,17 +379,18 @@
assignedDataSources.add(ds.getName());
- modelToDatasourceMap.put(key, ds);
+ dsmgr.setDataSource(key, ds);
return ds;
}
public void cleanup() {
- modelToDatasourceMap.clear();
assignedDataSources.clear();
+ requiredDataBaseTypes.clear();
- useDS = null;
+ if (useDS != null) useDS.clear();
+ if (availDS != null) availDS.clear();
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-11-16 20:57:15 UTC (rev 1553)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2009-11-16 20:57:31 UTC (rev 1554)
@@ -15,149 +15,170 @@
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-
-
/**
- * The DataSourceMgr is responsible for loading and managing the datasources defined by the datasource
- * connection properties file. There's only a need to load the set of available datasources once for
- * the duration of the entire test suite. And it will maintain one {@link DataSource} for each connection.properties
- * file that it finds.
+ * The DataSourceMgr is responsible for loading and managing the datasources
+ * defined by the datasource connection properties file. There's only a need to
+ * load the set of available datasources once for the duration of the entire
+ * test suite. And it will maintain one {@link DataSource} for each
+ * connection.properties file that it finds.
*
* @author vanhalbert
*
*/
public class DataSourceMgr {
+ private static DataSourceMgr _instance = null;
- private static DataSourceMgr _instance = null;
-
- private Map<String, DataSource> allDatasourcesMap = new HashMap<String, DataSource>(); // key=datasource name
+ private Map<String, DataSource> allDatasourcesMap = new HashMap<String, DataSource>(); // key
+ // =
+ // datasource
+ // name
- private DataSourceMgr() {
- }
+ // map of the datasources assigned to with model
+ // because only one VDB (Transactions) is used, then this mapping can live
+ // for the
+ // duration of all tests
+ private Map<String, DataSource> modelToDatasourceMap = new HashMap<String, DataSource>(); // key
+ // =
+ // modelname
- public static synchronized DataSourceMgr getInstance() {
- if (_instance == null) {
- _instance = new DataSourceMgr();
- try {
- _instance.loadDataSourceMappings();
- } catch (QueryTestFailedException e) {
- throw new TransactionRuntimeException(e);
- } catch (TransactionRuntimeException e) {
- throw e;
- }
+ private DataSourceMgr() {
+ }
- }
- return _instance;
+ public static synchronized DataSourceMgr getInstance() {
+ if (_instance == null) {
+ _instance = new DataSourceMgr();
+ try {
+ _instance.loadDataSourceMappings();
+ } catch (QueryTestFailedException e) {
+ throw new TransactionRuntimeException(e);
+ } catch (TransactionRuntimeException e) {
+ throw e;
+ }
+
}
-
+ return _instance;
+ }
+
public Map<String, DataSource> getDataSources() {
- Map<String, DataSource> ds = new HashMap<String, DataSource>(allDatasourcesMap.size());
- ds.putAll(allDatasourcesMap);
- return ds;
+ Map<String, DataSource> ds = new HashMap<String, DataSource>(
+ allDatasourcesMap.size());
+ ds.putAll(allDatasourcesMap);
+ return ds;
}
-
- public int numberOfAvailDataSources() {
- return allDatasourcesMap.size();
+
+ public int numberOfAvailDataSources() {
+ return allDatasourcesMap.size();
+ }
+
+ public DataSource getDataSource(String modelname) {
+ if (modelToDatasourceMap.containsKey(modelname)) {
+ return modelToDatasourceMap.get(modelname);
}
-
+ return null;
+ }
- private void loadDataSourceMappings()
- throws QueryTestFailedException {
-
-
- File[] dirs = findAllChildDirectories("./target/classes/datasources/");
- if (dirs == null || dirs.length == 0) {
- throw new TransactionRuntimeException("No datasource directories found at location " + "./target/classes/datasources/");
- }
- for (int i = 0; i < dirs.length; i++) {
- File d = dirs[i];
-
- String dname = d.getName();
-
- addDataSource(dname, d.getName(),allDatasourcesMap);
-
- }
-
- if (allDatasourcesMap == null || allDatasourcesMap.isEmpty()) {
- throw new TransactionRuntimeException(
- "Error: No Datasources were loaded.");
- }
-
- System.out.println("Number of total datasource mappings loaded " + allDatasourcesMap.size());
+ public void setDataSource(String modelName, DataSource ds) {
+ modelToDatasourceMap.put(modelName, ds);
+ }
+ private void loadDataSourceMappings() throws QueryTestFailedException {
+
+ File[] dirs = findAllChildDirectories("./target/classes/datasources/");
+ if (dirs == null || dirs.length == 0) {
+ throw new TransactionRuntimeException(
+ "No datasource directories found at location "
+ + "./target/classes/datasources/");
}
-
- /**
- * Returns a <code>File</code> array that will contain all the directories that exist in the directory
+ for (int i = 0; i < dirs.length; i++) {
+ File d = dirs[i];
+
+ String dname = d.getName();
+
+ addDataSource(dname, d.getName(), allDatasourcesMap);
+
+ }
+
+ if (allDatasourcesMap == null || allDatasourcesMap.isEmpty()) {
+ throw new TransactionRuntimeException(
+ "Error: No Datasources were loaded.");
+ }
+
+ System.out.println("Number of total datasource mappings loaded "
+ + allDatasourcesMap.size());
+
+ }
+
+ /**
+ * Returns a <code>File</code> array that will contain all the directories
+ * that exist in the directory
*
* @return File[] of directories in the directory
*/
private static File[] findAllChildDirectories(String dir) {
- // Find all files in the specified directory
- File mfile = new File(dir);
-
- File modelsDirFile = null;
- try {
- modelsDirFile = new File(mfile.getCanonicalPath());
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ // Find all files in the specified directory
+ File mfile = new File(dir);
+
+ File modelsDirFile = null;
+ try {
+ modelsDirFile = new File(mfile.getCanonicalPath());
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ if (!modelsDirFile.exists()) {
+ return null;
+ }
+ FileFilter fileFilter = new FileFilter() {
+
+ public boolean accept(File file) {
+ if (file.isDirectory()) {
+ return true;
}
- if (!modelsDirFile.exists()) {
- return null;
- }
- FileFilter fileFilter = new FileFilter() {
- public boolean accept(File file) {
- if (file.isDirectory()) {
- return true;
- }
+ return false;
+ }
+ };
- return false;
- }
- };
+ File[] modelFiles = modelsDirFile.listFiles(fileFilter);
- File[] modelFiles = modelsDirFile.listFiles(fileFilter);
+ return modelFiles;
- return modelFiles;
-
}
-
- private void addDataSource(String dirname, String dirloc, Map<String, DataSource> datasources) {
-
-
- String dsfile = "/datasources/" + dirloc + "/connection.properties";
- Properties dsprops = loadProperties(dsfile);
-
- if (dsprops != null) {
- DataSource ds = new DataSource(dirname,
- "dsgroup",
- dsprops);
- datasources.put(ds.getName(), ds);
- System.out.println("Loaded datasource " + ds.getName());
- }
+ private void addDataSource(String dirname, String dirloc,
+ Map<String, DataSource> datasources) {
+ String dsfile = "/datasources/" + dirloc + "/connection.properties";
+ Properties dsprops = loadProperties(dsfile);
+
+ if (dsprops != null) {
+
+ DataSource ds = new DataSource(dirname, "dsgroup", dsprops);
+ datasources.put(ds.getName(), ds);
+ System.out.println("Loaded datasource " + ds.getName());
+
}
+ }
- private static Properties loadProperties(String filename) {
- Properties props = null;
-
- try {
- InputStream in = DataSourceMgr.class.getResourceAsStream(filename);
- if (in != null) {
- props = new Properties();
- props.load(in);
- return props;
- }
- return null;
- } catch (IOException e) {
- throw new TransactionRuntimeException("Error loading properties from file '"
- + filename + "'" + e.getMessage());
- }
- }
+ private static Properties loadProperties(String filename) {
+ Properties props = null;
+ try {
+ InputStream in = DataSourceMgr.class.getResourceAsStream(filename);
+ if (in != null) {
+ props = new Properties();
+ props.load(in);
+ return props;
+ }
+ return null;
+ } catch (IOException e) {
+ throw new TransactionRuntimeException(
+ "Error loading properties from file '" + filename + "'"
+ + e.getMessage());
+ }
+ }
+
}
15 years, 1 month
teiid SVN: r1553 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 15:57:15 -0500 (Mon, 16 Nov 2009)
New Revision: 1553
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java
Log:
Teiid 773 - cleanup and refactoring so that the assumption is there will be 2 datasources required in order to run the test.
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-11-16 20:56:58 UTC (rev 1552)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-11-16 20:57:15 UTC (rev 1553)
@@ -9,9 +9,7 @@
import java.lang.reflect.Method;
import java.sql.Connection;
import java.util.Collection;
-import java.util.HashMap;
import java.util.Iterator;
-import java.util.Map;
import java.util.Properties;
import javax.sql.XAConnection;
@@ -23,26 +21,24 @@
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
import org.teiid.test.framework.datasource.DataSource;
import org.teiid.test.framework.datasource.DataSourceFactory;
+import org.teiid.test.framework.datasource.DataSourceMgr;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
+import com.metamatrix.common.util.PropertiesUtils;
+
public abstract class ConnectionStrategy {
+
- private Map<String, ConnectionStrategy> driversources = null;
- private Map<String, ConnectionStrategy> datasourcesources = null;
- private Map<String, ConnectionStrategy> jeesources = null;
-
-
- private Map<String, DataSource> datasources = null;
-
+ private Properties env = null;
private DataSourceFactory dsFactory;
-
- public ConnectionStrategy(Properties props, DataSourceFactory dsFactory) throws QueryTestFailedException {
- this.env = props;
- this.dsFactory = dsFactory;
-
+
+ public ConnectionStrategy(Properties props, DataSourceFactory dsf) {
+ this.env = PropertiesUtils.clone(props);
+
+ this.dsFactory = dsf;
}
/*
@@ -56,42 +52,12 @@
public abstract Connection getConnection() throws QueryTestFailedException;
/**
- * Implement shutdown of your type of connecton
- *
- *
* @since
*/
- public void shutdown() {
- if (driversources != null) {
- shutDownSources(driversources);
- driversources = null;
- }
-
- if (datasourcesources != null) {
- shutDownSources(datasourcesources);
- datasourcesources = null;
- }
-
- if (jeesources != null) {
- shutDownSources(jeesources);
- jeesources = null;
- }
+ public void shutdown() {
+ this.dsFactory.cleanup();
}
- private void shutDownSources(Map<String, ConnectionStrategy> sources) {
- for (Iterator<String> it=sources.keySet().iterator(); it.hasNext(); ){
- ConnectionStrategy cs = sources.get(it.next());
- try {
- cs.shutdown();
- } catch (Exception e) {
-
- }
-
- }
- sources.clear();
-
- }
-
public Connection getAdminConnection() throws QueryTestFailedException{
return null;
}
@@ -106,22 +72,14 @@
return null;
}
+
- private Properties env = null;
-
public Properties getEnvironment() {
return env;
}
- public int getNumberAvailableDataSources() {
- return this.dsFactory.getNumberAvailableDataSources();
- }
-
- public Map<String, DataSource> getDataSources() {
- return this.datasources;
- }
-
+
class CloseInterceptor implements InvocationHandler {
Connection conn;
@@ -144,8 +102,6 @@
void configure() throws QueryTestFailedException {
- datasources = new HashMap<String, DataSource>(3);
-
String ac = this.env.getProperty(CONNECTION_STRATEGY_PROPS.AUTOCOMMIT, "true");
this.autoCommit = Boolean.getBoolean(ac);
@@ -162,22 +118,15 @@
}
Admin admin = (Admin)c.getAdminAPI();
-
-// Properties p = new Properties();
-// if (this.env.getProperty(PROCESS_BATCH) != null) {
-// p.setProperty("metamatrix.buffer.processorBatchSize", this.env.getProperty(PROCESS_BATCH)); //$NON-NLS-1$
-// }
-//
-// if (this.env.getProperty(CONNECTOR_BATCH) != null) {
-// p.setProperty("metamatrix.buffer.connectorBatchSize", this.env.getProperty(CONNECTOR_BATCH)); //$NON-NLS-1$
-// }
setupVDBConnectorBindings(admin);
admin.restart();
+
+ int sleep = 5;
- System.out.println("Bouncing the system..(wait 15 seconds)"); //$NON-NLS-1$
- Thread.sleep(1000*15);
+ System.out.println("Bouncing the system..(wait " + sleep + " seconds)"); //$NON-NLS-1$
+ Thread.sleep(1000*sleep);
// Thread.sleep(1000*60);
System.out.println("done."); //$NON-NLS-1$
@@ -221,9 +170,8 @@
org.teiid.test.framework.datasource.DataSource ds = this.dsFactory.getDatasource(useName, m.getName());
if (ds != null) {
- datasources.put(m.getName(), ds);
- System.out.println("Set up Connector Binding (model:mapping:type): " + m.getName() + ":" + useName + ":" + ds.getConnectorType()); //$NON-NLS-1$
+ System.out.println("Set up Connector Binding (model:mapping:type): " + m.getName() + ":" + useName + ":" + ds.getConnectorType()); //$NON-NLS-1$
AdminOptions ao = new AdminOptions(AdminOptions.OnConflict.OVERWRITE);
ao.addOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR);
@@ -248,70 +196,64 @@
}
- public synchronized ConnectionStrategy createDriverStrategy(String identifier, Properties props) throws QueryTestFailedException {
- if (driversources == null) {
- driversources = new HashMap<String, ConnectionStrategy>();
- }
-
- if (identifier == null) {
- return new DriverConnection(props, dsFactory);
- }
-
- ConnectionStrategy strategy = null;
- if (driversources.containsKey(identifier)) {
- strategy = driversources.get(identifier);
- } else {
- strategy = new DriverConnection(props, dsFactory);
- driversources.put(identifier, strategy);
- }
-
- return strategy;
-
+ public synchronized Connection createDriverConnection(String identifier) throws QueryTestFailedException {
+
+ DataSource ds = null;
+ if (identifier != null) {
+ ds = DataSourceMgr.getInstance().getDataSource(identifier);
+ }
+ if (ds == null) {
+ throw new TransactionRuntimeException(
+ "Program Error: DataSource is not mapped to Identifier " + identifier);
+ }
+
+ Connection conn = ds.getConnection();
+
+ if (conn != null) return conn;
+
+ ConnectionStrategy cs = null;
+ if (identifier == null) {
+ cs = new DriverConnection(ds.getProperties(), this.dsFactory);
+
+ } else {
+ cs = new DriverConnection(ds.getProperties(), this.dsFactory);
+ }
+
+ ds.setConnection(cs);
+
+ return ds.getConnection();
+
+
}
+
- public synchronized ConnectionStrategy createDataSourceStrategy(String identifier, Properties props) throws QueryTestFailedException {
- if (datasourcesources == null) {
- datasourcesources = new HashMap<String, ConnectionStrategy>();
- }
-
- if (identifier == null) {
- return new DataSourceConnection(props, dsFactory);
- }
-
- ConnectionStrategy strategy = null;
- if (datasourcesources.containsKey(identifier)) {
- strategy = datasourcesources.get(identifier);
- } else {
- strategy = new DataSourceConnection(props, dsFactory);
- datasourcesources.put(identifier, strategy);
- }
-
- return strategy;
-
+ public synchronized XAConnection createDataSourceConnection(String identifier) throws QueryTestFailedException {
+
+ DataSource ds = null;
+ if (identifier != null) {
+ ds = DataSourceMgr.getInstance().getDataSource(identifier);
+ }
+ if (ds == null) {
+ throw new TransactionRuntimeException(
+ "Program Error: DataSource is not mapped to Identifier " + identifier);
+ }
+
+ XAConnection conn = ds.getXAConnection();
+
+ if (conn != null) return conn;
+
+ ConnectionStrategy cs = null;
+ if (identifier == null) {
+ cs = new DriverConnection(ds.getProperties(), this.dsFactory);
+ } else {
+ cs = new DriverConnection(ds.getProperties(), this.dsFactory);
+ }
+
+ ds.setXAConnection(cs);
+
+ return ds.getXAConnection();
+
+
}
- public synchronized ConnectionStrategy createJEEStrategy(String identifier, Properties props) throws QueryTestFailedException {
- if (jeesources == null) {
- jeesources = new HashMap<String, ConnectionStrategy>();
- }
-
- if (identifier == null) {
- return new JEEConnection(props, dsFactory);
- }
-
- ConnectionStrategy strategy = null;
- if (jeesources.containsKey(identifier)) {
- strategy = jeesources.get(identifier);
- } else {
- strategy = new JEEConnection(props, dsFactory);
- jeesources.put(identifier, strategy);
- }
-
- return strategy;
-
- }
-
-
-
-
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-11-16 20:56:58 UTC (rev 1552)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategyFactory.java 2009-11-16 20:57:15 UTC (rev 1553)
@@ -21,10 +21,11 @@
public class ConnectionStrategyFactory {
- public static ConnectionStrategy createConnectionStrategy(ConfigPropertyLoader configprops, DataSourceFactory dsFactory) throws QueryTestFailedException {
+ public static ConnectionStrategy createConnectionStrategy(ConfigPropertyLoader configprops) throws QueryTestFailedException {
ConnectionStrategy strategy = null;
Properties props = configprops.getProperties();
-
+ DataSourceFactory factory = new DataSourceFactory(configprops);
+
String type = props.getProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
if (type == null) {
throw new RuntimeException("Property " + ConfigPropertyNames.CONNECTION_TYPE + " was specified");
@@ -32,15 +33,15 @@
if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION)) {
// pass in null to create new strategy
- strategy = new DriverConnection(props, dsFactory);
+ strategy = new DriverConnection(props, factory);
System.out.println("Created Driver Strategy");
}
else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.DATASOURCE_CONNECTION)) {
- strategy = new DataSourceConnection(props, dsFactory);
+ strategy = new DataSourceConnection(props, factory);
System.out.println("Created DataSource Strategy");
}
else if (type.equalsIgnoreCase(ConfigPropertyNames.CONNECTION_TYPES.JNDI_CONNECTION)) {
- strategy = new JEEConnection(props, dsFactory);
+ strategy = new JEEConnection(props, factory);
System.out.println("Created JEE Strategy");
}
@@ -60,7 +61,7 @@
ConfigPropertyLoader config = ConfigPropertyLoader.createInstance();
- DataSourceFactory factory = new DataSourceFactory(config);
+ new DataSourceFactory(config);
}
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-11-16 20:56:58 UTC (rev 1552)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-11-16 20:57:15 UTC (rev 1553)
@@ -22,135 +22,136 @@
public class DataSourceConnection extends ConnectionStrategy {
- public static final String DS_USER = "user"; //$NON-NLS-1$
+ public static final String DS_USER = "user"; //$NON-NLS-1$
- // need both user variables because Teiid uses 'user' and connectors use
- // 'username'
- public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
- public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD; //$NON-NLS-1$
+ // need both user variables because Teiid uses 'user' and connectors use
+ // 'username'
+ public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
+ public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD; //$NON-NLS-1$
- // the driver is only used for making direct connections to the source, the
- // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE
- // driver class
- public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
+ // the driver is only used for making direct connections to the source, the
+ // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE
+ // driver class
+ public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
- public static final String DS_SERVERNAME = "ServerName"; //$NON-NLS-1$
- public static final String DS_SERVERPORT = "PortNumber"; //$NON-NLS-1$
- public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
- public static final String DS_DATABASENAME = "DatabaseName"; //$NON-NLS-1$
- public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
+ public static final String DS_SERVERNAME = "ServerName"; //$NON-NLS-1$
+ public static final String DS_SERVERPORT = "PortNumber"; //$NON-NLS-1$
+ public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
+ public static final String DS_DATABASENAME = "DatabaseName"; //$NON-NLS-1$
+ public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
- private String driver = null;
- private String username = null;
- private String pwd = null;
- private String applName = null;
- private String databaseName = null;
- private String serverName = null;
- private String portNumber = null;
+ private String driver = null;
+ private String username = null;
+ private String pwd = null;
+ private String applName = null;
+ private String databaseName = null;
+ private String serverName = null;
+ private String portNumber = null;
- private XAConnection xaConnection;
+ private XAConnection xaConnection;
- public DataSourceConnection(Properties props, DataSourceFactory dsFactory)
- throws QueryTestFailedException {
- super(props, dsFactory);
+ public DataSourceConnection(Properties props,
+ DataSourceFactory dsf) throws QueryTestFailedException {
+ super(props, dsf);
+ }
+
+ public void validate() {
+ databaseName = this.getEnvironment().getProperty(DS_DATABASENAME);
+ if (databaseName == null || databaseName.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_DATABASENAME
+ + " was not specified");
}
- public void validate() {
- databaseName = this.getEnvironment().getProperty(DS_DATABASENAME);
- if (databaseName == null || databaseName.length() == 0) {
- throw new TransactionRuntimeException("Property " + DS_DATABASENAME
- + " was not specified");
- }
+ serverName = this.getEnvironment().getProperty(DS_SERVERNAME);
+ if (serverName == null || serverName.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_SERVERNAME
+ + " was not specified");
+ }
- serverName = this.getEnvironment().getProperty(DS_SERVERNAME);
- if (serverName == null || serverName.length() == 0) {
- throw new TransactionRuntimeException("Property " + DS_SERVERNAME
- + " was not specified");
- }
+ this.portNumber = this.getEnvironment().getProperty(DS_SERVERPORT);
- this.portNumber = this.getEnvironment().getProperty(DS_SERVERPORT);
+ this.applName = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
- this.applName = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
+ this.driver = this.getEnvironment().getProperty(DS_DRIVER);
+ if (this.driver == null || this.driver.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_DRIVER
+ + " was not specified");
+ }
- this.driver = this.getEnvironment().getProperty(DS_DRIVER);
- if (this.driver == null || this.driver.length() == 0) {
- throw new TransactionRuntimeException("Property " + DS_DRIVER
- + " was not specified");
- }
+ this.username = this.getEnvironment().getProperty(DS_USER);
+ if (username == null) {
+ this.username = this.getEnvironment().getProperty(DS_USERNAME);
+ }
+ this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
- this.username = this.getEnvironment().getProperty(DS_USER);
- if (username == null) {
- this.username = this.getEnvironment().getProperty(DS_USERNAME);
- }
- this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
+ }
+ public Connection getConnection() throws QueryTestFailedException {
+ try {
+ return getXAConnection().getConnection();
+ } catch (QueryTestFailedException qtf) {
+ throw qtf;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new QueryTestFailedException(e);
}
+ }
- public Connection getConnection() throws QueryTestFailedException {
- try {
- return getXAConnection().getConnection();
- } catch (QueryTestFailedException qtf) {
- throw qtf;
- } catch (Exception e) {
- e.printStackTrace();
- throw new QueryTestFailedException(e);
- }
+ public synchronized XAConnection getXAConnection()
+ throws QueryTestFailedException {
+ if (xaConnection == null) {
+ validate();
+ try {
+ xaConnection = createConnection();
+ } catch (Exception e) {
+ throw new QueryTestFailedException(e);
+ }
}
+ return xaConnection;
+ }
- public synchronized XAConnection getXAConnection()
- throws QueryTestFailedException {
- if (xaConnection == null) {
- validate();
- try {
- xaConnection = createConnection();
- } catch (Exception e) {
- throw new QueryTestFailedException(e);
- }
- }
- return xaConnection;
- }
+ private XAConnection createConnection() throws SQLException,
+ InstantiationException, IllegalAccessException,
+ ClassNotFoundException {
+ System.out
+ .println("Creating Datasource Connection: \"" + this.serverName + " - " + this.databaseName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
- private XAConnection createConnection() throws SQLException,
- InstantiationException, IllegalAccessException,
- ClassNotFoundException {
- System.out
- .println("Creating Datasource Connection: \"" + this.serverName + " - " + this.databaseName + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ BaseDataSource dataSource = (BaseDataSource) Class.forName(this.driver)
+ .newInstance();
- BaseDataSource dataSource = (BaseDataSource) Class.forName(this.driver)
- .newInstance();
+ dataSource.setDatabaseName(this.databaseName);
+ if (this.applName != null) {
+ dataSource.setApplicationName(this.applName);
+ }
- dataSource.setDatabaseName(this.databaseName);
- if (this.applName != null) {
- dataSource.setApplicationName(this.applName);
- }
+ if (dataSource instanceof EmbeddedDataSource) {
+ ((EmbeddedDataSource) dataSource).setBootstrapFile(this.serverName);
+ } else {
+ ((TeiidDataSource) dataSource).setServerName(this.serverName);
+ ((TeiidDataSource) dataSource).setPortNumber(Integer
+ .parseInt(this.portNumber));
+ }
- if (dataSource instanceof EmbeddedDataSource) {
- ((EmbeddedDataSource) dataSource).setBootstrapFile(this.serverName);
- } else {
- ((TeiidDataSource) dataSource).setServerName(this.serverName);
- ((TeiidDataSource) dataSource).setPortNumber(Integer
- .parseInt(this.portNumber));
- }
-
- if (this.username != null) {
- dataSource.setUser(this.username);
- dataSource.setPassword(this.pwd);
- }
-
- return ((XADataSource) dataSource).getXAConnection();
+ if (this.username != null) {
+ dataSource.setUser(this.username);
+ dataSource.setPassword(this.pwd);
}
- public void shutdown() {
- super.shutdown();
- try {
+ return ((XADataSource) dataSource).getXAConnection(this.username,
+ this.pwd);
+ }
- if (this.xaConnection != null) {
- this.xaConnection.close();
- }
- } catch (SQLException e) {
- // ignore..
- }
+ public void shutdown() {
+ super.shutdown();
+ try {
- this.xaConnection = null;
+ if (this.xaConnection != null) {
+ this.xaConnection.close();
+ }
+ } catch (SQLException e) {
+ // ignore..
}
+
+ this.xaConnection = null;
+ }
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-11-16 20:56:58 UTC (rev 1552)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DriverConnection.java 2009-11-16 20:57:15 UTC (rev 1553)
@@ -14,131 +14,135 @@
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
+/**
+ * The DriverConnection strategy that can get connections in standalone mode or
+ * embedded mode.
+ */
+public class DriverConnection extends ConnectionStrategy {
+ public static final String DS_USER = "user"; //$NON-NLS-1$
-/**
- * The DriverConnection strategy that can get connections in standalone mode
- * or embedded mode.
- */
-public class DriverConnection extends ConnectionStrategy{
-
- public static final String DS_USER = "user"; //$NON-NLS-1$
-
- // need both user variables because Teiid uses 'user' and connectors use 'username'
- public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
- public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD; //$NON-NLS-1$
-
- // the driver is only used for making direct connections to the source, the
- // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE driver class
- public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
-
- public static final String DS_URL = JDBCPropertyNames.URL; //$NON-NLS-1$
- public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
-
-
+ // need both user variables because Teiid uses 'user' and connectors use
+ // 'username'
+ public static final String DS_USERNAME = JDBCPropertyNames.USERNAME; //$NON-NLS-1$
+ public static final String DS_PASSWORD = JDBCPropertyNames.PASSWORD; //$NON-NLS-1$
+
+ // the driver is only used for making direct connections to the source, the
+ // connector type will provide the JDBCPropertyNames.CONNECTION_SOURCE
+ // driver class
+ public static final String DS_DRIVER = "driver"; //$NON-NLS-1$
+
+ public static final String DS_URL = JDBCPropertyNames.URL; //$NON-NLS-1$
+ public static final String DS_APPLICATION_NAME = "application-name"; //$NON-NLS-1$
+
private String url = null;
private String driver = null;
private String username = null;
private String pwd = null;
-
+
private Connection connection;
-
- public DriverConnection(Properties props, DataSourceFactory dsFactory) throws QueryTestFailedException {
- super(props, dsFactory);
- validate();
+
+ public DriverConnection(Properties props,
+ DataSourceFactory dsf) throws QueryTestFailedException {
+ super(props, dsf);
+ validate();
}
-
- public void validate() {
- String urlProp = this.getEnvironment().getProperty(DS_URL);
- if (urlProp == null || urlProp.length() == 0) {
- throw new TransactionRuntimeException("Property " + DS_URL + " was not specified");
- }
- StringBuffer urlSB = new StringBuffer(urlProp);
-
- String appl = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
- if (appl != null) {
- urlSB.append(";");
- urlSB.append("ApplicationName").append("=").append(appl);
- }
-
- url = urlSB.toString();
-
- driver = this.getEnvironment().getProperty(DS_DRIVER);
- if (driver == null || driver.length() == 0) {
- throw new TransactionRuntimeException("Property " + DS_DRIVER + " was not specified");
- }
-
- // need both user variables because Teiid uses 'user' and connectors use 'username'
+ public void validate() {
- this.username = this.getEnvironment().getProperty(DS_USER);
- if (username == null) {
- this.username = this.getEnvironment().getProperty(DS_USERNAME);
- }
- this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
-
- try {
- // Load jdbc driver
- Class.forName(driver);
- } catch (ClassNotFoundException e) {
- throw new TransactionRuntimeException(e);
- }
-
+ String urlProp = this.getEnvironment().getProperty(DS_URL);
+ if (urlProp == null || urlProp.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_URL
+ + " was not specified");
}
+ StringBuffer urlSB = new StringBuffer(urlProp);
- public synchronized Connection getConnection() throws QueryTestFailedException {
- if (this.connection != null) {
- try {
- if (!this.connection.isClosed()) {
- return this.connection;
- }
- } catch (SQLException e) {
+ String appl = this.getEnvironment().getProperty(DS_APPLICATION_NAME);
+ if (appl != null) {
+ urlSB.append(";");
+ urlSB.append("ApplicationName").append("=").append(appl);
+ }
- }
-
- }
-
- this.connection = getJDBCConnection(this.driver, this.url, this.username, this.pwd);
- return this.connection;
- }
-
-
- private Connection getJDBCConnection(String driver, String url, String user, String passwd) throws QueryTestFailedException {
+ url = urlSB.toString();
- System.out.println("Creating Driver Connection: \"" + url + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+ driver = this.getEnvironment().getProperty(DS_DRIVER);
+ if (driver == null || driver.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_DRIVER
+ + " was not specified");
+ }
- Connection conn;
- try {
- // Create a connection
- if (user != null && user.length() > 0) {
- conn = DriverManager.getConnection(url, user, passwd);
- } else {
- conn = DriverManager.getConnection(url);
- }
-
-
- } catch (SQLException e) {
- throw new QueryTestFailedException(e);
- } catch (Throwable t) {
- t.printStackTrace();
- throw new QueryTestFailedException(t.getMessage());
- }
- return conn;
-
+ // need both user variables because Teiid uses 'user' and connectors use
+ // 'username'
+
+ this.username = this.getEnvironment().getProperty(DS_USER);
+ if (username == null) {
+ this.username = this.getEnvironment().getProperty(DS_USERNAME);
+ }
+ this.pwd = this.getEnvironment().getProperty(DS_PASSWORD);
+
+ try {
+ // Load jdbc driver
+ Class.forName(driver);
+ } catch (ClassNotFoundException e) {
+ throw new TransactionRuntimeException(e);
+ }
+
}
-
+
+ public synchronized Connection getConnection()
+ throws QueryTestFailedException {
+ if (this.connection != null) {
+ try {
+ if (!this.connection.isClosed()) {
+ return this.connection;
+ }
+ } catch (SQLException e) {
+
+ }
+
+ }
+
+ this.connection = getJDBCConnection(this.driver, this.url,
+ this.username, this.pwd);
+ return this.connection;
+ }
+
+ private Connection getJDBCConnection(String driver, String url,
+ String user, String passwd) throws QueryTestFailedException {
+
+ System.out.println("Creating Driver Connection: \"" + url + "\""); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Connection conn;
+ try {
+ // Create a connection
+ if (user != null && user.length() > 0) {
+ conn = DriverManager.getConnection(url, user, passwd);
+ } else {
+ conn = DriverManager.getConnection(url);
+ }
+
+ } catch (SQLException e) {
+ throw new QueryTestFailedException(e);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ throw new QueryTestFailedException(t.getMessage());
+ }
+ return conn;
+
+ }
+
public void shutdown() {
- super.shutdown();
- if (this.connection != null) {
- try {
- this.connection.close();
- } catch (Exception e) {
- //ignore
- }
- }
-
- this.connection = null;
-
+ super.shutdown();
+ if (this.connection != null) {
+ try {
+ this.connection.close();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ this.connection = null;
+
}
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java 2009-11-16 20:56:58 UTC (rev 1552)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/JEEConnection.java 2009-11-16 20:57:15 UTC (rev 1553)
@@ -14,56 +14,56 @@
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
+/**
+ * JEE (JNDI) Connection Strategy, when the test is run inside an application
+ * server. Make sure all the jndi names are set correctly in the properties
+ * file.
+ */
+public class JEEConnection extends ConnectionStrategy {
+ public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
-/**
- * JEE (JNDI) Connection Strategy, when the test is run inside an application server. Make
- * sure all the jndi names are set correctly in the properties file.
- */
-public class JEEConnection extends ConnectionStrategy{
-
- public static final String DS_JNDINAME = "ds-jndiname"; //$NON-NLS-1$
-
- private String jndi_name = null;
-
-
- public JEEConnection(Properties props, DataSourceFactory dsFactory) throws QueryTestFailedException {
- super(props, dsFactory);
+ private String jndi_name = null;
+
+
+ public JEEConnection(Properties props,
+ DataSourceFactory dsf) throws QueryTestFailedException {
+ super(props, dsf);
}
public Connection getConnection() throws QueryTestFailedException {
- validate();
- try {
- InitialContext ctx = new InitialContext();
- DataSource source = (DataSource)ctx.lookup(jndi_name);
-
+ validate();
+ try {
+ InitialContext ctx = new InitialContext();
+ DataSource source = (DataSource) ctx.lookup(jndi_name);
- if (source == null) {
- String msg = "Unable to find jndi source " + jndi_name;//$NON-NLS-1$
+ if (source == null) {
+ String msg = "Unable to find jndi source " + jndi_name;//$NON-NLS-1$
- QueryTestFailedException mme = new QueryTestFailedException(msg);//$NON-NLS-1$
- throw mme;
- }
- Connection conn = source.getConnection();
- return conn;
- } catch (QueryTestFailedException qtfe) {
- throw qtfe;
- } catch (Exception e) {
- throw new QueryTestFailedException(e);
- }
- }
-
+ QueryTestFailedException mme = new QueryTestFailedException(msg);//$NON-NLS-1$
+ throw mme;
+ }
+ Connection conn = source.getConnection();
+ return conn;
+ } catch (QueryTestFailedException qtfe) {
+ throw qtfe;
+ } catch (Exception e) {
+ throw new QueryTestFailedException(e);
+ }
+ }
+
public void shutdown() {
- super.shutdown();
- // no connection management here; app server takes care of these..
+ super.shutdown();
+ // no connection management here; app server takes care of these..
}
- public void validate() {
- // TODO Auto-generated method stub
-
- jndi_name = getEnvironment().getProperty(DS_JNDINAME);
- if (jndi_name == null || jndi_name.length() == 0) {
- throw new TransactionRuntimeException("Property " + DS_JNDINAME + " was not specified");
- }
- }
+ public void validate() {
+ // TODO Auto-generated method stub
+
+ jndi_name = getEnvironment().getProperty(DS_JNDINAME);
+ if (jndi_name == null || jndi_name.length() == 0) {
+ throw new TransactionRuntimeException("Property " + DS_JNDINAME
+ + " was not specified");
+ }
+ }
}
15 years, 1 month
teiid SVN: r1552 - trunk/test-integration/db/src/main/java/org/teiid/test/framework.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 15:56:58 -0500 (Mon, 16 Nov 2009)
New Revision: 1552
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
Log:
Teiid 773 - cleanup and refactoring so that the assumption is there will be 2 datasources required in order to run the test.
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-11-16 15:33:42 UTC (rev 1551)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-11-16 20:56:58 UTC (rev 1552)
@@ -71,7 +71,7 @@
return props;
}
- public Map getModelAssignedDatabaseTypes() {
+ public Map<String, String> getModelAssignedDatabaseTypes() {
return this.modelAssignedDatabaseType;
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-11-16 15:33:42 UTC (rev 1551)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-11-16 20:56:58 UTC (rev 1552)
@@ -1,5 +1,7 @@
package org.teiid.test.framework;
+import org.teiid.test.framework.datasource.DataSource;
+
import com.metamatrix.jdbc.api.ExecutionProperties;
/**
@@ -22,40 +24,36 @@
/**
* For Driver/Datasource connection related properties, {@link ConnectionStrategy}.
*/
-
- /**
- * Transaction Type indicates the type of transaction container to use
- * @see TransactionFactory
- */
- public static final String TRANSACTION_TYPE = "transaction-type"; //$NON-NLS-1$
-
- public interface TRANSACTION_TYPES {
- public static final String LOCAL_TRANSACTION = "local"; //$NON-NLS-1$
- public static final String XATRANSACTION = "xa"; //$NON-NLS-1$
- public static final String JNDI_TRANSACTION = "jndi"; //$NON-NLS-1$
- }
-
/**
- * The USE_DATASOURCES_PROP is a comma delimited system property that can be used to limit the
+ * The USE_DATASOURCES_PROP is a comma delimited property that can be used to limit the
* datasources that are in use for the tests. Use the directory name defined in the ddl directory.
* This enables a developers to test a certain datasource without having to remove
* connection.properties files.
*/
public static final String USE_DATASOURCES_PROP = "usedatasources";
+
+
+ /**
+ * The USE_DATASOURCE_TYPES_PROP is a comma delimited property that can be used to limit the
+ * types of datasources to be used for the tests. The database type {@link DataSource#DB_TYPE} corresponds to the
+ * defined types in the resources/ddl directory. By specifying this property, the test will use on data sources
+ * of the specified types..
+ */
+ public static final String USE_DATASOURCE_TYPES_PROP = "usedatasourcetypes";
+
/**
- * The EXCLUDE_DATASOURCES_PROP is a comma delimited system property that can be used to exclude
+ * The EXCLUDE_DATASOURCES_PROP is a comma delimited property that can be used to exclude
* certain database types.
* This is done so that whole sets of tests can be excluded when a datasource has been defined
* for a specific database type.
- * Example of this is the XATransactions currently doesn't support using sqlserver (@see TEIID-559)
*/
- public static final String EXCLUDE_DATASBASE_TYPES_PROP = "excludedatasources";
+ public static final String EXCLUDE_DATASBASE_TYPES_PROP = "excludedatasourcetypes";
@@ -99,5 +97,13 @@
public static final String JNDINAME_USERTXN = "usertxn-jndiname"; //$NON-NLS-1$
}
+
+ public interface TXN_AUTO_WRAP_OPTIONS {
+ public static final String AUTO_WRAP_OFF = "OFF"; //$NON-NLS-1$
+ public static final String AUTO_WRAP_ON = "ON"; //$NON-NLS-1$
+ public static final String AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC"; //$NON-NLS-1$
+ public static final String AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC"; //$NON-NLS-1$
+ }
+
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-11-16 15:33:42 UTC (rev 1551)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-11-16 20:56:58 UTC (rev 1552)
@@ -8,159 +8,150 @@
import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.connection.ConnectionStrategyFactory;
-import org.teiid.test.framework.datasource.DataSourceFactory;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
import com.metamatrix.core.util.StringUtil;
-
public abstract class TransactionContainer {
+
+ private boolean debug = false;
+
+
+ private String testClassName = null;
+
+ protected ConnectionStrategy connStrategy;
+ protected Properties props;
+
+ protected TransactionContainer() {
+ ConfigPropertyLoader config = ConfigPropertyLoader.createInstance();
- private boolean debug = false;
-
- protected ConfigPropertyLoader config = null;
- protected Properties props;
- protected ConnectionStrategy connStrategy;
- protected DataSourceFactory dsfactory;
-
- protected String testClassName = null;
-
- protected TransactionContainer(ConfigPropertyLoader propertyconfig){
- this.config = propertyconfig;
+ try {
+ this.connStrategy = ConnectionStrategyFactory
+ .createConnectionStrategy(config);
+ } catch (QueryTestFailedException e) {
+ // TODO Auto-generated catch block
+ throw new TransactionRuntimeException(e);
+ }
+ this.props = new Properties();
+ this.props.putAll(this.connStrategy.getEnvironment());
+
+ }
+
+
+ public ConnectionStrategy getConnectionStrategy() {
+ return this.connStrategy;
+ }
+
+
+ public void setEnvironmentProperty(String key, String value) {
+ this.getConnectionStrategy().getEnvironment().setProperty(key, value);
+ }
+
+ protected void before(TransactionQueryTest test) {
+ }
+
+ protected void after(TransactionQueryTest test) {
+ }
+
+ public void runTransaction(TransactionQueryTest test) {
+
+ this.testClassName = StringUtil.getLastToken(test.getClass().getName(),
+ ".");
+
+ try {
+ detail("Start transaction test: " + test.getTestName());
+
+ try {
+ test.setConnectionStrategy(connStrategy);
+
+ test.setup();
+
+ } catch (Throwable e) {
+ if (!test.exceptionExpected()) {
+ e.printStackTrace();
+ }
+ throw new TransactionRuntimeException(e.getMessage());
}
-
- protected void setUp(TransactionQueryTest test) throws QueryTestFailedException {
- this.dsfactory = new DataSourceFactory(config);
-
- this.connStrategy = ConnectionStrategyFactory.createConnectionStrategy(config, dsfactory);
- this.props = new Properties();
- this.props.putAll(this.connStrategy.getEnvironment());
-
-
- }
-
- protected void before(TransactionQueryTest test){}
-
- protected void after(TransactionQueryTest test) {}
-
- public void runTransaction(TransactionQueryTest test) {
-
- this.testClassName =StringUtil.getLastToken(test.getClass().getName(), ".");
-
- try {
-
- runIt(test);
-
- } finally {
- debug(" test.cleanup");
-
- try {
- test.cleanup();
- } finally {
-
- // cleanup all defined datasources for the last test and
- // any overrides regarding inclusions and exclusions.
- if (dsfactory != null) {
- this.dsfactory.cleanup();
- }
-
- // cleanup all connections created for this test.
- if (connStrategy != null) {
- connStrategy.shutdown();
- }
- }
- }
+ runTest(test);
+
+ detail("Completed transaction test: " + test.getTestName());
+
+ } finally {
+ debug(" test.cleanup");
+
+ try {
+ test.cleanup();
+ } finally {
+
+ // cleanup all connections created for this test.
+ if (connStrategy != null) {
+ connStrategy.shutdown();
+ }
}
-
- private void runIt(TransactionQueryTest test) {
-
- detail("Start transaction test: " + test.getTestName());
+ }
- try {
-
- setUp(test);
- test.setConnectionStrategy(connStrategy);
+ }
-
- if (!test.hasRequiredDataSources()) {
- return;
- }
-
-
-
- test.setupDataSource();
+ protected void runTest(TransactionQueryTest test) {
+ debug("Start runTest: " + test.getTestName());
-
- debug(" setConnection");
- test.setConnection(this.connStrategy.getConnection());
- test.setExecutionProperties(this.props);
- debug(" before(test)");
-
- before(test);
- debug(" test.before");
+ try {
- test.before();
-
- debug(" test.testcase");
+ debug(" before(test)");
- // run the test
- test.testCase();
-
- debug(" test.after");
+ before(test);
+ debug(" test.before");
- test.after();
- debug(" after(test)");
+ test.before();
- after(test);
-
- detail("End transaction test: " + test.getTestName());
+ debug(" test.testcase");
-
- }catch(Throwable e) {
- if (!test.exceptionExpected()) {
- e.printStackTrace();
- }
- throw new TransactionRuntimeException(e.getMessage());
- }
-
- if (test.exceptionExpected() && !test.exceptionOccurred()) {
- throw new TransactionRuntimeException("Expected exception, but one did not occur for test: " + this.getClass().getName() + "." + test.getTestName());
- }
-
- try {
- detail("Start validation: " + test.getTestName());
+ // run the test
+ test.testCase();
- test.validateTestCase();
-
- detail("End validation: " + test.getTestName());
+ debug(" test.after");
- }catch(Exception e) {
- throw new TransactionRuntimeException(e);
- }
-
- detail("Completed transaction test: " + test.getTestName());
+ test.after();
+ debug(" after(test)");
+ after(test);
- }
-
- public Properties getEnvironmentProperties() {
- return props;
+ debug("End runTest: " + test.getTestName());
+
+ } catch (Throwable e) {
+
+ if (!test.exceptionExpected()) {
+ e.printStackTrace();
}
-
- protected void debug(String message) {
- if (debug) {
- System.out.println("[" + this.testClassName + "] " + message);
- }
-
- }
-
- protected void detail(String message) {
- System.out.println("[" + this.testClassName + "] " + message);
- }
-
+ debug("Error: " + e.getMessage());
+ throw new TransactionRuntimeException(e.getMessage());
+ }
-
+ if (test.exceptionExpected() && !test.exceptionOccurred()) {
+ throw new TransactionRuntimeException(
+ "Expected exception, but one did not occur for test: "
+ + this.getClass().getName() + "."
+ + test.getTestName());
+ }
+ }
+
+
+ protected void debug(String message) {
+ if (debug) {
+ System.out.println("[" + this.testClassName + "] " + message);
+ }
+
+ }
+
+ protected void detail(String message) {
+ System.out.println("[" + this.testClassName + "] " + message);
+ }
+
+ protected boolean done() {
+ return true;
+ }
+
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java 2009-11-16 15:33:42 UTC (rev 1551)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTest.java 2009-11-16 20:56:58 UTC (rev 1552)
@@ -8,137 +8,200 @@
import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.exception.QueryTestFailedException;
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
/**
- * The TransactionQueryTest interface represents the transaction test framework from which
- * the @link TransactionContainer operates.
+ * The TransactionQueryTest interface represents the transaction test lifecycle of execution
+ * from which the @link TransactionContainer operates.
+ * <br><br>
+ * QueryTest lifecycle:</br>
+ *
+ * <br>
+ * There are 4 phases or groupings of methods:
+ * <li>Setup </li>
+ * <li>Test </li>
+ * <li>Validation</li>
+ * <li>Cleanup</li>
+ *
+ * <br>
+ * <p>
+ * <b>1. Setup phase is about setting the global environment for the testing</b>
+ * <br>
+ *
+ * <li>{@link #setConnectionStrategy(ConnectionStrategy)} - called first to provide
+ * the environment (i.e, type of connection, parameters, etc) that the test will
+ * be run under.
+ * <li>{@link #hasRequiredDataSources()} - called after the connection
+ * strategy is set so the determination can be made if this test has the
+ * required datasources defined and available in order to run the test. If not,
+ * then the test is bypassed.
+ * <li>{@link #setup()} - called to enable the test to
+ * perform any pretest (i.e., global) setup. Example would be data source setup.
+ * <li>{@link #setConnection(Connection)} - called to set the client driver (i.e.,
+ * Teiid) connection that will be used to execute queries against
+ * <li>{@link #setExecutionProperties(Properties)} - called at this time so that the
+ * overriding class can obtain / initialize settings that will be assigned when
+ * <li>{@link AbstractQueryTest#assignExecutionProperties(Statement)} is called
+ * prior to sql execution. (Example: set fetch size, batch time, or timeout)
+ * </li>
+ * <br>
+ * <p>
+ * <b>2. Test phase are the methods for executing a test, including any
+ * before/after test logic to support the test</b>
+ * <br><br>
+ *
+ * <li>{@link #before()} called before the execution of the test so that the
+ * transaction boundary can be set and any other pretest conditions
+ * <li>{@link #testCase()} called to execute the specific test
+ * <li>{@link #after()} called after the test is executed, which will commit/rollback the transaction
+ * and perform any other post conditions
+ * </li>
+ * <br>
+ * <p>
+ * <b>3. Validation phase is meant to enable data validation post transaction
+ * completion. This is especially helpful when performing XA transactions
+ * because the results are not completed and available until after the {@link #after()} step
+ * is performed.</b>
+ * <br><br>
+ *
+ * {@link #validateTestCase()}
+ *
+ * <p>
+ * <b>4. Cleanup</b>
+ * <br><br>
+ *
+ * {@link #cleanup()} Called to allow the testcase to perform any cleanup after execution.
+ *
+ * <br>
+ * ================
+ * <p>
+ * <b>Other Notes:</b>
+ * <br><br>
+ *
+ * The following methods were exposed from {@link AbstractQueryTest}:
+ *
+ * <li>{@link #exceptionExpected()} - when an exception is expected to occur, the
+ * underlying logic will treat the execution as if it succeeded. </li>
+ * <li>{@link #exceptionOccurred()} - this method indicates when an exception
+ * actually occurred outside of the normal expected results. </li>
+ * <li>{@link #getConnection()} and {@link #getXAConnection()} - these connection
+ * methods are exposed for {@link #before()} and {@link #after()} methods</li>
+ * <li>{@link #rollbackAllways()} - this is exposed for the {@link #after()} method
+ * as to what behavior is expected after the execution of the test</li>
+ *
+ *
+ * <br>
* @author vanhalbert
- *
+ *
*/
public interface TransactionQueryTest {
-
- /**
- * Returns the name of the test so that better tracing of what tests are running/completing.
- * @return String is test name
- */
- String getTestName();
-
- /**
- * Called by the @link TransactionContainer to set the Teiid connection to be used in the test.
- * @param conn
- *
- * @since
- */
- void setConnection(Connection conn);
-
-
- /**
- * Returns the connection being used in the test.
- * @return
- *
- * @since
- */
- Connection getConnection();
-
- XAConnection getXAConnection();
-
-
- /**
- * Called to set the properties used to initialize prior
- * to execution.
- * @param props
- *
- * @since
- */
- void setExecutionProperties(Properties props) ;
-
-
- /**
- * Called to set the current connection strategy being used.
- * @param connStrategy
- *
- * @since
- */
- void setConnectionStrategy(ConnectionStrategy connStrategy);
-
- /**
- * Indicates if the test has the required datasources in order to execute.
- * If it doesn't have the required datasources, it will be bypassed for execution.
- * @return true if the test has the required sources to execute
- *
- * @since
- */
-
- boolean hasRequiredDataSources();
-
-
- /**
- * Called by the {@link TransactionContainer} prior to testcase processing so that
- * the responsibility for performing datasource setup can be done
- *
- *
- * @since
- */
- void setupDataSource() throws QueryTestFailedException;
-
-
+
/**
- * Override <code>before</code> if there is behavior that needs to be performed
- * prior to {@link #testCase()} being called.
+ * Returns the name of the test so that better tracing of what tests are
+ * running/completing.
*
- *
+ * @return String is test name
+ */
+ String getTestName();
+
+ /**
+ * Called to set the current connection strategy being used.
+ *
+ * @param connStrategy
+ *
* @since
*/
+ void setConnectionStrategy(ConnectionStrategy connStrategy) throws QueryTestFailedException;
+
+ /**
+ * Called by the {@link TransactionContainer} prior to testcase processing
+ * so that the responsibility for performing an setup duties (ie..,
+ * datasource setup) can be done
+ *
+ *
+ * @since
+ */
+ void setup() throws QueryTestFailedException;
+
+ /**
+ * Called by the @link TransactionContainer to set the Teiid connection to
+ * be used in the test.
+ *
+ * @param conn
+ *
+ * @since
+ */
+ void setConnection(Connection conn);
+
+ /**
+ * Called to set the properties used to initialize prior to execution.
+ *
+ * @param props
+ *
+ * @since
+ */
+// void setExecutionProperties(Properties props);
+
+ /**
+ * Override <code>before</code> if there is behavior that needs to be
+ * performed prior to {@link #testCase()} being called.
+ *
+ *
+ * @since
+ */
void before();
-
- /**
- * Implement testCase(), it is the entry point to the execution of the test.
- * @throws Exception
- *
- * @since
- */
+
+ /**
+ * Implement testCase(), it is the entry point to the execution of the test.
+ *
+ * @throws Exception
+ *
+ * @since
+ */
void testCase() throws Exception;
-
-
+
/**
- * Override <code>after</code> if there is behavior that needs to be performed
- * after {@link #testCase()} being called.
+ * Override <code>after</code> if there is behavior that needs to be
+ * performed after {@link #testCase()} being called.
*
- *
+ *
* @since
*/
- void after() ;
-
+ void after();
+
/**
- * Indicates what should be done when a failure occurs in {@link #testCase()}
+ * Indicates what should be done when a failure occurs in
+ * {@link #testCase()}
+ *
* @return
- *
+ *
* @since
*/
- boolean rollbackAllways() ;
-
- boolean exceptionExpected();
-
- boolean exceptionOccurred();
+ boolean rollbackAllways();
-
/**
* Called at the end of the test so that the testcase can clean itself up by
* releasing any resources, closing any open connections, etc.
*
- *
+ *
* @since
*/
void cleanup();
-
+
/**
- * validateTestCase is called after the testcase has been completed. This enables
- * the validation to be performed as part of the overall testcase.
- * @throws Exception
- *
+ * Returns the connection being used in the test.
+ *
+ * @return
+ *
* @since
*/
- void validateTestCase() throws Exception;
+ Connection getConnection();
+ XAConnection getXAConnection();
+ boolean exceptionExpected();
+
+ boolean exceptionOccurred();
+
}
15 years, 1 month
teiid SVN: r1551 - in trunk: metadata/src/main/java/org/teiid/metadata/index and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-11-16 10:33:42 -0500 (Mon, 16 Nov 2009)
New Revision: 1551
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
Log:
TEIID-145 TEIID-869 defaulting to allowing double quoted identifiers (ansi standard). and further cleaning up metadata
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java 2009-11-16 02:17:12 UTC (rev 1550)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java 2009-11-16 15:33:42 UTC (rev 1551)
@@ -78,6 +78,7 @@
private void setValuesUsingParent(String name,
AbstractMetadataRecord parent, AbstractMetadataRecord child, String recordType) throws ConnectorException {
child.setFullName(parent.getFullName() + AbstractMetadataRecord.NAME_DELIM_CHAR + name);
+ child.setName(name);
if (!uniqueNames.add(recordType + "/" + child.getFullName())) { //$NON-NLS-1$
throw new ConnectorException(DataPlugin.Util.getString("MetadataFactory.duplicate_name", child)); //$NON-NLS-1$
}
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2009-11-16 02:17:12 UTC (rev 1550)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2009-11-16 15:33:42 UTC (rev 1551)
@@ -1011,6 +1011,20 @@
final String parentObjectID) {
record.setUUID(getObjectValue(objectID));
+ if (fullName != null) {
+ int index = fullName.indexOf(IndexConstants.NAME_DELIM_CHAR);
+ String name = fullName;
+ if (index > 0) {
+ name = fullName.substring(index + 1);
+ }
+ if (record instanceof ColumnRecordImpl) {
+ index = fullName.indexOf(IndexConstants.NAME_DELIM_CHAR);
+ if (index > 0) {
+ name = fullName.substring(index + 1);
+ }
+ }
+ record.setName(name);
+ }
record.setFullName(fullName);
record.setNameInSource(getObjectValue(nameInSource));
}
15 years, 1 month
teiid SVN: r1550 - in trunk: common-internal/src/main/java/com/metamatrix/common/vdb/api and 19 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-11-15 21:17:12 -0500 (Sun, 15 Nov 2009)
New Revision: 1550
Removed:
trunk/metadata/src/test/java/com/metamatrix/connector/metadata/
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/QueryMetadataCache.java
Modified:
trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/VDBArchive.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java
trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferConfig.java
trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java
trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java
trunk/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java
trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/proc/TestProcedurePlanner.java
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java
trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBaseDQPService.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java
Log:
TEIID-145 TEIID-869 defaulting to allowing double quoted identifiers (ansi standard). and further cleaning up metadata
Modified: trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java
===================================================================
--- trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/client-jdbc/src/main/java/com/metamatrix/jdbc/MMDatabaseMetaData.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -280,7 +280,7 @@
.append(".ProcedureParams as p CROSS JOIN ") //$NON-NLS-1$
.append(RUNTIME_MODEL.VIRTUAL_MODEL_NAME)
.append(".VirtualDatabases v WHERE UCASE(v.Name)").append(LIKE_ESCAPE).append("AND UCASE(p.ProcedureName)").append(LIKE_ESCAPE).append("AND UCASE(p.Name) LIKE ?") //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- .append(" ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME, COLUMN_TYPE, POSITION OPTION MAKEDEP SystemPhysical.COLUMNS").toString(); //$NON-NLS-1$
+ .append(" ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME, COLUMN_TYPE, POSITION").toString(); //$NON-NLS-1$
private static final String QUERY_SCHEMAS =
new StringBuffer("SELECT Name AS TABLE_SCHEM, NULL AS TABLE_CATALOG") //$NON-NLS-1$
Modified: trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/VDBArchive.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/VDBArchive.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/common-internal/src/main/java/com/metamatrix/common/vdb/api/VDBArchive.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -56,6 +56,7 @@
import com.metamatrix.vdb.materialization.ScriptType;
import com.metamatrix.vdb.runtime.BasicModelInfo;
import com.metamatrix.vdb.runtime.BasicVDBDefn;
+import com.metamatrix.vdb.runtime.VDBKey;
/**
* Latest incarnation of the VDBContext, specifically for weeding out
@@ -87,6 +88,8 @@
private Set<String> pathsInArchive = new HashSet<String>();
private boolean open;
+
+ private VDBKey key;
public static VDBArchive loadVDB(URL vdbURL, File deployDirectory) throws IOException {
boolean loadedFromDef = false;
@@ -365,7 +368,7 @@
* @param vdbDef
* @throws IOException
*/
- public void updateConfigurationDef(BasicVDBDefn vdbDef) throws IOException {
+ public synchronized void updateConfigurationDef(BasicVDBDefn vdbDef) throws IOException {
if (vdbDef == null) {
return;
}
@@ -383,6 +386,7 @@
// update the local copies.
this.def = vdbDef;
appendManifest(this.def);
+ this.key = null;
}
/**
@@ -467,13 +471,6 @@
return this.def.getName();
}
- public void setName(String name) {
- checkOpen();
- if (this.def != null) {
- this.def.setName(name);
- }
- }
-
public String getVersion() {
checkOpen();
return this.def.getVersion();
@@ -564,5 +561,29 @@
}
return this.def.getModel(name);
}
+
+ /**
+ * checks the validity of the VDB
+ * @return true if valid; false otherwise.
+ */
+ public boolean isValid() {
+ if (getVDBValidityErrors() != null) {
+ return false;
+ }
+
+ Collection models = getConfigurationDef().getModels();
+ if (models != null && models.isEmpty()) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public synchronized VDBKey getVDBKey() {
+ if (key == null) {
+ key = new VDBKey(getName(), getVersion());
+ }
+ return key;
+ }
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -70,14 +70,6 @@
}
public String getName() {
- if(this.name == null || this.name.trim().length() == 0) {
- int nmIdx = this.fullName != null ? this.fullName.lastIndexOf(NAME_DELIM_CHAR) : -1;
- if (nmIdx == -1) {
- this.name = this.fullName;
- } else {
- this.name = this.fullName != null ? this.fullName.substring(nmIdx+1) : null;
- }
- }
return name;
}
@@ -89,23 +81,20 @@
int prntIdx = fullName.indexOf(NAME_DELIM_CHAR);
return fullName.substring(0, prntIdx);
}
-
+
public String toString() {
- return uuid + ": " + name; //$NON-NLS-1$
+ StringBuffer sb = new StringBuffer(100);
+ sb.append(getClass().getSimpleName());
+ sb.append(" name="); //$NON-NLS-1$
+ sb.append(getName());
+ sb.append(", nameInSource="); //$NON-NLS-1$
+ sb.append(getNameInSource());
+ sb.append(", uuid="); //$NON-NLS-1$
+ sb.append(getUUID());
+ return sb.toString();
}
/**
- * @deprecated the returned value may be incorrect in the case of an XML element (see defects #11326 and #11362)
- */
- public String getParentFullName() {
- int prntIdx = getFullName() != null ? getFullName().lastIndexOf(NAME_DELIM_CHAR+getName()) : -1;
- if (prntIdx <= 0) {
- return ""; //$NON-NLS-1$
- }
- return getFullName().substring(0, prntIdx);
- }
-
- /**
* Return the extension properties for this record - may be null
* if {@link #setProperties(LinkedHashMap)} or {@link #setProperty(String, String)}
* has not been called
@@ -141,7 +130,6 @@
* Compare two records for equality.
*/
public boolean equals(Object obj) {
-
if(obj == this) {
return true;
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -237,16 +237,4 @@
this.nativeType = nativeType;
}
- public String toString() {
- StringBuffer sb = new StringBuffer(100);
- sb.append(getClass().getSimpleName());
- sb.append(" name="); //$NON-NLS-1$
- sb.append(getName());
- sb.append(", nameInSource="); //$NON-NLS-1$
- sb.append(getNameInSource());
- sb.append(", uuid="); //$NON-NLS-1$
- sb.append(getUUID());
- return sb.toString();
- }
-
}
\ No newline at end of file
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -67,19 +67,6 @@
private String primitiveTypeID;
private Variety varietyType;
- public String getName() {
- final String fullName = super.getName();
- int indx = fullName.lastIndexOf(URI_REFERENCE_DELIMITER);
- if (indx > -1) {
- return fullName.substring(indx+1);
- }
- indx = fullName.lastIndexOf(AbstractMetadataRecord.NAME_DELIM_CHAR);
- if (indx > -1) {
- return fullName.substring(indx+1);
- }
- return fullName;
- }
-
public int getLength() {
return this.length;
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -88,16 +88,4 @@
modelType = i;
}
- public String toString() {
- StringBuffer sb = new StringBuffer(100);
- sb.append(getClass().getSimpleName());
- sb.append(" name="); //$NON-NLS-1$
- sb.append(getName());
- sb.append(", nameInSource="); //$NON-NLS-1$
- sb.append(getNameInSource());
- sb.append(", uuid="); //$NON-NLS-1$
- sb.append(getUUID());
- return sb.toString();
- }
-
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -42,8 +42,6 @@
private int cardinality;
private Type tableType;
- private String materializedTableID;
- private String materializedStageTableID;
private boolean isVirtual;
private boolean isSystem;
private boolean isMaterialized;
@@ -59,8 +57,8 @@
private String insertPlan;
private String updatePlan;
private String deletePlan;
- private String materializedStageTableName;
- private String materializedTableName;
+ private TableRecordImpl materializedStageTable;
+ private TableRecordImpl materializedTable;
//XML specific
private List<String> bindings;
@@ -110,14 +108,6 @@
return tableType;
}
- public String getMaterializedStageTableID() {
- return this.materializedStageTableID;
- }
-
- public String getMaterializedTableID() {
- return this.materializedTableID;
- }
-
public boolean supportsUpdate() {
return supportsUpdate;
}
@@ -165,22 +155,6 @@
isSystem = b;
}
- /**
- * @param materializedStageTableID The materializedStageTableID to set.
- * @since 4.2
- */
- public void setMaterializedStageTableID(String materializedStageTableID) {
- this.materializedStageTableID = materializedStageTableID;
- }
-
- /**
- * @param materializedTableID The materializedTableID to set.
- * @since 4.2
- */
- public void setMaterializedTableID(String materializedTableID) {
- this.materializedTableID = materializedTableID;
- }
-
public String getInsertPlan() {
return insertPlan;
}
@@ -253,20 +227,20 @@
this.selectTransformation = selectTransformation;
}
- public String getMaterializedStageTableName() {
- return this.materializedStageTableName;
- }
+ public TableRecordImpl getMaterializedStageTable() {
+ return materializedStageTable;
+ }
- public String getMaterializedTableName() {
- return this.materializedTableName;
- }
+ public TableRecordImpl getMaterializedTable() {
+ return materializedTable;
+ }
- public void setMaterializedStageTableName(String materializedStageTableName) {
- this.materializedStageTableName = materializedStageTableName;
+ public void setMaterializedStageTable(TableRecordImpl materializedStageTable) {
+ this.materializedStageTable = materializedStageTable;
}
- public void setMaterializedTableName(String materializedTableName) {
- this.materializedTableName = materializedTableName;
+ public void setMaterializedTable(TableRecordImpl materializedTable) {
+ this.materializedTable = materializedTable;
}
public void setResourcePath(String resourcePath) {
@@ -289,16 +263,4 @@
return keys;
}
- public String toString() {
- StringBuffer sb = new StringBuffer(100);
- sb.append(getClass().getSimpleName());
- sb.append(" name="); //$NON-NLS-1$
- sb.append(getName());
- sb.append(", nameInSource="); //$NON-NLS-1$
- sb.append(getNameInSource());
- sb.append(", uuid="); //$NON-NLS-1$
- sb.append(getUUID());
- return sb.toString();
- }
-
}
\ No newline at end of file
Modified: trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferConfig.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferConfig.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferConfig.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -32,7 +32,8 @@
*/
public class BufferConfig {
- public static int DEFAULT_CONNECTOR_BATCH_SIZE = 1000;
+ public static int DEFAULT_CONNECTOR_BATCH_SIZE = 2000;
+ public static int DEFAULT_PROCESSOR_BATCH_SIZE = 2000;
// Configuration
private long totalAvailableMemory = 100000000;
@@ -40,8 +41,7 @@
private int activeMemoryThreshold = 75;
private int managementInterval = 500;
private int connectorBatchSize = DEFAULT_CONNECTOR_BATCH_SIZE;
- //private int processorBatchSize = 500;
- private int processorBatchSize = 100;
+ private int processorBatchSize = DEFAULT_PROCESSOR_BATCH_SIZE;
private String bufferStorageDirectory = "../buffer"; //$NON-NLS-1$
private int logStatInterval = 0;
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/ConfigurationService.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -54,6 +54,8 @@
*/
public URL getSystemVdb();
+ public File getWorkDir();
+
/**
* Get DQP properties
* @return Properties - properties
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -40,6 +40,7 @@
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
import com.metamatrix.query.optimizer.relational.RelationalPlanner;
+import com.metamatrix.query.optimizer.relational.rules.CapabilitiesUtil;
import com.metamatrix.query.processor.ProcessorPlan;
import com.metamatrix.query.processor.batch.BatchedUpdatePlan;
import com.metamatrix.query.processor.relational.BatchedUpdateNode;
@@ -138,7 +139,7 @@
batchLoop: for (int batchIndex = commandIndex+1; batchIndex < numCommands; batchIndex++) {
Command batchingCandidate = (Command)updateCommands.get(batchIndex);
// If this command updates the same model, and is eligible for batching, add it to the batch
- if (canBeAddedToBatch(batchingCandidate, batchModelID, metadata)) {
+ if (canBeAddedToBatch(batchingCandidate, batchModelID, metadata, capFinder)) {
batch.add(batchingCandidate);
if (allContexts != null) {
contexts.add(allContexts.get(batchIndex));
@@ -222,20 +223,18 @@
* @param command an update command
* @param batchModelID the model ID for the batch concerned
* @param metadata
+ * @param capFinder
* @return true if this command can be place in a batch associated with the model ID; false otherwise
* @throws QueryMetadataException
* @throws MetaMatrixComponentException
* @since 4.2
*/
- private static boolean canBeAddedToBatch(Command command, Object batchModelID, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ private static boolean canBeAddedToBatch(Command command, Object batchModelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, MetaMatrixComponentException {
// If it's eligible ...
if (isEligibleForBatching(command, metadata)) {
Object modelID = metadata.getModelID(getUpdatedGroup(command).getMetadataID());
- // ... and it updates a group in the same model ...
- if (modelID.equals(batchModelID)) {
- // ... then it can be added to the batch.
- return true;
- }
+
+ return CapabilitiesUtil.isSameConnector(modelID, batchModelID, metadata, capFinder);
}
return false;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -36,6 +36,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.common.buffer.impl.BufferConfig;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.query.QueryPlugin;
@@ -78,11 +79,6 @@
public static final float UNKNOWN_VALUE = -1;
- // These batch size should generally not be used as they should be retrieved from the
- // command context, however they might be used in test scenarios where that is undefined
- static final int DEFAULT_PROCESSOR_BATCH_SIZE = 2000;
- static final int DEFAULT_CONNECTOR_BATCH_SIZE = 2000;
-
// the following variables are used to hold cost estimates (roughly in milliseconds)
private final static float compareTime = .05f; //TODO: a better estimate would be based upon the number of conjuncts
private final static float readTime = .001f; //TODO: should come from the connector
@@ -908,7 +904,7 @@
float numberComparisons = merge?(leftChildCardinality + rightChildCardinality):(leftChildCardinality * rightChildCardinality);
- float connectorBatchSize = DEFAULT_CONNECTOR_BATCH_SIZE;
+ float connectorBatchSize = BufferConfig.DEFAULT_CONNECTOR_BATCH_SIZE;
if(context != null) {
connectorBatchSize = context.getConnectorBatchSize();
}
@@ -969,8 +965,8 @@
return UNKNOWN_VALUE;
}
- float connectorBatchSize = DEFAULT_CONNECTOR_BATCH_SIZE;
- float processorBatchSize = DEFAULT_PROCESSOR_BATCH_SIZE;
+ float connectorBatchSize = BufferConfig.DEFAULT_CONNECTOR_BATCH_SIZE;
+ float processorBatchSize = BufferConfig.DEFAULT_PROCESSOR_BATCH_SIZE;
if(context != null) {
connectorBatchSize = context.getConnectorBatchSize();
processorBatchSize = context.getProcessorBatchSize();
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -36,8 +36,8 @@
// This gets set according to the current clause
public boolean aggregatesAllowed = false;
- // treat a double quoted variable as variable insted of string
- public boolean allowDoubleQuotedVariable=false;
+ // treat a double quoted variable as variable instead of string
+ public boolean allowDoubleQuotedVariable=true;
public ParseInfo() { }
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -225,7 +225,6 @@
Object[] params = new Object[] { id };
throw new ParseException(QueryPlugin.Util.getString("SQLParser.Invalid_id", params)); //$NON-NLS-1$
}
- id = id.replace('/', '.');
id = id.replaceAll("\"", ""); //$NON-NLS-1$ //$NON-NLS-2$
return id;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -30,6 +30,7 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryProcessingException;
+import com.metamatrix.common.buffer.impl.BufferConfig;
import com.metamatrix.core.util.ArgCheck;
import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.eval.SecurityFunctionEvaluator;
@@ -54,9 +55,9 @@
/** Identify a group of related commands, which typically get cleaned up together */
private String connectionID;
- private int processorBatchSize = 2000;
+ private int processorBatchSize = BufferConfig.DEFAULT_PROCESSOR_BATCH_SIZE;
- private int connectorBatchSize = 2000;
+ private int connectorBatchSize = BufferConfig.DEFAULT_CONNECTOR_BATCH_SIZE;
private String userName;
Modified: trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -131,7 +131,6 @@
*/
public ColumnRecordImpl findElement(String elementName) throws QueryMetadataException {
- ColumnRecordImpl result = null;
if (StringUtil.startsWithIgnoreCase(elementName,UUID.PROTOCOL)) {
for (MetadataStore store : this.metadataStores) {
for (TableRecordImpl table : store.getTables().values()) {
@@ -154,10 +153,7 @@
}
}
}
- if (result == null) {
- throw new QueryMetadataException(elementName+TransformationMetadata.NOT_EXISTS_MESSAGE);
- }
- return result;
+ throw new QueryMetadataException(elementName+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
public Collection<TableRecordImpl> getXMLTempGroups(TableRecordImpl tableRecord) throws QueryMetadataException {
Modified: trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -225,10 +225,10 @@
public Object getGroupIDForElementID(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
if(elementID instanceof ColumnRecordImpl) {
ColumnRecordImpl columnRecord = (ColumnRecordImpl) elementID;
- return this.getGroupID(columnRecord.getParentFullName());
+ return this.getGroupID(getGroupName(columnRecord.getFullName()));
} else if(elementID instanceof ProcedureParameterRecordImpl){
ProcedureParameterRecordImpl columnRecord = (ProcedureParameterRecordImpl) elementID;
- return this.getGroupID(columnRecord.getParentFullName());
+ return this.getGroupID(getGroupName(columnRecord.getFullName()));
} else {
throw createInvalidRecordTypeException(elementID);
}
@@ -675,7 +675,7 @@
ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
TableRecordImpl tableRecord = (TableRecordImpl) groupID;
if(tableRecord.isMaterialized()) {
- return this.getGroupID(tableRecord.getMaterializedTableName());
+ return tableRecord.getMaterializedTable();
}
return null;
}
@@ -689,7 +689,7 @@
ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
TableRecordImpl tableRecord = (TableRecordImpl) groupID;
if(tableRecord.isMaterialized()) {
- return this.getGroupID(tableRecord.getMaterializedStageTableName());
+ return tableRecord.getMaterializedStageTable();
}
return null;
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -802,17 +802,17 @@
}
public void testInsert() {
- helpPlan("Insert into pm1.g1 (pm1.g1.e1, pm1.g1.e2) values (\"MyString\", 1)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ helpPlan("Insert into pm1.g1 (pm1.g1.e1, pm1.g1.e2) values ('MyString', 1)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES ('MyString', 1)"} ); //$NON-NLS-1$
}
public void testUpdate1() {
- helpPlan("Update pm1.g1 Set pm1.g1.e1= LTRIM(\"MyString\"), pm1.g1.e2= 1 where pm1.g1.e3= \"true\"", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ helpPlan("Update pm1.g1 Set pm1.g1.e1= LTRIM('MyString'), pm1.g1.e2= 1 where pm1.g1.e3= 'true'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "UPDATE pm1.g1 SET pm1.g1.e1 = 'MyString', pm1.g1.e2 = 1 WHERE pm1.g1.e3 = TRUE"} ); //$NON-NLS-1$
}
public void testUpdate2() {
- helpPlan("Update pm1.g1 Set pm1.g1.e1= LTRIM(\"MyString\"), pm1.g1.e2= 1 where pm1.g1.e2= convert(pm1.g1.e4, integer)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ helpPlan("Update pm1.g1 Set pm1.g1.e1= LTRIM('MyString'), pm1.g1.e2= 1 where pm1.g1.e2= convert(pm1.g1.e4, integer)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
new String[] { "UPDATE pm1.g1 SET pm1.g1.e1 = 'MyString', pm1.g1.e2 = 1 WHERE pm1.g1.e2 = convert(pm1.g1.e4, integer)"} ); //$NON-NLS-1$
}
@@ -3639,7 +3639,7 @@
ProcessorPlan plan = helpPlan(
"SELECT VDBName PKVDB, PKGroupFullName, PKElementName, VDBName FKVDB,FKGroupFullName, FKElementName, convert(FKPosition, short) As FKPosition, FKKeyName, PKKeyName " + //$NON-NLS-1$
- "FROM System.ReferenceKeyElements WHERE PKKeyType = 'Primary' AND FKKeyType = 'Foreign' AND FKGroupFullName = \"PartsOracle.SUPPLIER_PARTS\"", //$NON-NLS-1$
+ "FROM System.ReferenceKeyElements WHERE PKKeyType = 'Primary' AND FKKeyType = 'Foreign' AND FKGroupFullName = 'PartsOracle.SUPPLIER_PARTS'", //$NON-NLS-1$
FakeMetadataFactory.exampleSystemPhysical(),
null, capFinder,
new String[] {
Modified: trunk/engine/src/test/java/com/metamatrix/query/optimizer/proc/TestProcedurePlanner.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/proc/TestProcedurePlanner.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/proc/TestProcedurePlanner.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -138,7 +138,7 @@
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(CHANGING.e1=\"false\" and INPUT.e1=1)\n"; //$NON-NLS-1$
+ procedure = procedure + "if(CHANGING.e1='false' and INPUT.e1=1)\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -2070,15 +2070,15 @@
ElementSymbol a = new ElementSymbol("a"); //$NON-NLS-1$
select.addSymbol(a);
- Expression constant = new Constant("value"); //$NON-NLS-1$
- Criteria crit = new CompareCriteria(a, CompareCriteria.NE, constant);
+ Expression ex = new ElementSymbol("value"); //$NON-NLS-1$
+ Criteria crit = new CompareCriteria(a, CompareCriteria.NE, ex);
Query query = new Query();
query.setSelect(select);
query.setFrom(from);
query.setCriteria(crit);
helpTest("SELECT a from db.g where a <> \"value\"", //$NON-NLS-1$
- "SELECT a FROM db.g WHERE a <> 'value'", //$NON-NLS-1$
+ "SELECT a FROM db.g WHERE a <> value", //$NON-NLS-1$
query);
}
@@ -2099,7 +2099,7 @@
query.setSelect(select);
query.setFrom(from);
query.setCriteria(crit);
- helpTest("SELECT a from db.g where a != \"value\"", //$NON-NLS-1$
+ helpTest("SELECT a from db.g where a != 'value'", //$NON-NLS-1$
"SELECT a FROM db.g WHERE a <> 'value'", //$NON-NLS-1$
query);
}
@@ -5316,7 +5316,7 @@
}
public void testUnicode3() {
- String sql = "SELECT \"\u05e0\""; //$NON-NLS-1$
+ String sql = "SELECT '\u05e0'"; //$NON-NLS-1$
Query query = new Query();
Select select = new Select();
@@ -6461,54 +6461,7 @@
"SELECT fooKey AS fooAlias FROM x.y.z", //$NON-NLS-1$
query, info);
}
-
- public void testFullyQualifiedElementWithSlashes() throws Exception {
- GroupSymbol g = new GroupSymbol("x.y.z"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- select.addSymbol(new ElementSymbol("x.y.z.fooKey")); //$NON-NLS-1$
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("SELECT \"x/y\".z.fooKey FROM \"x/y\".z", //$NON-NLS-1$
- "SELECT x.y.z.fooKey FROM x.y.z", //$NON-NLS-1$
- query);
- }
-
- public void testFullyQualifiedVaribleWithSlashes() throws Exception {
- GroupSymbol g = new GroupSymbol("x.y.z"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- select.addSymbol(new ElementSymbol("x.y.z.fooKey")); //$NON-NLS-1$
- AliasSymbol alias = new AliasSymbol("key", new ElementSymbol("x.y.z.key2")); //$NON-NLS-1$ //$NON-NLS-2$
- select.addSymbol(alias);
-
- Criteria crit = new CompareCriteria(new ElementSymbol("x.y.z.fooKey"), SubqueryCompareCriteria.GT, new Constant(new Integer(10))); //$NON-NLS-1$
-
- OrderBy orderby = new OrderBy();
- orderby.addVariable(new ElementSymbol("x.y.z.fooKey"), true); //$NON-NLS-1$
-
- GroupBy groupby = new GroupBy();
- groupby.addSymbol(new ElementSymbol("key")); //$NON-NLS-1$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
- query.setCriteria(crit);
- query.setOrderBy(orderby);
- query.setGroupBy(groupby);
-
- helpTest("SELECT x/y.z.fooKey, x/y.z.key2 as 'key' FROM x/y.z where x/y.z.fooKey > 10 group by key order by x/y.z.fooKey", //$NON-NLS-1$
- "SELECT x.y.z.fooKey, x.y.z.key2 AS key FROM x.y.z WHERE x.y.z.fooKey > 10 GROUP BY key ORDER BY x.y.z.fooKey", //$NON-NLS-1$
- query);
- }
-
/** QUERY Tool Format*/
public void testQueryWithQuotes_MSQuery() throws Exception {
QueryParser.getQueryParser().parseCommand("SELECT \"PART_COLOR\", \"PART_ID\", \"PART_NAME\", \"PART_WEIGHT\" FROM \"VirtualParts/base\".\"Parts\""); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -3989,7 +3989,7 @@
@Test public void testInsert() {
// Create query
- String sql = "Insert into pm1.g1 (pm1.g1.e1, pm1.g1.e2) values (\"MyString\", 1)"; //$NON-NLS-1$
+ String sql = "Insert into pm1.g1 (pm1.g1.e1, pm1.g1.e2) values ('MyString', 1)"; //$NON-NLS-1$
// Create expected results
List[] expected = new List[] {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -42,12 +42,6 @@
* @since 4.2
*/
public class NodeTestUtil {
- static BufferManager getTestBufferManager(long bytesAvailable) {
- // Get the properties for BufferManager
- Properties bmProps = new Properties();
- bmProps.setProperty(BufferManagerPropertyNames.MEMORY_AVAILABLE, "" + bytesAvailable); //$NON-NLS-1$
- return createBufferManager(bmProps);
- }
static BufferManager getTestBufferManager(long bytesAvailable, int procBatchSize, int connectorBatchSize) {
Modified: trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -57,7 +57,7 @@
public static final int INT_BATCH_SIZE = TestSortNode.getIntBatchSize(); //the size of 100 integers
private void helpTestSort(long bytesInMemory, List elements, List[] data, List sortElements, List sortTypes, List[] expected, Set blockOn, Mode mode) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- BufferManager mgr = NodeTestUtil.getTestBufferManager(bytesInMemory);
+ BufferManager mgr = NodeTestUtil.getTestBufferManager(bytesInMemory, BATCH_SIZE, BATCH_SIZE);
TestableBufferManagerImpl impl = (TestableBufferManagerImpl) mgr;
impl.setBlockOn(blockOn);
impl.getConfig().setTotalAvailableMemory(bytesInMemory);
Modified: trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -1630,7 +1630,7 @@
String procedure = "CREATE PROCEDURE "; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "DECLARE integer var1;\n"; //$NON-NLS-1$
- procedure = procedure + "if(CHANGING.e1=\"false\" and INPUT.e1=1)\n"; //$NON-NLS-1$
+ procedure = procedure + "if(CHANGING.e1='false' and INPUT.e1=1)\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Select pm1.g1.e2, Input.e2 from pm1.g1;\n"; //$NON-NLS-1$
procedure = procedure + "UPDATE pm1.g1 SET pm1.g1.e1 = INPUT.e1, pm1.g1.e2 = INPUT.e2;\n"; //$NON-NLS-1$
Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -833,7 +833,7 @@
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "Insert into vm1.g1 (e1, e2) values (\"String\", 1)"; //$NON-NLS-1$
+ String userQuery = "Insert into vm1.g1 (e1, e2) values ('String', 1)"; //$NON-NLS-1$
String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
@@ -860,7 +860,7 @@
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "Insert into vm1.g1 (e1, e2) values (\"String\", 1)"; //$NON-NLS-1$
+ String userQuery = "Insert into vm1.g1 (e1, e2) values ('String', 1)"; //$NON-NLS-1$
String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
@@ -888,7 +888,7 @@
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "Insert into vm1.g1 (e1, e2) values (\"String\", 1)"; //$NON-NLS-1$
+ String userQuery = "Insert into vm1.g1 (e1, e2) values ('String', 1)"; //$NON-NLS-1$
String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
@@ -911,7 +911,7 @@
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "Insert into vm1.g1 (e1, e2) values (\"String\", 1)"; //$NON-NLS-1$
+ String userQuery = "Insert into vm1.g1 (e1, e2) values ('String', 1)"; //$NON-NLS-1$
String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
@@ -929,13 +929,13 @@
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "IF (CHANGING.e1 = \"false\")\n"; //$NON-NLS-1$
+ procedure = procedure + "IF (CHANGING.e1 = 'false')\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Select e1 from vm1.g1 where HAS = CRITERIA ON (vm1.g1.e2);\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "Update vm1.g1 SET e1 = \"String\", e2 =1 where e2 = 10"; //$NON-NLS-1$
+ String userQuery = "Update vm1.g1 SET e1 = 'String', e2 =1 where e2 = 10"; //$NON-NLS-1$
String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
@@ -952,12 +952,12 @@
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "IF (CHANGING.e1 = \"true\")\n"; //$NON-NLS-1$
+ procedure = procedure + "IF (CHANGING.e1 = 'true')\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "Update vm1.g1 SET e1 = \"String\", e2 =1 where e2 = 10"; //$NON-NLS-1$
+ String userQuery = "Update vm1.g1 SET e1 = 'String', e2 =1 where e2 = 10"; //$NON-NLS-1$
String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
@@ -974,13 +974,13 @@
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "IF (CHANGING.e1 = \"true\")\n"; //$NON-NLS-1$
+ procedure = procedure + "IF (CHANGING.e1 = 'true')\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Select e2 from pm1.g1 where TRANSLATE = CRITERIA ON (vm1.g1.e2);\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "Update vm1.g1 SET e1 = \"String\", e2 =1 where e2 = 10"; //$NON-NLS-1$
+ String userQuery = "Update vm1.g1 SET e1 = 'String', e2 =1 where e2 = 10"; //$NON-NLS-1$
String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
@@ -998,13 +998,13 @@
String procedure = "CREATE PROCEDURE\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
- procedure = procedure + "IF (CHANGING.e1 = \"true\")\n"; //$NON-NLS-1$
+ procedure = procedure + "IF (CHANGING.e1 = 'true')\n"; //$NON-NLS-1$
procedure = procedure + "BEGIN\n"; //$NON-NLS-1$
procedure = procedure + "Select e2 from pm1.g1 where TRANSLATE = CRITERIA ON (vm1.g1.e2) with (vm1.g1.e2 = convert(sqrt(pm1.g1.e2), integer));\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "Update vm1.g1 SET e1 = \"String\", e2 =1 where e2 = 10"; //$NON-NLS-1$
+ String userQuery = "Update vm1.g1 SET e1 = 'String', e2 =1 where e2 = 10"; //$NON-NLS-1$
String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
@@ -1794,7 +1794,7 @@
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "Insert into vm1.g1 (e1, e2) values (\"String\", 1)"; //$NON-NLS-1$
+ String userQuery = "Insert into vm1.g1 (e1, e2) values ('String', 1)"; //$NON-NLS-1$
QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(FakeMetadataObject.Props.INSERT_PROCEDURE, procedure);
@@ -1821,7 +1821,7 @@
procedure = procedure + "END\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "Insert into vm1.g1 (e1, e2) values (\"String\", 1)"; //$NON-NLS-1$
+ String userQuery = "Insert into vm1.g1 (e1, e2) values ('String', 1)"; //$NON-NLS-1$
String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
@@ -1843,7 +1843,7 @@
procedure = procedure + "Select count(*) from pm1.g1;\n"; //$NON-NLS-1$
procedure = procedure + "END\n"; //$NON-NLS-1$
- String userQuery = "Insert into vm1.g1 (e1, e2) values (\"String\", 1)"; //$NON-NLS-1$
+ String userQuery = "Insert into vm1.g1 (e1, e2) values ('String', 1)"; //$NON-NLS-1$
String rewritProc = "CREATE PROCEDURE\n"; //$NON-NLS-1$
rewritProc = rewritProc + "BEGIN\n"; //$NON-NLS-1$
Modified: trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -1092,10 +1092,10 @@
QueryNode vspqn59 = new QueryNode("vsp59", "CREATE VIRTUAL PROCEDURE BEGIN SELECT * INTO #temp FROM pm5.g3;INSERT INTO #temp (e1, e2) VALUES('integer',1); END"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vsp59 = createVirtualProcedure("pm5.vsp59", pm6, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn59); //$NON-NLS-1$
- QueryNode vspqn60 = new QueryNode("vsp60", "CREATE VIRTUAL PROCEDURE BEGIN create local temporary table temp_table (column1 string);insert into temp_table (column1) values (\"First\");insert into temp_table (column1) values (\"Second\");insert into temp_table (column1) values (\"Third\");select * from temp_table; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vspqn60 = new QueryNode("vsp60", "CREATE VIRTUAL PROCEDURE BEGIN create local temporary table temp_table (column1 string);insert into temp_table (column1) values ('First');insert into temp_table (column1) values ('Second');insert into temp_table (column1) values ('Third');select * from temp_table; END"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vsp60 = createVirtualProcedure("pm1.vsp60", pm1, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn60); //$NON-NLS-1$
- QueryNode vspqn61 = new QueryNode("vsp61", "CREATE VIRTUAL PROCEDURE BEGIN create local temporary table temp_table (column1 string);insert into temp_table (column1) values (\"First\");drop table temp_table;create local temporary table temp_table (column1 string);insert into temp_table (column1) values (\"First\");insert into temp_table (column1) values (\"Second\");insert into temp_table (column1) values (\"Third\");select * from temp_table; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vspqn61 = new QueryNode("vsp61", "CREATE VIRTUAL PROCEDURE BEGIN create local temporary table temp_table (column1 string);insert into temp_table (column1) values ('First');drop table temp_table;create local temporary table temp_table (column1 string);insert into temp_table (column1) values ('First');insert into temp_table (column1) values ('Second');insert into temp_table (column1) values ('Third');select * from temp_table; END"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vsp61 = createVirtualProcedure("pm1.vsp61", pm1, Arrays.asList(new FakeMetadataObject[] { vspp1 }), vspqn61); //$NON-NLS-1$
QueryNode vspqn62 = new QueryNode("vsp62", "CREATE VIRTUAL PROCEDURE BEGIN create local temporary table temp_table (column1 string); select e1 as column1 into temp_table from pm1.g1;select * from temp_table; END"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -1920,7 +1920,7 @@
QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g2 = createUpdatableVirtualGroup("vm1.g2", vm1, vm1g2n1); //$NON-NLS-1$
- QueryNode vm1g3n1 = new QueryNode("vm1.g3", "SELECT CONCAT(e1, \"m\") as x, (e2 +1) as y, Count(*) as e3, e4*50 as e4 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryNode vm1g3n1 = new QueryNode("vm1.g3", "SELECT CONCAT(e1, 'm') as x, (e2 +1) as y, Count(*) as e3, e4*50 as e4 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
FakeMetadataObject vm1g3 = createUpdatableVirtualGroup("vm1.g3", vm1, vm1g3n1); //$NON-NLS-1$
QueryNode vm1g4n1 = new QueryNode("vm1.g4", "SELECT * FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -27,6 +27,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -62,6 +63,7 @@
private Index[] indexes;
private Map<String, DatatypeRecordImpl> datatypeCache;
private Map<String, KeyRecord> primaryKeyCache = new HashMap<String, KeyRecord>();
+ private Map<String, TableRecordImpl> tableCache = new HashMap<String, TableRecordImpl>();
private MetadataStore store = new MetadataStore();
public IndexMetadataFactory(MetadataSource source) throws IOException {
@@ -91,77 +93,93 @@
}
public void getTables() {
- Collection<TableRecordImpl> records = findMetadataRecords(MetadataConstants.RECORD_TYPE.TABLE, null, false);
- for (TableRecordImpl tableRecord : records) {
- List<ColumnRecordImpl> columns = new ArrayList<ColumnRecordImpl>(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.COLUMN));
- for (ColumnRecordImpl columnRecordImpl : columns) {
- columnRecordImpl.setDatatype(getDatatypeCache().get(columnRecordImpl.getDatatypeUUID()));
- }
- Collections.sort(columns);
- tableRecord.setColumns(columns);
- tableRecord.setAccessPatterns(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.ACCESS_PATTERN));
- Map<String, ColumnRecordImpl> uuidColumnMap = new HashMap<String, ColumnRecordImpl>();
- for (ColumnRecordImpl columnRecordImpl : columns) {
- uuidColumnMap.put(columnRecordImpl.getUUID(), columnRecordImpl);
- }
- for (KeyRecord columnSetRecordImpl : tableRecord.getAccessPatterns()) {
- loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
- columnSetRecordImpl.setTable(tableRecord);
- }
- tableRecord.setForiegnKeys(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.FOREIGN_KEY));
- for (ForeignKeyRecordImpl foreignKeyRecord : tableRecord.getForeignKeys()) {
- foreignKeyRecord.setPrimaryKey(getPrimaryKey(foreignKeyRecord.getUniqueKeyID()));
- loadColumnSetRecords(foreignKeyRecord, uuidColumnMap);
- foreignKeyRecord.setTable(tableRecord);
- }
- tableRecord.setUniqueKeys(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.UNIQUE_KEY));
- for (KeyRecord columnSetRecordImpl : tableRecord.getUniqueKeys()) {
- loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
- columnSetRecordImpl.setTable(tableRecord);
- }
- tableRecord.setIndexes(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.INDEX));
- for (KeyRecord columnSetRecordImpl : tableRecord.getIndexes()) {
- loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
- columnSetRecordImpl.setTable(tableRecord);
- }
- if (tableRecord.getPrimaryKey() != null) {
- KeyRecord primaryKey = getPrimaryKey(tableRecord.getPrimaryKey().getUUID());
- loadColumnSetRecords(primaryKey, uuidColumnMap);
- primaryKey.setTable(tableRecord);
- tableRecord.setPrimaryKey(primaryKey);
- }
- String groupName = tableRecord.getFullName();
- if (tableRecord.isVirtual()) {
- TransformationRecordImpl update = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.UPDATE_TRANSFORM,false);
- if (update != null) {
- tableRecord.setUpdatePlan(update.getTransformation());
+ for (ModelRecordImpl model : store.getModels().values()) {
+ List<TableRecordImpl> records = findMetadataRecords(MetadataConstants.RECORD_TYPE.TABLE, model.getName() + IndexConstants.NAME_DELIM_CHAR + IndexConstants.RECORD_STRING.MATCH_CHAR, true);
+ //load non-materialized first, so that the uuid->table cache is populated
+ Collections.sort(records, new Comparator<TableRecordImpl>() {
+ @Override
+ public int compare(TableRecordImpl o1, TableRecordImpl o2) {
+ if (!o1.isMaterialized()) {
+ return -1;
+ }
+ if (!o2.isMaterialized()) {
+ return 1;
+ }
+ return 0;
+ }
+ });
+ for (TableRecordImpl tableRecord : records) {
+ tableCache.put(tableRecord.getUUID(), tableRecord);
+ List<ColumnRecordImpl> columns = new ArrayList<ColumnRecordImpl>(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.COLUMN));
+ for (ColumnRecordImpl columnRecordImpl : columns) {
+ columnRecordImpl.setDatatype(getDatatypeCache().get(columnRecordImpl.getDatatypeUUID()));
+ }
+ Collections.sort(columns);
+ tableRecord.setColumns(columns);
+ tableRecord.setAccessPatterns(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.ACCESS_PATTERN));
+ Map<String, ColumnRecordImpl> uuidColumnMap = new HashMap<String, ColumnRecordImpl>();
+ for (ColumnRecordImpl columnRecordImpl : columns) {
+ uuidColumnMap.put(columnRecordImpl.getUUID(), columnRecordImpl);
+ }
+ for (KeyRecord columnSetRecordImpl : tableRecord.getAccessPatterns()) {
+ loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
+ columnSetRecordImpl.setTable(tableRecord);
+ }
+ tableRecord.setForiegnKeys(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.FOREIGN_KEY));
+ for (ForeignKeyRecordImpl foreignKeyRecord : tableRecord.getForeignKeys()) {
+ foreignKeyRecord.setPrimaryKey(getPrimaryKey(foreignKeyRecord.getUniqueKeyID()));
+ loadColumnSetRecords(foreignKeyRecord, uuidColumnMap);
+ foreignKeyRecord.setTable(tableRecord);
+ }
+ tableRecord.setUniqueKeys(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.UNIQUE_KEY));
+ for (KeyRecord columnSetRecordImpl : tableRecord.getUniqueKeys()) {
+ loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
+ columnSetRecordImpl.setTable(tableRecord);
+ }
+ tableRecord.setIndexes(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.INDEX));
+ for (KeyRecord columnSetRecordImpl : tableRecord.getIndexes()) {
+ loadColumnSetRecords(columnSetRecordImpl, uuidColumnMap);
+ columnSetRecordImpl.setTable(tableRecord);
+ }
+ if (tableRecord.getPrimaryKey() != null) {
+ KeyRecord primaryKey = getPrimaryKey(tableRecord.getPrimaryKey().getUUID());
+ loadColumnSetRecords(primaryKey, uuidColumnMap);
+ primaryKey.setTable(tableRecord);
+ tableRecord.setPrimaryKey(primaryKey);
}
- TransformationRecordImpl insert = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.INSERT_TRANSFORM,false);
- if (insert != null) {
- tableRecord.setInsertPlan(insert.getTransformation());
+ String groupUUID = tableRecord.getUUID();
+ if (tableRecord.isVirtual()) {
+ TransformationRecordImpl update = (TransformationRecordImpl)getRecordByType(groupUUID, MetadataConstants.RECORD_TYPE.UPDATE_TRANSFORM,false);
+ if (update != null) {
+ tableRecord.setUpdatePlan(update.getTransformation());
+ }
+ TransformationRecordImpl insert = (TransformationRecordImpl)getRecordByType(groupUUID, MetadataConstants.RECORD_TYPE.INSERT_TRANSFORM,false);
+ if (insert != null) {
+ tableRecord.setInsertPlan(insert.getTransformation());
+ }
+ TransformationRecordImpl delete = (TransformationRecordImpl)getRecordByType(groupUUID, MetadataConstants.RECORD_TYPE.DELETE_TRANSFORM,false);
+ if (delete != null) {
+ tableRecord.setDeletePlan(delete.getTransformation());
+ }
+ TransformationRecordImpl select = (TransformationRecordImpl)getRecordByType(groupUUID, MetadataConstants.RECORD_TYPE.SELECT_TRANSFORM,false);
+ // this group may be an xml document
+ if(select == null) {
+ select = (TransformationRecordImpl)getRecordByType(groupUUID, MetadataConstants.RECORD_TYPE.MAPPING_TRANSFORM,false);
+ }
+ if (select != null) {
+ tableRecord.setSelectTransformation(select.getTransformation());
+ tableRecord.setBindings(select.getBindings());
+ tableRecord.setSchemaPaths(select.getSchemaPaths());
+ tableRecord.setResourcePath(select.getResourcePath());
+ }
}
- TransformationRecordImpl delete = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.DELETE_TRANSFORM,false);
- if (delete != null) {
- tableRecord.setDeletePlan(delete.getTransformation());
+ if (tableRecord.isMaterialized()) {
+ tableRecord.setMaterializedStageTable(tableCache.get(tableRecord.getMaterializedStageTable().getUUID()));
+ tableRecord.setMaterializedTable(tableCache.get(tableRecord.getMaterializedTable().getUUID()));
}
- TransformationRecordImpl select = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.SELECT_TRANSFORM,false);
- // this group may be an xml document
- if(select == null) {
- select = (TransformationRecordImpl)getRecordByType(groupName, MetadataConstants.RECORD_TYPE.MAPPING_TRANSFORM,false);
- }
- if (select != null) {
- tableRecord.setSelectTransformation(select.getTransformation());
- tableRecord.setBindings(select.getBindings());
- tableRecord.setSchemaPaths(select.getSchemaPaths());
- tableRecord.setResourcePath(select.getResourcePath());
- }
- }
- if (tableRecord.isMaterialized()) {
- tableRecord.setMaterializedStageTableName(((TableRecordImpl)getRecordByType(tableRecord.getMaterializedStageTableID(), MetadataConstants.RECORD_TYPE.TABLE)).getFullName());
- tableRecord.setMaterializedTableName(((TableRecordImpl)getRecordByType(tableRecord.getMaterializedTableID(), MetadataConstants.RECORD_TYPE.TABLE)).getFullName());
- }
- this.store.addTable(tableRecord);
- }
+ store.addTable(tableRecord);
+ }
+ }
}
private KeyRecord getPrimaryKey(String uuid) {
@@ -215,39 +233,41 @@
}
public void getProcedures() {
- Collection<ProcedureRecordImpl> procedureRecordImpls = findMetadataRecords(MetadataConstants.RECORD_TYPE.CALLABLE, null, false);
- for (ProcedureRecordImpl procedureRecord : procedureRecordImpls) {
- procedureRecord.setParameters(new ArrayList<ProcedureParameterRecordImpl>(procedureRecord.getParameterIDs().size()));
-
- // get the parameter metadata info
- for (String paramID : procedureRecord.getParameterIDs()) {
- ProcedureParameterRecordImpl paramRecord = (ProcedureParameterRecordImpl) this.getRecordByType(paramID, MetadataConstants.RECORD_TYPE.CALLABLE_PARAMETER);
- paramRecord.setDatatype(getDatatypeCache().get(paramRecord.getDatatypeUUID()));
- procedureRecord.getParameters().add(paramRecord);
- }
-
- String resultID = procedureRecord.getResultSetID();
- if(resultID != null) {
- ColumnSetRecordImpl resultRecord = (ColumnSetRecordImpl) getRecordByType(resultID, MetadataConstants.RECORD_TYPE.RESULT_SET, false);
- if (resultRecord != null) {
- loadColumnSetRecords(resultRecord, null);
- procedureRecord.setResultSet(resultRecord);
- }
- //it is ok to be null here. it will happen when a
- //virtual stored procedure is created from a
- //physical stored procedrue without a result set
- //TODO: find a better fix for this
- }
-
- // if this is a virtual procedure get the procedure plan
- if(procedureRecord.isVirtual()) {
- TransformationRecordImpl transformRecord = (TransformationRecordImpl)getRecordByType(procedureRecord.getFullName(), MetadataConstants.RECORD_TYPE.PROC_TRANSFORM, false);
- if(transformRecord != null) {
- procedureRecord.setQueryPlan(transformRecord.getTransformation());
- }
- }
- this.store.addProcedure(procedureRecord);
- }
+ for (ModelRecordImpl model : store.getModels().values()) {
+ Collection<ProcedureRecordImpl> procedureRecordImpls = findMetadataRecords(MetadataConstants.RECORD_TYPE.CALLABLE, model.getName() + IndexConstants.NAME_DELIM_CHAR + IndexConstants.RECORD_STRING.MATCH_CHAR, true);
+ for (ProcedureRecordImpl procedureRecord : procedureRecordImpls) {
+ procedureRecord.setParameters(new ArrayList<ProcedureParameterRecordImpl>(procedureRecord.getParameterIDs().size()));
+
+ // get the parameter metadata info
+ for (String paramID : procedureRecord.getParameterIDs()) {
+ ProcedureParameterRecordImpl paramRecord = (ProcedureParameterRecordImpl) this.getRecordByType(paramID, MetadataConstants.RECORD_TYPE.CALLABLE_PARAMETER);
+ paramRecord.setDatatype(getDatatypeCache().get(paramRecord.getDatatypeUUID()));
+ procedureRecord.getParameters().add(paramRecord);
+ }
+
+ String resultID = procedureRecord.getResultSetID();
+ if(resultID != null) {
+ ColumnSetRecordImpl resultRecord = (ColumnSetRecordImpl) getRecordByType(resultID, MetadataConstants.RECORD_TYPE.RESULT_SET, false);
+ if (resultRecord != null) {
+ loadColumnSetRecords(resultRecord, null);
+ procedureRecord.setResultSet(resultRecord);
+ }
+ //it is ok to be null here. it will happen when a
+ //virtual stored procedure is created from a
+ //physical stored procedure without a result set
+ //TODO: find a better fix for this
+ }
+
+ // if this is a virtual procedure get the procedure plan
+ if(procedureRecord.isVirtual()) {
+ TransformationRecordImpl transformRecord = (TransformationRecordImpl)getRecordByType(procedureRecord.getUUID(), MetadataConstants.RECORD_TYPE.PROC_TRANSFORM, false);
+ if(transformRecord != null) {
+ procedureRecord.setQueryPlan(transformRecord.getTransformation());
+ }
+ }
+ store.addProcedure(procedureRecord);
+ }
+ }
}
/**
@@ -277,10 +297,10 @@
}
}
- private Collection findMetadataRecords(final char recordType,
+ private List findMetadataRecords(final char recordType,
final String entityName, final boolean isPartialName) {
IEntryResult[] results = queryIndex(recordType, entityName, isPartialName);
- Collection<AbstractMetadataRecord> records = loadRecords(results);
+ List<AbstractMetadataRecord> records = loadRecords(results);
return records;
}
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -438,9 +438,13 @@
if(includeMaterializationFlag(indexVersion)) {
// The next token are the UUIDs for the materialized table ID
- table.setMaterializedTableID((String)tokens.get(tokenIndex++));
+ TableRecordImpl matTable = new TableRecordImpl();
+ matTable.setUUID((String)tokens.get(tokenIndex++));
+ table.setMaterializedTable(matTable);
// The next token are the UUID for the materialized stage table ID
- table.setMaterializedStageTableID((String)tokens.get(tokenIndex++));
+ matTable = new TableRecordImpl();
+ matTable.setUUID((String)tokens.get(tokenIndex++));
+ table.setMaterializedStageTable(matTable);
}
// The next tokens are footer values
@@ -1002,7 +1006,7 @@
* be the order of the arguments in method signature.
*/
private static void setRecordHeaderValues(final AbstractMetadataRecord record, final String recordType,
- final String upperName, final String objectID, final String fullName,
+ final String upperName, final String objectID, String fullName,
final String nameInSource,
final String parentObjectID) {
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -127,16 +127,4 @@
resourcePath = path;
}
- public String toString() {
- StringBuffer sb = new StringBuffer(100);
- sb.append(getClass().getSimpleName());
- sb.append(" name="); //$NON-NLS-1$
- sb.append(getName());
- sb.append(", nameInSource="); //$NON-NLS-1$
- sb.append(getNameInSource());
- sb.append(", uuid="); //$NON-NLS-1$
- sb.append(getUUID());
- return sb.toString();
- }
-
}
\ No newline at end of file
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBaseDQPService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBaseDQPService.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedBaseDQPService.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -22,7 +22,6 @@
package com.metamatrix.dqp.embedded.services;
-import java.util.Collection;
import java.util.Properties;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -30,12 +29,8 @@
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.common.vdb.api.VDBDefn;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.vdb.runtime.VDBKey;
/**
@@ -115,39 +110,4 @@
return started;
}
- protected VDBKey vdbId(VDBArchive vdb) {
- return new VDBKey(vdb.getName(),vdb.getVersion());
- }
-
- protected VDBKey vdbId(String name, String version) {
- return new VDBKey(name, version);
- }
-
- /**
- * checks the validity of the VDB
- * @param vdb
- * @return true if valid; false otherwise.
- */
- protected boolean isValidVDB(VDBArchive vdb) {
-
- // check if vdb has validity errors. If so log it..
- if (vdb.getVDBValidityErrors() != null) {
- String[] errors = vdb.getVDBValidityErrors();
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < errors.length; i++) {
- sb.append("-").append(errors[i]).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
- } // for
- DQPEmbeddedPlugin.logError("VDBService.validityErrors", new Object[] {vdb.getName(), sb}); //$NON-NLS-1$
- return false;
- }
-
- VDBDefn def = vdb.getConfigurationDef();
- Collection models = def.getModels();
- if (models != null && models.isEmpty()) {
- DQPEmbeddedPlugin.logError("VDBService.vdb_missing_models", new Object[] {vdb.getName(), vdb.getVersion()}); //$NON-NLS-1$
- return false;
- }
-
- return true;
- }
}
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedConfigurationService.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -271,7 +271,7 @@
*/
public VDBArchive getVDB(String vdbName, String vdbVersion)
throws MetaMatrixComponentException {
- return loadedVDBs.get(vdbId(vdbName, vdbVersion));
+ return loadedVDBs.get(new VDBKey(vdbName, vdbVersion));
}
/**
@@ -338,7 +338,7 @@
}
// make sure we match up the connector binding based on user preferences
- URL vdbFile = availableVDBFiles.get(vdbId(srcVdb));
+ URL vdbFile = availableVDBFiles.get(srcVdb.getVDBKey());
if (vdbFile == null) {
vdbFile = getNewVDBLocation(srcVdb);
VDBConfigurationWriter.write(srcVdb, vdbFile);
@@ -352,7 +352,7 @@
private VDBArchive loadVDB(VDBArchive vdb, boolean replaceBindings) throws MetaMatrixComponentException {
// check if this is a valid VDB
- if (!isValidVDB(vdb)) {
+ if (!vdb.isValid()) {
throw new MetaMatrixComponentException(DQPEmbeddedPlugin.Util.getString("EmbeddedConfigurationService.invalid_vdb", vdb.getName())); //$NON-NLS-1$
}
@@ -485,7 +485,7 @@
try {
- URL vdbFile = availableVDBFiles.remove(vdbId(vdb));
+ URL vdbFile = availableVDBFiles.remove(vdb.getVDBKey());
Assertion.isNotNull(vdbFile);
@@ -496,7 +496,7 @@
notifyVDBUnLoad(vdb.getName(), vdb.getVersion());
// remove from local references.
- loadedVDBs.remove(vdbId(vdb));
+ loadedVDBs.remove(vdb.getVDBKey());
VDBDefn def = vdb.getConfigurationDef();
@@ -1128,8 +1128,8 @@
private void deployVDB(URL vdbURL, VDBArchive vdb) {
// add vdb to loaded VDBS
- loadedVDBs.put(vdbId(vdb), vdb);
- availableVDBFiles.put(vdbId(vdb), vdbURL);
+ loadedVDBs.put(vdb.getVDBKey(), vdb);
+ availableVDBFiles.put(vdb.getVDBKey(), vdbURL);
DQPEmbeddedPlugin.logInfo("EmbeddedConfigurationService.loaded_vdb", new Object[] {vdbURL}); //$NON-NLS-1$
}
@@ -1338,7 +1338,7 @@
return Boolean.valueOf(getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_BUFFER_USEDISK, "true")).booleanValue(); //$NON-NLS-1$
}
- private File getWorkDir() {
+ public File getWorkDir() {
String workDirectory = getUserPreferences().getProperty(DQPEmbeddedProperties.DQP_WORKDIR);
File workDir = new File(workDirectory);
return workDir;
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -22,39 +22,211 @@
package com.metamatrix.dqp.embedded.services;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.metadata.CompositeMetadataStore;
import org.teiid.metadata.TransformationMetadata;
+import org.teiid.metadata.index.IndexMetadataFactory;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.common.application.ApplicationEnvironment;
import com.metamatrix.common.application.exception.ApplicationInitializationException;
import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.common.vdb.api.VDBArchive;
+import com.metamatrix.core.CoreConstants;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+import com.metamatrix.dqp.DQPPlugin;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.service.DataService;
import com.metamatrix.dqp.service.MetadataService;
import com.metamatrix.dqp.service.VDBLifeCycleListener;
import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.dqp.util.LogConstants;
+import com.metamatrix.metadata.runtime.api.MetadataSource;
+import com.metamatrix.vdb.runtime.VDBKey;
/**
* @since 4.3
*/
public class EmbeddedMetadataService extends EmbeddedBaseDQPService implements MetadataService {
-
- private QueryMetadataCache metadataCache = null;
+
private VDBLifeCycleListener listener = new VDBLifeCycleListener() {
public void loaded(String vdbName, String vdbVersion) {
}
public void unloaded(String vdbName, String vdbVersion) {
- metadataCache.removeFromCache(vdbName, vdbVersion);
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {"QueryMetadataCache Removing vdb from cache", vdbName, vdbVersion}); //$NON-NLS-1$
+ if(vdbName != null && vdbVersion != null) {
+ final VDBKey vdbID = toVdbID(vdbName, vdbVersion);
+ vdbToQueryMetadata.remove(vdbID);
+ }
}
};
+
+ private static class QueryMetadataHolder {
+ TransformationMetadata qmi;
+ }
+
+ // vdbID to QueryMetadataInterfaceHolder map
+ private Map<VDBKey, QueryMetadataHolder> vdbToQueryMetadata = Collections.synchronizedMap(new HashMap<VDBKey, QueryMetadataHolder>());
+ // RuntimeIndexSelector for the system vdb
+ private VDBArchive systemVDBSelector;
+ // boolean for the cache being valid
+ private boolean isCacheValid = true;
+ private MetadataStore systemMetadataStore;
+
+ /**
+ * Look up metadata for the given vdbName, version at the given filecontent.
+ * @throws MetaMatrixComponentException
+ */
+ private TransformationMetadata lookupMetadata(final String vdbName, final String vdbVersion, MetadataSource iss, DataService dataService) throws MetaMatrixComponentException {
+ assertIsValidCache();
+ VDBKey vdbID = toVdbID(vdbName, vdbVersion);
+ QueryMetadataHolder qmiHolder = null;
+ // Enter a synchronized block to find the holder of a QueryMetadataInterface for a VDB
+ synchronized(vdbToQueryMetadata) {
+ qmiHolder = vdbToQueryMetadata.get(vdbID);
+ if ( qmiHolder == null ) {
+ qmiHolder = new QueryMetadataHolder();
+ vdbToQueryMetadata.put(vdbID, qmiHolder);
+ }
+ }
+ synchronized (qmiHolder) {
+ if (qmiHolder.qmi == null) {
+ qmiHolder.qmi = loadMetadata(vdbID, iss, dataService);
+ }
+ }
+ return qmiHolder.qmi;
+ }
+
+ private void assertIsValidCache() {
+ if(!this.isCacheValid) {
+ throw new MetaMatrixRuntimeException(DQPPlugin.Util.getString("QueryMetadataCache.cache_not_valid")); //$NON-NLS-1$
+ }
+ }
+
+ private TransformationMetadata loadMetadata(final VDBKey vdbID, final MetadataSource runtimeSelector, DataService dataService) throws MetaMatrixComponentException {
+ // check cache status
+ assertIsValidCache();
+
+ List<MetadataStore> metadataStores = new ArrayList<MetadataStore>();
+ try {
+ metadataStores.add(loadMetadataStore(runtimeSelector));
+ Set<String> modelNames = runtimeSelector.getConnectorMetadataModelNames();
+ if (!modelNames.isEmpty()) {
+ for (String modelName : modelNames) {
+ MetadataStore connectorMetadata = null;
+ String savedMetadata = "/runtime-inf/" + modelName.toLowerCase() + ".ser"; //$NON-NLS-1$ //$NON-NLS-2$
+ if (runtimeSelector.cacheConnectorMetadata()) {
+ connectorMetadata = loadMetadataStore(runtimeSelector, savedMetadata);
+ }
+ if (connectorMetadata == null) {
+ connectorMetadata = dataService.getConnectorMetadata(vdbID.getName(), vdbID.getVersion(), modelName, runtimeSelector.getModelInfo(modelName).getProperties());
+ }
+ if (runtimeSelector.cacheConnectorMetadata()) {
+ saveMetadataStore(runtimeSelector, connectorMetadata, savedMetadata);
+ }
+ metadataStores.add(connectorMetadata);
+ }
+ }
+ metadataStores.add(systemMetadataStore);
+ } catch (IOException e) {
+ throw new MetaMatrixComponentException(e);
+ }
+ // build a composite selector for the runtimeselectors of this vdb and system vdb
+ CompositeMetadataStore composite = new CompositeMetadataStore(metadataStores, runtimeSelector);
+ return new TransformationMetadata(composite);
+ }
+
+ public void updateCostMetadata(String vdbName, String vdbVersion, String modelName) throws MetaMatrixComponentException {
+ CompositeMetadataStore store = getMetadataObjectSource(vdbName, vdbVersion);
+ //...
+ }
+
+ public void updateCostMetadata(String vdbName, String vdbVersion, String objectName, String propertyName, String value) {
+
+ }
+
+ private void saveMetadataStore(final MetadataSource runtimeSelector,
+ MetadataStore connectorMetadata, String savedMetadata)
+ throws IOException {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(connectorMetadata);
+ oos.close();
+ runtimeSelector.saveFile(new ByteArrayInputStream(baos.toByteArray()), savedMetadata);
+ }
+
+ private MetadataStore loadMetadataStore(final MetadataSource vdb) throws IOException {
+ String savedMetadata = "/runtime-inf/" + vdb.getName().toLowerCase() + ".vdb.ser"; //$NON-NLS-1$ //$NON-NLS-2$
+ MetadataStore store = loadMetadataStore(vdb, savedMetadata);
+ if (store == null) {
+ store = new IndexMetadataFactory(vdb).getMetadataStore();
+ saveMetadataStore(vdb, store, savedMetadata);
+ }
+ return store;
+ }
+
+ private MetadataStore loadMetadataStore(final MetadataSource runtimeSelector, String savedMetadata) throws IOException {
+ File f = runtimeSelector.getFile(savedMetadata);
+ if (f != null) {
+ ObjectInputStream ois = null;
+ try {
+ ois = new ObjectInputStream(new FileInputStream(f));
+ return (MetadataStore)ois.readObject();
+ } catch (Exception e) {
+
+ } finally {
+ if (ois != null) {
+ ois.close();
+ }
+ }
+ }
+ return null;
+ }
+
+ public Map<String, DatatypeRecordImpl> getBuiltinDatatypes() {
+ Collection<DatatypeRecordImpl> datatypes = this.systemMetadataStore.getDatatypes();
+ Map<String, DatatypeRecordImpl> datatypeMap = new HashMap<String, DatatypeRecordImpl>();
+ for (Class<?> typeClass : DataTypeManager.getAllDataTypeClasses()) {
+ for (DatatypeRecordImpl datatypeRecordImpl : datatypes) {
+ if (datatypeRecordImpl.getJavaClassName().equals(typeClass.getName())) {
+ datatypeMap.put(DataTypeManager.getDataTypeName(typeClass), datatypeRecordImpl);
+ break;
+ }
+ }
+ }
+ return datatypeMap;
+ }
+
+ /**
+ * Return unique id for a vdb
+ */
+ private VDBKey toVdbID(final String vdbName, final String vdbVersion) {
+ return new VDBKey(vdbName, vdbVersion);
+ }
+
+
/**
* @see com.metamatrix.dqp.embedded.services.EmbeddedBaseDQPService#initializeService(java.util.Properties)
* @since 4.3
@@ -69,10 +241,11 @@
public void startService(ApplicationEnvironment environment) throws ApplicationLifecycleException {
try {
ConfigurationService configSvc = this.getConfigurationService();
- this.metadataCache = new QueryMetadataCache(configSvc.getSystemVdb());
+ this.systemVDBSelector = VDBArchive.loadVDB(configSvc.getSystemVdb(), configSvc.getWorkDir());
+ this.systemMetadataStore = loadMetadataStore(this.systemVDBSelector);
configSvc.register(listener);
- } catch (MetaMatrixComponentException e) {
- throw new ApplicationLifecycleException(e);
+ } catch (IOException e) {
+ throw new ApplicationLifecycleException(e, DQPPlugin.Util.getString("QueryMetadataCache.Failed_creating_Runtime_Index_Selector._4", CoreConstants.SYSTEM_VDB)); //$NON-NLS-1$
}
}
@@ -82,7 +255,17 @@
*/
public void stopService() throws ApplicationLifecycleException {
getConfigurationService().unregister(this.listener);
- this.metadataCache.clearCache();
+ LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {"QueryMetadataCache Clearing VDB cache"}); //$NON-NLS-1$
+ // mark cache invalid
+ isCacheValid = false;
+ // Clear the holders ...
+ vdbToQueryMetadata.clear();
+
+ // Clean up the directory for the System VDB ...
+ if (this.systemVDBSelector != null) {
+ // selector should no longer be used
+ this.systemVDBSelector.close();
+ }
}
/**
@@ -93,7 +276,7 @@
throws MetaMatrixComponentException {
VDBService vdbService = ((VDBService)lookupService(DQPServiceNames.VDB_SERVICE));
DataService dataService = ((DataService)lookupService(DQPServiceNames.DATA_SERVICE));
- return this.metadataCache.lookupMetadata(vdbName, vdbVersion, vdbService.getVDB(vdbName, vdbVersion), dataService);
+ return lookupMetadata(vdbName, vdbVersion, vdbService.getVDB(vdbName, vdbVersion), dataService);
}
@@ -101,10 +284,4 @@
return lookupMetadata(vdbName, vdbVersion).getMetadataStore();
}
- @Override
- public Map<String, DatatypeRecordImpl> getBuiltinDatatypes()
- throws MetaMatrixComponentException {
- return this.metadataCache.getBuiltinDatatypes();
- }
-
}
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedVDBService.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -243,20 +243,22 @@
if (status != currentStatus) {
// Change the VDB's status
- if (currentStatus != VDBStatus.ACTIVE
- && (status == VDBStatus.ACTIVE || status == VDBStatus.ACTIVE_DEFAULT) ) {
- if (!isValidVDB(vdb) || !getConfigurationService().isFullyConfiguredVDB(vdb)) {
+ if (status == VDBStatus.ACTIVE || status == VDBStatus.ACTIVE_DEFAULT) {
+ if (!vdb.isValid()) {
+ throw new MetaMatrixComponentException(DQPEmbeddedPlugin.Util.getString("EmbeddedConfigurationService.invalid_vdb", vdb.getName())); //$NON-NLS-1$
+ }
+ if (!getConfigurationService().isFullyConfiguredVDB(vdb)) {
throw new MetaMatrixComponentException(DQPEmbeddedPlugin.Util.getString("VDBService.vdb_missing_bindings", new Object[] {vdb.getName(), vdb.getVersion()})); //$NON-NLS-1$
}
+ if (status == VDBStatus.ACTIVE_DEFAULT) {
+ //only 1 can be set as active default
+ VDBArchive latestActive = getVDB(vdbName, null);
+ if (latestActive.getStatus() == VDBStatus.ACTIVE_DEFAULT) {
+ latestActive.setStatus(VDBStatus.ACTIVE);
+ getConfigurationService().saveVDB(latestActive, latestActive.getVersion());
+ }
+ }
}
- if (status == VDBStatus.ACTIVE_DEFAULT) {
- //only 1 can be set as active default
- VDBArchive latestActive = getVDB(vdbName, null);
- if (latestActive.getStatus() == VDBStatus.ACTIVE_DEFAULT) {
- latestActive.setStatus(VDBStatus.ACTIVE);
- getConfigurationService().saveVDB(latestActive, latestActive.getVersion());
- }
- }
vdb.setStatus((short)status);
// make sure we got what we asked for
Deleted: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/QueryMetadataCache.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/QueryMetadataCache.java 2009-11-12 19:47:07 UTC (rev 1549)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/QueryMetadataCache.java 2009-11-16 02:17:12 UTC (rev 1550)
@@ -1,225 +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 com.metamatrix.dqp.embedded.services;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.metadata.CompositeMetadataStore;
-import org.teiid.metadata.TransformationMetadata;
-import org.teiid.metadata.index.IndexMetadataFactory;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.util.LogConstants;
-import com.metamatrix.metadata.runtime.api.MetadataSource;
-import com.metamatrix.vdb.runtime.VDBKey;
-
-
-/**
- * This caches QueryMetadataInterface implementations for all vdbs, each implementation has access to
- * metadata for a given vdb and the system vdb.
- * @since 4.2
- */
-public class QueryMetadataCache {
-
- private static class QueryMetadataHolder {
- TransformationMetadata qmi;
- }
-
- // vdbID to QueryMetadataInterfaceHolder map
- private Map<VDBKey, QueryMetadataHolder> vdbToQueryMetadata = Collections.synchronizedMap(new HashMap<VDBKey, QueryMetadataHolder>());
- // RuntimeIndexSelector for the system vdb
- private final VDBArchive systemVDBSelector;
-
- // boolean for the cache being valid
- private boolean isCacheValid = true;
- private MetadataStore systemMetadataStore;
-
- /**
- * Constructor given a URL to a system vdb.
- * @since 4.2
- */
- public QueryMetadataCache(final URL systemVdbUrl) throws MetaMatrixComponentException {
- try {
- this.systemVDBSelector = new VDBArchive(systemVdbUrl.openStream());
- this.systemMetadataStore = new IndexMetadataFactory(this.systemVDBSelector).getMetadataStore();
- } catch(IOException e) {
- throw new MetaMatrixComponentException(e, DQPPlugin.Util.getString("QueryMetadataCache.Failed_creating_Runtime_Index_Selector._4", CoreConstants.SYSTEM_VDB)); //$NON-NLS-1$
- }
- }
-
- /**
- * Look up metadata for the given vdbName, version at the given filecontent.
- * @throws MetaMatrixComponentException
- */
- public TransformationMetadata lookupMetadata(final String vdbName, final String vdbVersion, MetadataSource iss, DataService dataService) throws MetaMatrixComponentException {
- assertIsValidCache();
- VDBKey vdbID = toVdbID(vdbName, vdbVersion);
- QueryMetadataHolder qmiHolder = null;
- // Enter a synchronized block to find the holder of a QueryMetadataInterface for a VDB
- synchronized(vdbToQueryMetadata) {
- qmiHolder = vdbToQueryMetadata.get(vdbID);
- if ( qmiHolder == null ) {
- qmiHolder = new QueryMetadataHolder();
- vdbToQueryMetadata.put(vdbID, qmiHolder);
- }
- }
- synchronized (qmiHolder) {
- if (qmiHolder.qmi == null) {
- qmiHolder.qmi = loadMetadata(vdbID, iss, dataService);
- }
- }
- return qmiHolder.qmi;
- }
-
- private void assertIsValidCache() {
- if(!this.isCacheValid) {
- throw new MetaMatrixRuntimeException(DQPPlugin.Util.getString("QueryMetadataCache.cache_not_valid")); //$NON-NLS-1$
- }
- }
-
- private TransformationMetadata loadMetadata(final VDBKey vdbID, final MetadataSource runtimeSelector, DataService dataService) throws MetaMatrixComponentException {
- // check cache status
- assertIsValidCache();
-
- List<MetadataStore> metadataStores = new ArrayList<MetadataStore>();
- try {
- metadataStores.add(new IndexMetadataFactory(runtimeSelector).getMetadataStore());
- Set<String> modelNames = runtimeSelector.getConnectorMetadataModelNames();
- if (!modelNames.isEmpty()) {
- for (String modelName : modelNames) {
- MetadataStore connectorMetadata = null;
- String savedMetadata = "/META-INF/" + modelName.toLowerCase() + ".ser"; //$NON-NLS-1$ //$NON-NLS-2$
- if (runtimeSelector.cacheConnectorMetadata()) {
- File f = runtimeSelector.getFile(savedMetadata);
- if (f != null) {
- ObjectInputStream ois = null;
- try {
- ois = new ObjectInputStream(new FileInputStream(f));
- connectorMetadata = (MetadataStore)ois.readObject();
- } catch (Exception e) {
-
- } finally {
- if (ois != null) {
- ois.close();
- }
- }
- }
- }
- if (connectorMetadata == null) {
- connectorMetadata = dataService.getConnectorMetadata(vdbID.getName(), vdbID.getVersion(), modelName, runtimeSelector.getModelInfo(modelName).getProperties());
- }
- if (runtimeSelector.cacheConnectorMetadata()) {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(connectorMetadata);
- oos.close();
- runtimeSelector.saveFile(new ByteArrayInputStream(baos.toByteArray()), savedMetadata);
- }
- metadataStores.add(connectorMetadata);
- }
- }
- metadataStores.add(systemMetadataStore);
- } catch (IOException e) {
- throw new MetaMatrixComponentException(e);
- }
- // build a composite selector for the runtimeselectors of this vdb and system vdb
- CompositeMetadataStore composite = new CompositeMetadataStore(metadataStores, runtimeSelector);
- return new TransformationMetadata(composite);
- }
-
- public Map<String, DatatypeRecordImpl> getBuiltinDatatypes() {
- Collection<DatatypeRecordImpl> datatypes = this.systemMetadataStore.getDatatypes();
- Map<String, DatatypeRecordImpl> datatypeMap = new HashMap<String, DatatypeRecordImpl>();
- for (Class<?> typeClass : DataTypeManager.getAllDataTypeClasses()) {
- for (DatatypeRecordImpl datatypeRecordImpl : datatypes) {
- if (datatypeRecordImpl.getJavaClassName().equals(typeClass.getName())) {
- datatypeMap.put(DataTypeManager.getDataTypeName(typeClass), datatypeRecordImpl);
- break;
- }
- }
- }
- return datatypeMap;
- }
-
- /**
- * Clears all state on this cache and also deletes any indexfiles
- * associated with the cache.
- * @since 4.2
- */
- public void clearCache() {
- LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {"QueryMetadataCache Clearing VDB cache"}); //$NON-NLS-1$
- // mark cache invalid
- isCacheValid = false;
- // Clear the holders ...
- vdbToQueryMetadata.clear();
-
- // Clean up the directory for the System VDB ...
- if (this.systemVDBSelector != null) {
- // selector should no longer be used
- this.systemVDBSelector.close();
- }
- }
-
- /**
- * Remove cache for a given vdb, called when a vdb is actually deleted.
- * Also deletes any temp files associated with the vdb.
- */
- public void removeFromCache(final String vdbName, final String vdbVersion) {
- LogManager.logTrace(LogConstants.CTX_DQP, new Object[] {"QueryMetadataCache Removing vdb from cache", vdbName, vdbVersion}); //$NON-NLS-1$
- if(vdbName != null && vdbVersion != null) {
- final VDBKey vdbID = toVdbID(vdbName, vdbVersion);
- vdbToQueryMetadata.remove(vdbID);
- }
- }
-
- /**
- * Return unique id for a vdb
- */
- private VDBKey toVdbID(final String vdbName, final String vdbVersion) {
- return new VDBKey(vdbName, vdbVersion);
- }
-
-}
15 years, 1 month
teiid SVN: r1549 - in trunk: connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc and 10 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-11-12 14:47:07 -0500 (Thu, 12 Nov 2009)
New Revision: 1549
Added:
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TranslationHelper.java
Removed:
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/MetadataFactory.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/extension/impl/
Modified:
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCProcedureExecution.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2SqlTranslator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbySQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
trunk/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
Log:
TEIID-880 adding a fix for uniqueidentifier handling
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sqlserver/SqlServerSQLTranslator.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -28,9 +28,16 @@
import java.util.List;
import org.teiid.connector.api.ConnectorCapabilities;
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.api.ExecutionContext;
+import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.jdbc.sybase.SybaseSQLTranslator;
+import org.teiid.connector.language.IElement;
import org.teiid.connector.language.IFunction;
+import org.teiid.connector.language.ILanguageObject;
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
/**
* Updated to assume the use of the DataDirect, 2005 driver, or later.
*/
@@ -52,5 +59,20 @@
public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
return SqlServerCapabilities.class;
}
+
+ @Override
+ public List<?> translate(ILanguageObject obj, ExecutionContext context) {
+ if (obj instanceof IElement) {
+ IElement elem = (IElement)obj;
+ try {
+ if (TypeFacility.RUNTIME_TYPES.STRING.equals(elem.getType()) && "uniqueidentifier".equalsIgnoreCase(elem.getMetadataObject().getNativeType())) { //$NON-NLS-1$
+ return Arrays.asList("cast(", elem, " as char(36))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } catch (ConnectorException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ }
+ return super.translate(obj, context);
+ }
}
Deleted: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/MetadataFactory.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/MetadataFactory.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/MetadataFactory.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -1,66 +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.connector.jdbc;
-
-import static org.junit.Assert.*;
-
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.jdbc.translator.TranslatedCommand;
-import org.teiid.connector.jdbc.translator.Translator;
-import org.teiid.connector.language.ICommand;
-
-import junit.framework.Assert;
-
-import com.metamatrix.cdk.api.EnvironmentUtility;
-import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.cdk.unittest.FakeTranslationFactory;
-
-public class MetadataFactory {
-
- public static final String PARTS_VDB = "/PartsSupplier.vdb"; //$NON-NLS-1$
- public static final String BQT_VDB = "/bqt.vdb"; //$NON-NLS-1$
-
- public static ICommand helpTranslate(String vdbFileName, String sql) {
- TranslationUtility util = null;
- if (PARTS_VDB.equals(vdbFileName)) {
- util = new TranslationUtility(MetadataFactory.class.getResource(vdbFileName));
- } else if (BQT_VDB.equals(vdbFileName)){
- util = FakeTranslationFactory.getInstance().getBQTTranslationUtility();
- } else {
- Assert.fail("unknown vdb"); //$NON-NLS-1$
- }
- return util.parseCommand(sql);
- }
-
- public static void helpTestVisitor(String vdb, String input, String expectedOutput, Translator translator) throws ConnectorException {
- // Convert from sql to objects
- ICommand obj = helpTranslate(vdb, input);
-
- TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), translator); //$NON-NLS-1$
- tc.translateCommand(obj);
-
- // Check stuff
- assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
- }
-
-}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCProcedureExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCProcedureExecution.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCProcedureExecution.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -44,7 +44,7 @@
public class TestJDBCProcedureExecution {
@Test public void testProcedureExecution() throws Exception {
- ICommand command = MetadataFactory.helpTranslate(MetadataFactory.BQT_VDB, "exec pm2.spTest8a()"); //$NON-NLS-1$
+ ICommand command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "exec pm2.spTest8a()"); //$NON-NLS-1$
Connection connection = Mockito.mock(Connection.class);
CallableStatement cs = Mockito.mock(CallableStatement.class);
Mockito.stub(cs.getUpdateCount()).toReturn(-1);
@@ -60,7 +60,7 @@
}
@Test public void testProcedureExecution1() throws Exception {
- ICommand command = MetadataFactory.helpTranslate(MetadataFactory.BQT_VDB, "exec pm2.spTest8(1)"); //$NON-NLS-1$
+ ICommand command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "exec pm2.spTest8(1)"); //$NON-NLS-1$
Connection connection = Mockito.mock(Connection.class);
CallableStatement cs = Mockito.mock(CallableStatement.class);
Mockito.stub(cs.getUpdateCount()).toReturn(-1);
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -42,7 +42,7 @@
public class TestJDBCUpdateExecution {
@Test public void testBulkUpdate() throws Exception {
- ICommand command = MetadataFactory.helpTranslate(MetadataFactory.BQT_VDB, "insert into bqt1.smalla (intkey, intnum) values (1, 2)"); //$NON-NLS-1$
+ ICommand command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "insert into bqt1.smalla (intkey, intnum) values (1, 2)"); //$NON-NLS-1$
ILiteral value = ((ILiteral)((IInsertExpressionValueSource)((IInsert)command).getValueSource()).getValues().get(0));
ILiteral value1 = ((ILiteral)((IInsertExpressionValueSource)((IInsert)command).getValueSource()).getValues().get(1));
value.setMultiValued(true);
Copied: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TranslationHelper.java (from rev 1545, trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/MetadataFactory.java)
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TranslationHelper.java (rev 0)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TranslationHelper.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -0,0 +1,69 @@
+/*
+ * 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.connector.jdbc;
+
+import static org.junit.Assert.*;
+
+import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.jdbc.translator.TranslatedCommand;
+import org.teiid.connector.jdbc.translator.Translator;
+import org.teiid.connector.language.ICommand;
+
+import junit.framework.Assert;
+
+import com.metamatrix.cdk.api.EnvironmentUtility;
+import com.metamatrix.cdk.api.TranslationUtility;
+import com.metamatrix.cdk.unittest.FakeTranslationFactory;
+
+public class TranslationHelper {
+
+ public static final String PARTS_VDB = "/PartsSupplier.vdb"; //$NON-NLS-1$
+ public static final String BQT_VDB = "/bqt.vdb"; //$NON-NLS-1$
+
+ public static ICommand helpTranslate(String vdbFileName, String sql) {
+ TranslationUtility util = null;
+ if (PARTS_VDB.equals(vdbFileName)) {
+ util = new TranslationUtility(TranslationHelper.class.getResource(vdbFileName));
+ } else if (BQT_VDB.equals(vdbFileName)){
+ util = FakeTranslationFactory.getInstance().getBQTTranslationUtility();
+ } else {
+ Assert.fail("unknown vdb"); //$NON-NLS-1$
+ }
+ return util.parseCommand(sql);
+ }
+
+ public static void helpTestVisitor(String vdb, String input, String expectedOutput, Translator translator) throws ConnectorException {
+ // Convert from sql to objects
+ ICommand obj = helpTranslate(vdb, input);
+
+ helpTestVisitor(expectedOutput, translator, obj);
+ }
+
+ public static void helpTestVisitor(String expectedOutput,
+ Translator translator, ICommand obj) throws ConnectorException {
+ TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), translator); //$NON-NLS-1$
+ tc.translateCommand(obj);
+ assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TranslationHelper.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2SqlTranslator.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/db2/TestDB2SqlTranslator.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -30,7 +30,7 @@
import org.junit.Test;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.jdbc.MetadataFactory;
+import org.teiid.connector.jdbc.TranslationHelper;
import org.teiid.connector.jdbc.translator.TranslatedCommand;
import org.teiid.connector.language.ICommand;
@@ -130,7 +130,7 @@
String input = "SELECT locate(INTNUM, 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT LOCATE(char(SmallA.IntNum), 'chimp', 1) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -147,7 +147,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp') FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT LOCATE(SmallA.StringNum, 'chimp') FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -164,7 +164,7 @@
String input = "SELECT locate(INTNUM, '234567890', 1) FROM BQT1.SMALLA WHERE INTKEY = 26"; //$NON-NLS-1$
String output = "SELECT LOCATE(char(SmallA.IntNum), '234567890', 1) FROM SmallA WHERE SmallA.IntKey = 26"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -181,7 +181,7 @@
String input = "SELECT locate('c', 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT 1 FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -198,7 +198,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', -5) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT LOCATE(SmallA.StringNum, 'chimp', 1) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -215,7 +215,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', INTNUM) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT LOCATE(SmallA.StringNum, 'chimp', CASE WHEN SmallA.IntNum < 1 THEN 1 ELSE SmallA.IntNum END) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -232,7 +232,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', LOCATE(STRINGNUM, 'chimp') + 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT LOCATE(SmallA.StringNum, 'chimp', CASE WHEN (LOCATE(SmallA.StringNum, 'chimp') + 1) < 1 THEN 1 ELSE (LOCATE(SmallA.StringNum, 'chimp') + 1) END) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbySQLTranslator.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/derby/TestDerbySQLTranslator.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -27,7 +27,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.jdbc.MetadataFactory;
+import org.teiid.connector.jdbc.TranslationHelper;
import com.metamatrix.cdk.api.EnvironmentUtility;
@@ -48,7 +48,7 @@
String input = "select concat(stringnum,'_xx') from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT {fn concat(SmallA.StringNum, '_xx')} FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB, input, output, TRANSLATOR);
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
@Test
@@ -56,7 +56,7 @@
String input = "select concat(stringnum, stringnum) from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT {fn concat(SmallA.StringNum, SmallA.StringNum)} FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB, input, output, TRANSLATOR);
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
@Test
@@ -64,7 +64,7 @@
String input = "select concat2(stringnum,'_xx') from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT {fn concat(coalesce(SmallA.StringNum, ''), '_xx')} FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB, input, output, TRANSLATOR);
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
@Test
@@ -72,7 +72,7 @@
String input = "select concat2(stringnum, stringnum) from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT CASE WHEN SmallA.StringNum IS NULL THEN NULL ELSE {fn concat(coalesce(SmallA.StringNum, ''), coalesce(SmallA.StringNum, ''))} END FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB, input, output, TRANSLATOR);
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/h2/TestH2Translator.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -27,7 +27,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.jdbc.MetadataFactory;
+import org.teiid.connector.jdbc.TranslationHelper;
import com.metamatrix.cdk.api.EnvironmentUtility;
@@ -45,21 +45,21 @@
String input = "select timestampdiff(SQL_TSI_FRAC_SECOND, timestampvalue, {d'1970-01-01'}) from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT datediff('MILLISECOND', SmallA.TimestampValue, TIMESTAMP '1970-01-01 00:00:00.0') * 1000000 FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB, input, output, TRANSLATOR);
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
@Test public void testTimestampAdd() throws Exception {
String input = "select timestampadd(SQL_TSI_FRAC_SECOND, 2, datevalue) from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT cast(dateadd('MILLISECOND', (2 / 1000000), cast(SmallA.DateValue AS timestamp)) AS date) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB, input, output, TRANSLATOR);
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
@Test public void testTimestampAdd1() throws Exception {
String input = "select timestampadd(SQL_TSI_HOUR, intnum, {t'00:00:00'}) from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT cast(dateadd('HOUR', SmallA.IntNum, TIMESTAMP '1970-01-01 00:00:00.0') AS time) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB, input, output, TRANSLATOR);
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -27,7 +27,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.jdbc.MetadataFactory;
+import org.teiid.connector.jdbc.TranslationHelper;
import com.metamatrix.cdk.api.EnvironmentUtility;
@@ -43,18 +43,18 @@
}
private String getTestVDB() {
- return MetadataFactory.PARTS_VDB;
+ return TranslationHelper.PARTS_VDB;
}
private String getTestBQTVDB() {
- return MetadataFactory.BQT_VDB;
+ return TranslationHelper.BQT_VDB;
}
@Test public void testConversion1() throws Exception {
String input = "SELECT char(convert(PART_WEIGHT, integer) + 100) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT char((cast(PARTS.PART_WEIGHT AS signed) + 100)) FROM PARTS"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -63,7 +63,7 @@
String input = "SELECT convert(PART_WEIGHT, long) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(PARTS.PART_WEIGHT AS signed) FROM PARTS"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -72,7 +72,7 @@
String input = "SELECT convert(convert(PART_WEIGHT, long), string) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(cast(PARTS.PART_WEIGHT AS signed) AS char) FROM PARTS"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -81,7 +81,7 @@
String input = "SELECT convert(convert(PART_WEIGHT, date), string) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT date_format(DATE(PARTS.PART_WEIGHT), '%Y-%m-%d') FROM PARTS"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -89,7 +89,7 @@
String input = "SELECT convert(convert(PART_WEIGHT, time), string) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT date_format(TIME(PARTS.PART_WEIGHT), '%H:%i:%S') FROM PARTS"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -97,7 +97,7 @@
String input = "SELECT convert(convert(PART_WEIGHT, timestamp), string) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT date_format(TIMESTAMP(PARTS.PART_WEIGHT), '%Y-%m-%d %H:%i:%S.%f') FROM PARTS"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -105,7 +105,7 @@
String input = "SELECT ifnull(PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
String output = "SELECT ifnull(PARTS.PART_WEIGHT, 'otherString') FROM PARTS"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -113,7 +113,7 @@
String input = "SELECT convert(convert(PART_WEIGHT, integer), string) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT cast(cast(PARTS.PART_WEIGHT AS signed) AS char) FROM PARTS"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -121,7 +121,7 @@
String input = "SELECT insert(PART_WEIGHT, 1, 5, 'chimp') FROM PARTS"; //$NON-NLS-1$
String output = "SELECT insert(PARTS.PART_WEIGHT, 1, 5, 'chimp') FROM PARTS"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -138,7 +138,7 @@
String input = "SELECT locate(INTNUM, 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT LOCATE(cast(SmallA.IntNum AS char), 'chimp', 1) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -155,7 +155,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp') FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT LOCATE(SmallA.StringNum, 'chimp') FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -172,7 +172,7 @@
String input = "SELECT locate(INTNUM, '234567890', 1) FROM BQT1.SMALLA WHERE INTKEY = 26"; //$NON-NLS-1$
String output = "SELECT LOCATE(cast(SmallA.IntNum AS char), '234567890', 1) FROM SmallA WHERE SmallA.IntKey = 26"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -189,7 +189,7 @@
String input = "SELECT locate('c', 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT 1 FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -206,7 +206,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', -5) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT LOCATE(SmallA.StringNum, 'chimp', 1) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -223,7 +223,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', INTNUM) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT LOCATE(SmallA.StringNum, 'chimp', CASE WHEN SmallA.IntNum < 1 THEN 1 ELSE SmallA.IntNum END) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -240,7 +240,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', LOCATE(STRINGNUM, 'chimp') + 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT LOCATE(SmallA.StringNum, 'chimp', CASE WHEN (LOCATE(SmallA.StringNum, 'chimp') + 1) < 1 THEN 1 ELSE (LOCATE(SmallA.StringNum, 'chimp') + 1) END) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -249,7 +249,7 @@
String input = "SELECT substring(PART_WEIGHT, 1) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT substring(PARTS.PART_WEIGHT, 1) FROM PARTS"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -257,7 +257,7 @@
String input = "SELECT substring(PART_WEIGHT, 1, 5) FROM PARTS"; //$NON-NLS-1$
String output = "SELECT substring(PARTS.PART_WEIGHT, 1, 5) FROM PARTS"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -265,7 +265,7 @@
String input = "SELECT PART_ID FROM PARTS UNION SELECT PART_ID FROM PARTS ORDER BY PART_ID"; //$NON-NLS-1$
String output = "(SELECT PARTS.PART_ID FROM PARTS) UNION (SELECT PARTS.PART_ID FROM PARTS) ORDER BY PART_ID"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestVDB(),
+ TranslationHelper.helpTestVisitor(getTestVDB(),
input,
output, TRANSLATOR);
}
@@ -274,7 +274,7 @@
String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 100"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestBQTVDB(),
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
input,
output, TRANSLATOR);
}
@@ -283,7 +283,7 @@
String input = "select intkey from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
String output = "SELECT SmallA.IntKey FROM SmallA LIMIT 50, 100"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(getTestBQTVDB(),
+ TranslationHelper.helpTestVisitor(getTestBQTVDB(),
input,
output, TRANSLATOR);
}
@@ -292,7 +292,7 @@
String input = "select bitand(intkey, intnum) from bqt1.smalla"; //$NON-NLS-1$
String output = "SELECT cast((SmallA.IntKey & SmallA.IntNum) AS signed) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input,
output, TRANSLATOR);
}
@@ -301,7 +301,7 @@
String input = "select smalla.intkey from bqt1.smalla inner join bqt1.smallb on smalla.stringkey=smallb.stringkey cross join bqt1.mediuma"; //$NON-NLS-1$
String output = "SELECT SmallA.IntKey FROM (SmallA INNER JOIN SmallB ON SmallA.StringKey = SmallB.StringKey) CROSS JOIN MediumA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input,
output, TRANSLATOR);
}
@@ -310,7 +310,7 @@
String input = "select smalla.intkey from bqt1.smalla where smalla.timestampvalue = '2009-08-06 12:23:34.999'"; //$NON-NLS-1$
String output = "SELECT SmallA.IntKey FROM SmallA WHERE SmallA.TimestampValue = {ts '2009-08-06 12:23:34.0'}"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input,
output, TRANSLATOR);
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -30,7 +30,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.jdbc.MetadataFactory;
+import org.teiid.connector.jdbc.TranslationHelper;
import org.teiid.connector.jdbc.translator.TranslatedCommand;
import org.teiid.connector.jdbc.translator.Translator;
import org.teiid.connector.language.ICommand;
@@ -101,7 +101,7 @@
String input = "select smalla.intkey from bqt1.smalla inner join bqt1.smallb on smalla.stringkey=smallb.stringkey cross join bqt1.mediuma"; //$NON-NLS-1$
String output = "SELECT SmallA.IntKey FROM SmallA INNER JOIN SmallB ON SmallA.StringKey = SmallB.StringKey CROSS JOIN MediumA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input,
output, TRANSLATOR);
}
@@ -110,7 +110,7 @@
String input = "select smalla.intkey from bqt1.smalla cross join (bqt1.smallb cross join bqt1.mediuma)"; //$NON-NLS-1$
String output = "SELECT SmallA.IntKey FROM SmallA CROSS JOIN (SmallB CROSS JOIN MediumA)"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input,
output, TRANSLATOR);
}
@@ -119,7 +119,7 @@
String input = "SELECT char(convert(STRINGNUM, integer) + 100) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT chr((trunc(to_number(SmallA.StringNum)) + 100)) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -128,7 +128,7 @@
String input = "SELECT convert(STRINGNUM, long) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT trunc(to_number(SmallA.StringNum)) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -137,7 +137,7 @@
String input = "SELECT convert(convert(STRINGNUM, long), string) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT to_char(trunc(to_number(SmallA.StringNum))) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -146,7 +146,7 @@
String input = "SELECT convert(convert(TIMESTAMPVALUE, date), string) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT to_char(trunc(cast(SmallA.TimestampValue AS date)), 'YYYY-MM-DD') FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -154,7 +154,7 @@
String input = "SELECT convert(convert(TIMEVALUE, timestamp), string) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT to_char(cast(SmallA.TimeValue AS timestamp), 'YYYY-MM-DD HH24:MI:SS.FF') FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -162,7 +162,7 @@
String input = "SELECT nvl(INTNUM, 'otherString') FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT nvl(to_char(SmallA.IntNum), 'otherString') FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -170,7 +170,7 @@
String input = "SELECT convert(convert(STRINGNUM, integer), string) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT to_char(trunc(to_number(SmallA.StringNum))) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -187,7 +187,7 @@
String input = "SELECT locate(INTNUM, 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT INSTR('chimp', to_char(SmallA.IntNum), 1) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -204,7 +204,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp') FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT INSTR('chimp', SmallA.StringNum) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -221,7 +221,7 @@
String input = "SELECT locate(INTNUM, '234567890', 1) FROM BQT1.SMALLA WHERE INTKEY = 26"; //$NON-NLS-1$
String output = "SELECT INSTR('234567890', to_char(SmallA.IntNum), 1) FROM SmallA WHERE SmallA.IntKey = 26"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -238,7 +238,7 @@
String input = "SELECT locate('c', 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT 1 FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -255,7 +255,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', -5) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT INSTR('chimp', SmallA.StringNum, 1) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -272,7 +272,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', INTNUM) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT INSTR('chimp', SmallA.StringNum, CASE WHEN SmallA.IntNum < 1 THEN 1 ELSE SmallA.IntNum END) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -289,7 +289,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', LOCATE(STRINGNUM, 'chimp') + 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT INSTR('chimp', SmallA.StringNum, CASE WHEN (INSTR('chimp', SmallA.StringNum) + 1) < 1 THEN 1 ELSE (INSTR('chimp', SmallA.StringNum) + 1) END) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -298,7 +298,7 @@
String input = "SELECT substring(StringNum, 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT substr(SmallA.StringNum, 1) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -306,7 +306,7 @@
String input = "SELECT substring(StringNum, 1, 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT substr(SmallA.StringNum, 1, 1) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -314,7 +314,7 @@
String input = "SELECT IntKey FROM BQT1.SMALLA UNION SELECT IntKey FROM BQT1.SMALLB ORDER BY IntKey"; //$NON-NLS-1$
String output = "SELECT SmallA.IntKey FROM SmallA UNION SELECT SmallB.IntKey FROM SmallB ORDER BY IntKey NULLS FIRST"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -322,7 +322,7 @@
String input = "select intkey from bqt1.smalla limit 10, 0"; //$NON-NLS-1$
String output = "SELECT * FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT SmallA.IntKey FROM SmallA) VIEW_FOR_LIMIT WHERE ROWNUM <= 10) WHERE ROWNUM_ > 10"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -330,7 +330,7 @@
String input = "select intkey from bqt1.smalla limit 0, 10"; //$NON-NLS-1$
String output = "SELECT * FROM (SELECT SmallA.IntKey FROM SmallA) WHERE ROWNUM <= 10"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -338,7 +338,7 @@
String input = "select intkey from bqt1.smalla limit 1, 10"; //$NON-NLS-1$
String output = "SELECT * FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT SmallA.IntKey FROM SmallA) VIEW_FOR_LIMIT WHERE ROWNUM <= 11) WHERE ROWNUM_ > 1"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -346,7 +346,7 @@
String input = "select intkey from bqt1.mediuma limit 100"; //$NON-NLS-1$
String output = "SELECT * FROM (SELECT MediumA.IntKey FROM MediumA) WHERE ROWNUM <= 100"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -354,7 +354,7 @@
String input = "select intkey from bqt1.mediuma limit 50, 100"; //$NON-NLS-1$
String output = "SELECT * FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT MediumA.IntKey FROM MediumA) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -362,7 +362,7 @@
@Test public void testConcat2_useLiteral() throws Exception {
String input = "select concat2(stringnum,'_xx') from bqt1.Smalla"; //$NON-NLS-1$
String output = "SELECT concat(nvl(SmallA.StringNum, ''), '_xx') FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -370,7 +370,7 @@
@Test public void testConcat2() throws Exception {
String input = "select concat2(stringnum, stringkey) from bqt1.Smalla"; //$NON-NLS-1$
String output = "SELECT CASE WHEN (SmallA.StringNum IS NULL) AND (SmallA.StringKey IS NULL) THEN NULL ELSE concat(nvl(SmallA.StringNum, ''), nvl(SmallA.StringKey, '')) END FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -386,7 +386,7 @@
String input = "SELECT a.INTKEY FROM BQT1.SMALLA A, BQT1.SMALLB B WHERE sdo_relate(A.OBJECTVALUE, b.OBJECTVALUE, 'mask=ANYINTERACT') = true"; //$NON-NLS-1$
String output = "SELECT /*+ ORDERED */ A.IntKey FROM SmallA A, SmallB B WHERE sdo_relate(A.ObjectValue, B.ObjectValue, 'mask=ANYINTERACT') = 'true'"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -402,7 +402,7 @@
String input = "SELECT INTKEY FROM BQT1.SMALLA WHERE sdo_within_distance(OBJECTVALUE, 'SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(90.0, -45.0, NULL), NULL, NULL)', 'DISTANCE=25.0 UNIT=NAUT_MILE') = true"; //$NON-NLS-1$
String output = "SELECT SmallA.IntKey FROM SmallA WHERE sdo_within_distance(SmallA.ObjectValue, SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(90.0, -45.0, NULL), NULL, NULL), 'DISTANCE=25.0 UNIT=NAUT_MILE') = 'true'"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -418,7 +418,7 @@
String input = "SELECT INTKEY FROM BQT1.SMALLA WHERE sdo_within_distance('SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(90.0, -45.0, NULL), NULL, NULL)', OBJECTVALUE, 'DISTANCE=25.0 UNIT=NAUT_MILE') = true"; //$NON-NLS-1$
String output = "SELECT SmallA.IntKey FROM SmallA WHERE sdo_within_distance(SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(90.0, -45.0, NULL), NULL, NULL), SmallA.ObjectValue, 'DISTANCE=25.0 UNIT=NAUT_MILE') = 'true'"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -439,7 +439,7 @@
// as the signature was the best match for this query.
String output = "SELECT SmallA.IntKey FROM SmallA WHERE sdo_within_distance(SmallA.StringKey, SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(90.0, -45.0, NULL), NULL, NULL), 'DISTANCE=25.0 UNIT=NAUT_MILE') = ?"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -460,7 +460,7 @@
// as the signature was the best match for this query.
String output = "SELECT SmallA.IntKey FROM SmallA WHERE sdo_within_distance(SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(90.0, -45.0, NULL), NULL, NULL), SDO_GEOMETRY(2001, 8307, MDSYS.SDO_POINT_TYPE(90.0, -45.0, NULL), NULL, NULL), 'DISTANCE=25.0 UNIT=NAUT_MILE') = ?"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -476,7 +476,7 @@
String input = "SELECT a.INTKEY FROM BQT1.SMALLA A, BQT1.SMALLB B WHERE sdo_within_distance(a.OBJECTVALUE, b.OBJECTVALUE, 'DISTANCE=25.0 UNIT=NAUT_MILE') = true"; //$NON-NLS-1$
String output = "SELECT A.IntKey FROM SmallA A, SmallB B WHERE sdo_within_distance(A.ObjectValue, B.ObjectValue, 'DISTANCE=25.0 UNIT=NAUT_MILE') = 'true'"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -485,7 +485,7 @@
String input = "SELECT log(CONVERT(stringkey, INTEGER)) FROM bqt1.smalla"; //$NON-NLS-1$
String output = "SELECT ln(trunc(to_number(SmallA.StringKey))) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -494,7 +494,7 @@
String input = "SELECT log10(CONVERT(stringkey, INTEGER)) FROM bqt1.smalla"; //$NON-NLS-1$
String output = "SELECT log(10, trunc(to_number(SmallA.StringKey))) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -503,7 +503,7 @@
String input = "SELECT char(CONVERT(stringkey, INTEGER)), lcase(stringkey), ucase(stringkey), ifnull(stringkey, 'x') FROM bqt1.smalla"; //$NON-NLS-1$
String output = "SELECT chr(trunc(to_number(SmallA.StringKey))), lower(SmallA.StringKey), upper(SmallA.StringKey), nvl(SmallA.StringKey, 'x') FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/postgresql/TestPostgreSQLTranslator.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -27,7 +27,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.jdbc.MetadataFactory;
+import org.teiid.connector.jdbc.TranslationHelper;
import com.metamatrix.cdk.api.EnvironmentUtility;
@@ -41,15 +41,15 @@
}
public String getTestVDB() {
- return MetadataFactory.PARTS_VDB;
+ return TranslationHelper.PARTS_VDB;
}
private String getTestBQTVDB() {
- return MetadataFactory.BQT_VDB;
+ return TranslationHelper.BQT_VDB;
}
public void helpTestVisitor(String vdb, String input, String expectedOutput) throws ConnectorException {
- MetadataFactory.helpTestVisitor(vdb, input, expectedOutput, TRANSLATOR);
+ TranslationHelper.helpTestVisitor(vdb, input, expectedOutput, TRANSLATOR);
}
@Test public void testConversion1() throws Exception {
@@ -414,7 +414,7 @@
String input = "SELECT locate(INTNUM, 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT position(cast(SmallA.IntNum AS varchar(4000)) in substr('chimp', 1)) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -431,7 +431,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp') FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT position(SmallA.StringNum in 'chimp') FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -448,7 +448,7 @@
String input = "SELECT locate(INTNUM, '234567890', 1) FROM BQT1.SMALLA WHERE INTKEY = 26"; //$NON-NLS-1$
String output = "SELECT position(cast(SmallA.IntNum AS varchar(4000)) in substr('234567890', 1)) FROM SmallA WHERE SmallA.IntKey = 26"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -465,7 +465,7 @@
String input = "SELECT locate('c', 'chimp', 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT 1 FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -482,7 +482,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', -5) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT position(SmallA.StringNum in substr('chimp', 1)) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -499,7 +499,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', INTNUM) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT position(SmallA.StringNum in substr('chimp', CASE WHEN SmallA.IntNum < 1 THEN 1 ELSE SmallA.IntNum END)) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
@@ -516,7 +516,7 @@
String input = "SELECT locate(STRINGNUM, 'chimp', LOCATE(STRINGNUM, 'chimp') + 1) FROM BQT1.SMALLA"; //$NON-NLS-1$
String output = "SELECT position(SmallA.StringNum in substr('chimp', CASE WHEN (position(SmallA.StringNum in 'chimp') + 1) < 1 THEN 1 ELSE (position(SmallA.StringNum in 'chimp') + 1) END)) FROM SmallA"; //$NON-NLS-1$
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB,
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
TRANSLATOR);
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -22,17 +22,23 @@
package org.teiid.connector.jdbc.sqlserver;
+import java.util.List;
import java.util.Properties;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.jdbc.MetadataFactory;
-import org.teiid.connector.jdbc.translator.TranslatedCommand;
+import org.teiid.connector.jdbc.TranslationHelper;
import org.teiid.connector.language.ICommand;
import com.metamatrix.cdk.api.EnvironmentUtility;
+import com.metamatrix.cdk.api.TranslationUtility;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.unittest.FakeMetadataFacade;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+import com.metamatrix.query.unittest.FakeMetadataObject;
+import com.metamatrix.query.unittest.FakeMetadataStore;
/**
*/
@@ -46,23 +52,16 @@
}
public String getTestVDB() {
- return MetadataFactory.PARTS_VDB;
+ return TranslationHelper.PARTS_VDB;
}
public String getBQTVDB() {
- return MetadataFactory.BQT_VDB;
+ return TranslationHelper.BQT_VDB;
}
public void helpTestVisitor(String vdb, String input, String expectedOutput) throws ConnectorException {
- helpTestVisitor(vdb, input, new String[] {expectedOutput});
+ TranslationHelper.helpTestVisitor(vdb, input, expectedOutput, trans);
}
-
- public void helpTestVisitor(String vdb, String input, String[] expectedOutputs) throws ConnectorException {
- ICommand obj = MetadataFactory.helpTranslate(vdb, input);
- TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), trans); //$NON-NLS-1$
- tc.translateCommand(obj);
- Assert.assertEquals("Did not get correct sql", expectedOutputs[0], tc.getSql()); //$NON-NLS-1$
- }
@Test
public void testModFunction() throws Exception {
@@ -132,5 +131,33 @@
input,
output);
}
+
+ @Test public void testUniqueidentifier() throws Exception {
+ FakeMetadataObject ldapModel = FakeMetadataFactory.createPhysicalModel("foo"); //$NON-NLS-1$
+ FakeMetadataObject table = FakeMetadataFactory.createPhysicalGroup("bar", ldapModel); //$NON-NLS-1$
+ String[] elemNames = new String[] {
+ "x" //$NON-NLS-1$
+ };
+ String[] elemTypes = new String[] {
+ DataTypeManager.DefaultDataTypes.STRING
+ };
+
+ List cols = FakeMetadataFactory.createElements(table, elemNames, elemTypes);
+
+ FakeMetadataObject obj = (FakeMetadataObject) cols.get(0);
+ obj.putProperty(FakeMetadataObject.Props.NATIVE_TYPE, "uniqueidentifier"); //$NON-NLS-1$
+
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(ldapModel);
+ store.addObject(table);
+ store.addObjects(cols);
+
+ // Create the facade from the store
+ QueryMetadataInterface metadata = new FakeMetadataFacade(store);
+
+ TranslationUtility tu = new TranslationUtility(metadata);
+ ICommand command = tu.parseCommand("select max(x) from bar"); //$NON-NLS-1$
+ TranslationHelper.helpTestVisitor("SELECT MAX(cast(bar.x as char(36))) FROM bar", trans, command); //$NON-NLS-1$
+ }
}
Modified: trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -29,7 +29,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.jdbc.MetadataFactory;
+import org.teiid.connector.jdbc.TranslationHelper;
import org.teiid.connector.jdbc.translator.TranslatedCommand;
import org.teiid.connector.language.ICommand;
@@ -47,16 +47,16 @@
}
public String getTestVDB() {
- return MetadataFactory.PARTS_VDB;
+ return TranslationHelper.PARTS_VDB;
}
public String getBQTVDB() {
- return MetadataFactory.BQT_VDB;
+ return TranslationHelper.BQT_VDB;
}
public void helpTestVisitor(String vdb, String input, String expectedOutput) {
// Convert from sql to objects
- ICommand obj = MetadataFactory.helpTranslate(vdb, input);
+ ICommand obj = TranslationHelper.helpTranslate(vdb, input);
TranslatedCommand tc = new TranslatedCommand(EnvironmentUtility.createSecurityContext("user"), trans); //$NON-NLS-1$
try {
Modified: trunk/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
===================================================================
--- trunk/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-11-11 21:17:34 UTC (rev 1548)
+++ trunk/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2009-11-12 19:47:07 UTC (rev 1549)
@@ -29,7 +29,7 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.jdbc.JDBCPropertyNames;
-import org.teiid.connector.jdbc.MetadataFactory;
+import org.teiid.connector.jdbc.TranslationHelper;
import org.teiid.connector.jdbc.translator.SQLConversionVisitor;
import org.teiid.connector.jdbc.translator.Translator;
import org.teiid.connector.language.ILanguageObject;
@@ -65,7 +65,7 @@
}
public String getTestVDB() {
- return MetadataFactory.PARTS_VDB;
+ return TranslationHelper.PARTS_VDB;
}
public void helpTestVisitor(String vdb, String input, String expectedOutput) {
@@ -81,7 +81,7 @@
}
trans.initialize(EnvironmentUtility.createEnvironment(p, false));
- MetadataFactory.helpTestVisitor(vdb, input, expectedOutput, trans);
+ TranslationHelper.helpTestVisitor(vdb, input, expectedOutput, trans);
} catch (ConnectorException e) {
throw new RuntimeException(e);
}
@@ -405,6 +405,6 @@
p.setProperty(JDBCPropertyNames.TRIM_STRINGS, Boolean.TRUE.toString());
trans.initialize(EnvironmentUtility.createEnvironment(p, false));
- MetadataFactory.helpTestVisitor(MetadataFactory.BQT_VDB, "select stringkey from bqt1.smalla", "SELECT rtrim(SmallA.StringKey) FROM SmallA", trans); //$NON-NLS-1$ //$NON-NLS-2$
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, "select stringkey from bqt1.smalla", "SELECT rtrim(SmallA.StringKey) FROM SmallA", trans); //$NON-NLS-1$ //$NON-NLS-2$
}
}
15 years, 1 month