teiid SVN: r1881 - in branches/JCA: client-jdbc/src/main/java/com/metamatrix/jdbc and 19 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-02-27 21:38:06 -0500 (Sat, 27 Feb 2010)
New Revision: 1881
Removed:
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SetClauseList.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
Modified:
branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ResultsFuture.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SearchedCase.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Update.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
branches/JCA/connector-sdk/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java
branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/Util.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
branches/JCA/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
branches/JCA/test-integration/pom.xml
Log:
TEIID-903 TEIID-851 TEIID-1003 fixing unit tests also removing setclauselist
Modified: branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ResultsFuture.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ResultsFuture.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/client/src/main/java/com/metamatrix/dqp/client/ResultsFuture.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -36,6 +36,12 @@
*/
public class ResultsFuture<T> implements Future<T> {
+ public static ResultsFuture<Void> NULL_FUTURE = new ResultsFuture<Void>();
+
+ static {
+ NULL_FUTURE.getResultsReceiver().receiveResults(null);
+ }
+
public interface CompletionListener<T> {
void onCompletion(ResultsFuture<T> future);
}
Modified: branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java
===================================================================
--- branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/client-jdbc/src/main/java/com/metamatrix/jdbc/MMStatement.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -22,7 +22,6 @@
package com.metamatrix.jdbc;
-import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
@@ -52,7 +51,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.MetaMatrixException;
import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.util.SqlUtil;
import com.metamatrix.core.util.ObjectConverterUtil;
import com.metamatrix.dqp.client.ClientSideDQP;
Modified: branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java
===================================================================
--- branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/client-jdbc/src/test/java/com/metamatrix/jdbc/TestMMConnection.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -22,23 +22,29 @@
package com.metamatrix.jdbc;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.stub;
+import static org.mockito.Mockito.*;
import java.sql.SQLException;
import java.util.Properties;
import junit.framework.TestCase;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
import com.metamatrix.common.comm.api.ServerConnection;
+import com.metamatrix.common.xa.MMXid;
+import com.metamatrix.common.xa.XATransactionException;
import com.metamatrix.dqp.client.ClientSideDQP;
+import com.metamatrix.dqp.client.ResultsFuture;
import com.metamatrix.platform.security.api.LogonResult;
import com.metamatrix.platform.security.api.SessionToken;
public class TestMMConnection extends TestCase {
protected static final String STD_DATABASE_NAME = "QT_Ora9DS"; //$NON-NLS-1$
- protected static final int STD_DATABASE_VERSION = 1; //$NON-NLS-1$
+ protected static final int STD_DATABASE_VERSION = 1;
static String serverUrl = "jdbc:metamatrix:QT_Ora9DS@mm://localhost:7001;version=1;user=metamatrixadmin;password=mm"; //$NON-NLS-1$
@@ -48,7 +54,30 @@
public static MMConnection getMMConnection() {
ServerConnection mock = mock(ServerConnection.class);
- stub(mock.getService(ClientSideDQP.class)).toReturn(mock(ClientSideDQP.class));
+ ClientSideDQP dqp = mock(ClientSideDQP.class);
+ try {
+ stub(dqp.start((MMXid)Mockito.anyObject(), Mockito.anyInt(), Mockito.anyInt())).toAnswer(new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ return ResultsFuture.NULL_FUTURE;
+ }
+ });
+ stub(dqp.rollback((MMXid)Mockito.anyObject())).toAnswer(new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ return ResultsFuture.NULL_FUTURE;
+ }
+ });
+ stub(dqp.rollback()).toAnswer(new Answer() {
+ @Override
+ public Object answer(InvocationOnMock invocation) throws Throwable {
+ return ResultsFuture.NULL_FUTURE;
+ }
+ });
+ } catch (XATransactionException e) {
+ throw new RuntimeException(e);
+ }
+ stub(mock.getService(ClientSideDQP.class)).toReturn(dqp);
Properties props = new Properties();
props.setProperty(BaseDataSource.VDB_NAME, STD_DATABASE_NAME);
props.setProperty(BaseDataSource.VDB_VERSION, String.valueOf(STD_DATABASE_VERSION));
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -178,7 +178,7 @@
return new SubqueryIn(expression, isNegated, subquery);
}
- public Update createUpdate(NamedTable group, SetClauseList updates, Condition criteria) {
+ public Update createUpdate(NamedTable group, List<SetClause> updates, Condition criteria) {
return new Update(group, updates, criteria);
}
@@ -201,7 +201,4 @@
return new SetClause(symbol, value);
}
- public SetClauseList createSetClauseList(List<SetClause> clauses) {
- return new SetClauseList(clauses);
- }
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SearchedCase.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SearchedCase.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SearchedCase.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -31,7 +31,7 @@
* <br/> CASE WHEN criteria THEN expression ... END
*/
public class SearchedCase extends BaseLanguageObject implements Expression {
-
+
private List<Condition> whenConditions;
private List<Expression> thenExpressions;
private Expression elseExpression;
Deleted: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SetClauseList.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SetClauseList.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SetClauseList.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -1,51 +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.language;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-
-public class SetClauseList extends BaseLanguageObject {
-
- private List<SetClause> clauses;
-
- public SetClauseList(List<SetClause> clauses) {
- if (clauses == null) {
- clauses = new ArrayList<SetClause>();
- }
- this.clauses = clauses;
- }
-
- public List<SetClause> getClauses() {
- return clauses;
- }
-
- @Override
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
-}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Update.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Update.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Update.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -22,6 +22,8 @@
package org.teiid.connector.language;
+import java.util.List;
+
import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
/**
@@ -30,10 +32,10 @@
public class Update extends BaseLanguageObject implements Command {
private NamedTable table;
- private SetClauseList changes;
+ private List<SetClause> changes;
private Condition where;
- public Update(NamedTable group, SetClauseList changes, Condition criteria) {
+ public Update(NamedTable group, List<SetClause> changes, Condition criteria) {
this.table = group;
this.changes = changes;
this.where = criteria;
@@ -43,7 +45,7 @@
return table;
}
- public SetClauseList getChanges() {
+ public List<SetClause> getChanges() {
return changes;
}
@@ -59,7 +61,7 @@
this.table = group;
}
- public void setChanges(SetClauseList changes) {
+ public void setChanges(List<SetClause> changes) {
this.changes = changes;
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -49,11 +49,10 @@
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.SetClause;
-import org.teiid.connector.language.SetClauseList;
import org.teiid.connector.language.SetQuery;
import org.teiid.connector.language.SortSpecification;
import org.teiid.connector.language.SubqueryComparison;
@@ -144,6 +143,5 @@
public void visit(SubqueryIn obj) {}
public void visit(Update obj) {}
public void visit(SetQuery obj) {}
- public void visit(SetClauseList obj) {}
public void visit(SetClause obj) {}
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -47,11 +47,10 @@
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.SetClause;
-import org.teiid.connector.language.SetClauseList;
import org.teiid.connector.language.SetQuery;
import org.teiid.connector.language.SortSpecification;
import org.teiid.connector.language.SubqueryComparison;
@@ -375,18 +374,6 @@
}
@Override
- public void visit(SetClauseList obj) {
- if (preVisitor != null) {
- preVisitor.visit(obj);
- }
- super.visit(obj);
- if (postVisitor != null) {
- postVisitor.visit(obj);
- }
-
- }
-
- @Override
public void visit(SetClause obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -42,11 +42,10 @@
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.SetClause;
-import org.teiid.connector.language.SetClauseList;
import org.teiid.connector.language.SetQuery;
import org.teiid.connector.language.SubqueryComparison;
import org.teiid.connector.language.SubqueryIn;
@@ -210,7 +209,7 @@
public void visit(Update obj) {
visitNode(obj.getTable());
- visitNode(obj.getChanges());
+ visitNodes(obj.getChanges());
visitNode(obj.getWhere());
}
@@ -222,11 +221,6 @@
}
@Override
- public void visit(SetClauseList obj) {
- visitNodes(obj.getClauses());
- }
-
- @Override
public void visit(SetClause obj) {
visitNode(obj.getSymbol());
visitNode(obj.getValue());
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -59,6 +59,5 @@
public void visit(SubqueryIn obj);
public void visit(Update obj);
public void visit(SetQuery obj);
- public void visit(SetClauseList obj);
public void visit(SetClause obj);
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -52,11 +52,10 @@
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.SetClause;
-import org.teiid.connector.language.SetClauseList;
import org.teiid.connector.language.SetQuery;
import org.teiid.connector.language.SortSpecification;
import org.teiid.connector.language.SubqueryComparison;
@@ -220,11 +219,6 @@
}
@Override
- public void visit(SetClauseList obj) {
- checkInstance(obj);
- }
-
- @Override
public void visit(SetClause obj) {
checkInstance(obj);
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -55,11 +55,10 @@
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.SetClause;
-import org.teiid.connector.language.SetClauseList;
import org.teiid.connector.language.SetQuery;
import org.teiid.connector.language.SortSpecification;
import org.teiid.connector.language.SubqueryComparison;
@@ -819,10 +818,6 @@
}
}
- public void visit(SetClauseList obj) {
- append(obj.getClauses());
- }
-
public void visit(SetClause clause) {
buffer.append(getElementName(clause.getSymbol(), false));
buffer.append(SQLReservedWords.SPACE).append(SQLReservedWords.EQ).append(SQLReservedWords.SPACE);
Modified: branches/JCA/connector-sdk/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java
===================================================================
--- branches/JCA/connector-sdk/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connector-sdk/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -24,7 +24,6 @@
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.validator.TestValidator;
public class FakeTranslationFactory {
@@ -42,14 +41,6 @@
return new TranslationUtility(FakeMetadataFactory.exampleYahoo());
}
- public TranslationUtility getTextTranslationUtility() {
- return new TranslationUtility(FakeMetadataFactory.exampleText());
- }
-
- public TranslationUtility getAutoIncrementTranslationUtility() {
- return new TranslationUtility(TestValidator.exampleMetadata3());
- }
-
public TranslationUtility getExampleTranslationUtility() {
return new TranslationUtility(FakeMetadataFactory.example1Cached());
}
Deleted: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleSQLConversionVisitor.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -1,355 +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.oracle;
-
-import static org.junit.Assert.*;
-
-import java.util.Properties;
-
-import org.junit.Test;
-import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.jdbc.JDBCManagedConnectionFactory;
-import org.teiid.connector.jdbc.JDBCPropertyNames;
-import org.teiid.connector.jdbc.translator.TranslatedCommand;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
-import org.teiid.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
-import org.teiid.metadata.CompositeMetadataStore;
-import org.teiid.metadata.TransformationMetadata;
-
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.RealMetadataFactory;
-
-public class TestOracleSQLConversionVisitor {
- private static ExecutionContext EMPTY_CONTEXT = new FakeExecutionContextImpl();
-
- private String getTestVDB() {
- return UnitTestUtil.getTestDataPath() + "/PartsSupplierOracle.vdb"; //$NON-NLS-1$
- }
-
- private void helpTestVisitor(String vdb, String input, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
- helpTestVisitor(vdb, input, EMPTY_CONTEXT, dbmsTimeZone, expectedOutput, false);
- }
-
- private void helpTestVisitor(String vdb, String input, String dbmsTimeZone, String expectedOutput, boolean correctNaming) throws ConnectorException {
- helpTestVisitor(vdb, input, EMPTY_CONTEXT, dbmsTimeZone, expectedOutput, correctNaming);
- }
-
- private void helpTestVisitor(String vdb, String input, ExecutionContext context, String dbmsTimeZone, String expectedOutput, boolean correctNaming) throws ConnectorException {
- // Convert from sql to objects
- TranslationUtility util = new TranslationUtility(vdb);
- Command obj = util.parseCommand(input, correctNaming, true);
- this.helpTestVisitor(obj, context, dbmsTimeZone, expectedOutput);
- }
-
- /** Helper method takes a QueryMetadataInterface impl instead of a VDB filename
- * @throws ConnectorException
- */
- private void helpTestVisitor(QueryMetadataInterface metadata, String input, ExecutionContext context, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
- // Convert from sql to objects
- CommandBuilder commandBuilder = new CommandBuilder(metadata);
- Command obj = commandBuilder.getCommand(input);
- this.helpTestVisitor(obj, context, dbmsTimeZone, expectedOutput);
- }
-
- private void helpTestVisitor(Command obj, ExecutionContext context, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
-
-
- // Apply function replacement
- OracleSQLTranslator translator = new OracleSQLTranslator();
- Properties p = new Properties();
- if (dbmsTimeZone != null) {
- p.setProperty(JDBCPropertyNames.DATABASE_TIME_ZONE, dbmsTimeZone);
- }
- translator.initialize(new JDBCManagedConnectionFactory());
- // Convert back to SQL
- TranslatedCommand tc = new TranslatedCommand(context, translator);
- tc.translateCommand(obj);
-
- // Check stuff
- assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
- }
-
- /** defect 21775 */
- @Test public void testDateStuff() throws Exception {
- String input = "SELECT ((CASE WHEN month(datevalue) < 10 THEN ('0' || convert(month(datevalue), string)) ELSE convert(month(datevalue), string) END || CASE WHEN dayofmonth(datevalue) < 10 THEN ('0' || convert(dayofmonth(datevalue), string)) ELSE convert(dayofmonth(datevalue), string) END) || convert(year(datevalue), string)), SUM(intkey) FROM bqt1.SMALLA GROUP BY datevalue"; //$NON-NLS-1$
- String output = "SELECT CASE WHEN CASE WHEN CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL OR CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END IS NULL THEN NULL ELSE concat(CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END, CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('!
0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END) END IS NULL OR to_char(EXTRACT(YEAR FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat(CASE WHEN CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL OR CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END IS NULL THEN NULL ELSE concat(CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.Da!
teValue)) END, CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < !
10 THEN
CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END) END, to_char(EXTRACT(YEAR FROM SmallA.DateValue))) END, SUM(SmallA.IntKey) FROM SmallA GROUP BY SmallA.DateValue"; //$NON-NLS-1$
-
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
- input,
- EMPTY_CONTEXT, null, output);
- }
-
- @Test public void testAliasedGroup() throws Exception {
- helpTestVisitor(getTestVDB(),
- "select y.part_name from parts as y", //$NON-NLS-1$
- null,
- "SELECT y.PART_NAME FROM PARTS y"); //$NON-NLS-1$
- }
-
- @Test public void testDateLiteral() throws Exception {
- helpTestVisitor(getTestVDB(),
- "select {d '2002-12-31'} FROM parts", //$NON-NLS-1$
- null,
- "SELECT {d '2002-12-31'} FROM PARTS"); //$NON-NLS-1$
- }
-
- @Test public void testTimeLiteral() throws Exception {
- helpTestVisitor(getTestVDB(),
- "select {t '13:59:59'} FROM parts", //$NON-NLS-1$
- null,
- "SELECT {ts '1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
- }
-
- @Test public void testTimestampLiteral() throws Exception {
- helpTestVisitor(getTestVDB(),
- "select {ts '2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
- null,
- "SELECT {ts '2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
- }
-
- @Test public void testUnionOrderByWithThreeBranches() throws Exception {
- helpTestVisitor(getTestVDB(),
- "select part_id id FROM parts UNION ALL select part_name FROM parts UNION ALL select part_id FROM parts ORDER BY id", //$NON-NLS-1$
- null,
- "SELECT g_2.PART_ID AS c_0 FROM PARTS g_2 UNION ALL SELECT g_1.PART_NAME AS c_0 FROM PARTS g_1 UNION ALL SELECT g_0.PART_ID AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
- true);
- }
-
- @Test public void testUnionOrderBy() throws Exception {
- helpTestVisitor(getTestVDB(),
- "select part_id FROM parts UNION ALL select part_name FROM parts ORDER BY part_id", //$NON-NLS-1$
- null,
- "SELECT g_1.PART_ID AS c_0 FROM PARTS g_1 UNION ALL SELECT g_0.PART_NAME AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
- true);
- }
-
- @Test public void testUnionOrderBy2() throws Exception {
- helpTestVisitor(getTestVDB(),
- "select part_id as p FROM parts UNION ALL select part_name FROM parts ORDER BY p", //$NON-NLS-1$
- null,
- "SELECT PARTS.PART_ID AS p FROM PARTS UNION ALL SELECT PARTS.PART_NAME FROM PARTS ORDER BY p NULLS FIRST"); //$NON-NLS-1$
- }
-
- @Test public void testUpdateWithFunction() throws Exception {
- String input = "UPDATE bqt1.smalla SET intkey = intkey + 1"; //$NON-NLS-1$
- String output = "UPDATE SmallA SET IntKey = (SmallA.IntKey + 1)"; //$NON-NLS-1$
-
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
- input,
- EMPTY_CONTEXT, null, output);
- }
-
-
- /**
- * Oracle's DUAL table is a pseudo-table; element names cannot be
- * fully qualified since the table doesn't really exist nor contain
- * any columns. But this requires modeling the DUAL table in
- * MM as if it were a real physical table, and also modeling any
- * columns in the table. Case 3742
- *
- * @since 4.3
- */
- @Test public void testDUAL() throws Exception {
- String input = "SELECT something FROM DUAL"; //$NON-NLS-1$
- String output = "SELECT something FROM DUAL"; //$NON-NLS-1$
-
- helpTestVisitor(getOracleSpecificMetadata(),
- input,
- EMPTY_CONTEXT,
- null,
- output);
- }
-
- /**
- * Test Oracle's rownum pseudo-column. Not a real column, so it can't
- * be fully-qualified with a table name. MM requires this column to be
- * modeled in any table which the user wants to use rownum with.
- * Case 3739
- *
- * @since 4.3
- */
- @Test public void testROWNUM() throws Exception {
- String input = "SELECT part_name, rownum FROM parts"; //$NON-NLS-1$
- String output = "SELECT PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- null,
- output);
- }
-
- /**
- * Test Oracle's rownum pseudo-column. Not a real column, so it can't
- * be fully-qualified with a table name. MM requires this column to be
- * modeled in any table which the user wants to use rownum with. Case 3739
- *
- * @since 4.3
- */
- @Test public void testROWNUM2() throws Exception {
- String input = "SELECT part_name FROM parts where rownum < 100"; //$NON-NLS-1$
- String output = "SELECT PARTS.PART_NAME FROM PARTS WHERE ROWNUM < 100"; //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- null,
- output); }
-
- /**
- * Case 3744. Test that an Oracle-specific db hint, delivered as a String via command
- * payload, is added to the translated SQL.
- *
- * @since 4.3
- */
- @Test public void testOracleCommentPayload() throws Exception {
- String input = "SELECT part_name, rownum FROM parts"; //$NON-NLS-1$
- String output = "SELECT /*+ ALL_ROWS */ PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
-
- String hint = "/*+ ALL_ROWS */"; //$NON-NLS-1$
- ExecutionContext context = new ExecutionContextImpl(null, 1, hint, null, "", null, null, null); //$NON-NLS-1$
-
- helpTestVisitor(getTestVDB(),
- input,
- context,
- null,
- output,
- false);
- }
-
- /**
- * reproducing this case relies on the name in source for the table being different from
- * the name
- */
- @Test public void testCase3845() throws Exception {
-
- String input = "SELECT (DoubleNum * 1.0) FROM BQT1.Smalla"; //$NON-NLS-1$
- String output = "SELECT (SmallishA.DoubleNum * 1.0) FROM SmallishA"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = getOracleSpecificMetadata();
-
- helpTestVisitor(metadata, input, EMPTY_CONTEXT, null, output);
- }
-
- /** create fake BQT metadata to test this case, name in source is important */
- private QueryMetadataInterface getOracleSpecificMetadata() {
- MetadataStore metadataStore = new MetadataStore();
- Schema foo = RealMetadataFactory.createPhysicalModel("BQT1", metadataStore); //$NON-NLS-1$
- Table table = RealMetadataFactory.createPhysicalGroup("SmallA", foo); //$NON-NLS-1$
- Table dual = RealMetadataFactory.createPhysicalGroup("DUAL", foo); //$NON-NLS-1$
- table.setNameInSource("SmallishA");//$NON-NLS-1$
- String[] elemNames = new String[] {
- "DoubleNum", //$NON-NLS-1$
- };
- String[] elemTypes = new String[] {
- DataTypeManager.DefaultDataTypes.DOUBLE,
- };
- RealMetadataFactory.createElements(table, elemNames, elemTypes);
- RealMetadataFactory.createElements(dual, new String[] {"something"}, new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
-
- CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
- return new TransformationMetadata(null, store, null, null);
- }
-
- public void helpTestVisitor(String vdb, String input, String expectedOutput) throws ConnectorException {
- helpTestVisitor(vdb, input, null, expectedOutput);
- }
-
- @Test public void testRowLimit2() throws Exception {
- String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
- String output = "SELECT * FROM (SELECT SmallA.IntKey FROM SmallA) WHERE ROWNUM <= 100"; //$NON-NLS-1$
-
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
- input,
- EMPTY_CONTEXT, null, output);
- }
-
- @Test public void testRowLimit3() throws Exception {
- String input = "select intkey from bqt1.smalla limit 50, 100"; //$NON-NLS-1$
- String output = "SELECT * FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT SmallA.IntKey FROM SmallA) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50"; //$NON-NLS-1$
-
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
- input,
- EMPTY_CONTEXT, null, output);
- }
-
- @Test public void testLimitWithNestedInlineView() throws Exception {
- String input = "select max(intkey), stringkey from (select intkey, stringkey from bqt1.smalla order by intkey limit 100) x group by stringkey"; //$NON-NLS-1$
- String output = "SELECT MAX(x.intkey), x.stringkey FROM (SELECT * FROM (SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY intkey NULLS FIRST) WHERE ROWNUM <= 100) x GROUP BY x.stringkey"; //$NON-NLS-1$
-
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
- input,
- EMPTY_CONTEXT, null, output);
- }
-
- @Test public void testExceptAsMinus() throws Exception {
- String input = "select intkey, intnum from bqt1.smalla except select intnum, intkey from bqt1.smallb"; //$NON-NLS-1$
- String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA MINUS SELECT SmallB.IntNum, SmallB.IntKey FROM SmallB"; //$NON-NLS-1$
-
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
- input,
- EMPTY_CONTEXT, null, output);
- }
-
- @Test public void testConcat2_useLiteral() throws Exception {
- String sql = "select concat2(stringnum,'_xx') from BQT1.Smalla"; //$NON-NLS-1$
- String expected = "SELECT concat(nvl(SmallA.StringNum, ''), '_xx') FROM SmallA"; //$NON-NLS-1$
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
- }
-
- @Test public void testConcat2() throws Exception {
- String sql = "select concat2(stringnum, stringnum) from BQT1.Smalla"; //$NON-NLS-1$
- String expected = "SELECT CASE WHEN SmallA.StringNum IS NULL THEN NULL ELSE concat(nvl(SmallA.StringNum, ''), nvl(SmallA.StringNum, '')) END FROM SmallA"; //$NON-NLS-1$
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
- }
-
- @Test public void testConcat() throws Exception {
- String sql = "select concat(stringnum, stringkey) from BQT1.Smalla"; //$NON-NLS-1$
- String expected = "SELECT CASE WHEN SmallA.StringNum IS NULL OR SmallA.StringKey IS NULL THEN NULL ELSE concat(SmallA.StringNum, SmallA.StringKey) END FROM SmallA"; //$NON-NLS-1$
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
- }
-
- @Test public void testConcat_withLiteral() throws Exception {
- String sql = "select stringnum || '1' from BQT1.Smalla"; //$NON-NLS-1$
- String expected = "SELECT CASE WHEN SmallA.StringNum IS NULL THEN NULL ELSE concat(SmallA.StringNum, '1') END FROM SmallA"; //$NON-NLS-1$
- helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
- }
-
- @Test public void testRowLimitWithUnionOrderBy() throws Exception {
- String input = "(select intkey from bqt1.smalla limit 50, 100) union select intnum from bqt1.smalla order by intkey"; //$NON-NLS-1$
- String output = "SELECT c_0 FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT g_1.IntKey AS c_0 FROM SmallA g_1) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50 UNION SELECT g_0.IntNum AS c_0 FROM SmallA g_0 ORDER BY c_0 NULLS FIRST"; //$NON-NLS-1$
-
- CommandBuilder commandBuilder = new CommandBuilder(FakeMetadataFactory.exampleBQTCached());
- Command obj = commandBuilder.getCommand(input, true, true);
- this.helpTestVisitor(obj, EMPTY_CONTEXT, null, output);
- }
-
-}
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/oracle/TestOracleTranslator.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -22,18 +22,37 @@
package org.teiid.connector.jdbc.oracle;
+import static org.junit.Assert.*;
+
+import java.util.List;
+import java.util.Properties;
+
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mockito;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.jdbc.JDBCManagedConnectionFactory;
+import org.teiid.connector.jdbc.JDBCPropertyNames;
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.Command;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.connector.metadata.runtime.Schema;
+import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
+import org.teiid.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
+import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.TransformationMetadata;
-import com.metamatrix.cdk.unittest.FakeTranslationFactory;
+import com.metamatrix.cdk.CommandBuilder;
+import com.metamatrix.cdk.api.TranslationUtility;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.core.util.UnitTestUtil;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.unittest.FakeMetadataFactory;
+import com.metamatrix.query.unittest.RealMetadataFactory;
public class TestOracleTranslator {
@@ -42,6 +61,7 @@
*/
private Translator TRANSLATOR;
private String UDF = "/OracleSpatialFunctions.xmi"; //$NON-NLS-1$;
+ private static ExecutionContext EMPTY_CONTEXT = new FakeExecutionContextImpl();
@Before
public void setup() throws Exception {
@@ -50,22 +70,15 @@
}
private void helpTestVisitor(String input, String expectedOutput) throws ConnectorException {
- // Convert from sql to objects
- Command obj = FakeTranslationFactory.getInstance().getAutoIncrementTranslationUtility().parseCommand(input);
-
- TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), TRANSLATOR);
- tc.translateCommand(obj);
-
- // Check stuff
- org.junit.Assert.assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
+ helpTestVisitor(getOracleSpecificMetadata(), input, EMPTY_CONTEXT, null, expectedOutput);
}
@Test public void testInsertWithSequnce() throws Exception {
- helpTestVisitor("insert into test.group (e0) values (1)", "INSERT INTO group (e0, e1) VALUES (1, MYSEQUENCE.nextVal)"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestVisitor("insert into smalla (doublenum) values (1)", "INSERT INTO SmallishA (DoubleNum, ID) VALUES (1.0, MYSEQUENCE.nextVal)"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testInsertWithSequnce1() throws Exception {
- helpTestVisitor("insert into test.group (e0, e1) values (1, 'x')", "INSERT INTO group (e0, e1) VALUES (1, 'x')"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestVisitor("insert into smalla (doublenum, id) values (1, 1)", "INSERT INTO SmallishA (DoubleNum, ID) VALUES (1.0, 1)"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testJoins() throws Exception {
@@ -478,5 +491,276 @@
input, output,
TRANSLATOR);
}
+
+ private String getTestVDB() {
+ return UnitTestUtil.getTestDataPath() + "/PartsSupplierOracle.vdb"; //$NON-NLS-1$
+ }
+
+ private void helpTestVisitor(String vdb, String input, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
+ helpTestVisitor(vdb, input, EMPTY_CONTEXT, dbmsTimeZone, expectedOutput, false);
+ }
+ private void helpTestVisitor(String vdb, String input, String dbmsTimeZone, String expectedOutput, boolean correctNaming) throws ConnectorException {
+ helpTestVisitor(vdb, input, EMPTY_CONTEXT, dbmsTimeZone, expectedOutput, correctNaming);
+ }
+
+ private void helpTestVisitor(String vdb, String input, ExecutionContext context, String dbmsTimeZone, String expectedOutput, boolean correctNaming) throws ConnectorException {
+ // Convert from sql to objects
+ TranslationUtility util = new TranslationUtility(vdb);
+ Command obj = util.parseCommand(input, correctNaming, true);
+ this.helpTestVisitor(obj, context, dbmsTimeZone, expectedOutput);
+ }
+
+ /** Helper method takes a QueryMetadataInterface impl instead of a VDB filename
+ * @throws ConnectorException
+ */
+ private void helpTestVisitor(QueryMetadataInterface metadata, String input, ExecutionContext context, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
+ // Convert from sql to objects
+ CommandBuilder commandBuilder = new CommandBuilder(metadata);
+ Command obj = commandBuilder.getCommand(input);
+ this.helpTestVisitor(obj, context, dbmsTimeZone, expectedOutput);
+ }
+
+ private void helpTestVisitor(Command obj, ExecutionContext context, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
+ OracleSQLTranslator translator = new OracleSQLTranslator();
+ Properties p = new Properties();
+ if (dbmsTimeZone != null) {
+ p.setProperty(JDBCPropertyNames.DATABASE_TIME_ZONE, dbmsTimeZone);
+ }
+ translator.initialize(new JDBCManagedConnectionFactory());
+ // Convert back to SQL
+ TranslatedCommand tc = new TranslatedCommand(context, translator);
+ tc.translateCommand(obj);
+
+ // Check stuff
+ assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
+ }
+
+ /** defect 21775 */
+ @Test public void testDateStuff() throws Exception {
+ String input = "SELECT ((CASE WHEN month(datevalue) < 10 THEN ('0' || convert(month(datevalue), string)) ELSE convert(month(datevalue), string) END || CASE WHEN dayofmonth(datevalue) < 10 THEN ('0' || convert(dayofmonth(datevalue), string)) ELSE convert(dayofmonth(datevalue), string) END) || convert(year(datevalue), string)), SUM(intkey) FROM bqt1.SMALLA GROUP BY datevalue"; //$NON-NLS-1$
+ String output = "SELECT CASE WHEN CASE WHEN CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL OR CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END IS NULL THEN NULL ELSE concat(CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END, CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('!
0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END) END IS NULL OR to_char(EXTRACT(YEAR FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat(CASE WHEN CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.DateValue)) END IS NULL OR CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END IS NULL THEN NULL ELSE concat(CASE WHEN EXTRACT(MONTH FROM SmallA.DateValue) < 10 THEN CASE WHEN to_char(EXTRACT(MONTH FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(MONTH FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(MONTH FROM SmallA.Da!
teValue)) END, CASE WHEN EXTRACT(DAY FROM SmallA.DateValue) < !
10 THEN
CASE WHEN to_char(EXTRACT(DAY FROM SmallA.DateValue)) IS NULL THEN NULL ELSE concat('0', to_char(EXTRACT(DAY FROM SmallA.DateValue))) END ELSE to_char(EXTRACT(DAY FROM SmallA.DateValue)) END) END, to_char(EXTRACT(YEAR FROM SmallA.DateValue))) END, SUM(SmallA.IntKey) FROM SmallA GROUP BY SmallA.DateValue"; //$NON-NLS-1$
+
+ helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
+ input,
+ EMPTY_CONTEXT, null, output);
+ }
+
+ @Test public void testAliasedGroup() throws Exception {
+ helpTestVisitor(getTestVDB(),
+ "select y.part_name from parts as y", //$NON-NLS-1$
+ null,
+ "SELECT y.PART_NAME FROM PARTS y"); //$NON-NLS-1$
+ }
+
+ @Test public void testDateLiteral() throws Exception {
+ helpTestVisitor(getTestVDB(),
+ "select {d '2002-12-31'} FROM parts", //$NON-NLS-1$
+ null,
+ "SELECT {d '2002-12-31'} FROM PARTS"); //$NON-NLS-1$
+ }
+
+ @Test public void testTimeLiteral() throws Exception {
+ helpTestVisitor(getTestVDB(),
+ "select {t '13:59:59'} FROM parts", //$NON-NLS-1$
+ null,
+ "SELECT {ts '1970-01-01 13:59:59'} FROM PARTS"); //$NON-NLS-1$
+ }
+
+ @Test public void testTimestampLiteral() throws Exception {
+ helpTestVisitor(getTestVDB(),
+ "select {ts '2002-12-31 13:59:59'} FROM parts", //$NON-NLS-1$
+ null,
+ "SELECT {ts '2002-12-31 13:59:59.0'} FROM PARTS"); //$NON-NLS-1$
+ }
+
+ @Test public void testUnionOrderByWithThreeBranches() throws Exception {
+ helpTestVisitor(getTestVDB(),
+ "select part_id id FROM parts UNION ALL select part_name FROM parts UNION ALL select part_id FROM parts ORDER BY id", //$NON-NLS-1$
+ null,
+ "SELECT g_2.PART_ID AS c_0 FROM PARTS g_2 UNION ALL SELECT g_1.PART_NAME AS c_0 FROM PARTS g_1 UNION ALL SELECT g_0.PART_ID AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
+ true);
+ }
+
+ @Test public void testUnionOrderBy() throws Exception {
+ helpTestVisitor(getTestVDB(),
+ "select part_id FROM parts UNION ALL select part_name FROM parts ORDER BY part_id", //$NON-NLS-1$
+ null,
+ "SELECT g_1.PART_ID AS c_0 FROM PARTS g_1 UNION ALL SELECT g_0.PART_NAME AS c_0 FROM PARTS g_0 ORDER BY c_0 NULLS FIRST", //$NON-NLS-1$
+ true);
+ }
+
+ @Test public void testUnionOrderBy2() throws Exception {
+ helpTestVisitor(getTestVDB(),
+ "select part_id as p FROM parts UNION ALL select part_name FROM parts ORDER BY p", //$NON-NLS-1$
+ null,
+ "SELECT PARTS.PART_ID AS p FROM PARTS UNION ALL SELECT PARTS.PART_NAME FROM PARTS ORDER BY p NULLS FIRST"); //$NON-NLS-1$
+ }
+
+ @Test public void testUpdateWithFunction() throws Exception {
+ String input = "UPDATE bqt1.smalla SET intkey = intkey + 1"; //$NON-NLS-1$
+ String output = "UPDATE SmallA SET IntKey = (SmallA.IntKey + 1)"; //$NON-NLS-1$
+
+ helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
+ input,
+ EMPTY_CONTEXT, null, output);
+ }
+
+
+ /**
+ * Oracle's DUAL table is a pseudo-table; element names cannot be
+ * fully qualified since the table doesn't really exist nor contain
+ * any columns. But this requires modeling the DUAL table in
+ * MM as if it were a real physical table, and also modeling any
+ * columns in the table. Case 3742
+ *
+ * @since 4.3
+ */
+ @Test public void testDUAL() throws Exception {
+ String input = "SELECT something FROM DUAL"; //$NON-NLS-1$
+ String output = "SELECT something FROM DUAL"; //$NON-NLS-1$
+
+ helpTestVisitor(getOracleSpecificMetadata(),
+ input,
+ EMPTY_CONTEXT,
+ null,
+ output);
+ }
+
+ /**
+ * Test Oracle's rownum pseudo-column. Not a real column, so it can't
+ * be fully-qualified with a table name. MM requires this column to be
+ * modeled in any table which the user wants to use rownum with.
+ * Case 3739
+ *
+ * @since 4.3
+ */
+ @Test public void testROWNUM() throws Exception {
+ String input = "SELECT part_name, rownum FROM parts"; //$NON-NLS-1$
+ String output = "SELECT PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
+
+ helpTestVisitor(getTestVDB(),
+ input,
+ null,
+ output);
+ }
+
+ /**
+ * Test Oracle's rownum pseudo-column. Not a real column, so it can't
+ * be fully-qualified with a table name. MM requires this column to be
+ * modeled in any table which the user wants to use rownum with. Case 3739
+ *
+ * @since 4.3
+ */
+ @Test public void testROWNUM2() throws Exception {
+ String input = "SELECT part_name FROM parts where rownum < 100"; //$NON-NLS-1$
+ String output = "SELECT PARTS.PART_NAME FROM PARTS WHERE ROWNUM < 100"; //$NON-NLS-1$
+
+ helpTestVisitor(getTestVDB(),
+ input,
+ null,
+ output); }
+
+ /**
+ * Case 3744. Test that an Oracle-specific db hint, delivered as a String via command
+ * payload, is added to the translated SQL.
+ *
+ * @since 4.3
+ */
+ @Test public void testOracleCommentPayload() throws Exception {
+ String input = "SELECT part_name, rownum FROM parts"; //$NON-NLS-1$
+ String output = "SELECT /*+ ALL_ROWS */ PARTS.PART_NAME, ROWNUM FROM PARTS"; //$NON-NLS-1$
+
+ String hint = "/*+ ALL_ROWS */"; //$NON-NLS-1$
+ ExecutionContext context = new ExecutionContextImpl(null, 1, hint, null, "", null, null, null); //$NON-NLS-1$
+
+ helpTestVisitor(getTestVDB(),
+ input,
+ context,
+ null,
+ output,
+ false);
+ }
+
+ /**
+ * reproducing this case relies on the name in source for the table being different from
+ * the name
+ */
+ @Test public void testCase3845() throws Exception {
+
+ String input = "SELECT (DoubleNum * 1.0) FROM BQT1.Smalla"; //$NON-NLS-1$
+ String output = "SELECT (SmallishA.DoubleNum * 1.0) FROM SmallishA"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = getOracleSpecificMetadata();
+
+ helpTestVisitor(metadata, input, EMPTY_CONTEXT, null, output);
+ }
+
+ /** create fake BQT metadata to test this case, name in source is important */
+ private QueryMetadataInterface getOracleSpecificMetadata() {
+ MetadataStore metadataStore = new MetadataStore();
+ Schema foo = RealMetadataFactory.createPhysicalModel("BQT1", metadataStore); //$NON-NLS-1$
+ Table table = RealMetadataFactory.createPhysicalGroup("SmallA", foo); //$NON-NLS-1$
+ Table dual = RealMetadataFactory.createPhysicalGroup("DUAL", foo); //$NON-NLS-1$
+ table.setNameInSource("SmallishA");//$NON-NLS-1$
+ String[] elemNames = new String[] {
+ "DoubleNum", //$NON-NLS-1$
+ "ID", //$NON-NLS-1$
+ };
+ String[] elemTypes = new String[] {
+ DataTypeManager.DefaultDataTypes.DOUBLE,
+ DataTypeManager.DefaultDataTypes.INTEGER,
+ };
+ List<Column> cols = RealMetadataFactory.createElements(table, elemNames, elemTypes);
+ cols.get(1).setAutoIncremented(true);
+ cols.get(1).setNameInSource("ID:SEQUENCE=MYSEQUENCE.nextVal"); //$NON-NLS-1$
+ RealMetadataFactory.createElements(dual, new String[] {"something"}, new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
+
+ CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
+ return new TransformationMetadata(null, store, null, null);
+ }
+
+ public void helpTestVisitor(String vdb, String input, String expectedOutput) throws ConnectorException {
+ helpTestVisitor(vdb, input, null, expectedOutput);
+ }
+
+ @Test public void testLimitWithNestedInlineView() throws Exception {
+ String input = "select max(intkey), stringkey from (select intkey, stringkey from bqt1.smalla order by intkey limit 100) x group by stringkey"; //$NON-NLS-1$
+ String output = "SELECT MAX(x.intkey), x.stringkey FROM (SELECT * FROM (SELECT SmallA.IntKey, SmallA.StringKey FROM SmallA ORDER BY intkey NULLS FIRST) WHERE ROWNUM <= 100) x GROUP BY x.stringkey"; //$NON-NLS-1$
+
+ helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
+ input,
+ EMPTY_CONTEXT, null, output);
+ }
+
+ @Test public void testExceptAsMinus() throws Exception {
+ String input = "select intkey, intnum from bqt1.smalla except select intnum, intkey from bqt1.smallb"; //$NON-NLS-1$
+ String output = "SELECT SmallA.IntKey, SmallA.IntNum FROM SmallA MINUS SELECT SmallB.IntNum, SmallB.IntKey FROM SmallB"; //$NON-NLS-1$
+
+ helpTestVisitor(FakeMetadataFactory.exampleBQTCached(),
+ input,
+ EMPTY_CONTEXT, null, output);
+ }
+
+ @Test public void testConcat() throws Exception {
+ String sql = "select concat(stringnum, stringkey) from BQT1.Smalla"; //$NON-NLS-1$
+ String expected = "SELECT CASE WHEN SmallA.StringNum IS NULL OR SmallA.StringKey IS NULL THEN NULL ELSE concat(SmallA.StringNum, SmallA.StringKey) END FROM SmallA"; //$NON-NLS-1$
+ helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
+ }
+
+ @Test public void testConcat_withLiteral() throws Exception {
+ String sql = "select stringnum || '1' from BQT1.Smalla"; //$NON-NLS-1$
+ String expected = "SELECT CASE WHEN SmallA.StringNum IS NULL THEN NULL ELSE concat(SmallA.StringNum, '1') END FROM SmallA"; //$NON-NLS-1$
+ helpTestVisitor(FakeMetadataFactory.exampleBQTCached(), sql, EMPTY_CONTEXT, null, expected);
+ }
+
+ @Test public void testRowLimitWithUnionOrderBy() throws Exception {
+ String input = "(select intkey from bqt1.smalla limit 50, 100) union select intnum from bqt1.smalla order by intkey"; //$NON-NLS-1$
+ String output = "SELECT c_0 FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM (SELECT g_1.IntKey AS c_0 FROM SmallA g_1) VIEW_FOR_LIMIT WHERE ROWNUM <= 150) WHERE ROWNUM_ > 50 UNION SELECT g_0.IntNum AS c_0 FROM SmallA g_0 ORDER BY c_0 NULLS FIRST"; //$NON-NLS-1$
+
+ CommandBuilder commandBuilder = new CommandBuilder(FakeMetadataFactory.exampleBQTCached());
+ Command obj = commandBuilder.getCommand(input, true, true);
+ this.helpTestVisitor(obj, EMPTY_CONTEXT, null, output);
+ }
+
}
Modified: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -64,9 +64,9 @@
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.SortSpecification;
import org.teiid.connector.language.TableReference;
import org.teiid.connector.language.Comparison.Operator;
Modified: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPUpdateExecution.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -38,14 +38,14 @@
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.UpdateExecution;
import org.teiid.connector.basic.BasicExecution;
+import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.Command;
import org.teiid.connector.language.Comparison;
import org.teiid.connector.language.Condition;
import org.teiid.connector.language.Delete;
-import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.Expression;
+import org.teiid.connector.language.ExpressionValueSource;
import org.teiid.connector.language.Insert;
-import org.teiid.connector.language.ExpressionValueSource;
import org.teiid.connector.language.Literal;
import org.teiid.connector.language.SetClause;
import org.teiid.connector.language.Update;
@@ -282,7 +282,7 @@
private void executeUpdate()
throws ConnectorException {
- List<SetClause> updateList = ((Update)command).getChanges().getClauses();
+ List<SetClause> updateList = ((Update)command).getChanges();
Condition criteria = ((Update)command).getWhere();
// since we have the exact same processing rules for criteria
Modified: branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -38,16 +38,20 @@
import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.language.Command;
import org.teiid.connector.language.Select;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import org.teiid.connector.metadata.runtime.Schema;
+import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.connector.metadata.runtime.Column.SearchType;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.TransformationMetadata;
import com.metamatrix.cdk.CommandBuilder;
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;
+import com.metamatrix.query.unittest.RealMetadataFactory;
/**
* Test IQueryToLdapSearchParser.
@@ -264,13 +268,15 @@
return searchDetails;
}
- public static FakeMetadataFacade exampleLdap() {
+ public static QueryMetadataInterface exampleLdap() {
+ MetadataStore metadataStore = new MetadataStore();
+
// Create models
- FakeMetadataObject ldapModel = FakeMetadataFactory.createPhysicalModel("LdapModel"); //$NON-NLS-1$
+ Schema ldapModel = RealMetadataFactory.createPhysicalModel("LdapModel", metadataStore); //$NON-NLS-1$
// Create physical groups
- FakeMetadataObject table = FakeMetadataFactory.createPhysicalGroup("LdapModel.People", ldapModel); //$NON-NLS-1$
- table.putProperty(FakeMetadataObject.Props.NAME_IN_SOURCE, "ou=people,dc=metamatrix,dc=com"); //$NON-NLS-1$
+ Table table = RealMetadataFactory.createPhysicalGroup("People", ldapModel); //$NON-NLS-1$
+ table.setNameInSource("ou=people,dc=metamatrix,dc=com"); //$NON-NLS-1$
// Create physical elements
String[] elemNames = new String[] {
@@ -280,32 +286,24 @@
DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING
};
- List cols = FakeMetadataFactory.createElements(table, elemNames, elemTypes);
+ List<Column> cols = RealMetadataFactory.createElements(table, elemNames, elemTypes);
// Set name in source on each column
String[] nameInSource = new String[] {
"uid", "cn" //$NON-NLS-1$ //$NON-NLS-2$
};
for(int i=0; i<2; i++) {
- FakeMetadataObject obj = (FakeMetadataObject) cols.get(i);
- obj.putProperty(FakeMetadataObject.Props.NAME_IN_SOURCE, nameInSource[i]);
+ Column obj = cols.get(i);
+ obj.setNameInSource(nameInSource[i]);
}
// Set column-specific properties
- ((FakeMetadataObject) cols.get(0)).putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
for(int i=1; i<2; i++) {
- ((FakeMetadataObject) cols.get(0)).putProperty(FakeMetadataObject.Props.SEARCHABLE_COMPARE, Boolean.FALSE);
- ((FakeMetadataObject) cols.get(0)).putProperty(FakeMetadataObject.Props.SEARCHABLE_LIKE, Boolean.FALSE);
+ cols.get(i).setSearchType(SearchType.Unsearchable);
}
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(ldapModel);
- store.addObject(table);
- store.addObjects(cols);
-
// Create the facade from the store
- return new FakeMetadataFacade(store);
+ return new TransformationMetadata(null, new CompositeMetadataStore(metadataStore), null, null);
}
}
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/UpdateExecutionImpl.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -63,7 +63,7 @@
if (null != Ids && Ids.length > 0) {
List<JAXBElement> elements = new ArrayList<JAXBElement>();
- for (SetClause clause : ((Update)command).getChanges().getClauses()) {
+ for (SetClause clause : ((Update)command).getChanges()) {
ColumnReference element = clause.getSymbol();
Column column = element.getMetadataObject();
String val = ((Literal) clause.getValue())
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/CriteriaVisitor.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -54,7 +54,9 @@
*/
public abstract class CriteriaVisitor extends HierarchyVisitor implements ICriteriaVisitor {
- protected static final String SELECT = "SELECT";
+ private static final String RESTRICTEDMULTISELECTPICKLIST = "restrictedmultiselectpicklist";
+ private static final String MULTIPICKLIST = "multipicklist";
+ protected static final String SELECT = "SELECT";
protected static final String FROM = "FROM";
protected static final String WHERE = "WHERE";
protected static final String ORDER_BY = "ORDER BY";
@@ -170,8 +172,7 @@
String columnName = lExpr.toString();
if (columnElementsByName.containsKey(columnName)) {
Column column = columnElementsByName.get(columnName);
- if (null != column.getNativeType()
- && (column.getNativeType().equals("multipicklist") || column.getNativeType().equals("restrictedmultiselectpicklist"))) {
+ if (MULTIPICKLIST.equalsIgnoreCase(column.getNativeType()) || RESTRICTEDMULTISELECTPICKLIST.equalsIgnoreCase(column.getNativeType())) {
appendMultiselectIn(column, criteria);
} else {
appendCriteria(criteria);
@@ -409,7 +410,7 @@
if (expression instanceof ColumnReference) {
Column element = ((ColumnReference)expression).getMetadataObject();
String nativeType = element.getNativeType();
- if (nativeType.equalsIgnoreCase("multipicklist") || nativeType.equalsIgnoreCase("restrictedmultiselectpicklist")) {
+ if (MULTIPICKLIST.equalsIgnoreCase(nativeType) || RESTRICTEDMULTISELECTPICKLIST.equalsIgnoreCase(nativeType)) {
result = true;
}
}
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -32,9 +32,9 @@
import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.Expression;
+import org.teiid.connector.language.Limit;
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Select;
-import org.teiid.connector.language.TableReference;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -56,7 +56,6 @@
super(metadata);
}
-
public void visit(Select query) {
super.visit(query);
if (query.isDistinct()) {
@@ -88,28 +87,30 @@
}
++index;
}
+ }
+
+ @Override
+ public void visit(NamedTable obj) {
try {
- // could be a join here, but if so we do nothing and handle
- // it in visit(IJoin join).
- TableReference fromItem = query.getFrom().get(0);
- if(fromItem instanceof NamedTable) {
- table = ((NamedTable)fromItem).getMetadataObject();
- String supportsQuery = table.getProperties().get(Constants.SUPPORTS_QUERY);
- objectSupportsRetrieve = Boolean.valueOf(table.getProperties().get(Constants.SUPPORTS_RETRIEVE));
- if (!Boolean.valueOf(supportsQuery)) {
- throw new ConnectorException(table.getNameInSource() + " "
- + Messages.getString("CriteriaVisitor.query.not.supported"));
- }
- loadColumnMetadata((NamedTable)fromItem);
- }
+ table = obj.getMetadataObject();
+ String supportsQuery = table.getProperties().get(Constants.SUPPORTS_QUERY);
+ objectSupportsRetrieve = Boolean.valueOf(table.getProperties().get(Constants.SUPPORTS_RETRIEVE));
+ if (!Boolean.valueOf(supportsQuery)) {
+ throw new ConnectorException(table.getNameInSource() + " "
+ + Messages.getString("CriteriaVisitor.query.not.supported"));
+ }
+ loadColumnMetadata(obj);
} catch (ConnectorException ce) {
exceptions.add(ce);
}
- if(null != query.getLimit()) {
- limitClause.append(LIMIT).append(SPACE).append(query.getLimit().getRowLimit());
- }
}
-
+
+ @Override
+ public void visit(Limit obj) {
+ super.visit(obj);
+ limitClause.append(LIMIT).append(SPACE).append(obj.getRowLimit());
+ }
+
/*
* The SOQL SELECT command uses the following syntax: SELECT fieldList FROM
* objectType [WHERE The Condition Expression (WHERE Clause)] [ORDER BY]
Modified: branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -28,24 +28,30 @@
import org.junit.Test;
import org.teiid.connector.language.Select;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.connector.metadata.runtime.Schema;
+import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.connector.metadata.runtime.Column.SearchType;
+import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.TransformationMetadata;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.unittest.RealMetadataFactory;
public class TestVisitors {
- public static FakeMetadataFacade exampleSalesforce() {
+ public static QueryMetadataInterface exampleSalesforce() {
+ MetadataStore store = new MetadataStore();
// Create models
- FakeMetadataObject salesforceModel = FakeMetadataFactory.createPhysicalModel("SalesforceModel"); //$NON-NLS-1$
+ Schema salesforceModel = RealMetadataFactory.createPhysicalModel("SalesforceModel", store); //$NON-NLS-1$
// Create Account group
- FakeMetadataObject accounTable = FakeMetadataFactory.createPhysicalGroup("SalesforceModel.Account", salesforceModel); //$NON-NLS-1$
- accounTable.putProperty(FakeMetadataObject.Props.NAME_IN_SOURCE, "Account"); //$NON-NLS-1$
- accounTable.setExtensionProp("Supports Query", Boolean.TRUE.toString()); //$NON-NLS-1$
+ Table accounTable = RealMetadataFactory.createPhysicalGroup("Account", salesforceModel); //$NON-NLS-1$
+ accounTable.setNameInSource("Account"); //$NON-NLS-1$
+ accounTable.setProperty("Supports Query", Boolean.TRUE.toString()); //$NON-NLS-1$
// Create Account Columns
String[] acctNames = new String[] {
"ID", "Name", "Stuff", "Industry" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
@@ -54,54 +60,40 @@
DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING
};
- List<FakeMetadataObject> acctCols = FakeMetadataFactory.createElements(accounTable, acctNames, acctTypes);
- acctCols.get(2).putProperty(FakeMetadataObject.Props.NATIVE_TYPE, "multipicklist"); //$NON-NLS-1$
- acctCols.get(2).putProperty(FakeMetadataObject.Props.SEARCHABLE_COMPARE, false);
- acctCols.get(2).putProperty(FakeMetadataObject.Props.SEARCHABLE_LIKE, true);
+ List<Column> acctCols = RealMetadataFactory.createElements(accounTable, acctNames, acctTypes);
+ acctCols.get(2).setNativeType("multipicklist"); //$NON-NLS-1$
+ acctCols.get(2).setSearchType(SearchType.Like_Only);
// Set name in source on each column
String[] accountNameInSource = new String[] {
- "id", "AccountName", "Stuff", "Industry" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "id", "AccountName", "Stuff", "Industry" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
};
for(int i=0; i<2; i++) {
- FakeMetadataObject obj = acctCols.get(i);
- obj.putProperty(FakeMetadataObject.Props.NAME_IN_SOURCE, accountNameInSource[i]);
+ Column obj = acctCols.get(i);
+ obj.setNameInSource(accountNameInSource[i]);
}
- // Add all Account to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(salesforceModel);
- store.addObject(accounTable);
- store.addObjects(acctCols);
-
// Create Contact group
- FakeMetadataObject contactTable = FakeMetadataFactory.createPhysicalGroup("SalesforceModel.Contact", salesforceModel); //$NON-NLS-1$
- contactTable.putProperty(FakeMetadataObject.Props.NAME_IN_SOURCE, "Contact"); //$NON-NLS-1$
- contactTable.setExtensionProp("Supports Query", Boolean.TRUE.toString()); //$NON-NLS-1$
+ Table contactTable = RealMetadataFactory.createPhysicalGroup("Contact", salesforceModel); //$NON-NLS-1$
+ contactTable.setNameInSource("Contact"); //$NON-NLS-1$
+ contactTable.setProperty("Supports Query", Boolean.TRUE.toString()); //$NON-NLS-1$
// Create Contact Columns
String[] elemNames = new String[] {
- "ContactID", "Name", "AccountId" //$NON-NLS-1$ //$NON-NLS-2$
+ "ContactID", "Name", "AccountId" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
};
String[] elemTypes = new String[] {
DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING
};
- List<FakeMetadataObject> contactCols = FakeMetadataFactory.createElements(contactTable, elemNames, elemTypes);
+ List<Column> contactCols = RealMetadataFactory.createElements(contactTable, elemNames, elemTypes);
// Set name in source on each column
String[] contactNameInSource = new String[] {
"id", "ContactName", "accountid" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
};
for(int i=0; i<2; i++) {
- FakeMetadataObject obj = contactCols.get(i);
- obj.putProperty(FakeMetadataObject.Props.NAME_IN_SOURCE, contactNameInSource[i]);
+ Column obj = contactCols.get(i);
+ obj.setNameInSource(contactNameInSource[i]);
}
-
- // Add all Account to the store
- store.addObject(salesforceModel);
- store.addObject(contactTable);
- store.addObjects(contactCols);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
+ return new TransformationMetadata(null, new CompositeMetadataStore(store), null, null);
}
private static TranslationUtility translationUtility = new TranslationUtility(exampleSalesforce());
Modified: branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/Util.java
===================================================================
--- branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/Util.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/connectors/connector-text/src/test/java/com/metamatrix/connector/text/Util.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -29,10 +29,19 @@
import org.mockito.Mockito;
import org.teiid.connector.api.ConnectorLogger;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.connector.metadata.runtime.Schema;
+import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.TransformationMetadata;
import com.metamatrix.cdk.api.ConnectorHost;
-import com.metamatrix.cdk.unittest.FakeTranslationFactory;
+import com.metamatrix.cdk.api.TranslationUtility;
+import com.metamatrix.common.types.DataTypeManager;
import com.metamatrix.core.util.UnitTestUtil;
+import com.metamatrix.query.metadata.QueryMetadataInterface;
+import com.metamatrix.query.unittest.RealMetadataFactory;
public class Util {
@@ -62,8 +71,31 @@
Mockito.stub(config.getLogger()).toReturn(Mockito.mock(ConnectorLogger.class));
- ConnectorHost host = new ConnectorHost(new TextConnector(), config, FakeTranslationFactory.getInstance().getTextTranslationUtility());
+ ConnectorHost host = new ConnectorHost(new TextConnector(), config, new TranslationUtility(exampleText()));
return host;
}
+
+ public static QueryMetadataInterface exampleText() {
+ MetadataStore store = new MetadataStore();
+ // Create models
+ Schema lib = RealMetadataFactory.createPhysicalModel("Text", store); //$NON-NLS-1$
+ // Create physical groups
+ Table library = RealMetadataFactory.createPhysicalGroup("Library", lib); //$NON-NLS-1$
+
+ // Create physical elements
+ String[] elemNames = new String[] {
+ "ID", "PDate", "Author" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.DATE,
+ DataTypeManager.DefaultDataTypes.STRING };
+
+ List<Column> libe1 = RealMetadataFactory.createElements( library, elemNames, elemTypes);
+ int index = 0;
+ for (Column column : libe1) {
+ column.setNameInSource(String.valueOf(index++));
+ }
+ return new TransformationMetadata(null, new CompositeMetadataStore(store), null, null);
+ }
+
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -424,7 +424,7 @@
Ordering direction = items.get(i).isAscending() ? Ordering.ASC: Ordering.DESC;
SortSpecification orderByItem = null;
- if(symbol instanceof AliasSymbol || (symbol.getOutputName() != null && symbol.getOutputName().indexOf(ElementSymbol.SEPARATOR) == -1)){
+ if(symbol instanceof AliasSymbol || !items.get(i).isUnrelated()){
orderByItem = new SortSpecification(direction, new ColumnReference(null, symbol.getOutputName(), null, symbol.getType()));
} else {
orderByItem = new SortSpecification(direction, translate(symbol));
@@ -564,12 +564,12 @@
translate(update.getCriteria()));
}
- org.teiid.connector.language.SetClauseList translate(SetClauseList setClauseList) throws MetaMatrixComponentException {
+ List<org.teiid.connector.language.SetClause> translate(SetClauseList setClauseList) throws MetaMatrixComponentException {
List<org.teiid.connector.language.SetClause> clauses = new ArrayList<org.teiid.connector.language.SetClause>(setClauseList.getClauses().size());
for (SetClause setClause : setClauseList.getClauses()) {
clauses.add(translate(setClause));
}
- return new org.teiid.connector.language.SetClauseList(clauses);
+ return clauses;
}
org.teiid.connector.language.SetClause translate(SetClause setClause) throws MetaMatrixComponentException {
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -364,7 +364,7 @@
if (workItem != null) {
workItem.removeLobStream(lobRequestId);
}
- return null;
+ return ResultsFuture.NULL_FUTURE;
}
public ResultsFuture<LobChunk> requestNextLobChunk(int lobRequestId,
@@ -468,7 +468,7 @@
public ResultsFuture<?> closeRequest(long requestId) throws MetaMatrixProcessingException, MetaMatrixComponentException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
closeRequest(workContext.getRequestID(requestId));
- return null;
+ return ResultsFuture.NULL_FUTURE;
}
/**
@@ -713,7 +713,7 @@
public ResultsFuture<?> begin() throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
this.getTransactionService().begin(threadId);
- return null;
+ return ResultsFuture.NULL_FUTURE;
}
// local txn
@@ -758,13 +758,13 @@
public ResultsFuture<?> end(MMXid xid, int flags) throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
this.getTransactionService().end(threadId, xid, flags, false);
- return null;
+ return ResultsFuture.NULL_FUTURE;
}
// global txn
public ResultsFuture<?> forget(MMXid xid) throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
this.getTransactionService().forget(threadId, xid, false);
- return null;
+ return ResultsFuture.NULL_FUTURE;
}
// global txn
@@ -811,7 +811,7 @@
throws XATransactionException {
String threadId = DQPWorkContext.getWorkContext().getConnectionID();
this.getTransactionService().start(threadId, xid, flags, timeout, false);
- return null;
+ return ResultsFuture.NULL_FUTURE;
}
public MetadataResult getMetadata(long requestID)
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -1944,7 +1944,7 @@
@Test public void testDefect10809(){
String sql = "select * from LOB_TESTING_ONE where CLOB_COLUMN LIKE '%fff%'"; //$NON-NLS-1$
- helpResolve(helpParse(sql), FakeMetadataFactory.exampleLOB(), AnalysisRecord.createNonRecordingRecord());
+ helpResolve(helpParse(sql), FakeMetadataFactory.exampleBQTCached(), AnalysisRecord.createNonRecordingRecord());
}
@Test public void testNonAutoConversionOfLiteralIntegerToShort() throws Exception {
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -46,7 +46,6 @@
import com.metamatrix.query.mapping.xml.MappingAttribute;
import com.metamatrix.query.mapping.xml.MappingDocument;
import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
import com.metamatrix.query.mapping.xml.MappingSequenceNode;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -2137,405 +2136,6 @@
return RealMetadataFactory.exampleBQT();
}
- public static FakeMetadataFacade exampleUQT() {
- // Create models
- FakeMetadataObject uqt2 = createPhysicalModel("UQT2"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject uqt2UpdateA = createPhysicalGroup("UQT2.UpdateA", uqt2); //$NON-NLS-1$
- FakeMetadataObject uqt2UpdateB = createPhysicalGroup("UQT2.UpdateB", uqt2); //$NON-NLS-1$
- FakeMetadataObject uqt2BlobTable = createPhysicalGroup("UQT2.BlobTable", uqt2); //$NON-NLS-1$
-
- // Create physical elements
- String[] elemNames = new String[] {
- "IntKey", "StringKey", //$NON-NLS-1$ //$NON-NLS-2$
- "IntNum", "StringNum", //$NON-NLS-1$ //$NON-NLS-2$
- "FloatNum", "LongNum", //$NON-NLS-1$ //$NON-NLS-2$
- "DoubleNum", "ByteNum", //$NON-NLS-1$ //$NON-NLS-2$
- "DateValue", "TimeValue", //$NON-NLS-1$ //$NON-NLS-2$
- "TimestampValue", "BooleanValue", //$NON-NLS-1$ //$NON-NLS-2$
- "CharValue", "ShortValue", //$NON-NLS-1$ //$NON-NLS-2$
- "BigIntegerValue", "BigDecimalValue", //$NON-NLS-1$ //$NON-NLS-2$
- "ObjectValue" }; //$NON-NLS-1$
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.LONG,
- DataTypeManager.DefaultDataTypes.DOUBLE, DataTypeManager.DefaultDataTypes.BYTE,
- DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIME,
- DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BOOLEAN,
- DataTypeManager.DefaultDataTypes.CHAR, DataTypeManager.DefaultDataTypes.SHORT,
- DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL,
- DataTypeManager.DefaultDataTypes.OBJECT };
-
- String[] blobElemNames = new String[] {
- "id", "BlobValue" //$NON-NLS-1$ //$NON-NLS-2$
- };
- String[] blobElemTypes = new String[] {DataTypeManager.DefaultDataTypes.STRING,
- DataTypeManager.DefaultDataTypes.BLOB
- };
-
- List uqt2UpdateAe = createElements(uqt2UpdateA, elemNames, elemTypes);
- List uqt2UpdateBe = createElements(uqt2UpdateB, elemNames, elemTypes);
- List uqt2BlobTablee = createElements(uqt2BlobTable, blobElemNames, blobElemTypes);
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(uqt2);
- store.addObject(uqt2UpdateA);
- store.addObjects(uqt2UpdateAe);
- store.addObject(uqt2UpdateB);
- store.addObjects(uqt2UpdateBe);
- store.addObject(uqt2BlobTable);
- store.addObjects(uqt2BlobTablee);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
- public static FakeMetadataFacade exampleLOB() {
- // Create models
- FakeMetadataObject lib = createPhysicalModel("Blob"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject library = createPhysicalGroup("LOB_TESTING_ONE", lib, true); //$NON-NLS-1$
-
- // Create physical elements
- String[] elemNames = new String[] {
- "CLOB_COLUMN", "BLOB_COLUMN", "KEY_EMULATOR" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.CLOB, DataTypeManager.DefaultDataTypes.BLOB,
- DataTypeManager.DefaultDataTypes.INTEGER };
-
- List libe1 = createElements( library, elemNames, elemTypes, true);
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(lib);
- store.addObject(library);
- store.addObjects(libe1);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
- public static FakeMetadataFacade exampleStream(boolean isStream) {
- // Create models
- FakeMetadataObject lib = createPhysicalModel("Blob"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject library = null;
- if (isStream) {
- library = createPhysicalGroup("STREAMEXAMPLE", lib, true); //$NON-NLS-1$
- } else {
- library = createPhysicalGroup("READEREAMPLE", lib, true); //$NON-NLS-1$
- }
- // Create physical elements
- String[] elemNames = new String[] {
- "KEY_EMULATOR", "DATA"}; //$NON-NLS-1$ //$NON-NLS-2$
-
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.OBJECT};
-
- List libe1 = createElements( library, elemNames, elemTypes, true);
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(lib);
- store.addObject(library);
- store.addObjects(libe1);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
- public static FakeMetadataFacade exampleBytes() {
- // Create models
- FakeMetadataObject lib = createPhysicalModel("Blob"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject library = createPhysicalGroup("BYTE_EXAMPLE", lib, true); //$NON-NLS-1$
-
- // Create physical elements
- String[] elemNames = new String[] {
- "KEY_EMULATOR", "DATA"}; //$NON-NLS-1$ //$NON-NLS-2$
-
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.OBJECT};
-
- List libe1 = createElements( library, elemNames, elemTypes, true);
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(lib);
- store.addObject(library);
- store.addObjects(libe1);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
- public static FakeMetadataFacade exampleText() {
- // Create models
- FakeMetadataObject lib = createPhysicalModel("Text"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject library = createPhysicalGroup("Text.Library", lib, true); //$NON-NLS-1$
-
- // Create physical elements
- String[] elemNames = new String[] {
- "ID", "PDate", "Author" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- String[] elemTypes = new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.DATE,
- DataTypeManager.DefaultDataTypes.STRING };
-
- List libe1 = createElements( library, elemNames, elemTypes, false);
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(lib);
- store.addObject(library);
- store.addObjects(libe1);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
- public static FakeMetadataFacade exampleXQT() {
- FakeMetadataStore store = new FakeMetadataStore();
- FakeMetadataFacade facade = new FakeMetadataFacade(store);
-
- // Create models
- FakeMetadataObject xqt = FakeMetadataFactory.createPhysicalModel("XQT"); //$NON-NLS-1$
- FakeMetadataObject xqttest = FakeMetadataFactory.createVirtualModel("xqttest"); //$NON-NLS-1$
-
- // Create physical groups
- //FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("xqt.data", xqt);
- FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallA", xqt); //$NON-NLS-1$
-
-
- // Create physical elements
- List xqtData = FakeMetadataFactory.createElements(xqtGroup,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- // Create virtual groups
- QueryNode rsQuery = new QueryNode("xqttest.data", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey=13"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs = FakeMetadataFactory.createVirtualGroup("xqttest.data", xqttest, rsQuery); //$NON-NLS-1$
-
- QueryNode rsQuery2 = new QueryNode("xqttest.data2", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery2.addBinding("xqttest.data.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs2 = FakeMetadataFactory.createVirtualGroup("xqttest.data2", xqttest, rsQuery2); //$NON-NLS-1$
-
- QueryNode rsQuery3 = new QueryNode("xqttest.data3", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery3.addBinding("xqttest.data2.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs3 = FakeMetadataFactory.createVirtualGroup("xqttest.data3", xqttest, rsQuery3); //$NON-NLS-1$
-
- QueryNode rsQuery4 = new QueryNode("xqttest.data4", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery4.addBinding("xqttest.data.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs4 = FakeMetadataFactory.createVirtualGroup("xqttest.data4", xqttest, rsQuery4); //$NON-NLS-1$
-
- QueryNode rsQuery5 = new QueryNode("xqttest.data5", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery5.addBinding("xqttest.data4.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs5 = FakeMetadataFactory.createVirtualGroup("xqttest.data5", xqttest, rsQuery5); //$NON-NLS-1$
-
- QueryNode rsQuery6 = new QueryNode("xqttest.data6", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey = ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery6.addBinding("xqttest.data5.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs6 = FakeMetadataFactory.createVirtualGroup("xqttest.data6", xqttest, rsQuery6); //$NON-NLS-1$
-
-
- QueryNode rsQuery7 = new QueryNode("xqttest.data7", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs7 = FakeMetadataFactory.createVirtualGroup("xqttest.data7", xqttest, rsQuery7); //$NON-NLS-1$
-
- QueryNode rsQuery8 = new QueryNode("xqttest.data8", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey < ?"); //$NON-NLS-1$ //$NON-NLS-2$
- rsQuery8.addBinding("xqttest.data7.intNum"); //$NON-NLS-1$
- FakeMetadataObject rs8 = FakeMetadataFactory.createVirtualGroup("xqttest.data8", xqttest, rsQuery8); //$NON-NLS-1$
-
- // Create virtual elements
- List rsElements = FakeMetadataFactory.createElements(rs,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements2 = FakeMetadataFactory.createElements(rs2,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements3 = FakeMetadataFactory.createElements(rs3,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements4 = FakeMetadataFactory.createElements(rs4,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements5 = FakeMetadataFactory.createElements(rs5,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements6 = FakeMetadataFactory.createElements(rs6,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements7 = FakeMetadataFactory.createElements(rs7,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- List rsElements8 = FakeMetadataFactory.createElements(rs8,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
-
- FakeMetadataObject doc1 = FakeMetadataFactory.createVirtualGroup("xqttest.doc1", xqttest, createXQTPlanRecursive_5988()); //$NON-NLS-1$
- FakeMetadataObject doc1a = FakeMetadataFactory.createVirtualGroup("xqttest.doc1a", xqttest, createXQTPlanRecursive1a_5988()); //$NON-NLS-1$
-// FakeMetadataObject doc2 = FakeMetadataFactory.createVirtualGroup("xqttest.doc2", xqttest, createXQTPlanRecursiveSiblings());
-// FakeMetadataObject doc3 = FakeMetadataFactory.createVirtualGroup("xqttest.doc3", xqttest, createXQTPlanRecursive3_5988());
-// FakeMetadataObject doc4 = FakeMetadataFactory.createVirtualGroup("xqttest.doc4", xqttest, createXQTPlanChoice_6796());
-
- store.addObject(xqt);
- store.addObject(xqtGroup);
- store.addObjects(xqtData);
-
- store.addObject(xqttest);
- store.addObject(rs);
- store.addObject(rs2);
- store.addObject(rs3);
- store.addObject(rs4);
- store.addObject(rs5);
- store.addObject(rs6);
- store.addObject(rs7);
- store.addObject(rs8);
- store.addObjects(rsElements);
- store.addObjects(rsElements2);
- store.addObjects(rsElements3);
- store.addObjects(rsElements4);
- store.addObjects(rsElements5);
- store.addObjects(rsElements6);
- store.addObjects(rsElements7);
- store.addObjects(rsElements8);
-
- store.addObject(doc1);
- store.addObject(doc1a);
-// store.addObject(doc2);
-// store.addObject(doc3);
-// store.addObject(doc4);
-
- return facade;
- }
-
- public static FakeMetadataFacade exampleXQT1() {
- FakeMetadataStore store = new FakeMetadataStore();
- FakeMetadataFacade facade = new FakeMetadataFacade(store);
-
- // Create models
- FakeMetadataObject xqt = FakeMetadataFactory.createPhysicalModel("XQT"); //$NON-NLS-1$
- FakeMetadataObject xqttest = FakeMetadataFactory.createVirtualModel("xqttest"); //$NON-NLS-1$
-
- // Create physical groups
- //FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("xqt.data", xqt);
- FakeMetadataObject xqtGroup = FakeMetadataFactory.createPhysicalGroup("BQT1.SmallA", xqt); //$NON-NLS-1$
-
- // Create physical elements
- List xqtData = FakeMetadataFactory.createElements(xqtGroup,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- // Create virtual groups
- QueryNode rsQuery = new QueryNode("xqttest.data", "SELECT intKey, intNum, stringNum FROM BQT1.SmallA WHERE intKey=13"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs = FakeMetadataFactory.createVirtualGroup("xqttest.data", xqttest, rsQuery); //$NON-NLS-1$
-
- // Create virtual elements
- List rsElements = FakeMetadataFactory.createElements(rs,
- new String[] { "intKey", "intNum", "stringNum" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING });
-
- FakeMetadataObject doc1 = FakeMetadataFactory.createVirtualGroup("xqttest.doc1", xqttest, createBQTDocTest_Plan()); //$NON-NLS-1$
-
- store.addObject(xqt);
- store.addObject(xqtGroup);
- store.addObjects(xqtData);
-
- store.addObject(xqttest);
- store.addObject(rs);
- store.addObjects(rsElements);
- store.addObject(doc1);
-
- return facade;
- }
-
- /**
- * Method createXQTPlanRecursive.
- * @return Object
- */
- private static MappingDocument createXQTPlanRecursive_5988() {
- MappingDocument doc = new MappingDocument(true);
- MappingElement root = doc.addChildElement(new MappingElement("recursiveTest")); //$NON-NLS-1$
-
- MappingElement src1 = root.addChildElement(new MappingElement("src")); //$NON-NLS-1$
- src1.setSource("xqttest.data");//$NON-NLS-1$
-
- MappingSequenceNode seq1 = src1.addSequenceNode(new MappingSequenceNode());
- seq1.addChildElement(new MappingElement("key", "xqttest.data.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
- seq1.addChildElement(new MappingElement("data", "xqttest.data.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-
- MappingElement src2 = seq1.addChildElement(new MappingElement("srcNested")); //$NON-NLS-1$
- src2.setSource("xqttest.data2");//$NON-NLS-1$
-
- MappingSequenceNode seq2 = src2.addSequenceNode(new MappingSequenceNode());
- seq2.addChildElement(new MappingElement("key", "xqttest.data2.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
- seq2.addChildElement(new MappingElement("data", "xqttest.data2.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-
- MappingElement recursive = seq2.addChildElement(new MappingRecursiveElement("srcNestedRecursive", "xqttest.data2")); //$NON-NLS-1$ //$NON-NLS-2$
- recursive.setSource("xqttest.data3");//$NON-NLS-1$
-
- return doc;
- }
-
- /**
- * Method createXQTPlanRecursive.
- * @return Object
- */
- private static MappingDocument createXQTPlanRecursive1a_5988() {
-
- MappingDocument doc = new MappingDocument(true);
- MappingElement root = doc.addChildElement(new MappingElement("recursiveTest")); //$NON-NLS-1$
-
- MappingElement src1 = root.addChildElement(new MappingElement("src")); //$NON-NLS-1$
- src1.setSource("xqttest.data");//$NON-NLS-1$
-
- MappingSequenceNode seq1 = src1.addSequenceNode(new MappingSequenceNode());
- seq1.addChildElement(new MappingElement("key", "xqttest.data.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
- seq1.addChildElement(new MappingElement("data", "xqttest.data.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-
- MappingElement src2 = seq1.addChildElement(new MappingElement("srcNested")); //$NON-NLS-1$
- src2.setSource("xqttest.data2");//$NON-NLS-1$
-
- MappingSequenceNode seq2 = src2.addSequenceNode(new MappingSequenceNode());
- seq2.addChildElement(new MappingElement("key", "xqttest.data2.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
- seq2.addChildElement(new MappingElement("data", "xqttest.data2.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
-
- MappingElement recursive = seq2.addChildElement(new MappingRecursiveElement("srcRecursive", "xqttest.data2")); //$NON-NLS-1$ //$NON-NLS-2$
- recursive.setSource("xqttest.data3");//$NON-NLS-1$
-
- // was not being used
-// MappingRecursiveElement src4 = new MappingRecursiveElement("srcRecursive", "xqttest.data"); //$NON-NLS-1$ //$NON-NLS-2$
-// src4.setSource("xqttest.data4"); //$NON-NLS-1$
- return doc;
- }
-
- /**
- * Method createXQTPlanRecursive.
- * @return Object
- */
- private static MappingDocument createBQTDocTest_Plan() {
- MappingDocument doc = new MappingDocument(false);
- MappingElement root = doc.addChildElement(new MappingElement("BQTDocTest")); //$NON-NLS-1$
-
- MappingElement src1 = root.addChildElement(new MappingElement("src")); //$NON-NLS-1$
- src1.setSource("xqttest.data");//$NON-NLS-1$
-
- MappingSequenceNode seq1 = src1.addSequenceNode(new MappingSequenceNode());
- seq1.addChildElement(new MappingElement("key", "xqttest.data.intKey")); //$NON-NLS-1$ //$NON-NLS-2$
- seq1.addChildElement(new MappingElement("data", "xqttest.data.intNum")); //$NON-NLS-1$ //$NON-NLS-2$
- return doc;
- }
-
public static FakeMetadataFacade exampleSymphony() {
// Create models
FakeMetadataObject model = createPhysicalModel("COMPLEX"); //$NON-NLS-1$
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -81,6 +81,10 @@
Table bqt3MediumA = createPhysicalGroup("MediumA", bqt3); //$NON-NLS-1$
Table bqt3MediumB = createPhysicalGroup("MediumB", bqt3); //$NON-NLS-1$
Table lobTable = createPhysicalGroup("LobTbl", lob); //$NON-NLS-1$
+ Table library = createPhysicalGroup("LOB_TESTING_ONE", lob); //$NON-NLS-1$
+
+ createElements( library, new String[] { "CLOB_COLUMN", "BLOB_COLUMN", "KEY_EMULATOR" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] { DataTypeManager.DefaultDataTypes.CLOB, DataTypeManager.DefaultDataTypes.BLOB, DataTypeManager.DefaultDataTypes.INTEGER });
// Create virtual groups
QueryNode vqtn1 = new QueryNode("VQT.SmallA", "SELECT * FROM BQT1.SmallA"); //$NON-NLS-1$ //$NON-NLS-2$
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -63,7 +63,7 @@
}
public void testGetChanges() throws Exception {
- List changes = example().getChanges().getClauses();
+ List changes = example().getChanges();
assertNotNull(changes);
assertEquals(4, changes.size());
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-02-28 02:38:06 UTC (rev 1881)
@@ -122,7 +122,7 @@
public ResultsFuture<?> logoff() throws InvalidSessionException {
this.service.closeSession(DQPWorkContext.getWorkContext().getSessionId());
DQPWorkContext.getWorkContext().reset();
- return null;
+ return ResultsFuture.NULL_FUTURE;
}
public ResultsFuture<?> ping() throws InvalidSessionException,MetaMatrixComponentException {
@@ -132,7 +132,7 @@
if (id != -1) {
this.service.pingServer(id);
}
- return null;
+ return ResultsFuture.NULL_FUTURE;
}
@Override
Modified: branches/JCA/test-integration/pom.xml
===================================================================
--- branches/JCA/test-integration/pom.xml 2010-02-27 13:43:10 UTC (rev 1880)
+++ branches/JCA/test-integration/pom.xml 2010-02-28 02:38:06 UTC (rev 1881)
@@ -133,6 +133,6 @@
<modules>
<module>common</module>
- <module>db</module>
+ <!-- <module>db</module> -->
</modules>
</project>
\ No newline at end of file
14 years, 10 months
teiid SVN: r1880 - in branches/JCA: connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase and 21 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-02-27 08:43:10 -0500 (Sat, 27 Feb 2010)
New Revision: 1880
Added:
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/OrderByItem.java
Modified:
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseSQLTranslator.java
branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java
branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/access/TestAccessSQLTranslator.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
branches/JCA/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
branches/JCA/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinRegion.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleAssignOutputElements.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeVirtual.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanSorts.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseNull.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java
branches/JCA/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java
branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java
branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
branches/JCA/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/LanguageObject.java
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/LanguageVisitor.java
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/OrderBy.java
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/navigator/PreOrPostOrderNavigator.java
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java
branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
branches/JCA/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
branches/JCA/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
branches/JCA/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
Log:
TEIID-833 merging from truck (except for console) -r 1840:1878
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -685,6 +685,10 @@
if (obj.isDistinct()) {
buffer.append(SQLReservedWords.DISTINCT).append(SQLReservedWords.SPACE);
}
+ if (useSelectLimit() && obj.getLimit() != null) {
+ append(obj.getLimit());
+ buffer.append(SQLReservedWords.SPACE);
+ }
append(obj.getDerivedColumns());
if (obj.getFrom() != null) {
buffer.append(SQLReservedWords.SPACE).append(SQLReservedWords.FROM).append(SQLReservedWords.SPACE);
@@ -710,7 +714,7 @@
buffer.append(SQLReservedWords.SPACE);
append(obj.getOrderBy());
}
- if (obj.getLimit() != null) {
+ if (!useSelectLimit() && obj.getLimit() != null) {
buffer.append(SQLReservedWords.SPACE);
append(obj.getLimit());
}
@@ -893,4 +897,8 @@
protected boolean useParensForJoins() {
return false;
}
+
+ protected boolean useSelectLimit() {
+ return false;
+ }
}
Modified: branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseSQLTranslator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseSQLTranslator.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/sybase/SybaseSQLTranslator.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -43,7 +43,7 @@
import org.teiid.connector.language.Function;
import org.teiid.connector.language.Limit;
import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.QueryExpression;
+import org.teiid.connector.language.SetQuery;
/**
@@ -166,12 +166,15 @@
return 3;
}
+ /**
+ * SetQueries don't have a concept of TOP, an inline view is needed.
+ */
@Override
public List<?> translateCommand(Command command, ExecutionContext context) {
- if (!(command instanceof QueryExpression)) {
+ if (!(command instanceof SetQuery)) {
return null;
}
- QueryExpression queryCommand = (QueryExpression)command;
+ SetQuery queryCommand = (SetQuery)command;
if (queryCommand.getLimit() == null) {
return null;
}
@@ -180,8 +183,8 @@
queryCommand.setLimit(null);
queryCommand.setOrderBy(null);
List<Object> parts = new ArrayList<Object>(6);
- parts.add("SELECT TOP "); //$NON-NLS-1$
- parts.add(limit.getRowLimit());
+ parts.add("SELECT "); //$NON-NLS-1$
+ parts.addAll(translateLimit(limit, context));
parts.add(" * FROM ("); //$NON-NLS-1$
parts.add(queryCommand);
parts.add(") AS X"); //$NON-NLS-1$
@@ -192,7 +195,18 @@
return parts;
}
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<?> translateLimit(Limit limit, ExecutionContext context) {
+ return Arrays.asList("TOP ", limit.getRowLimit()); //$NON-NLS-1$
+ }
+
@Override
+ public boolean useSelectLimit() {
+ return true;
+ }
+
+ @Override
public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
return SybaseCapabilities.class;
}
Modified: branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/SQLConversionVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -364,4 +364,8 @@
return translator.useParensForJoins();
}
+ protected boolean useSelectLimit() {
+ return translator.useSelectLimit();
+ }
+
}
Modified: branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/translator/Translator.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -808,4 +808,12 @@
return false;
}
+ /**
+ *
+ * @return true if the limit clause is part of the select
+ */
+ public boolean useSelectLimit() {
+ return false;
+ }
+
}
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/access/TestAccessSQLTranslator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/access/TestAccessSQLTranslator.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/access/TestAccessSQLTranslator.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -65,7 +65,7 @@
public void testRowLimit() throws Exception {
String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
- String output = "SELECT TOP 100 * FROM (SELECT SmallA.IntKey FROM SmallA) AS X"; //$NON-NLS-1$
+ String output = "SELECT TOP 100 SmallA.IntKey FROM SmallA"; //$NON-NLS-1$
helpTestVisitor(
input,
@@ -75,7 +75,7 @@
public void testRowLimit1() throws Exception {
String input = "select distinct intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
- String output = "SELECT TOP 100 * FROM (SELECT DISTINCT SmallA.IntKey FROM SmallA) AS X"; //$NON-NLS-1$
+ String output = "SELECT DISTINCT TOP 100 SmallA.IntKey FROM SmallA"; //$NON-NLS-1$
helpTestVisitor(
input,
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/mysql/TestMySQLTranslator.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -332,8 +332,8 @@
}
@Test public void testBooleanToString() throws Exception {
- String input = "SELECT convert(INTKEY, boolean) FROM BQT1.SmallA ORDER BY INTKEY"; //$NON-NLS-1$
- String output = "SELECT CASE WHEN SmallA.IntKey = 0 THEN 0 WHEN SmallA.IntKey IS NOT NULL THEN 1 END FROM SmallA ORDER BY INTKEY"; //$NON-NLS-1$
+ String input = "SELECT convert(INTKEY, boolean) FROM BQT1.SmallA"; //$NON-NLS-1$
+ String output = "SELECT CASE WHEN SmallA.IntKey = 0 THEN 0 WHEN SmallA.IntKey IS NOT NULL THEN 1 END FROM SmallA"; //$NON-NLS-1$
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input,
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -99,7 +99,7 @@
@Test
public void testRowLimit() throws Exception {
String input = "select intkey from bqt1.smalla limit 100"; //$NON-NLS-1$
- String output = "SELECT TOP 100 * FROM (SELECT SmallA.IntKey FROM SmallA) AS X"; //$NON-NLS-1$
+ String output = "SELECT TOP 100 SmallA.IntKey FROM SmallA"; //$NON-NLS-1$
helpTestVisitor(getBQTVDB(),
input,
@@ -116,6 +116,15 @@
output);
}
+ @Test public void testLimitWithOrderByUnrelated() throws Exception {
+ String input = "select intkey from bqt1.smalla order by intnum limit 100"; //$NON-NLS-1$
+ String output = "SELECT TOP 100 SmallA.IntKey FROM SmallA ORDER BY SmallA.IntNum"; //$NON-NLS-1$
+
+ helpTestVisitor(getBQTVDB(),
+ input,
+ output);
+ }
+
@Test
public void testDateFunctions() throws Exception {
String input = "select dayName(timestampValue), dayOfWeek(timestampValue), quarter(timestampValue) from bqt1.smalla"; //$NON-NLS-1$
Modified: branches/JCA/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
===================================================================
--- branches/JCA/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2010-02-27 13:43:10 UTC (rev 1880)
@@ -245,6 +245,15 @@
Allowed explicit conversions may still fail during processing
if the runtime values are not actually convertable.</para>
</listitem>
+ <listitem>
+ <warning>
+ <para>The Teiid conversions of float/double/bigdecimal/timestamp to string rely on the JDBC/Java defined
+ output formats. Pushdown behavior attempts to mimic these results, but may vary depending upon the actual
+ source type and conversion logic. Care should be taken to not assume the string form in criteria or other
+ places where a variation may cause different results.
+ </para>
+ </warning>
+ </listitem>
</itemizedlist>
<para>
</para>
Modified: branches/JCA/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
===================================================================
--- branches/JCA/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-02-27 13:43:10 UTC (rev 1880)
@@ -793,7 +793,7 @@
<para>Syntax Rules:
</para>
<listitem>
- <para>Sort columns may be specified positionally by a 1 based
+ <para>Sort columns may be specified positionally by a 1-based positional
integer, by SELECT clause alias name, by SELECT clause expression, or by an unrelated expression.</para>
</listitem>
<listitem>
@@ -806,7 +806,8 @@
</listitem>
<listitem>
<para>Unrelated expressions, expressions not appearing as an aliased expression in the select clause,
- are allowed in the order by clause of a non-set QUERY. The columns referenced in the expression must also follow the prior rule.
+ are allowed in the order by clause of a non-set QUERY. The columns referenced in the expression must come from the
+ from clause table references. The column references cannot be to alias names or positional.
</para>
</listitem>
<listitem>
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -343,7 +343,7 @@
if (needsAlias) {
element = new AliasSymbol(element.getShortName(), (SingleElementSymbol)expr);
- obj.getVariables().set(i, element);
+ obj.getOrderByItems().get(i).setSymbol(element);
}
element.setOutputName(name);
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -34,9 +34,6 @@
// This flag indicates that the plan has a virtual group somewhere
public boolean hasVirtualGroups = false;
- // This flag indicates that the plan has a sort somewhere
- public boolean hasSort = false;
-
// flag indicates that the plan has a union somewhere
public boolean hasSetQuery = false;
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -74,6 +74,7 @@
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.Insert;
import com.metamatrix.query.sql.lang.JoinType;
+import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.StoredProcedure;
import com.metamatrix.query.sql.lang.SetQuery.Operation;
@@ -321,11 +322,10 @@
case NodeConstants.Types.SORT:
case NodeConstants.Types.DUP_REMOVE:
SortNode sortNode = new SortNode(getID());
-
- List elements = (List) node.getProperty(NodeConstants.Info.SORT_ORDER);
- List sortTypes = (List) node.getProperty(NodeConstants.Info.ORDER_TYPES);
-
- sortNode.setSortElements(elements, sortTypes);
+ OrderBy orderBy = (OrderBy) node.getProperty(NodeConstants.Info.SORT_ORDER);
+ if (orderBy != null) {
+ sortNode.setSortElements(orderBy.getSortKeys(), orderBy.getTypes());
+ }
if (node.getType() == NodeConstants.Types.DUP_REMOVE) {
sortNode.setMode(Mode.DUP_REMOVE);
} else if (node.hasBooleanProperty(NodeConstants.Info.IS_DUP_REMOVAL)) {
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -65,6 +65,7 @@
import com.metamatrix.query.resolver.QueryResolver;
import com.metamatrix.query.resolver.util.BindVariableVisitor;
import com.metamatrix.query.rewriter.QueryRewriter;
+import com.metamatrix.query.sql.LanguageObject.Util;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.From;
@@ -156,7 +157,7 @@
connectSubqueryContainers(plan); //TODO: merge with node creation
// Set top column information on top node
- List<SingleElementSymbol> topCols = QueryRewriter.deepClone(command.getProjectedSymbols(), SingleElementSymbol.class);
+ List<SingleElementSymbol> topCols = Util.deepClone(command.getProjectedSymbols(), SingleElementSymbol.class);
// Build rule set based on hints
RuleStack rules = RelationalPlanner.buildRules(hints);
@@ -530,7 +531,6 @@
if(command.getOrderBy() != null) {
node = attachSorting(node, command.getOrderBy());
- hints.hasSort = true;
}
if (command.getLimit() != null) {
@@ -786,8 +786,7 @@
private static PlanNode attachSorting(PlanNode plan, OrderBy orderBy) {
PlanNode sortNode = NodeFactory.getNewNode(NodeConstants.Types.SORT);
- sortNode.setProperty(NodeConstants.Info.SORT_ORDER, orderBy.getVariables());
- sortNode.setProperty(NodeConstants.Info.ORDER_TYPES, orderBy.getTypes());
+ sortNode.setProperty(NodeConstants.Info.SORT_ORDER, orderBy);
if (orderBy.hasUnrelated()) {
sortNode.setProperty(Info.UNRELATED_SORT, true);
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -108,8 +108,7 @@
IS_DEPENDENT_SET, // Boolean - only used with dependent joins
// Sort node properties
- ORDER_TYPES, // List <Boolean>
- SORT_ORDER, // List <SingleElementSymbol>
+ SORT_ORDER, // OrderBy
UNRELATED_SORT, // Boolean
IS_DUP_REMOVAL, // Boolean
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -235,10 +235,8 @@
convertAccessPatterns(symbolMap, node);
} else if(type == NodeConstants.Types.SORT) {
- List<SingleElementSymbol> sortCols = (List<SingleElementSymbol>)node.getProperty(NodeConstants.Info.SORT_ORDER);
- OrderBy orderBy = new OrderBy(sortCols);
+ OrderBy orderBy = (OrderBy)node.getProperty(NodeConstants.Info.SORT_ORDER);
ExpressionMappingVisitor.mapExpressions(orderBy, symbolMap);
- node.setProperty(NodeConstants.Info.SORT_ORDER, orderBy.getVariables());
if (!singleMapping) {
GroupsUsedByElementsVisitor.getGroups(orderBy, groups);
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinRegion.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinRegion.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinRegion.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -52,7 +52,7 @@
import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
/**
- * A join region is a set of cross and inner joins whose ordering is completely interchangable.
+ * A join region is a set of cross and inner joins whose ordering is completely interchangeable.
*
* It can be conceptually thought of as:
* Criteria node some combination of groups A, B, C
@@ -73,30 +73,30 @@
public static final int UNKNOWN_TUPLE_EST = 100000;
- private LinkedHashMap dependentJoinSourceNodes = new LinkedHashMap();
- private LinkedHashMap joinSourceNodes = new LinkedHashMap();
+ private LinkedHashMap<PlanNode, PlanNode> dependentJoinSourceNodes = new LinkedHashMap<PlanNode, PlanNode>();
+ private LinkedHashMap<PlanNode, PlanNode> joinSourceNodes = new LinkedHashMap<PlanNode, PlanNode>();
- private List dependentCritieraNodes = new ArrayList();
- private List criteriaNodes = new ArrayList();
+ private List<PlanNode> dependentCritieraNodes = new ArrayList<PlanNode>();
+ private List<PlanNode> criteriaNodes = new ArrayList<PlanNode>();
- private List unsatisfiedAccessPatterns = new LinkedList();
+ private List<Collection<AccessPattern>> unsatisfiedAccessPatterns = new LinkedList<Collection<AccessPattern>>();
private Map<ElementSymbol, Set<Collection<GroupSymbol>>> dependentCriteriaElements;
- private Map critieriaToSourceMap;
+ private Map<PlanNode, Set<PlanNode>> critieriaToSourceMap;
public PlanNode getJoinRoot() {
return joinRoot;
}
- public List getUnsatisfiedAccessPatterns() {
+ public List<Collection<AccessPattern>> getUnsatisfiedAccessPatterns() {
return unsatisfiedAccessPatterns;
}
- public Map getJoinSourceNodes() {
+ public Map<PlanNode, PlanNode> getJoinSourceNodes() {
return joinSourceNodes;
}
- public Map getDependentJoinSourceNodes() {
+ public Map<PlanNode, PlanNode> getDependentJoinSourceNodes() {
return dependentJoinSourceNodes;
}
@@ -104,7 +104,7 @@
return criteriaNodes;
}
- public List getDependentCriteriaNodes() {
+ public List<PlanNode> getDependentCriteriaNodes() {
return dependentCritieraNodes;
}
@@ -112,7 +112,7 @@
return this.dependentCriteriaElements;
}
- public Map getCritieriaToSourceMap() {
+ public Map<PlanNode, Set<PlanNode>> getCritieriaToSourceMap() {
return this.critieriaToSourceMap;
}
@@ -122,7 +122,7 @@
root = root.getParent();
}
if (sourceNode.hasCollectionProperty(NodeConstants.Info.ACCESS_PATTERNS)) {
- Collection aps = (Collection)sourceNode.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
+ Collection<AccessPattern> aps = (Collection<AccessPattern>)sourceNode.getProperty(NodeConstants.Info.ACCESS_PATTERNS);
unsatisfiedAccessPatterns.add(aps);
dependentJoinSourceNodes.put(sourceNode, root);
} else {
@@ -146,12 +146,11 @@
}
}
- public void addJoinCriteriaList(List joinCriteria) {
+ public void addJoinCriteriaList(List<? extends Criteria> joinCriteria) {
if (joinCriteria == null || joinCriteria.isEmpty()) {
return;
}
- for (Iterator i = joinCriteria.iterator(); i.hasNext();) {
- Criteria crit = (Criteria)i.next();
+ for (Criteria crit : joinCriteria) {
criteriaNodes.add(RelationalPlanner.createSelectNode(crit, false));
}
}
@@ -167,20 +166,19 @@
*
*/
public void reconstructJoinRegoin() {
- LinkedHashMap combined = new LinkedHashMap(joinSourceNodes);
+ LinkedHashMap<PlanNode, PlanNode> combined = new LinkedHashMap<PlanNode, PlanNode>(joinSourceNodes);
combined.putAll(dependentJoinSourceNodes);
PlanNode root = null;
if (combined.size() < 2) {
- root = (PlanNode)combined.values().iterator().next();
+ root = combined.values().iterator().next();
root.removeProperty(NodeConstants.Info.EST_CARDINALITY);
} else {
root = RulePlanJoins.createJoinNode();
- for (Iterator i = combined.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Map.Entry)i.next();
- PlanNode joinSourceRoot = (PlanNode)entry.getValue();
+ for (Map.Entry<PlanNode, PlanNode> entry : combined.entrySet()) {
+ PlanNode joinSourceRoot = entry.getValue();
joinSourceRoot.removeProperty(NodeConstants.Info.EST_CARDINALITY);
if (root.getChildCount() == 2) {
PlanNode parentJoin = RulePlanJoins.createJoinNode();
@@ -189,10 +187,10 @@
root = parentJoin;
}
root.addLastChild(joinSourceRoot);
- root.addGroups(((PlanNode)entry.getKey()).getGroups());
+ root.addGroups(entry.getKey().getGroups());
}
}
- LinkedList criteria = new LinkedList(dependentCritieraNodes);
+ LinkedList<PlanNode> criteria = new LinkedList<PlanNode>(dependentCritieraNodes);
criteria.addAll(criteriaNodes);
PlanNode parent = this.joinRoot.getParent();
@@ -201,9 +199,7 @@
parent.removeChild(joinRoot);
- for (Iterator i = criteria.iterator(); i.hasNext();) {
- PlanNode critNode = (PlanNode)i.next();
-
+ for (PlanNode critNode : criteria) {
critNode.removeFromParent();
critNode.removeAllChildren();
critNode.addFirstChild(root);
@@ -229,24 +225,24 @@
* @return
*/
public double scoreRegion(Object[] joinOrder, QueryMetadataInterface metadata) {
- List joinSourceEntries = new ArrayList(joinSourceNodes.entrySet());
+ List<Map.Entry<PlanNode, PlanNode>> joinSourceEntries = new ArrayList<Map.Entry<PlanNode, PlanNode>>(joinSourceNodes.entrySet());
double totalIntermediatCost = 0;
double cost = 1;
- HashSet criteria = new HashSet(this.criteriaNodes);
- HashSet groups = new HashSet(this.joinSourceNodes.size());
+ HashSet<PlanNode> criteria = new HashSet<PlanNode>(this.criteriaNodes);
+ HashSet<GroupSymbol> groups = new HashSet<GroupSymbol>(this.joinSourceNodes.size());
for (int i = 0; i < joinOrder.length; i++) {
Integer source = (Integer)joinOrder[i];
- Map.Entry entry = (Map.Entry)joinSourceEntries.get(source.intValue());
- PlanNode joinSourceRoot = (PlanNode)entry.getValue();
+ Map.Entry<PlanNode, PlanNode> entry = joinSourceEntries.get(source.intValue());
+ PlanNode joinSourceRoot = entry.getValue();
//check to make sure that this group ordering satisfies the access patterns
if (!this.unsatisfiedAccessPatterns.isEmpty()) {
- PlanNode joinSource = (PlanNode)entry.getKey();
+ PlanNode joinSource = entry.getKey();
- Collection requiredGroups = (Collection)joinSource.getProperty(NodeConstants.Info.REQUIRED_ACCESS_PATTERN_GROUPS);
+ Collection<GroupSymbol> requiredGroups = (Collection<GroupSymbol>)joinSource.getProperty(NodeConstants.Info.REQUIRED_ACCESS_PATTERN_GROUPS);
if (requiredGroups != null && !groups.containsAll(requiredGroups)) {
return Double.MAX_VALUE;
@@ -266,11 +262,9 @@
cost *= sourceCost;
if (!criteria.isEmpty() && i > 0) {
- List applicableCriteria = getJoinCriteriaForGroups(groups, criteria);
+ List<PlanNode> applicableCriteria = getJoinCriteriaForGroups(groups, criteria);
- for (Iterator j = applicableCriteria.iterator(); j.hasNext();) {
- PlanNode criteriaNode = (PlanNode)j.next();
-
+ for (PlanNode criteriaNode : applicableCriteria) {
float filter = ((Float)criteriaNode.getProperty(NodeConstants.Info.EST_SELECTIVITY)).floatValue();
cost *= filter;
@@ -290,15 +284,9 @@
* This does not necessarily mean that a join tree will be successfully created
*/
public boolean isSatisfiable() {
- if (getUnsatisfiedAccessPatterns().isEmpty()) {
- return true;
- }
-
- for (Iterator i = getUnsatisfiedAccessPatterns().iterator(); i.hasNext();) {
- Collection accessPatterns = (Collection)i.next();
+ for (Collection<AccessPattern> accessPatterns : getUnsatisfiedAccessPatterns()) {
boolean matchedAll = false;
- for (Iterator j = accessPatterns.iterator(); j.hasNext();) {
- AccessPattern ap = (AccessPattern)j.next();
+ for (AccessPattern ap : accessPatterns) {
if (dependentCriteriaElements.keySet().containsAll(ap.getUnsatisfied())) {
matchedAll = true;
break;
@@ -313,8 +301,7 @@
}
public void initializeCostingInformation(QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
- for (Iterator i = joinSourceNodes.values().iterator(); i.hasNext();) {
- PlanNode node = (PlanNode)i.next();
+ for (PlanNode node : joinSourceNodes.values()) {
NewCalculateCostUtil.computeCostForTree(node, metadata);
}
@@ -328,9 +315,7 @@
*/
private void estimateCriteriaSelectivity(QueryMetadataInterface metadata) throws QueryMetadataException,
MetaMatrixComponentException {
- for (Iterator i = criteriaNodes.iterator(); i.hasNext();) {
- PlanNode node = (PlanNode)i.next();
-
+ for (PlanNode node : criteriaNodes) {
Criteria crit = (Criteria)node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
float[] baseCosts = new float[] {100, 10000, 1000000};
@@ -355,28 +340,21 @@
* TODO: assumptions are made here about how dependent criteria must look that are a little restrictive
*/
public void initializeJoinInformation() {
- critieriaToSourceMap = new HashMap();
+ critieriaToSourceMap = new HashMap<PlanNode, Set<PlanNode>>();
- LinkedList crits = new LinkedList(criteriaNodes);
+ LinkedList<PlanNode> crits = new LinkedList<PlanNode>(criteriaNodes);
crits.addAll(dependentCritieraNodes);
- LinkedHashMap source = new LinkedHashMap(joinSourceNodes);
+ LinkedHashMap<PlanNode, PlanNode> source = new LinkedHashMap<PlanNode, PlanNode>(joinSourceNodes);
source.putAll(dependentJoinSourceNodes);
- for (Iterator j = crits.iterator(); j.hasNext();) {
- PlanNode critNode = (PlanNode)j.next();
-
- for (Iterator k = critNode.getGroups().iterator(); k.hasNext();) {
-
- GroupSymbol group = (GroupSymbol)k.next();
-
- for (Iterator i = source.keySet().iterator(); i.hasNext();) {
- PlanNode node = (PlanNode)i.next();
-
+ for (PlanNode critNode : crits) {
+ for (GroupSymbol group : critNode.getGroups()) {
+ for (PlanNode node : source.keySet()) {
if (node.getGroups().contains(group)) {
- Set sources = (Set)critieriaToSourceMap.get(critNode);
+ Set<PlanNode> sources = critieriaToSourceMap.get(critNode);
if (sources == null) {
- sources = new HashSet();
+ sources = new HashSet<PlanNode>();
critieriaToSourceMap.put(critNode, sources);
}
sources.add(node);
@@ -390,22 +368,18 @@
return;
}
- Map dependentGroupToSourceMap = new HashMap();
+ Map<GroupSymbol, PlanNode> dependentGroupToSourceMap = new HashMap<GroupSymbol, PlanNode>();
- for (Iterator i = dependentJoinSourceNodes.keySet().iterator(); i.hasNext();) {
- PlanNode node = (PlanNode)i.next();
-
- for (Iterator j = node.getGroups().iterator(); j.hasNext();) {
- GroupSymbol symbol = (GroupSymbol)j.next();
+ for (PlanNode node : dependentJoinSourceNodes.keySet()) {
+ for (GroupSymbol symbol : node.getGroups()) {
dependentGroupToSourceMap.put(symbol, node);
}
}
- for (Iterator i = getCriteriaNodes().iterator(); i.hasNext();) {
- PlanNode node = (PlanNode)i.next();
+ for (Iterator<PlanNode> i = getCriteriaNodes().iterator(); i.hasNext();) {
+ PlanNode node = i.next();
- for (Iterator j = node.getGroups().iterator(); j.hasNext();) {
- GroupSymbol symbol = (GroupSymbol)j.next();
+ for (GroupSymbol symbol : node.getGroups()) {
if (dependentGroupToSourceMap.containsKey(symbol)) {
i.remove();
dependentCritieraNodes.add(node);
@@ -416,8 +390,7 @@
dependentCriteriaElements = new HashMap<ElementSymbol, Set<Collection<GroupSymbol>>>();
- for (Iterator i = dependentCritieraNodes.iterator(); i.hasNext();) {
- PlanNode critNode = (PlanNode)i.next();
+ for (PlanNode critNode : dependentCritieraNodes) {
Criteria crit = (Criteria)critNode.getProperty(NodeConstants.Info.SELECT_CRITERIA);
if(!(crit instanceof CompareCriteria)) {
continue;
@@ -479,17 +452,15 @@
return false;
}
- public List getJoinCriteriaForGroups(Set groups) {
+ public List<PlanNode> getJoinCriteriaForGroups(Set<GroupSymbol> groups) {
return getJoinCriteriaForGroups(groups, getCriteriaNodes());
}
//TODO: this should be better than a linear search
- protected List getJoinCriteriaForGroups(Set groups, Collection nodes) {
- List result = new LinkedList();
+ protected List<PlanNode> getJoinCriteriaForGroups(Set<GroupSymbol> groups, Collection<PlanNode> nodes) {
+ List<PlanNode> result = new LinkedList<PlanNode>();
- for (Iterator i = nodes.iterator(); i.hasNext();) {
- PlanNode critNode = (PlanNode)i.next();
-
+ for (PlanNode critNode : nodes) {
if (groups.containsAll(critNode.getGroups())) {
result.add(critNode);
}
@@ -499,12 +470,12 @@
}
public void changeJoinOrder(Object[] joinOrder) {
- List joinSourceEntries = new ArrayList(joinSourceNodes.entrySet());
+ List<Map.Entry<PlanNode, PlanNode>> joinSourceEntries = new ArrayList<Map.Entry<PlanNode, PlanNode>>(joinSourceNodes.entrySet());
for (int i = 0; i < joinOrder.length; i++) {
Integer source = (Integer)joinOrder[i];
- Map.Entry entry = (Map.Entry)joinSourceEntries.get(source.intValue());
+ Map.Entry<PlanNode, PlanNode> entry = joinSourceEntries.get(source.intValue());
this.joinSourceNodes.remove(entry.getKey());
this.joinSourceNodes.put(entry.getKey(), entry.getValue());
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleAssignOutputElements.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleAssignOutputElements.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleAssignOutputElements.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -46,6 +46,8 @@
import com.metamatrix.query.resolver.util.ResolverUtil;
import com.metamatrix.query.sql.lang.Command;
import com.metamatrix.query.sql.lang.Criteria;
+import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.OrderByItem;
import com.metamatrix.query.sql.lang.StoredProcedure;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.AliasSymbol;
@@ -147,11 +149,11 @@
case NodeConstants.Types.SORT:
if (root.hasBooleanProperty(NodeConstants.Info.UNRELATED_SORT)) {
//add missing sort columns
- List<SingleElementSymbol> elements = (List<SingleElementSymbol>) root.getProperty(NodeConstants.Info.SORT_ORDER);
+ OrderBy elements = (OrderBy) root.getProperty(NodeConstants.Info.SORT_ORDER);
outputElements = new ArrayList<SingleElementSymbol>(outputElements);
- for (SingleElementSymbol singleElementSymbol : elements) {
- if (!outputElements.contains(singleElementSymbol)) {
- outputElements.add(singleElementSymbol);
+ for (OrderByItem item : elements.getOrderByItems()) {
+ if (!outputElements.contains(item.getSymbol())) {
+ outputElements.add(item.getSymbol());
}
}
}
@@ -235,15 +237,15 @@
if (sort == null) {
return outputElements;
}
- List sortOrder = (List)sort.getProperty(NodeConstants.Info.SORT_ORDER);
+ OrderBy sortOrder = (OrderBy)sort.getProperty(NodeConstants.Info.SORT_ORDER);
List<SingleElementSymbol> topCols = FrameUtil.findTopCols(sort);
SymbolMap symbolMap = (SymbolMap)root.getProperty(NodeConstants.Info.SYMBOL_MAP);
List<ElementSymbol> symbolOrder = symbolMap.getKeys();
- for (final Iterator iterator = sortOrder.iterator(); iterator.hasNext();) {
- final Expression expr = (Expression)iterator.next();
+ for (OrderByItem item : sortOrder.getOrderByItems()) {
+ final Expression expr = item.getSymbol();
int index = topCols.indexOf(expr);
ElementSymbol symbol = symbolOrder.get(index);
if (!outputElements.contains(symbol)) {
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -87,24 +87,21 @@
if(nonRelationalPlan != null) {
accessNode.setProperty(NodeConstants.Info.PROCESSOR_PLAN, nonRelationalPlan);
- } else {
- // Create command from access on down and save in access node
- if(command == null) {
- PlanNode commandRoot = accessNode;
- GroupSymbol intoGroup = (GroupSymbol)accessNode.getFirstChild().getProperty(NodeConstants.Info.INTO_GROUP);
- if (intoGroup != null) {
- commandRoot = NodeEditor.findNodePreOrder(accessNode, NodeConstants.Types.SOURCE).getFirstChild();
- }
- plan = removeUnnecessaryInlineView(plan, commandRoot);
- QueryCommand queryCommand = createQuery(metadata, capFinder, accessNode, commandRoot);
- addDistinct(metadata, capFinder, accessNode, queryCommand);
- command = queryCommand;
- if (intoGroup != null) {
- Insert insertCommand = new Insert(intoGroup, ResolverUtil.resolveElementsInGroup(intoGroup, metadata), null);
- insertCommand.setQueryExpression(queryCommand);
- command = insertCommand;
- }
- }
+ } else if(command == null) {
+ PlanNode commandRoot = accessNode;
+ GroupSymbol intoGroup = (GroupSymbol)accessNode.getFirstChild().getProperty(NodeConstants.Info.INTO_GROUP);
+ if (intoGroup != null) {
+ commandRoot = NodeEditor.findNodePreOrder(accessNode, NodeConstants.Types.SOURCE).getFirstChild();
+ }
+ plan = removeUnnecessaryInlineView(plan, commandRoot);
+ QueryCommand queryCommand = createQuery(metadata, capFinder, accessNode, commandRoot);
+ addDistinct(metadata, capFinder, accessNode, queryCommand);
+ command = queryCommand;
+ if (intoGroup != null) {
+ Insert insertCommand = new Insert(intoGroup, ResolverUtil.resolveElementsInGroup(intoGroup, metadata), null);
+ insertCommand.setQueryExpression(queryCommand);
+ command = insertCommand;
+ }
}
accessNode.setProperty(NodeConstants.Info.ATOMIC_REQUEST, command);
accessNode.removeAllChildren();
@@ -417,10 +414,7 @@
}
private void processOrderBy(PlanNode node, QueryCommand query) {
- List params = (List)node.getProperty(NodeConstants.Info.SORT_ORDER);
- List types = (List)node.getProperty(NodeConstants.Info.ORDER_TYPES);
- OrderBy orderBy = new OrderBy(params, types);
- query.setOrderBy(orderBy);
+ query.setOrderBy((OrderBy)node.getProperty(NodeConstants.Info.SORT_ORDER));
}
/**
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -122,10 +121,8 @@
boolean needsCorrection = outputSymbols.size() > oldSize;
- List<Boolean> directions = Collections.nCopies(orderSymbols.size(), OrderBy.ASC);
+ PlanNode sortNode = createSortNode(new ArrayList<SingleElementSymbol>(orderSymbols), outputSymbols);
- PlanNode sortNode = createSortNode(orderSymbols, outputSymbols, directions);
-
if (sourceNode.getType() == NodeConstants.Types.ACCESS) {
if (NewCalculateCostUtil.usesKey(sourceNode, expressions, metadata)) {
joinNode.setProperty(joinNode.getFirstChild() == childNode ? NodeConstants.Info.IS_LEFT_DISTINCT : NodeConstants.Info.IS_RIGHT_DISTINCT, true);
@@ -151,13 +148,11 @@
return false;
}
- private static PlanNode createSortNode(Collection orderSymbols,
- Collection outputElements,
- List directions) {
+ private static PlanNode createSortNode(List<SingleElementSymbol> orderSymbols,
+ Collection outputElements) {
PlanNode sortNode = NodeFactory.getNewNode(NodeConstants.Types.SORT);
- sortNode.setProperty(NodeConstants.Info.SORT_ORDER, new ArrayList(orderSymbols));
+ sortNode.setProperty(NodeConstants.Info.SORT_ORDER, new OrderBy(orderSymbols));
sortNode.setProperty(NodeConstants.Info.OUTPUT_COLS, new ArrayList(outputElements));
- sortNode.setProperty(NodeConstants.Info.ORDER_TYPES, directions);
return sortNode;
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeVirtual.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeVirtual.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeVirtual.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -42,6 +42,8 @@
import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
import com.metamatrix.query.sql.lang.JoinType;
+import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.OrderByItem;
import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.Expression;
import com.metamatrix.query.sql.symbol.Function;
@@ -244,14 +246,12 @@
PlanNode sort = NodeEditor.findParent(parentProject, NodeConstants.Types.SORT, NodeConstants.Types.SOURCE);
if (sort != null) { //special handling is needed since we are retaining the child aliases
List<SingleElementSymbol> childProject = (List<SingleElementSymbol>)NodeEditor.findNodePreOrder(frame, NodeConstants.Types.PROJECT).getProperty(NodeConstants.Info.PROJECT_COLS);
- List<SingleElementSymbol> elements = (List<SingleElementSymbol>)sort.getProperty(NodeConstants.Info.SORT_ORDER);
- List<SingleElementSymbol> newElements = new ArrayList<SingleElementSymbol>(elements.size());
- for (SingleElementSymbol singleElementSymbol : elements) {
- newElements.add(childProject.get(selectSymbols.indexOf(singleElementSymbol)));
+ OrderBy elements = (OrderBy)sort.getProperty(NodeConstants.Info.SORT_ORDER);
+ for (OrderByItem item : elements.getOrderByItems()) {
+ item.setSymbol(childProject.get(selectSymbols.indexOf(item.getSymbol())));
}
- sort.setProperty(NodeConstants.Info.SORT_ORDER, newElements);
sort.getGroups().clear();
- sort.addGroups(GroupsUsedByElementsVisitor.getGroups(newElements));
+ sort.addGroups(GroupsUsedByElementsVisitor.getGroups(elements));
}
prepareFrame(frame);
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanSorts.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanSorts.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanSorts.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -38,7 +38,9 @@
import com.metamatrix.query.optimizer.relational.plantree.NodeConstants.Info;
import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
import com.metamatrix.query.processor.relational.MergeJoinStrategy.SortOption;
+import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.lang.SetQuery;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.util.CommandContext;
/**
@@ -74,7 +76,7 @@
if (mergeSortWithDupRemoval(node)) {
node.setProperty(NodeConstants.Info.IS_DUP_REMOVAL, true);
}
- List orderColumns = (List)node.getProperty(NodeConstants.Info.SORT_ORDER);
+ List<SingleElementSymbol> orderColumns = ((OrderBy)node.getProperty(NodeConstants.Info.SORT_ORDER)).getSortKeys();
PlanNode possibleSort = NodeEditor.findNodePreOrder(node, NodeConstants.Types.GROUP, NodeConstants.Types.SOURCE | NodeConstants.Types.ACCESS);
if (possibleSort != null) {
List exprs = (List)possibleSort.getProperty(Info.GROUP_COLS);
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -58,10 +58,12 @@
import com.metamatrix.query.resolver.util.ResolverVisitor;
import com.metamatrix.query.rewriter.QueryRewriter;
import com.metamatrix.query.sql.ReservedWords;
+import com.metamatrix.query.sql.LanguageObject.Util;
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.IsNullCriteria;
import com.metamatrix.query.sql.lang.JoinType;
+import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.lang.Select;
import com.metamatrix.query.sql.lang.SetQuery.Operation;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
@@ -294,8 +296,10 @@
//branches other than the first need to have their projected column names updated
PlanNode sortNode = NodeEditor.findNodePreOrder(unionSource, NodeConstants.Types.SORT, NodeConstants.Types.SOURCE);
List<SingleElementSymbol> sortOrder = null;
+ OrderBy orderBy = null;
if (sortNode != null) {
- sortOrder = (List<SingleElementSymbol>)sortNode.getProperty(Info.SORT_ORDER);
+ orderBy = (OrderBy)sortNode.getProperty(Info.SORT_ORDER);
+ sortOrder = orderBy.getSortKeys();
}
List<SingleElementSymbol> projectCols = FrameUtil.findTopCols(unionSource);
for (int i = 0; i < virtualElements.size(); i++) {
@@ -306,6 +310,7 @@
int sortIndex = sortOrder.indexOf(projectedSymbol);
if (sortIndex > -1) {
updateSymbolName(sortOrder, sortIndex, virtualElem, sortOrder.get(sortIndex));
+ orderBy.getOrderByItems().get(sortIndex).setSymbol(sortOrder.get(sortIndex));
}
}
updateSymbolName(projectCols, i, virtualElem, projectedSymbol);
@@ -336,7 +341,7 @@
}
}
- List<SingleElementSymbol> projectedViewSymbols = QueryRewriter.deepClone(projectedSymbols, SingleElementSymbol.class);
+ List<SingleElementSymbol> projectedViewSymbols = Util.deepClone(projectedSymbols, SingleElementSymbol.class);
SymbolMap viewMapping = SymbolMap.createSymbolMap(NodeEditor.findParent(unionSource, NodeConstants.Types.SOURCE).getGroups().iterator().next(), projectedSymbols, metadata);
for (AggregateSymbol agg : aggregates) {
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -47,6 +47,7 @@
import com.metamatrix.query.sql.lang.CompareCriteria;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.JoinType;
+import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.lang.SetQuery.Operation;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -255,9 +256,9 @@
return false;
}
- List sortCols = (List)parentNode.getProperty(NodeConstants.Info.SORT_ORDER);
- for (int i = 0; i < sortCols.size(); i++) {
- SingleElementSymbol symbol = (SingleElementSymbol)sortCols.get(i);
+ //TODO: this check shouldn't be necessary, since the order by is not introducing new expressions
+ List<SingleElementSymbol> sortCols = ((OrderBy)parentNode.getProperty(NodeConstants.Info.SORT_ORDER)).getSortKeys();
+ for (SingleElementSymbol symbol : sortCols) {
if(! canPushSymbol(symbol, true, modelID, metadata, capFinder)) {
return false;
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseNull.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseNull.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseNull.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -40,6 +40,8 @@
import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
import com.metamatrix.query.sql.lang.JoinType;
+import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.OrderByItem;
import com.metamatrix.query.sql.lang.SetQuery;
import com.metamatrix.query.sql.symbol.AliasSymbol;
import com.metamatrix.query.sql.symbol.ExpressionSymbol;
@@ -159,11 +161,11 @@
PlanNode sort = NodeEditor.findParent(firstProject, NodeConstants.Types.SORT, NodeConstants.Types.SOURCE);
if (sort != null) { //correct the sort to the new columns as well
- List<SingleElementSymbol> sortOrder = (List<SingleElementSymbol>)sort.getProperty(NodeConstants.Info.SORT_ORDER);
- for (int i = 0; i < sortOrder.size(); i++) {
- SingleElementSymbol sortElement = sortOrder.get(i);
+ OrderBy sortOrder = (OrderBy)sort.getProperty(NodeConstants.Info.SORT_ORDER);
+ for (OrderByItem item : sortOrder.getOrderByItems()) {
+ SingleElementSymbol sortElement = item.getSymbol();
sortElement = newProjectSymbols.get(oldProjectSymbols.indexOf(sortElement));
- sortOrder.set(i, sortElement);
+ item.setSymbol(sortElement);
}
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -45,6 +45,7 @@
import com.metamatrix.query.sql.ReservedWords;
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.JoinType;
+import com.metamatrix.query.sql.lang.OrderBy;
import com.metamatrix.query.sql.symbol.AggregateSymbol;
import com.metamatrix.query.sql.symbol.Constant;
import com.metamatrix.query.sql.symbol.ElementSymbol;
@@ -163,7 +164,7 @@
case NodeConstants.Types.SORT:
{
if (elements != null) {
- List sortOrder = (List)node.getProperty(NodeConstants.Info.SORT_ORDER);
+ OrderBy sortOrder = (OrderBy)node.getProperty(NodeConstants.Info.SORT_ORDER);
ElementCollectorVisitor.getElements(sortOrder, elements);
}
break;
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -305,7 +305,7 @@
return;
}
- List elements = orderBy.getVariables();
+ List elements = orderBy.getSortKeys();
List types = orderBy.getTypes();
for (int i = 0; i< elements.size(); i++) {
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/processor/proc/AbstractAssignmentInstruction.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -104,7 +104,7 @@
clone.setVariable(this.variable);
clone.setExpression(this.expression);
if (processPlan != null) {
- clone.setProcessPlan((ProcessorPlan)getProcessPlan().clone());
+ clone.setProcessPlan(getProcessPlan().clone());
}
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -138,7 +138,7 @@
* @return True if the ORDER BY contains the element
*/
public static boolean orderByContainsVariable(OrderBy orderBy, SingleElementSymbol ses, int position) {
- for (final Iterator iterator = orderBy.getVariables().iterator(); iterator.hasNext();) {
+ for (final Iterator iterator = orderBy.getSortKeys().iterator(); iterator.hasNext();) {
final ElementSymbol element = (ElementSymbol)iterator.next();
if (position == ((TempMetadataID)element.getMetadataID()).getPosition()) {
return true;
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -346,15 +346,12 @@
for (int i = 0; i < orderBy.getVariableCount(); i++) {
SingleElementSymbol sortKey = orderBy.getVariable(i);
if (sortKey instanceof ElementSymbol) {
- int index = resolveSortKey(orderBy, fromClauseGroups, knownElements, metadata,
- isSimpleQuery, knownShortNames, (ElementSymbol)sortKey);
+ int index = resolveSortKey(fromClauseGroups, knownElements, metadata, isSimpleQuery,
+ knownShortNames, (ElementSymbol)sortKey);
if (index == -1) {
index = expressions.indexOf(SymbolMap.getExpression(sortKey));
}
orderBy.setExpressionPosition(i, index);
- if (index == -1) {
- orderBy.addUnrelated((ElementSymbol)sortKey);
- }
continue;
} else if (sortKey instanceof ExpressionSymbol) {
// check for legacy positional
@@ -367,6 +364,7 @@
throw new QueryResolverException(QueryPlugin.Util.getString("SQLParser.non_position_constant", c)); //$NON-NLS-1$
}
orderBy.setExpressionPosition(i, elementOrder - 1);
+ continue;
}
}
//handle order by expressions
@@ -374,24 +372,18 @@
throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.setquery_order_expression", sortKey)); //$NON-NLS-1$
}
for (ElementSymbol symbol : ElementCollectorVisitor.getElements(sortKey, false)) {
- resolveSortKey(orderBy, fromClauseGroups, knownElements, metadata,
- isSimpleQuery, knownShortNames, symbol);
+ resolveSortKey(fromClauseGroups, null, metadata, isSimpleQuery, null, symbol);
}
ResolverVisitor.resolveLanguageObject(sortKey, metadata);
- int index = expressions.indexOf(SymbolMap.getExpression(sortKey));
- if (index != -1) {
- //the query is using an derived column, but not through an alias
- orderBy.setExpressionPosition(i, index);
- }
- //must be an unrelated sort expression
+ int index = expressions.indexOf(SymbolMap.getExpression(sortKey));
+ orderBy.setExpressionPosition(i, index);
}
}
- private static int resolveSortKey(OrderBy orderBy, List fromClauseGroups,
- List knownElements, QueryMetadataInterface metadata,
- boolean isSimpleQuery, String[] knownShortNames,
- ElementSymbol symbol) throws MetaMatrixComponentException,
+ private static int resolveSortKey(List fromClauseGroups, List knownElements,
+ QueryMetadataInterface metadata, boolean isSimpleQuery,
+ String[] knownShortNames, ElementSymbol symbol) throws MetaMatrixComponentException,
QueryMetadataException, QueryResolverException {
SingleElementSymbol matchedSymbol = null;
String symbolName = symbol.getName();
@@ -403,38 +395,40 @@
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0043, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0043, symbolName));
}
- // walk the SELECT col short names, looking for a match on the current ORDER BY 'short name'
- for(int i=0; i<knownShortNames.length; i++) {
- if( shortName.equalsIgnoreCase( knownShortNames[i] )) {
- if (groupPart != null) {
- Object knownSymbol = knownElements.get(i);
- if(knownSymbol instanceof ElementSymbol) {
- ElementSymbol knownElement = (ElementSymbol) knownSymbol;
- GroupSymbol group = knownElement.getGroupSymbol();
-
- // skip this one if the two short names are not from the same group
- if (!nameMatchesGroup(groupPart.toUpperCase(), group.getCanonicalName())) {
- continue;
- }
- }
- }
-
- // if we already have a matched symbol, matching again here means it is duplicate/ambiguous
- if(matchedSymbol != null) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0042, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0042, symbolName));
- }
- matchedSymbol = (SingleElementSymbol)knownElements.get(i);
- }
+ if (knownShortNames != null) {
+ // walk the SELECT col short names, looking for a match on the current ORDER BY 'short name'
+ for(int i=0; i<knownShortNames.length; i++) {
+ if( shortName.equalsIgnoreCase( knownShortNames[i] )) {
+ if (groupPart != null) {
+ Object knownSymbol = knownElements.get(i);
+ if(knownSymbol instanceof ElementSymbol) {
+ ElementSymbol knownElement = (ElementSymbol) knownSymbol;
+ GroupSymbol group = knownElement.getGroupSymbol();
+
+ // skip this one if the two short names are not from the same group
+ if (!nameMatchesGroup(groupPart.toUpperCase(), group.getCanonicalName())) {
+ continue;
+ }
+ }
+ }
+
+ // if we already have a matched symbol, matching again here means it is duplicate/ambiguous
+ if(matchedSymbol != null) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0042, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0042, symbolName));
+ }
+ matchedSymbol = (SingleElementSymbol)knownElements.get(i);
+ }
+ }
+ if (matchedSymbol != null) {
+ TempMetadataID tempMetadataID = new TempMetadataID(symbol.getName(), matchedSymbol.getType());
+ int position = knownElements.indexOf(matchedSymbol);
+ tempMetadataID.setPosition(position);
+ symbol.setMetadataID(tempMetadataID);
+ symbol.setType(matchedSymbol.getType());
+ return position;
+ }
}
- if (matchedSymbol != null) {
- TempMetadataID tempMetadataID = new TempMetadataID(symbol.getName(), matchedSymbol.getType());
- int position = knownElements.indexOf(matchedSymbol);
- tempMetadataID.setPosition(position);
- symbol.setMetadataID(tempMetadataID);
- symbol.setType(matchedSymbol.getType());
- return position;
- }
if (!isSimpleQuery) {
throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.invalid_unrelated", symbol.getName())); //$NON-NLS-1$
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -35,6 +35,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -71,6 +72,7 @@
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.ProcedureReservedWords;
import com.metamatrix.query.sql.ReservedWords;
+import com.metamatrix.query.sql.LanguageObject.Util;
import com.metamatrix.query.sql.lang.AbstractSetCriteria;
import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
import com.metamatrix.query.sql.lang.BetweenCriteria;
@@ -93,6 +95,7 @@
import com.metamatrix.query.sql.lang.MatchCriteria;
import com.metamatrix.query.sql.lang.NotCriteria;
import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.OrderByItem;
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.QueryCommand;
import com.metamatrix.query.sql.lang.SPParameter;
@@ -135,7 +138,6 @@
import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.symbol.ScalarSubquery;
import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SelectSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.util.ValueIterator;
@@ -794,19 +796,21 @@
boolean hasUnrelatedExpression = false;
+ LinkedList<OrderByItem> unrelatedItems = new LinkedList<OrderByItem>();
for (int i = 0; i < orderBy.getVariableCount(); i++) {
SingleElementSymbol querySymbol = orderBy.getVariable(i);
int index = orderBy.getExpressionPosition(i);
if (index == -1) {
+ unrelatedItems.add(orderBy.getOrderByItems().get(i));
hasUnrelatedExpression |= (querySymbol instanceof ExpressionSymbol);
- continue; // must be unrelated - but potentially contains references to the select clause
+ continue; // must be unrelated
}
querySymbol = (SingleElementSymbol)projectedSymbols.get(index);
Expression expr = SymbolMap.getExpression(querySymbol);
if (!previousExpressions.add(expr) || (queryCommand instanceof Query && EvaluatableVisitor.isFullyEvaluatable(expr, true))) {
orderBy.removeOrderByItem(i--);
} else {
- orderBy.getVariables().set(i, querySymbol.clone());
+ orderBy.getOrderByItems().get(i).setSymbol((SingleElementSymbol)querySymbol.clone());
}
}
@@ -822,7 +826,9 @@
int originalSymbolCount = select.getProjectedSymbols().size();
//add unrelated to select
- select.addSymbols(orderBy.getUnrelated());
+ for (OrderByItem orderByItem : unrelatedItems) {
+ select.addSymbol(orderByItem.getSymbol());
+ }
makeSelectUnique(select, false);
Query query = queryCommand.getProjectedQuery();
@@ -836,8 +842,8 @@
Query top = null;
try {
- Query intermediate = createInlineViewQuery(new GroupSymbol("X"), query, metadata, select.getProjectedSymbols()); //$NON-NLS-1$
- Iterator iter = intermediate.getSelect().getProjectedSymbols().iterator();
+ top = createInlineViewQuery(new GroupSymbol("X"), query, metadata, select.getProjectedSymbols()); //$NON-NLS-1$
+ Iterator iter = top.getSelect().getProjectedSymbols().iterator();
HashMap<Expression, SingleElementSymbol> expressionMap = new HashMap<Expression, SingleElementSymbol>();
for (SingleElementSymbol symbol : (List<SingleElementSymbol>)select.getProjectedSymbols()) {
SingleElementSymbol ses = (SingleElementSymbol)iter.next();
@@ -845,22 +851,6 @@
expressionMap.put(new ElementSymbol(symbol.getName()), ses);
}
ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap);
- for (int i = 0; i < orderBy.getVariableCount(); i++) {
- int index = orderBy.getExpressionPosition(i);
- SingleElementSymbol ss = orderBy.getVariable(i);
- if (index == -1 && !(ss instanceof ElementSymbol)) {
- intermediate.getSelect().addSymbol((SelectSymbol)ss.clone());
- }
- }
- makeSelectUnique(intermediate.getSelect(), true);
-
- top = createInlineViewQuery(new GroupSymbol("Y"), intermediate, metadata, intermediate.getSelect().getProjectedSymbols()); //$NON-NLS-1$
- iter = top.getSelect().getProjectedSymbols().iterator();
- expressionMap = new HashMap<Expression, SingleElementSymbol>();
- for (SingleElementSymbol symbol : (List<SingleElementSymbol>)intermediate.getSelect().getProjectedSymbols()) {
- expressionMap.put(SymbolMap.getExpression(symbol), (SingleElementSymbol)iter.next());
- }
- ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap);
//now the order by should only contain element symbols
} catch (QueryResolverException e) {
throw new QueryValidatorException(e, e.getMessage());
@@ -869,12 +859,7 @@
} catch (MetaMatrixComponentException e) {
throw new QueryValidatorException(e, e.getMessage());
}
- //filter back out the unrelated
- orderBy.getUnrelated().clear();
List symbols = top.getSelect().getSymbols();
- for (ElementSymbol symbol : (List<ElementSymbol>)symbols.subList(originalSymbolCount, symbols.size())) {
- orderBy.addUnrelated(symbol);
- }
top.getSelect().setSymbols(symbols.subList(0, originalSymbolCount));
top.setInto(into);
top.setLimit(limit);
@@ -892,7 +877,7 @@
private Insert rewriteSelectInto(Query query) throws QueryValidatorException {
Into into = query.getInto();
try {
- List<ElementSymbol> allIntoElements = deepClone(ResolverUtil.resolveElementsInGroup(into.getGroup(), metadata), ElementSymbol.class);
+ List<ElementSymbol> allIntoElements = Util.deepClone(ResolverUtil.resolveElementsInGroup(into.getGroup(), metadata), ElementSymbol.class);
Insert insert = new Insert(into.getGroup(), allIntoElements, Collections.emptyList());
query.setInto(null);
insert.setQueryExpression(query);
@@ -2401,14 +2386,6 @@
return query;
}
- public static <S extends Expression, T extends S> List<S> deepClone(List<T> collection, Class<S> clazz) {
- ArrayList<S> result = new ArrayList<S>(collection.size());
- for (Expression expression : collection) {
- result.add((S)expression.clone());
- }
- return result;
- }
-
public static void makeSelectUnique(Select select, boolean expressionSymbolsOnly) {
select.setSymbols(select.getProjectedSymbols());
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/LanguageObject.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/LanguageObject.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/LanguageObject.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -23,6 +23,8 @@
package com.metamatrix.query.sql;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
/**
* This is the primary interface for all language objects. It extends a few
@@ -43,5 +45,17 @@
* @return Deep clone of this object
*/
Object clone();
+
+ public static class Util {
+
+ public static <S extends LanguageObject, T extends S> ArrayList<S> deepClone(List<T> collection, Class<S> type) {
+ ArrayList<S> result = new ArrayList<S>(collection.size());
+ for (LanguageObject obj : collection) {
+ result.add(type.cast(obj.clone()));
+ }
+ return result;
+ }
+
+ }
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/LanguageVisitor.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/LanguageVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/LanguageVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -125,4 +125,5 @@
public void visit(ProcedureContainer obj) {}
public void visit(SetClauseList obj) {}
public void visit(SetClause obj) {}
+ public void visit(OrderByItem obj) {}
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/OrderBy.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/OrderBy.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/OrderBy.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -23,22 +23,15 @@
package com.metamatrix.query.sql.lang;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import java.util.Set;
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.QueryPlugin;
import com.metamatrix.query.sql.LanguageObject;
import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* Represents the ORDER BY clause of a query. The ORDER BY clause states
@@ -55,42 +48,34 @@
/** Constant for the descending value */
public static final boolean DESC = false;
- private List sortOrder;
- private List orderTypes;
+ private List<OrderByItem> orderByItems = new ArrayList<OrderByItem>();
+
/**
- * set by the resolver to contain element symbol references
- * outside of the select clause
- */
- private Set<ElementSymbol> unrelated;
- private List<Integer> expressionPositions;
- /**
* Constructs a default instance of this class.
*/
public OrderBy() {
- sortOrder = new ArrayList();
- orderTypes = new ArrayList();
}
/**
- * Constructs an instance of this class from an ordered set of elements.
+ * Constructs an instance of this class from an ordered list of elements.
* @param parameters The ordered list of SingleElementSymbol
*/
- public OrderBy( List parameters ) {
- sortOrder = new ArrayList( parameters );
- orderTypes = new ArrayList(parameters.size());
- for( int i=0; i< parameters.size(); i++) {
- orderTypes.add(Boolean.TRUE);
- }
+ public OrderBy( List<? extends SingleElementSymbol> parameters ) {
+ for (SingleElementSymbol singleElementSymbol : parameters) {
+ orderByItems.add(new OrderByItem(singleElementSymbol, ASC));
+ }
}
-
+
/**
* Constructs an instance of this class from an ordered set of elements.
* @param parameters The ordered list of SingleElementSymbol
* @param types The list of directions by which the results are ordered (Boolean, true=ascending)
*/
- public OrderBy( List parameters, List types ) {
- sortOrder = new ArrayList( parameters );
- orderTypes = new ArrayList( types );
+ public OrderBy( List<? extends SingleElementSymbol> parameters, List<Boolean> types ) {
+ Iterator<Boolean> typeIter = types.iterator();
+ for (SingleElementSymbol singleElementSymbol : parameters) {
+ orderByItems.add(new OrderByItem(singleElementSymbol, typeIter.next()));
+ }
}
// =========================================================================
@@ -101,32 +86,20 @@
* @return Number of variables in ORDER BY
*/
public int getVariableCount() {
- return sortOrder.size();
+ return orderByItems.size();
}
-
- /**
- * Returns an ordered list of the symbols in ORDER BY
- * @param List of SingleElementSymbol in ORDER BY
- */
- public List getVariables() {
- return sortOrder;
+
+ public List<OrderByItem> getOrderByItems() {
+ return this.orderByItems;
}
/**
- * Returns an ordered list of sort direction for each order.
- * @param List of Boolean, Boolean.TRUE represents ascending
- */
- public List getTypes() {
- return orderTypes;
- }
-
- /**
* Returns the ORDER BY element at the specified index.
* @param index Index to get
* @return The element at the index
*/
public SingleElementSymbol getVariable( int index ) {
- return (SingleElementSymbol)sortOrder.get(index);
+ return orderByItems.get(index).getSymbol();
}
/**
@@ -135,7 +108,7 @@
* @return The sort order at the index
*/
public Boolean getOrderType( int index ) {
- return (Boolean)orderTypes.get(index);
+ return orderByItems.get(index).isAscending();
}
/**
@@ -143,10 +116,7 @@
* @param element Element to add
*/
public void addVariable( SingleElementSymbol element ) {
- if(element != null) {
- sortOrder.add(element);
- orderTypes.add(Boolean.valueOf(ASC));
- }
+ addVariable(element, ASC);
}
/**
@@ -157,28 +127,10 @@
*/
public void addVariable( SingleElementSymbol element, boolean type ) {
if(element != null) {
- sortOrder.add(element);
- orderTypes.add(Boolean.valueOf(type));
+ orderByItems.add(new OrderByItem(element, type));
}
}
- /**
- * Sets a new collection of variables to be used. The replacement
- * set must be of the same size as the previous set.
- * @param elements Collection of SingleElementSymbol
- * @throws IllegalArgumentException if element is null or size of elements != size of existing elements
- */
- public void replaceVariables( Collection elements ) {
- if(elements == null) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0004));
- }
- if(elements.size() != sortOrder.size()) {
- throw new IllegalArgumentException(QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0005));
- }
-
- sortOrder = new ArrayList(elements);
- }
-
public void acceptVisitor(LanguageVisitor visitor) {
visitor.visit(this);
}
@@ -190,26 +142,10 @@
/**
* Return deep copy of this ORDER BY clause.
*/
- public Object clone() {
- List thisSymbols = getVariables();
- List copySymbols = new ArrayList(thisSymbols.size());
- Iterator iter = thisSymbols.iterator();
- while(iter.hasNext()) {
- SingleElementSymbol ses = (SingleElementSymbol) iter.next();
- copySymbols.add(ses.clone());
- }
- OrderBy result = new OrderBy(copySymbols, getTypes());
- if (this.unrelated != null) {
- HashSet<ElementSymbol> copyUnrelated = new HashSet<ElementSymbol>();
- for (ElementSymbol elementSymbol : this.unrelated) {
- copyUnrelated.add((ElementSymbol)elementSymbol.clone());
- }
- result.unrelated = copyUnrelated;
- }
- if (this.expressionPositions != null) {
- result.expressionPositions = new ArrayList<Integer>(expressionPositions);
- }
- return result;
+ public OrderBy clone() {
+ OrderBy clone = new OrderBy();
+ clone.orderByItems = LanguageObject.Util.deepClone(this.orderByItems, OrderByItem.class);
+ return clone;
}
/**
@@ -228,8 +164,7 @@
}
OrderBy other = (OrderBy) obj;
- return EquivalenceUtil.areEqual(getVariables(), other.getVariables()) &&
- EquivalenceUtil.areEqual(getTypes(), other.getTypes());
+ return EquivalenceUtil.areEqual(orderByItems, other.orderByItems);
}
/**
@@ -240,10 +175,7 @@
* @return Hash code
*/
public int hashCode() {
- int hc = 0;
- hc = HashCodeUtil.hashCode(0, getVariables());
- hc = HashCodeUtil.hashCode(hc, getTypes());
- return hc;
+ return HashCodeUtil.hashCode(0, orderByItems);
}
/**
@@ -254,42 +186,45 @@
return SQLStringVisitor.getSQLString(this);
}
- public boolean hasUnrelated() {
- return this.unrelated != null;
- }
-
- public void addUnrelated(ElementSymbol symbol) {
- if (this.unrelated == null) {
- this.unrelated = new HashSet<ElementSymbol>();
- }
- this.unrelated.add(symbol);
- }
-
- public Set<ElementSymbol> getUnrelated() {
- if (this.unrelated == null) {
- return Collections.emptySet();
- }
- return unrelated;
- }
-
public void setExpressionPosition(int orderIndex, int selectIndex) {
- if (this.expressionPositions == null) {
- this.expressionPositions = new ArrayList<Integer>(Collections.nCopies(sortOrder.size(), -1));
- }
- this.expressionPositions.set(orderIndex, selectIndex);
+ this.orderByItems.get(orderIndex).setExpressionPosition(selectIndex);
}
public int getExpressionPosition(int orderIndex) {
- if (expressionPositions == null) {
- return -1;
- }
- return expressionPositions.get(orderIndex);
+ return this.orderByItems.get(orderIndex).getExpressionPosition();
}
public void removeOrderByItem(int index) {
- sortOrder.remove(index);
- orderTypes.remove(index);
- expressionPositions.remove(index);
+ this.orderByItems.remove(index);
}
+ public boolean hasUnrelated() {
+ for (OrderByItem item : orderByItems) {
+ if (item.isUnrelated()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get the list or sort key symbols. Modifications to this list will not add or remove {@link OrderByItem}s.
+ * @return
+ */
+ public List<SingleElementSymbol> getSortKeys() {
+ ArrayList<SingleElementSymbol> result = new ArrayList<SingleElementSymbol>(orderByItems.size());
+ for (OrderByItem item : orderByItems) {
+ result.add(item.getSymbol());
+ }
+ return result;
+ }
+
+ public List<Boolean> getTypes() {
+ ArrayList<Boolean> result = new ArrayList<Boolean>(orderByItems.size());
+ for (OrderByItem item : orderByItems) {
+ result.add(item.isAscending());
+ }
+ return result;
+ }
+
}
Copied: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/OrderByItem.java (from rev 1879, trunk/engine/src/main/java/com/metamatrix/query/sql/lang/OrderByItem.java)
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/OrderByItem.java (rev 0)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/lang/OrderByItem.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -0,0 +1,109 @@
+/*
+ * 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.query.sql.lang;
+
+import com.metamatrix.query.sql.LanguageObject;
+import com.metamatrix.query.sql.LanguageVisitor;
+import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+
+public class OrderByItem implements LanguageObject {
+
+ private static final long serialVersionUID = 6937561370697819126L;
+
+ private Integer expressionPosition; //set during resolving to the select clause position
+ private boolean ascending = true;
+ private SingleElementSymbol symbol;
+
+ public OrderByItem(SingleElementSymbol symbol, boolean ascending) {
+ this.symbol = symbol;
+ this.ascending = ascending;
+ }
+
+ public int getExpressionPosition() {
+ return expressionPosition == null?-1:expressionPosition;
+ }
+
+ public void setExpressionPosition(int expressionPosition) {
+ this.expressionPosition = expressionPosition;
+ }
+
+ public boolean isAscending() {
+ return ascending;
+ }
+
+ public void setAscending(boolean ascending) {
+ this.ascending = ascending;
+ }
+
+ public SingleElementSymbol getSymbol() {
+ return symbol;
+ }
+
+ public void setSymbol(SingleElementSymbol symbol) {
+ this.symbol = symbol;
+ }
+
+ /**
+ *
+ * @return true if the expression does not appear in the select clause
+ */
+ public boolean isUnrelated() {
+ return expressionPosition != null && expressionPosition == -1;
+ }
+
+ @Override
+ public void acceptVisitor(LanguageVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ @Override
+ public OrderByItem clone() {
+ OrderByItem clone = new OrderByItem((SingleElementSymbol)this.symbol.clone(), ascending);
+ clone.expressionPosition = this.expressionPosition;
+ return clone;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ }
+ if (!(obj instanceof OrderByItem)) {
+ return false;
+ }
+ OrderByItem o = (OrderByItem)obj;
+ return o.symbol.equals(symbol) && o.ascending == this.ascending;
+ }
+
+ @Override
+ public int hashCode() {
+ return symbol.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return SQLStringVisitor.getSQLString(this);
+ }
+
+}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/navigator/PreOrPostOrderNavigator.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/navigator/PreOrPostOrderNavigator.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/navigator/PreOrPostOrderNavigator.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -49,6 +49,7 @@
import com.metamatrix.query.sql.lang.NotCriteria;
import com.metamatrix.query.sql.lang.Option;
import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.OrderByItem;
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.SPParameter;
import com.metamatrix.query.sql.lang.Select;
@@ -350,9 +351,15 @@
}
public void visit(OrderBy obj) {
preVisitVisitor(obj);
- visitNodes(obj.getVariables());
+ visitNodes(obj.getOrderByItems());
postVisitVisitor(obj);
}
+ @Override
+ public void visit(OrderByItem obj) {
+ preVisitVisitor(obj);
+ visitNode(obj.getSymbol());
+ postVisitVisitor(obj);
+ }
public void visit(Query obj) {
preVisitVisitor(obj);
visitNode(obj.getSelect());
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -41,7 +41,7 @@
import com.metamatrix.query.sql.lang.IsNullCriteria;
import com.metamatrix.query.sql.lang.Limit;
import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.OrderByItem;
import com.metamatrix.query.sql.lang.SPParameter;
import com.metamatrix.query.sql.lang.Select;
import com.metamatrix.query.sql.lang.SetClause;
@@ -90,29 +90,35 @@
if (symbol instanceof SingleElementSymbol) {
SingleElementSymbol ses = (SingleElementSymbol)symbol;
- SingleElementSymbol replacmentSymbol = null;
-
- Expression expr = ses;
- if (ses instanceof ExpressionSymbol && !(ses instanceof AggregateSymbol)) {
- expr = ((ExpressionSymbol)ses).getExpression();
- }
+ SingleElementSymbol replacmentSymbol = replaceSymbol(ses, alias);
- Expression replacement = replaceExpression(expr);
-
- if (replacement instanceof SingleElementSymbol) {
- replacmentSymbol = (SingleElementSymbol)replacement;
- } else {
- replacmentSymbol = new ExpressionSymbol(ses.getName(), replacement);
- }
-
- if (alias && createAliases() && !replacmentSymbol.getShortCanonicalName().equals(ses.getShortCanonicalName())) {
- replacmentSymbol = new AliasSymbol(ses.getShortName(), replacmentSymbol);
- }
-
symbols.set(i, replacmentSymbol);
}
}
}
+
+ private SingleElementSymbol replaceSymbol(SingleElementSymbol ses,
+ boolean alias) {
+ SingleElementSymbol replacmentSymbol = null;
+
+ Expression expr = ses;
+ if (ses instanceof ExpressionSymbol && !(ses instanceof AggregateSymbol)) {
+ expr = ((ExpressionSymbol)ses).getExpression();
+ }
+
+ Expression replacement = replaceExpression(expr);
+
+ if (replacement instanceof SingleElementSymbol) {
+ replacmentSymbol = (SingleElementSymbol)replacement;
+ } else {
+ replacmentSymbol = new ExpressionSymbol(ses.getName(), replacement);
+ }
+
+ if (alias && createAliases() && !replacmentSymbol.getShortCanonicalName().equals(ses.getShortCanonicalName())) {
+ replacmentSymbol = new AliasSymbol(ses.getShortName(), replacmentSymbol);
+ }
+ return replacmentSymbol;
+ }
/**
* @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.symbol.AliasSymbol)
@@ -265,12 +271,9 @@
replaceSymbols(obj.getSymbols(), false);
}
- /**
- * Swap each SingleElementSymbol in OrderBy (other symbols are ignored).
- * @param obj Object to remap
- */
- public void visit(OrderBy obj) {
- replaceSymbols(obj.getVariables(), true);
+ @Override
+ public void visit(OrderByItem obj) {
+ obj.setSymbol(replaceSymbol(obj.getSymbol(), true));
}
public void visit(Limit obj) {
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -58,6 +58,7 @@
import com.metamatrix.query.sql.lang.NotCriteria;
import com.metamatrix.query.sql.lang.Option;
import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.OrderByItem;
import com.metamatrix.query.sql.lang.PredicateCriteria;
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.QueryCommand;
@@ -697,29 +698,28 @@
parts.add(SPACE);
parts.add(ReservedWords.BY);
parts.add(SPACE);
-
- List variables = obj.getVariables();
- List types = obj.getTypes();
- Iterator iter = variables.iterator();
- Iterator typeIter = types.iterator();
- while ( iter.hasNext() ) {
- SingleElementSymbol ses = (SingleElementSymbol)iter.next();
- if (ses instanceof AliasSymbol) {
- AliasSymbol as = (AliasSymbol)ses;
- outputDisplayName(as.getOutputName());
- } else {
- parts.add(registerNode(ses));
- }
- Boolean type = (Boolean) typeIter.next();
- if( type.booleanValue() == OrderBy.DESC ) {
- parts.add(SPACE);
- parts.add(ReservedWords.DESC);
- } // Don't print default "ASC"
-
- if (iter.hasNext()) {
- parts.add( ", " ); //$NON-NLS-1$
- }
+ for (Iterator<OrderByItem> iterator = obj.getOrderByItems().iterator(); iterator.hasNext();) {
+ OrderByItem item = iterator.next();
+ parts.add(registerNode(item));
+ if (iterator.hasNext()) {
+ parts.add( ", " ); //$NON-NLS-1$
+ }
+ }
+ }
+
+ @Override
+ public void visit(OrderByItem obj) {
+ SingleElementSymbol ses = obj.getSymbol();
+ if (ses instanceof AliasSymbol) {
+ AliasSymbol as = (AliasSymbol)ses;
+ outputDisplayName(as.getOutputName());
+ } else {
+ parts.add(registerNode(ses));
}
+ if(!obj.isAscending()) {
+ parts.add(SPACE);
+ parts.add(ReservedWords.DESC);
+ } // Don't print default "ASC"
}
public void visit(DynamicCommand obj) {
Modified: branches/JCA/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -64,6 +64,7 @@
import com.metamatrix.query.sql.lang.NotCriteria;
import com.metamatrix.query.sql.lang.Option;
import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.OrderByItem;
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.QueryCommand;
import com.metamatrix.query.sql.lang.Select;
@@ -203,8 +204,9 @@
validateInsert(obj);
}
- public void visit(OrderBy obj) {
- validateSortable(obj.getVariables());
+ @Override
+ public void visit(OrderByItem obj) {
+ validateSortable(obj.getSymbol());
}
public void visit(Query obj) {
@@ -605,12 +607,16 @@
Iterator iter = symbols.iterator();
while(iter.hasNext()) {
SingleElementSymbol symbol = (SingleElementSymbol) iter.next();
- if (isNonComparable(symbol)) {
- handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0026, symbol), symbol);
- }
+ validateSortable(symbol);
}
}
+ private void validateSortable(SingleElementSymbol symbol) {
+ if (isNonComparable(symbol)) {
+ handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0026, symbol), symbol);
+ }
+ }
+
public static boolean isNonComparable(Expression symbol) {
return DataTypeManager.isNonComparable(DataTypeManager.getDataTypeName(symbol.getType()));
}
@@ -647,11 +653,8 @@
}
if (obj.getOrderBy() != null) {
OrderBy orderBy = obj.getOrderBy();
- if (orderBy.hasUnrelated()) {
- handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.unrelated_orderby_xml"), obj); //$NON-NLS-1$
- }
- for (SingleElementSymbol ses : (List<SingleElementSymbol>)orderBy.getVariables()) {
- if (!(ses instanceof ElementSymbol)) {
+ for (OrderByItem item : orderBy.getOrderByItems()) {
+ if (!(item.getSymbol() instanceof ElementSymbol)) {
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.orderby_expression_xml"), obj); //$NON-NLS-1$
}
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -85,6 +85,7 @@
import com.metamatrix.query.sql.lang.MatchCriteria;
import com.metamatrix.query.sql.lang.NotCriteria;
import com.metamatrix.query.sql.lang.OrderBy;
+import com.metamatrix.query.sql.lang.OrderByItem;
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.QueryCommand;
import com.metamatrix.query.sql.lang.SPParameter;
@@ -416,15 +417,12 @@
if(orderBy == null){
return null;
}
- List items = orderBy.getVariables();
- List types = orderBy.getTypes();
+ List<OrderByItem> items = orderBy.getOrderByItems();
List<SortSpecification> translatedItems = new ArrayList<SortSpecification>();
for (int i = 0; i < items.size(); i++) {
- SingleElementSymbol symbol = (SingleElementSymbol)items.get(i);
- Ordering direction = (((Boolean)types.get(i)).booleanValue() == OrderBy.DESC)
- ? Ordering.DESC
- : Ordering.ASC;
-
+ SingleElementSymbol symbol = items.get(i).getSymbol();
+ Ordering direction = items.get(i).isAscending() ? Ordering.ASC: Ordering.DESC;
+
SortSpecification orderByItem = null;
if(symbol instanceof AliasSymbol || (symbol.getOutputName() != null && symbol.getOutputName().indexOf(ElementSymbol.SEPARATOR) == -1)){
orderByItem = new SortSpecification(direction, new ColumnReference(null, symbol.getOutputName(), null, symbol.getType()));
@@ -509,7 +507,6 @@
ColumnReference translate(ElementSymbol symbol) throws MetaMatrixComponentException {
ColumnReference element = null;
element = new ColumnReference(translate(symbol.getGroupSymbol()), symbol.getOutputName(), null, symbol.getType());
-
if (element.getTable().getMetadataObject() == null) {
return element;
}
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -72,7 +72,7 @@
String sql = "select e1 from pm1.g1 order by e1"; //$NON-NLS-1$
String expected = "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
Query command = (Query)helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
- assertEquals(((SingleElementSymbol)command.getOrderBy().getVariables().get(0)).getName(), "e1"); //$NON-NLS-1$
+ assertEquals(command.getOrderBy().getSortKeys().get(0).getName(), "e1"); //$NON-NLS-1$
assertEquals(((SingleElementSymbol)command.getProjectedSymbols().get(0)).getShortName(), "e1"); //$NON-NLS-1$
}
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java 2010-02-27 12:48:26 UTC (rev 1879)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java 2010-02-27 13:43:10 UTC (rev 1880)
@@ -65,7 +65,7 @@
String[] elementNames,
String[] elementIDs) {
List elements = new ArrayList();
- for (Iterator i = langObj.getVariables().iterator(); i.hasNext();) {
+ for (Iterator i = langObj.getSortKeys().iterator(); i.hasNext();) {
ElementCollectorVisitor.getElements((LanguageObject)i.next(), elements);
}
@@ -84,7 +84,7 @@
private void helpCheckExpressionsSymbols(OrderBy langObj,
String[] functionsNames) {
int expCount = 0;
- for (Iterator i = langObj.getVariables().iterator(); i.hasNext();) {
+ for (Iterator i = langObj.getSortKeys().iterator(); i.hasNext();) {
SingleElementSymbol ses = (SingleElementSymbol)i.next();
if (ses instanceof ExpressionSymbol) {
assertEquals("Expression Symbols does not match: ", functionsNames[expCount++], ses.toString()); //$NON-NLS-1$
@@ -309,8 +309,8 @@
}
@Test public void testOrderByExpression() throws Exception {
- Query resolvedQuery = (Query) getCommand("SELECT 0 AS SOMEINT, pm1.g1.e2 as y FROM pm1.g1 ORDER BY y + SOMEINT, e3"); //$NON-NLS-1$
- assertEquals("SELECT Y_1.SOMEINT, Y_1.Y FROM (SELECT X_1.SOMEINT, X_1.Y, X_1.E3, (X_1.Y + X_1.SOMEINT) AS EXPR1 FROM (SELECT 0 AS SOMEINT, pm1.g1.e2 AS y, e3 FROM pm1.g1) AS X_1) AS Y_1 ORDER BY Y_1.EXPR1, Y_1.E3", resolvedQuery.toString()); //$NON-NLS-1$
+ Query resolvedQuery = (Query) getCommand("SELECT 0 AS SOMEINT, pm1.g1.e2 as y FROM pm1.g1 ORDER BY e2 || e1, e3"); //$NON-NLS-1$
+ assertEquals("SELECT X_1.SOMEINT, X_1.Y FROM (SELECT 0 AS SOMEINT, pm1.g1.e2 AS y, (e2 || e1) AS EXPR1, e3 FROM pm1.g1) AS X_1 ORDER BY X_1.EXPR1, X_1.E3", resolvedQuery.toString()); //$NON-NLS-1$
}
@Test public void testRewiteOrderBy() {
14 years, 10 months
teiid SVN: r1879 - in branches/JCA: connector-api/src/main/java/org/teiid/connector/metadata/runtime and 33 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-02-27 07:48:26 -0500 (Sat, 27 Feb 2010)
New Revision: 1879
Added:
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Select.java
Removed:
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/From.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/QuerySpecification.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Select.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java
Modified:
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/QueryExpression.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/ScalarSubquery.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SetQuery.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java
branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java
branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java
branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java
branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java
branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java
branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java
branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java
branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java
branches/JCA/connectors/connector-xml-http/src/main/java/org/teiid/connector/xml/http/HTTPConnectionImpl.java
branches/JCA/connectors/connector-xml-http/src/main/java/org/teiid/connector/xml/http/HTTPExecution.java
branches/JCA/connectors/connector-xml-soap/src/main/java/org/teiid/connector/xml/soap/SOAPConnectionImpl.java
branches/JCA/connectors/connector-xml-soap/src/main/java/org/teiid/connector/xml/soap/SOAPExecution.java
branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/IQueryPreprocessor.java
branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/CriteriaDesc.java
branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/QueryAnalyzer.java
branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/BaseStreamingExecution.java
branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/MockQueryPreprocessor.java
branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java
branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/ProxyObjectFactory.java
branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestCriteriaDesc.java
branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestExecutionInfo.java
branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestOutputXPathDesc.java
branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestParameterDescriptor.java
branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestQueryAnalyzer.java
branches/JCA/connectors/connector-xmlsource-file/src/main/java/org/teiid/connector/xmlsource/file/FileConnection.java
branches/JCA/connectors/connector-xmlsource-file/src/main/java/org/teiid/connector/xmlsource/file/FileResultSetExecution.java
branches/JCA/connectors/connector-xmlsource-soap/src/main/java/org/teiid/connector/xmlsource/soap/SOAPResultSetExecution.java
branches/JCA/connectors/connector-xmlsource-soap/src/main/java/org/teiid/connector/xmlsource/soap/SoapConnection.java
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java
branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java
branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java
branches/JCA/connectors/sandbox/connector-yahoo/src/test/java/com/metamatrix/connector/yahoo/TestYahooTranslation.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
branches/JCA/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java
branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/util/TestJDBCExecutionHelper.java
branches/JCA/test-integration/common/src/test/java/org/teiid/connector/language/TestLanguageUtil.java
branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java
branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java
branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java
branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java
branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestCollectorVisitor.java
branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
Log:
TEIID-1003 removing the select and from classes and renaming queryspecification to select.
Deleted: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/From.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/From.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/From.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -1,56 +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.language;
-
-import java.util.List;
-
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- * Represents a FROM clause in a query.
- */
-public class From extends BaseLanguageObject {
-
- private List<TableReference> items;
-
- public From(List<TableReference> items) {
- this.items = items;
- }
-
- /**
- * Get a List of IFromItem in this FROM clause.
- * @return List of IFromItem
- */
- public List<TableReference> getItems() {
- return items;
- }
-
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- public void setItems(List<TableReference> items) {
- this.items = items;
- }
-
-}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -67,14 +67,10 @@
return new ColumnReference(group, name, metadataReference, type);
}
- public Exists createExists(QuerySpecification query) {
+ public Exists createExists(Select query) {
return new Exists(query);
}
- public From createFrom(List<TableReference> items) {
- return new From(items);
- }
-
public Function createFunction(String functionName, Expression[] args, Class<?> type) {
return new Function(functionName, Arrays.asList(args), type);
}
@@ -143,17 +139,18 @@
return new Call(name, parameters, metadataReference);
}
- public QuerySpecification createQuery(
- Select select,
- From from,
+ public Select createQuery(
+ List<DerivedColumn> select,
+ boolean isDistinct,
+ List<TableReference> from,
Condition where,
GroupBy groupBy,
Condition having,
OrderBy orderBy) {
- return new QuerySpecification(select, from, where, groupBy, having, orderBy);
+ return new Select(select, isDistinct, from, where, groupBy, having, orderBy);
}
- public ScalarSubquery createScalarSubquery(QuerySpecification query) {
+ public ScalarSubquery createScalarSubquery(Select query) {
return new ScalarSubquery(query);
}
@@ -165,10 +162,6 @@
return new SearchedCase(new ArrayList<Condition>(whenExpressions), new ArrayList<Expression>(thenExpressions), elseExpression, type);
}
- public Select createSelect(boolean isDistinct, List<DerivedColumn> selectSymbols) {
- return new Select(selectSymbols, isDistinct);
- }
-
public DerivedColumn createSelectSymbol(String name, Expression expression) {
return new DerivedColumn(name, expression);
}
@@ -177,11 +170,11 @@
Expression leftExpression,
Comparison.Operator operator,
SubqueryComparison.Quantifier quantifier,
- QuerySpecification subquery) {
+ Select subquery) {
return new SubqueryComparison(leftExpression, operator, quantifier, subquery);
}
- public SubqueryIn createSubqueryInCriteria(Expression expression, QuerySpecification subquery, boolean isNegated) {
+ public SubqueryIn createSubqueryInCriteria(Expression expression, Select subquery, boolean isNegated) {
return new SubqueryIn(expression, isNegated, subquery);
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/QueryExpression.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/QueryExpression.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/QueryExpression.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -29,7 +29,7 @@
private OrderBy orderBy;
private Limit limit;
- public abstract QuerySpecification getProjectedQuery();
+ public abstract Select getProjectedQuery();
/**
* Get ORDER BY clause, may be null.
@@ -54,7 +54,7 @@
* @since 4.3
*/
public String[] getColumnNames() {
- List<DerivedColumn> selectSymbols = getProjectedQuery().getSelect().getDerivedColumns();
+ List<DerivedColumn> selectSymbols = getProjectedQuery().getDerivedColumns();
String[] columnNames = new String[selectSymbols.size()];
int symbolIndex = 0;
for (DerivedColumn column : selectSymbols) {
@@ -69,7 +69,7 @@
* @since 4.3
*/
public Class<?>[] getColumnTypes() {
- List<DerivedColumn> selectSymbols = getProjectedQuery().getSelect().getDerivedColumns();
+ List<DerivedColumn> selectSymbols = getProjectedQuery().getDerivedColumns();
Class<?>[] columnTypes = new Class[selectSymbols.size()];
int symbolIndex = 0;
for (DerivedColumn column : selectSymbols) {
Deleted: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/QuerySpecification.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/QuerySpecification.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/QuerySpecification.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -1,135 +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.language;
-
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-/**
- * Represents a simple SELECT query.
- */
-public class QuerySpecification extends QueryExpression {
-
- private Select select;
- private From from;
- private Condition where;
- private GroupBy groupBy;
- private Condition having;
-
- public QuerySpecification(Select select, From from, Condition where,
- GroupBy groupBy, Condition having, OrderBy orderBy) {
- this.select = select;
- this.from = from;
- this.where = where;
- this.groupBy = groupBy;
- this.having = having;
- this.setOrderBy(orderBy);
- }
-
- /**
- * Get SELECT clause, should never be null.
- * @return Select clause object
- */
- public Select getSelect() {
- return select;
- }
-
- /**
- * Get FROM clause, should never be null.
- * @return From clause object
- */
- public From getFrom() {
- return from;
- }
-
- /**
- * Get WHERE clause, may be null.
- * @return A criteria object
- */
- public Condition getWhere() {
- return where;
- }
-
- /**
- * Get GROUP BY clause, may be null.
- * @return A group by object
- */
- public GroupBy getGroupBy() {
- return groupBy;
- }
-
- /**
- * Get HAVING clause, may be null.
- * @return A criteria object
- */
- public Condition getHaving() {
- return having;
- }
-
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- /**
- * Set SELECT clause, should never be null.
- * @param select Select clause object
- */
- public void setSelect(Select select) {
- this.select = select;
- }
-
- /**
- * Set FROM clause, should never be null.
- * @param from From clause object
- */
- public void setFrom(From from) {
- this.from = from;
- }
-
- /**
- * Set WHERE clause, may be null.
- * @param criteria A criteria object
- */
- public void setWhere(Condition criteria) {
- this.where = criteria;
- }
-
- /**
- * Set GROUP BY clause, may be null.
- * @param groupBy A group by object
- */
- public void setGroupBy(GroupBy groupBy) {
- this.groupBy = groupBy;
- }
-
- /**
- * Set HAVING clause, may be null.
- * @param criteria A criteria object
- */
- public void setHaving(Condition criteria) {
- this.having = criteria;
- }
-
- public QuerySpecification getProjectedQuery() {
- return this;
- }
-}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/ScalarSubquery.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/ScalarSubquery.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/ScalarSubquery.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -53,7 +53,7 @@
@Override
public Class<?> getType() {
- return query.getProjectedQuery().getSelect().getDerivedColumns().get(0).getExpression().getType();
+ return query.getProjectedQuery().getDerivedColumns().get(0).getExpression().getType();
}
Deleted: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Select.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Select.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Select.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -1,59 +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.language;
-
-import java.util.List;
-
-import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
-
-public class Select extends BaseLanguageObject {
-
- private List<DerivedColumn> derivedColumns;
- private boolean isDistinct;
-
- public Select(List<DerivedColumn> derivedColumns, boolean distinct) {
- this.derivedColumns = derivedColumns;
- this.isDistinct = distinct;
- }
-
- public List<DerivedColumn> getDerivedColumns() {
- return derivedColumns;
- }
-
- public boolean isDistinct() {
- return this.isDistinct;
- }
-
- public void acceptVisitor(LanguageObjectVisitor visitor) {
- visitor.visit(this);
- }
-
- public void setDerivedColumns(List<DerivedColumn> symbols) {
- this.derivedColumns = symbols;
- }
-
- public void setDistinct(boolean distinct) {
- this.isDistinct = distinct;
- }
-
-}
Copied: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Select.java (from rev 1878, branches/JCA/connector-api/src/main/java/org/teiid/connector/language/QuerySpecification.java)
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Select.java (rev 0)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/Select.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -0,0 +1,139 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.connector.visitor.framework.LanguageObjectVisitor;
+
+/**
+ * Represents a simple SELECT query.
+ */
+public class Select extends QueryExpression {
+
+ private List<DerivedColumn> derivedColumns;
+ private boolean isDistinct;
+ private List<TableReference> from;
+ private Condition where;
+ private GroupBy groupBy;
+ private Condition having;
+
+ public Select(List<DerivedColumn> derivedColumns, boolean distinct, List<TableReference> from, Condition where,
+ GroupBy groupBy, Condition having, OrderBy orderBy) {
+ this.derivedColumns = derivedColumns;
+ this.isDistinct = distinct;
+ this.from = from;
+ this.where = where;
+ this.groupBy = groupBy;
+ this.having = having;
+ this.setOrderBy(orderBy);
+ }
+
+ public List<DerivedColumn> getDerivedColumns() {
+ return derivedColumns;
+ }
+
+ public boolean isDistinct() {
+ return this.isDistinct;
+ }
+
+ public void setDerivedColumns(List<DerivedColumn> symbols) {
+ this.derivedColumns = symbols;
+ }
+
+ public void setDistinct(boolean distinct) {
+ this.isDistinct = distinct;
+ }
+
+ /**
+ * Get FROM clause, should never be null.
+ * @return From clause object
+ */
+ public List<TableReference> getFrom() {
+ return from;
+ }
+
+ /**
+ * Get WHERE clause, may be null.
+ * @return A criteria object
+ */
+ public Condition getWhere() {
+ return where;
+ }
+
+ /**
+ * Get GROUP BY clause, may be null.
+ * @return A group by object
+ */
+ public GroupBy getGroupBy() {
+ return groupBy;
+ }
+
+ /**
+ * Get HAVING clause, may be null.
+ * @return A criteria object
+ */
+ public Condition getHaving() {
+ return having;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Set FROM clause, should never be null.
+ * @param from From clause object
+ */
+ public void setFrom(List<TableReference> from) {
+ this.from = from;
+ }
+
+ /**
+ * Set WHERE clause, may be null.
+ * @param criteria A criteria object
+ */
+ public void setWhere(Condition criteria) {
+ this.where = criteria;
+ }
+
+ /**
+ * Set GROUP BY clause, may be null.
+ * @param groupBy A group by object
+ */
+ public void setGroupBy(GroupBy groupBy) {
+ this.groupBy = groupBy;
+ }
+
+ /**
+ * Set HAVING clause, may be null.
+ * @param criteria A criteria object
+ */
+ public void setHaving(Condition criteria) {
+ this.having = criteria;
+ }
+
+ public Select getProjectedQuery() {
+ return this;
+ }
+}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SetQuery.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SetQuery.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/language/SetQuery.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -43,9 +43,9 @@
/**
* @see org.teiid.connector.language.QueryExpression#getProjectedQuery()
*/
- public QuerySpecification getProjectedQuery() {
- if (leftQuery instanceof QuerySpecification) {
- return (QuerySpecification)leftQuery;
+ public Select getProjectedQuery() {
+ if (leftQuery instanceof Select) {
+ return (Select)leftQuery;
}
return leftQuery.getProjectedQuery();
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -22,6 +22,7 @@
package org.teiid.connector.metadata.runtime;
+import java.util.LinkedList;
import java.util.List;
@@ -40,7 +41,7 @@
private boolean isFunction;
private boolean isVirtual;
private int updateCount = 1;
- private List<ProcedureParameter> parameters;
+ private List<ProcedureParameter> parameters = new LinkedList<ProcedureParameter>();
private ColumnSet<Procedure> resultSet;
private String queryPlan;
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -36,7 +36,6 @@
import org.teiid.connector.language.DerivedTable;
import org.teiid.connector.language.Exists;
import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.From;
import org.teiid.connector.language.Function;
import org.teiid.connector.language.GroupBy;
import org.teiid.connector.language.In;
@@ -50,10 +49,9 @@
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
-import org.teiid.connector.language.Select;
import org.teiid.connector.language.SetClause;
import org.teiid.connector.language.SetClauseList;
import org.teiid.connector.language.SetQuery;
@@ -122,7 +120,6 @@
public void visit(ColumnReference obj) {}
public void visit(Call obj) {}
public void visit(Exists obj) {}
- public void visit(From obj) {}
public void visit(Function obj) {}
public void visit(NamedTable obj) {}
public void visit(GroupBy obj) {}
@@ -139,10 +136,9 @@
public void visit(OrderBy obj) {}
public void visit(SortSpecification obj) {}
public void visit(Argument obj) {}
- public void visit(QuerySpecification obj) {}
+ public void visit(Select obj) {}
public void visit(ScalarSubquery obj) {}
public void visit(SearchedCase obj) {}
- public void visit(Select obj) {}
public void visit(DerivedColumn obj) {}
public void visit(SubqueryComparison obj) {}
public void visit(SubqueryIn obj) {}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -34,7 +34,6 @@
import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.DerivedTable;
import org.teiid.connector.language.Exists;
-import org.teiid.connector.language.From;
import org.teiid.connector.language.Function;
import org.teiid.connector.language.GroupBy;
import org.teiid.connector.language.In;
@@ -48,10 +47,9 @@
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
-import org.teiid.connector.language.Select;
import org.teiid.connector.language.SetClause;
import org.teiid.connector.language.SetClauseList;
import org.teiid.connector.language.SetQuery;
@@ -163,15 +161,6 @@
postVisitor.visit(obj);
}
}
- public void visit(From obj) {
- if (preVisitor != null) {
- preVisitor.visit(obj);
- }
- super.visit(obj);
- if (postVisitor != null) {
- postVisitor.visit(obj);
- }
- }
public void visit(Function obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
@@ -309,7 +298,7 @@
postVisitor.visit(obj);
}
}
- public void visit(QuerySpecification obj) {
+ public void visit(Select obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
}
@@ -337,15 +326,6 @@
postVisitor.visit(obj);
}
}
- public void visit(Select obj) {
- if (preVisitor != null) {
- preVisitor.visit(obj);
- }
- super.visit(obj);
- if (postVisitor != null) {
- postVisitor.visit(obj);
- }
- }
public void visit(DerivedColumn obj) {
if (preVisitor != null) {
preVisitor.visit(obj);
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -32,7 +32,6 @@
import org.teiid.connector.language.DerivedTable;
import org.teiid.connector.language.Exists;
import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.From;
import org.teiid.connector.language.Function;
import org.teiid.connector.language.GroupBy;
import org.teiid.connector.language.In;
@@ -43,10 +42,9 @@
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
-import org.teiid.connector.language.Select;
import org.teiid.connector.language.SetClause;
import org.teiid.connector.language.SetClauseList;
import org.teiid.connector.language.SetQuery;
@@ -110,10 +108,6 @@
}
}
- public void visit(From obj) {
- visitNodes(obj.getItems());
- }
-
public void visit(Function obj) {
visitNodes(obj.getParameters());
}
@@ -163,9 +157,9 @@
visitNodes(obj.getSortSpecifications());
}
- public void visit(QuerySpecification obj) {
- visitNode(obj.getSelect());
- visitNode(obj.getFrom());
+ public void visit(Select obj) {
+ visitNodes(obj.getDerivedColumns());
+ visitNodes(obj.getFrom());
visitNode(obj.getWhere());
visitNode(obj.getGroupBy());
visitNode(obj.getHaving());
@@ -187,10 +181,6 @@
visitNode(obj.getElseExpression());
}
- public void visit(Select obj) {
- visitNodes(obj.getDerivedColumns());
- }
-
public void visit(DerivedColumn obj) {
visitNode(obj.getExpression());
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -36,7 +36,6 @@
public void visit(ColumnReference obj);
public void visit(Call obj);
public void visit(Exists obj);
- public void visit(From obj);
public void visit(Function obj);
public void visit(NamedTable obj);
public void visit(GroupBy obj);
@@ -52,10 +51,9 @@
public void visit(OrderBy obj);
public void visit(SortSpecification obj);
public void visit(Argument obj);
- public void visit(QuerySpecification obj);
+ public void visit(Select obj);
public void visit(ScalarSubquery obj);
public void visit(SearchedCase obj);
- public void visit(Select obj);
public void visit(DerivedColumn obj);
public void visit(SubqueryComparison obj);
public void visit(SubqueryIn obj);
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -39,7 +39,6 @@
import org.teiid.connector.language.DerivedTable;
import org.teiid.connector.language.Exists;
import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.From;
import org.teiid.connector.language.Function;
import org.teiid.connector.language.GroupBy;
import org.teiid.connector.language.In;
@@ -53,10 +52,9 @@
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
-import org.teiid.connector.language.Select;
import org.teiid.connector.language.SetClause;
import org.teiid.connector.language.SetClauseList;
import org.teiid.connector.language.SetQuery;
@@ -121,10 +119,6 @@
checkInstance(obj);
}
- public void visit(From obj) {
- checkInstance(obj);
- }
-
public void visit(Function obj) {
checkInstance(obj);
}
@@ -193,7 +187,7 @@
checkInstance(obj);
}
- public void visit(QuerySpecification obj) {
+ public void visit(Select obj) {
checkInstance(obj);
}
@@ -205,10 +199,6 @@
checkInstance(obj);
}
- public void visit(Select obj) {
- checkInstance(obj);
- }
-
public void visit(DerivedColumn obj) {
checkInstance(obj);
}
Modified: branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java
===================================================================
--- branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -41,7 +41,6 @@
import org.teiid.connector.language.Exists;
import org.teiid.connector.language.Expression;
import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.From;
import org.teiid.connector.language.Function;
import org.teiid.connector.language.GroupBy;
import org.teiid.connector.language.In;
@@ -56,10 +55,9 @@
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
-import org.teiid.connector.language.Select;
import org.teiid.connector.language.SetClause;
import org.teiid.connector.language.SetClauseList;
import org.teiid.connector.language.SetQuery;
@@ -349,15 +347,6 @@
buffer.append(SQLReservedWords.RPAREN);
}
- /**
- * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.connector.language.From)
- */
- public void visit(From obj) {
- buffer.append(SQLReservedWords.FROM)
- .append(SQLReservedWords.SPACE);
- append(obj.getItems());
- }
-
protected boolean isInfixFunction(String function) {
return infixFunctions.contains(function);
}
@@ -690,10 +679,15 @@
buffer.append(obj.getArgumentValue());
}
- public void visit(QuerySpecification obj) {
- visitSelect(obj.getSelect(), obj);
+ public void visit(Select obj) {
+ buffer.append(SQLReservedWords.SELECT).append(SQLReservedWords.SPACE);
+ buffer.append(getSourceComment(obj));
+ if (obj.isDistinct()) {
+ buffer.append(SQLReservedWords.DISTINCT).append(SQLReservedWords.SPACE);
+ }
+ append(obj.getDerivedColumns());
if (obj.getFrom() != null) {
- buffer.append(SQLReservedWords.SPACE);
+ buffer.append(SQLReservedWords.SPACE).append(SQLReservedWords.FROM).append(SQLReservedWords.SPACE);
append(obj.getFrom());
}
if (obj.getWhere() != null) {
@@ -745,19 +739,6 @@
.append(SQLReservedWords.END);
}
- public void visit(Select obj) {
- visitSelect(obj, null);
- }
-
- private void visitSelect(Select obj, Command command) {
- buffer.append(SQLReservedWords.SELECT).append(SQLReservedWords.SPACE);
- buffer.append(getSourceComment(command));
- if (obj.isDistinct()) {
- buffer.append(SQLReservedWords.DISTINCT).append(SQLReservedWords.SPACE);
- }
- append(obj.getDerivedColumns());
- }
-
protected String getSourceComment(Command command) {
return ""; //$NON-NLS-1$
}
Modified: branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java
===================================================================
--- branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connector-sdk/src/main/java/com/metamatrix/cdk/ConnectorShellCommandTarget.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -46,7 +46,7 @@
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.language.Command;
import org.teiid.connector.language.Call;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.cdk.file.ConfigReaderWriter;
@@ -92,8 +92,8 @@
try {
Command command = getConnectorHost().getCommand(query);
String[] columnNames = null;
- if(command instanceof QuerySpecification) {
- QuerySpecification iquery = (QuerySpecification) command;
+ if(command instanceof Select) {
+ Select iquery = (Select) command;
columnNames = iquery.getColumnNames();
} else if (!(command instanceof Call)){
columnNames = new String[] {"count"}; //$NON-NLS-1$
Modified: branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/oracle/OracleSQLTranslator.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -54,7 +54,7 @@
import org.teiid.connector.language.Insert;
import org.teiid.connector.language.ExpressionValueSource;
import org.teiid.connector.language.Limit;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.SetQuery.Operation;
@@ -234,7 +234,7 @@
* we just use the projected names
*/
boolean allAliased = true;
- for (DerivedColumn selectSymbol : queryCommand.getProjectedQuery().getSelect().getDerivedColumns()) {
+ for (DerivedColumn selectSymbol : queryCommand.getProjectedQuery().getDerivedColumns()) {
if (selectSymbol.getAlias() == null) {
allAliased = false;
break;
@@ -297,7 +297,7 @@
}
}
- if (command instanceof QuerySpecification) {
+ if (command instanceof Select) {
//
// This simple algorithm determines the hint which will be added to the
// query.
Modified: branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java
===================================================================
--- branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-jdbc/src/test/java/org/teiid/connector/jdbc/TestJDBCUpdateExecution.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -51,7 +51,7 @@
Connection connection = Mockito.mock(Connection.class);
PreparedStatement p = Mockito.mock(PreparedStatement.class);
Mockito.stub(p.executeBatch()).toReturn(new int [] {1, 1});
- Mockito.stub(connection.prepareStatement("INSERT INTO BQT1.SmallA (IntKey, IntNum) VALUES (?, ?)")).toReturn(p); //$NON-NLS-1$
+ Mockito.stub(connection.prepareStatement("INSERT INTO SmallA (IntKey, IntNum) VALUES (?, ?)")).toReturn(p); //$NON-NLS-1$
JDBCManagedConnectionFactory config = Mockito.mock(JDBCManagedConnectionFactory.class);
Mockito.stub(config.getExtensionTranslationClass()).toReturn(new Translator());
Modified: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/IQueryToLdapSearchParser.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -64,7 +64,7 @@
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Not;
import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import org.teiid.connector.language.SearchedCase;
import org.teiid.connector.language.SortSpecification;
@@ -112,7 +112,7 @@
// ou=people,dc=company,dc=com?SUBTREE_SCOPE?RESTRICT
// TODO - change method for calling RESTRICT to also specify
// object class name (RESTRICT=inetOrgPerson)
- public LDAPSearchDetails translateSQLQueryToLDAPSearch(QuerySpecification query) throws ConnectorException {
+ public LDAPSearchDetails translateSQLQueryToLDAPSearch(Select query) throws ConnectorException {
// Parse SELECT symbols.
// The columns will be translated into LDAP attributes of interest.
ArrayList attributeList = getAttributesFromSelectSymbols(query);
@@ -120,7 +120,7 @@
// Parse FROM table.
// Only one table is expected here.
- List fromList = query.getFrom().getItems();
+ List fromList = query.getFrom();
Iterator itr = fromList.listIterator();
if(!itr.hasNext()) {
final String msg = LDAPPlugin.Util.getString("IQueryToLdapSearchParser.noTablesInFromError"); //$NON-NLS-1$
@@ -607,9 +607,9 @@
* @param query the supplied Query
* @return the list of SELECT elements
*/
- private ArrayList getElementsFromSelectSymbols(QuerySpecification query) throws ConnectorException {
+ private ArrayList getElementsFromSelectSymbols(Select query) throws ConnectorException {
ArrayList selectElementList = new ArrayList();
- Iterator selectSymbolItr = query.getSelect().getDerivedColumns().iterator();
+ Iterator selectSymbolItr = query.getDerivedColumns().iterator();
while(selectSymbolItr.hasNext()) {
Column e = getElementFromSymbol((DerivedColumn)selectSymbolItr.next());
@@ -623,10 +623,10 @@
* @param query the supplied Query
* @return the list of attributes
*/
- private ArrayList getAttributesFromSelectSymbols(QuerySpecification query) throws ConnectorException {
+ private ArrayList getAttributesFromSelectSymbols(Select query) throws ConnectorException {
ArrayList ldapAttributeList = new ArrayList();
- Iterator selectSymbolItr = query.getSelect().getDerivedColumns().iterator();
+ Iterator selectSymbolItr = query.getDerivedColumns().iterator();
int i=0;
while(selectSymbolItr.hasNext()) {
Column e = getElementFromSymbol((DerivedColumn)selectSymbolItr.next());
Modified: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPConnection.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -36,7 +36,7 @@
import org.teiid.connector.api.UpdateExecution;
import org.teiid.connector.basic.BasicConnection;
import org.teiid.connector.language.Command;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -157,7 +157,7 @@
public ResultSetExecution createResultSetExecution(QueryExpression command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new LDAPSyncQueryExecution((QuerySpecification)command, executionContext, metadata, this.initCtx, this.config);
+ return new LDAPSyncQueryExecution((Select)command, executionContext, metadata, this.initCtx, this.config);
}
@Override
Modified: branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-ldap/src/main/java/com/metamatrix/connector/ldap/LDAPSyncQueryExecution.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -98,7 +98,7 @@
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.basic.BasicExecution;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -115,7 +115,7 @@
private LdapContext ldapCtx;
private NamingEnumeration searchEnumeration;
private IQueryToLdapSearchParser parser;
- private QuerySpecification query;
+ private Select query;
private LDAPManagedConnectionFactory config;
/**
@@ -126,7 +126,7 @@
* @param logger the ConnectorLogger
* @param ldapCtx the LDAP Context
*/
- public LDAPSyncQueryExecution(QuerySpecification query, ExecutionContext ctx, RuntimeMetadata rm, InitialLdapContext ldapCtx, LDAPManagedConnectionFactory config) throws ConnectorException {
+ public LDAPSyncQueryExecution(Select query, ExecutionContext ctx, RuntimeMetadata rm, InitialLdapContext ldapCtx, LDAPManagedConnectionFactory config) throws ConnectorException {
this.rm = rm;
this.initialLdapContext = ldapCtx;
this.query = query;
Modified: branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java
===================================================================
--- branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-ldap/src/test/java/com/metamatrix/connector/ldap/TestIQueryToLdapSearchParser.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -37,7 +37,7 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ConnectorLogger;
import org.teiid.connector.language.Command;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
@@ -258,7 +258,7 @@
IQueryToLdapSearchParser searchParser = new IQueryToLdapSearchParser(rm, config);
- QuerySpecification query = (QuerySpecification)getCommand(queryString, metadata);
+ Select query = (Select)getCommand(queryString, metadata);
LDAPSearchDetails searchDetails = searchParser.translateSQLQueryToLDAPSearch(query);
return searchDetails;
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/QueryExecutionImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -42,10 +42,10 @@
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.basic.BasicExecution;
import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.From;
import org.teiid.connector.language.Join;
import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
+import org.teiid.connector.language.TableReference;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -117,9 +117,9 @@
public void execute() throws ConnectorException {
connectorEnv.getLogger().logInfo(
getLogPreamble() + "Incoming Query: " + query.toString());
- From from = ((QuerySpecification)query).getFrom();
+ List<TableReference> from = ((Select)query).getFrom();
String finalQuery;
- if(from.getItems().get(0) instanceof Join) {
+ if(from.get(0) instanceof Join) {
visitor = new JoinQueryVisitor(metadata);
visitor.visitNode(query);
finalQuery = visitor.getQuery().trim();
@@ -146,7 +146,7 @@
@Override
public List next() throws ConnectorException, DataNotAvailableException {
List<?> result;
- if (query.getProjectedQuery().getSelect().getDerivedColumns().get(0)
+ if (query.getProjectedQuery().getDerivedColumns().get(0)
.getExpression() instanceof AggregateFunction) {
result = Arrays.asList(results.getSize());
results = null;
Modified: branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-salesforce/src/main/java/com/metamatrix/connector/salesforce/execution/visitors/SelectVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -30,13 +30,11 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.language.AggregateFunction;
import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.From;
-import org.teiid.connector.language.TableReference;
import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.QuerySpecification;
import org.teiid.connector.language.Select;
-import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.TableReference;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -59,21 +57,13 @@
}
- public void visit(QuerySpecification query) {
+ public void visit(Select query) {
super.visit(query);
- if(null != query.getLimit()) {
- limitClause.append(LIMIT).append(SPACE).append(query.getLimit().getRowLimit());
- }
- }
-
-
- public void visit(Select select) {
- super.visit(select);
- if (select.isDistinct()) {
+ if (query.isDistinct()) {
exceptions.add(new ConnectorException(
Messages.getString("SelectVisitor.distinct.not.supported")));
}
- selectSymbols = select.getDerivedColumns();
+ selectSymbols = query.getDerivedColumns();
selectSymbolCount = selectSymbols.size();
Iterator<DerivedColumn> symbolIter = selectSymbols.iterator();
int index = 0;
@@ -98,15 +88,10 @@
}
++index;
}
- }
-
- @Override
- public void visit(From from) {
- super.visit(from);
try {
// could be a join here, but if so we do nothing and handle
// it in visit(IJoin join).
- TableReference fromItem = from.getItems().get(0);
+ TableReference fromItem = query.getFrom().get(0);
if(fromItem instanceof NamedTable) {
table = ((NamedTable)fromItem).getMetadataObject();
String supportsQuery = table.getProperties().get(Constants.SUPPORTS_QUERY);
@@ -120,8 +105,11 @@
} catch (ConnectorException ce) {
exceptions.add(ce);
}
+ if(null != query.getLimit()) {
+ limitClause.append(LIMIT).append(SPACE).append(query.getLimit().getRowLimit());
+ }
}
-
+
/*
* The SOQL SELECT command uses the following syntax: SELECT fieldList FROM
* objectType [WHERE The Condition Expression (WHERE Clause)] [ORDER BY]
Modified: branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java
===================================================================
--- branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-salesforce/src/test/java/com/metamatrix/connector/salesforce/execution/visitors/TestVisitors.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -27,7 +27,7 @@
import java.util.List;
import org.junit.Test;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.common.types.DataTypeManager;
@@ -107,28 +107,28 @@
private static TranslationUtility translationUtility = new TranslationUtility(exampleSalesforce());
@Test public void testOr() throws Exception {
- QuerySpecification command = (QuerySpecification)translationUtility.parseCommand("select * from Account where Name = 'foo' or Stuff = 'bar'"); //$NON-NLS-1$
+ Select command = (Select)translationUtility.parseCommand("select * from Account where Name = 'foo' or Stuff = 'bar'"); //$NON-NLS-1$
SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE (Account.AccountName = 'foo') OR (Account.Stuff = 'bar')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
}
@Test public void testNot() throws Exception {
- QuerySpecification command = (QuerySpecification)translationUtility.parseCommand("select * from Account where not (Name = 'foo' and Stuff = 'bar')"); //$NON-NLS-1$
+ Select command = (Select)translationUtility.parseCommand("select * from Account where not (Name = 'foo' and Stuff = 'bar')"); //$NON-NLS-1$
SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE (Account.AccountName != 'foo') OR (Account.Stuff != 'bar')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
}
@Test public void testCountStart() throws Exception {
- QuerySpecification command = (QuerySpecification)translationUtility.parseCommand("select count(*) from Account"); //$NON-NLS-1$
+ Select command = (Select)translationUtility.parseCommand("select count(*) from Account"); //$NON-NLS-1$
SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertEquals("SELECT count() FROM Account", visitor.getQuery().toString().trim()); //$NON-NLS-1$
}
@Test public void testNotLike() throws Exception {
- QuerySpecification command = (QuerySpecification)translationUtility.parseCommand("select * from Account where Name not like '%foo' or Stuff = 'bar'"); //$NON-NLS-1$
+ Select command = (Select)translationUtility.parseCommand("select * from Account where Name not like '%foo' or Stuff = 'bar'"); //$NON-NLS-1$
SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertEquals("SELECT Account.id, Account.AccountName, Account.Stuff, Account.Industry FROM Account WHERE (NOT (Account.AccountName LIKE '%foo')) OR (Account.Stuff = 'bar')", visitor.getQuery().toString().trim()); //$NON-NLS-1$
@@ -136,7 +136,7 @@
@Test public void testIN() throws Exception {
- QuerySpecification command = (QuerySpecification)translationUtility.parseCommand("select * from Account where Industry IN (1,2,3)"); //$NON-NLS-1$
+ Select command = (Select)translationUtility.parseCommand("select * from Account where Industry IN (1,2,3)"); //$NON-NLS-1$
SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertFalse(visitor.hasOnlyIDCriteria());
@@ -146,7 +146,7 @@
@Test public void testOnlyIDsIN() throws Exception {
// this can resolve to a better performing retrieve call
- QuerySpecification command = (QuerySpecification)translationUtility.parseCommand("select * from Account where ID IN (1,2,3)"); //$NON-NLS-1$
+ Select command = (Select)translationUtility.parseCommand("select * from Account where ID IN (1,2,3)"); //$NON-NLS-1$
SelectVisitor visitor = new SelectVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertTrue(visitor.hasOnlyIdInCriteria());
@@ -156,14 +156,14 @@
}
@Test public void testJoin() throws Exception {
- QuerySpecification command = (QuerySpecification)translationUtility.parseCommand("SELECT Account.Name, Contact.Name FROM Contact LEFT OUTER JOIN Account ON Account.Id = Contact.AccountId"); //$NON-NLS-1$
+ Select command = (Select)translationUtility.parseCommand("SELECT Account.Name, Contact.Name FROM Contact LEFT OUTER JOIN Account ON Account.Id = Contact.AccountId"); //$NON-NLS-1$
SelectVisitor visitor = new JoinQueryVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertEquals("SELECT Account.AccountName, Contact.ContactName FROM Contact", visitor.getQuery().toString().trim()); //$NON-NLS-1$
}
@Test public void testJoin2() throws Exception {
- QuerySpecification command = (QuerySpecification)translationUtility.parseCommand("SELECT Account.Name, Contact.Name FROM Account LEFT OUTER JOIN Contact ON Account.Id = Contact.AccountId"); //$NON-NLS-1$
+ Select command = (Select)translationUtility.parseCommand("SELECT Account.Name, Contact.Name FROM Account LEFT OUTER JOIN Contact ON Account.Id = Contact.AccountId"); //$NON-NLS-1$
SelectVisitor visitor = new JoinQueryVisitor(translationUtility.createRuntimeMetadata());
visitor.visit(command);
assertEquals("SELECT Account.AccountName, (SELECT Contact.ContactName FROM Contacts) FROM Account", visitor.getQuery().toString().trim()); //$NON-NLS-1$
Modified: branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java
===================================================================
--- branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnection.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -31,7 +31,7 @@
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.basic.BasicConnection;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.MetadataFactory;
@@ -62,7 +62,7 @@
@Override
public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new TextSynchExecution(this.config, (QuerySpecification)command, this.metadataProps);
+ return new TextSynchExecution(this.config, (Select)command, this.metadataProps);
}
@Override
Modified: branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java
===================================================================
--- branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextSynchExecution.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -44,12 +44,11 @@
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.basic.BasicExecution;
-import org.teiid.connector.language.Command;
import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.From;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Command;
import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.NamedTable;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.Table;
@@ -61,7 +60,7 @@
*/
public class TextSynchExecution extends BasicExecution implements ResultSetExecution {
// Command to be executed
- private QuerySpecification cmd;
+ private Select cmd;
// metadata properties
private Map metadataProps;
@@ -111,7 +110,7 @@
* @param cmd
* @param txtConn
*/
- public TextSynchExecution(TextManagedConnectionFactory config, QuerySpecification query, Map <String, Properties> metaProps) {
+ public TextSynchExecution(TextManagedConnectionFactory config, Select query, Map <String, Properties> metaProps) {
this.config = config;
this.metadataProps = metaProps;
this.cmd = query;
@@ -128,7 +127,7 @@
// translate results
translateResults(response, cmd);
- cols = getSelectCols(cmd.getSelect().getDerivedColumns());
+ cols = getSelectCols(cmd.getDerivedColumns());
}
@Override
@@ -136,7 +135,7 @@
if (canceled) {
throw new ConnectorException("Execution cancelled"); //$NON-NLS-1$
}
- QuerySpecification query = cmd;
+ Select query = cmd;
Class[] types = query.getColumnTypes();
@@ -368,14 +367,13 @@
}
// Get the columns widths for all the elements in the group.
- QuerySpecification query = (QuerySpecification) request;
+ Select query = (Select) request;
/* Defect 13371
* Can't use the select columns to get the columns widths because we may not be selecting all the columns. Instead,
* we need to get all the child elements of the group being queried, and get the columns widths of each one of them.
*/
- From from = query.getFrom();
- NamedTable group = (NamedTable)from.getItems().get(0);
+ NamedTable group = (NamedTable)query.getFrom().get(0);
try {
/* We need to create the reader queue before we
* attempt to create the request as we may need
@@ -434,8 +432,7 @@
}
// get the group metadataID for group present on the command
- From from = ((QuerySpecification) cmd).getFrom();
- List groups = from.getItems();
+ List groups = ((Select) cmd).getFrom();
NamedTable symbol = (NamedTable) groups.get(0);
Table group = symbol.getMetadataObject();
Modified: branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/IQueryPreprocessor.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/IQueryPreprocessor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/IQueryPreprocessor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -26,7 +26,7 @@
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
public interface IQueryPreprocessor {
@@ -41,6 +41,6 @@
* @param m_metadata the runtime metadata
* @return an IQuery object representing the altered query
*/
- public QuerySpecification preprocessQuery(QuerySpecification query, RuntimeMetadata m_metadata, ExecutionContext exeContext, ConnectorEnvironment config);
+ public Select preprocessQuery(Select query, RuntimeMetadata m_metadata, ExecutionContext exeContext, ConnectorEnvironment config);
}
Modified: branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/CriteriaDesc.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/CriteriaDesc.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/CriteriaDesc.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -35,7 +35,7 @@
import org.teiid.connector.language.Expression;
import org.teiid.connector.language.In;
import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.LanguageUtil;
import org.teiid.connector.language.Comparison.Operator;
import org.teiid.connector.metadata.runtime.Column;
@@ -105,7 +105,7 @@
//use static method do see if a criteria object needs to be created
public static CriteriaDesc getCriteriaDescForColumn(Column element,
- QuerySpecification query) throws ConnectorException {
+ Select query) throws ConnectorException {
CriteriaDesc retVal = null;
List values = parseCriteriaToValues(element, query);
@@ -352,7 +352,7 @@
m_currentIndexInValuesList = 0;
}
- private static ArrayList parseCriteriaToValues(Column element, QuerySpecification query) throws ConnectorException {
+ private static ArrayList parseCriteriaToValues(Column element, Select query) throws ConnectorException {
String fullName = element.getFullName().trim().toUpperCase();
ArrayList parmPair = new ArrayList();
Modified: branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/QueryAnalyzer.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/QueryAnalyzer.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/base/QueryAnalyzer.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -29,24 +29,22 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.From;
-import org.teiid.connector.language.TableReference;
-import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Select;
-import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.TableReference;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.Table;
public class QueryAnalyzer {
- private QuerySpecification command;
+ private Select command;
private Table table;
private ExecutionInfo executionInfo;
- public QueryAnalyzer(QuerySpecification query) throws ConnectorException {
+ public QueryAnalyzer(Select query) throws ConnectorException {
this.command = query;
executionInfo = new ExecutionInfo();
analyze();
@@ -66,8 +64,7 @@
}
private void setGroupInfo() throws ConnectorException {
- From from = command.getFrom();
- List<TableReference> fromItems = from.getItems();
+ List<TableReference> fromItems = command.getFrom();
//Can only be one because we do not support joins
NamedTable group = (NamedTable) fromItems.get(0);
this.table = group.getMetadataObject();
@@ -78,8 +75,7 @@
List<OutputXPathDesc> columns = new ArrayList<OutputXPathDesc>();
//get the request items
- Select select = this.command.getSelect();
- List<DerivedColumn> selectSymbols = select.getDerivedColumns();
+ List<DerivedColumn> selectSymbols = this.command.getDerivedColumns();
//setup column numbers
int projectedColumnCount = 0;
Modified: branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/BaseStreamingExecution.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/BaseStreamingExecution.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/main/java/com/metamatrix/connector/xml/streaming/BaseStreamingExecution.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -34,7 +34,7 @@
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.basic.BasicManagedConnectionFactory;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xml.Document;
@@ -48,12 +48,12 @@
private int resultIndex = 0;
// injected state
- protected QuerySpecification query;
+ protected Select query;
protected RuntimeMetadata metadata;
protected ExecutionContext context;
protected XMLBaseManagedConnectionFactory config;
- public BaseStreamingExecution(QuerySpecification command, XMLBaseManagedConnectionFactory config, RuntimeMetadata rtMetadata, ExecutionContext context) {
+ public BaseStreamingExecution(Select command, XMLBaseManagedConnectionFactory config, RuntimeMetadata rtMetadata, ExecutionContext context) {
this.query = command;
this.metadata = rtMetadata;
this.context = context;
Modified: branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/MockQueryPreprocessor.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/MockQueryPreprocessor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/MockQueryPreprocessor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -26,7 +26,7 @@
import org.teiid.connector.api.ConnectorEnvironment;
import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
public class MockQueryPreprocessor implements IQueryPreprocessor {
@@ -35,7 +35,7 @@
super();
}
- public QuerySpecification preprocessQuery(QuerySpecification query, RuntimeMetadata m_metadata, ExecutionContext exeContext, ConnectorEnvironment connectorEnv) {
+ public Select preprocessQuery(Select query, RuntimeMetadata m_metadata, ExecutionContext exeContext, ConnectorEnvironment connectorEnv) {
return query;
}
Modified: branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/TestElementCollector.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -12,7 +12,7 @@
import junit.framework.TestCase;
import org.teiid.connector.basic.TypeFacilityImpl;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import com.metamatrix.common.types.InputStreamFactory;
import com.metamatrix.connector.xml.base.ExecutionInfo;
@@ -35,7 +35,7 @@
Map prefixes = new HashMap<String, String>();
prefixes.put("po", "http://www.example.com/PO1");
prefixes.put("xsd", "http://www.w3.org/2001/XMLSchema");
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, "SELECT * FROM po_list.ITEM");
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, "SELECT * FROM po_list.ITEM");
QueryAnalyzer analyzer = new QueryAnalyzer(query);
analyzer.analyze();
ExecutionInfo info = analyzer.getExecutionInfo();
Modified: branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/ProxyObjectFactory.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/ProxyObjectFactory.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/ProxyObjectFactory.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -31,7 +31,7 @@
import org.jdom.input.SAXBuilder;
import org.mockito.Mockito;
import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.cdk.api.TranslationUtility;
@@ -176,9 +176,9 @@
// }
- public static QuerySpecification getDefaultIQuery(String vdbPath, String queryString) {
+ public static Select getDefaultIQuery(String vdbPath, String queryString) {
TranslationUtility transUtil = new TranslationUtility(vdbPath);
- QuerySpecification query = (QuerySpecification) transUtil.parseCommand(queryString);
+ Select query = (Select) transUtil.parseCommand(queryString);
return query;
}
Modified: branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestCriteriaDesc.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestCriteriaDesc.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestCriteriaDesc.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -35,7 +35,7 @@
import org.teiid.connector.language.Condition;
import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.LanguageUtil;
import org.teiid.connector.metadata.runtime.Column;
@@ -62,9 +62,9 @@
//case 1: values provided
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam in ('foo')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -75,9 +75,9 @@
//case 2: param, required, defaulted
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredDefaultedParam from CriteriaDescTable"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -88,9 +88,9 @@
//case 3: param, not required, not defaulted, not allowed empty
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select OptionalNotAllowedEmptyParam from CriteriaDescTable"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -102,8 +102,8 @@
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select OptionalAllowedEmptyParam from CriteriaDescTable"; //$NON-NLS-1$
final int colLocation = 0;
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -115,9 +115,9 @@
try {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredUndefaultedParam from CriteriaDescTable"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -130,9 +130,9 @@
//case 6: not a param
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select OutputColumn from CriteriaDescTable"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -143,9 +143,9 @@
//case 7: compare criteria
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam = 'foo'"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -156,9 +156,9 @@
public void testGetCriteriaDescForColumnMultiElement() throws Exception {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select MultiElementParam from CriteriaDescTable where MultiElementParam in ('foo','bar')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
String multiplicityStr = elem.getProperties().get(
@@ -170,9 +170,9 @@
public void testGetCriteriaDescForColumnDelimited() throws Exception {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select DelimitedParam from CriteriaDescTable where DelimitedParam in ('foo','bar')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
String multiplicityStr = elem.getProperties().get(
@@ -185,9 +185,9 @@
try {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select LikeSearchableParam from CriteriaDescTable where LikeSearchableParam in ('foo')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
String multiplicityStr = elem.getProperties().get(
@@ -201,9 +201,9 @@
public void testGetCriteriaDescForColumnUnlikeSearchable() throws Exception {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select UnlikeSearchableParam from CriteriaDescTable where UnlikeSearchableParam in ('foo')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
String multiplicityStr = elem.getProperties().get(
@@ -215,9 +215,9 @@
try {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select UnsearchableParam from CriteriaDescTable where UnsearchableParam in ('foo','bar')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
String multiplicityStr = elem.getProperties().get(
@@ -232,9 +232,9 @@
//case 1: values provided
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam like 'foo'"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -245,9 +245,9 @@
//case 1: values provided
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam != 'foo'"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -257,9 +257,9 @@
public void testGetCriteriaDescForColumnLiteral() throws Exception {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredDefaultedParam from CriteriaDescTable where concat(RequiredDefaultedParam, 'bar') in('foo')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -269,9 +269,9 @@
public void testGetCriteriaDescForColumnNameMatchFailure() throws Exception {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredDefaultedParam from CriteriaDescTable where AttributeParam in('foo')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -283,9 +283,9 @@
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredDefaultedParam from CriteriaDescTable " //$NON-NLS-1$
+ "where concat('bar', 'foo') = concat('bar', RequiredDefaultedParam)"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -295,9 +295,9 @@
public void testGetCriteriaDescForColumnTwoElements() throws Exception {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredDefaultedParam from CriteriaDescTable where OutputColumn = RequiredDefaultedParam"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -307,9 +307,9 @@
public void testGetCriteriaDescForColumnLeftElementEqualsLiteral() throws Exception {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredDefaultedParam from CriteriaDescTable where AttributeParam = 'foo'"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -320,9 +320,9 @@
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select RequiredDefaultedParam from CriteriaDescTable where" //$NON-NLS-1$
+ " RequiredDefaultedParam = concat('foo', OutputColumn)"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -332,9 +332,9 @@
public void testGetInputXPathNoXpath() throws Exception {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select BadNoInputXpath from CriteriaDescTable where BadNoInputXpath in ('foo')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -345,9 +345,9 @@
public void testGetInputXPathEmptyXpath() throws Exception {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select BadEmptyInputXPath from CriteriaDescTable where BadEmptyInputXPath in ('foo')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -357,9 +357,9 @@
public void testGetDataAttributeNameEmptyName() throws Exception {
assertNotNull("vdb path is null", vdbPath); //$NON-NLS-1$
String query = "select BadNoDataAttributeName from CriteriaDescTable where BadNoDataAttributeName in ('foo')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -455,9 +455,9 @@
public void testGetCurrentIndexValueEnumerated() throws Exception {
String query = "select DelimitedParam from CriteriaDescTable where DelimitedParam in ('foo', 'bar')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, iquery);
@@ -469,9 +469,9 @@
public void testIncrementIndexEnumerated() throws Exception {
String query = "select DelimitedParam from CriteriaDescTable where DelimitedParam in ('foo', 'bar')"; //$NON-NLS-1$
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
RuntimeMetadata metadata = ProxyObjectFactory.getDefaultRuntimeMetadata(vdbPath);
Column elem = ((ColumnReference) expr).getMetadataObject();
@@ -515,7 +515,7 @@
}
public void testNameMatch() {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
Condition crit = query.getWhere();
List criteriaList = LanguageUtil.separateCriteriaByAnd(crit);
Iterator criteriaIter = criteriaList.iterator();
@@ -575,7 +575,7 @@
String strQuery = "Select Balance from Response"; //$NON-NLS-1$
try {
Column elem = getElement(strQuery);
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
CriteriaDesc desc = CriteriaDesc.getCriteriaDescForColumn(elem, query);
} finally {
vdbPath = tempVdbpath;
@@ -597,8 +597,8 @@
private Column getElement(String query, int colLocation)
throws ConnectorException {
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
Column elem = ((ColumnReference) expr).getMetadataObject();
return elem;
Modified: branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestExecutionInfo.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestExecutionInfo.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestExecutionInfo.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -30,7 +30,7 @@
import junit.framework.TestCase;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
/**
*
@@ -61,7 +61,7 @@
@Override
public void setUp() throws ConnectorException {
String vdbPath = ProxyObjectFactory.getStateCollegeVDBLocation();
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
QueryAnalyzer analyzer = new QueryAnalyzer(query);
analyzer.analyze();
m_info = analyzer.getExecutionInfo();
@@ -107,7 +107,7 @@
public void testGetCriteria() {
String vdbPath = ProxyObjectFactory.getStateCollegeVDBLocation();
//String query = "Select AttributeColumn from TestTable where AttributeColumn in ('foo')";
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
try {
QueryAnalyzer analyzer = new QueryAnalyzer(iquery);
analyzer.analyze();
@@ -124,7 +124,7 @@
public void testGetOtherProperties() throws ConnectorException {
String vdbPath = ProxyObjectFactory.getDocumentsFolder() + "/UnitTests.vdb";
String strQuery = "select * from Response";
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
QueryAnalyzer analyzer = new QueryAnalyzer(query);
analyzer.analyze();
ExecutionInfo info = analyzer.getExecutionInfo();
Modified: branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestOutputXPathDesc.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestOutputXPathDesc.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestOutputXPathDesc.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -27,15 +27,14 @@
import junit.framework.TestCase;
import org.teiid.connector.api.ConnectorException;
+import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.Comparison;
import org.teiid.connector.language.Condition;
-import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.Expression;
+import org.teiid.connector.language.LanguageUtil;
import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.QuerySpecification;
import org.teiid.connector.language.Select;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.LanguageUtil;
import org.teiid.connector.metadata.runtime.Column;
@@ -73,9 +72,8 @@
* Class under test for void OutputXPathDesc(Element)
*/
public void testOutputXPathDescElement() throws Exception {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- Select select = query.getSelect();
- List symbols = select.getDerivedColumns();
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ List symbols = query.getDerivedColumns();
DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
Expression expr = selectSymbol.getExpression();
assertTrue(expr instanceof ColumnReference);
@@ -87,9 +85,9 @@
public void testOutputXPathDescParam() throws Exception {
String query = "select RequiredDefaultedParam from CriteriaDescTable where RequiredDefaultedParam in ('foo')";
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
assertTrue(expr instanceof ColumnReference);
Column element = ((ColumnReference) expr).getMetadataObject();
@@ -101,9 +99,9 @@
public void testOutputXPathDescNoXPath() throws Exception {
try {
String query = "select OutputColumnNoXPath from CriteriaDescTable";
- QuerySpecification iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
+ Select iquery = ProxyObjectFactory.getDefaultIQuery(vdbPath, query);
final int colLocation = 0;
- DerivedColumn symbol = (DerivedColumn) iquery.getSelect().getDerivedColumns().get(colLocation);
+ DerivedColumn symbol = (DerivedColumn) iquery.getDerivedColumns().get(colLocation);
Expression expr = symbol.getExpression();
assertTrue(expr instanceof ColumnReference);
Column element = ((ColumnReference) expr).getMetadataObject();
@@ -119,7 +117,7 @@
public void testOutputXPathDescILiteral() throws Exception {
String strLiteral = "MetaMatrix";
String strQuery = "Select Company_id from Company where Company_id = '" + strLiteral + "'";
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
Condition crits = query.getWhere();
List criteriaList = LanguageUtil.separateCriteriaByAnd(crits);
Comparison compCriteria = (Comparison) criteriaList.get(0);
@@ -133,7 +131,7 @@
public void testOutputXPathDescILiteralNullValue() throws Exception {
String strLiteral = "MetaMatrix";
String strQuery = "Select Company_id from Company where Company_id = '" + strLiteral + "'";
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
Condition crits = query.getWhere();
List criteriaList = LanguageUtil.separateCriteriaByAnd(crits);
Comparison compCriteria = (Comparison) criteriaList.get(0);
@@ -146,9 +144,8 @@
}
public void testSetAndGetCurrentValue() throws Exception {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- Select select = query.getSelect();
- List symbols = select.getDerivedColumns();
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ List symbols = query.getDerivedColumns();
DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
Expression expr = selectSymbol.getExpression();
assertTrue(expr instanceof ColumnReference);
@@ -160,9 +157,8 @@
}
public void testGetDataType() throws Exception {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- Select select = query.getSelect();
- List symbols = select.getDerivedColumns();
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ List symbols = query.getDerivedColumns();
DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
Expression expr = selectSymbol.getExpression();
assertTrue(expr instanceof ColumnReference);
Modified: branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestParameterDescriptor.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestParameterDescriptor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestParameterDescriptor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -28,10 +28,9 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.QuerySpecification;
import org.teiid.connector.language.Select;
-import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.metadata.runtime.Column;
@@ -69,9 +68,8 @@
* Class under test for void ParameterDescriptor(Element)
*/
public void testParameterDescriptorElement() throws Exception {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- Select select = query.getSelect();
- List symbols = select.getDerivedColumns();
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ List symbols = query.getDerivedColumns();
DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
Expression expr = selectSymbol.getExpression();
assertTrue(expr instanceof ColumnReference);
@@ -82,9 +80,8 @@
public void testParameterDescriptorElementParameter() throws Exception {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, "select RequiredDefaultedParam from CriteriaDescTable");
- Select select = query.getSelect();
- List symbols = select.getDerivedColumns();
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, "select RequiredDefaultedParam from CriteriaDescTable");
+ List symbols = query.getDerivedColumns();
DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
Expression expr = selectSymbol.getExpression();
assertTrue(expr instanceof ColumnReference);
@@ -96,9 +93,8 @@
public void testParameterDescriptorElementSpaceXPath() throws Exception {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, "select OutputColumnSpaceXPath from CriteriaDescTable");
- Select select = query.getSelect();
- List symbols = select.getDerivedColumns();
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, "select OutputColumnSpaceXPath from CriteriaDescTable");
+ List symbols = query.getDerivedColumns();
DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
Expression expr = selectSymbol.getExpression();
assertTrue(expr instanceof ColumnReference);
@@ -147,9 +143,8 @@
}
public void testGetElement() throws Exception {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- Select select = query.getSelect();
- List symbols = select.getDerivedColumns();
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ List symbols = query.getDerivedColumns();
DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
Expression expr = selectSymbol.getExpression();
assertTrue(expr instanceof ColumnReference);
@@ -162,9 +157,8 @@
String trueQuery = "select EmptyCol from EmptyTable where EmptyCol = 'foo'";
String falseQuery = "select Company_id from Company";
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, trueQuery);
- Select select = query.getSelect();
- List symbols = select.getDerivedColumns();
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, trueQuery);
+ List symbols = query.getDerivedColumns();
DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
Expression expr = selectSymbol.getExpression();
assertTrue(expr instanceof ColumnReference);
@@ -172,8 +166,7 @@
assertTrue(ParameterDescriptor.testForParam(element));
query = ProxyObjectFactory.getDefaultIQuery(vdbPath, falseQuery);
- select = query.getSelect();
- symbols = select.getDerivedColumns();
+ symbols = query.getDerivedColumns();
selectSymbol = (DerivedColumn) symbols.get(0);
expr = selectSymbol.getExpression();
assertTrue(expr instanceof ColumnReference);
@@ -182,9 +175,8 @@
}
private ParameterDescriptor getParameterDescriptor() throws Exception {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
- Select select = query.getSelect();
- List symbols = select.getDerivedColumns();
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ List symbols = query.getDerivedColumns();
DerivedColumn selectSymbol = (DerivedColumn) symbols.get(0);
Expression expr = selectSymbol.getExpression();
assertTrue(expr instanceof ColumnReference);
Modified: branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestQueryAnalyzer.java
===================================================================
--- branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestQueryAnalyzer.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml/src/test/java/com/metamatrix/connector/xml/base/TestQueryAnalyzer.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -27,7 +27,7 @@
import junit.framework.TestCase;
import org.teiid.connector.api.ConnectorException;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
/**
*
@@ -57,7 +57,7 @@
}
public void testQueryAnalyzer() {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
try {
QueryAnalyzer analyzer = new QueryAnalyzer(query);
assertNotNull("analyzer is null", analyzer);
@@ -67,7 +67,7 @@
}
public void testAnalyze() {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
try {
QueryAnalyzer analyzer = new QueryAnalyzer(query);
analyzer.analyze();
@@ -78,7 +78,7 @@
public void testAnalyzeSimpleSelect() {
String strQuery = "select SimpleOutput from SimpleTable";
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
try {
QueryAnalyzer analyzer = new QueryAnalyzer(query);
analyzer.analyze();
@@ -89,7 +89,7 @@
public void testAnalyzeLiteralSelect() {
String strQuery = "select SimpleOutput, 'foo' from SimpleTable";
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
try {
QueryAnalyzer analyzer = new QueryAnalyzer(query);
analyzer.analyze();
@@ -100,7 +100,7 @@
public void testAnalyzeFunctionSelect() {
String strQuery = "select concat(SimpleOutput, 'foo') from SimpleTable";
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
try {
QueryAnalyzer analyzer = new QueryAnalyzer(query);
analyzer.analyze();
@@ -111,7 +111,7 @@
public void testAnalyzeParameterSelect() {
String strQuery = "select SimpleParam from SimpleInput where SimpleParam in ('foo')";
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
try {
QueryAnalyzer analyzer = new QueryAnalyzer(query);
analyzer.analyze();
@@ -122,7 +122,7 @@
public void testAnalyzeComplexQuery() {
String strQuery = "select SimpleOut from SimpleInput where SimpleParam in ('foo')";
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
try {
QueryAnalyzer analyzer = new QueryAnalyzer(query);
analyzer.analyze();
@@ -133,7 +133,7 @@
public void testAnalyzeComplexQuery2() {
String strQuery = "select SimpleOut from SimpleInput where SimpleParam in ('foo') and OtherOut in ('bar')";
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, strQuery);
try {
QueryAnalyzer analyzer = new QueryAnalyzer(query);
analyzer.analyze();
@@ -143,7 +143,7 @@
}
public void testGetExecutionInfo() {
- QuerySpecification query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
+ Select query = ProxyObjectFactory.getDefaultIQuery(vdbPath, QUERY);
try {
QueryAnalyzer analyzer = new QueryAnalyzer(query);
assertNotNull("analyzer is null", analyzer);
Modified: branches/JCA/connectors/connector-xml-http/src/main/java/org/teiid/connector/xml/http/HTTPConnectionImpl.java
===================================================================
--- branches/JCA/connectors/connector-xml-http/src/main/java/org/teiid/connector/xml/http/HTTPConnectionImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml-http/src/main/java/org/teiid/connector/xml/http/HTTPConnectionImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -3,7 +3,7 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ResultSetExecution;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.connector.xml.StatefulConnector;
@@ -23,7 +23,7 @@
public ResultSetExecution createResultSetExecution(QueryExpression command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new HTTPExecution((QuerySpecification)command, this, metadata, executionContext, getConnectorEnv());
+ return new HTTPExecution((Select)command, this, metadata, executionContext, getConnectorEnv());
}
//End Connection API Implementation
Modified: branches/JCA/connectors/connector-xml-http/src/main/java/org/teiid/connector/xml/http/HTTPExecution.java
===================================================================
--- branches/JCA/connectors/connector-xml-http/src/main/java/org/teiid/connector/xml/http/HTTPExecution.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml-http/src/main/java/org/teiid/connector/xml/http/HTTPExecution.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -25,7 +25,7 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.connector.xml.base.XMLConnectionImpl;
@@ -41,7 +41,7 @@
protected XMLConnectionImpl connection;
private ExecutionInfo executionInfo;
- public HTTPExecution(QuerySpecification query, XMLConnectionImpl conn, RuntimeMetadata metadata, ExecutionContext exeContext, XMLBaseManagedConnectionFactory connectorEnv) {
+ public HTTPExecution(Select query, XMLConnectionImpl conn, RuntimeMetadata metadata, ExecutionContext exeContext, XMLBaseManagedConnectionFactory connectorEnv) {
super(query, connectorEnv, metadata, exeContext);
this.connection = conn;
}
Modified: branches/JCA/connectors/connector-xml-soap/src/main/java/org/teiid/connector/xml/soap/SOAPConnectionImpl.java
===================================================================
--- branches/JCA/connectors/connector-xml-soap/src/main/java/org/teiid/connector/xml/soap/SOAPConnectionImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml-soap/src/main/java/org/teiid/connector/xml/soap/SOAPConnectionImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -3,7 +3,7 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ResultSetExecution;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.connector.xml.StatefulConnector;
@@ -23,7 +23,7 @@
@Override
public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new SOAPExecution((QuerySpecification)command, this, metadata, executionContext, getConnectorEnv());
+ return new SOAPExecution((Select)command, this, metadata, executionContext, getConnectorEnv());
}
//End Connection API Implementation
Modified: branches/JCA/connectors/connector-xml-soap/src/main/java/org/teiid/connector/xml/soap/SOAPExecution.java
===================================================================
--- branches/JCA/connectors/connector-xml-soap/src/main/java/org/teiid/connector/xml/soap/SOAPExecution.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xml-soap/src/main/java/org/teiid/connector/xml/soap/SOAPExecution.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -2,7 +2,7 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.connector.xml.SOAPConnectorState;
import org.teiid.connector.xml.base.XMLConnectionImpl;
@@ -13,7 +13,7 @@
public class SOAPExecution extends HTTPExecution {
- public SOAPExecution(QuerySpecification query, XMLConnectionImpl conn, RuntimeMetadata metadata, ExecutionContext exeContext, XMLBaseManagedConnectionFactory connectorEnv) {
+ public SOAPExecution(Select query, XMLConnectionImpl conn, RuntimeMetadata metadata, ExecutionContext exeContext, XMLBaseManagedConnectionFactory connectorEnv) {
super(query, conn, metadata, exeContext, connectorEnv);
}
Modified: branches/JCA/connectors/connector-xmlsource-file/src/main/java/org/teiid/connector/xmlsource/file/FileConnection.java
===================================================================
--- branches/JCA/connectors/connector-xmlsource-file/src/main/java/org/teiid/connector/xmlsource/file/FileConnection.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xmlsource-file/src/main/java/org/teiid/connector/xmlsource/file/FileConnection.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -32,7 +32,7 @@
import org.teiid.connector.basic.BasicManagedConnectionFactory;
import org.teiid.connector.language.Call;
import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xml.IQueryPreprocessor;
@@ -62,10 +62,10 @@
public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata) throws ConnectorException {
IQueryPreprocessor preProcessor = getQueryPreProcessor();
if (preProcessor != null) {
- command = preProcessor.preprocessQuery((QuerySpecification)command, metadata, executionContext, this.config);
+ command = preProcessor.preprocessQuery((Select)command, metadata, executionContext, this.config);
this.config.getLogger().logTrace("XML Connector Framework: executing command: " + command);
}
- return new FileResultSetExecution((QuerySpecification)command, this.config, metadata, executionContext);
+ return new FileResultSetExecution((Select)command, this.config, metadata, executionContext);
}
@Override
Modified: branches/JCA/connectors/connector-xmlsource-file/src/main/java/org/teiid/connector/xmlsource/file/FileResultSetExecution.java
===================================================================
--- branches/JCA/connectors/connector-xmlsource-file/src/main/java/org/teiid/connector/xmlsource/file/FileResultSetExecution.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xmlsource-file/src/main/java/org/teiid/connector/xmlsource/file/FileResultSetExecution.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -35,7 +35,7 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.common.types.InputStreamFactory;
@@ -55,7 +55,7 @@
private FileManagedConnectionFactory env;
private File content;
- public FileResultSetExecution(QuerySpecification command, FileManagedConnectionFactory config, RuntimeMetadata metadata, ExecutionContext context) {
+ public FileResultSetExecution(Select command, FileManagedConnectionFactory config, RuntimeMetadata metadata, ExecutionContext context) {
super(command, config, metadata, context);
this.env = config;
}
Modified: branches/JCA/connectors/connector-xmlsource-soap/src/main/java/org/teiid/connector/xmlsource/soap/SOAPResultSetExecution.java
===================================================================
--- branches/JCA/connectors/connector-xmlsource-soap/src/main/java/org/teiid/connector/xmlsource/soap/SOAPResultSetExecution.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xmlsource-soap/src/main/java/org/teiid/connector/xmlsource/soap/SOAPResultSetExecution.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -29,7 +29,7 @@
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.ExecutionContext;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.connector.xml.Document;
@@ -44,7 +44,7 @@
private ExecutionInfo executionInfo;
private ArrayList<SOAPRequest> requests = new ArrayList<SOAPRequest>();
- public SOAPResultSetExecution(QuerySpecification query, RuntimeMetadata metadata, ExecutionContext exeContext, SoapManagedConnectionFactory config) {
+ public SOAPResultSetExecution(Select query, RuntimeMetadata metadata, ExecutionContext exeContext, SoapManagedConnectionFactory config) {
super(query, config, metadata, exeContext);
}
Modified: branches/JCA/connectors/connector-xmlsource-soap/src/main/java/org/teiid/connector/xmlsource/soap/SoapConnection.java
===================================================================
--- branches/JCA/connectors/connector-xmlsource-soap/src/main/java/org/teiid/connector/xmlsource/soap/SoapConnection.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/connector-xmlsource-soap/src/main/java/org/teiid/connector/xmlsource/soap/SoapConnection.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -29,7 +29,7 @@
import org.teiid.connector.basic.BasicConnection;
import org.teiid.connector.basic.BasicManagedConnectionFactory;
import org.teiid.connector.language.Call;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -68,10 +68,10 @@
throws ConnectorException {
IQueryPreprocessor preProcessor = getQueryPreProcessor();
if (preProcessor != null) {
- command = preProcessor.preprocessQuery((QuerySpecification)command, metadata, executionContext, this.config);
+ command = preProcessor.preprocessQuery((Select)command, metadata, executionContext, this.config);
this.config.getLogger().logTrace("XML Connector Framework: executing command: " + command);
}
- return new SOAPResultSetExecution((QuerySpecification)command, metadata, executionContext, this.config);
+ return new SOAPResultSetExecution((Select)command, metadata, executionContext, this.config);
}
private IQueryPreprocessor getQueryPreProcessor() throws ConnectorException {
Modified: branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecAntExecution.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -45,7 +45,7 @@
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.basic.BasicExecution;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import com.metamatrix.common.util.OSPlatformUtil;
@@ -72,9 +72,9 @@
private Process p = null;
private List exclusionList;
- private QuerySpecification query;
+ private Select query;
- public ExecAntExecution(QuerySpecification query, ExecManagedConnectionFactory env, RuntimeMetadata metadata, List exclusionThese) {
+ public ExecAntExecution(Select query, ExecManagedConnectionFactory env, RuntimeMetadata metadata, List exclusionThese) {
this.config = env;
this.query = query;
if (exclusionThese != null)
Modified: branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/sandbox/connector-exec/src/main/java/com/metamatrix/connector/exec/ExecConnection.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -27,7 +27,7 @@
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.basic.BasicConnection;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -50,7 +50,7 @@
public ResultSetExecution createResultSetExecution(QueryExpression command,
ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new ExecAntExecution((QuerySpecification)command, this.config, metadata, exclusionList);
+ return new ExecAntExecution((Select)command, this.config, metadata, exclusionList);
}
@Override
Modified: branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooConnection.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -26,7 +26,7 @@
import org.teiid.connector.api.ExecutionContext;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.basic.BasicConnection;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -45,7 +45,7 @@
@Override
public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata)
throws ConnectorException {
- return new YahooExecution((QuerySpecification)command, config, metadata);
+ return new YahooExecution((Select)command, config, metadata);
}
public void close() {
Modified: branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/sandbox/connector-yahoo/src/main/java/com/metamatrix/connector/yahoo/YahooExecution.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -43,12 +43,11 @@
import org.teiid.connector.api.DataNotAvailableException;
import org.teiid.connector.api.ResultSetExecution;
import org.teiid.connector.basic.BasicExecution;
-import org.teiid.connector.language.Condition;
import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.Condition;
+import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.QuerySpecification;
import org.teiid.connector.language.Select;
-import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
@@ -67,13 +66,13 @@
// Connector resources
private YahooManagedConnectionFactory config;
private RuntimeMetadata metadata;
- private QuerySpecification command;
+ private Select command;
// Execution state
List results;
int[] neededColumns;
int returnIndex = 0;
- private QuerySpecification query;
+ private Select query;
private String previousHttpProxyHost;
private String previousHttpProxyPort;
@@ -81,7 +80,7 @@
/**
*
*/
- public YahooExecution(QuerySpecification query, YahooManagedConnectionFactory env, RuntimeMetadata metadata) {
+ public YahooExecution(Select query, YahooManagedConnectionFactory env, RuntimeMetadata metadata) {
this.config = env;
this.metadata = metadata;
this.query = query;
@@ -102,10 +101,10 @@
this.results = executeUrl(yahooUrl, this.config.getLogger());
// Determine needed columns in results
- this.neededColumns = getNeededColumns(query.getSelect(), this.metadata);
+ this.neededColumns = getNeededColumns(query.getDerivedColumns(), this.metadata);
}
- static String translateIntoUrl(QuerySpecification query) throws ConnectorException {
+ static String translateIntoUrl(Select query) throws ConnectorException {
StringBuffer url = new StringBuffer();
url.append(YahooPlugin.Util.getString("YahooExecution.URL_BEGIN")); //$NON-NLS-1$
@@ -128,7 +127,7 @@
/**
* @return
*/
- static Set getTickers(QuerySpecification query) throws ConnectorException {
+ static Set getTickers(Select query) throws ConnectorException {
Condition crit = query.getWhere();
if(crit == null) {
throw new ConnectorException(YahooPlugin.Util.getString("YahooExecution.Must_have_criteria")); //$NON-NLS-1$
@@ -244,9 +243,9 @@
* @param select
* @return
*/
- static int[] getNeededColumns(Select select, RuntimeMetadata metadata) throws ConnectorException {
- int[] cols = new int[select.getDerivedColumns().size()];
- Iterator iter = select.getDerivedColumns().iterator();
+ static int[] getNeededColumns(List<DerivedColumn> select, RuntimeMetadata metadata) throws ConnectorException {
+ int[] cols = new int[select.size()];
+ Iterator iter = select.iterator();
for(int i=0; iter.hasNext(); i++) {
DerivedColumn symbol = (DerivedColumn) iter.next();
Expression expr = symbol.getExpression();
Modified: branches/JCA/connectors/sandbox/connector-yahoo/src/test/java/com/metamatrix/connector/yahoo/TestYahooTranslation.java
===================================================================
--- branches/JCA/connectors/sandbox/connector-yahoo/src/test/java/com/metamatrix/connector/yahoo/TestYahooTranslation.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/connectors/sandbox/connector-yahoo/src/test/java/com/metamatrix/connector/yahoo/TestYahooTranslation.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -23,7 +23,7 @@
package com.metamatrix.connector.yahoo;
import org.teiid.connector.language.Command;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import junit.framework.TestCase;
@@ -34,7 +34,7 @@
public void helpTestTranslation(String sql, String expectedUrl) throws Exception {
Command command = FakeTranslationFactory.getInstance().getYahooTranslationUtility().parseCommand(sql);
- String url = YahooExecution.translateIntoUrl((QuerySpecification) command);
+ String url = YahooExecution.translateIntoUrl((Select) command);
assertEquals("Did not get expected url", expectedUrl, url); //$NON-NLS-1$
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -47,7 +47,7 @@
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Not;
import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.SearchedCase;
import org.teiid.connector.language.SortSpecification;
import org.teiid.connector.language.SubqueryComparison;
@@ -75,7 +75,6 @@
import com.metamatrix.query.sql.lang.Criteria;
import com.metamatrix.query.sql.lang.Delete;
import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.From;
import com.metamatrix.query.sql.lang.FromClause;
import com.metamatrix.query.sql.lang.GroupBy;
import com.metamatrix.query.sql.lang.Insert;
@@ -89,7 +88,6 @@
import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.QueryCommand;
import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
import com.metamatrix.query.sql.lang.SetClause;
import com.metamatrix.query.sql.lang.SetClauseList;
import com.metamatrix.query.sql.lang.SetCriteria;
@@ -170,19 +168,8 @@
}
/* Query */
- QuerySpecification translate(Query query) throws MetaMatrixComponentException {
- QuerySpecification q = new QuerySpecification(translate(query.getSelect()),
- translate(query.getFrom()),
- translate(query.getCriteria()),
- translate(query.getGroupBy()),
- translate(query.getHaving()),
- translate(query.getOrderBy()));
- q.setLimit(translate(query.getLimit()));
- return q;
- }
-
- public org.teiid.connector.language.Select translate(Select select) throws MetaMatrixComponentException {
- List symbols = select.getSymbols();
+ Select translate(Query query) throws MetaMatrixComponentException {
+ List symbols = query.getSelect().getSymbols();
List<DerivedColumn> translatedSymbols = new ArrayList<DerivedColumn>(symbols.size());
for (Iterator i = symbols.iterator(); i.hasNext();) {
SingleElementSymbol symbol = (SingleElementSymbol)i.next();
@@ -204,17 +191,21 @@
DerivedColumn selectSymbol = new DerivedColumn(alias, iExp);
translatedSymbols.add(selectSymbol);
}
- return new org.teiid.connector.language.Select(translatedSymbols, select.isDistinct());
+ List<TableReference> items = null;
+ if (query.getFrom() != null) {
+ List clauses = query.getFrom().getClauses();
+ items = new ArrayList<TableReference>(clauses.size());
+ for (Iterator i = clauses.iterator(); i.hasNext();) {
+ items.add(translate((FromClause)i.next()));
+ }
+ }
+ Select q = new Select(translatedSymbols, query
+ .getSelect().isDistinct(), items,
+ translate(query.getCriteria()), translate(query.getGroupBy()),
+ translate(query.getHaving()), translate(query.getOrderBy()));
+ q.setLimit(translate(query.getLimit()));
+ return q;
}
-
- public org.teiid.connector.language.From translate(From from) throws MetaMatrixComponentException {
- List clauses = from.getClauses();
- List<TableReference> items = new ArrayList<TableReference>();
- for (Iterator i = clauses.iterator(); i.hasNext();) {
- items.add(translate((FromClause)i.next()));
- }
- return new org.teiid.connector.language.From(items);
- }
public TableReference translate(FromClause clause) throws MetaMatrixComponentException {
if (clause == null) return null;
Modified: branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -45,7 +45,7 @@
DQPWorkContext workContext = new DQPWorkContext();
workContext.setSessionToken(new SessionToken(2, "foo")); //$NON-NLS-1$
AtomicRequestMessage message = new AtomicRequestMessage(rm, workContext, 1000);
- message.setCommand(TestQueryImpl.helpExample());
+ message.setCommand(TestQueryImpl.helpExample(true));
message.setFetchSize(100);
message.setPartialResults(true);
message.setRequestID(new RequestID(5000L));
@@ -59,7 +59,7 @@
AtomicRequestMessage example = example();
AtomicRequestMessage copy = UnitTestUtil.helpSerialize(example);
- assertEquals(TestQueryImpl.helpExample(), copy.getCommand());
+ assertEquals(TestQueryImpl.helpExample(true), copy.getCommand());
assertEquals(100, copy.getFetchSize());
assertEquals(example.getProcessingTimestamp(), copy.getProcessingTimestamp());
Modified: branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -187,23 +187,20 @@
// Add stored procedure
Schema pm1 = createPhysicalModel("pm1", metadataStore); //$NON-NLS-1$
ProcedureParameter rs1p1 = createParameter("intkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- ColumnSet<Procedure> rs1 = createResultSet("pm1.rs1", pm1, new String[] { "IntKey", "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ProcedureParameter rs1p2 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs1); //$NON-NLS-1$
- Procedure spTest5 = createStoredProcedure("spTest5", pm1, Arrays.asList(rs1p1, rs1p2), "spTest5"); //$NON-NLS-1$ //$NON-NLS-2$
+ ColumnSet<Procedure> rs1 = createResultSet("rs1", pm1, new String[] { "IntKey", "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Procedure spTest5 = createStoredProcedure("spTest5", pm1, Arrays.asList(rs1p1), "spTest5"); //$NON-NLS-1$ //$NON-NLS-2$
spTest5.setResultSet(rs1);
Schema pm2 = createPhysicalModel("pm2", metadataStore); //$NON-NLS-1$
ProcedureParameter rs2p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
ProcedureParameter rs2p2 = createParameter("outkey", 3, ParameterInfo.OUT, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- ColumnSet<Procedure> rs2 = createResultSet("pm2.rs2", pm2, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ProcedureParameter rs2p3 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2); //$NON-NLS-1$
- Procedure spTest8 = createStoredProcedure("spTest8", pm2, Arrays.asList(rs2p1, rs2p2, rs2p3), "spTest8"); //$NON-NLS-1$ //$NON-NLS-2$
+ ColumnSet<Procedure> rs2 = createResultSet("rs2", pm2, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Procedure spTest8 = createStoredProcedure("spTest8", pm2, Arrays.asList(rs2p1, rs2p2), "spTest8"); //$NON-NLS-1$ //$NON-NLS-2$
spTest8.setResultSet(rs2);
ProcedureParameter rs2p2a = createParameter("outkey", 3, ParameterInfo.OUT, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- ColumnSet<Procedure> rs2a = createResultSet("pm2.rs2", pm2, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ProcedureParameter rs2p3a = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs2); //$NON-NLS-1$
- Procedure spTest8a = createStoredProcedure("spTest8a", pm2, Arrays.asList(rs2p2a, rs2p3a), "spTest8a"); //$NON-NLS-1$ //$NON-NLS-2$
+ ColumnSet<Procedure> rs2a = createResultSet("rs2", pm2, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Procedure spTest8a = createStoredProcedure("spTest8a", pm2, Arrays.asList(rs2p2a), "spTest8a"); //$NON-NLS-1$ //$NON-NLS-2$
spTest8a.setResultSet(rs2a);
Schema pm4 = createPhysicalModel("pm4", metadataStore); //$NON-NLS-1$
@@ -214,49 +211,42 @@
Schema pm3 = createPhysicalModel("pm3", metadataStore); //$NON-NLS-1$
ProcedureParameter rs3p1 = createParameter("inkey", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
ProcedureParameter rs3p2 = createParameter("outkey", 3, ParameterInfo.INOUT, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- ColumnSet<Procedure> rs3 = createResultSet("pm3.rs3", pm3, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ProcedureParameter rs3p3 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs3); //$NON-NLS-1$
- Procedure spTest11 = createStoredProcedure("spTest11", pm3, Arrays.asList(rs3p1, rs3p2, rs3p3), "spTest11"); //$NON-NLS-1$ //$NON-NLS-2$
+ ColumnSet<Procedure> rs3 = createResultSet("rs3", pm3, new String[] { "IntKey", "StringKey"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER , DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Procedure spTest11 = createStoredProcedure("spTest11", pm3, Arrays.asList(rs3p1, rs3p2), "spTest11"); //$NON-NLS-1$ //$NON-NLS-2$
spTest11.setResultSet(rs3);
//add virtual stored procedures
Schema mmspTest1 = createVirtualModel("mmspTest1", metadataStore); //$NON-NLS-1$
ColumnSet<Procedure> vsprs1 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
- ProcedureParameter vspp1 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, vsprs1); //$NON-NLS-1$
QueryNode vspqn1 = new QueryNode("vsp1", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor BEGIN x= intKeyCursor.intkey - 1; END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
- Procedure vsp1 = createVirtualProcedure("MMSP1", mmspTest1, Arrays.asList(vspp1), vspqn1); //$NON-NLS-1$
+ Procedure vsp1 = createVirtualProcedure("MMSP1", mmspTest1, null, vspqn1); //$NON-NLS-1$
vsp1.setResultSet(vsprs1);
ColumnSet<Procedure> vsprs2 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
- ProcedureParameter vspp2 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, vsprs1); //$NON-NLS-1$
QueryNode vspqn2 = new QueryNode("vsp2", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor1 BEGIN LOOP ON (SELECT intkey FROM bqt1.smallB) AS intKeyCursor2 BEGIN x= intKeyCursor1.intkey - intKeyCursor2.intkey; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
- Procedure vsp2 = createVirtualProcedure("MMSP2", mmspTest1, Arrays.asList(vspp2), vspqn2); //$NON-NLS-1$
+ Procedure vsp2 = createVirtualProcedure("MMSP2", mmspTest1, null, vspqn2); //$NON-NLS-1$
vsp2.setResultSet(vsprs2);
ColumnSet<Procedure> vsprs3 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
- ProcedureParameter vspp3 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, vsprs1); //$NON-NLS-1$
QueryNode vspqn3 = new QueryNode("vsp3", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; LOOP ON (SELECT intkey FROM bqt1.smallA) AS intKeyCursor BEGIN x= intKeyCursor.intkey - 1; if(x = 25) BEGIN BREAK; END ELSE BEGIN CONTINUE; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
- Procedure vsp3 = createVirtualProcedure("MMSP3", mmspTest1, Arrays.asList(vspp3), vspqn3); //$NON-NLS-1$
+ Procedure vsp3 = createVirtualProcedure("MMSP3", mmspTest1, null, vspqn3); //$NON-NLS-1$
vsp3.setResultSet(vsprs3);
ColumnSet<Procedure> vsprs4 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
- ProcedureParameter vspp4 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, vsprs1); //$NON-NLS-1$
QueryNode vspqn4 = new QueryNode("vsp4", "CREATE VIRTUAL PROCEDURE BEGIN DECLARE integer x; x=0; WHILE(x < 50) BEGIN x= x + 1; if(x = 25) BEGIN BREAK; END ELSE BEGIN CONTINUE; END END SELECT stringkey FROM bqt1.smalla where intkey=x; END"); //$NON-NLS-1$ //$NON-NLS-2$
- Procedure vsp4 = createVirtualProcedure("MMSP4", mmspTest1, Arrays.asList(vspp4), vspqn4); //$NON-NLS-1$
+ Procedure vsp4 = createVirtualProcedure("MMSP4", mmspTest1, null, vspqn4); //$NON-NLS-1$
vsp4.setResultSet(vsprs4);
ColumnSet<Procedure> vsprs5 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
- ProcedureParameter vspp5 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, vsprs1); //$NON-NLS-1$
ProcedureParameter vsp5p1 = createParameter("param1", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
QueryNode vspqn5 = new QueryNode("vsp5", "CREATE VIRTUAL PROCEDURE BEGIN SELECT 0; END"); //$NON-NLS-1$ //$NON-NLS-2$
- Procedure vsp5 = createVirtualProcedure("MMSP5", mmspTest1, Arrays.asList(vspp5, vsp5p1), vspqn5); //$NON-NLS-1$
+ Procedure vsp5 = createVirtualProcedure("MMSP5", mmspTest1, Arrays.asList(vsp5p1), vspqn5); //$NON-NLS-1$
vsp5.setResultSet(vsprs5);
ColumnSet<Procedure> vsprs6 = createResultSet("mmspTest1.vsprs1", mmspTest1, new String[] { "StringKey" }, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
- ProcedureParameter vspp6 = createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, vsprs1); //$NON-NLS-1$
ProcedureParameter vsp6p1 = createParameter("p1", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
QueryNode vspqn6 = new QueryNode("vsp6", "CREATE VIRTUAL PROCEDURE BEGIN SELECT 1; END"); //$NON-NLS-1$ //$NON-NLS-2$
- Procedure vsp6 = createVirtualProcedure("MMSP6", mmspTest1, Arrays.asList(vspp6, vsp6p1), vspqn6); //$NON-NLS-1$
+ Procedure vsp6 = createVirtualProcedure("MMSP6", mmspTest1, Arrays.asList(vsp6p1), vspqn6); //$NON-NLS-1$
vsp6.setResultSet(vsprs6);
CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
@@ -487,7 +477,6 @@
public static ProcedureParameter createParameter(String name, int index, int direction, String type, Object rs) {
ProcedureParameter param = new ProcedureParameter();
param.setName(name);
- param.setPosition(index);
switch (direction) {
case SPParameter.IN:
param.setType(Type.In);
@@ -499,8 +488,7 @@
param.setType(Type.Out);
break;
case SPParameter.RESULT_SET:
- param.setType(Type.ResultSet);
- break;
+ throw new AssertionError("should not directly create a resultset param"); //$NON-NLS-1$
case SPParameter.RETURN_VALUE:
param.setType(Type.ReturnValue);
break;
@@ -520,10 +508,14 @@
public static Procedure createStoredProcedure(String name, Schema model, List<ProcedureParameter> params, String callableName) {
Procedure proc = new Procedure();
proc.setName(name);
- for (ProcedureParameter procedureParameter : params) {
- procedureParameter.setProcedure(proc);
- }
- proc.setParameters(params);
+ if (params != null) {
+ int index = 1;
+ for (ProcedureParameter procedureParameter : params) {
+ procedureParameter.setProcedure(proc);
+ procedureParameter.setPosition(index++);
+ }
+ proc.setParameters(params);
+ }
model.addProcedure(proc);
return proc;
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -42,7 +42,7 @@
}
public static ExistsCriteria helpExample() {
- ExistsCriteria crit = new ExistsCriteria(TestQueryImpl.helpExample());
+ ExistsCriteria crit = new ExistsCriteria(TestQueryImpl.helpExample(true));
return crit;
}
Deleted: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFromImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -1,69 +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.dqp.internal.datamgr.language;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.teiid.connector.language.From;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.TableReference;
-
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-
-public class TestFromImpl extends TestCase {
-
- /**
- * Constructor for TestFromImpl.
- * @param name
- */
- public TestFromImpl(String name) {
- super(name);
- }
-
- public static com.metamatrix.query.sql.lang.From helpExample() {
- List<UnaryFromClause> clauses = new ArrayList<UnaryFromClause>();
- clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g1"))); //$NON-NLS-1$
- clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("myAlias", "vm1.g2"))); //$NON-NLS-1$ //$NON-NLS-2$
- clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g3"))); //$NON-NLS-1$
- clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g4"))); //$NON-NLS-1$
- return new com.metamatrix.query.sql.lang.From(clauses);
- }
-
- public static From example() throws Exception {
- return TstLanguageBridgeFactory.factory.translate(helpExample());
- }
-
- public void testGetItems() throws Exception {
- From from = example();
- assertNotNull(from.getItems());
- assertEquals(4, from.getItems().size());
- for (Iterator<TableReference> i = from.getItems().iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof NamedTable);
- }
- }
-
-}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -36,7 +36,7 @@
}
public static SubqueryFromClause helpExample() {
- return new SubqueryFromClause("xyz", TestQueryImpl.helpExample()); //$NON-NLS-1$
+ return new SubqueryFromClause("xyz", TestQueryImpl.helpExample(true)); //$NON-NLS-1$
}
public static DerivedTable example() throws Exception {
@@ -48,7 +48,7 @@
}
public void testGetQuery() throws Exception {
- assertEquals("SELECT DISTINCT vm1.g1.e1, vm1.g1.e2, vm1.g1.e3, vm1.g1.e4 FROM vm1.g1, vm1.g2 AS myAlias, vm1.g3, vm1.g4 WHERE 100 >= 200 AND 100 >= 200 GROUP BY vm1.g1.e1, vm1.g1.e2, vm1.g1.e3, vm1.g1.e4 HAVING 100 >= 200 AND 100 >= 200 ORDER BY e1, e2 DESC, e3, e4 DESC", example().getQuery().toString()); //$NON-NLS-1$
+ assertEquals("SELECT DISTINCT vm1.g1.e1, vm1.g1.e2, vm1.g1.e3, vm1.g1.e4 FROM vm1.g1, vm1.g2 AS myAlias, vm1.g3, vm1.g4 WHERE 100 >= 200 AND 500 < 600 GROUP BY vm1.g1.e1, vm1.g1.e2, vm1.g1.e3, vm1.g1.e4 HAVING 100 >= 200 AND 500 < 600 ORDER BY e1, e2 DESC, e3, e4 DESC", example().getQuery().toString()); //$NON-NLS-1$
}
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -23,13 +23,20 @@
package org.teiid.dqp.internal.datamgr.language;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import junit.framework.TestCase;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.DerivedColumn;
+import org.teiid.connector.language.Select;
import com.metamatrix.core.util.EquivalenceUtil;
import com.metamatrix.query.sql.lang.CompoundCriteria;
import com.metamatrix.query.sql.lang.Query;
+import com.metamatrix.query.sql.lang.UnaryFromClause;
+import com.metamatrix.query.sql.symbol.ElementSymbol;
public class TestQueryImpl extends TestCase {
@@ -40,10 +47,21 @@
public TestQueryImpl(String name) {
super(name);
}
+
+ public static com.metamatrix.query.sql.lang.Select helpExampleSelect(boolean distinct) {
+ ArrayList<ElementSymbol> symbols = new ArrayList<ElementSymbol>();
+ symbols.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
+ symbols.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
+ symbols.add(TestElementImpl.helpExample("vm1.g1", "e3")); //$NON-NLS-1$ //$NON-NLS-2$
+ symbols.add(TestElementImpl.helpExample("vm1.g1", "e4")); //$NON-NLS-1$ //$NON-NLS-2$
+ com.metamatrix.query.sql.lang.Select sel = new com.metamatrix.query.sql.lang.Select(symbols);
+ sel.setDistinct(distinct);
+ return sel;
+ }
- public static Query helpExample() {
- return new Query(TestSelectImpl.helpExample(true),
- TestFromImpl.helpExample(),
+ public static Query helpExample(boolean distinct) {
+ return new Query(helpExampleSelect(distinct),
+ TestQueryImpl.helpExampleFrom(),
TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
TestGroupByImpl.helpExample(),
TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
@@ -51,44 +69,67 @@
null);
}
- public static QuerySpecification example() throws Exception {
- return TstLanguageBridgeFactory.factory.translate(helpExample());
+ public static Select example(boolean distinct) throws Exception {
+ return TstLanguageBridgeFactory.factory.translate(helpExample(distinct));
}
public void testGetSelect() throws Exception {
- assertNotNull(example().getSelect());
+ assertNotNull(example(true).getDerivedColumns());
}
public void testGetFrom() throws Exception {
- assertNotNull(example().getFrom());
+ assertNotNull(example(true).getFrom());
}
public void testGetWhere() throws Exception {
- assertNotNull(example().getWhere());
+ assertNotNull(example(true).getWhere());
}
public void testGetGroupBy() throws Exception {
- assertNotNull(example().getGroupBy());
+ assertNotNull(example(true).getGroupBy());
}
public void testGetHaving() throws Exception {
- assertNotNull(example().getHaving());
+ assertNotNull(example(true).getHaving());
}
public void testGetOrderBy() throws Exception {
- assertNotNull(example().getOrderBy());
+ assertNotNull(example(true).getOrderBy());
}
public void testGetColumnNames() throws Exception {
String[] expected = new String[4];
- String[] names = example().getColumnNames();
+ String[] names = example(true).getColumnNames();
assertTrue(EquivalenceUtil.areEquivalent(expected, names));
}
public void testGetColumnTypes() throws Exception {
Class[] expected = {String.class, String.class, String.class, String.class};
- Class[] types = example().getColumnTypes();
+ Class[] types = example(true).getColumnTypes();
assertTrue(EquivalenceUtil.areEquivalent(expected, types));
}
+ public static com.metamatrix.query.sql.lang.From helpExampleFrom() {
+ List<UnaryFromClause> clauses = new ArrayList<UnaryFromClause>();
+ clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g1"))); //$NON-NLS-1$
+ clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("myAlias", "vm1.g2"))); //$NON-NLS-1$ //$NON-NLS-2$
+ clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g3"))); //$NON-NLS-1$
+ clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g4"))); //$NON-NLS-1$
+ return new com.metamatrix.query.sql.lang.From(clauses);
+ }
+
+ public void testGetSelectSymbols() throws Exception {
+ List symbols = example(false).getDerivedColumns();
+ assertNotNull(symbols);
+ assertEquals(4, symbols.size());
+ for (Iterator i = symbols.iterator(); i.hasNext();) {
+ assertTrue(i.next() instanceof DerivedColumn);
+ }
+ }
+
+ public void testIsDistinct() throws Exception {
+ assertTrue(example(true).isDistinct());
+ assertFalse(example(false).isDistinct());
+ }
+
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -24,7 +24,7 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
import com.metamatrix.query.sql.lang.Query;
@@ -43,7 +43,7 @@
}
public static com.metamatrix.query.sql.symbol.ScalarSubquery helpExample() {
- Query query = TestQueryImpl.helpExample();
+ Query query = TestQueryImpl.helpExample(true);
com.metamatrix.query.sql.symbol.ScalarSubquery ss = new com.metamatrix.query.sql.symbol.ScalarSubquery(query);
ss.setType(((SingleElementSymbol)query.getProjectedSymbols().get(0)).getType());
return ss;
@@ -57,8 +57,8 @@
assertNotNull(example().getSubquery()); }
public void testGetType() throws Exception {
- QuerySpecification query = TstLanguageBridgeFactory.factory.translate(TestQueryImpl.helpExample());
- Class<?> firstSymbolType = query.getSelect().getDerivedColumns().get(0).getExpression().getType();
+ Select query = TstLanguageBridgeFactory.factory.translate(TestQueryImpl.helpExample(true));
+ Class<?> firstSymbolType = query.getDerivedColumns().get(0).getExpression().getType();
assertEquals("Got incorrect type", firstSymbolType, example().getType()); //$NON-NLS-1$
}
Deleted: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -1,75 +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.dqp.internal.datamgr.language;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.Select;
-
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-
-public class TestSelectImpl extends TestCase {
-
- /**
- * Constructor for TestSelectImpl.
- * @param name
- */
- public TestSelectImpl(String name) {
- super(name);
- }
-
- public static com.metamatrix.query.sql.lang.Select helpExample(boolean distinct) {
- ArrayList<ElementSymbol> symbols = new ArrayList<ElementSymbol>();
- symbols.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
- symbols.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
- symbols.add(TestElementImpl.helpExample("vm1.g1", "e3")); //$NON-NLS-1$ //$NON-NLS-2$
- symbols.add(TestElementImpl.helpExample("vm1.g1", "e4")); //$NON-NLS-1$ //$NON-NLS-2$
- com.metamatrix.query.sql.lang.Select sel = new com.metamatrix.query.sql.lang.Select(symbols);
- sel.setDistinct(distinct);
- return sel;
- }
-
- public static Select example(boolean distinct) throws Exception {
- return TstLanguageBridgeFactory.factory.translate(helpExample(distinct));
- }
-
- public void testGetSelectSymbols() throws Exception {
- List symbols = example(false).getDerivedColumns();
- assertNotNull(symbols);
- assertEquals(4, symbols.size());
- for (Iterator i = symbols.iterator(); i.hasNext();) {
- assertTrue(i.next() instanceof DerivedColumn);
- }
- }
-
- public void testIsDistinct() throws Exception {
- assertTrue(example(true).isDistinct());
- assertFalse(example(false).isDistinct());
- }
-
-}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -22,13 +22,13 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.Expression;
+import junit.framework.TestCase;
+
+import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.DerivedColumn;
-import com.metamatrix.query.sql.symbol.*;
+import com.metamatrix.common.types.DataTypeManager;
-import junit.framework.TestCase;
-
public class TestSelectSymbolImpl extends TestCase {
/**
@@ -39,23 +39,8 @@
super(name);
}
- public static com.metamatrix.query.sql.symbol.Expression helpExample(String name, String alias) {
- SingleElementSymbol symbol = TestElementImpl.helpExample("vm1.g1", name); //$NON-NLS-1$
-
- if (alias != null) {
- return new AliasSymbol(alias, symbol);
- }
- return symbol;
- }
-
public static DerivedColumn example(String symbolName, String alias) throws Exception {
- com.metamatrix.query.sql.symbol.Expression expr = helpExample(symbolName, alias);
- Expression iExp = TstLanguageBridgeFactory.factory.translate(expr);
- String name = null;
- if (expr instanceof AliasSymbol) {
- name = ((AliasSymbol)expr).getOutputName();
- }
- DerivedColumn selectSymbol = new DerivedColumn(name, iExp);
+ DerivedColumn selectSymbol = new DerivedColumn(alias, new ColumnReference(null, symbolName, null, DataTypeManager.DefaultDataClasses.INTEGER));
return selectSymbol;
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -29,17 +29,13 @@
import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.From;
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.QuerySpecification;
import org.teiid.connector.language.Select;
import org.teiid.connector.language.SetQuery;
import org.teiid.connector.language.SortSpecification;
import org.teiid.connector.language.SortSpecification.Ordering;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Query;
import com.metamatrix.query.sql.lang.SetQuery.Operation;
@@ -48,21 +44,11 @@
*/
public class TestSetQueryImpl extends TestCase {
- public static Query helpExampleQuery() {
- return new Query(TestSelectImpl.helpExample(true),
- TestFromImpl.helpExample(),
- TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
- TestGroupByImpl.helpExample(),
- TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND),
- TestOrderByImpl.helpExample(),
- null);
- }
-
public static com.metamatrix.query.sql.lang.SetQuery helpExampleSetQuery() {
com.metamatrix.query.sql.lang.SetQuery setQuery = new com.metamatrix.query.sql.lang.SetQuery(Operation.UNION);
setQuery.setAll(false);
- setQuery.setLeftQuery(helpExampleQuery());
- setQuery.setRightQuery(helpExampleQuery());
+ setQuery.setLeftQuery(TestQueryImpl.helpExample(true));
+ setQuery.setRightQuery(TestQueryImpl.helpExample(true));
setQuery.setOrderBy(TestOrderByImpl.helpExample());
return setQuery;
}
@@ -77,25 +63,21 @@
DerivedColumn symbol = new DerivedColumn("nugent",element); //$NON-NLS-1$
List symbols = new ArrayList();
symbols.add(symbol);
- Select select = new Select(symbols, false);
List items = new ArrayList();
items.add(group);
- From from = new From(items);
NamedTable group2 = new NamedTable("dave", null, null); //$NON-NLS-1$
ColumnReference element2 = new ColumnReference(group2, "barry", null, String.class); //$NON-NLS-1$
DerivedColumn symbol2 = new DerivedColumn("barry", element2); //$NON-NLS-1$
List symbols2 = new ArrayList();
symbols2.add(symbol2);
- Select select2 = new Select(symbols2, false);
List items2 = new ArrayList();
items2.add(group2);
- From from2 = new From(items2);
- QuerySpecification secondQuery = new QuerySpecification(select2, from2, null, null, null, null);
+ Select secondQuery = new Select(symbols2, false, items2, null, null, null, null);
- QuerySpecification query = new QuerySpecification(select, from, null, null, null, null);
+ Select query = new Select(symbols, false, items, null, null, null, null);
SetQuery setQuery = new SetQuery();
setQuery.setOperation(SetQuery.Operation.UNION);
@@ -110,7 +92,7 @@
SetQuery union = example2();
List<SortSpecification> items = new ArrayList<SortSpecification>();
- ColumnReference element = (ColumnReference) (union.getProjectedQuery().getSelect().getDerivedColumns().get(0)).getExpression();
+ ColumnReference element = (ColumnReference) (union.getProjectedQuery().getDerivedColumns().get(0)).getExpression();
items.add(new SortSpecification(Ordering.ASC, element));
OrderBy orderBy = new OrderBy(items);
@@ -119,15 +101,15 @@
}
public void testNestedSetQuery() throws Exception {
- com.metamatrix.query.sql.lang.SetQuery query = new com.metamatrix.query.sql.lang.SetQuery(com.metamatrix.query.sql.lang.SetQuery.Operation.EXCEPT, true, helpExampleQuery(), helpExampleQuery());
+ com.metamatrix.query.sql.lang.SetQuery query = new com.metamatrix.query.sql.lang.SetQuery(com.metamatrix.query.sql.lang.SetQuery.Operation.EXCEPT, true, helpExampleSetQuery(), helpExampleSetQuery());
SetQuery setQuery = TstLanguageBridgeFactory.factory.translate(query);
- assertTrue(setQuery.getLeftQuery() instanceof QuerySpecification);
- assertTrue(setQuery.getRightQuery() instanceof QuerySpecification);
+ assertTrue(setQuery.getLeftQuery() instanceof SetQuery);
+ assertTrue(setQuery.getRightQuery() instanceof SetQuery);
}
public void testGetSelect() throws Exception {
- assertNotNull(example().getProjectedQuery().getSelect());
+ assertNotNull(example().getProjectedQuery().getDerivedColumns());
}
public void testGetFrom() throws Exception {
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -47,7 +47,7 @@
public static SubqueryCompareCriteria helpExample() {
ElementSymbol element = TestElementImpl.helpExample("g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- Query query = TestQueryImpl.helpExample();
+ Query query = TestQueryImpl.helpExample(true);
SubqueryCompareCriteria scc = new SubqueryCompareCriteria(element, query, AbstractCompareCriteria.GT, SubqueryCompareCriteria.ANY);
return scc;
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -45,7 +45,7 @@
public static SubquerySetCriteria helpExample() {
ElementSymbol element = TestElementImpl.helpExample("g1", "e1"); //$NON-NLS-1$ //$NON-NLS-2$
- Query query = TestQueryImpl.helpExample();
+ Query query = TestQueryImpl.helpExample(true);
SubquerySetCriteria ssc = new SubquerySetCriteria(element, query);
ssc.setNegated(true);
return ssc;
Modified: branches/JCA/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -26,7 +26,7 @@
import org.teiid.connector.language.Command;
import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import com.metamatrix.core.util.UnitTestUtil;
@@ -79,8 +79,8 @@
TranslationUtility util = new TranslationUtility(getTestVDB());
// Translate command to get some ids
- QuerySpecification query = (QuerySpecification) util.parseCommand("select * from partssupplier.parts"); //$NON-NLS-1$
- NamedTable group = (NamedTable) query.getFrom().getItems().get(0);
+ Select query = (Select) util.parseCommand("select * from partssupplier.parts"); //$NON-NLS-1$
+ NamedTable group = (NamedTable) query.getFrom().get(0);
AbstractMetadataRecord mid = group.getMetadataObject();
assertEquals("PartsSupplier.PARTSSUPPLIER.PARTS", mid.getFullName()); //$NON-NLS-1$
Modified: branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/extension/TestSQLConversionVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -38,7 +38,7 @@
import org.teiid.dqp.internal.datamgr.language.TestDeleteImpl;
import org.teiid.dqp.internal.datamgr.language.TestInsertImpl;
import org.teiid.dqp.internal.datamgr.language.TestProcedureImpl;
-import org.teiid.dqp.internal.datamgr.language.TestSelectImpl;
+import org.teiid.dqp.internal.datamgr.language.TestQueryImpl;
import org.teiid.dqp.internal.datamgr.language.TestUpdateImpl;
import org.teiid.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
/**
@@ -383,9 +383,9 @@
@Test public void testVisitISelectWithComment() throws Exception {
String expected = "SELECT /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ g1.e1, g1.e2, g1.e3, g1.e4"; //$NON-NLS-1$
- assertEquals(expected, getStringWithContext(TestSelectImpl.example(false)));
+ assertEquals(expected, getStringWithContext(TestQueryImpl.example(false)));
expected = "SELECT /*teiid sessionid:ConnectionID, requestid:RequestID.PartID*/ DISTINCT g1.e1, g1.e2, g1.e3, g1.e4"; //$NON-NLS-1$
- assertEquals(expected, getStringWithContext(TestSelectImpl.example(true)));
+ assertEquals(expected, getStringWithContext(TestQueryImpl.example(true)));
}
@Test public void testVisitIUpdateWithComment() throws Exception {
Modified: branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/util/TestJDBCExecutionHelper.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/util/TestJDBCExecutionHelper.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/test-integration/common/src/test/java/com/metamatrix/connector/jdbc/util/TestJDBCExecutionHelper.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -29,12 +29,9 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.QuerySpecification;
-import org.teiid.connector.language.Select;
+import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.QuerySpecification;
import org.teiid.connector.language.Select;
-import org.teiid.connector.language.DerivedColumn;
import com.metamatrix.common.types.DataTypeManager;
@@ -52,8 +49,7 @@
expectedResults[0] = DataTypeManager.DefaultDataClasses.STRING;
symbols.add(new DerivedColumn("c2", new Literal(new Integer(5), DataTypeManager.DefaultDataClasses.INTEGER))); //$NON-NLS-1$//$NON-NLS-2$
expectedResults[1] = DataTypeManager.DefaultDataClasses.INTEGER;
- Select select = new Select(symbols, false);
- QuerySpecification query = new QuerySpecification(select, null, null, null, null, null);
+ Select query = new Select(symbols, false, null, null, null, null, null);
Class[] results = query.getColumnTypes();
assertEquals( results[0], expectedResults[0]);
assertEquals( results[1], expectedResults[1]);
Modified: branches/JCA/test-integration/common/src/test/java/org/teiid/connector/language/TestLanguageUtil.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/org/teiid/connector/language/TestLanguageUtil.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/test-integration/common/src/test/java/org/teiid/connector/language/TestLanguageUtil.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -48,7 +48,7 @@
// Create ICriteria from criteriaStr
TranslationUtility util = FakeTranslationFactory.getInstance().getBQTTranslationUtility();
String sql = "SELECT IntKey FROM BQT1.SmallA WHERE " + criteriaStr; //$NON-NLS-1$
- QuerySpecification query = (QuerySpecification) util.parseCommand(sql);
+ Select query = (Select) util.parseCommand(sql);
Condition criteria = query.getWhere();
return criteria;
}
Modified: branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -61,12 +61,12 @@
RuntimeMetadata metadata) throws ConnectorException {
Properties groupProps = new Properties();
groupProps.setProperty("customName", "CustomTableA");//$NON-NLS-1$ //$NON-NLS-2$
- NamedTable group = (NamedTable)query.getProjectedQuery().getFrom().getItems().get(0);
+ NamedTable group = (NamedTable)query.getProjectedQuery().getFrom().get(0);
AbstractMetadataRecord groupMD = group.getMetadataObject();
TestCase.assertEquals(groupProps, groupMD.getProperties());
- DerivedColumn symbl = query.getProjectedQuery().getSelect().getDerivedColumns().get(0);
+ DerivedColumn symbl = query.getProjectedQuery().getDerivedColumns().get(0);
ColumnReference element = (ColumnReference)symbl.getExpression();
Column elementMD = element.getMetadataObject();
@@ -94,7 +94,7 @@
TestCase.assertEquals(elementProps, elementMD.getProperties());
- DerivedColumn symbl2 = query.getProjectedQuery().getSelect().getDerivedColumns().get(1);
+ DerivedColumn symbl2 = query.getProjectedQuery().getDerivedColumns().get(1);
ColumnReference element2 = (ColumnReference)symbl2.getExpression();
Column elementMD2 = element2.getMetadataObject();
Modified: branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -29,7 +29,7 @@
import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
import org.teiid.connector.metadata.runtime.Column.SearchType;
@@ -58,8 +58,8 @@
}
public Column getElement(String groupName, String elementName, TranslationUtility transUtil) throws Exception {
- QuerySpecification query = (QuerySpecification) transUtil.parseCommand("SELECT " + elementName + " FROM " + groupName); //$NON-NLS-1$ //$NON-NLS-2$
- DerivedColumn symbol = query.getSelect().getDerivedColumns().get(0);
+ Select query = (Select) transUtil.parseCommand("SELECT " + elementName + " FROM " + groupName); //$NON-NLS-1$ //$NON-NLS-2$
+ DerivedColumn symbol = query.getDerivedColumns().get(0);
ColumnReference element = (ColumnReference) symbol.getExpression();
return element.getMetadataObject();
}
Modified: branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -28,7 +28,7 @@
import junit.framework.TestCase;
import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.core.util.UnitTestUtil;
@@ -58,8 +58,8 @@
// ################ TEST GROUP METADATAID ######################
public Table getGroup(String groupName, TranslationUtility transUtil) throws Exception {
- QuerySpecification query = (QuerySpecification) transUtil.parseCommand("SELECT 1 FROM " + groupName); //$NON-NLS-1$
- NamedTable group = (NamedTable) query.getFrom().getItems().get(0);
+ Select query = (Select) transUtil.parseCommand("SELECT 1 FROM " + groupName); //$NON-NLS-1$
+ NamedTable group = (NamedTable) query.getFrom().get(0);
return group.getMetadataObject();
}
Modified: branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -30,7 +30,7 @@
import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Call;
-import org.teiid.connector.language.QuerySpecification;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.metadata.runtime.Procedure;
@@ -65,8 +65,8 @@
// ################ TEST GROUP METADATAID ######################
public Table getGroupID(String groupName, TranslationUtility transUtil) {
- QuerySpecification query = (QuerySpecification) transUtil.parseCommand("SELECT 1 FROM " + groupName); //$NON-NLS-1$
- NamedTable group = (NamedTable) query.getFrom().getItems().get(0);
+ Select query = (Select) transUtil.parseCommand("SELECT 1 FROM " + groupName); //$NON-NLS-1$
+ NamedTable group = (NamedTable) query.getFrom().get(0);
return group.getMetadataObject();
}
@@ -94,8 +94,8 @@
// ################ TEST ELEMENT METADATAID ######################
public Column getElementID(String groupName, String elementName, TranslationUtility transUtil) {
- QuerySpecification query = (QuerySpecification) transUtil.parseCommand("SELECT " + elementName + " FROM " + groupName); //$NON-NLS-1$ //$NON-NLS-2$
- DerivedColumn symbol = query.getSelect().getDerivedColumns().get(0);
+ Select query = (Select) transUtil.parseCommand("SELECT " + elementName + " FROM " + groupName); //$NON-NLS-1$ //$NON-NLS-2$
+ DerivedColumn symbol = query.getDerivedColumns().get(0);
ColumnReference element = (ColumnReference) symbol.getExpression();
return element.getMetadataObject();
}
Modified: branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestCollectorVisitor.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestCollectorVisitor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestCollectorVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -22,16 +22,25 @@
package org.teiid.connector.visitor.util;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
-import org.teiid.connector.language.*;
+import junit.framework.TestCase;
+
+import org.teiid.connector.language.ColumnReference;
+import org.teiid.connector.language.Comparison;
+import org.teiid.connector.language.Expression;
+import org.teiid.connector.language.Function;
+import org.teiid.connector.language.LanguageObject;
+import org.teiid.connector.language.NamedTable;
+import org.teiid.connector.language.Select;
import org.teiid.connector.language.Comparison.Operator;
-import org.teiid.connector.visitor.util.CollectorVisitor;
-import org.teiid.dqp.internal.datamgr.language.*;
-
-import junit.framework.TestCase;
-
/**
*/
public class TestCollectorVisitor extends TestCase {
@@ -73,11 +82,9 @@
symbols.add(new ColumnReference(g, "e1", null, String.class)); //$NON-NLS-1$
Function function = new Function("length", Arrays.asList(new ColumnReference(g, "e2", null, String.class)), Integer.class); //$NON-NLS-1$ //$NON-NLS-2$
symbols.add(function);
- Select s = new Select(symbols, false);
List groups = new ArrayList();
groups.add(g);
- From f = new From(groups);
- QuerySpecification q = new QuerySpecification(s, f, null, null, null, null);
+ Select q = new Select(symbols, false, groups, null, null, null, null);
return q;
}
Modified: branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
===================================================================
--- branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-02-27 05:17:30 UTC (rev 1878)
+++ branches/JCA/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-02-27 12:48:26 UTC (rev 1879)
@@ -33,24 +33,20 @@
import org.junit.Test;
import org.teiid.connector.language.AggregateFunction;
import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Command;
-import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.Expression;
import org.teiid.connector.language.Function;
-import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Insert;
import org.teiid.connector.language.LanguageObject;
-import org.teiid.connector.language.QuerySpecification;
import org.teiid.connector.language.Literal;
+import org.teiid.connector.language.NamedTable;
+import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.language.TestAggregateImpl;
import org.teiid.dqp.internal.datamgr.language.TestCompareCriteriaImpl;
import org.teiid.dqp.internal.datamgr.language.TestDeleteImpl;
import org.teiid.dqp.internal.datamgr.language.TestElementImpl;
import org.teiid.dqp.internal.datamgr.language.TestExistsCriteriaImpl;
-import org.teiid.dqp.internal.datamgr.language.TestFromImpl;
import org.teiid.dqp.internal.datamgr.language.TestFunctionImpl;
import org.teiid.dqp.internal.datamgr.language.TestGroupByImpl;
import org.teiid.dqp.internal.datamgr.language.TestGroupImpl;
@@ -66,7 +62,6 @@
import org.teiid.dqp.internal.datamgr.language.TestQueryImpl;
import org.teiid.dqp.internal.datamgr.language.TestScalarSubqueryImpl;
import org.teiid.dqp.internal.datamgr.language.TestSearchedCaseExpressionImpl;
-import org.teiid.dqp.internal.datamgr.language.TestSelectImpl;
import org.teiid.dqp.internal.datamgr.language.TestSelectSymbolImpl;
import org.teiid.dqp.internal.datamgr.language.TestSetQueryImpl;
import org.teiid.dqp.internal.datamgr.language.TestSubqueryCompareCriteriaImpl;
@@ -192,14 +187,6 @@
}
/*
- * Test for void visit(IFrom)
- */
- @Test public void testVisitIFrom() throws Exception {
- String expected = "FROM g1, g2 AS myAlias, g3, g4"; //$NON-NLS-1$
- assertEquals(expected, getString(TestFromImpl.example()));
- }
-
- /*
* Test for void visit(IFunction)
*/
@Test public void testVisitIFunction() throws Exception {
@@ -355,7 +342,7 @@
*/
@Test public void testVisitIQuery() throws Exception {
String expected = "SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4 FROM g1, g2 AS myAlias, g3, g4 WHERE (100 >= 200) AND (500 < 600) GROUP BY g1.e1, g1.e2, g1.e3, g1.e4 HAVING (100 >= 200) AND (500 < 600) ORDER BY e1, e2 DESC, e3, e4 DESC"; //$NON-NLS-1$
- assertEquals(expected, getString(TestQueryImpl.example()));
+ assertEquals(expected, getString(TestQueryImpl.example(true)));
}
/*
@@ -379,9 +366,9 @@
*/
@Test public void testVisitISelect() throws Exception {
String expected = "SELECT g1.e1, g1.e2, g1.e3, g1.e4"; //$NON-NLS-1$
- assertEquals(expected, getString(TestSelectImpl.example(false)));
+ assertEquals(expected, getString(TestQueryImpl.example(false)));
expected = "SELECT DISTINCT g1.e1, g1.e2, g1.e3, g1.e4"; //$NON-NLS-1$
- assertEquals(expected, getString(TestSelectImpl.example(true)));
+ assertEquals(expected, getString(TestQueryImpl.example(true)));
}
@@ -453,7 +440,7 @@
Insert insert = (Insert)FakeTranslationFactory.getInstance().getExampleTranslationUtility().parseCommand(sql);
- QuerySpecification command = (QuerySpecification)FakeTranslationFactory.getInstance().getExampleTranslationUtility().parseCommand("select * from pm1.g2"); //$NON-NLS-1$
+ Select command = (Select)FakeTranslationFactory.getInstance().getExampleTranslationUtility().parseCommand("select * from pm1.g2"); //$NON-NLS-1$
insert.setValueSource(command);
assertEquals("INSERT INTO g1 (e1, e2, e3, e4) SELECT g2.e1, g2.e2, g2.e3, g2.e4 FROM g2", insert.toString()); //$NON-NLS-1$
}
14 years, 10 months
teiid SVN: r1877 - branches/JCA/connectors/sandbox.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-02-26 21:54:32 -0500 (Fri, 26 Feb 2010)
New Revision: 1877
Removed:
branches/JCA/connectors/sandbox/connector-object/
Modified:
branches/JCA/connectors/sandbox/pom.xml
Log:
TEIID-1002 removing the object connector
Modified: branches/JCA/connectors/sandbox/pom.xml
===================================================================
--- branches/JCA/connectors/sandbox/pom.xml 2010-02-25 21:59:53 UTC (rev 1876)
+++ branches/JCA/connectors/sandbox/pom.xml 2010-02-27 02:54:32 UTC (rev 1877)
@@ -14,6 +14,5 @@
<modules>
<module>connector-yahoo</module>
<module>connector-exec</module>
- <module>connector-object</module>
</modules>
</project>
\ No newline at end of file
14 years, 10 months
teiid SVN: r1876 - trunk/documentation/reference/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-02-25 16:59:53 -0500 (Thu, 25 Feb 2010)
New Revision: 1876
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
Log:
TEIID-1001 adding a documentation warning about converting types to string
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2010-02-25 17:05:21 UTC (rev 1875)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2010-02-25 21:59:53 UTC (rev 1876)
@@ -245,6 +245,15 @@
Allowed explicit conversions may still fail during processing
if the runtime values are not actually convertable.</para>
</listitem>
+ <listitem>
+ <warning>
+ <para>The Teiid conversions of float/double/bigdecimal/timestamp to string rely on the JDBC/Java defined
+ output formats. Pushdown behavior attempts to mimic these results, but may vary depending upon the actual
+ source type and conversion logic. Care should be taken to not assume the string form in criteria or other
+ places where a variation may cause different results.
+ </para>
+ </warning>
+ </listitem>
</itemizedlist>
<para>
</para>
14 years, 10 months
teiid SVN: r1875 - trunk/documentation/reference/src/main/docbook/en-US/content.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-02-25 12:05:21 -0500 (Thu, 25 Feb 2010)
New Revision: 1875
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
Log:
TEIID-989 aliased items should not be referenced in an order by expression
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-02-25 02:07:39 UTC (rev 1874)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2010-02-25 17:05:21 UTC (rev 1875)
@@ -793,7 +793,7 @@
<para>Syntax Rules:
</para>
<listitem>
- <para>Sort columns may be specified positionally by a 1 based
+ <para>Sort columns may be specified positionally by a 1-based positional
integer, by SELECT clause alias name, by SELECT clause expression, or by an unrelated expression.</para>
</listitem>
<listitem>
@@ -806,7 +806,8 @@
</listitem>
<listitem>
<para>Unrelated expressions, expressions not appearing as an aliased expression in the select clause,
- are allowed in the order by clause of a non-set QUERY. The columns referenced in the expression must also follow the prior rule.
+ are allowed in the order by clause of a non-set QUERY. The columns referenced in the expression must come from the
+ from clause table references. The column references cannot be to alias names or positional.
</para>
</listitem>
<listitem>
14 years, 10 months
teiid SVN: r1874 - in trunk/engine/src: main/java/com/metamatrix/query/rewriter and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-02-24 21:07:39 -0500 (Wed, 24 Feb 2010)
New Revision: 1874
Modified:
trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
Log:
TEIID-989 aliased items should not be referenced in an order by expression
Modified: trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2010-02-24 22:49:00 UTC (rev 1873)
+++ trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2010-02-25 02:07:39 UTC (rev 1874)
@@ -348,8 +348,8 @@
for (int i = 0; i < orderBy.getVariableCount(); i++) {
SingleElementSymbol sortKey = orderBy.getVariable(i);
if (sortKey instanceof ElementSymbol) {
- int index = resolveSortKey(orderBy, fromClauseGroups, knownElements, metadata,
- isSimpleQuery, knownShortNames, (ElementSymbol)sortKey);
+ int index = resolveSortKey(fromClauseGroups, knownElements, metadata, isSimpleQuery,
+ knownShortNames, (ElementSymbol)sortKey);
if (index == -1) {
index = expressions.indexOf(SymbolMap.getExpression(sortKey));
}
@@ -374,8 +374,7 @@
throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.setquery_order_expression", sortKey)); //$NON-NLS-1$
}
for (ElementSymbol symbol : ElementCollectorVisitor.getElements(sortKey, false)) {
- resolveSortKey(orderBy, fromClauseGroups, knownElements, metadata,
- isSimpleQuery, knownShortNames, symbol);
+ resolveSortKey(fromClauseGroups, null, metadata, isSimpleQuery, null, symbol);
}
ResolverVisitor.resolveLanguageObject(sortKey, metadata);
@@ -384,10 +383,9 @@
}
}
- private static int resolveSortKey(OrderBy orderBy, List fromClauseGroups,
- List knownElements, QueryMetadataInterface metadata,
- boolean isSimpleQuery, String[] knownShortNames,
- ElementSymbol symbol) throws MetaMatrixComponentException,
+ private static int resolveSortKey(List fromClauseGroups, List knownElements,
+ QueryMetadataInterface metadata, boolean isSimpleQuery,
+ String[] knownShortNames, ElementSymbol symbol) throws MetaMatrixComponentException,
QueryMetadataException, QueryResolverException {
SingleElementSymbol matchedSymbol = null;
String symbolName = symbol.getName();
@@ -399,38 +397,40 @@
throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0043, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0043, symbolName));
}
- // walk the SELECT col short names, looking for a match on the current ORDER BY 'short name'
- for(int i=0; i<knownShortNames.length; i++) {
- if( shortName.equalsIgnoreCase( knownShortNames[i] )) {
- if (groupPart != null) {
- Object knownSymbol = knownElements.get(i);
- if(knownSymbol instanceof ElementSymbol) {
- ElementSymbol knownElement = (ElementSymbol) knownSymbol;
- GroupSymbol group = knownElement.getGroupSymbol();
-
- // skip this one if the two short names are not from the same group
- if (!nameMatchesGroup(groupPart.toUpperCase(), group.getCanonicalName())) {
- continue;
- }
- }
- }
-
- // if we already have a matched symbol, matching again here means it is duplicate/ambiguous
- if(matchedSymbol != null) {
- throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0042, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0042, symbolName));
- }
- matchedSymbol = (SingleElementSymbol)knownElements.get(i);
- }
+ if (knownShortNames != null) {
+ // walk the SELECT col short names, looking for a match on the current ORDER BY 'short name'
+ for(int i=0; i<knownShortNames.length; i++) {
+ if( shortName.equalsIgnoreCase( knownShortNames[i] )) {
+ if (groupPart != null) {
+ Object knownSymbol = knownElements.get(i);
+ if(knownSymbol instanceof ElementSymbol) {
+ ElementSymbol knownElement = (ElementSymbol) knownSymbol;
+ GroupSymbol group = knownElement.getGroupSymbol();
+
+ // skip this one if the two short names are not from the same group
+ if (!nameMatchesGroup(groupPart.toUpperCase(), group.getCanonicalName())) {
+ continue;
+ }
+ }
+ }
+
+ // if we already have a matched symbol, matching again here means it is duplicate/ambiguous
+ if(matchedSymbol != null) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0042, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0042, symbolName));
+ }
+ matchedSymbol = (SingleElementSymbol)knownElements.get(i);
+ }
+ }
+ if (matchedSymbol != null) {
+ TempMetadataID tempMetadataID = new TempMetadataID(symbol.getName(), matchedSymbol.getType());
+ int position = knownElements.indexOf(matchedSymbol);
+ tempMetadataID.setPosition(position);
+ symbol.setMetadataID(tempMetadataID);
+ symbol.setType(matchedSymbol.getType());
+ return position;
+ }
}
- if (matchedSymbol != null) {
- TempMetadataID tempMetadataID = new TempMetadataID(symbol.getName(), matchedSymbol.getType());
- int position = knownElements.indexOf(matchedSymbol);
- tempMetadataID.setPosition(position);
- symbol.setMetadataID(tempMetadataID);
- symbol.setType(matchedSymbol.getType());
- return position;
- }
if (!isSimpleQuery) {
throw new QueryResolverException(QueryPlugin.Util.getString("ResolverUtil.invalid_unrelated", symbol.getName())); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2010-02-24 22:49:00 UTC (rev 1873)
+++ trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2010-02-25 02:07:39 UTC (rev 1874)
@@ -65,7 +65,6 @@
import com.metamatrix.query.function.FunctionMethods;
import com.metamatrix.query.metadata.QueryMetadataInterface;
import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
import com.metamatrix.query.metadata.TempMetadataStore;
import com.metamatrix.query.processor.ProcessorDataManager;
import com.metamatrix.query.processor.relational.DependentValueSource;
@@ -141,7 +140,6 @@
import com.metamatrix.query.sql.symbol.Reference;
import com.metamatrix.query.sql.symbol.ScalarSubquery;
import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SelectSymbol;
import com.metamatrix.query.sql.symbol.SingleElementSymbol;
import com.metamatrix.query.sql.util.SymbolMap;
import com.metamatrix.query.sql.util.ValueIterator;
@@ -807,7 +805,7 @@
if (index == -1) {
unrelatedItems.add(orderBy.getOrderByItems().get(i));
hasUnrelatedExpression |= (querySymbol instanceof ExpressionSymbol);
- continue; // must be unrelated - but potentially contains references to the select clause
+ continue; // must be unrelated
}
querySymbol = (SingleElementSymbol)projectedSymbols.get(index);
Expression expr = SymbolMap.getExpression(querySymbol);
@@ -831,12 +829,7 @@
//add unrelated to select
for (OrderByItem orderByItem : unrelatedItems) {
- Collection<ElementSymbol> elements = ElementCollectorVisitor.getElements(orderByItem.getSymbol(), true);
- for (ElementSymbol elementSymbol : elements) {
- if (!(elementSymbol.getMetadataID() instanceof TempMetadataID) || ((TempMetadataID)elementSymbol.getMetadataID()).getPosition() == -1) {
- select.addSymbol(elementSymbol);
- }
- }
+ select.addSymbol(orderByItem.getSymbol());
}
makeSelectUnique(select, false);
@@ -851,8 +844,8 @@
Query top = null;
try {
- Query intermediate = createInlineViewQuery(new GroupSymbol("X"), query, metadata, select.getProjectedSymbols()); //$NON-NLS-1$
- Iterator iter = intermediate.getSelect().getProjectedSymbols().iterator();
+ top = createInlineViewQuery(new GroupSymbol("X"), query, metadata, select.getProjectedSymbols()); //$NON-NLS-1$
+ Iterator iter = top.getSelect().getProjectedSymbols().iterator();
HashMap<Expression, SingleElementSymbol> expressionMap = new HashMap<Expression, SingleElementSymbol>();
for (SingleElementSymbol symbol : (List<SingleElementSymbol>)select.getProjectedSymbols()) {
SingleElementSymbol ses = (SingleElementSymbol)iter.next();
@@ -860,22 +853,6 @@
expressionMap.put(new ElementSymbol(symbol.getName()), ses);
}
ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap);
- for (int i = 0; i < orderBy.getVariableCount(); i++) {
- int index = orderBy.getExpressionPosition(i);
- SingleElementSymbol ss = orderBy.getVariable(i);
- if (index == -1 && !(ss instanceof ElementSymbol)) {
- intermediate.getSelect().addSymbol((SelectSymbol)ss.clone());
- }
- }
- makeSelectUnique(intermediate.getSelect(), true);
-
- top = createInlineViewQuery(new GroupSymbol("Y"), intermediate, metadata, intermediate.getSelect().getProjectedSymbols()); //$NON-NLS-1$
- iter = top.getSelect().getProjectedSymbols().iterator();
- expressionMap = new HashMap<Expression, SingleElementSymbol>();
- for (SingleElementSymbol symbol : (List<SingleElementSymbol>)intermediate.getSelect().getProjectedSymbols()) {
- expressionMap.put(SymbolMap.getExpression(symbol), (SingleElementSymbol)iter.next());
- }
- ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap);
//now the order by should only contain element symbols
} catch (QueryResolverException e) {
throw new QueryValidatorException(e, e.getMessage());
Modified: trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java 2010-02-24 22:49:00 UTC (rev 1873)
+++ trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java 2010-02-25 02:07:39 UTC (rev 1874)
@@ -309,8 +309,8 @@
}
@Test public void testOrderByExpression() throws Exception {
- Query resolvedQuery = (Query) getCommand("SELECT 0 AS SOMEINT, pm1.g1.e2 as y FROM pm1.g1 ORDER BY y + SOMEINT, e3"); //$NON-NLS-1$
- assertEquals("SELECT Y_1.SOMEINT, Y_1.Y FROM (SELECT X_1.SOMEINT, X_1.Y, X_1.E3, (X_1.Y + X_1.SOMEINT) AS EXPR1 FROM (SELECT 0 AS SOMEINT, pm1.g1.e2 AS y, e3 FROM pm1.g1) AS X_1) AS Y_1 ORDER BY Y_1.EXPR1, Y_1.E3", resolvedQuery.toString()); //$NON-NLS-1$
+ Query resolvedQuery = (Query) getCommand("SELECT 0 AS SOMEINT, pm1.g1.e2 as y FROM pm1.g1 ORDER BY e2 || e1, e3"); //$NON-NLS-1$
+ assertEquals("SELECT X_1.SOMEINT, X_1.Y FROM (SELECT 0 AS SOMEINT, pm1.g1.e2 AS y, (e2 || e1) AS EXPR1, e3 FROM pm1.g1) AS X_1 ORDER BY X_1.EXPR1, X_1.E3", resolvedQuery.toString()); //$NON-NLS-1$
}
@Test public void testRewiteOrderBy() {
14 years, 10 months
teiid SVN: r1873 - in branches/JCA: build/assembly/jboss-container and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-02-24 17:49:00 -0500 (Wed, 24 Feb 2010)
New Revision: 1873
Added:
branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
Modified:
branches/JCA/build/assembly/jboss-container/dist.xml
branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml
branches/JCA/build/pom.xml
branches/JCA/client/src/main/java/org/teiid/adminapi/AdminFactory.java
Log:
TEIID-833: adding the XML connectors to deployment profile and also moved the connector types to a different xml file
Modified: branches/JCA/build/assembly/jboss-container/dist.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/dist.xml 2010-02-24 21:14:30 UTC (rev 1872)
+++ branches/JCA/build/assembly/jboss-container/dist.xml 2010-02-24 22:49:00 UTC (rev 1873)
@@ -13,7 +13,7 @@
<fileSets>
<fileSet>
- <directory>build/kit-jboss-container</directory>
+ <directory>build/target/kit-jboss-container</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
@@ -75,9 +75,7 @@
<include>org.jboss.teiid.connectors:connector-text:rar</include>
<include>org.jboss.teiid.connectors:connector-ldap:rar</include>
<include>org.jboss.teiid.connectors:connector-salesforce:rar</include>
- <include>org.jboss.teiid.connectors:connector-xml-file:rar</include>
<include>org.jboss.teiid.connectors:connector-xml-http:rar</include>
- <include>org.jboss.teiid.connectors:connector-xml-soap:rar</include>
<include>org.jboss.teiid.connectors:connector-xmlsource-file:rar</include>
<include>org.jboss.teiid.connectors:connector-xmlsource-soap:rar</include>
</includes>
Added: branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml (rev 0)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml 2010-02-24 22:49:00 UTC (rev 1873)
@@ -0,0 +1,116 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <!-- This file defines the connector templates for Teiid based connectors -->
+ <bean name="connector-jdbc-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <property name="info"><inject bean="connector-jdbc-templateinfo"/></property>
+ <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
+ </bean>
+ <bean name="connector-jdbc-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="DSDeploymentTemplateInfoFactory"/>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
+ <parameter class="java.lang.String">connector-jdbc-${project.version}</parameter>
+ <parameter class="java.lang.String">Teiid JDBC Connector</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="connector-ldap-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <property name="info"><inject bean="connector-ldap-templateinfo"/></property>
+ <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
+ </bean>
+ <bean name="connector-ldap-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="DSDeploymentTemplateInfoFactory"/>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
+ <parameter class="java.lang.String">connector-ldap-${project.version}</parameter>
+ <parameter class="java.lang.String">Teiid LDAP Connector</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="connector-loopback-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <property name="info"><inject bean="connector-loopback-templateinfo"/></property>
+ <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
+ </bean>
+ <bean name="connector-loopback-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="DSDeploymentTemplateInfoFactory"/>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
+ <parameter class="java.lang.String">connector-loopback-${project.version}</parameter>
+ <parameter class="java.lang.String">Teiid Loopback Connector</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="connector-salesforce-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <property name="info"><inject bean="connector-salesforce-templateinfo"/></property>
+ <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
+ </bean>
+ <bean name="connector-salesforce-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="DSDeploymentTemplateInfoFactory"/>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
+ <parameter class="java.lang.String">connector-salesforce-${project.version}</parameter>
+ <parameter class="java.lang.String">Teiid Salesforce Connector</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="connector-text-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <property name="info"><inject bean="connector-text-templateinfo"/></property>
+ <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
+ </bean>
+ <bean name="connector-text-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="DSDeploymentTemplateInfoFactory"/>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
+ <parameter class="java.lang.String">connector-text-${project.version}</parameter>
+ <parameter class="java.lang.String">Teiid Text Connector</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="connector-xmlsource-file-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <property name="info"><inject bean="connector-xmlsource-file-templateinfo"/></property>
+ <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
+ </bean>
+ <bean name="connector-xmlsource-file-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="DSDeploymentTemplateInfoFactory"/>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
+ <parameter class="java.lang.String">connector-xmlsource-file-${project.version}</parameter>
+ <parameter class="java.lang.String">Teiid XML File Connector</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="connector-xmlsource-soap-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <property name="info"><inject bean="connector-xmlsource-soap-templateinfo"/></property>
+ <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
+ </bean>
+ <bean name="connector-xmlsource-soap-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="DSDeploymentTemplateInfoFactory"/>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
+ <parameter class="java.lang.String">connector-xmlsource-soap-${project.version}</parameter>
+ <parameter class="java.lang.String">Teiid XML SOAP Connector</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="connector-xml-http-${project.version}" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <property name="info"><inject bean="connector-xml-http-templateinfo"/></property>
+ <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
+ </bean>
+ <bean name="connector-xml-http-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="DSDeploymentTemplateInfoFactory"/>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
+ <parameter class="java.lang.String">connector-xml-http-${project.version}</parameter>
+ <parameter class="java.lang.String">Teiid XML HTTP Connector</parameter>
+ </constructor>
+ </bean>
+
+</deployment>
Property changes on: branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-connector-templates-jboss-beans.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-02-24 21:14:30 UTC (rev 1872)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid/teiid-jboss-beans.xml 2010-02-24 22:49:00 UTC (rev 1873)
@@ -160,75 +160,5 @@
</login-module>
</authentication>
</application-policy>
-
- <!-- Connector Types -->
- <bean name="connector-jdbc-7.0.0-SNAPSHOT" class="org.teiid.templates.connector.ConnectorTypeTemplate">
- <property name="info"><inject bean="connector-jdbc-templateinfo"/></property>
- <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
- </bean>
- <bean name="connector-jdbc-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
- <constructor factoryMethod="createTemplateInfo">
- <factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-jdbc-7.0.0-SNAPSHOT</parameter>
- <parameter class="java.lang.String">Teiid JDBC Connector</parameter>
- </constructor>
- </bean>
-
- <bean name="connector-ldap-7.0.0-SNAPSHOT" class="org.teiid.templates.connector.ConnectorTypeTemplate">
- <property name="info"><inject bean="connector-ldap-templateinfo"/></property>
- <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
- </bean>
- <bean name="connector-ldap-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
- <constructor factoryMethod="createTemplateInfo">
- <factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-ldap-7.0.0-SNAPSHOT</parameter>
- <parameter class="java.lang.String">Teiid LDAP Connector</parameter>
- </constructor>
- </bean>
-
- <bean name="connector-loopback-7.0.0-SNAPSHOT" class="org.teiid.templates.connector.ConnectorTypeTemplate">
- <property name="info"><inject bean="connector-loopback-templateinfo"/></property>
- <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
- </bean>
- <bean name="connector-loopback-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
- <constructor factoryMethod="createTemplateInfo">
- <factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-loopback-7.0.0-SNAPSHOT</parameter>
- <parameter class="java.lang.String">Teiid Loopback Connector</parameter>
- </constructor>
- </bean>
-
- <bean name="connector-salesforce-7.0.0-SNAPSHOT" class="org.teiid.templates.connector.ConnectorTypeTemplate">
- <property name="info"><inject bean="connector-salesforce-templateinfo"/></property>
- <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
- </bean>
- <bean name="connector-salesforce-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
- <constructor factoryMethod="createTemplateInfo">
- <factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-salesforce-7.0.0-SNAPSHOT</parameter>
- <parameter class="java.lang.String">Teiid Salesforce Connector</parameter>
- </constructor>
- </bean>
-
- <bean name="connector-text-7.0.0-SNAPSHOT" class="org.teiid.templates.connector.ConnectorTypeTemplate">
- <property name="info"><inject bean="connector-text-templateinfo"/></property>
- <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
- </bean>
- <bean name="connector-text-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
- <constructor factoryMethod="createTemplateInfo">
- <factory bean="DSDeploymentTemplateInfoFactory"/>
- <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
- <parameter class="java.lang.String">connector-text-7.0.0-SNAPSHOT</parameter>
- <parameter class="java.lang.String">Teiid Text Connector</parameter>
- </constructor>
- </bean>
+
</deployment>
Modified: branches/JCA/build/pom.xml
===================================================================
--- branches/JCA/build/pom.xml 2010-02-24 21:14:30 UTC (rev 1872)
+++ branches/JCA/build/pom.xml 2010-02-24 22:49:00 UTC (rev 1873)
@@ -7,113 +7,25 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>build</artifactId>
- <packaging>pom</packaging>
<name>Build</name>
<description>Teiid Build</description>
- <!--
<build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy</id>
- <phase>package</phase>
- <goals>
- <goal>copy</goal>
- </goals>
- <configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-connector-api</artifactId>
- <version>${pom.version}</version>
- <classifier>bundle</classifier>
- <type>zip</type>
- <overWrite>true</overWrite>
- </artifactItem>
- <artifactItem>
- <groupId>org.jboss.teiid.connectors</groupId>
- <artifactId>connector-xml</artifactId>
- <version>${pom.version}</version>
- <classifier>bundle</classifier>
- <type>zip</type>
- <overWrite>true</overWrite>
- </artifactItem>
- <artifactItem>
- <groupId>org.jboss.teiid.connectors</groupId>
- <artifactId>connector-xml-common</artifactId>
- <version>${pom.version}</version>
- <classifier>bundle</classifier>
- <type>zip</type>
- <overWrite>true</overWrite>
- </artifactItem>
- <artifactItem>
- <groupId>org.jboss.teiid.connectors</groupId>
- <artifactId>connector-jdbc</artifactId>
- <version>${pom.version}</version>
- <classifier>bundle</classifier>
- <type>zip</type>
- <overWrite>true</overWrite>
- </artifactItem>
- <artifactItem>
- <groupId>org.jboss.teiid.connectors</groupId>
- <artifactId>connector-text</artifactId>
- <version>${pom.version}</version>
- <classifier>bundle</classifier>
- <type>zip</type>
- <overWrite>true</overWrite>
- </artifactItem>
- <artifactItem>
- <groupId>org.jboss.teiid.connectors</groupId>
- <artifactId>connector-ldap</artifactId>
- <version>${pom.version}</version>
- <classifier>bundle</classifier>
- <type>zip</type>
- <overWrite>true</overWrite>
- </artifactItem>
- <artifactItem>
- <groupId>org.jboss.teiid.connectors</groupId>
- <artifactId>connector-loopback</artifactId>
- <version>${pom.version}</version>
- <classifier>bundle</classifier>
- <type>zip</type>
- <overWrite>true</overWrite>
- </artifactItem>
- <artifactItem>
- <groupId>org.jboss.teiid.connectors</groupId>
- <artifactId>connector-salesforce</artifactId>
- <version>${pom.version}</version>
- <classifier>bundle</classifier>
- <type>zip</type>
- <overWrite>true</overWrite>
- </artifactItem>
- </artifactItems>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>assemble-artifacts</id>
- <phase>package</phase>
- <configuration>
- <tasks>
- <ant antfile="assembly/runtime/build-configuration.xml" />
- </tasks>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
+ <outputDirectory>target/kit-jboss-container</outputDirectory>
+ <resources>
+ <resource>
+ <directory>kit-jboss-container</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>kit-jboss-container</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>**/*.xml</exclude>
+ </excludes>
+ </resource>
+ </resources>
</build>
- -->
</project>
\ No newline at end of file
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/AdminFactory.java 2010-02-24 21:14:30 UTC (rev 1872)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/AdminFactory.java 2010-02-24 22:49:00 UTC (rev 1873)
@@ -77,7 +77,7 @@
try {
registry = serverConnectionFactory.getConnection(p);
} catch (ConnectionException e) {
- throw new AdminComponentException(e.getMessage());
+ throw new AdminComponentException(e);
}
target = registry.getService(Admin.class);
return target;
@@ -234,9 +234,9 @@
Admin serverAdmin = (Admin)Proxy.newProxyInstance(this.getClass().getClassLoader(), new Class[] { Admin.class }, new ReconnectingProxy(p));
return serverAdmin;
} catch (ConnectionException e) {
- throw new AdminComponentException(e.getMessage());
+ throw new AdminComponentException(e);
} catch (CommunicationException e) {
- throw new AdminComponentException(e.getMessage());
+ throw new AdminComponentException(e);
}
}
14 years, 10 months
teiid SVN: r1872 - in branches/JCA/runtime/src: test/java/org/teiid/transport and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-02-24 16:14:30 -0500 (Wed, 24 Feb 2010)
New Revision: 1872
Modified:
branches/JCA/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java
branches/JCA/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java
branches/JCA/runtime/src/main/java/org/teiid/transport/SocketListener.java
branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java
branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
Log:
TEIID-833 ensuring that a new sslengine is used for each channel
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java 2010-02-24 19:24:18 UTC (rev 1871)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java 2010-02-24 21:14:30 UTC (rev 1872)
@@ -138,7 +138,7 @@
}
private final ChannelListener.ChannelListenerFactory listenerFactory;
- private final SSLEngine engine;
+ private final SSLConfiguration config;
private final ClassLoader classLoader;
private Map<Channel, ChannelListener> listeners = Collections.synchronizedMap(new HashMap<Channel, ChannelListener>());
private AtomicLong objectsRead = new AtomicLong(0);
@@ -158,9 +158,9 @@
};
public SSLAwareChannelHandler(ChannelListener.ChannelListenerFactory listenerFactory,
- SSLEngine engine, ClassLoader classloader) {
+ SSLConfiguration config, ClassLoader classloader) {
this.listenerFactory = listenerFactory;
- this.engine = engine;
+ this.config = config;
this.classLoader = classloader;
}
@@ -172,8 +172,8 @@
this.listeners.put(e.getChannel(), listener);
maxChannels = Math.max(maxChannels, this.listeners.size());
}
- if (engine != null) {
- SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
+ SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
+ if (sslHandler != null) {
sslHandler.handshake(e.getChannel()).addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture arg0)
throws Exception {
@@ -224,6 +224,7 @@
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = new DefaultChannelPipeline();
+ SSLEngine engine = config.getServerSSLEngine();
if (engine != null) {
pipeline.addLast("ssl", new SslHandler(engine)); //$NON-NLS-1$
}
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java 2010-02-24 19:24:18 UTC (rev 1871)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java 2010-02-24 21:14:30 UTC (rev 1872)
@@ -36,9 +36,9 @@
public class SSLConfiguration {
- private static final String ONEWAY = "1-way"; //$NON-NLS-1$ - one way is the default
- private static final String TWOWAY = "2-way"; //$NON-NLS-1$
- private static final String ANONYMOUS = "anonymous"; //$NON-NLS-1$
+ public static final String ONEWAY = "1-way"; //$NON-NLS-1$ - one way is the default
+ public static final String TWOWAY = "2-way"; //$NON-NLS-1$
+ public static final String ANONYMOUS = "anonymous"; //$NON-NLS-1$
private static final String DEFAULT_SSL_PROTOCOL = "SSLv3"; //$NON-NLS-1$
private static final String DEFAULT_KEYSTORE_TYPE = "JKS"; //$NON-NLS-1$
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/SocketListener.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-02-24 19:24:18 UTC (rev 1871)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-02-24 21:14:30 UTC (rev 1872)
@@ -26,8 +26,6 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import javax.net.ssl.SSLEngine;
-
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
@@ -61,8 +59,8 @@
* @param server
*/
public SocketListener(int port, String bindAddress, int inputBufferSize,
- int outputBufferSize, int maxWorkers, SSLEngine engine, boolean isClientEncryptionEnabled, ClientServiceRegistryImpl csr) {
- this.isClientEncryptionEnabled = isClientEncryptionEnabled;
+ int outputBufferSize, int maxWorkers, SSLConfiguration config, ClientServiceRegistryImpl csr) {
+ this.isClientEncryptionEnabled = config.isClientEncryptionEnabled();
this.csr = csr;
if (port < 0 || port > 0xFFFF) {
throw new IllegalArgumentException("port out of range:" + port); //$NON-NLS-1$
@@ -76,7 +74,7 @@
ChannelFactory factory = new NioServerSocketChannelFactory(this.nettyPool, this.nettyPool, Math.min(Runtime.getRuntime().availableProcessors(), maxWorkers));
ServerBootstrap bootstrap = new ServerBootstrap(factory);
- this.channelHandler = new SSLAwareChannelHandler(this, engine, Thread.currentThread().getContextClassLoader());
+ this.channelHandler = new SSLAwareChannelHandler(this, config, Thread.currentThread().getContextClassLoader());
bootstrap.setPipelineFactory(channelHandler);
if (inputBufferSize != 0) {
bootstrap.setOption("receiveBufferSize", new Integer(inputBufferSize)); //$NON-NLS-1$
Modified: branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java 2010-02-24 19:24:18 UTC (rev 1871)
+++ branches/JCA/runtime/src/main/java/org/teiid/transport/SocketTransport.java 2010-02-24 21:14:30 UTC (rev 1872)
@@ -21,13 +21,8 @@
*/
package org.teiid.transport;
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.security.GeneralSecurityException;
-
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogConstants;
-import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
/**
@@ -48,33 +43,14 @@
public void start() {
String bindAddress = this.config.getHostAddress().getHostAddress();
- try {
- if (this.config.isEnabled()) {
- LogManager.logDetail(LogConstants.CTX_SERVER, DQPEmbeddedPlugin.Util.getString("SocketTransport.1", new Object[] {bindAddress, String.valueOf(this.config.getPortNumber())})); //$NON-NLS-1$
- this.listener = new SocketListener(this.config.getPortNumber(), bindAddress, this.config.getInputBufferSize(), this.config.getOutputBufferSize(), this.config.getMaxSocketThreads(), this.config.getSSLConfiguration().getServerSSLEngine(), this.config.getSSLConfiguration().isClientEncryptionEnabled(), csr);
-
- }
- else {
- LogManager.logDetail(LogConstants.CTX_SERVER, DQPEmbeddedPlugin.Util.getString("SocketTransport.3")); //$NON-NLS-1$
- }
-
- } catch (UnknownHostException e) {
- throw new MetaMatrixRuntimeException(e, DQPEmbeddedPlugin.Util.getString("SocketTransport.2",new Object[] {bindAddress, String.valueOf(this.config.getPortNumber())})); //$NON-NLS-1$
- } catch (IOException e) {
- throw new MetaMatrixRuntimeException(e, DQPEmbeddedPlugin.Util.getString("SocketTransport.2",new Object[] {bindAddress, String.valueOf(this.config.getPortNumber())})); //$NON-NLS-1$
- } catch (GeneralSecurityException e) {
- throw new MetaMatrixRuntimeException(e, DQPEmbeddedPlugin.Util.getString("SocketTransport.2",new Object[] {bindAddress, String.valueOf(this.config.getPortNumber())})); //$NON-NLS-1$
- }
+ LogManager.logDetail(LogConstants.CTX_SERVER, DQPEmbeddedPlugin.Util.getString("SocketTransport.1", new Object[] {bindAddress, String.valueOf(this.config.getPortNumber())})); //$NON-NLS-1$
+ this.listener = new SocketListener(this.config.getPortNumber(), bindAddress, this.config.getInputBufferSize(), this.config.getOutputBufferSize(), this.config.getMaxSocketThreads(), this.config.getSSLConfiguration(), csr);
}
public void stop() {
this.listener.stop();
}
- public int getPort() {
- return this.listener.getPort();
- }
-
public SocketListenerStats getStats() {
return this.listener.getStats();
}
Modified: branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-02-24 19:24:18 UTC (rev 1871)
+++ branches/JCA/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-02-24 21:14:30 UTC (rev 1872)
@@ -33,12 +33,10 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mockito;
import com.metamatrix.api.exception.ComponentNotFoundException;
import com.metamatrix.api.exception.security.LogonException;
import com.metamatrix.common.api.MMURL;
-import com.metamatrix.common.comm.api.ServerConnectionFactory;
import com.metamatrix.common.comm.exception.CommunicationException;
import com.metamatrix.common.comm.exception.ConnectionException;
import com.metamatrix.common.comm.platform.socket.SocketUtil;
@@ -67,7 +65,8 @@
}
@Test public void testFailedConnect() throws Exception {
- listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(),1024, 1024, 1, null, true, null);
+ SSLConfiguration config = new SSLConfiguration();
+ listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(),1024, 1024, 1, config, null);
try {
Properties p = new Properties();
@@ -83,7 +82,7 @@
@Test public void testConnectWithoutPooling() throws Exception {
Properties p = new Properties();
p.setProperty("org.teiid.sockets.maxCachedInstances", String.valueOf(0)); //$NON-NLS-1$
- SocketServerConnection conn = helpEstablishConnection(false, null, true, p);
+ SocketServerConnection conn = helpEstablishConnection(false, new SSLConfiguration(), p);
SocketListenerStats stats = listener.getStats();
assertEquals(2, stats.objectsRead); // handshake response, logon,
assertEquals(1, stats.sockets);
@@ -101,7 +100,7 @@
}
@Test public void testConnectWithPooling() throws Exception {
- SocketServerConnection conn = helpEstablishConnection(false, null);
+ SocketServerConnection conn = helpEstablishConnection(false);
SocketListenerStats stats = listener.getStats();
assertEquals(2, stats.objectsRead); // handshake response, logon,
assertEquals(1, stats.sockets);
@@ -111,7 +110,7 @@
assertEquals(3, stats.objectsRead); // handshake response, logon, logoff
stats = listener.getStats();
assertEquals(1, stats.sockets);
- conn = helpEstablishConnection(false, null);
+ conn = helpEstablishConnection(false);
conn.close();
stats = listener.getStats();
assertEquals(1, stats.sockets);
@@ -120,18 +119,18 @@
@Test public void testConnectWithoutClientEncryption() throws Exception {
- SocketServerConnection conn = helpEstablishConnection(false, null, false, new Properties());
+ SSLConfiguration config = new SSLConfiguration();
+ config.setClientEncryptionEnabled(false);
+ SocketServerConnection conn = helpEstablishConnection(false, config, new Properties());
assertTrue(conn.selectServerInstance().getCryptor() instanceof NullCryptor);
conn.close();
}
- private SocketServerConnection helpEstablishConnection(boolean secure,
- SSLEngine serverSSL) throws CommunicationException, ConnectionException {
- return helpEstablishConnection(secure, serverSSL, true, new Properties());
+ private SocketServerConnection helpEstablishConnection(boolean secure) throws CommunicationException, ConnectionException {
+ return helpEstablishConnection(secure, new SSLConfiguration(), new Properties());
}
- private SocketServerConnection helpEstablishConnection(boolean secure,
- SSLEngine serverSSL, boolean isClientEncryptionEnabled, Properties socketConfig) throws CommunicationException,
+ private SocketServerConnection helpEstablishConnection(boolean clientSecure, SSLConfiguration config, Properties socketConfig) throws CommunicationException,
ConnectionException {
if (listener == null) {
ClientServiceRegistryImpl server = new ClientServiceRegistryImpl();
@@ -143,7 +142,7 @@
}
}, null);
- listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(), 1024, 1024, 1, serverSSL, isClientEncryptionEnabled, server);
+ listener = new SocketListener(addr.getPort(), addr.getAddress().getHostAddress(), 1024, 1024, 1, config, server);
SocketListenerStats stats = listener.getStats();
assertEquals(0, stats.maxSockets);
@@ -153,7 +152,7 @@
}
Properties p = new Properties();
- String url = new MMURL(addr.getHostName(), listener.getPort(),secure).getAppServerURL();
+ String url = new MMURL(addr.getHostName(), listener.getPort(), clientSecure).getAppServerURL();
p.setProperty(MMURL.CONNECTION.SERVER_URL, url);
p.setProperty(MMURL.CONNECTION.DISCOVERY_STRATEGY, UrlServerDiscovery.class.getName());
if (sscf == null) {
@@ -165,7 +164,7 @@
@Test public void testSSLConnectWithNonSSLServer() throws Exception {
try {
- helpEstablishConnection(true, null);
+ helpEstablishConnection(true);
fail("exception expected"); //$NON-NLS-1$
} catch (CommunicationException e) {
@@ -178,7 +177,10 @@
engine.setEnabledCipherSuites(new String[] { SocketUtil.ANON_CIPHER_SUITE });
Properties p = new Properties();
p.setProperty(SocketUtil.TRUSTSTORE_FILENAME, SocketUtil.NONE);
- SocketServerConnection conn = helpEstablishConnection(true, engine, true, p);
+ SSLConfiguration config = new SSLConfiguration();
+ config.setSslEnabled(true);
+ config.setAuthenticationMode(SSLConfiguration.ANONYMOUS);
+ SocketServerConnection conn = helpEstablishConnection(true, config, p);
conn.close();
}
14 years, 10 months
teiid SVN: r1871 - branches/JCA/client/src/main/java/org/teiid/adminapi/impl.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-02-24 14:24:18 -0500 (Wed, 24 Feb 2010)
New Revision: 1871
Modified:
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java
Log:
TEIID-998: All the metadata object needs to be serializable for transport purposes
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java 2010-02-23 22:22:21 UTC (rev 1870)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/DataRoleMetadata.java 2010-02-24 19:24:18 UTC (rev 1871)
@@ -21,6 +21,7 @@
*/
package org.teiid.adminapi.impl;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -69,7 +70,7 @@
"securityRoleRef"
})
@ManagementObject
-public class DataRoleMetadata {
+public class DataRoleMetadata implements Serializable {
@XmlAttribute(name = "name", required = true)
protected String name;
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2010-02-23 22:22:21 UTC (rev 1870)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/PropertyMetadata.java 2010-02-24 19:24:18 UTC (rev 1871)
@@ -22,6 +22,8 @@
package org.teiid.adminapi.impl;
+import java.io.Serializable;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
@@ -43,7 +45,7 @@
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(name = "property")
-public class PropertyMetadata {
+public class PropertyMetadata implements Serializable{
@XmlAttribute(name = "name", required = true)
protected String name;
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java 2010-02-23 22:22:21 UTC (rev 1870)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ReferenceMappingMetadata.java 2010-02-24 19:24:18 UTC (rev 1871)
@@ -21,6 +21,7 @@
*/
package org.teiid.adminapi.impl;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@@ -53,7 +54,7 @@
"names"
})
@ManagementObject
-public class ReferenceMappingMetadata {
+public class ReferenceMappingMetadata implements Serializable {
@XmlElement(name = "ref-name", required = true)
protected String refName;
14 years, 10 months