teiid SVN: r3440 - in branches/7.4.x/engine/src: test/java/org/teiid/dqp/internal/process and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-08-31 14:43:49 -0400 (Wed, 31 Aug 2011)
New Revision: 3440
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
Log:
TEIID-1738 applying temptable permissions appropriately
Modified: branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java 2011-08-31 18:28:44 UTC (rev 3439)
+++ branches/7.4.x/engine/src/main/java/org/teiid/dqp/internal/process/DataRolePolicyDecider.java 2011-08-31 18:43:49 UTC (rev 3440)
@@ -1,3 +1,25 @@
+/*
+ * 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.process;
import java.util.Collections;
@@ -49,13 +71,20 @@
@Override
public boolean isTempAccessable(PermissionType action, String resource,
Context context, CommandContext commandContext) {
+ Boolean result = null;
for(DataPolicy p:commandContext.getAllowedDataPolicies().values()) {
DataPolicyMetadata policy = (DataPolicyMetadata)p;
if (policy.isAllowCreateTemporaryTables() != null) {
- return policy.isAllowCreateTemporaryTables();
+ if (policy.isAllowCreateTemporaryTables()) {
+ return true;
+ }
+ result = policy.isAllowCreateTemporaryTables();
}
}
+ if (result != null) {
+ return result;
+ }
return allowCreateTemporaryTablesByDefault;
}
Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-08-31 18:28:44 UTC (rev 3439)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestAuthorizationValidationVisitor.java 2011-08-31 18:43:49 UTC (rev 3440)
@@ -170,7 +170,7 @@
return svc;
}
- private void helpTest(DataPolicyMetadata policy, String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb) throws QueryParserException, QueryResolverException, TeiidComponentException {
+ private void helpTest(String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb, DataPolicyMetadata... roles) throws QueryParserException, QueryResolverException, TeiidComponentException {
QueryParser parser = QueryParser.getQueryParser();
Command command = parser.parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
@@ -178,7 +178,9 @@
vdb.addAttchment(QueryMetadataInterface.class, metadata);
HashMap<String, DataPolicy> policies = new HashMap<String, DataPolicy>();
- policies.put(policy.getName(), policy);
+ for (DataPolicyMetadata dataPolicyMetadata : roles) {
+ policies.put(dataPolicyMetadata.getName(), dataPolicyMetadata);
+ }
this.context.getDQPWorkContext().setPolicies(policies);
DataRolePolicyDecider dataRolePolicyDecider = new DataRolePolicyDecider();
dataRolePolicyDecider.setAllowFunctionCallsByDefault(false);
@@ -206,125 +208,127 @@
@Test public void testTemp() throws Exception {
//allowed by default
- helpTest(exampleAuthSvc1(), "create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
//explicitly denied
- helpTest(exampleAuthSvc2(), "create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {"x"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("create local temporary table x (y string)", RealMetadataFactory.example1Cached(), new String[] {"x"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testFunction() throws Exception {
QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
- helpTest(exampleAuthSvc2(), "SELECT e1, curdate() FROM pm1.g2 where xyz() > 0", metadata, new String[] {"xyz()"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 FROM pm1.g1 where xyz() > 0", metadata, new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
+ helpTest("SELECT e1, curdate() FROM pm1.g2 where xyz() > 0", metadata, new String[] {"xyz()"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testEverythingAccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testEverythingAccessible1() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testEverythingAccessible2() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e1', '1'), e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT lookup('pm1.g1', 'e1', 'e1', '1'), e1 FROM (select e1 from pm1.g1) x", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testInaccesibleElement() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e2 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("SELECT e2 FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testInaccesibleElement2() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT lookup('pm1.g1', 'e1', 'e2', '1')", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("SELECT lookup('pm1.g1', 'e1', 'e2', '1')", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testInaccesibleGroup() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 FROM pm1.g2", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2", "pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ helpTest("SELECT e1 FROM pm1.g2", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2", "pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Test public void testInsert() throws Exception {
- helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("INSERT INTO pm1.g1 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testInsertInaccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "INSERT INTO pm1.g2 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("INSERT INTO pm1.g2 (e1, e2, e3, e4) VALUES ('x', 5, {b'true'}, 1.0)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testUpdate() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e2 = 5", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("UPDATE pm1.g1 SET e2 = 5", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testUpdateCriteriaInaccessibleForRead() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g2 SET e2 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("UPDATE pm1.g2 SET e2 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testUpdateCriteriaInaccessibleForRead1() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g2 SET e2 = cast(e1 as integer)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("UPDATE pm1.g2 SET e2 = cast(e1 as integer)", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testUpdateElementInaccessibleForUpdate() throws Exception {
- helpTest(exampleAuthSvc1(), "UPDATE pm1.g1 SET e1 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("UPDATE pm1.g1 SET e1 = 5 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDelete() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("DELETE FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testDeleteCriteriaInaccesibleForRead() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g2 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("DELETE FROM pm1.g2 WHERE e1 = 'x'", RealMetadataFactory.example1Cached(), new String[] {"pm1.g2.e1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDeleteInaccesibleGroup() throws Exception {
- helpTest(exampleAuthSvc1(), "DELETE FROM pm1.g3", RealMetadataFactory.example1Cached(), new String[] {"pm1.g3"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("DELETE FROM pm1.g3", RealMetadataFactory.example1Cached(), new String[] {"pm1.g3"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testProc() throws Exception {
- helpTest(exampleAuthSvc1(), "EXEC pm1.sq1()", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("EXEC pm1.sq1()", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
}
@Test public void testProcInaccesible() throws Exception {
- helpTest(exampleAuthSvc1(), "EXEC pm1.sq2('xyz')", RealMetadataFactory.example1Cached(), new String[] {"pm1.sq2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("EXEC pm1.sq2('xyz')", RealMetadataFactory.example1Cached(), new String[] {"pm1.sq2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testSelectIntoEverythingAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1, e2, e3, e4 INTO pm1.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testSelectIntoTarget_e1_NotAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm2.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm2.g2", "pm2.g2.e2","pm2.g2.e4","pm2.g2.e3"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ helpTest("SELECT e1, e2, e3, e4 INTO pm2.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm2.g2", "pm2.g2.e2","pm2.g2.e4","pm2.g2.e3"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
@Test public void testSelectIntoTarget_e1e2_NotAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "SELECT e1, e2, e3, e4 INTO pm3.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm3.g2", "pm3.g2.e4", "pm3.g2.e3"},RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ helpTest("SELECT e1, e2, e3, e4 INTO pm3.g2 FROM pm2.g1", RealMetadataFactory.example1Cached(), new String[] {"pm3.g2", "pm3.g2.e4", "pm3.g2.e3"}, RealMetadataFactory.example1VDB(),exampleAuthSvc2()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Test public void testTempTableSelectInto() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
- helpTest(exampleAuthSvc2(), "SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
+ helpTest("SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
+ helpTest("SELECT e1 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc2(), exampleAuthSvc1()); //$NON-NLS-1$
+
}
@Test public void testTempTableSelectInto1() throws Exception {
- helpTest(exampleAuthSvc1(), "SELECT e1, e2 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("SELECT e1, e2 INTO #temp FROM pm1.g1", RealMetadataFactory.example1Cached(), new String[] {"pm1.g1.e2"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testTempTableInsert() throws Exception {
- helpTest(exampleAuthSvc1(), "insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
- helpTest(exampleAuthSvc2(), "insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$
+ helpTest("insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$
+ helpTest("insert into #temp (e1, e2, e3, e4) values ('1', '2', '3', '4')", RealMetadataFactory.example1Cached(), new String[] {"#temp"}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$
}
@Test public void testXMLAccessible() throws Exception {
- helpTest(exampleAuthSvc2(), "select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {}, RealMetadataFactory.example1VDB(), exampleAuthSvc2()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testXMLInAccessible() throws Exception {
- helpTest(exampleAuthSvc1(), "select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}, RealMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("select * from xmltest.doc1", RealMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}, RealMetadataFactory.example1VDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testAlter() throws Exception {
- helpTest(exampleAuthSvc1(), "alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest(examplePolicyBQT(), "alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter view SmallA_2589 as select * from bqt1.smalla", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB(), examplePolicyBQT()); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest(exampleAuthSvc1(), "alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
- helpTest(examplePolicyBQT(), "alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {"SmallA_2589"}, RealMetadataFactory.exampleBQTVDB(), exampleAuthSvc1()); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTest("alter trigger on SmallA_2589 INSTEAD OF UPDATE enabled", RealMetadataFactory.exampleBQTCached(), new String[] {}, RealMetadataFactory.exampleBQTVDB(), examplePolicyBQT()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
13 years, 4 months
teiid SVN: r3439 - in branches/7.4.x/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-08-31 14:28:44 -0400 (Wed, 31 Aug 2011)
New Revision: 3439
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
Log:
TEIID-1737 fix for temptabledatamanager inappropriately handling queries with a with clause
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-08-31 15:51:27 UTC (rev 3438)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/tempdata/TempTableDataManager.java 2011-08-31 18:28:44 UTC (rev 3439)
@@ -64,6 +64,7 @@
import org.teiid.query.eval.Evaluator;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.optimizer.relational.RelationalPlanner;
import org.teiid.query.parser.ParseInfo;
@@ -185,6 +186,9 @@
TempTableStore contextStore = context.getTempTableStore();
if (command instanceof Query) {
Query query = (Query)command;
+ if (modelName != null && !modelName.equals(TempMetadataAdapter.TEMP_MODEL.getID())) {
+ return null;
+ }
return registerQuery(context, contextStore, query);
}
if (command instanceof ProcedureContainer) {
Modified: branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2011-08-31 15:51:27 UTC (rev 3438)
+++ branches/7.4.x/engine/src/test/java/org/teiid/query/processor/TestWithClauseProcessing.java 2011-08-31 18:28:44 UTC (rev 3439)
@@ -64,10 +64,16 @@
String sql = "with a (x, y, z) as (select e1, e2, e3 from pm1.g1) SELECT a.x from a, a z"; //$NON-NLS-1$
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ List[] expected = new List[] {
+ Arrays.asList("a", 1, Boolean.FALSE),
+ };
+
+ dataManager.addData("WITH a (x, y, z) AS (SELECT g_0.e1, g_0.e2, g_0.e3 FROM pm1.g1 AS g_0) SELECT g_0.x FROM a AS g_0, a AS g_1", expected);
- TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] {"WITH a (x, y, z) AS (SELECT g_0.e1, g_0.e2, g_0.e3 FROM pm1.g1 AS g_0) SELECT g_0.x FROM a AS g_0, a AS g_1"}, ComparisonMode.EXACT_COMMAND_STRING);
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, RealMetadataFactory.example1Cached(), null, capFinder, new String[] {"WITH a (x, y, z) AS (SELECT g_0.e1, g_0.e2, g_0.e3 FROM pm1.g1 AS g_0) SELECT g_0.x FROM a AS g_0, a AS g_1"}, ComparisonMode.EXACT_COMMAND_STRING);
+
+ helpProcess(plan, dataManager, expected);
}
@Test public void testWithPushdownWithConstants() throws TeiidException {
13 years, 4 months
teiid SVN: r3438 - in branches/as7: jboss-integration/src/main/resources/org/teiid/jboss and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-08-31 11:51:27 -0400 (Wed, 31 Aug 2011)
New Revision: 3438
Added:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineReferenceFactoryService.java
Modified:
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
branches/as7/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
Log:
TEIID-1720: Bind the engine correctly so that local connections have access to it.
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-08-30 19:30:48 UTC (rev 3437)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-08-31 15:51:27 UTC (rev 3438)
@@ -39,8 +39,8 @@
import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.descriptions.DescriptionProvider;
import org.jboss.as.naming.ManagedReferenceFactory;
-import org.jboss.as.naming.ManagedReferenceInjector;
import org.jboss.as.naming.NamingStore;
+import org.jboss.as.naming.deployment.ContextNames;
import org.jboss.as.naming.service.BinderService;
import org.jboss.as.network.SocketBinding;
import org.jboss.as.security.plugins.SecurityDomainContext;
@@ -59,6 +59,7 @@
import org.teiid.logging.LogManager;
import org.teiid.services.BufferServiceImpl;
import org.teiid.transport.ClientServiceRegistry;
+import org.teiid.transport.LocalServerConnection;
import org.teiid.transport.SSLConfiguration;
import org.teiid.transport.SocketConfiguration;
@@ -107,49 +108,56 @@
engine.setOdbcSocketConfiguration(odbc);
}
- ServiceBuilder<ClientServiceRegistry> serviceBuilder = target.addService(TeiidServiceNames.engineServiceName(engine.getName()), engine);
- serviceBuilder.addDependency(ServiceName.JBOSS.append("connector", "workmanager"), WorkManager.class, engine.getWorkManagerInjector()); //$NON-NLS-1$ //$NON-NLS-2$
- serviceBuilder.addDependency(ServiceName.JBOSS.append("txn", "XATerminator"), XATerminator.class, engine.getXaTerminatorInjector()); //$NON-NLS-1$ //$NON-NLS-2$
- serviceBuilder.addDependency(ServiceName.JBOSS.append("txn", "TransactionManager"), TransactionManager.class, engine.getTxnManagerInjector()); //$NON-NLS-1$ //$NON-NLS-2$
- serviceBuilder.addDependency(TeiidServiceNames.BUFFER_MGR, BufferServiceImpl.class, engine.getBufferServiceInjector());
- serviceBuilder.addDependency(TeiidServiceNames.SYSTEM_VDB, SystemVDBDeployer.class, new InjectedValue<SystemVDBDeployer>());
- serviceBuilder.addDependency(TeiidServiceNames.TRANSLATOR_REPO, TranslatorRepository.class, engine.getTranslatorRepositoryInjector());
- serviceBuilder.addDependency(TeiidServiceNames.VDB_REPO, VDBRepository.class, engine.getVdbRepositoryInjector());
- serviceBuilder.addDependency(TeiidServiceNames.AUTHORIZATION_VALIDATOR, AuthorizationValidator.class, engine.getAuthorizationValidatorInjector());
- serviceBuilder.addDependency(TeiidServiceNames.CACHE_FACTORY, CacheFactory.class, engine.getCachefactoryInjector());
+ ServiceBuilder<ClientServiceRegistry> engineBuilder = target.addService(TeiidServiceNames.engineServiceName(engine.getName()), engine);
+ engineBuilder.addDependency(ServiceName.JBOSS.append("connector", "workmanager"), WorkManager.class, engine.getWorkManagerInjector()); //$NON-NLS-1$ //$NON-NLS-2$
+ engineBuilder.addDependency(ServiceName.JBOSS.append("txn", "XATerminator"), XATerminator.class, engine.getXaTerminatorInjector()); //$NON-NLS-1$ //$NON-NLS-2$
+ engineBuilder.addDependency(ServiceName.JBOSS.append("txn", "TransactionManager"), TransactionManager.class, engine.getTxnManagerInjector()); //$NON-NLS-1$ //$NON-NLS-2$
+ engineBuilder.addDependency(TeiidServiceNames.BUFFER_MGR, BufferServiceImpl.class, engine.getBufferServiceInjector());
+ engineBuilder.addDependency(TeiidServiceNames.SYSTEM_VDB, SystemVDBDeployer.class, new InjectedValue<SystemVDBDeployer>());
+ engineBuilder.addDependency(TeiidServiceNames.TRANSLATOR_REPO, TranslatorRepository.class, engine.getTranslatorRepositoryInjector());
+ engineBuilder.addDependency(TeiidServiceNames.VDB_REPO, VDBRepository.class, engine.getVdbRepositoryInjector());
+ engineBuilder.addDependency(TeiidServiceNames.AUTHORIZATION_VALIDATOR, AuthorizationValidator.class, engine.getAuthorizationValidatorInjector());
+ engineBuilder.addDependency(TeiidServiceNames.CACHE_FACTORY, CacheFactory.class, engine.getCachefactoryInjector());
if (jdbc != null) {
- serviceBuilder.addDependency(ServiceName.JBOSS.append("binding", jdbc.getSocketBinding()), SocketBinding.class, engine.getJdbcSocketBindingInjector()); //$NON-NLS-1$
+ engineBuilder.addDependency(ServiceName.JBOSS.append("binding", jdbc.getSocketBinding()), SocketBinding.class, engine.getJdbcSocketBindingInjector()); //$NON-NLS-1$
}
if (odbc != null) {
- serviceBuilder.addDependency(ServiceName.JBOSS.append("binding", odbc.getSocketBinding()), SocketBinding.class, engine.getOdbcSocketBindingInjector()); //$NON-NLS-1$
+ engineBuilder.addDependency(ServiceName.JBOSS.append("binding", odbc.getSocketBinding()), SocketBinding.class, engine.getOdbcSocketBindingInjector()); //$NON-NLS-1$
}
+
+ // register a JNDI name, this looks hard.
+ final QueryEngineReferenceFactoryService referenceFactoryService = new QueryEngineReferenceFactoryService();
+ final ServiceName referenceFactoryServiceName = TeiidServiceNames.engineServiceName(engine.getName()).append("reference-factory"); //$NON-NLS-1$
+ final ServiceBuilder<?> referenceBuilder = target.addService(referenceFactoryServiceName,referenceFactoryService);
+ referenceBuilder.addDependency(TeiidServiceNames.engineServiceName(engine.getName()), RuntimeEngineDeployer.class, referenceFactoryService.getQueryEngineInjector());
+ referenceBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
- // register JNDI Name
- ServiceName teiidContext = ServiceName.JBOSS.append("naming", "context", "teiid"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- BinderService binder = new BinderService(engine.getName());
- ServiceBuilder<ManagedReferenceFactory> namingBuilder = target.addService(teiidContext.append(engine.getName()), binder);
- namingBuilder.addDependency(teiidContext, NamingStore.class, binder.getNamingStoreInjector());
- namingBuilder.addDependency(TeiidServiceNames.engineServiceName(engine.getName()), RuntimeEngineDeployer.class, new ManagedReferenceInjector<RuntimeEngineDeployer>(binder.getManagedObjectInjector()));
- namingBuilder.setInitialMode(ServiceController.Mode.ON_DEMAND);
- newControllers.add(namingBuilder.install());
+ final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(LocalServerConnection.TEIID_RUNTIME_CONTEXT+engine.getName());
+ final BinderService engineBinderService = new BinderService(bindInfo.getBindName());
+ final ServiceBuilder<?> engineBinderBuilder = target.addService(bindInfo.getBinderServiceName(), engineBinderService);
+ engineBinderBuilder.addDependency(referenceFactoryServiceName, ManagedReferenceFactory.class, engineBinderService.getManagedObjectInjector());
+ engineBinderBuilder.addDependency(bindInfo.getParentContextServiceName(), NamingStore.class, engineBinderService.getNamingStoreInjector());
+ engineBinderBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
-
// add security domains
if ( operation.hasDefined(Configuration.SECURITY_DOMAIN)) {
List<ModelNode> domains = operation.get(Configuration.SECURITY_DOMAIN).asList();
for (ModelNode domain:domains) {
LogManager.logInfo(LogConstants.CTX_SECURITY, "Security Enabled: true"); //$NON-NLS-1$
- serviceBuilder.addDependency(ServiceName.JBOSS.append("security", "security-domain", domain.asString()), SecurityDomainContext.class, new ConcurrentMapInjector<String,SecurityDomainContext>(engine.securityDomains, domain.asString())); //$NON-NLS-1$ //$NON-NLS-2$
+ engineBuilder.addDependency(ServiceName.JBOSS.append("security", "security-domain", domain.asString()), SecurityDomainContext.class, new ConcurrentMapInjector<String,SecurityDomainContext>(engine.securityDomains, domain.asString())); //$NON-NLS-1$ //$NON-NLS-2$
}
}
- serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
- ServiceController<ClientServiceRegistry> controller = serviceBuilder.install();
+ engineBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
+ ServiceController<ClientServiceRegistry> controller = engineBuilder.install();
newControllers.add(controller);
ServiceContainer container = controller.getServiceContainer();
- container.addTerminateListener(shutdownListener);
+ container.addTerminateListener(shutdownListener);
+
+ newControllers.add(referenceBuilder.install());
+ newControllers.add(engineBinderBuilder.install());
}
Added: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineReferenceFactoryService.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineReferenceFactoryService.java (rev 0)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineReferenceFactoryService.java 2011-08-31 15:51:27 UTC (rev 3438)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This 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 software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.teiid.jboss;
+
+import org.jboss.as.naming.ManagedReference;
+import org.jboss.as.naming.ManagedReferenceFactory;
+import org.jboss.as.naming.ValueManagedReference;
+import org.jboss.msc.inject.Injector;
+import org.jboss.msc.service.Service;
+import org.jboss.msc.service.StartContext;
+import org.jboss.msc.service.StartException;
+import org.jboss.msc.service.StopContext;
+import org.jboss.msc.value.ImmediateValue;
+import org.jboss.msc.value.InjectedValue;
+import org.teiid.jboss.deployers.RuntimeEngineDeployer;
+
+
+public class QueryEngineReferenceFactoryService implements Service<ManagedReferenceFactory>, ManagedReferenceFactory {
+ private final InjectedValue<RuntimeEngineDeployer> engineInjector = new InjectedValue<RuntimeEngineDeployer>();
+
+ private ManagedReference reference;
+
+ public synchronized void start(StartContext startContext) throws StartException {
+ reference = new ValueManagedReference(new ImmediateValue<Object>(engineInjector.getValue()));
+ }
+
+ public synchronized void stop(StopContext stopContext) {
+ reference = null;
+ }
+
+ public synchronized ManagedReferenceFactory getValue() throws IllegalStateException, IllegalArgumentException {
+ return this;
+ }
+
+ public synchronized ManagedReference getReference() {
+ return reference;
+ }
+
+ public Injector<RuntimeEngineDeployer> getQueryEngineInjector() {
+ return engineInjector;
+ }
+}
Property changes on: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineReferenceFactoryService.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-08-30 19:30:48 UTC (rev 3437)
+++ branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-08-31 15:51:27 UTC (rev 3438)
@@ -86,7 +86,7 @@
max-odbc-lob-size-allowed.describe=Maximum size of lob allowed through ODBC connection in bytes (default 5MB)
event-distributor-name.describe=The JNDI name of the Teiid Event Distributor
detect-change-events.describe=Set to true for the engine to detect local change events. Should be disabled if using external change data capture tools. (default true)
-security-domain.describe=Comma separated list of domains to be used to login into Teiid
+security-domain.describe=List of domains to be used to login into Teiid
admin-security-domain.describe=security domain to be used with Admin API (please do not change this, as this should be same as profile service)
max-sessions-allowed.describe=Maximum number of sessions allowed by the system (default 5000)
sessions-expiration-timelimit.describe=Max allowed time before the session is terminated by the system, 0 indicates unlimited (default 0)
Modified: branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-08-30 19:30:48 UTC (rev 3437)
+++ branches/as7/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2011-08-31 15:51:27 UTC (rev 3438)
@@ -159,7 +159,7 @@
throw new SessionServiceException(RuntimePlugin.Util.getString("SessionServiceImpl.reached_max_sessions", new Object[] {new Long(sessionMaxLimit)})); //$NON-NLS-1$
}
- if (!domains.isEmpty() && authenticate) {
+ if (domains!= null && !domains.isEmpty() && authenticate) {
// Authenticate user...
// if not authenticated, this method throws exception
boolean onlyAllowPassthrough = Boolean.valueOf(properties.getProperty(TeiidURL.CONNECTION.PASSTHROUGH_AUTHENTICATION, "false")); //$NON-NLS-1$
@@ -168,7 +168,9 @@
securityDomain = membership.getSecurityDomain();
securityContext = membership.getSecurityContext();
subject = membership.getSubject();
- }
+ } else {
+ LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"No Security Domain configured for Teiid for authentication"}); //$NON-NLS-1$
+ }
long creationTime = System.currentTimeMillis();
Modified: branches/as7/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2011-08-30 19:30:48 UTC (rev 3437)
+++ branches/as7/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2011-08-31 15:51:27 UTC (rev 3438)
@@ -49,7 +49,7 @@
public class LocalServerConnection implements ServerConnection {
- private static final String TEIID_RUNTIME_CONTEXT = "teiid/"; //$NON-NLS-1$
+ public static final String TEIID_RUNTIME_CONTEXT = "teiid/queryengine/"; //$NON-NLS-1$
private LogonResult result;
private boolean shutdown;
13 years, 4 months
teiid SVN: r3437 - in trunk: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql and 13 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-08-30 15:30:48 -0400 (Tue, 30 Aug 2011)
New Revision: 3437
Modified:
trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/WindowFunctionProjectNode.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java
trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
Log:
TEIID-1735 adding support for non-ordered distinct aggs
Modified: trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/api/src/main/java/org/teiid/translator/ExecutionFactory.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -887,6 +887,14 @@
}
/**
+ * @return true if distinct aggregates can be windowed function.
+ * @since 7.6
+ */
+ public boolean supportsWindowDistinctAggregates() {
+ return supportsElementaryOlapOperations();
+ }
+
+ /**
* @return true if array_agg is supported
* @since 7.5
*/
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -506,6 +506,11 @@
}
@Override
+ public boolean supportsWindowDistinctAggregates() {
+ return false;
+ }
+
+ @Override
public boolean supportsSimilarTo() {
return true;
}
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -233,6 +233,11 @@
}
@Override
+ public boolean supportsWindowDistinctAggregates() {
+ return false;
+ }
+
+ @Override
public boolean supportsWindowOrderByWithAggregates() {
return false;
}
Modified: trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml
===================================================================
--- trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/documentation/developer-guide/src/main/docbook/en-US/content/translator-api.xml 2011-08-30 19:30:48 UTC (rev 3437)
@@ -1331,7 +1331,7 @@
<para>WindowOrderByWithAggregates</para>
</entry>
<entry>
- <para/>
+ <para>ElementaryOlapOperations</para>
</entry>
<entry>
<para>Translator supports windowed aggregates with a window order by clause.</para>
@@ -1339,10 +1339,21 @@
</row>
<row>
<entry>
+ <para>WindowDistinctAggregates</para>
+ </entry>
+ <entry>
+ <para>ElementaryOlapOperations, AggregatesDistinct</para>
+ </entry>
+ <entry>
+ <para>Translator supports windowed distinct aggregates.</para>
+ </entry>
+ </row>
+ <row>
+ <entry>
<para>AdvancedOlapOperations</para>
</entry>
<entry>
- <para/>
+ <para>ElementaryOlapOperations</para>
</entry>
<entry>
<para>Translator supports aggregate conditions.</para>
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 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2011-08-30 19:30:48 UTC (rev 3437)
@@ -326,7 +326,7 @@
</para>
</listitem>
<listitem>
- <para>Windowed aggregates may not use DISTINCT.
+ <para>Windowed aggregates may not use DISTINCT if the window specification is ordered.
</para>
</listitem>
</itemizedlist>
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -25,7 +25,10 @@
import java.util.Iterator;
import java.util.List;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
import org.teiid.metadata.FunctionMethod;
+import org.teiid.query.QueryPlugin;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
@@ -52,14 +55,14 @@
tgtCaps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, srcCaps.supportsSelectDistinct());
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, srcCaps.supportsAliasedTable());
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, srcCaps.supportsInnerJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, srcCaps.supportsSelfJoins());
+ setSupports(connectorID, tgtCaps, Capability.QUERY_FROM_JOIN_SELFJOIN, srcCaps.supportsSelfJoins(), Capability.QUERY_FROM_GROUP_ALIAS);
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, srcCaps.supportsOuterJoins());
tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, srcCaps.supportsFullOuterJoins());
- tgtCaps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, srcCaps.supportsInlineViews());
+ setSupports(connectorID, tgtCaps, Capability.QUERY_FROM_INLINE_VIEWS, srcCaps.supportsInlineViews(), Capability.QUERY_FROM_GROUP_ALIAS);
tgtCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, srcCaps.supportsCompareCriteriaEquals());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, srcCaps.supportsCompareCriteriaOrdered());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE, srcCaps.supportsLikeCriteria());
- tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE_ESCAPE, srcCaps.supportsLikeCriteriaEscapeCharacter());
+ setSupports(connectorID, tgtCaps, Capability.CRITERIA_LIKE_ESCAPE, srcCaps.supportsLikeCriteriaEscapeCharacter(), Capability.CRITERIA_LIKE);
tgtCaps.setCapabilitySupport(Capability.CRITERIA_IN, srcCaps.supportsInCriteria());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, srcCaps.supportsInCriteriaSubquery());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_ISNULL, srcCaps.supportsIsNullCriteria());
@@ -99,12 +102,13 @@
tgtCaps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, srcCaps.supportsOrderByNullOrdering());
tgtCaps.setCapabilitySupport(Capability.INSERT_WITH_ITERATOR, srcCaps.supportsInsertWithIterator());
tgtCaps.setCapabilitySupport(Capability.COMMON_TABLE_EXPRESSIONS, srcCaps.supportsCommonTableExpressions());
- tgtCaps.setCapabilitySupport(Capability.ADVANCED_OLAP, srcCaps.supportsAdvancedOlapOperations());
tgtCaps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, srcCaps.supportsElementaryOlapOperations());
- tgtCaps.setCapabilitySupport(Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, srcCaps.supportsWindowOrderByWithAggregates());
+ setSupports(connectorID, tgtCaps, Capability.ADVANCED_OLAP, srcCaps.supportsAdvancedOlapOperations(), Capability.ELEMENTARY_OLAP);
+ setSupports(connectorID, tgtCaps, Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, srcCaps.supportsWindowOrderByWithAggregates(), Capability.ELEMENTARY_OLAP);
tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_ARRAY, srcCaps.supportsArrayAgg());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_SIMILAR, srcCaps.supportsSimilarTo());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_LIKE_REGEX, srcCaps.supportsLikeRegex());
+ setSupports(connectorID, tgtCaps, Capability.WINDOW_FUNCTION_DISTINCT_AGGREGATES, srcCaps.supportsWindowDistinctAggregates(), Capability.ELEMENTARY_OLAP, Capability.QUERY_AGGREGATES_DISTINCT);
List<String> functions = srcCaps.getSupportedFunctions();
if(functions != null && functions.size() > 0) {
@@ -130,4 +134,17 @@
return tgtCaps;
}
+ private static void setSupports(Object connectorID, BasicSourceCapabilities tgtCaps, Capability cap, boolean supports, Capability... required) {
+ if (!supports) {
+ return;
+ }
+ for (Capability capability : required) {
+ if (!tgtCaps.supportsCapability(capability)) {
+ LogManager.logWarning(LogConstants.CTX_CONNECTOR, QueryPlugin.Util.getString("support_required", cap, capability, connectorID)); //$NON-NLS-1$
+ supports = false;
+ }
+ }
+ tgtCaps.setCapabilitySupport(cap, supports);
+ }
+
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -25,6 +25,7 @@
public interface SourceCapabilities {
public enum Capability {
+
/**
* Support indicates connector can accept queries with SELECT DISTINCT
*/
@@ -38,7 +39,7 @@
*
* @since 3.1 SP2
*/
- QUERY_FROM_GROUP_ALIAS,
+ QUERY_FROM_GROUP_ALIAS("TableAlias"), //$NON-NLS-1$
/**
* Max number of groups appearing in a from clause
*/
@@ -64,7 +65,7 @@
*
* @since 3.1 SP2
*/
- QUERY_FROM_JOIN_SELFJOIN,
+ QUERY_FROM_JOIN_SELFJOIN("SelfJoins"), //$NON-NLS-1$
/**
* Support indicates connector can accept right or left outer joins
*
@@ -76,7 +77,7 @@
*
* @since 4.1
*/
- QUERY_FROM_INLINE_VIEWS,
+ QUERY_FROM_INLINE_VIEWS("InlineViews"), //$NON-NLS-1$
/**
* Support indicates connector can accept full outer joins
*
@@ -101,13 +102,13 @@
*
* @since 3.1 SP2
*/
- CRITERIA_LIKE,
+ CRITERIA_LIKE("LikeCriteria"), //$NON-NLS-1$
/**
* Support indicates connector accepts criteria of form (element LIKE constant ESCAPE char) - CURRENTLY NOT USED
*
* @since 3.1 SP2
*/
- CRITERIA_LIKE_ESCAPE,
+ CRITERIA_LIKE_ESCAPE("LikeCriteriaEscapeCharacter"), //$NON-NLS-1$
/**
* Support indicates connector accepts criteria of form (element IN set)
*
@@ -226,7 +227,7 @@
*
* @since 3.1 SP2
*/
- QUERY_AGGREGATES_DISTINCT,
+ QUERY_AGGREGATES_DISTINCT("AggregatesDistinct"),
/**
* Support indicates connector can accept scalar subqueries in the SELECT, WHERE, and HAVING clauses
*
@@ -321,12 +322,29 @@
INSERT_WITH_ITERATOR,
COMMON_TABLE_EXPRESSIONS,
MAX_DEPENDENT_PREDICATES,
- ADVANCED_OLAP,
+ ADVANCED_OLAP("AdvancedOLAP"), //$NON-NLS-1$
QUERY_AGGREGATES_ARRAY,
- ELEMENTARY_OLAP,
- WINDOW_FUNCTION_ORDER_BY_AGGREGATES,
+ ELEMENTARY_OLAP("ElementaryOLAP"), //$NON-NLS-1$
+ WINDOW_FUNCTION_ORDER_BY_AGGREGATES("WindowOrderByAggregates"), //$NON-NLS-1$
CRITERIA_SIMILAR,
- CRITERIA_LIKE_REGEX
+ CRITERIA_LIKE_REGEX,
+ WINDOW_FUNCTION_DISTINCT_AGGREGATES("WindowDistinctAggregates"); //$NON-NLS-1$
+
+
+ private final String toString;
+
+ Capability(String toString) {
+ this.toString = toString;
+ }
+
+ Capability() {
+ this.toString = name();
+ }
+
+ public String toString() {
+ return toString;
+ }
+
}
public enum Scope {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -30,6 +30,7 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.SortSpecification.NullOrdering;
import org.teiid.metadata.Schema;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.metadata.QueryMetadataInterface;
@@ -38,6 +39,7 @@
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.symbol.AggregateSymbol;
import org.teiid.query.sql.symbol.Constant;
@@ -462,4 +464,35 @@
}
return true;
}
+
+ static boolean supportsNullOrdering(QueryMetadataInterface metadata,
+ CapabilitiesFinder capFinder, Object modelID, OrderByItem symbol)
+ throws QueryMetadataException, TeiidComponentException {
+ boolean supportsNullOrdering = CapabilitiesUtil.supports(Capability.QUERY_ORDERBY_NULL_ORDERING, modelID, metadata, capFinder);
+ NullOrder defaultNullOrder = CapabilitiesUtil.getDefaultNullOrder(modelID, metadata, capFinder);
+ if (symbol.getNullOrdering() != null) {
+ if (!supportsNullOrdering) {
+ if (symbol.getNullOrdering() == NullOrdering.FIRST) {
+ if (defaultNullOrder != NullOrder.FIRST && !(symbol.isAscending() && defaultNullOrder == NullOrder.LOW)
+ && !(!symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)) {
+ return false;
+ }
+ } else if (defaultNullOrder != NullOrder.LAST && !(symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)
+ && !(!symbol.isAscending() && defaultNullOrder == NullOrder.LOW)) {
+ return false;
+ }
+ symbol.setNullOrdering(null);
+ }
+ } else if (supportsNullOrdering && defaultNullOrder != NullOrder.LOW) {
+ //try to match the expected default of low
+ if (symbol.isAscending()) {
+ if (defaultNullOrder != NullOrder.FIRST) {
+ symbol.setNullOrdering(NullOrdering.FIRST);
+ }
+ } else if (defaultNullOrder != NullOrder.LAST) {
+ symbol.setNullOrdering(NullOrdering.LAST);
+ }
+ }
+ return true;
+ }
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -51,6 +51,7 @@
import org.teiid.query.sql.lang.IsNullCriteria;
import org.teiid.query.sql.lang.MatchCriteria;
import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.OrderByItem;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.QueryCommand;
import org.teiid.query.sql.lang.SetCriteria;
@@ -176,8 +177,36 @@
markInvalid(windowFunction, "Window function order by with aggregate not supported by source"); //$NON-NLS-1$
return;
}
+ if (!this.caps.supportsCapability(Capability.WINDOW_FUNCTION_DISTINCT_AGGREGATES)
+ && windowFunction.getFunction().isDistinct()) {
+ markInvalid(windowFunction, "Window function distinct aggregate not supported by source"); //$NON-NLS-1$
+ return;
+ }
+ try {
+ if (!CapabilitiesUtil.checkElementsAreSearchable(windowFunction.getWindowSpecification().getPartition(), metadata, SupportConstants.Element.SEARCHABLE_COMPARE)) {
+ markInvalid(windowFunction, "not all source columns support search type"); //$NON-NLS-1$
+ }
+ } catch(QueryMetadataException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
+ handleException(e);
+ }
}
+ @Override
+ public void visit(OrderByItem obj) {
+ try {
+ checkElementsAreSearchable(obj.getSymbol(), SupportConstants.Element.SEARCHABLE_COMPARE);
+ if (!CapabilitiesUtil.supportsNullOrdering(this.metadata, this.capFinder, this.modelID, obj)) {
+ markInvalid(obj, "Desired null ordering is not supported by source"); //$NON-NLS-1$
+ }
+ } catch(QueryMetadataException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
+ handleException(e);
+ }
+ }
+
public void visit(CaseExpression obj) {
if(! this.caps.supportsCapability(Capability.QUERY_CASE)) {
markInvalid(obj, "CaseExpression pushdown not supported by source"); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -32,7 +32,6 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.core.TeiidComponentException;
-import org.teiid.language.SortSpecification.NullOrdering;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.SupportConstants;
@@ -58,7 +57,6 @@
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.util.CommandContext;
-import org.teiid.translator.ExecutionFactory.NullOrder;
import org.teiid.translator.ExecutionFactory.SupportedJoinCriteria;
@@ -356,30 +354,8 @@
if(! canPushSymbol(symbol.getSymbol(), true, modelID, metadata, capFinder, record)) {
return false;
}
- boolean supportsNullOrdering = CapabilitiesUtil.supports(Capability.QUERY_ORDERBY_NULL_ORDERING, modelID, metadata, capFinder);
- NullOrder defaultNullOrder = CapabilitiesUtil.getDefaultNullOrder(modelID, metadata, capFinder);
- if (symbol.getNullOrdering() != null) {
- if (!supportsNullOrdering) {
- if (symbol.getNullOrdering() == NullOrdering.FIRST) {
- if (defaultNullOrder != NullOrder.FIRST && !(symbol.isAscending() && defaultNullOrder == NullOrder.LOW)
- && !(!symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)) {
- return false;
- }
- } else if (defaultNullOrder != NullOrder.LAST && !(symbol.isAscending() && defaultNullOrder == NullOrder.HIGH)
- && !(!symbol.isAscending() && defaultNullOrder == NullOrder.LOW)) {
- return false;
- }
- symbol.setNullOrdering(null);
- }
- } else if (supportsNullOrdering && defaultNullOrder != NullOrder.LOW) {
- //try to match the expected default of low
- if (symbol.isAscending()) {
- if (defaultNullOrder != NullOrder.FIRST) {
- symbol.setNullOrdering(NullOrdering.FIRST);
- }
- } else if (defaultNullOrder != NullOrder.LAST) {
- symbol.setNullOrdering(NullOrdering.LAST);
- }
+ if (!CapabilitiesUtil.supportsNullOrdering(metadata, capFinder, modelID, symbol)) {
+ return false;
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -39,7 +39,6 @@
import org.teiid.common.buffer.TupleSource;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
-import org.teiid.language.SQLConstants.NonReserved;
import org.teiid.language.SortSpecification.NullOrdering;
import org.teiid.query.eval.Evaluator;
import org.teiid.query.function.aggregate.AggregateFunction;
@@ -235,12 +234,8 @@
functions[i] = new StatsFunction(function);
}
- if(aggSymbol.isDistinct() && !function.equals(NonReserved.MIN) && !function.equals(NonReserved.MAX)) {
- SortingFilter filter = new SortingFilter(functions[i], getBufferManager(), getConnectionID(), true);
- ElementSymbol element = new ElementSymbol("val"); //$NON-NLS-1$
- element.setType(inputType);
- filter.setElements(Arrays.asList(element));
- functions[i] = filter;
+ if(aggSymbol.isDistinct()) {
+ functions[i] = handleDistinct(functions[i], inputType, getBufferManager(), getConnectionID());
} else if (aggSymbol.getOrderBy() != null) { //handle the xmlagg case
int[] orderIndecies = new int[aggSymbol.getOrderBy().getOrderByItems().size()];
List<OrderByItem> orderByItems = new ArrayList<OrderByItem>(orderIndecies.length);
@@ -277,6 +272,14 @@
}
}
+ static SortingFilter handleDistinct(AggregateFunction af, Class<?> inputType, BufferManager bm, String cid) {
+ SortingFilter filter = new SortingFilter(af, bm, cid, true);
+ ElementSymbol element = new ElementSymbol("val"); //$NON-NLS-1$
+ element.setType(inputType);
+ filter.setElements(Arrays.asList(element));
+ return filter;
+ }
+
private int collectExpression(Expression ex) {
int index = this.collectedExpressions.indexOf(ex);
if(index == -1) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/WindowFunctionProjectNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/WindowFunctionProjectNode.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/WindowFunctionProjectNode.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -462,6 +462,10 @@
af = new StatsFunction(function);
}
+ if(aggSymbol.isDistinct()) {
+ af = GroupingNode.handleDistinct(af, inputType, getBufferManager(), getConnectionID());
+ }
+
af.setExpressionIndex(wfi.expressionIndex);
af.setConditionIndex(wfi.conditionIndex);
af.initialize(outputType, inputType);
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -2256,9 +2256,13 @@
expression.setAggregateFunction(Type.MAX);
}
}
- if ((expression.getAggregateFunction() == Type.MAX || expression.getAggregateFunction() == Type.MIN)
- && rewriteAggs && expression.getExpression() != null && EvaluatableVisitor.willBecomeConstant(expression.getExpression())) {
- return expression.getExpression();
+ if ((expression.getAggregateFunction() == Type.MAX || expression.getAggregateFunction() == Type.MIN)) {
+ if (expression.isDistinct()) {
+ expression.setDistinct(false);
+ }
+ if (rewriteAggs && expression.getExpression() != null && EvaluatableVisitor.willBecomeConstant(expression.getExpression())) {
+ return expression.getExpression();
+ }
}
if (expression.getExpression() != null && expression.getCondition() != null && !expression.respectsNulls()) {
Expression cond = expression.getCondition();
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -156,6 +156,10 @@
public boolean isDistinct() {
return this.distinct;
}
+
+ public void setDistinct(boolean distinct) {
+ this.distinct = distinct;
+ }
/**
* Get the type of the symbol, which depends on the aggregate function and the
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -1234,7 +1234,7 @@
break;
}
validateNoSubqueriesOrOuterReferences(windowFunction);
- if (windowFunction.getFunction().getOrderBy() != null || windowFunction.getFunction().isDistinct()) {
+ if (windowFunction.getFunction().getOrderBy() != null || (windowFunction.getFunction().isDistinct() && windowFunction.getWindowSpecification().getOrderBy() != null)) {
handleValidationError(QueryPlugin.Util.getString("ERR.015.012.0042", new Object[] {windowFunction.getFunction(), windowFunction}), windowFunction); //$NON-NLS-1$
}
if (windowFunction.getWindowSpecification().getPartition() != null) {
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-08-30 19:30:48 UTC (rev 3437)
@@ -210,7 +210,7 @@
ERR.015.012.0037 = {0} cannot be used outside of aggregate functions since they are not present in a GROUP BY clause.
ERR.015.012.0039 = Nested aggregate expressions are not allowed: {0}
ERR.015.012.0041 = The aggregate function {0} cannot be used with non-numeric expressions: {1}
-ERR.015.012.0042 = A windowed aggregate function {0} cannot use its own order by clause or be distinct: {1}
+ERR.015.012.0042 = A windowed aggregate function {0} cannot use its own order by clause or be distinct with an OVER ORDER BY: {1}
AggregateValidationVisitor.non_comparable = The aggregate function {0} cannot be used with non-comparable expressions: {1}
AggregateValidationVisitor.non_xml = The XMLAGG aggregate function {0} requires an expression of type XML: {1}
AggregateValidationVisitor.non_boolean=The boolean aggregate functions ANY, SOME, EVERY require a boolean expression.
@@ -938,4 +938,6 @@
DdlPlan.event_not_exists={0} does not have an INSTEAD OF trigger defined for {1}.
DdlPlan.event_already_exists={0} already has an INSTEAD OF trigger defined for {1}.
-error_refresh=error occurred during refreshing the materialized view entries for view {0}
\ No newline at end of file
+error_refresh=error occurred during refreshing the materialized view entries for view {0}
+
+support_required=Without required support property {0}, pushdown will not be enabled for {1} on translator {2}.
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestWindowFunctions.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -34,6 +34,9 @@
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.ProjectNode;
+import org.teiid.query.processor.relational.WindowFunctionProjectNode;
import org.teiid.query.unittest.RealMetadataFactory;
@SuppressWarnings({"nls", "unchecked"})
@@ -91,6 +94,49 @@
});
}
+ @Test public void testWindowFunctionPushdown2() throws Exception {
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, true);
+ caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ ProcessorPlan plan = TestOptimizer.helpPlan("select max(e1) over (order by e1 nulls first) as y from pm1.g1", //$NON-NLS-1$
+ RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps),
+ new String[] {
+ "SELECT g_0.e1 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {1, 1, 1}, new Class<?>[] {AccessNode.class, WindowFunctionProjectNode.class, ProjectNode.class});
+
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY_NULL_ORDERING, true);
+ plan = TestOptimizer.helpPlan("select max(e1) over (order by e1 nulls first) as y from pm1.g1", //$NON-NLS-1$
+ RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps),
+ new String[] {
+ "SELECT MAX(g_0.e1) OVER (ORDER BY g_0.e1 NULLS FIRST) FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testWindowFunctionPushdown3() throws Exception {
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_DISTINCT, true);
+ ProcessorPlan plan = TestOptimizer.helpPlan("select count(distinct e1) over (partition by e2) as y from pm1.g1", //$NON-NLS-1$
+ RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps),
+ new String[] {
+ "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {1, 1, 1}, new Class<?>[] {AccessNode.class, WindowFunctionProjectNode.class, ProjectNode.class});
+
+ caps.setCapabilitySupport(Capability.WINDOW_FUNCTION_DISTINCT_AGGREGATES, true);
+ plan = TestOptimizer.helpPlan("select count(distinct e1) over (partition by e2) as y from pm1.g1", //$NON-NLS-1$
+ RealMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps),
+ new String[] {
+ "SELECT COUNT(DISTINCT g_0.e1) OVER (PARTITION BY g_0.e2) FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+
@Test public void testRanking() throws Exception {
String sql = "select e1, row_number() over (order by e1), rank() over (order by e1), dense_rank() over (order by e1 nulls last) from pm1.g1";
@@ -236,4 +282,24 @@
helpProcess(plan, dataManager, expected);
}
+ @Test public void testPartitionedDistinctCount() throws Exception {
+ String sql = "select e1, e3, count(distinct e1) over (partition by e3) as r from pm1.g1 order by e1, e3";
+
+ List<?>[] expected = new List[] {
+ Arrays.asList(null, Boolean.FALSE, 2),
+ Arrays.asList("a", Boolean.FALSE, 2),
+ Arrays.asList("a", Boolean.FALSE, 2),
+ Arrays.asList("a", Boolean.TRUE, 2),
+ Arrays.asList("b", Boolean.FALSE, 2),
+ Arrays.asList("c", Boolean.TRUE, 2),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+ ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+
}
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2011-08-30 18:11:33 UTC (rev 3436)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2011-08-30 19:30:48 UTC (rev 3437)
@@ -1949,4 +1949,8 @@
helpValidate("select count(*) over () as y", new String[] {"COUNT(*) OVER ()"}, RealMetadataFactory.example1Cached());
}
+ @Test public void testWindowFunctionOrderedDistinct() {
+ helpValidate("select count(distinct e1) over (order by e2) as y from pm1.g1", new String[] {"COUNT(DISTINCT e1) OVER (ORDER BY e2)"}, RealMetadataFactory.example1Cached());
+ }
+
}
13 years, 4 months
teiid SVN: r3436 - trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-08-30 14:11:33 -0400 (Tue, 30 Aug 2011)
New Revision: 3436
Modified:
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
Log:
TEIID-1736 correcting support capabilities
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2011-08-30 14:31:06 UTC (rev 3435)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/CapabilitiesConverter.java 2011-08-30 18:11:33 UTC (rev 3436)
@@ -100,7 +100,7 @@
tgtCaps.setCapabilitySupport(Capability.INSERT_WITH_ITERATOR, srcCaps.supportsInsertWithIterator());
tgtCaps.setCapabilitySupport(Capability.COMMON_TABLE_EXPRESSIONS, srcCaps.supportsCommonTableExpressions());
tgtCaps.setCapabilitySupport(Capability.ADVANCED_OLAP, srcCaps.supportsAdvancedOlapOperations());
- tgtCaps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, srcCaps.supportsAdvancedOlapOperations());
+ tgtCaps.setCapabilitySupport(Capability.ELEMENTARY_OLAP, srcCaps.supportsElementaryOlapOperations());
tgtCaps.setCapabilitySupport(Capability.WINDOW_FUNCTION_ORDER_BY_AGGREGATES, srcCaps.supportsWindowOrderByWithAggregates());
tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_ARRAY, srcCaps.supportsArrayAgg());
tgtCaps.setCapabilitySupport(Capability.CRITERIA_SIMILAR, srcCaps.supportsSimilarTo());
13 years, 4 months
teiid SVN: r3435 - branches/7.4.x/runtime/src/main/java/org/teiid/odbc.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-08-30 10:31:06 -0400 (Tue, 30 Aug 2011)
New Revision: 3435
Modified:
branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
Log:
TEIID-1732 refining empty handling
Modified: branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-08-30 14:16:43 UTC (rev 3434)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-08-30 14:31:06 UTC (rev 3435)
@@ -592,7 +592,7 @@
}
@Override
- public void executeQuery(final String query) {
+ public void executeQuery(String query) {
if (beginExecution()) {
errorOccurred("Awaiting asynch result"); //$NON-NLS-1$
ready();
@@ -601,6 +601,11 @@
//46.2.3 Note that a simple Query message also destroys the unnamed portal.
this.portalMap.remove(UNNAMED);
this.preparedMap.remove(UNNAMED);
+ query = query.trim();
+ if (query.length() == 0) {
+ client.emptyQueryReceived();
+ ready();
+ }
QueryWorkItem r = new QueryWorkItem(query);
r.run();
@@ -848,11 +853,6 @@
sql = reader.readStatement();
}
while (sql != null) {
- if (sql.trim().length() == 0) {
- sql = reader.readStatement();
- client.emptyQueryReceived();
- continue;
- }
try {
ResultsFuture<Integer> results = new ResultsFuture<Integer>();
13 years, 4 months
teiid SVN: r3434 - branches/7.4.x/runtime/src/main/java/org/teiid/odbc.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-08-30 10:16:43 -0400 (Tue, 30 Aug 2011)
New Revision: 3434
Modified:
branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
Log:
TEIID-1732 correcting the simple query execution to always send ready
Modified: branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java
===================================================================
--- branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-08-30 02:16:42 UTC (rev 3433)
+++ branches/7.4.x/runtime/src/main/java/org/teiid/odbc/ODBCServerRemoteImpl.java 2011-08-30 14:16:43 UTC (rev 3434)
@@ -454,7 +454,6 @@
List<PgColInfo> cols = getPgColInfo(stmt.getResultSet().getMetaData());
client.sendResults(query.sql, stmt.getResultSet(), cols, result, true);
} else {
- // null future
client.sendUpdateCount(query.sql, stmt.getUpdateCount());
setEncoding();
result.getResultsReceiver().receiveResults(1);
@@ -603,11 +602,6 @@
this.portalMap.remove(UNNAMED);
this.preparedMap.remove(UNNAMED);
- if (query.trim().length() == 0) {
- this.client.emptyQueryReceived();
- ready();
- return;
- }
QueryWorkItem r = new QueryWorkItem(query);
r.run();
}
@@ -837,6 +831,15 @@
private QueryWorkItem(String query) {
this.reader = new ScriptReader(new StringReader(query));
}
+
+ private void done(Throwable error) {
+ if (error != null) {
+ errorOccurred(error);
+ } else {
+ doneExecuting();
+ }
+ ready();
+ }
@Override
public void run() {
@@ -845,6 +848,11 @@
sql = reader.readStatement();
}
while (sql != null) {
+ if (sql.trim().length() == 0) {
+ sql = reader.readStatement();
+ client.emptyQueryReceived();
+ continue;
+ }
try {
ResultsFuture<Integer> results = new ResultsFuture<Integer>();
@@ -856,14 +864,14 @@
} catch (InterruptedException e) {
throw new AssertionError(e);
} catch (IOException e) {
- client.errorOccurred(e);
+ done(e);
return;
} catch (ExecutionException e) {
Throwable cause = e;
while (cause instanceof ExecutionException && cause.getCause() != null && cause != cause.getCause()) {
cause = cause.getCause();
}
- client.errorOccurred(cause);
+ done(cause);
return;
}
QueryWorkItem.this.run(); //continue processing
@@ -909,15 +917,15 @@
}
return; //wait for the execution to finish
} catch (SQLException e) {
- errorOccurred(e);
- break;
+ done(e);
+ return;
}
}
} catch(IOException e) {
- errorOccurred(e);
+ done(e);
+ return;
}
- doneExecuting();
- ready();
+ done(null);
}
}
13 years, 4 months
teiid SVN: r3433 - in branches/as7: build/kits/jboss-as7 and 35 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-08-29 22:16:42 -0400 (Mon, 29 Aug 2011)
New Revision: 3433
Added:
branches/as7/build/kits/jboss-as7/docs/
branches/as7/build/kits/jboss-as7/docs/teiid/
branches/as7/build/kits/jboss-as7/docs/teiid/datasources/
branches/as7/build/kits/jboss-as7/docs/teiid/datasources/all-drivers.xml
branches/as7/build/kits/jboss-as7/docs/teiid/datasources/h2.xml
branches/as7/build/kits/jboss-as7/docs/teiid/datasources/oracle.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-roles.properties
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-users.properties
branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
branches/as7/client/src/test/resources/parser-test-vdb.xml
Modified:
branches/as7/api/src/main/java/org/teiid/metadata/FunctionMethod.java
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/api/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/common-core/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/file/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/loopback/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/api/main/module.xml
branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml
branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
branches/as7/client/src/main/java/org/teiid/client/plan/PlanNode.java
branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
branches/as7/client/src/test/java/org/teiid/client/plan/TestPlanNode.java
branches/as7/connectors/connector-file/src/main/rar/META-INF/MANIFEST.MF
branches/as7/connectors/connector-ldap/src/main/rar/META-INF/MANIFEST.MF
branches/as7/connectors/connector-salesforce/src/main/rar/META-INF/MANIFEST.MF
branches/as7/connectors/connector-ws/src/main/rar/META-INF/MANIFEST.MF
branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
branches/as7/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java
branches/as7/engine/src/main/java/org/teiid/query/function/FunctionTree.java
branches/as7/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java
branches/as7/engine/src/main/java/org/teiid/query/function/UDFSource.java
branches/as7/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
branches/as7/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
branches/as7/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ObjectSerializer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyProcessor.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructure.java
branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
branches/as7/jboss-integration/src/main/resources/schema/jboss-teiid.xsd
branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt
branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml
branches/as7/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
branches/as7/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
branches/as7/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
Log:
TEIID-1720: vdb deploys and client can connect and issue queries
Modified: branches/as7/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- branches/as7/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -111,8 +111,9 @@
protected List<FunctionParameter> inParameters = new ArrayList<FunctionParameter>();
private FunctionParameter outputParameter;
private Schema parent;
+ private ClassLoader classLoader;
- protected FunctionMethod() {
+ public FunctionMethod() {
}
public FunctionMethod(String name, String description, String category, FunctionParameter[] inputParams, FunctionParameter outputParam) {
@@ -464,4 +465,12 @@
public Schema getParent() {
return parent;
}
+
+ public ClassLoader getClassLoader() {
+ return this.classLoader;
+ }
+
+ public void setClassloader(ClassLoader classloader) {
+ this.classLoader = classloader;
+ }
}
Added: branches/as7/build/kits/jboss-as7/docs/teiid/datasources/all-drivers.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/docs/teiid/datasources/all-drivers.xml (rev 0)
+++ branches/as7/build/kits/jboss-as7/docs/teiid/datasources/all-drivers.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -0,0 +1,8 @@
+<drivers>
+ <driver name="h2" module="com.h2database.h2">
+ <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
+ </driver>
+ <driver name="oracle" module="com.oracle">
+ <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+ </driver>
+</drivers>
\ No newline at end of file
Property changes on: branches/as7/build/kits/jboss-as7/docs/teiid/datasources/all-drivers.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/build/kits/jboss-as7/docs/teiid/datasources/h2.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/docs/teiid/datasources/h2.xml (rev 0)
+++ branches/as7/build/kits/jboss-as7/docs/teiid/datasources/h2.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -0,0 +1,14 @@
+<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="H2DS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
+ <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
+ <driver>h2</driver>
+ <pool>
+ <prefill>false</prefill>
+ <use-strict-min>false</use-strict-min>
+ <flush-strategy>FailingConnectionOnly</flush-strategy>
+ </pool>
+ <security>
+ <user-name>sa</user-name>
+ <password>sa</password>
+ </security>
+</datasource>
+
Property changes on: branches/as7/build/kits/jboss-as7/docs/teiid/datasources/h2.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/build/kits/jboss-as7/docs/teiid/datasources/oracle.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/docs/teiid/datasources/oracle.xml (rev 0)
+++ branches/as7/build/kits/jboss-as7/docs/teiid/datasources/oracle.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -0,0 +1,13 @@
+<datasource jndi-name="java:/Oracle11_PushDS" pool-name="OracleDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
+ <connection-url>jdbc:oracle:thin:@englxdbs11.mw.lab.eng.bos.redhat.com:1521:orcl</connection-url>
+ <driver>oracle</driver>
+ <pool>
+ <prefill>false</prefill>
+ <use-strict-min>false</use-strict-min>
+ <flush-strategy>FailingConnectionOnly</flush-strategy>
+ </pool>
+ <security>
+ <user-name>bqt2_ro</user-name>
+ <password>mm</password>
+ </security>
+</datasource>
\ No newline at end of file
Property changes on: branches/as7/build/kits/jboss-as7/docs/teiid/datasources/oracle.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/api/main/module.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/api/main/module.xml 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/api/main/module.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -7,6 +7,7 @@
<dependencies>
+ <module name="javax.api"/>
<module name="javax.resource.api"/>
<module name="org.jboss.teiid.common-core"/>
<module name="org.jboss.teiid.client" />
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/common-core/main/module.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/common-core/main/module.xml 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/common-core/main/module.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -6,5 +6,7 @@
</resources>
<dependencies>
+ <module name="javax.api"/>
+ <module name="javax.activation.api"/>
</dependencies>
</module>
\ No newline at end of file
Added: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-roles.properties
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-roles.properties (rev 0)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-roles.properties 2011-08-30 02:16:42 UTC (rev 3433)
@@ -0,0 +1,3 @@
+# A roles.properties file for use with the UsersRolesLoginModule
+# username=role1,role2
+user=example-role
Property changes on: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-roles.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-users.properties
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-users.properties (rev 0)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-users.properties 2011-08-30 02:16:42 UTC (rev 3433)
@@ -0,0 +1,3 @@
+# A users.properties file for use with the UsersRolesLoginModule
+# username=password
+user=user
Property changes on: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/conf/teiid-security-users.properties
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/main/module.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -10,8 +10,8 @@
<resource-root path="teiid-runtime-${project.version}.jar" />
<resource-root path="teiid-engine-${project.version}.jar" />
<resource-root path="saxonhe-9.2.1.5.jar" />
- <resource-root path="json-simple-1.1.jar" />
- <!-- Insert resources here -->
+ <resource-root path="json-simple-1.1.jar" />
+ <resource-root path="conf" />
</resources>
@@ -37,6 +37,7 @@
<module name="org.jboss.as.naming"/>
<module name="javax.xml.bind.api"/>
<module name="javax.transaction.api"/>
+ <module name="javax.activation.api"/>
</dependencies>
</module>
\ No newline at end of file
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/file/main/module.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/file/main/module.xml 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/file/main/module.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -7,6 +7,7 @@
<dependencies>
+ <module name="javax.api"/>
<module name="javax.resource.api"/>
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j"/>
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/loopback/main/module.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/loopback/main/module.xml 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/loopback/main/module.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -7,6 +7,7 @@
<dependencies>
+ <module name="javax.api"/>
<module name="javax.resource.api"/>
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j"/>
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/api/main/module.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/api/main/module.xml 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/api/main/module.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -6,5 +6,6 @@
</resources>
<dependencies>
+ <module name="javax.api"/>
</dependencies>
</module>
\ No newline at end of file
Modified: branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/build/kits/jboss-as7/modules/org/jboss/teiid/translator/salesforce/main/module.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -6,6 +6,7 @@
</resources>
<dependencies>
+ <module name="javax.api"/>
<module name="javax.resource.api"/>
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j"/>
Modified: branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml
===================================================================
--- branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/build/kits/jboss-as7/standalone/configuration/standalone-teiid.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -105,10 +105,26 @@
<password>sa</password>
</security>
</datasource>
+ <datasource jndi-name="java:/Oracle11_PushDS" pool-name="OracleDS" enabled="true" jta="true" use-java-context="true" use-ccm="true">
+ <connection-url>jdbc:oracle:thin:@englxdbs11.mw.lab.eng.bos.redhat.com:1521:orcl</connection-url>
+ <driver>oracle</driver>
+ <pool>
+ <prefill>false</prefill>
+ <use-strict-min>false</use-strict-min>
+ <flush-strategy>FailingConnectionOnly</flush-strategy>
+ </pool>
+ <security>
+ <user-name>bqt2_ro</user-name>
+ <password>mm</password>
+ </security>
+ </datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
+ <driver name="oracle" module="com.oracle">
+ <xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
+ </driver>
</drivers>
</datasources>
</subsystem>
Added: branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java (rev 0)
+++ branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -0,0 +1,310 @@
+/*
+ * 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.adminapi.impl;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.adminapi.impl.ModelMetaData.ValidationError;
+import org.teiid.adminapi.impl.VDBMetaData;
+
+@SuppressWarnings("nls")
+public class VDBMetadataParser {
+
+ public static VDBMetaData unmarshell(InputStream content) throws XMLStreamException {
+ XMLInputFactory inputFactory=XMLInputFactory.newInstance();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
+
+ // elements
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case VDB:
+ VDBMetaData vdb = new VDBMetaData();
+ Properties props = getAttributes(reader);
+ vdb.setName(props.getProperty(Element.NAME.getLocalName()));
+ vdb.setVersion(Integer.parseInt(props.getProperty(Element.VERSION.getLocalName())));
+ parseVDB(reader, vdb);
+ return vdb;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ return null;
+ }
+
+ private static void parseVDB(XMLStreamReader reader, VDBMetaData vdb) throws XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ vdb.setDescription(reader.getElementText());
+ break;
+ case PROPERTY:
+ parseProperty(reader, vdb);
+ break;
+ case MODEL:
+ ModelMetaData model = new ModelMetaData();
+ parseModel(reader, model);
+ vdb.addModel(model);
+ break;
+ case TRANSLATOR:
+ VDBTranslatorMetaData translator = new VDBTranslatorMetaData();
+ parseTranslator(reader, translator);
+ vdb.addOverideTranslator(translator);
+ break;
+ case DATA_ROLE:
+ DataPolicyMetadata policy = new DataPolicyMetadata();
+ parseDataRole(reader, policy);
+ vdb.addDataPolicy(policy);
+ break;
+ case ENTRY:
+ // this is designer specific.
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseProperty(XMLStreamReader reader, AdminObjectImpl anObj)
+ throws XMLStreamException {
+ if (reader.getAttributeCount() > 0) {
+ String key = null;
+ String value = null;
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ if (attrName.equals(Element.NAME.getLocalName())) {
+ key = attrValue;
+ }
+ if (attrName.equals(Element.VALUE.getLocalName())) {
+ value = attrValue;
+ }
+ }
+ anObj.addProperty(key, value);
+ }
+ while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+ }
+
+ private static void parseDataRole(XMLStreamReader reader, DataPolicyMetadata policy) throws XMLStreamException {
+ Properties props = getAttributes(reader);
+ policy.setName(props.getProperty(Element.NAME.getLocalName()));
+ policy.setAnyAuthenticated(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ANY_ATHENTICATED_ATTR.getLocalName())));
+ policy.setAllowCreateTemporaryTables(Boolean.parseBoolean(props.getProperty(Element.DATA_ROLE_ALLOW_TEMP_TABLES_ATTR.getLocalName())));
+
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ policy.setDescription(reader.getElementText());
+ break;
+ case PERMISSION:
+ PermissionMetaData permission = new PermissionMetaData();
+ parsePermission(reader, permission);
+ policy.addPermission(permission);
+ break;
+ case MAPPED_ROLE_NAME:
+ policy.addMappedRoleName(reader.getElementText());
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parsePermission(XMLStreamReader reader, PermissionMetaData permission) throws XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case RESOURCE_NAME:
+ permission.setResourceName(reader.getElementText());
+ break;
+ case ALLOW_ALTER:
+ permission.setAllowAlter(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_CREATE:
+ permission.setAllowCreate(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_DELETE:
+ permission.setAllowDelete(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_EXECUTE:
+ permission.setAllowExecute(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_READ:
+ permission.setAllowRead(Boolean.parseBoolean(reader.getElementText()));
+ break;
+ case ALLOW_UPADTE:
+ permission.setAllowUpdate(Boolean.parseBoolean(reader.getElementText()));
+ break;
+
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseTranslator(XMLStreamReader reader, VDBTranslatorMetaData translator) throws XMLStreamException {
+ Properties props = getAttributes(reader);
+ translator.setName(props.getProperty(Element.NAME.getLocalName()));
+ translator.setType(props.getProperty(Element.TYPE.getLocalName()));
+ translator.setDescription(props.getProperty(Element.DESCRIPTION.getLocalName()));
+
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case PROPERTY:
+ parseProperty(reader, translator);
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+ private static void parseModel(XMLStreamReader reader, ModelMetaData model) throws XMLStreamException {
+ Properties props = getAttributes(reader);
+ model.setName(props.getProperty(Element.NAME.getLocalName()));
+ model.setModelType(Model.Type.valueOf(props.getProperty(Element.TYPE.getLocalName(), "PHYSICAL")));
+ model.setVisible(Boolean.parseBoolean(props.getProperty(Element.VISIBLE.getLocalName(), "true")));
+ model.setPath(props.getProperty(Element.PATH.getLocalName()));
+
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case DESCRIPTION:
+ model.setDescription(reader.getElementText());
+ break;
+ case PROPERTY:
+ parseProperty(reader, model);
+ break;
+ case SOURCE:
+ Properties sourceProps = getAttributes(reader);
+ String name = sourceProps.getProperty(Element.NAME.getLocalName());
+ String translatorName = sourceProps.getProperty(Element.SOURCE_TRANSLATOR_NAME_ATTR.getLocalName());
+ String connectionName = sourceProps.getProperty(Element.SOURCE_CONNECTION_JNDI_NAME_ATTR.getLocalName());
+ model.addSourceMapping(name, translatorName, connectionName);
+ while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+ break;
+ case VALIDATION_ERROR:
+ Properties validationProps = getAttributes(reader);
+ String msg = reader.getElementText();
+ String severity = validationProps.getProperty(Element.VALIDATION_SEVERITY_ATTR.getLocalName());
+ String path = validationProps.getProperty(Element.PATH.getLocalName());
+ ValidationError ve = new ValidationError(severity, msg);
+ ve.setPath(path);
+ model.addError(ve);
+ break;
+ default:
+ throw new XMLStreamException("Unexpected element '" + reader.getName() + "' encountered", reader.getLocation());
+ }
+ }
+ }
+
+
+ private static Properties getAttributes(XMLStreamReader reader) {
+ Properties props = new Properties();
+ if (reader.getAttributeCount() > 0) {
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ props.setProperty(attrName, attrValue);
+ }
+ }
+ return props;
+ }
+
+ enum Element {
+ // must be first
+ UNKNOWN(null),
+ VDB("vdb"),
+ NAME("name"),
+ VERSION("version"),
+ DESCRIPTION("description"),
+ PROPERTY("property"),
+ VALUE("value"),
+ MODEL("model"),
+ TYPE("type"),
+ VISIBLE("visible"),
+ PATH("path"),
+ SOURCE("source"),
+ SOURCE_TRANSLATOR_NAME_ATTR("translator-name"),
+ SOURCE_CONNECTION_JNDI_NAME_ATTR("connection-jndi-name"),
+ VALIDATION_ERROR("validation-error"),
+ VALIDATION_SEVERITY_ATTR("severity"),
+ TRANSLATOR("translator"),
+ DATA_ROLE("data-role"),
+ DATA_ROLE_ANY_ATHENTICATED_ATTR("any-authenticated"),
+ DATA_ROLE_ALLOW_TEMP_TABLES_ATTR("allow-create-temporary-tables"),
+ PERMISSION("permission"),
+ RESOURCE_NAME("resource-name"),
+ ALLOW_CREATE("allow-create"),
+ ALLOW_READ("allow-read"),
+ ALLOW_UPADTE("allow-update"),
+ ALLOW_DELETE("allow-delete"),
+ ALLOW_EXECUTE("allow-execute"),
+ ALLOW_ALTER("allow-alyer"),
+ MAPPED_ROLE_NAME("mapped-role-name"),
+ ENTRY("entry");
+
+ private final String name;
+
+ Element(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get the local name of this element.
+ *
+ * @return the local name
+ */
+ public String getLocalName() {
+ return name;
+ }
+
+ private static final Map<String, Element> elements;
+
+ static {
+ final Map<String, Element> map = new HashMap<String, Element>();
+ for (Element element : values()) {
+ final String name = element.getLocalName();
+ if (name != null) map.put(name, element);
+ }
+ elements = map;
+ }
+
+ public static Element forName(String localName) {
+ final Element element = elements.get(localName);
+ return element == null ? UNKNOWN : element;
+ }
+ }
+}
Property changes on: branches/as7/client/src/main/java/org/teiid/adminapi/impl/VDBMetadataParser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/client/src/main/java/org/teiid/client/plan/PlanNode.java
===================================================================
--- branches/as7/client/src/main/java/org/teiid/client/plan/PlanNode.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/client/src/main/java/org/teiid/client/plan/PlanNode.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -22,23 +22,20 @@
package org.teiid.client.plan;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.io.StringWriter;
+import java.io.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.ExternalizeUtil;
@@ -171,18 +168,50 @@
*/
public String toXml() {
try {
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {PlanNode.class});
- Marshaller marshaller = jc.createMarshaller();
- marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE); //$NON-NLS-1$
- StringWriter writer = new StringWriter();
- marshaller.marshal(this, writer);
- return writer.toString();
- } catch (JAXBException e) {
- //shouldn't happen
- throw new TeiidRuntimeException(e);
+ XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
+ StringWriter stringWriter = new StringWriter();
+ XMLStreamWriter writer = outputFactory.createXMLStreamWriter(stringWriter);
+ writer.writeStartDocument("UTF-8", "1.0"); //$NON-NLS-1$ //$NON-NLS-2$
+ writePlanNode(this, writer);
+ writer.writeEndDocument();
+ return stringWriter.toString();
+ } catch (FactoryConfigurationError e) {
+ throw new TeiidRuntimeException(e);
+ } catch (XMLStreamException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ private void writeProperty(Property property, XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeStartElement("property"); //$NON-NLS-1$
+ writer.writeAttribute("name", property.getName()); //$NON-NLS-1$
+ if (property.getValues() != null) {
+ for (String value:property.getValues()) {
+ writeElement(writer, "value", value); //$NON-NLS-1$
+ }
}
+ PlanNode node = property.getPlanNode();
+ if (node != null) {
+ writePlanNode(node, writer);
+ }
+ writer.writeEndElement();
}
+ private void writePlanNode(PlanNode node, XMLStreamWriter writer) throws XMLStreamException {
+ writer.writeStartElement("node"); //$NON-NLS-1$
+ writer.writeAttribute("name", node.getName()); //$NON-NLS-1$
+ for (Property p:node.getProperties()) {
+ writeProperty(p, writer);
+ }
+ writer.writeEndElement();
+ }
+
+ private void writeElement(final XMLStreamWriter writer, String name, String value) throws XMLStreamException {
+ writer.writeStartElement(name);
+ writer.writeCharacters(value);
+ writer.writeEndElement();
+ }
+
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
Modified: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetaData.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -65,7 +65,7 @@
StringWriter sw = new StringWriter();
marshell.marshal(vdb, sw);
- //System.out.println(sw.toString());
+ System.out.println(sw.toString());
// UnMarshell
Unmarshaller un = jc.createUnmarshaller();
@@ -75,7 +75,7 @@
validateVDB(vdb);
}
- private void validateVDB(VDBMetaData vdb) {
+ static void validateVDB(VDBMetaData vdb) {
ModelMetaData modelOne;
ModelMetaData modelTwo;
assertEquals("myVDB", vdb.getName()); //$NON-NLS-1$
Added: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java (rev 0)
+++ branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -0,0 +1,17 @@
+package org.teiid.adminapi.impl;
+
+import java.io.FileInputStream;
+
+import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
+
+@SuppressWarnings("nls")
+public class TestVDBMetadataParser {
+
+ @Test
+ public void testparseVDB() throws Exception {
+ FileInputStream in = new FileInputStream(UnitTestUtil.getTestDataPath() + "/parser-test-vdb.xml");
+ VDBMetaData vdb = VDBMetadataParser.unmarshell(in);
+ TestVDBMetaData.validateVDB(vdb);
+ }
+}
Property changes on: branches/as7/client/src/test/java/org/teiid/adminapi/impl/TestVDBMetadataParser.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/client/src/test/java/org/teiid/client/plan/TestPlanNode.java
===================================================================
--- branches/as7/client/src/test/java/org/teiid/client/plan/TestPlanNode.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/client/src/test/java/org/teiid/client/plan/TestPlanNode.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -62,7 +62,7 @@
}
public void testXml() throws Exception {
- assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<node name=\"x\">\n <property name=\"test\">\n <value></value>\n </property>\n <property name=\"string\">\n <value>string</value>\n </property>\n <property name=\"list<string>\">\n <value>item1</value>\n <value>item2</value>\n <value>item3</value>\n </property>\n <property name=\"child\">\n <node name=\"y\">\n <property name=\"outputCols\">\n <value>Name (string)</value>\n <value>Year (integer)</value>\n </property>\n <property name=\"Join Type\">\n <value>INNER JOIN</value>\n </property>\n <property name=\"Criteria\">\n <value>Item.ID = History.ID</value>\n </property>\n <property name=\"Other\"/>\n </node>\n </property>\n</node>\n", example1().toXml()); //$NON-NLS-1$
+ assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><node name=\"x\"><property name=\"test\"><value></value></property><property name=\"string\"><value>string</value></property><property name=\"list<string>\"><value>item1</value><value>item2</value><value>item3</value></property><property name=\"child\"><node name=\"y\"><property name=\"outputCols\"><value>Name (string)</value><value>Year (integer)</value></property><property name=\"Join Type\"><value>INNER JOIN</value></property><property name=\"Criteria\"><value>Item.ID = History.ID</value></property><property name=\"Other\"></property></node></property></node>", example1().toXml()); //$NON-NLS-1$
}
public void testText() throws Exception {
Added: branches/as7/client/src/test/resources/parser-test-vdb.xml
===================================================================
--- branches/as7/client/src/test/resources/parser-test-vdb.xml (rev 0)
+++ branches/as7/client/src/test/resources/parser-test-vdb.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<vdb name="myVDB" version="1">
+ <description>vdb description</description>
+ <property value="vdb-value" name="vdb-property"/>
+ <property value="vdb-value2" name="vdb-property2"/>
+ <model name="model-one" visible="false" type="PHYSICAL">
+ <description>model description</description>
+ <property value="model-value-override" name="model-prop"/>
+ <source translator-name="translator" connection-jndi-name="java:mybinding" name="s1"/>
+ <validation-error severity="ERROR">There is an error in VDB</validation-error>
+ </model>
+ <model name="model-two" visible="true" type="VIRTUAL">
+ <property value="model-value" name="model-prop"/>
+ <source translator-name="translator" connection-jndi-name="java:binding-one" name="s1"/>
+ <source translator-name="translator" connection-jndi-name="java:binding-two" name="s2"/>
+ </model>
+ <translator type="oracle" name="oracleOverride" description="hello world">
+ <property value="my-value" name="my-property"/>
+ </translator>
+ <data-role allow-create-temporary-tables="true" any-authenticated="false" name="roleOne">
+ <description>roleOne described</description>
+ <permission>
+ <resource-name>myTable.T1</resource-name>
+ <allow-read>true</allow-read>
+ </permission>
+ <permission>
+ <resource-name>myTable.T2</resource-name>
+ <allow-read>false</allow-read>
+ <allow-delete>true</allow-delete>
+ </permission>
+ <mapped-role-name>ROLE1</mapped-role-name>
+ <mapped-role-name>ROLE2</mapped-role-name>
+ </data-role>
+</vdb>
\ No newline at end of file
Property changes on: branches/as7/client/src/test/resources/parser-test-vdb.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/as7/connectors/connector-file/src/main/rar/META-INF/MANIFEST.MF
===================================================================
--- branches/as7/connectors/connector-file/src/main/rar/META-INF/MANIFEST.MF 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/connectors/connector-file/src/main/rar/META-INF/MANIFEST.MF 2011-08-30 02:16:42 UTC (rev 3433)
@@ -1 +1 @@
-Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api
+Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api,javax.api
Modified: branches/as7/connectors/connector-ldap/src/main/rar/META-INF/MANIFEST.MF
===================================================================
--- branches/as7/connectors/connector-ldap/src/main/rar/META-INF/MANIFEST.MF 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/connectors/connector-ldap/src/main/rar/META-INF/MANIFEST.MF 2011-08-30 02:16:42 UTC (rev 3433)
@@ -1 +1 @@
-Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api
+Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api,javax.api
Modified: branches/as7/connectors/connector-salesforce/src/main/rar/META-INF/MANIFEST.MF
===================================================================
--- branches/as7/connectors/connector-salesforce/src/main/rar/META-INF/MANIFEST.MF 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/connectors/connector-salesforce/src/main/rar/META-INF/MANIFEST.MF 2011-08-30 02:16:42 UTC (rev 3433)
@@ -1 +1 @@
-Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api
+Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api,javax.api
Modified: branches/as7/connectors/connector-ws/src/main/rar/META-INF/MANIFEST.MF
===================================================================
--- branches/as7/connectors/connector-ws/src/main/rar/META-INF/MANIFEST.MF 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/connectors/connector-ws/src/main/rar/META-INF/MANIFEST.MF 2011-08-30 02:16:42 UTC (rev 3433)
@@ -1 +1 @@
-Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api
+Dependencies: org.jboss.teiid.common-core,org.jboss.teiid.api,javax.api
Modified: branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
===================================================================
--- branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -30,6 +30,7 @@
import java.util.List;
import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
import junit.framework.Assert;
@@ -76,7 +77,7 @@
util.addUDF("foo", methods); //$NON-NLS-1$
} catch (IOException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
- } catch (JAXBException e) {
+ } catch (XMLStreamException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
}
}
@@ -91,7 +92,7 @@
Collection <FunctionMethod> methods = new ArrayList<FunctionMethod>();
try {
methods.addAll(FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream()));
- } catch (JAXBException e) {
+ } catch (XMLStreamException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
} catch (IOException e) {
throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
Modified: branches/as7/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -52,5 +52,5 @@
* @return Class reference
* @throws ClassNotFoundException If class could not be found
*/
- Class getInvocationClass(String className) throws ClassNotFoundException;
+ Class getInvocationClass(String className, ClassLoader cl) throws ClassNotFoundException;
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -80,7 +80,7 @@
* @param source The metadata source
*/
public FunctionTree(String name, FunctionMetadataSource source) {
- this(name, source, false);
+ this(name, source, false, null);
}
/**
@@ -88,12 +88,19 @@
* @param source The metadata source
*/
public FunctionTree(String name, FunctionMetadataSource source, boolean validateClass) {
+ this(name, source, validateClass, null);
+ }
+
+ public FunctionTree(String name, FunctionMetadataSource source, boolean validateClass, ClassLoader defaultClassloader) {
// Load data structures
this.validateClass = validateClass;
Collection<FunctionMethod> functions = source.getFunctionMethods();
for (FunctionMethod method : functions) {
if (!containsIndistinguishableFunction(method)){
+ if (method.getClassLoader() == null) {
+ method.setClassloader(defaultClassloader);
+ }
// Add to tree
addFunction(name, source, method);
} else if (!CoreConstants.SYSTEM_MODEL.equalsIgnoreCase(name)) {
@@ -288,7 +295,7 @@
// Defect 20007 - Ignore the invocation method if pushdown is not required.
if (validateClass && (method.getPushdown() == PushDown.CAN_PUSHDOWN || method.getPushdown() == PushDown.CANNOT_PUSHDOWN)) {
try {
- Class<?> methodClass = source.getInvocationClass(method.getInvocationClass());
+ Class<?> methodClass = source.getInvocationClass(method.getInvocationClass(), method.getClassLoader());
ReflectionHelper helper = new ReflectionHelper(methodClass);
try {
invocationMethod = helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
Modified: branches/as7/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -34,6 +34,7 @@
private FunctionTree systemFunctionTree;
private boolean allowEnvFunction = true;
+ private ClassLoader classLoader;
public FunctionTree getSystemFunctions() {
if(systemFunctionTree == null) {
@@ -47,7 +48,7 @@
// Should never happen as SystemSourcTe doesn't change
System.err.println(QueryPlugin.Util.getString("ERR.015.001.0005", report)); //$NON-NLS-1$
}
- systemFunctionTree = new FunctionTree(CoreConstants.SYSTEM_MODEL, systemSource, true);
+ systemFunctionTree = new FunctionTree(CoreConstants.SYSTEM_MODEL, systemSource, true, this.classLoader);
}
return systemFunctionTree;
}
@@ -74,4 +75,12 @@
public void setAllowEnvFunction(boolean allowEnvFunction) {
this.allowEnvFunction = allowEnvFunction;
}
+
+ public ClassLoader getClassLoader() {
+ return this.classLoader;
+ }
+
+ public void setClassloader(ClassLoader classloader) {
+ this.classLoader = classloader;
+ }
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/function/UDFSource.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/function/UDFSource.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/engine/src/main/java/org/teiid/query/function/UDFSource.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -40,7 +40,7 @@
return this.methods;
}
- public Class<?> getInvocationClass(String className) throws ClassNotFoundException {
- return Class.forName(className);
+ public Class<?> getInvocationClass(String className, ClassLoader cl) throws ClassNotFoundException {
+ return Class.forName(className, true, cl);
}
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -1,17 +1,18 @@
package org.teiid.query.function.metadata;
import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import org.teiid.metadata.FunctionMethod;
+import org.teiid.metadata.FunctionParameter;
@XmlType
@XmlRootElement(namespace="http://www.omg.org/XMI", name="XMI")
@@ -20,11 +21,196 @@
@XmlElement(namespace="http://www.metamatrix.com/metamodels/MetaMatrixFunction", name="ScalarFunction")
List<FunctionMethod> functionMethods = new ArrayList<FunctionMethod>();
- public static List<FunctionMethod> loadFunctionMethods(InputStream source) throws JAXBException {
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {FunctionMetadataReader.class});
- Unmarshaller marshaller = jc.createUnmarshaller();
- FunctionMetadataReader md = (FunctionMetadataReader) marshaller.unmarshal(source);
+ public static List<FunctionMethod> loadFunctionMethods(InputStream source) throws XMLStreamException {
+ FunctionMetadataReader md = parseFunctions(source);
return md.functionMethods;
}
+
+ public static FunctionMetadataReader parseFunctions(InputStream content) throws XMLStreamException {
+ XMLInputFactory inputFactory=XMLInputFactory.newInstance();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(content);
+ FunctionMetadataReader fmr = new FunctionMetadataReader();
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ System.out.println(reader.getLocalName());
+ switch (Namespace.forUri(reader.getNamespaceURI())) {
+ case XMI: {
+ Element element = Element.forName(reader.getLocalName());
+ switch (element) {
+ case XMI:
+ parseFunctions(reader, fmr);
+ while(reader.hasNext() && reader.next() != XMLStreamConstants.END_DOCUMENT);
+ break;
+ }
+ break;
+ }
+ }
+ }
+ return fmr;
+ }
+
+ private static void parseFunctions(XMLStreamReader reader, FunctionMetadataReader fmr) throws XMLStreamException {
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ String elementName = reader.getLocalName();
+ switch (Element.forName(elementName)) {
+ case SCALAR_FUNCTION:
+ fmr.functionMethods.add(parseScalarFunction(reader));
+ break;
+ default:
+ // skip the elements not needed.
+ while (reader.hasNext()) {
+ if (reader.nextTag() == XMLStreamConstants.END_ELEMENT && reader.getLocalName().equals(elementName)) {
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ private static FunctionMethod parseScalarFunction(XMLStreamReader reader) throws XMLStreamException {
+ FunctionMethod function = new FunctionMethod();
+ if (reader.getAttributeCount() > 0) {
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ if (Element.NAME.getLocalName().equals(attrName)) {
+ function.setName(attrValue);
+ }
+ else if (Element.CATEGORY.getLocalName().equals(attrName)) {
+ function.setCategory(attrValue);
+ }
+ else if (Element.INVOCATION_CLASS.getLocalName().equals(attrName)) {
+ function.setInvocationClass(attrValue);
+ // TODO: set class loader
+ // function.setClassloader();
+ }
+ else if (Element.INVOCATION_METHOD.getLocalName().equals(attrName)) {
+ function.setInvocationMethod(attrValue);
+ }
+ else if (Element.PUSHDOWN.getLocalName().equals(attrName)) {
+ function.setPushDown(attrValue);
+ }
+ else if (Element.DETERMINISTIC.getLocalName().equals(attrName)) {
+ function.setDeterministicBoolean(Boolean.parseBoolean(attrValue));
+ }
+ }
+ }
+ LinkedList<FunctionParameter> inputs = new LinkedList<FunctionParameter>();
+
+ while (reader.hasNext() && (reader.nextTag() != XMLStreamConstants.END_ELEMENT)) {
+ switch (Element.forName(reader.getLocalName())) {
+ case INPUT_PARAMTERS:
+ inputs.addLast(parseParameter(reader));
+ break;
+ case RETURN_PARAMETER:
+ function.setOutputParameter(parseParameter(reader));
+ break;
+ }
+ }
+ function.setInputParameters(inputs);
+ return function;
+ }
+
+ private static FunctionParameter parseParameter(XMLStreamReader reader) throws XMLStreamException {
+ FunctionParameter fp = new FunctionParameter();
+ if (reader.getAttributeCount() > 0) {
+ for(int i=0; i<reader.getAttributeCount(); i++) {
+ String attrName = reader.getAttributeLocalName(i);
+ String attrValue = reader.getAttributeValue(i);
+ if (Element.NAME.getLocalName().equals(attrName)) {
+ fp.setName(attrValue);
+ }
+ else if (Element.DESCRIPTION.getLocalName().equals(attrName)) {
+ fp.setDescription(attrValue);
+ }
+ else if (Element.TYPE.getLocalName().equals(attrName)) {
+ fp.setType(attrValue);
+ }
+ }
+ }
+ while(reader.nextTag() != XMLStreamConstants.END_ELEMENT);
+ return fp;
+ }
+
+ enum Element {
+ // must be first
+ UNKNOWN(null),
+ XMI("XMI"),//$NON-NLS-1$
+ SCALAR_FUNCTION("ScalarFunction"),//$NON-NLS-1$
+ NAME("name"), //$NON-NLS-1$
+ INPUT_PARAMTERS("inputParameters"),//$NON-NLS-1$
+ DESCRIPTION("description"),//$NON-NLS-1$
+ CATEGORY("category"),//$NON-NLS-1$
+ PUSHDOWN("pushDown"),//$NON-NLS-1$
+ INVOCATION_CLASS("invocationClass"),//$NON-NLS-1$
+ INVOCATION_METHOD("invocationMethod"),//$NON-NLS-1$
+ RETURN_PARAMETER("returnParameter"),//$NON-NLS-1$
+ DETERMINISTIC("deterministic"),//$NON-NLS-1$
+ TYPE("type");//$NON-NLS-1$
+
+ private final String name;
+
+ Element(final String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get the local name of this element.
+ *
+ * @return the local name
+ */
+ public String getLocalName() {
+ return name;
+ }
+
+ private static final Map<String, Element> elements;
+
+ static {
+ final Map<String, Element> map = new HashMap<String, Element>();
+ for (Element element : values()) {
+ final String name = element.getLocalName();
+ if (name != null) map.put(name, element);
+ }
+ elements = map;
+ }
+
+ public static Element forName(String localName) {
+ final Element element = elements.get(localName);
+ return element == null ? UNKNOWN : element;
+ }
+ }
+
+ enum Namespace {
+ // must be first
+ UNKNOWN(null),
+ XMI("http://www.omg.org/XMI"), //$NON-NLS-1$
+ FUNCTION("http://www.metamatrix.com/metamodels/MetaMatrixFunction"); //$NON-NLS-1$
+
+ private final String uri;
+
+ Namespace(String uri) {
+ this.uri = uri;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ private static final Map<String, Namespace> namespaces;
+
+ static {
+ final Map<String, Namespace> map = new HashMap<String, Namespace>();
+ for (Namespace namespace : values()) {
+ final String name = namespace.getUri();
+ if (name != null) map.put(name, namespace);
+ }
+ namespaces = map;
+ }
+
+ public static Namespace forUri(String uri) {
+ final Namespace element = namespaces.get(uri);
+ return element == null ? UNKNOWN : element;
+ }
+ }
}
Modified: branches/as7/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
--- branches/as7/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -1101,7 +1101,7 @@
* @return Class reference
* @throws ClassNotFoundException If class could not be found
*/
- public Class<?> getInvocationClass(String className) throws ClassNotFoundException {
- return Class.forName(className);
+ public Class<?> getInvocationClass(String className, ClassLoader classloader) throws ClassNotFoundException {
+ return Class.forName(className, true, classloader);
}
}
Modified: branches/as7/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java
===================================================================
--- branches/as7/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -60,8 +60,8 @@
return methods;
}
- public Class getInvocationClass(String className) throws ClassNotFoundException {
- return Class.forName(className);
+ public Class getInvocationClass(String className, ClassLoader cl) throws ClassNotFoundException {
+ return Class.forName(className, true, cl);
}
// dummy function
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/Element.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -48,10 +48,10 @@
MAX_ODBC_LOB_SIZE_ALLOWED_ELEMENT(MAX_ODBC_LOB_SIZE_ALLOWED),
EVENT_DISTRIBUTOR_NAME_ELEMENT(EVENT_DISTRIBUTOR_NAME),
DETECTING_CHANGE_EVENTS_ELEMENT(DETECTING_CHANGE_EVENTS),
- JDBC_SECURITY_DOMAIN_ELEMENT(SECURITY_DOMAIN),
MAX_SESSIONS_ALLOWED_ELEMENT(MAX_SESSIONS_ALLOWED),
SESSION_EXPIRATION_TIME_LIMIT_ELEMENT(SESSION_EXPIRATION_TIME_LIMIT),
ALLOW_ENV_FUNCTION_ELEMENT(ALLOW_ENV_FUNCTION),
+ SECURITY_DOMAIN_ELEMENT(SECURITY_DOMAIN),
//children
BUFFER_SERVICE_ELEMENT(BUFFER_SERVICE),
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ObjectSerializer.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ObjectSerializer.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/ObjectSerializer.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -67,6 +67,7 @@
if (!attachmentsStore.exists() || force) {
ObjectOutputStream oos = null;
try {
+ attachmentsStore.getParentFile().mkdirs();
oos = new ObjectOutputStream(new FileOutputStream(attachmentsStore));
oos.writeObject(attachment);
return true;
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/QueryEngineAdd.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -138,14 +138,10 @@
// add security domains
if ( operation.hasDefined(Configuration.SECURITY_DOMAIN)) {
- String domainNameOrder = operation.get(Configuration.SECURITY_DOMAIN).asString();
- if (domainNameOrder != null && domainNameOrder.trim().length()>0) {
+ List<ModelNode> domains = operation.get(Configuration.SECURITY_DOMAIN).asList();
+ for (ModelNode domain:domains) {
LogManager.logInfo(LogConstants.CTX_SECURITY, "Security Enabled: true"); //$NON-NLS-1$
- String[] domainNames = domainNameOrder.split(","); //$NON-NLS-1$
- for (String domainName : domainNames) {
- engine.addSecurityDomain(domainName);
- serviceBuilder.addDependency(ServiceName.JBOSS.append("security", "security-domain", domainName), SecurityDomainContext.class, new ConcurrentMapInjector<String,SecurityDomainContext>(engine.securityDomains, domainName)); //$NON-NLS-1$ //$NON-NLS-2$
- }
+ serviceBuilder.addDependency(ServiceName.JBOSS.append("security", "security-domain", domain.asString()), SecurityDomainContext.class, new ConcurrentMapInjector<String,SecurityDomainContext>(engine.securityDomains, domain.asString())); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -201,8 +197,13 @@
}
if (node.hasDefined(Configuration.MAX_SESSIONS_ALLOWED)) {
engine.setSessionMaxLimit(node.get(Configuration.MAX_SESSIONS_ALLOWED).asInt());
- }
-
+ }
+ if (node.hasDefined(Configuration.SECURITY_DOMAIN)) {
+ List<ModelNode> securityDomains = node.get(Configuration.SECURITY_DOMAIN).asList();
+ for (ModelNode domain:securityDomains) {
+ engine.addSecurityDomain(domain.asString());
+ }
+ }
return engine;
}
@@ -286,7 +287,7 @@
addAttribute(node, Configuration.DETECTING_CHANGE_EVENTS, type, bundle.getString(Configuration.DETECTING_CHANGE_EVENTS+DESC), ModelType.BOOLEAN, false, "true"); //$NON-NLS-1$
//session stuff
- addAttribute(node, Configuration.SECURITY_DOMAIN, type, bundle.getString(Configuration.SECURITY_DOMAIN+DESC), ModelType.STRING, false, null);
+ addAttribute(node, Configuration.SECURITY_DOMAIN, type, bundle.getString(Configuration.SECURITY_DOMAIN+DESC), ModelType.LIST, false, null);
addAttribute(node, Configuration.MAX_SESSIONS_ALLOWED, type, bundle.getString(Configuration.MAX_SESSIONS_ALLOWED+DESC), ModelType.INT, false, "5000"); //$NON-NLS-1$
addAttribute(node, Configuration.SESSION_EXPIRATION_TIME_LIMIT, type, bundle.getString(Configuration.SESSION_EXPIRATION_TIME_LIMIT+DESC), ModelType.INT, false, "0"); //$NON-NLS-1$
@@ -370,6 +371,12 @@
if (operation.hasDefined(Configuration.EVENT_DISTRIBUTOR_NAME)) {
model.get(Configuration.EVENT_DISTRIBUTOR_NAME).set(operation.get(Configuration.EVENT_DISTRIBUTOR_NAME).asString());
}
+ if (operation.hasDefined(Configuration.SECURITY_DOMAIN)) {
+ List<ModelNode> domains = operation.get(Configuration.SECURITY_DOMAIN).asList();
+ for (ModelNode domain: domains) {
+ model.get(Configuration.SECURITY_DOMAIN).add(domain.asString());
+ }
+ }
if (operation.hasDefined(Configuration.DETECTING_CHANGE_EVENTS)) {
model.get(Configuration.DETECTING_CHANGE_EVENTS).set(operation.get(Configuration.DETECTING_CHANGE_EVENTS).asBoolean());
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidBootServicesAdd.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -138,13 +138,19 @@
newControllers.add(service);
// system function tree
- SystemFunctionManager systemFunctionManager = new SystemFunctionManager();
- if (operation.hasDefined(Configuration.ALLOW_ENV_FUNCTION)) {
- systemFunctionManager.setAllowEnvFunction(operation.get(Configuration.ALLOW_ENV_FUNCTION).asBoolean());
- }
- else {
- systemFunctionManager.setAllowEnvFunction(false);
- }
+ SystemFunctionManager systemFunctionManager = null;
+ try {
+ systemFunctionManager = new SystemFunctionManager();
+ if (operation.hasDefined(Configuration.ALLOW_ENV_FUNCTION)) {
+ systemFunctionManager.setAllowEnvFunction(operation.get(Configuration.ALLOW_ENV_FUNCTION).asBoolean());
+ }
+ else {
+ systemFunctionManager.setAllowEnvFunction(false);
+ }
+ systemFunctionManager.setClassloader(Module.getCallerModule().getModule(ModuleIdentifier.create("org.jboss.teiid")).getClassLoader()); //$NON-NLS-1$
+ } catch (ModuleLoadException e) {
+ throw new OperationFailedException(e, operation);
+ }
// VDB repository
final VDBRepository vdbRepository = new VDBRepository();
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -47,7 +47,7 @@
}
public static ServiceName vdbServiceName(String vdbName, int version) {
- return VDB_SVC_BASE.append(vdbName, ".", String.valueOf(version)); //$NON-NLS-1$
+ return VDB_SVC_BASE.append(vdbName, String.valueOf(version));
}
public static ServiceName executorServiceName(String poolName) {
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/TeiidSubsystemParser.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -123,9 +123,15 @@
writeElement(writer, Element.MAX_ODBC_LOB_SIZE_ALLOWED_ELEMENT, node);
writeElement(writer, Element.EVENT_DISTRIBUTOR_NAME_ELEMENT, node);
writeElement(writer, Element.DETECTING_CHANGE_EVENTS_ELEMENT, node);
- writeElement(writer, Element.JDBC_SECURITY_DOMAIN_ELEMENT, node);
+
+ if (node.hasDefined(Element.SECURITY_DOMAIN_ELEMENT.getLocalName())) {
+ List<ModelNode> domains = node.get(Element.SECURITY_DOMAIN_ELEMENT.getLocalName()).asList();
+ writeElement(writer, Element.SECURITY_DOMAIN_ELEMENT, domains);
+ }
+
writeElement(writer, Element.MAX_SESSIONS_ALLOWED_ELEMENT, node);
writeElement(writer, Element.SESSION_EXPIRATION_TIME_LIMIT_ELEMENT, node);
+
//jdbc
if (has(node, Element.JDBC_ELEMENT.getLocalName())){
@@ -201,8 +207,16 @@
writer.writeCharacters(node.get(element.getLocalName()).asString());
writer.writeEndElement();
}
- }
+ }
+ private void writeElement(final XMLExtendedStreamWriter writer, final Element element, final List<ModelNode> nodes) throws XMLStreamException {
+ for (ModelNode node:nodes) {
+ writer.writeStartElement(element.getLocalName());
+ writer.writeCharacters(node.asString());
+ writer.writeEndElement();
+ }
+ }
+
private void writeAttribute(final XMLExtendedStreamWriter writer, final Element element, final ModelNode node) throws XMLStreamException {
if (has(node, element.getLocalName())) {
writer.writeAttribute(element.getLocalName(), node.get(element.getLocalName()).asString());
@@ -327,9 +341,14 @@
//Strings
case EVENT_DISTRIBUTOR_NAME_ELEMENT:
- case JDBC_SECURITY_DOMAIN_ELEMENT:
node.get(reader.getLocalName()).set(reader.getElementText());
break;
+
+ //List
+ case SECURITY_DOMAIN_ELEMENT:
+ node.get(reader.getLocalName()).add(reader.getElementText());
+ break;
+
case JDBC_ELEMENT:
node.get(reader.getLocalName()).set(parseSocketConfiguration(reader));
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyProcessor.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyProcessor.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDependencyProcessor.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -82,13 +82,9 @@
try {
final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
final ModuleLoader moduleLoader = Module.getCallerModule().getModule(ModuleIdentifier.create("org.jboss.teiid")).getModuleLoader(); //$NON-NLS-1$
- VDBMetaData vdb = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
-
- for (ModelMetaData model: vdb.getModelMetaDatas().values()) {
- for (String source:model.getSourceNames()) {
- moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create(model.getSourceTranslatorName(source)), false, false, false));
- }
- }
+ moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("org.jboss.teiid.api"), false, false, false)); //$NON-NLS-1$
+ moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("org.jboss.teiid.common-core"), false, false, false)); //$NON-NLS-1$
+ moduleSpecification.addLocalDependency(new ModuleDependency(moduleLoader, ModuleIdentifier.create("javax.api"), false, false, false)); //$NON-NLS-1$
} catch (ModuleLoadException e) {
throw new DeploymentUnitProcessingException(e);
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -22,6 +22,7 @@
package org.teiid.jboss;
import java.util.List;
+import java.util.concurrent.Executor;
import org.jboss.as.server.deployment.*;
import org.jboss.msc.service.ServiceBuilder;
@@ -110,11 +111,19 @@
vdbService.addDependency(ServiceName.JBOSS.append("data-source", model.getSourceConnectionJndiName(sourceName))); //$NON-NLS-1$
}
}
+
+ // adding the translator services is redundant, however if one is removed then it is an issue.
+ for (Translator t: deployment.getOverrideTranslators()) {
+ VDBTranslatorMetaData data = (VDBTranslatorMetaData)t;
+ String type = data.getType();
+ vdbService.addDependency(TeiidServiceNames.translatorServiceName(type));
+ }
+
vdbService.addDependency(TeiidServiceNames.VDB_REPO, VDBRepository.class, vdb.getVDBRepositoryInjector());
vdbService.addDependency(TeiidServiceNames.TRANSLATOR_REPO, TranslatorRepository.class, vdb.getTranslatorRepositoryInjector());
- vdbService.addDependency(TeiidServiceNames.executorServiceName(this.asyncThreadPoolName), TranslatorRepository.class, vdb.getTranslatorRepositoryInjector());
+ vdbService.addDependency(TeiidServiceNames.executorServiceName(this.asyncThreadPoolName), Executor.class, vdb.getExecutorInjector());
vdbService.addDependency(TeiidServiceNames.OBJECT_SERIALIZER, ObjectSerializer.class, vdb.getSerializerInjector());
- vdbService.setInitialMode(Mode.ACTIVE).install();
+ vdbService.setInitialMode(Mode.PASSIVE).install();
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -24,18 +24,14 @@
import java.io.IOException;
import java.util.List;
-import javax.xml.XMLConstants;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.validation.Schema;
-import javax.xml.validation.SchemaFactory;
+import javax.xml.stream.XMLStreamException;
import org.jboss.as.server.deployment.*;
import org.jboss.vfs.VirtualFile;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.adminapi.impl.VDBMetadataParser;
import org.teiid.deployers.TeiidAttachments;
import org.teiid.deployers.UDFMetaData;
import org.teiid.logging.LogConstants;
@@ -43,7 +39,6 @@
import org.teiid.metadata.VdbConstants;
import org.teiid.metadata.index.IndexMetadataFactory;
import org.teiid.runtime.RuntimePlugin;
-import org.xml.sax.SAXException;
/**
@@ -84,10 +79,10 @@
}
}
else {
- if (file.getLowerCaseName().equals(VdbConstants.DEPLOYMENT_FILE)) {
+ if (file.getName().toLowerCase().equals(VdbConstants.DEPLOYMENT_FILE)) {
parseVDBXML(file, deploymentUnit);
}
- else if (file.getLowerCaseName().endsWith(VdbConstants.INDEX_EXT)) {
+ else if (file.getName().endsWith(VdbConstants.INDEX_EXT)) {
IndexMetadataFactory imf = deploymentUnit.getAttachment(TeiidAttachments.INDEX_METADATA);
if (imf == null) {
imf = new IndexMetadataFactory();
@@ -95,7 +90,7 @@
}
imf.addIndexFile(file);
}
- else if (file.getLowerCaseName().endsWith(VdbConstants.MODEL_EXT)) {
+ else if (file.getName().toLowerCase().endsWith(VdbConstants.MODEL_EXT)) {
UDFMetaData udf = deploymentUnit.getAttachment(TeiidAttachments.UDF_METADATA);
if (udf == null) {
udf = new UDFMetaData();
@@ -103,21 +98,16 @@
}
udf.addModelFile(file);
}
-
}
}
- private void parseVDBXML(VirtualFile file, DeploymentUnit deploymentUnit)
- throws DeploymentUnitProcessingException {
+ private void parseVDBXML(VirtualFile file, DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
try {
- Unmarshaller un = getUnMarsheller();
- VDBMetaData vdb = (VDBMetaData)un.unmarshal(file.openStream());
+ VDBMetaData vdb = VDBMetadataParser.unmarshell(file.openStream());
deploymentUnit.putAttachment(TeiidAttachments.VDB_METADATA, vdb);
LogManager.logDetail(LogConstants.CTX_RUNTIME,"VDB "+file.getName()+" has been parsed."); //$NON-NLS-1$ //$NON-NLS-2$
- } catch (JAXBException e) {
+ } catch (XMLStreamException e) {
throw new DeploymentUnitProcessingException(e);
- } catch (SAXException e) {
- throw new DeploymentUnitProcessingException(e);
} catch (IOException e) {
throw new DeploymentUnitProcessingException(e);
}
@@ -126,16 +116,6 @@
public void undeploy(final DeploymentUnit context) {
}
-
- static Unmarshaller getUnMarsheller() throws JAXBException, SAXException {
- JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {VDBMetaData.class});
- SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
- Schema schema = schemaFactory.newSchema(VDBMetaData.class.getResource("/vdb-deployer.xsd")); //$NON-NLS-1$
- Unmarshaller un = jc.createUnmarshaller();
- un.setSchema(schema);
- return un;
- }
-
protected VDBMetaData mergeMetaData(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException {
VDBMetaData vdb = deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
UDFMetaData udf = deploymentUnit.getAttachment(TeiidAttachments.UDF_METADATA);
@@ -172,7 +152,7 @@
}
} catch(IOException e) {
throw new DeploymentUnitProcessingException(e);
- } catch (JAXBException e) {
+ } catch (XMLStreamException e) {
throw new DeploymentUnitProcessingException(e);
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -72,7 +72,10 @@
// check if this is a VDB with index files, if there are then build the TransformationMetadata
UDFMetaData udf = this.vdb.getAttachment(UDFMetaData.class);
IndexMetadataFactory indexFactory = this.vdb.getAttachment(IndexMetadataFactory.class);
- long vdbModifiedTime = Long.parseLong(vdb.getPropertyValue(VDBService.VDB_LASTMODIFIED_TIME));
+ long vdbModifiedTime = -1L;
+ if (vdb.getPropertyValue(VDBService.VDB_LASTMODIFIED_TIME) != null) {
+ vdbModifiedTime = Long.parseLong(vdb.getPropertyValue(VDBService.VDB_LASTMODIFIED_TIME));
+ }
// add required connector managers; if they are not already there
for (Translator t: this.vdb.getOverrideTranslators()) {
@@ -93,7 +96,7 @@
createConnectorManagers(cmr, repo, this.vdb);
// check to see if the vdb has been modified when server is down; if it is then clear the old files
- if (getSerializer().isStale(this.vdb, vdbModifiedTime)) {
+ if (vdbModifiedTime != -1L && getSerializer().isStale(this.vdb, vdbModifiedTime)) {
getSerializer().removeAttachments(this.vdb);
LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB ", vdb.getName(), " old cached metadata has been removed"); //$NON-NLS-1$ //$NON-NLS-2$
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructure.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructure.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/VDBStructure.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -21,15 +21,7 @@
*/
package org.teiid.jboss;
-import java.io.Closeable;
-import java.io.IOException;
-
import org.jboss.as.server.deployment.*;
-import org.jboss.as.server.deployment.module.ModuleRootMarker;
-import org.jboss.as.server.deployment.module.MountHandle;
-import org.jboss.as.server.deployment.module.ResourceRoot;
-import org.jboss.as.server.deployment.module.TempFileProviderService;
-import org.jboss.vfs.VFS;
import org.jboss.vfs.VirtualFile;
import org.teiid.deployers.TeiidAttachments;
import org.teiid.metadata.VdbConstants;
@@ -50,28 +42,19 @@
return;
}
- if(file.getLowerCaseName().endsWith(VDB_EXTENSION)) {
-
- try {
- final Closeable closable = VFS.mountZip(file, file, TempFileProviderService.provider());
- final ResourceRoot vdbArchiveRoot = new ResourceRoot(file.getName(), file, new MountHandle(closable));
- ModuleRootMarker.mark(vdbArchiveRoot);
-
- VirtualFile metainf = file.getChild("META-INF"); //$NON-NLS-1$
- if (metainf == null) {
- return;
- }
-
- if (metainf.getChild(VdbConstants.DEPLOYMENT_FILE) == null) {
- return;
- }
- // adds a TYPE attachment.
- TeiidAttachments.setAsVDBDeployment(deploymentUnit);
- } catch (IOException e) {
- throw new DeploymentUnitProcessingException("failed to process " + file, e); //$NON-NLS-1$
- }
+ if(file.getName().toLowerCase().endsWith(VDB_EXTENSION)) {
+ VirtualFile metainf = file.getChild("META-INF"); //$NON-NLS-1$
+ if (metainf == null) {
+ return;
+ }
+
+ if (metainf.getChild(VdbConstants.DEPLOYMENT_FILE) == null) {
+ return;
+ }
+ // adds a TYPE attachment.
+ TeiidAttachments.setAsVDBDeployment(deploymentUnit);
}
- else if (file.getLowerCaseName().endsWith(DYNAMIC_VDB_STRUCTURE)) {
+ else if (file.getName().toLowerCase().endsWith(DYNAMIC_VDB_STRUCTURE)) {
TeiidAttachments.setAsDynamicVDBDeployment(deploymentUnit);
}
}
@@ -79,7 +62,6 @@
@Override
public void undeploy(final DeploymentUnit context) {
-
}
}
Modified: branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
--- branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -167,6 +167,7 @@
this.sessionService.setSessionMaxLimit(this.sessionMaxLimit);
this.sessionService.setDqp(this.dqpCore);
this.sessionService.setVDBRepository(this.vdbRepository);
+ this.sessionService.setSecurityHelper(getSecurityHelper());
this.sessionService.start();
this.setBufferService(bufferServiceInjector.getValue());
Modified: branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-08-30 02:16:42 UTC (rev 3433)
@@ -32,6 +32,7 @@
policy_not_found=Policy name "{0}" not found in the VDB with name "{1}" version "{2}"
datasource_not_found=Datasource {0} not found in the configuration.
sourcename_not_found=No source name {0} found in the model: {1}.{2}.{3}
+vdb_file_not_found = VDB file {0} not found at the location specified.
no_operation=No operation found with given name = {0}
failed_to_remove=Failed to remove the deployment
Modified: branches/as7/jboss-integration/src/main/resources/schema/jboss-teiid.xsd
===================================================================
--- branches/as7/jboss-integration/src/main/resources/schema/jboss-teiid.xsd 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/main/resources/schema/jboss-teiid.xsd 2011-08-30 02:16:42 UTC (rev 3433)
@@ -250,7 +250,7 @@
<xs:documentation>Set to true for the engine to detect local change events. Should be disabled if using external change data capture tools. (default true)</xs:documentation>
</xs:annotation>
</xs:element>
- <xs:element name="security-domain" type="xs:string" minOccurs="0" maxOccurs="1">
+ <xs:element name="security-domain" type="xs:string" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>Comma separated list of domains to be used to login into Teiid</xs:documentation>
</xs:annotation>
Modified: branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt
===================================================================
--- branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/test/resources/teiid-model-config.txt 2011-08-30 02:16:42 UTC (rev 3433)
@@ -91,7 +91,7 @@
"default" => true
},
"security-domain" => {
- "type" => STRING,
+ "type" => LIST,
"description" => "Comma separated list of domains to be used to login into Teiid",
"required" => false,
"max-occurs" => 1
Modified: branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml
===================================================================
--- branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/jboss-integration/src/test/resources/teiid-sample-config.xml 2011-08-30 02:16:42 UTC (rev 3433)
@@ -49,6 +49,7 @@
<event-distributor-name>teiid/event-distributor</event-distributor-name>
<detect-change-events>true</detect-change-events>
<security-domain>teiid-security</security-domain>
+ <security-domain>teiid-security2</security-domain>
<max-sessions-allowed>5000</max-sessions-allowed>
<sessions-expiration-timelimit>0</sessions-expiration-timelimit>
Modified: branches/as7/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
--- branches/as7/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -32,6 +32,7 @@
import java.util.concurrent.Executors;
import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
import org.jboss.vfs.TempFileProvider;
import org.jboss.vfs.VFS;
@@ -98,7 +99,7 @@
return vdbmetadata;
} catch (URISyntaxException e) {
throw new IOException(e);
- } catch (JAXBException e) {
+ } catch (XMLStreamException e) {
throw new IOException(e);
}
}
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -29,6 +29,9 @@
import java.util.Random;
import java.util.UUID;
+import org.jboss.modules.Module;
+import org.jboss.modules.ModuleIdentifier;
+import org.jboss.modules.ModuleLoadException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.metadata.AbstractMetadataRecord;
import org.teiid.metadata.Column;
@@ -550,16 +553,21 @@
private FunctionMethod addHasFunctionPrivilage() throws TranslatorException {
FunctionMethod func = addFunction("has_function_privilege"); //$NON-NLS-1$
- ArrayList<FunctionParameter> inParams = new ArrayList<FunctionParameter>();
- inParams.add(new FunctionParameter("oid", DataTypeManager.DefaultDataTypes.INTEGER, ""));//$NON-NLS-1$ //$NON-NLS-2$
- inParams.add(new FunctionParameter("permission", DataTypeManager.DefaultDataTypes.STRING, "")); //$NON-NLS-1$ //$NON-NLS-2$
-
- func.setInputParameters(inParams);
- func.setOutputParameter(new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "")); //$NON-NLS-1$ //$NON-NLS-2$
-
- func.setInvocationClass(ReturnTrue.class.getName());
- func.setInvocationMethod("result"); //$NON-NLS-1$
- func.setPushdown(PushDown.CANNOT_PUSHDOWN);
+ try {
+ ArrayList<FunctionParameter> inParams = new ArrayList<FunctionParameter>();
+ inParams.add(new FunctionParameter("oid", DataTypeManager.DefaultDataTypes.INTEGER, ""));//$NON-NLS-1$ //$NON-NLS-2$
+ inParams.add(new FunctionParameter("permission", DataTypeManager.DefaultDataTypes.STRING, "")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ func.setInputParameters(inParams);
+ func.setOutputParameter(new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, "")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ func.setInvocationClass(ReturnTrue.class.getName());
+ func.setInvocationMethod("result"); //$NON-NLS-1$
+ func.setPushdown(PushDown.CANNOT_PUSHDOWN);
+ func.setClassloader(Module.getModuleFromCallerModuleLoader(ModuleIdentifier.create("org.jboss.teiid")).getClassLoader()); //$NON-NLS-1$
+ } catch (ModuleLoadException e) {
+ throw new TranslatorException(e);
+ }
return func;
}
Modified: branches/as7/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -25,6 +25,7 @@
import java.util.*;
import javax.xml.bind.JAXBException;
+import javax.xml.stream.XMLStreamException;
import org.jboss.vfs.VirtualFile;
import org.teiid.metadata.FunctionMethod;
@@ -45,7 +46,7 @@
}
- public void buildFunctionModelFile(String name, String path) throws IOException, JAXBException {
+ public void buildFunctionModelFile(String name, String path) throws IOException, XMLStreamException {
for (String f:files.keySet()) {
if (f.endsWith(path)) {
path = f;
Modified: branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/runtime/src/main/java/org/teiid/services/TeiidLoginContext.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -96,11 +96,11 @@
if (authManager != null) {
Principal userPrincipal = new SimplePrincipal(username);
Subject subject = new Subject();
- boolean isValid = authManager.isValid(userPrincipal, credential, subject);
+ boolean isValid = authManager.isValid(userPrincipal, new String(credential.getCredentialsAsCharArray()), subject);
if (isValid) {
this.userName = baseUsername+AT+domain;
this.securitydomain = domain;
- this.securityContext = this.securityHelper.createSecurityContext(this.securitydomain, userPrincipal, credential, subject);
+ this.securityContext = this.securityHelper.createSecurityContext(this.securitydomain, userPrincipal, new String(credential.getCredentialsAsCharArray()), subject);
LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"Logon successful for \"", username, "\""}); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
Modified: branches/as7/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
===================================================================
--- branches/as7/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2011-08-29 19:07:09 UTC (rev 3432)
+++ branches/as7/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2011-08-30 02:16:42 UTC (rev 3433)
@@ -32,6 +32,7 @@
import javax.crypto.SealedObject;
+import org.jboss.modules.Module;
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.client.util.ExceptionHolder;
import org.teiid.client.util.ResultsFuture;
@@ -67,7 +68,9 @@
Message result = null;
String loggingContext = null;
final boolean encrypt = message.getContents() instanceof SealedObject;
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
+ Thread.currentThread().setContextClassLoader(Module.getCallerModule().getClassLoader());
message.setContents(this.socketClientInstance.getCryptor().unsealObject(message.getContents()));
if (!(message.getContents() instanceof ServiceInvocationStruct)) {
throw new AssertionError("unknown message contents"); //$NON-NLS-1$
@@ -109,6 +112,8 @@
Message holder = new Message();
holder.setContents(processException(t, loggingContext));
result = holder;
+ } finally {
+ Thread.currentThread().setContextClassLoader(classLoader);
}
if (result != null) {
13 years, 4 months
teiid SVN: r3432 - in trunk: engine/src/main/java/org/teiid/dqp/internal/process and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-08-29 15:07:09 -0400 (Mon, 29 Aug 2011)
New Revision: 3432
Modified:
trunk/cache-jbosscache/pom.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
Log:
TEIID-1673 minor cleanups
Modified: trunk/cache-jbosscache/pom.xml
===================================================================
--- trunk/cache-jbosscache/pom.xml 2011-08-29 19:06:14 UTC (rev 3431)
+++ trunk/cache-jbosscache/pom.xml 2011-08-29 19:07:09 UTC (rev 3432)
@@ -33,6 +33,7 @@
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.man</groupId>
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-08-29 19:06:14 UTC (rev 3431)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2011-08-29 19:07:09 UTC (rev 3432)
@@ -45,7 +45,6 @@
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
import org.teiid.cache.CacheConfiguration;
import org.teiid.cache.CacheFactory;
-import org.teiid.cache.CacheConfiguration.Policy;
import org.teiid.client.DQP;
import org.teiid.client.RequestMessage;
import org.teiid.client.ResultsMessage;
@@ -204,8 +203,6 @@
private LinkedList<RequestWorkItem> waitingPlans = new LinkedList<RequestWorkItem>();
private CacheFactory cacheFactory;
- private SessionAwareCache<CachedResults> matTables;
-
private AuthorizationValidator authorizationValidator;
/**
@@ -621,9 +618,6 @@
clearResultSetCache(vdbName, version);
break;
}
- if (this.matTables != null) {
- this.matTables.clearForVDB(vdbName, version);
- }
}
public Collection<org.teiid.adminapi.Transaction> getTransactions() {
@@ -723,11 +717,6 @@
this.userRequestSourceConcurrency = Math.min(config.getMaxThreads(), 2*config.getMaxThreads()/this.maxActivePlans);
}
- if (cacheFactory.isReplicated()) {
- matTables = new SessionAwareCache<CachedResults>(this.cacheFactory, SessionAwareCache.Type.RESULTSET, new CacheConfiguration(Policy.EXPIRATION, -1, -1, "MaterilizationTables")); //$NON-NLS-1$
- matTables.setBufferManager(this.bufferManager);
- }
-
DataTierManagerImpl processorDataManager = new DataTierManagerImpl(this,this.bufferService, this.config.isDetectingChangeEvents());
processorDataManager.setEventDistributor(eventDistributor);
processorDataManager.setMetadataRepository(metadataRepository);
13 years, 4 months
teiid SVN: r3431 - in branches/7.4.x/engine/src: main/java/org/teiid/query/processor/relational and 2 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-08-29 15:06:14 -0400 (Mon, 29 Aug 2011)
New Revision: 3431
Modified:
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchCollector.java
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java
branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
branches/7.4.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
Log:
TEIID-1686 fix for assertionerror in tuplebuffer
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchCollector.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchCollector.java 2011-08-29 18:37:36 UTC (rev 3430)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/processor/BatchCollector.java 2011-08-29 19:06:14 UTC (rev 3431)
@@ -120,11 +120,12 @@
private TupleBuffer buffer;
private boolean forwardOnly;
- public BatchCollector(BatchProducer sourceNode, BufferManager bm, CommandContext context, boolean fowardOnly) throws TeiidComponentException {
+ public BatchCollector(BatchProducer sourceNode, BufferManager bm, CommandContext context, boolean forwardOnly) throws TeiidComponentException {
this.sourceNode = sourceNode;
+ this.forwardOnly = forwardOnly;
if (!this.sourceNode.hasFinalBuffer()) {
this.buffer = bm.createTupleBuffer(sourceNode.getOutputElements(), context.getConnectionID(), TupleSourceType.PROCESSOR);
- this.buffer.setForwardOnly(fowardOnly);
+ this.buffer.setForwardOnly(forwardOnly);
}
}
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java 2011-08-29 18:37:36 UTC (rev 3430)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java 2011-08-29 19:06:14 UTC (rev 3431)
@@ -133,7 +133,9 @@
public void closeDirect() {
if(this.output != null) {
- this.output.remove();
+ if (!usingOutput) {
+ this.output.remove();
+ }
this.output = null;
}
this.outputTs = null;
Modified: branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java
===================================================================
--- branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2011-08-29 18:37:36 UTC (rev 3430)
+++ branches/7.4.x/engine/src/main/java/org/teiid/query/processor/relational/XMLTableNode.java 2011-08-29 19:06:14 UTC (rev 3431)
@@ -95,7 +95,9 @@
public void closeDirect() {
super.closeDirect();
if(this.buffer != null) {
- this.buffer.remove();
+ if (!usingOutput) {
+ this.buffer.remove();
+ }
this.buffer = null;
}
reset();
Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-08-29 18:37:36 UTC (rev 3430)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2011-08-29 19:06:14 UTC (rev 3431)
@@ -333,6 +333,37 @@
assertEquals(100, item.resultsBuffer.getRowCount());
}
+ @Test public void testBufferReuse1() throws Exception {
+ //the sql should return 100 rows
+ String sql = "SELECT IntKey FROM texttable('11\n12\n13\n14\n15' columns intkey integer) t " +
+ "union " +
+ "SELECT IntKey FROM bqt1.smalla"; //$NON-NLS-1$
+ String userName = "1"; //$NON-NLS-1$
+ String sessionid = "1"; //$NON-NLS-1$
+ agds.sleep = 500;
+ agds.setUseIntCounter(true);
+ RequestMessage reqMsg = exampleRequestMessage(sql);
+ reqMsg.setCursorType(ResultSet.TYPE_FORWARD_ONLY);
+ DQPWorkContext.getWorkContext().getSession().setSessionId(sessionid);
+ DQPWorkContext.getWorkContext().getSession().setUserName(userName);
+ BufferManagerImpl bufferManager = (BufferManagerImpl)core.getBufferManager();
+ bufferManager.setProcessorBatchSize(20);
+ Future<ResultsMessage> message = core.executeRequest(reqMsg.getExecutionId(), reqMsg);
+ ResultsMessage rm = message.get(500000, TimeUnit.MILLISECONDS);
+ assertNull(rm.getException());
+ assertEquals(5, rm.getResults().length);
+
+ message = core.processCursorRequest(reqMsg.getExecutionId(), 6, 5);
+ rm = message.get(500000, TimeUnit.MILLISECONDS);
+ assertNull(rm.getException());
+ assertEquals(5, rm.getResults().length);
+
+ message = core.processCursorRequest(reqMsg.getExecutionId(), 11, 5);
+ rm = message.get(500000, TimeUnit.MILLISECONDS);
+ assertNull(rm.getException());
+ assertEquals(5, rm.getResults().length);
+ }
+
@Test public void testSourceConcurrency() throws Exception {
//setup default of 2
agds.setSleep(100);
Modified: branches/7.4.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
===================================================================
--- branches/7.4.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2011-08-29 18:37:36 UTC (rev 3430)
+++ branches/7.4.x/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2011-08-29 19:06:14 UTC (rev 3431)
@@ -59,13 +59,17 @@
public int sleep;
private final AtomicInteger executeCount = new AtomicInteger();
private final AtomicInteger closeCount = new AtomicInteger();
+ private boolean useIntCounter;
-
public AutoGenDataService() {
super("FakeConnector","FakeConnector"); //$NON-NLS-1$ //$NON-NLS-2$
caps = TestOptimizer.getTypicalCapabilities();
}
+ public void setUseIntCounter(boolean useIntCounter) {
+ this.useIntCounter = useIntCounter;
+ }
+
public void setSleep(int sleep) {
this.sleep = sleep;
}
@@ -151,7 +155,7 @@
while(iter.hasNext()) {
SingleElementSymbol symbol = (SingleElementSymbol) iter.next();
Class type = symbol.getType();
- row.add( getValue(type) );
+ row.add( getValue(type, i) );
}
rows[i] = row;
}
@@ -174,11 +178,11 @@
private static final java.sql.Time TIME_VAL = new java.sql.Time(0);
private static final java.sql.Timestamp TIMESTAMP_VAL = new java.sql.Timestamp(0);
- private Object getValue(Class<?> type) {
+ private Object getValue(Class<?> type, int row) {
if(type.equals(DataTypeManager.DefaultDataClasses.STRING)) {
return STRING_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.INTEGER)) {
- return INTEGER_VAL;
+ return useIntCounter?row:INTEGER_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.SHORT)) {
return SHORT_VAL;
} else if(type.equals(DataTypeManager.DefaultDataClasses.LONG)) {
13 years, 4 months