teiid SVN: r1574 - trunk/test-integration/db/src/test/java/org/teiid/test/testcases.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-19 13:58:25 -0500 (Thu, 19 Nov 2009)
New Revision: 1574
Added:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/CommonTransactionTests.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionTests.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OnWrapTransactionTests.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java
Log:
Teiid 773 - refactored back in the way jbedsp transaction classes where defined and added the other integration test
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/CommonTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/CommonTransactionTests.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/CommonTransactionTests.java 2009-11-19 18:58:25 UTC (rev 1574)
@@ -0,0 +1,599 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.OnWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+/**
+ * A common test case among many different transaction stuff.
+ */
+public abstract class CommonTransactionTests extends BaseAbstractTransactionTestCase {
+
+ public CommonTransactionTests(String name) {
+ super(name);
+ }
+
+ protected abstract TransactionContainer getTransactionContainter();
+
+// void runConcurrentTestCases(int howMany, final String[] sqls) {
+//
+// SeparateClient[] clients = new SeparateClient[howMany];
+//
+// for(int i = 0; i < howMany; i++) {
+// AbstractQueryTransactionTest testCase = new AbstractQueryTransactionTest() {
+// public void testCase() throws Exception {
+// execute(sqls);
+// }
+// };
+// clients[i] = new SeparateClient(getTransactionContainter(), testCase);
+// }
+//
+// for(int i = 0; i < howMany; i++) {
+// clients[i].start();
+// }
+//
+// try {
+// for(int i = 0; i < howMany; i++) {
+// clients[i].join();
+// }
+// } catch (InterruptedException e) {
+// // boo
+// }
+// }
+
+// static class SeparateClient extends Thread{
+// TransactionContainer container = null;
+// AbstractTransactionTestCase testCase = null;
+//
+// public SeparateClient(TransactionContainer container, AbstractTransactionTestCase testCase) {
+// this.container = container;
+// this.testCase = testCase;
+// }
+//
+// public void run() {
+// this.container.runTransaction(this.testCase);
+// }
+// }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // Single Source - Rows below 500 (for insert/update/delete)
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sources = 1
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // there is nothing to verify here..
+ }
+
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g1 (e1, e2) values(100, '100')");
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 = 100");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePreparedUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g1 (e1, e2) values(?, ?)", new Object[] {new Integer(102), "102"});
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 = 102");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceMultipleCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+
+ execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+
+ for (int i = 100; i < 110; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 >= 100");
+ test.assertRowCount(10);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = 1, Select
+ * Batching = Partial Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePartialProcessing() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 where pm1.g1.e1 < 100 limit 10");
+ assertRowCount(10);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // Multiple Sources - Rows from 500
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.g1 where vm.g1.pm1e1 < 100");
+ assertRowCount(100);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(500, '500', 500, '500')");
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e2 = '500'");
+ test.assertRowCount(1);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e2 = '500'");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceSelectInto() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(501, '501', 501, '501')");
+ execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 = 501");
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e2 = '501'");
+ test.assertRowCount(1);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e2 = '501'");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceBulkRowInsert() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ for (int i = 100; i < 112; i++) {
+ Integer val = new Integer(i);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ }
+ execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 112");
+ test.assertRowCount(12);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 112");
+ test.assertRowCount(12);
+ test.execute("select * from g2 where e1 >= 100 and e1 < 112");
+ test.assertRowCount(12);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourcePreparedUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ Integer value = new Integer(500);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {value, value.toString(), value, value.toString()});
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 = 500");
+ test.assertRowCount(1);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 = 500");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceMultipleCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g2 where e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm1.g1 where e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm2.g2 where e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm2.g1 where e1 >= ?", new Object[] {new Integer(100)});
+
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+
+ for (int i = 100; i < 115; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+
+ execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ execute("update pm1.g1 set e2='blah' where e1 > 100");
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1")) {
+ protected boolean compareCaseSensitive() {
+ return false;
+ }
+ };
+ test.execute("select * from g1 where e1 >= 100 and e1 < 115");
+ test.assertRowCount(15);
+ test.execute("select * from g2 where e1 >= 100 and e1 < 115");
+ test.assertRowCount(15);
+ test.execute("select distinct e2 from g1 where e1 > 100");
+
+ // NOTE: if this is an oracle source, it failes because it return varchar2
+ test.assertResultsSetEquals(new String[] {"e2[varchar]", "blah"});
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceMultipleVirtualCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+
+ for (int i = 200; i < 207; i++) {
+ Integer val = new Integer(i);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ execute("insert into vm.g2 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ }
+
+ execute("update vm.g1 set pm1e2='blah' where pm1e1 >= 200");
+
+ execute("delete from vm.g2 where vm.g2.pm1e1 >= 205");
+ execute("delete from vm.g1 where vm.g1.pm1e1 >= 205");
+
+ execute("select * from vm.g1 where pm1e1 >= 200 and pm1e1 < 207");
+ assertRowCount(5);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1")){
+ protected boolean compareCaseSensitive() {
+ return false;
+ }
+ };
+ test.execute("select * from g1 where e1 >= 200 and e1 < 207");
+ test.assertRowCount(5);
+ test.execute("select * from g2 where e1 >= 200 and e1 < 207");
+ test.assertRowCount(5);
+ test.execute("select distinct e2 from g1 where e1 >= 200 and e1 < 207");
+ test.assertResultsSetEquals(new String[] {"e2[varchar2]", "blah"});
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testMultipleSourceMultipleCommandsCancel() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+
+ public void testCase() throws Exception {
+ Thread t = new Thread("Cancel Thread") {
+ public void run() {
+ try {
+ try {
+ Thread.sleep(500);
+ cancelQuery();
+ } catch (SQLException e) {
+ // debug(e.getMessage());
+ }
+ } catch (InterruptedException e) {}
+ }
+ };
+ t.start();
+ executeBatch(getMultipleSourceBatch());
+ }
+
+ /**
+ * @see com.metamatrix.transaction.test.framework.AbstractQueryTest#exceptionExpected()
+ */
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results (this may finish under one second, then this test is not valid)
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 600 and e1 < 650");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 600 and e1 < 650");
+ test.assertRowCount(0);
+ test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 650");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testMultipleSourceTimeout() throws Exception{
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ executeBatch(getMultipleSourceBatch(), 1); // time out after 1 sec
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed with time out exception");
+ }
+ else {
+ assertTrue(getLastException().getMessage().indexOf("Operation timed out before completion") != -1);
+ }
+ }
+ };
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results (this may finish under one second, then this test is not valid)
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 600 and e1 < 750");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 600 and e1 < 750");
+ test.assertRowCount(0);
+ test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 750");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+
+ static String[] getMultipleSourceBatch() {
+ ArrayList list = new ArrayList();
+
+ for (int i = 600; i < 750; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values ("+i+",'"+i+"')");
+ list.add("insert into pm2.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm2.g2 (e1, e2) values ("+i+",'"+i+"')");
+ }
+
+ list.add("update pm1.g1 set e2='blah' where pm1.g1.e1 >= 600");
+ list.add("update pm2.g1 set e2='blah' where pm2.g1.e1 >= 600");
+
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 610");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 610");
+ list.add("delete from pm2.g2 where pm2.g2.e1 >= 610");
+ list.add("delete from pm2.g1 where pm2.g1.e1 >= 610");
+
+ return(String[])list.toArray(new String[list.size()]);
+ }
+
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Partial Processing, Single Connector Batch
+ * result = commit
+ * Note: This is producing the below error some times; however this is SQL Server issue.
+ * http://support.microsoft.com/?kbid=834849
+ */
+ public void testMultipleSourcePartialProcessingUsingLimit() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.g1 where pm1e1 < 100 limit 10");
+ assertRowCount(10);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Partial Processing, Single Connector Batch
+ * result = commit
+ * Note: This is producing the below error some times; however this is SQL Server issue.
+ * http://support.microsoft.com/?kbid=834849
+ */
+ public void testMultipleSourcePartialProcessingUsingMakedep() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select pm1.g1.e1, pm1.g1.e2 from pm1.g1 LEFT OUTER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e2 = pm2.g1.e2 where pm2.g1.e1 >= 50 and pm2.g1.e1 < 100");
+ assertRowCount(50);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+
+
+
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/CommonTransactionTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionTests.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionTests.java 2009-11-19 18:58:25 UTC (rev 1574)
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.LocalTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+
+/**
+ * User Transaction Test is where user handles all the transaction boundaries
+ * so, autocmmit = OFF, and No transaction auto wrapping.
+ */
+public class LocalTransactionTests extends CommonTransactionTests {
+
+
+ public LocalTransactionTests(String testName) {
+ super(testName);
+ }
+
+
+ @Override
+ protected TransactionContainer getTransactionContainter() {
+ // TODO Auto-generated method stub
+ return new LocalTransaction();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testSingleSourceMultipleCommandsExplicitRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ for (int i = 200; i < 220; i++) {
+ execute("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ execute("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+ }
+
+ public boolean rollbackAllways() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 220");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 200 and e1 < 220");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ for (int i = 200; i < 220; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ // force the rollback by trying to insert an invalid row.
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 220");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testMultipleSourceMultipleCommandsExplicitRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+
+ for (int i = 700; i < 720; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+
+ execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+ }
+
+ // force the rollback
+ public boolean rollbackAllways() {
+ return true;
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+ test.assertRowCount(0);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testMultipleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+
+ for (int i = 700; i < 720; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+
+ execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ // force the rollback by trying to insert an invalid row.
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+ test.assertRowCount(0);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 700 and e1 < 720");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceBulkRowInsertRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ for (int i = 100; i < 120; i++) {
+ Integer val = new Integer(i);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ }
+ execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
+
+ // force the rollback by trying to insert an invalid row.
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(0);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceMultipleVirtualCommandsRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+
+ for (int i = 600; i < 615; i++) {
+ Integer val = new Integer(i);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ execute("insert into vm.g2 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {val, val.toString(), val, val.toString()});
+ }
+
+ execute("update vm.g1 set pm1e2='blah' where pm1e1 >= 605");
+
+ execute("delete from vm.g2 where vm.g2.pm1e1 >= 610");
+ execute("delete from vm.g1 where vm.g1.pm1e1 >= 610");
+
+ execute("select * from vm.g1 where pm1e1 >= 600 and pm1e1 < 615");
+ assertRowCount(10);
+
+ // force the rollback by trying to insert an invalid row.
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 600 and e1 < 615");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 600 and e1 < 615");
+ test.assertRowCount(0);
+ test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 615");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/LocalTransactionTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OnWrapTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OnWrapTransactionTests.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OnWrapTransactionTests.java 2009-11-19 18:58:25 UTC (rev 1574)
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.OnWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+
+public class OnWrapTransactionTests extends CommonTransactionTests {
+
+ public OnWrapTransactionTests(String testName) {
+ super(testName);
+ }
+
+
+ @Override
+ protected TransactionContainer getTransactionContainter() {
+ // TODO Auto-generated method stub
+ return new OnWrapTransaction();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ for (int i = 200; i < 210; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ // try to rollback, however since this autocommit=on above two are already commited
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 210");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testSingleSourceBatchCommandReferentialIntegrityRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ for (int i = 200; i < 210; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ }
+
+ // try to rollback, since we are in single batch it must rollback
+ list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 210");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceBulkRowInsertRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ ArrayList list = new ArrayList();
+ public void testCase() throws Exception {
+ for (int i = 100; i < 110; i++) {
+ list.add("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values("+i+",'"+i+"',"+i+",'"+i+"')");
+ }
+ list.add("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
+
+ // force the rollback by trying to insert an invalid row.
+ list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
+
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 110");
+ test.assertRowCount(0);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 110");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 100 and e1 < 110");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OnWrapTransactionTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java 2009-11-19 18:58:25 UTC (rev 1574)
@@ -0,0 +1,491 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.OptimisticWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+/**
+ * The main thing to test in this is, when the single source should is involved it should work
+ * fine, when multiple sources involved it should fail.
+ */
+public class OptimisticWrapTransactionTests extends BaseAbstractTransactionTestCase {
+
+ public OptimisticWrapTransactionTests(String testName) {
+ super(testName);
+ }
+
+ protected TransactionContainer getTransactionContainter() {
+ return new OptimisticWrapTransaction();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // Single Source - Rows below 500 (for insert/update/delete)
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sources = 1
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePreparedUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g1 (e1, e2) values(?, ?)", new Object[] {new Integer(102), "102"});
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 = 102");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceMultipleCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+ for (int i = 100; i < 120; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(20);
+ test.execute("select * from g2 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(20);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceBatchCommand() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ for (int i = 200; i < 205; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 205");
+ test.assertRowCount(5);
+ test.execute("select * from g2 where e1 >= 200 and e1 < 205");
+ test.assertRowCount(5);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePreparedUpdateRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceMultipleCommandsRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new Object[] {new Integer(100)});
+ execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new Object[] {new Integer(100)});
+
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+
+ for (int i = 300; i < 310; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ // this will make it rollback
+ execute("insert into pm1.g2 (e1, e2) values(?, ?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results (since they are not bundled in single command they should be treated individually)
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 300 and e1 < 310");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 >= 300 and e1 < 310");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceBatchCommandRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ for (int i = 400; i < 410; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+
+ // this will make it rollback
+ list.add("insert into pm1.g2 (e1, e2) values(9999, '9999')");
+
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results (all commands will trated as single under single transaction)
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 400 and e1 < 410");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 400 and e1 < 410");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+ // Multiple Sources - Rows from 500
+ ///////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1 where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+
+ public void after() {
+ // selects are special case as they will not fail to use multiple sources. The transaction
+ // source count only starts when there are updates to db, so this is OK
+ if (exceptionOccurred()) {
+ fail("should not have failed to involve multiple sources under optimistic txn");
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ Integer value = new Integer(500);
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] {value, value.toString(), value, value.toString()});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourcesBatchCommand() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ list.add("delete from pm2.g2 where pm2.g2.e1 >= 100");
+ list.add("delete from pm2.g1 where pm2.g1.e1 >= 100");
+
+ for (int i = 200; i < 210; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2) values("+i+",'"+i+"')");
+ }
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.g1");
+ }
+
+ public void after() {
+ if (exceptionOccurred()) {
+ fail("should not have failed to involve multiple sources under optimistic txn");
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualProceduralSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.p1");
+ }
+
+ public void after() {
+ if (exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualProcedure() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.p2 where vm.p2.e1 = ? and vm.p2.e2 = ?", new Object[] {new Integer(200), "200"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ public void testMultipleSourceVirtualProceduralSelectWithUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("exec vm.p2(?, ?)", new Object[] {new Integer(200), "200"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from vm.g1 where vm.g1.pm1e1 > 100");
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(), getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java (rev 0)
+++ trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java 2009-11-19 18:58:25 UTC (rev 1574)
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.PessimisticWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+public class PessimisticWrapTransactionTests extends CommonTransactionTests {
+
+ public PessimisticWrapTransactionTests(String testName) {
+ super(testName);
+ }
+
+ protected TransactionContainer getTransactionContainter() {
+ return new PessimisticWrapTransaction();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ for (int i = 200; i < 210; i++) {
+ Integer val = new Integer(i);
+ execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
+ }
+
+ // try to rollback, however since this pessimistic above two are already commited
+ execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] {new Integer(9999), "9999"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 210");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testSingleSourceBatchCommandReferentialIntegrityRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ for (int i = 200; i < 210; i++) {
+ list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
+ }
+
+ // try to rollback, since we are in single batch it must rollback
+ list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 200 and e1 < 210");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceBulkRowInsertRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ ArrayList list = new ArrayList();
+ public void testCase() throws Exception {
+ for (int i = 100; i < 120; i++) {
+ list.add("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values("+i+",'"+i+"',"+i+",'"+i+"')");
+ }
+ list.add("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
+
+ // force the rollback by trying to insert an invalid row.
+ list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
+
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(0);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+}
Property changes on: trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
15 years, 1 month
teiid SVN: r1573 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: connection and 3 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-19 13:52:49 -0500 (Thu, 19 Nov 2009)
New Revision: 1573
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
Log:
Teiid 773 - refactored back in the way jbedsp transaction classes where defined
Added: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java (rev 0)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java 2009-11-19 18:52:49 UTC (rev 1573)
@@ -0,0 +1,207 @@
+package org.teiid.test.framework;
+
+import java.sql.Connection;
+import java.util.Properties;
+
+import javax.sql.XAConnection;
+
+import org.teiid.test.framework.connection.ConnectionStrategy;
+import org.teiid.test.framework.exception.QueryTestFailedException;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+/**
+ * The TransactionQueryTest interface represents the transaction test lifecycle of execution
+ * from which the @link TransactionContainer operates.
+ * <br><br>
+ * QueryTest lifecycle:</br>
+ *
+ * <br>
+ * There are 4 phases or groupings of methods:
+ * <li>Setup </li>
+ * <li>Test </li>
+ * <li>Validation</li>
+ * <li>Cleanup</li>
+ *
+ * <br>
+ * <p>
+ * <b>1. Setup phase is about setting the global environment for the testing</b>
+ * <br>
+ *
+ * <li>{@link #setConnectionStrategy(ConnectionStrategy)} - called first to provide
+ * the environment (i.e, type of connection, parameters, etc) that the test will
+ * be run under.
+ * <li>{@link #hasRequiredDataSources()} - called after the connection
+ * strategy is set so the determination can be made if this test has the
+ * required datasources defined and available in order to run the test. If not,
+ * then the test is bypassed.
+ * <li>{@link #setup()} - called to enable the test to
+ * perform any pretest (i.e., global) setup. Example would be data source setup.
+ * <li>{@link #setConnection(Connection)} - called to set the client driver (i.e.,
+ * Teiid) connection that will be used to execute queries against
+ * <li>{@link #setExecutionProperties(Properties)} - called at this time so that the
+ * overriding class can obtain / initialize settings that will be assigned when
+ * <li>{@link AbstractQueryTest#assignExecutionProperties(Statement)} is called
+ * prior to sql execution. (Example: set fetch size, batch time, or timeout)
+ * </li>
+ * <br>
+ * <p>
+ * <b>2. Test phase are the methods for executing a test, including any
+ * before/after test logic to support the test</b>
+ * <br><br>
+ *
+ * <li>{@link #before()} called before the execution of the test so that the
+ * transaction boundary can be set and any other pretest conditions
+ * <li>{@link #testCase()} called to execute the specific test
+ * <li>{@link #after()} called after the test is executed, which will commit/rollback the transaction
+ * and perform any other post conditions
+ * </li>
+ * <br>
+ * <p>
+ * <b>3. Validation phase is meant to enable data validation post transaction
+ * completion. This is especially helpful when performing XA transactions
+ * because the results are not completed and available until after the {@link #after()} step
+ * is performed.</b>
+ * <br><br>
+ *
+ * {@link #validateTestCase()}
+ *
+ * <p>
+ * <b>4. Cleanup</b>
+ * <br><br>
+ *
+ * {@link #cleanup()} Called to allow the testcase to perform any cleanup after execution.
+ *
+ * <br>
+ * ================
+ * <p>
+ * <b>Other Notes:</b>
+ * <br><br>
+ *
+ * The following methods were exposed from {@link AbstractQueryTest}:
+ *
+ * <li>{@link #exceptionExpected()} - when an exception is expected to occur, the
+ * underlying logic will treat the execution as if it succeeded. </li>
+ * <li>{@link #exceptionOccurred()} - this method indicates when an exception
+ * actually occurred outside of the normal expected results. </li>
+ * <li>{@link #getConnection()} and {@link #getXAConnection()} - these connection
+ * methods are exposed for {@link #before()} and {@link #after()} methods</li>
+ * <li>{@link #rollbackAllways()} - this is exposed for the {@link #after()} method
+ * as to what behavior is expected after the execution of the test</li>
+ *
+ *
+ * <br>
+ * @author vanhalbert
+ *
+ */
+
+public interface TransactionQueryTestCase {
+
+ /**
+ * Returns the name of the test so that better tracing of what tests are
+ * running/completing.
+ *
+ * @return String is test name
+ */
+ String getTestName();
+
+ /**
+ * Called to set the current connection strategy being used.
+ *
+ * @param connStrategy
+ *
+ * @since
+ */
+ void setConnectionStrategy(ConnectionStrategy connStrategy) throws QueryTestFailedException;
+
+ /**
+ * Called by the {@link TransactionContainer} prior to testcase processing
+ * so that the responsibility for performing an setup duties (ie..,
+ * datasource setup) can be done
+ *
+ *
+ * @since
+ */
+ void setup() throws QueryTestFailedException;
+
+ /**
+ * Called by the @link TransactionContainer to set the Teiid connection to
+ * be used in the test.
+ *
+ * @param conn
+ *
+ * @since
+ */
+ void setConnection(Connection conn);
+
+ /**
+ * Called to set the properties used to initialize prior to execution.
+ *
+ * @param props
+ *
+ * @since
+ */
+// void setExecutionProperties(Properties props);
+
+ /**
+ * Override <code>before</code> if there is behavior that needs to be
+ * performed prior to {@link #testCase()} being called.
+ *
+ *
+ * @since
+ */
+ void before();
+
+ /**
+ * Implement testCase(), it is the entry point to the execution of the test.
+ *
+ * @throws Exception
+ *
+ * @since
+ */
+ void testCase() throws Exception;
+
+ /**
+ * Override <code>after</code> if there is behavior that needs to be
+ * performed after {@link #testCase()} being called.
+ *
+ *
+ * @since
+ */
+ void after();
+
+ /**
+ * Indicates what should be done when a failure occurs in
+ * {@link #testCase()}
+ *
+ * @return
+ *
+ * @since
+ */
+ boolean rollbackAllways();
+
+ /**
+ * Called at the end of the test so that the testcase can clean itself up by
+ * releasing any resources, closing any open connections, etc.
+ *
+ *
+ * @since
+ */
+ void cleanup();
+
+ /**
+ * Returns the connection being used in the test.
+ *
+ * @return
+ *
+ * @since
+ */
+ Connection getConnection();
+
+ XAConnection getXAConnection();
+
+ boolean exceptionExpected();
+
+ boolean exceptionOccurred();
+
+}
Property changes on: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionQueryTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-11-18 20:11:21 UTC (rev 1572)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-11-19 18:52:49 UTC (rev 1573)
@@ -26,6 +26,7 @@
import org.teiid.test.framework.exception.TransactionRuntimeException;
import com.metamatrix.common.util.PropertiesUtils;
+import com.metamatrix.jdbc.util.MMJDBCURL;
public abstract class ConnectionStrategy {
@@ -54,8 +55,12 @@
/**
* @since
*/
- public void shutdown() {
- this.dsFactory.cleanup();
+ public void shutdown() {
+ try {
+ this.dsFactory.cleanup();
+ } catch (Throwable t) {
+
+ }
}
public Connection getAdminConnection() throws QueryTestFailedException{
@@ -121,19 +126,19 @@
setupVDBConnectorBindings(admin);
- admin.restart();
+ // admin.restart();
+
int sleep = 5;
System.out.println("Bouncing the system..(wait " + sleep + " seconds)"); //$NON-NLS-1$
Thread.sleep(1000*sleep);
- // Thread.sleep(1000*60);
System.out.println("done."); //$NON-NLS-1$
- } catch (Exception e) {
+ } catch (Throwable e) {
e.printStackTrace();
- throw new TransactionRuntimeException(e);
+ throw new TransactionRuntimeException(e.getMessage());
} finally {
// need to close and flush the connection after restarting
this.shutdown();
@@ -144,15 +149,33 @@
protected void setupVDBConnectorBindings(Admin api) throws QueryTestFailedException {
try {
-
+
+ VDB vdb = null;
Collection<VDB> vdbs = api.getVDBs("*");
if (vdbs == null) {
throw new QueryTestFailedException("GetVDBS returned no vdbs available");
- } else if (vdbs.size() != 1) {
- throw new QueryTestFailedException("GetVDBS returned more than 1 vdb available");
+ } else if (vdbs.size() > 0) {
+ String urlString = this.env.getProperty(DriverConnection.DS_URL);
+ MMJDBCURL url = new MMJDBCURL(urlString);
+ System.out.println("Trying to match VDB : " + url.getVDBName());
+
+ for (Iterator iterator = vdbs.iterator(); iterator
+ .hasNext();) {
+ VDB v = (VDB) iterator.next();
+ if (v.getName().equalsIgnoreCase(url.getVDBName())) {
+ vdb = v;
+ }
+
+ }
+ if (vdbs == null) {
+ throw new QueryTestFailedException("GetVDBS did not return a vdb that matched " + url.getVDBName());
+ }
+
+ } else {
+ vdb = (VDB) vdbs.iterator().next();
}
- VDB vdb = (VDB) vdbs.iterator().next();
+
Iterator<Model> modelIt = vdb.getModels().iterator();
while (modelIt.hasNext() ) {
Model m = modelIt.next();
@@ -180,6 +203,8 @@
api.assignBindingToModel(ds.getName(), vdb.getName(), vdb.getVDBVersion(), m.getName());
+
+ api.startConnectorBinding(ds.getName());
} else {
throw new QueryTestFailedException("Error: Unable to create binding to map to model : " + m.getName() + ", the mapped name " + useName + " had no datasource properties defined");
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java 2009-11-18 20:11:21 UTC (rev 1572)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataStore.java 2009-11-19 18:52:49 UTC (rev 1573)
@@ -99,8 +99,8 @@
private static void setUpTest(Connection c) throws Exception {
Statement stmt = c.createStatement();
- stmt.addBatch("delete from g2 where e1 > 50"); //$NON-NLS-1$
- stmt.addBatch("delete from g1 where e1 > 100");
+ stmt.addBatch("delete from g2 where e1 >= 50"); //$NON-NLS-1$
+ stmt.addBatch("delete from g1 where e1 >= 100");
stmt.executeBatch();
stmt.close();
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-11-18 20:11:21 UTC (rev 1572)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-11-19 18:52:49 UTC (rev 1573)
@@ -45,7 +45,7 @@
public abstract class AbstractQueryTransactionTest extends com.metamatrix.jdbc.api.AbstractQueryTest
implements TransactionQueryTestCase {
- private static boolean initialized = false;
+ private static String initialized = null;
protected String testname = "NA";
protected int fetchSize = -1;
@@ -138,10 +138,8 @@
}
- public boolean compareResultsCaseSensitive() {
- return true;
- }
+
/**
* Override <code>setupDataSource</code> if there is different mechanism for
* setting up the datasources for the testcase
@@ -154,8 +152,8 @@
@Override
public void setup() throws QueryTestFailedException {
- if (!initialized) {
- initialized = true;
+ if (initialized == null || !initialized.equalsIgnoreCase(this.getClass().getSimpleName()) ) {
+ initialized = this.getClass().getSimpleName();
DataStore.initialize(connStrategy);
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java 2009-11-18 20:11:21 UTC (rev 1572)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java 2009-11-19 18:52:49 UTC (rev 1573)
@@ -4,7 +4,6 @@
*/
package org.teiid.test.framework.transaction;
-import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java 2009-11-18 20:11:21 UTC (rev 1572)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java 2009-11-19 18:52:49 UTC (rev 1573)
@@ -4,7 +4,6 @@
*/
package org.teiid.test.framework.transaction;
-import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java 2009-11-18 20:11:21 UTC (rev 1572)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java 2009-11-19 18:52:49 UTC (rev 1573)
@@ -4,7 +4,6 @@
*/
package org.teiid.test.framework.transaction;
-import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java 2009-11-18 20:11:21 UTC (rev 1572)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java 2009-11-19 18:52:49 UTC (rev 1573)
@@ -4,7 +4,6 @@
*/
package org.teiid.test.framework.transaction;
-import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
15 years, 1 month
teiid SVN: r1572 - trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-18 15:11:21 -0500 (Wed, 18 Nov 2009)
New Revision: 1572
Modified:
trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java
Log:
Teiid 773 - added ability to override to indicate to perform comparison in either case sensitive or non-sensitive
Modified: trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java
===================================================================
--- trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java 2009-11-18 15:26:22 UTC (rev 1571)
+++ trunk/client-jdbc/src/test/java/com/metamatrix/jdbc/api/AbstractQueryTest.java 2009-11-18 20:11:21 UTC (rev 1572)
@@ -388,9 +388,13 @@
}
protected void compareResults(BufferedReader resultReader, BufferedReader expectedReader) throws IOException {
- assertEquals(read(expectedReader, true) , read(resultReader, true));
+ assertEquals(read(expectedReader, compareCaseSensitive()) , read(resultReader, compareCaseSensitive()));
}
+ protected boolean compareCaseSensitive() {
+ return true;
+ }
+
public void printResults() {
printResults(this.internalResultSet);
}
15 years, 1 month
teiid SVN: r1571 - in trunk: connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc and 13 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2009-11-18 10:26:22 -0500 (Wed, 18 Nov 2009)
New Revision: 1571
Added:
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/SchemaObject.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java
Removed:
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSetRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKeyRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameterRecordImpl.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java
trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCMetdataProcessor.java
trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java
trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java
trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml
trunk/documentation/reference/src/main/docbook/en-US/content/procedures.xml
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml
trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java
trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeMetadataService.java
trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java
Log:
TEIID-869 TEIID-883 intermediate cleanup of metadata removing parsing logic that supported modelerid and / in identifiers
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -77,11 +77,6 @@
this.name = name;
}
- public String getModelName() {
- int prntIdx = fullName.indexOf(NAME_DELIM_CHAR);
- return fullName.substring(0, prntIdx);
- }
-
public String toString() {
StringBuffer sb = new StringBuffer(100);
sb.append(getClass().getSimpleName());
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -44,7 +44,7 @@
private int precision;
private NullType nullType;
private int position;
- private DatatypeRecordImpl datatype;
+ private Datatype datatype;
public String getDefaultValue() {
return defaultValue;
@@ -121,11 +121,11 @@
defaultValue = object;
}
- public DatatypeRecordImpl getDatatype() {
+ public Datatype getDatatype() {
return datatype;
}
- public void setDatatype(DatatypeRecordImpl datatype) {
+ public void setDatatype(Datatype datatype) {
this.datatype = datatype;
}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java (from rev 1550, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -0,0 +1,240 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.metadata.runtime;
+
+
+/**
+ * ColumnRecordImpl
+ */
+public class Column extends BaseColumn implements Comparable<Column> {
+
+ public enum SearchType {
+ Unsearchable,
+ Like_Only {
+ @Override
+ public String toString() {
+ return "Like Only"; //$NON-NLS-1$
+ }
+ },
+ All_Except_Like {
+ @Override
+ public String toString() {
+ return "All Except Like"; //$NON-NLS-1$
+ }
+ },
+ Searchable
+ }
+
+ private boolean selectable = true;
+ private boolean updatable;
+ private boolean autoIncrementable;
+ private boolean caseSensitive;
+ private boolean signed;
+ private boolean currency;
+ private boolean fixedLength;
+ private SearchType searchType;
+ private String minValue;
+ private String maxValue;
+ private String nativeType;
+ private String format;
+ private int charOctetLength;
+ private int distinctValues = -1;
+ private int nullValues = -1;
+
+ @Override
+ public int compareTo(Column record) {
+ return this.getPosition() - record.getPosition();
+ }
+
+ public int getCharOctetLength() {
+ return charOctetLength;
+ }
+
+ public String getMaxValue() {
+ return maxValue;
+ }
+
+ public String getMinValue() {
+ return minValue;
+ }
+
+ public SearchType getSearchType() {
+ if (searchType == null) {
+ return this.getDatatype().getSearchType();
+ }
+ return searchType;
+ }
+
+ public String getFormat() {
+ return format;
+ }
+
+ public boolean isAutoIncrementable() {
+ return autoIncrementable;
+ }
+
+ public boolean isCaseSensitive() {
+ return caseSensitive;
+ }
+
+ public boolean isCurrency() {
+ return currency;
+ }
+
+ public boolean isFixedLength() {
+ return fixedLength;
+ }
+
+ public boolean isSelectable() {
+ return selectable;
+ }
+
+ public boolean isSigned() {
+ return signed;
+ }
+
+ public boolean isUpdatable() {
+ return updatable;
+ }
+
+ public String getNativeType() {
+ return nativeType;
+ }
+
+ public int getDistinctValues() {
+ return this.distinctValues;
+ }
+
+ public int getNullValues() {
+ return this.nullValues;
+ }
+
+ /**
+ * @param b
+ */
+ public void setAutoIncrementable(boolean b) {
+ autoIncrementable = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setCaseSensitive(boolean b) {
+ caseSensitive = b;
+ }
+
+ /**
+ * @param i
+ */
+ public void setCharOctetLength(int i) {
+ charOctetLength = i;
+ }
+
+ /**
+ * @param b
+ */
+ public void setCurrency(boolean b) {
+ currency = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setFixedLength(boolean b) {
+ fixedLength = b;
+ }
+
+ /**
+ * @param object
+ */
+ public void setMaxValue(String object) {
+ maxValue = object;
+ }
+
+ /**
+ * @param object
+ */
+ public void setMinValue(String object) {
+ minValue = object;
+ }
+
+ /**
+ * @param s
+ */
+ public void setSearchType(SearchType s) {
+ searchType = s;
+ }
+
+ /**
+ * @param b
+ */
+ public void setSelectable(boolean b) {
+ selectable = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setSigned(boolean b) {
+ signed = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setUpdatable(boolean b) {
+ updatable = b;
+ }
+
+ /**
+ * @param string
+ */
+ public void setFormat(String string) {
+ format = string;
+ }
+
+ /**
+ * @param distinctValues The distinctValues to set.
+ * @since 4.3
+ */
+ public void setDistinctValues(int distinctValues) {
+ this.distinctValues = distinctValues;
+ }
+
+ /**
+ * @param nullValues The nullValues to set.
+ * @since 4.3
+ */
+ public void setNullValues(int nullValues) {
+ this.nullValues = nullValues;
+ }
+
+ /**
+ * @param nativeType The nativeType to set.
+ * @since 4.2
+ */
+ public void setNativeType(String nativeType) {
+ this.nativeType = nativeType;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnRecordImpl.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -1,240 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-
-/**
- * ColumnRecordImpl
- */
-public class ColumnRecordImpl extends BaseColumn implements Comparable<ColumnRecordImpl> {
-
- public enum SearchType {
- Unsearchable,
- Like_Only {
- @Override
- public String toString() {
- return "Like Only"; //$NON-NLS-1$
- }
- },
- All_Except_Like {
- @Override
- public String toString() {
- return "All Except Like"; //$NON-NLS-1$
- }
- },
- Searchable
- }
-
- private boolean selectable = true;
- private boolean updatable;
- private boolean autoIncrementable;
- private boolean caseSensitive;
- private boolean signed;
- private boolean currency;
- private boolean fixedLength;
- private SearchType searchType;
- private String minValue;
- private String maxValue;
- private String nativeType;
- private String format;
- private int charOctetLength;
- private int distinctValues = -1;
- private int nullValues = -1;
-
- @Override
- public int compareTo(ColumnRecordImpl record) {
- return this.getPosition() - record.getPosition();
- }
-
- public int getCharOctetLength() {
- return charOctetLength;
- }
-
- public String getMaxValue() {
- return maxValue;
- }
-
- public String getMinValue() {
- return minValue;
- }
-
- public SearchType getSearchType() {
- if (searchType == null) {
- return this.getDatatype().getSearchType();
- }
- return searchType;
- }
-
- public String getFormat() {
- return format;
- }
-
- public boolean isAutoIncrementable() {
- return autoIncrementable;
- }
-
- public boolean isCaseSensitive() {
- return caseSensitive;
- }
-
- public boolean isCurrency() {
- return currency;
- }
-
- public boolean isFixedLength() {
- return fixedLength;
- }
-
- public boolean isSelectable() {
- return selectable;
- }
-
- public boolean isSigned() {
- return signed;
- }
-
- public boolean isUpdatable() {
- return updatable;
- }
-
- public String getNativeType() {
- return nativeType;
- }
-
- public int getDistinctValues() {
- return this.distinctValues;
- }
-
- public int getNullValues() {
- return this.nullValues;
- }
-
- /**
- * @param b
- */
- public void setAutoIncrementable(boolean b) {
- autoIncrementable = b;
- }
-
- /**
- * @param b
- */
- public void setCaseSensitive(boolean b) {
- caseSensitive = b;
- }
-
- /**
- * @param i
- */
- public void setCharOctetLength(int i) {
- charOctetLength = i;
- }
-
- /**
- * @param b
- */
- public void setCurrency(boolean b) {
- currency = b;
- }
-
- /**
- * @param b
- */
- public void setFixedLength(boolean b) {
- fixedLength = b;
- }
-
- /**
- * @param object
- */
- public void setMaxValue(String object) {
- maxValue = object;
- }
-
- /**
- * @param object
- */
- public void setMinValue(String object) {
- minValue = object;
- }
-
- /**
- * @param s
- */
- public void setSearchType(SearchType s) {
- searchType = s;
- }
-
- /**
- * @param b
- */
- public void setSelectable(boolean b) {
- selectable = b;
- }
-
- /**
- * @param b
- */
- public void setSigned(boolean b) {
- signed = b;
- }
-
- /**
- * @param b
- */
- public void setUpdatable(boolean b) {
- updatable = b;
- }
-
- /**
- * @param string
- */
- public void setFormat(String string) {
- format = string;
- }
-
- /**
- * @param distinctValues The distinctValues to set.
- * @since 4.3
- */
- public void setDistinctValues(int distinctValues) {
- this.distinctValues = distinctValues;
- }
-
- /**
- * @param nullValues The nullValues to set.
- * @since 4.3
- */
- public void setNullValues(int nullValues) {
- this.nullValues = nullValues;
- }
-
- /**
- * @param nativeType The nativeType to set.
- * @since 4.2
- */
- public void setNativeType(String nativeType) {
- this.nativeType = nativeType;
- }
-
-}
\ No newline at end of file
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java (from rev 1545, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSetRecordImpl.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.metadata.runtime;
+
+import java.util.List;
+
+/**
+ * ColumnSetRecordImpl
+ */
+public class ColumnSet extends AbstractMetadataRecord {
+
+ private List<Column> columns;
+
+ public List<Column> getColumns() {
+ return columns;
+ }
+
+ public void setColumns(List<Column> columns) {
+ this.columns = columns;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSetRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSetRecordImpl.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSetRecordImpl.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -1,42 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.util.List;
-
-/**
- * ColumnSetRecordImpl
- */
-public class ColumnSetRecordImpl extends AbstractMetadataRecord {
-
- private List<ColumnRecordImpl> columns;
-
- public List<ColumnRecordImpl> getColumns() {
- return columns;
- }
-
- public void setColumns(List<ColumnRecordImpl> columns) {
- this.columns = columns;
- }
-
-}
\ No newline at end of file
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java (from rev 1550, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -0,0 +1,282 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.metadata.runtime;
+
+import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
+import org.teiid.connector.metadata.runtime.Column.SearchType;
+
+
+
+/**
+ * ColumnRecordImpl
+ */
+public class Datatype extends AbstractMetadataRecord {
+
+ public enum Type {
+ Basic,
+ UserDefined,
+ ResultSet
+ }
+
+ public enum Variety {
+ Atomic,
+ List,
+ Union,
+ Complex
+ }
+
+ /** Delimiter used to separate the URI string from the URI fragment */
+ public static final String URI_REFERENCE_DELIMITER = "#"; //$NON-NLS-1$
+
+ private static final String DEFAULT_JAVA_CLASS_NAME = "java.lang.Object"; //$NON-NLS-1$
+
+ private int length;
+ private int precisionLength;
+ private int scale;
+ private int radix;
+ private boolean isSigned;
+ private boolean isAutoIncrement;
+ private boolean isCaseSensitive;
+ private Type type;
+ private SearchType searchType;
+ private NullType nullType;
+ private String javaClassName = DEFAULT_JAVA_CLASS_NAME;
+ private String runtimeTypeName;
+ private String datatypeID;
+ private String basetypeID;
+ private String primitiveTypeID;
+ private Variety varietyType;
+
+ public int getLength() {
+ return this.length;
+ }
+
+ public int getPrecisionLength() {
+ return this.precisionLength;
+ }
+
+ public int getScale() {
+ return this.scale;
+ }
+
+ public int getRadix() {
+ return this.radix;
+ }
+
+ public boolean isSigned() {
+ return this.isSigned;
+ }
+
+ public boolean isAutoIncrement() {
+ return this.isAutoIncrement;
+ }
+
+ public boolean isCaseSensitive() {
+ return this.isCaseSensitive;
+ }
+
+ public Type getType() {
+ return this.type;
+ }
+
+ public boolean isBuiltin() {
+ return getType() == Type.Basic;
+ }
+
+
+ public SearchType getSearchType() {
+ return this.searchType;
+ }
+
+ public NullType getNullType() {
+ if (this.nullType == null) {
+ return NullType.Unknown;
+ }
+ return this.nullType;
+ }
+
+ public String getJavaClassName() {
+ return this.javaClassName;
+ }
+
+ public String getRuntimeTypeName() {
+ return this.runtimeTypeName;
+ }
+
+ public String getDatatypeID() {
+ return this.datatypeID;
+ }
+
+ public String getBasetypeID() {
+ return this.basetypeID;
+ }
+
+ public String getBasetypeName() {
+ if ( this.basetypeID != null ) {
+ final int i = getBasetypeID().lastIndexOf(URI_REFERENCE_DELIMITER);
+ if ( i != -1 && getBasetypeID().length() > (i+1)) {
+ return getBasetypeID().substring(i+1);
+ }
+ }
+ return null;
+ }
+
+ public String getPrimitiveTypeID() {
+ return this.primitiveTypeID;
+ }
+
+ public Variety getVarietyType() {
+ return this.varietyType;
+ }
+
+ /**
+ * @param string
+ */
+ public void setBasetypeID(String string) {
+ basetypeID = string;
+ }
+
+ /**
+ * @param string
+ */
+ public void setPrimitiveTypeID(String string) {
+ primitiveTypeID = string;
+ }
+
+ /**
+ * @param b
+ */
+ public void setAutoIncrement(boolean b) {
+ isAutoIncrement = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setCaseSensitive(boolean b) {
+ isCaseSensitive = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setSigned(boolean b) {
+ isSigned = b;
+ }
+
+ /**
+ * @param string
+ */
+ public void setJavaClassName(String string) {
+ javaClassName = string;
+ }
+
+ /**
+ * @param i
+ */
+ public void setLength(int i) {
+ length = i;
+ }
+
+ /**
+ * @param s
+ */
+ public void setNullType(NullType s) {
+ nullType = s;
+ }
+
+ /**
+ * @param i
+ */
+ public void setPrecisionLength(int i) {
+ precisionLength = i;
+ }
+
+ /**
+ * @param i
+ */
+ public void setRadix(int i) {
+ radix = i;
+ }
+
+ /**
+ * @param string
+ */
+ public void setRuntimeTypeName(String string) {
+ runtimeTypeName = string;
+ }
+
+ /**
+ * @param i
+ */
+ public void setScale(int i) {
+ scale = i;
+ }
+
+ /**
+ * @param s
+ */
+ public void setSearchType(SearchType s) {
+ searchType = s;
+ }
+
+ /**
+ * @param s
+ */
+ public void setType(Type s) {
+ type = s;
+ }
+
+ /**
+ * @param string
+ */
+ public void setDatatypeID(String string) {
+ datatypeID = string;
+ }
+
+ /**
+ * @param s
+ */
+ public void setVarietyType(Variety s) {
+ varietyType = s;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer(100);
+ sb.append(getClass().getSimpleName());
+ sb.append(" name="); //$NON-NLS-1$
+ sb.append(getName());
+ sb.append(", basetype name="); //$NON-NLS-1$
+ sb.append(getBasetypeName());
+ sb.append(", runtimeType="); //$NON-NLS-1$
+ sb.append(getRuntimeTypeName());
+ sb.append(", javaClassName="); //$NON-NLS-1$
+ sb.append(getJavaClassName());
+ sb.append(", ObjectID="); //$NON-NLS-1$
+ sb.append(getUUID());
+ sb.append(", datatypeID="); //$NON-NLS-1$
+ sb.append(getDatatypeID());
+ return sb.toString();
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/DatatypeRecordImpl.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -1,282 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl.SearchType;
-
-
-
-/**
- * ColumnRecordImpl
- */
-public class DatatypeRecordImpl extends AbstractMetadataRecord {
-
- public enum Type {
- Basic,
- UserDefined,
- ResultSet
- }
-
- public enum Variety {
- Atomic,
- List,
- Union,
- Complex
- }
-
- /** Delimiter used to separate the URI string from the URI fragment */
- public static final String URI_REFERENCE_DELIMITER = "#"; //$NON-NLS-1$
-
- private static final String DEFAULT_JAVA_CLASS_NAME = "java.lang.Object"; //$NON-NLS-1$
-
- private int length;
- private int precisionLength;
- private int scale;
- private int radix;
- private boolean isSigned;
- private boolean isAutoIncrement;
- private boolean isCaseSensitive;
- private Type type;
- private SearchType searchType;
- private NullType nullType;
- private String javaClassName = DEFAULT_JAVA_CLASS_NAME;
- private String runtimeTypeName;
- private String datatypeID;
- private String basetypeID;
- private String primitiveTypeID;
- private Variety varietyType;
-
- public int getLength() {
- return this.length;
- }
-
- public int getPrecisionLength() {
- return this.precisionLength;
- }
-
- public int getScale() {
- return this.scale;
- }
-
- public int getRadix() {
- return this.radix;
- }
-
- public boolean isSigned() {
- return this.isSigned;
- }
-
- public boolean isAutoIncrement() {
- return this.isAutoIncrement;
- }
-
- public boolean isCaseSensitive() {
- return this.isCaseSensitive;
- }
-
- public Type getType() {
- return this.type;
- }
-
- public boolean isBuiltin() {
- return getType() == Type.Basic;
- }
-
-
- public SearchType getSearchType() {
- return this.searchType;
- }
-
- public NullType getNullType() {
- if (this.nullType == null) {
- return NullType.Unknown;
- }
- return this.nullType;
- }
-
- public String getJavaClassName() {
- return this.javaClassName;
- }
-
- public String getRuntimeTypeName() {
- return this.runtimeTypeName;
- }
-
- public String getDatatypeID() {
- return this.datatypeID;
- }
-
- public String getBasetypeID() {
- return this.basetypeID;
- }
-
- public String getBasetypeName() {
- if ( this.basetypeID != null ) {
- final int i = getBasetypeID().lastIndexOf(URI_REFERENCE_DELIMITER);
- if ( i != -1 && getBasetypeID().length() > (i+1)) {
- return getBasetypeID().substring(i+1);
- }
- }
- return null;
- }
-
- public String getPrimitiveTypeID() {
- return this.primitiveTypeID;
- }
-
- public Variety getVarietyType() {
- return this.varietyType;
- }
-
- /**
- * @param string
- */
- public void setBasetypeID(String string) {
- basetypeID = string;
- }
-
- /**
- * @param string
- */
- public void setPrimitiveTypeID(String string) {
- primitiveTypeID = string;
- }
-
- /**
- * @param b
- */
- public void setAutoIncrement(boolean b) {
- isAutoIncrement = b;
- }
-
- /**
- * @param b
- */
- public void setCaseSensitive(boolean b) {
- isCaseSensitive = b;
- }
-
- /**
- * @param b
- */
- public void setSigned(boolean b) {
- isSigned = b;
- }
-
- /**
- * @param string
- */
- public void setJavaClassName(String string) {
- javaClassName = string;
- }
-
- /**
- * @param i
- */
- public void setLength(int i) {
- length = i;
- }
-
- /**
- * @param s
- */
- public void setNullType(NullType s) {
- nullType = s;
- }
-
- /**
- * @param i
- */
- public void setPrecisionLength(int i) {
- precisionLength = i;
- }
-
- /**
- * @param i
- */
- public void setRadix(int i) {
- radix = i;
- }
-
- /**
- * @param string
- */
- public void setRuntimeTypeName(String string) {
- runtimeTypeName = string;
- }
-
- /**
- * @param i
- */
- public void setScale(int i) {
- scale = i;
- }
-
- /**
- * @param s
- */
- public void setSearchType(SearchType s) {
- searchType = s;
- }
-
- /**
- * @param s
- */
- public void setType(Type s) {
- type = s;
- }
-
- /**
- * @param string
- */
- public void setDatatypeID(String string) {
- datatypeID = string;
- }
-
- /**
- * @param s
- */
- public void setVarietyType(Variety s) {
- varietyType = s;
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer(100);
- sb.append(getClass().getSimpleName());
- sb.append(" name="); //$NON-NLS-1$
- sb.append(getName());
- sb.append(", basetype name="); //$NON-NLS-1$
- sb.append(getBasetypeName());
- sb.append(", runtimeType="); //$NON-NLS-1$
- sb.append(getRuntimeTypeName());
- sb.append(", javaClassName="); //$NON-NLS-1$
- sb.append(getJavaClassName());
- sb.append(", ObjectID="); //$NON-NLS-1$
- sb.append(getUUID());
- sb.append(", datatypeID="); //$NON-NLS-1$
- sb.append(getDatatypeID());
- return sb.toString();
- }
-
-}
\ No newline at end of file
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java (from rev 1545, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKeyRecordImpl.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.metadata.runtime;
+
+/**
+ * ForeignKeyRecordImpl
+ */
+public class ForeignKey extends KeyRecord {
+
+ private String uniqueKeyID;
+ private KeyRecord primaryKey;
+
+ public ForeignKey() {
+ super(Type.Foreign);
+ }
+
+ public String getUniqueKeyID() {
+ return uniqueKeyID;
+ }
+
+ /**
+ * @param object
+ */
+ public void setUniqueKeyID(String keyID) {
+ uniqueKeyID = keyID;
+ }
+
+ public KeyRecord getPrimaryKey() {
+ return this.primaryKey;
+ }
+
+ public void setPrimaryKey(KeyRecord primaryKey) {
+ this.primaryKey = primaryKey;
+ }
+}
\ No newline at end of file
Property changes on: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKeyRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKeyRecordImpl.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKeyRecordImpl.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-/**
- * ForeignKeyRecordImpl
- */
-public class ForeignKeyRecordImpl extends KeyRecord {
-
- private String uniqueKeyID;
- private KeyRecord primaryKey;
-
- public ForeignKeyRecordImpl() {
- super(Type.Foreign);
- }
-
- public String getUniqueKeyID() {
- return uniqueKeyID;
- }
-
- /**
- * @param object
- */
- public void setUniqueKeyID(String keyID) {
- uniqueKeyID = keyID;
- }
-
- public KeyRecord getPrimaryKey() {
- return this.primaryKey;
- }
-
- public void setPrimaryKey(KeyRecord primaryKey) {
- this.primaryKey = primaryKey;
- }
-}
\ No newline at end of file
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -22,7 +22,7 @@
package org.teiid.connector.metadata.runtime;
-public class KeyRecord extends ColumnSetRecordImpl {
+public class KeyRecord extends ColumnSet {
public enum Type {
Primary,
@@ -34,7 +34,7 @@
}
private Type type;
- private TableRecordImpl table;
+ private Table table;
public KeyRecord(Type type) {
this.type = type;
@@ -44,11 +44,11 @@
return type;
}
- public TableRecordImpl getTable() {
+ public Table getTable() {
return table;
}
- public void setTable(TableRecordImpl table) {
+ public void setTable(Table table) {
this.table = table;
}
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -33,7 +33,6 @@
import org.teiid.connector.DataPlugin;
import org.teiid.connector.api.ConnectorException;
import org.teiid.connector.api.TypeFacility;
-import org.teiid.connector.metadata.runtime.ModelRecordImpl.Type;
import com.metamatrix.core.id.UUIDFactory;
@@ -45,22 +44,22 @@
*/
public class MetadataFactory {
- private ModelRecordImpl model;
+ private Schema model;
private UUIDFactory factory = new UUIDFactory();
- private Map<String, DatatypeRecordImpl> dataTypes;
+ private Map<String, Datatype> dataTypes;
private Properties importProperties;
private MetadataStore store = new MetadataStore();
private Set<String> uniqueNames = new HashSet<String>();
- public MetadataFactory(String modelName, Map<String, DatatypeRecordImpl> dataTypes, Properties importProperties) {
+ public MetadataFactory(String modelName, Map<String, Datatype> dataTypes, Properties importProperties) {
this.dataTypes = dataTypes;
this.importProperties = importProperties;
- model = new ModelRecordImpl();
+ model = new Schema();
model.setName(modelName);
- model.setModelType(Type.Physical);
+ model.setPhysical(true);
model.setPrimaryMetamodelUri("http://www.metamatrix.com/metamodels/Relational"); //$NON-NLS-1$
setUUID(model);
- store.addModel(model);
+ store.addSchema(model);
}
public MetadataStore getMetadataStore() {
@@ -90,17 +89,17 @@
* @return
* @throws ConnectorException
*/
- public TableRecordImpl addTable(String name) throws ConnectorException {
- TableRecordImpl table = new TableRecordImpl();
- table.setTableType(TableRecordImpl.Type.Table);
+ public Table addTable(String name) throws ConnectorException {
+ Table table = new Table();
+ table.setTableType(Table.Type.Table);
setValuesUsingParent(name, model, table, "table"); //$NON-NLS-1$
- table.setColumns(new LinkedList<ColumnRecordImpl>());
+ table.setColumns(new LinkedList<Column>());
table.setAccessPatterns(new LinkedList<KeyRecord>());
table.setIndexes(new LinkedList<KeyRecord>());
- table.setForiegnKeys(new LinkedList<ForeignKeyRecordImpl>());
+ table.setForiegnKeys(new LinkedList<ForeignKey>());
table.setUniqueKeys(new LinkedList<KeyRecord>());
setUUID(table);
- this.store.addTable(table);
+ this.model.addTable(table);
return table;
}
@@ -112,12 +111,12 @@
* @return
* @throws ConnectorException
*/
- public ColumnRecordImpl addColumn(String name, String type, ColumnSetRecordImpl table) throws ConnectorException {
- ColumnRecordImpl column = new ColumnRecordImpl();
+ public Column addColumn(String name, String type, ColumnSet table) throws ConnectorException {
+ Column column = new Column();
setValuesUsingParent(name, table, column, "column"); //$NON-NLS-1$
table.getColumns().add(column);
column.setPosition(table.getColumns().size()); //1 based indexing
- DatatypeRecordImpl datatype = setColumnType(type, column);
+ Datatype datatype = setColumnType(type, column);
column.setCaseSensitive(datatype.isCaseSensitive());
column.setAutoIncrementable(datatype.isAutoIncrement());
column.setSigned(datatype.isSigned());
@@ -125,9 +124,9 @@
return column;
}
- private DatatypeRecordImpl setColumnType(String type,
+ private Datatype setColumnType(String type,
BaseColumn column) throws ConnectorException {
- DatatypeRecordImpl datatype = dataTypes.get(type);
+ Datatype datatype = dataTypes.get(type);
if (datatype == null) {
throw new ConnectorException(DataPlugin.Util.getString("MetadataFactory.unknown_datatype", type)); //$NON-NLS-1$
}
@@ -148,10 +147,10 @@
* @return
* @throws ConnectorException
*/
- public ColumnSetRecordImpl addPrimaryKey(String name, List<String> columnNames, TableRecordImpl table) throws ConnectorException {
+ public ColumnSet addPrimaryKey(String name, List<String> columnNames, Table table) throws ConnectorException {
KeyRecord primaryKey = new KeyRecord(KeyRecord.Type.Primary);
primaryKey.setTable(table);
- primaryKey.setColumns(new ArrayList<ColumnRecordImpl>(columnNames.size()));
+ primaryKey.setColumns(new ArrayList<Column>(columnNames.size()));
setValuesUsingParent(name, table, primaryKey, "pk"); //$NON-NLS-1$
setUUID(primaryKey);
assignColumns(columnNames, table, primaryKey);
@@ -167,10 +166,10 @@
* @return
* @throws ConnectorException
*/
- public KeyRecord addAccessPattern(String name, List<String> columnNames, TableRecordImpl table) throws ConnectorException {
+ public KeyRecord addAccessPattern(String name, List<String> columnNames, Table table) throws ConnectorException {
KeyRecord ap = new KeyRecord(KeyRecord.Type.AccessPattern);
ap.setTable(table);
- ap.setColumns(new ArrayList<ColumnRecordImpl>(columnNames.size()));
+ ap.setColumns(new ArrayList<Column>(columnNames.size()));
setValuesUsingParent(name, table, ap, "index"); //$NON-NLS-1$
setUUID(ap);
assignColumns(columnNames, table, ap);
@@ -187,10 +186,10 @@
* @return
* @throws ConnectorException
*/
- public KeyRecord addIndex(String name, boolean nonUnique, List<String> columnNames, TableRecordImpl table) throws ConnectorException {
+ public KeyRecord addIndex(String name, boolean nonUnique, List<String> columnNames, Table table) throws ConnectorException {
KeyRecord index = new KeyRecord(nonUnique?KeyRecord.Type.NonUnique:KeyRecord.Type.Index);
index.setTable(table);
- index.setColumns(new ArrayList<ColumnRecordImpl>(columnNames.size()));
+ index.setColumns(new ArrayList<Column>(columnNames.size()));
setValuesUsingParent(name, table, index, "index"); //$NON-NLS-1$
setUUID(index);
assignColumns(columnNames, table, index);
@@ -207,10 +206,10 @@
* @return
* @throws ConnectorException
*/
- public ForeignKeyRecordImpl addForiegnKey(String name, List<String> columnNames, TableRecordImpl pkTable, TableRecordImpl table) throws ConnectorException {
- ForeignKeyRecordImpl foreignKey = new ForeignKeyRecordImpl();
+ public ForeignKey addForiegnKey(String name, List<String> columnNames, Table pkTable, Table table) throws ConnectorException {
+ ForeignKey foreignKey = new ForeignKey();
foreignKey.setTable(table);
- foreignKey.setColumns(new ArrayList<ColumnRecordImpl>(columnNames.size()));
+ foreignKey.setColumns(new ArrayList<Column>(columnNames.size()));
setValuesUsingParent(name, table, foreignKey, "fk"); //$NON-NLS-1$
setUUID(foreignKey);
if (pkTable.getPrimaryKey() == null) {
@@ -233,8 +232,8 @@
ProcedureRecordImpl procedure = new ProcedureRecordImpl();
setValuesUsingParent(name, this.model, procedure, "proc"); //$NON-NLS-1$
setUUID(procedure);
- procedure.setParameters(new LinkedList<ProcedureParameterRecordImpl>());
- this.store.addProcedure(procedure);
+ procedure.setParameters(new LinkedList<ProcedureParameter>());
+ this.model.addProcedure(procedure);
return procedure;
}
@@ -242,13 +241,13 @@
* Add a procedure parameter.
* @param name
* @param type should be one of {@link TypeFacility.RUNTIME_NAMES}
- * @param parameterType should be one of {@link ProcedureParameterRecordImpl.Type}
+ * @param parameterType should be one of {@link ProcedureParameter.Type}
* @param procedure
* @return
* @throws ConnectorException
*/
- public ProcedureParameterRecordImpl addProcedureParameter(String name, String type, ProcedureParameterRecordImpl.Type parameterType, ProcedureRecordImpl procedure) throws ConnectorException {
- ProcedureParameterRecordImpl param = new ProcedureParameterRecordImpl();
+ public ProcedureParameter addProcedureParameter(String name, String type, ProcedureParameter.Type parameterType, ProcedureRecordImpl procedure) throws ConnectorException {
+ ProcedureParameter param = new ProcedureParameter();
setValuesUsingParent(name, procedure, param, "param"); //$NON-NLS-1$
setUUID(param);
param.setType(parameterType);
@@ -266,9 +265,9 @@
* @return
* @throws ConnectorException
*/
- public ColumnRecordImpl addProcedureResultSetColumn(String name, String type, ProcedureRecordImpl procedure) throws ConnectorException {
+ public Column addProcedureResultSetColumn(String name, String type, ProcedureRecordImpl procedure) throws ConnectorException {
if (procedure.getResultSet() == null) {
- ColumnSetRecordImpl resultSet = new ColumnSetRecordImpl();
+ ColumnSet resultSet = new ColumnSet();
setValuesUsingParent("RESULT_SET", procedure, resultSet, "rs"); //$NON-NLS-1$ //$NON-NLS-2$
setUUID(resultSet);
procedure.setResultSet(resultSet);
@@ -277,11 +276,11 @@
return addColumn(name, type, procedure.getResultSet());
}
- private void assignColumns(List<String> columnNames, TableRecordImpl table,
- ColumnSetRecordImpl columns) throws ConnectorException {
+ private void assignColumns(List<String> columnNames, Table table,
+ ColumnSet columns) throws ConnectorException {
for (String columnName : columnNames) {
boolean match = false;
- for (ColumnRecordImpl column : table.getColumns()) {
+ for (Column column : table.getColumns()) {
if (column.getName().equals(columnName)) {
match = true;
columns.getColumns().add(column);
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -33,59 +33,27 @@
*/
public class MetadataStore implements Serializable {
- private static final long serialVersionUID = -5276588417872522795L;
- private Map<String, ModelRecordImpl> models = new LinkedHashMap<String, ModelRecordImpl>();
- private Map<String, TableRecordImpl> tables = new LinkedHashMap<String, TableRecordImpl>();
- private Map<String, ProcedureRecordImpl> procedures = new LinkedHashMap<String, ProcedureRecordImpl>();
- private Collection<DatatypeRecordImpl> datatypes = new ArrayList<DatatypeRecordImpl>();
+ private static final long serialVersionUID = -3130247626435324312L;
+ private Map<String, Schema> schemas = new LinkedHashMap<String, Schema>();
+ private Collection<Datatype> datatypes = new ArrayList<Datatype>();
- public void addModel(ModelRecordImpl model) {
- this.models.put(model.getFullName().toLowerCase(), model);
+ public Map<String, Schema> getSchemas() {
+ return schemas;
}
- public void addTable(TableRecordImpl table) {
- this.tables.put(table.getFullName().toLowerCase(), table);
+ public void addSchema(Schema schema) {
+ this.schemas.put(schema.getName().toLowerCase(), schema);
}
- public void addProcedure(ProcedureRecordImpl procedure) {
- this.procedures.put(procedure.getFullName().toLowerCase(), procedure);
- }
-
- public void addDatatype(DatatypeRecordImpl datatype) {
+ public void addDatatype(Datatype datatype) {
this.datatypes.add(datatype);
}
/**
- * Get the models represented in this store.
- * For a connector there will only be 1 model and the model name is treated as
- * a top level schema for all source metadata.
- * @return
- */
- public Map<String, ModelRecordImpl> getModels() {
- return models;
- }
-
- /**
- * Get the tables defined in this store
- * @return
- */
- public Map<String, TableRecordImpl> getTables() {
- return tables;
- }
-
- /**
- * Get the procedures defined in this store
- * @return
- */
- public Map<String, ProcedureRecordImpl> getProcedures() {
- return procedures;
- }
-
- /**
* Get the datatypes defined in this store
* @return
*/
- public Collection<DatatypeRecordImpl> getDatatypes() {
+ public Collection<Datatype> getDatatypes() {
return datatypes;
}
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -1,91 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-
-/**
- * ModelRecordImpl
- */
-public class ModelRecordImpl extends AbstractMetadataRecord {
-
- public enum Type {
- Physical,
- Virtual,
- Type,
- VDB_Archive() {
- @Override
- public String toString() {
- return "VDB Archive"; //$NON-NLS-1$
- }
- },
- Unknown,
- Function,
- Configuration,
- Metamodel,
- Extension,
- Logical,
- Materialization
- }
-
- private Type modelType;
- private boolean isVisible = true;
- private String primaryMetamodelUri;
-
- public String getPrimaryMetamodelUri() {
- return primaryMetamodelUri;
- }
-
- public boolean isVisible() {
- return isVisible;
- }
-
- public Type getModelType() {
- return modelType;
- }
-
- public boolean isPhysical() {
- return getModelType() == Type.Physical;
- }
-
- /**
- * @param string
- */
- public void setPrimaryMetamodelUri(String string) {
- primaryMetamodelUri = string;
- }
-
- /**
- * @param b
- */
- public void setVisible(boolean b) {
- isVisible = b;
- }
-
- /**
- * @param i
- */
- public void setModelType(Type i) {
- modelType = i;
- }
-
-}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java (from rev 1545, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameterRecordImpl.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.metadata.runtime;
+
+
+/**
+ * ProcedureParameterRecordImpl
+ */
+public class ProcedureParameter extends BaseColumn {
+
+ public enum Type {
+ Unknown,
+ In,
+ InOut,
+ ResultSet,
+ Out,
+ ReturnValue
+ }
+
+ private Type type;
+ private boolean optional;
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void setOptional(boolean optional) {
+ this.optional = optional;
+ }
+
+ public boolean isOptional() {
+ return optional;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameterRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameterRecordImpl.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameterRecordImpl.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-
-/**
- * ProcedureParameterRecordImpl
- */
-public class ProcedureParameterRecordImpl extends BaseColumn {
-
- public enum Type {
- Unknown,
- In,
- InOut,
- ResultSet,
- Out,
- ReturnValue
- }
-
- private Type type;
- private boolean optional;
-
- public void setType(Type type) {
- this.type = type;
- }
-
- public Type getType() {
- return type;
- }
-
- public void setOptional(boolean optional) {
- this.optional = optional;
- }
-
- public boolean isOptional() {
- return optional;
- }
-
-}
\ No newline at end of file
Modified: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureRecordImpl.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -28,7 +28,7 @@
/**
* ProcedureRecordImpl
*/
-public class ProcedureRecordImpl extends AbstractMetadataRecord {
+public class ProcedureRecordImpl extends AbstractMetadataRecord implements SchemaObject {
public enum Type {
Function,
@@ -42,10 +42,22 @@
private boolean isVirtual;
private String resultSetID;
private int updateCount = 1;
- private List<ProcedureParameterRecordImpl> parameters;
- private ColumnSetRecordImpl resultSet;
+ private List<ProcedureParameter> parameters;
+ private ColumnSet resultSet;
private String queryPlan;
+ private Schema schema;
+
+ @Override
+ public Schema getSchema() {
+ return schema;
+ }
+
+ @Override
+ public void setSchema(Schema schema) {
+ this.schema = schema;
+ }
+
public List<String> getParameterIDs() {
return parameterIDs;
}
@@ -79,11 +91,11 @@
return this.updateCount;
}
- public List<ProcedureParameterRecordImpl> getParameters() {
+ public List<ProcedureParameter> getParameters() {
return parameters;
}
- public void setParameters(List<ProcedureParameterRecordImpl> parameters) {
+ public void setParameters(List<ProcedureParameter> parameters) {
this.parameters = parameters;
}
@@ -127,11 +139,11 @@
this.updateCount = count;
}
- public void setResultSet(ColumnSetRecordImpl resultSet) {
+ public void setResultSet(ColumnSet resultSet) {
this.resultSet = resultSet;
}
- public ColumnSetRecordImpl getResultSet() {
+ public ColumnSet getResultSet() {
return resultSet;
}
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java (from rev 1550, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ModelRecordImpl.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.metadata.runtime;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class Schema extends AbstractMetadataRecord {
+
+ private boolean physical = true;
+ private boolean isVisible = true;
+ private String primaryMetamodelUri;
+
+ private Map<String, Table> tables = new LinkedHashMap<String, Table>();
+ private Map<String, ProcedureRecordImpl> procedures = new LinkedHashMap<String, ProcedureRecordImpl>();
+
+ public void addTable(Table table) {
+ table.setSchema(this);
+ this.tables.put(table.getFullName().toLowerCase(), table);
+ }
+
+ public void addProcedure(ProcedureRecordImpl procedure) {
+ procedure.setSchema(this);
+ this.procedures.put(procedure.getFullName().toLowerCase(), procedure);
+ }
+
+ /**
+ * Get the tables defined in this schema
+ * @return
+ */
+ public Map<String, Table> getTables() {
+ return tables;
+ }
+
+ /**
+ * Get the procedures defined in this schema
+ * @return
+ */
+ public Map<String, ProcedureRecordImpl> getProcedures() {
+ return procedures;
+ }
+
+ public String getPrimaryMetamodelUri() {
+ return primaryMetamodelUri;
+ }
+
+ public boolean isVisible() {
+ return isVisible;
+ }
+
+ public boolean isPhysical() {
+ return physical;
+ }
+
+ /**
+ * @param string
+ */
+ public void setPrimaryMetamodelUri(String string) {
+ primaryMetamodelUri = string;
+ }
+
+ /**
+ * @param b
+ */
+ public void setVisible(boolean b) {
+ isVisible = b;
+ }
+
+ public void setPhysical(boolean physical) {
+ this.physical = physical;
+ }
+
+}
Property changes on: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/SchemaObject.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/SchemaObject.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/SchemaObject.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.metadata.runtime;
+
+public interface SchemaObject {
+
+ Schema getSchema();
+
+ void setSchema(Schema schema);
+
+}
Property changes on: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/SchemaObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java (from rev 1550, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -0,0 +1,276 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.connector.metadata.runtime;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * TableRecordImpl
+ */
+public class Table extends ColumnSet implements SchemaObject {
+
+ public enum Type {
+ Table,
+ View,
+ Document,
+ XmlMappingClass,
+ XmlStagingTable,
+ MaterializedTable
+ }
+
+ private int cardinality;
+ private Type tableType;
+ private boolean isVirtual;
+ private boolean isSystem;
+ private boolean isMaterialized;
+ private boolean supportsUpdate;
+ private List<ForeignKey> foriegnKeys;
+ private List<KeyRecord> indexes;
+ private List<KeyRecord> uniqueKeys;
+ private List<KeyRecord> accessPatterns;
+ private KeyRecord primaryKey;
+
+ //view information
+ private String selectTransformation;
+ private String insertPlan;
+ private String updatePlan;
+ private String deletePlan;
+ private Table materializedStageTable;
+ private Table materializedTable;
+
+ //XML specific
+ private List<String> bindings;
+ private List<String> schemaPaths;
+ private String resourcePath;
+
+ private Schema schema;
+
+ public Schema getSchema() {
+ return schema;
+ }
+
+ public void setSchema(Schema schema) {
+ this.schema = schema;
+ }
+
+ public List<String> getBindings() {
+ return bindings;
+ }
+
+ public void setBindings(List<String> bindings) {
+ this.bindings = bindings;
+ }
+
+ public List<String> getSchemaPaths() {
+ return schemaPaths;
+ }
+
+ public void setSchemaPaths(List<String> schemaPaths) {
+ this.schemaPaths = schemaPaths;
+ }
+
+ public int getCardinality() {
+ return cardinality;
+ }
+
+ public boolean isVirtual() {
+ return isVirtual;
+ }
+
+ public boolean isMaterialized() {
+ return isMaterialized;
+ }
+
+ public boolean isPhysical() {
+ return !isVirtual();
+ }
+
+ public boolean isSystem() {
+ return isSystem;
+ }
+
+ public Type getTableType() {
+ if (tableType == null) {
+ return Type.Table;
+ }
+ return tableType;
+ }
+
+ public boolean supportsUpdate() {
+ return supportsUpdate;
+ }
+
+ /**
+ * @param i
+ */
+ public void setCardinality(int i) {
+ cardinality = i;
+ }
+
+ /**
+ * @param i
+ */
+ public void setTableType(Type i) {
+ tableType = i;
+ }
+
+ /**
+ * @param b
+ */
+ public void setSupportsUpdate(boolean b) {
+ supportsUpdate = b;
+ }
+
+ /**
+ * @param b
+ */
+ public void setVirtual(boolean b) {
+ isVirtual = b;
+ }
+
+ /**
+ * @param isMaterialized The isMaterialized to set.
+ * @since 4.2
+ */
+ public void setMaterialized(boolean isMaterialized) {
+ this.isMaterialized = isMaterialized;
+ }
+
+ /**
+ * @param b
+ */
+ public void setSystem(boolean b) {
+ isSystem = b;
+ }
+
+ public String getInsertPlan() {
+ return insertPlan;
+ }
+
+ public String getUpdatePlan() {
+ return updatePlan;
+ }
+
+ public String getDeletePlan() {
+ return deletePlan;
+ }
+
+ public void setInsertPlan(String insertPlan) {
+ this.insertPlan = insertPlan;
+ }
+
+ public void setUpdatePlan(String updatePlan) {
+ this.updatePlan = updatePlan;
+ }
+
+ public void setDeletePlan(String deletePlan) {
+ this.deletePlan = deletePlan;
+ }
+
+ public List<ForeignKey> getForeignKeys() {
+ return this.foriegnKeys;
+ }
+
+ public void setForiegnKeys(List<ForeignKey> foriegnKeys) {
+ this.foriegnKeys = foriegnKeys;
+ }
+
+ public List<KeyRecord> getIndexes() {
+ return this.indexes;
+ }
+
+ public void setIndexes(List<KeyRecord> indexes) {
+ this.indexes = indexes;
+ }
+
+ public List<KeyRecord> getUniqueKeys() {
+ return this.uniqueKeys;
+ }
+
+ public void setUniqueKeys(List<KeyRecord> uniqueKeys) {
+ this.uniqueKeys = uniqueKeys;
+ }
+
+ public List<KeyRecord> getAccessPatterns() {
+ return this.accessPatterns;
+ }
+
+ public void setAccessPatterns(List<KeyRecord> accessPatterns) {
+ this.accessPatterns = accessPatterns;
+ }
+
+ public KeyRecord getPrimaryKey() {
+ return this.primaryKey;
+ }
+
+ public void setPrimaryKey(KeyRecord primaryKey) {
+ this.primaryKey = primaryKey;
+ }
+
+ public String getSelectTransformation() {
+ return selectTransformation;
+ }
+
+ public void setSelectTransformation(String selectTransformation) {
+ this.selectTransformation = selectTransformation;
+ }
+
+ public Table getMaterializedStageTable() {
+ return materializedStageTable;
+ }
+
+ public Table getMaterializedTable() {
+ return materializedTable;
+ }
+
+ public void setMaterializedStageTable(Table materializedStageTable) {
+ this.materializedStageTable = materializedStageTable;
+ }
+
+ public void setMaterializedTable(Table materializedTable) {
+ this.materializedTable = materializedTable;
+ }
+
+ public void setResourcePath(String resourcePath) {
+ this.resourcePath = resourcePath;
+ }
+
+ public String getResourcePath() {
+ return resourcePath;
+ }
+
+ public Collection<KeyRecord> getAllKeys() {
+ Collection<KeyRecord> keys = new LinkedList<KeyRecord>();
+ if (getPrimaryKey() != null) {
+ keys.add(getPrimaryKey());
+ }
+ keys.addAll(getForeignKeys());
+ keys.addAll(getAccessPatterns());
+ keys.addAll(getIndexes());
+ keys.addAll(getUniqueKeys());
+ return keys;
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/TableRecordImpl.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -1,266 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * TableRecordImpl
- */
-public class TableRecordImpl extends ColumnSetRecordImpl {
-
- public enum Type {
- Table,
- View,
- Document,
- XmlMappingClass,
- XmlStagingTable,
- MaterializedTable
- }
-
- private int cardinality;
- private Type tableType;
- private boolean isVirtual;
- private boolean isSystem;
- private boolean isMaterialized;
- private boolean supportsUpdate;
- private List<ForeignKeyRecordImpl> foriegnKeys;
- private List<KeyRecord> indexes;
- private List<KeyRecord> uniqueKeys;
- private List<KeyRecord> accessPatterns;
- private KeyRecord primaryKey;
-
- //view information
- private String selectTransformation;
- private String insertPlan;
- private String updatePlan;
- private String deletePlan;
- private TableRecordImpl materializedStageTable;
- private TableRecordImpl materializedTable;
-
- //XML specific
- private List<String> bindings;
- private List<String> schemaPaths;
- private String resourcePath;
-
- public List<String> getBindings() {
- return bindings;
- }
-
- public void setBindings(List<String> bindings) {
- this.bindings = bindings;
- }
-
- public List<String> getSchemaPaths() {
- return schemaPaths;
- }
-
- public void setSchemaPaths(List<String> schemaPaths) {
- this.schemaPaths = schemaPaths;
- }
-
- public int getCardinality() {
- return cardinality;
- }
-
- public boolean isVirtual() {
- return isVirtual;
- }
-
- public boolean isMaterialized() {
- return isMaterialized;
- }
-
- public boolean isPhysical() {
- return !isVirtual();
- }
-
- public boolean isSystem() {
- return isSystem;
- }
-
- public Type getTableType() {
- if (tableType == null) {
- return Type.Table;
- }
- return tableType;
- }
-
- public boolean supportsUpdate() {
- return supportsUpdate;
- }
-
- /**
- * @param i
- */
- public void setCardinality(int i) {
- cardinality = i;
- }
-
- /**
- * @param i
- */
- public void setTableType(Type i) {
- tableType = i;
- }
-
- /**
- * @param b
- */
- public void setSupportsUpdate(boolean b) {
- supportsUpdate = b;
- }
-
- /**
- * @param b
- */
- public void setVirtual(boolean b) {
- isVirtual = b;
- }
-
- /**
- * @param isMaterialized The isMaterialized to set.
- * @since 4.2
- */
- public void setMaterialized(boolean isMaterialized) {
- this.isMaterialized = isMaterialized;
- }
-
- /**
- * @param b
- */
- public void setSystem(boolean b) {
- isSystem = b;
- }
-
- public String getInsertPlan() {
- return insertPlan;
- }
-
- public String getUpdatePlan() {
- return updatePlan;
- }
-
- public String getDeletePlan() {
- return deletePlan;
- }
-
- public void setInsertPlan(String insertPlan) {
- this.insertPlan = insertPlan;
- }
-
- public void setUpdatePlan(String updatePlan) {
- this.updatePlan = updatePlan;
- }
-
- public void setDeletePlan(String deletePlan) {
- this.deletePlan = deletePlan;
- }
-
- public List<ForeignKeyRecordImpl> getForeignKeys() {
- return this.foriegnKeys;
- }
-
- public void setForiegnKeys(List<ForeignKeyRecordImpl> foriegnKeys) {
- this.foriegnKeys = foriegnKeys;
- }
-
- public List<KeyRecord> getIndexes() {
- return this.indexes;
- }
-
- public void setIndexes(List<KeyRecord> indexes) {
- this.indexes = indexes;
- }
-
- public List<KeyRecord> getUniqueKeys() {
- return this.uniqueKeys;
- }
-
- public void setUniqueKeys(List<KeyRecord> uniqueKeys) {
- this.uniqueKeys = uniqueKeys;
- }
-
- public List<KeyRecord> getAccessPatterns() {
- return this.accessPatterns;
- }
-
- public void setAccessPatterns(List<KeyRecord> accessPatterns) {
- this.accessPatterns = accessPatterns;
- }
-
- public KeyRecord getPrimaryKey() {
- return this.primaryKey;
- }
-
- public void setPrimaryKey(KeyRecord primaryKey) {
- this.primaryKey = primaryKey;
- }
-
- public String getSelectTransformation() {
- return selectTransformation;
- }
-
- public void setSelectTransformation(String selectTransformation) {
- this.selectTransformation = selectTransformation;
- }
-
- public TableRecordImpl getMaterializedStageTable() {
- return materializedStageTable;
- }
-
- public TableRecordImpl getMaterializedTable() {
- return materializedTable;
- }
-
- public void setMaterializedStageTable(TableRecordImpl materializedStageTable) {
- this.materializedStageTable = materializedStageTable;
- }
-
- public void setMaterializedTable(TableRecordImpl materializedTable) {
- this.materializedTable = materializedTable;
- }
-
- public void setResourcePath(String resourcePath) {
- this.resourcePath = resourcePath;
- }
-
- public String getResourcePath() {
- return resourcePath;
- }
-
- public Collection<KeyRecord> getAllKeys() {
- Collection<KeyRecord> keys = new LinkedList<KeyRecord>();
- if (getPrimaryKey() != null) {
- keys.add(getPrimaryKey());
- }
- keys.addAll(getForeignKeys());
- keys.addAll(getAccessPatterns());
- keys.addAll(getIndexes());
- keys.addAll(getUniqueKeys());
- return keys;
- }
-
-}
\ No newline at end of file
Modified: trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCMetdataProcessor.java
===================================================================
--- trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCMetdataProcessor.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connectors/connector-jdbc/src/main/java/org/teiid/connector/jdbc/JDBCMetdataProcessor.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -36,12 +36,12 @@
import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import org.teiid.connector.metadata.runtime.BaseColumn;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
+import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.MetadataFactory;
import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
+import org.teiid.connector.metadata.runtime.Table;
import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.ProcedureParameterRecordImpl.Type;
+import org.teiid.connector.metadata.runtime.ProcedureParameter.Type;
/**
* Reads from {@link DatabaseMetaData} and creates metadata through the {@link MetadataFactory}.
@@ -55,9 +55,9 @@
private String catalog;
private String schema;
private String name;
- private TableRecordImpl table;
+ private Table table;
- public TableInfo(String catalog, String schema, String name, TableRecordImpl table) {
+ public TableInfo(String catalog, String schema, String name, Table table) {
this.catalog = catalog;
this.schema = schema;
this.name = name;
@@ -126,7 +126,7 @@
}
BaseColumn record = null;
if (columnType == DatabaseMetaData.procedureColumnResult) {
- ColumnRecordImpl column = metadataFactory.addProcedureResultSetColumn(columnName, TypeFacility.getDataTypeNameFromSQLType(sqlType), procedure);
+ Column column = metadataFactory.addProcedureResultSetColumn(columnName, TypeFacility.getDataTypeNameFromSQLType(sqlType), procedure);
record = column;
column.setNativeType(columns.getString(7));
} else {
@@ -153,7 +153,7 @@
String tableSchema = tables.getString(2);
String tableName = tables.getString(3);
String fullName = getTableName(tableCatalog, tableSchema, tableName);
- TableRecordImpl table = metadataFactory.addTable(useFullSchemaName?fullName:tableName);
+ Table table = metadataFactory.addTable(useFullSchemaName?fullName:tableName);
table.setNameInSource(fullName);
table.setSupportsUpdate(true);
String remarks = tables.getString(5);
@@ -184,7 +184,7 @@
String columnName = columns.getString(4);
int type = columns.getInt(5);
//note that the resultset is already ordered by position, so we can rely on just adding columns in order
- ColumnRecordImpl column = metadataFactory.addColumn(columnName, TypeFacility.getDataTypeNameFromSQLType(type), tableInfo.table);
+ Column column = metadataFactory.addColumn(columnName, TypeFacility.getDataTypeNameFromSQLType(type), tableInfo.table);
column.setNativeType(columns.getString(6));
column.setRadix(columns.getInt(10));
column.setNullType(NullType.values()[columns.getShort(11)]);
Modified: trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java
===================================================================
--- trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connectors/connector-text/src/main/java/com/metamatrix/connector/text/TextConnector.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -43,9 +43,9 @@
import org.teiid.connector.api.MetadataProvider;
import org.teiid.connector.api.TypeFacility;
import org.teiid.connector.basic.BasicConnector;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
+import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
+import org.teiid.connector.metadata.runtime.Table;
/**
@@ -374,10 +374,10 @@
throw new ConnectorException(TextPlugin.Util.getString("TextConnector.column_mismatch", entry.getKey())); //$NON-NLS-1$
}
}
- TableRecordImpl table = metadataFactory.addTable(entry.getKey().substring(entry.getKey().indexOf('.') + 1));
+ Table table = metadataFactory.addTable(entry.getKey().substring(entry.getKey().indexOf('.') + 1));
for (int i = 0; i < columnNames.length; i++) {
String type = typeNames == null?TypeFacility.RUNTIME_NAMES.STRING:typeNames[i].trim().toLowerCase();
- ColumnRecordImpl column = metadataFactory.addColumn(columnNames[i].trim(), type, table);
+ Column column = metadataFactory.addColumn(columnNames[i].trim(), type, table);
column.setNameInSource(String.valueOf(i));
column.setNativeType(TypeFacility.RUNTIME_NAMES.STRING);
}
Modified: trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java
===================================================================
--- trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/connectors/connector-text/src/test/java/com/metamatrix/connector/text/TestTextConnector.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -30,9 +30,9 @@
import org.junit.Test;
import org.teiid.connector.api.ConnectorEnvironment;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
+import org.teiid.connector.metadata.runtime.Table;
import com.metamatrix.cdk.api.EnvironmentUtility;
import com.metamatrix.common.types.DataTypeManager;
@@ -49,7 +49,6 @@
ConnectorEnvironment env = EnvironmentUtility.createEnvironment(props, false);
TextConnector connector = new TextConnector();
- // Initialize license checker with class, non-GUI notifier and don't exitOnFailure
connector.start(env);
return connector;
}
@@ -63,15 +62,15 @@
@Test public void testGetMetadata() throws Exception{
TextConnector connector = helpSetUp(UnitTestUtil.getTestDataPath() + "/SummitData_Descriptor.txt"); //$NON-NLS-1$
- Map<String, DatatypeRecordImpl> datatypes = new HashMap<String, DatatypeRecordImpl>();
- datatypes.put(DataTypeManager.DefaultDataTypes.STRING, new DatatypeRecordImpl());
- datatypes.put(DataTypeManager.DefaultDataTypes.BIG_INTEGER, new DatatypeRecordImpl());
- datatypes.put(DataTypeManager.DefaultDataTypes.INTEGER, new DatatypeRecordImpl());
- datatypes.put(DataTypeManager.DefaultDataTypes.TIMESTAMP, new DatatypeRecordImpl());
+ Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
+ datatypes.put(DataTypeManager.DefaultDataTypes.STRING, new Datatype());
+ datatypes.put(DataTypeManager.DefaultDataTypes.BIG_INTEGER, new Datatype());
+ datatypes.put(DataTypeManager.DefaultDataTypes.INTEGER, new Datatype());
+ datatypes.put(DataTypeManager.DefaultDataTypes.TIMESTAMP, new Datatype());
MetadataFactory metadata = new MetadataFactory("SummitData", datatypes, new Properties()); //$NON-NLS-1$
connector.getConnectorMetadata(metadata);
- assertEquals(0, metadata.getMetadataStore().getProcedures().size());
- TableRecordImpl group = metadata.getMetadataStore().getTables().get("summitdata.summitdata"); //$NON-NLS-1$
+ assertEquals(0, metadata.getMetadataStore().getSchemas().values().iterator().next().getProcedures().size());
+ Table group = metadata.getMetadataStore().getSchemas().values().iterator().next().getTables().get("summitdata.summitdata"); //$NON-NLS-1$
assertEquals("SUMMITDATA", group.getName()); //$NON-NLS-1$
assertEquals("SummitData.SUMMITDATA", group.getFullName()); //$NON-NLS-1$
assertEquals(14, group.getColumns().size());
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/datatypes.xml 2009-11-18 15:26:22 UTC (rev 1571)
@@ -231,7 +231,7 @@
<para>When Teiid detects that an explicit conversion can
not be applied implicitly in criteria, the criteria will be
treated as false. For example:</para>
- <programlisting>SELECT * FROM my.group WHERE created_by = ‘not a date’</programlisting>
+ <programlisting>SELECT * FROM my.table WHERE created_by = ‘not a date’</programlisting>
<para>
Given that created_by is typed as date, rather than converting
<literal>'not a date'</literal>
@@ -350,10 +350,10 @@
<title>Conversion of String Literals</title>
<para> Teiid automatically converts string literals within a
SQL statement to their implied types. This typically occurs in a
- criteria comparison where an element with a different datatype
+ criteria comparison where an expression with a different datatype
is compared to a literal string:</para>
- <programlisting>SELECT * FROM my.group WHERE created_by = ‘2003-01-02’</programlisting>
- <para> Here if the created_by element has the datatype of date,
+ <programlisting>SELECT * FROM my.table WHERE created_by = ‘2003-01-02’</programlisting>
+ <para> Here if the created_by column has the datatype of date,
Teiid automatically converts the string literal to a date
datatype as well.</para>
</sect2>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/federated_planning.xml 2009-11-18 15:26:22 UTC (rev 1571)
@@ -128,12 +128,12 @@
<title>Access Patterns</title>
<para>
Access patterns are used on both physical and virtual sources to
- specify the need for criteria against a set of elements. Failure to supply the criteria will
+ specify the need for criteria against a set of columns. Failure to supply the criteria will
result in a planning error, rather than a run-away source query. Access
patterns can be applied in a set such that only one of the access
patterns is required to be satisfied.</para>
- <para>Currently any form of criteria may satisfy an access
- pattern as long as it contains references to affect elements.</para>
+ <para>Currently any form of criteria referencing an affected column may satisfy an access
+ pattern.</para>
</sect2>
<sect2>
<title>Pushdown</title>
@@ -536,21 +536,6 @@
processing. Also processes an offset if present.</para>
<para />
</listitem>
- <listitem>
- <para> Dependent Feeder - This node accepts its input stream
- and forwards to its parent unchanged but also feeds all
- dependent sources that need the stream of data. Thus, this
- node actually performs no work within the tree, just diverts
- a copy of the tuple stream to listening nodes.</para>
- <para />
- </listitem>
- <listitem>
- <para> Dependent Wait - This node waits until a criteria
- requiring dependent values below this node has the necessary
- data to continue. At that point, it continues processing on
- it's subplan and merely forwards data from the child to the
- parent.</para>
- </listitem>
</itemizedlist>
<sect3>
<title>Node Statistics</title>
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/procedures.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/procedures.xml 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/procedures.xml 2009-11-18 15:26:22 UTC (rev 1571)
@@ -20,12 +20,12 @@
A command statement executes a
<link linkend="sql_commands">SQL command</link>
, such as SELECT, INSERT, UPDATE, DELETE, or EXECUTE, against
- one or more other models (and their underlying data sources).
+ one or more data sources.
</para>
<example>
<title>Example Command Statements</title>
- <programlisting>SELECT * FROM MyModel.MyTable WHERE ColA > 100;
-INSERT INTO MyModel.MyTable (ColA,ColB) VALUES (50, 'hi');</programlisting>
+ <programlisting>SELECT * FROM MySchema.MyTable WHERE ColA > 100;
+INSERT INTO MySchema.MyTable (ColA,ColB) VALUES (50, 'hi');</programlisting>
</example>
</sect2>
<sect2 id="dynamic_sql">
@@ -49,7 +49,7 @@
</para>
</listitem>
<listitem>
- <para>The "USING" clause allows the dynamic SQL string to contain special element symbols that are bound at runtime to specified values. This allows for some independence of the SQL string from the surrounding procedure variable names and input names. In the dynamic command "USING" clause, each variable is specified by short name only. However in the dynamic SQL the "USING" variable must be fully qualified to "USING.". The "USING" clause is only for values that will be used in the dynamic SQL as legal expressions. It is not possible to use the "USING" clause to replace table names, keywords, etc. This makes using symbols equivalent in power to normal bind (?) expressions in prepared statements. The "USING" clause helps reduce the amount of string manipulation needed. If a reference is made to a USING symbol in the SQL string that is not bound to a value in the "USING" clause, an exception will occur.
+ <para>The "USING" clause allows the dynamic SQL string to contain variable references that are bound at runtime to specified values. This allows for some independence of the SQL string from the surrounding procedure variable names and input names. In the dynamic command "USING" clause, each variable is specified by short name only. However in the dynamic SQL the "USING" variable must be fully qualified to "USING.". The "USING" clause is only for values that will be used in the dynamic SQL as legal expressions. It is not possible to use the "USING" clause to replace table names, keywords, etc. This makes using symbols equivalent in power to normal bind (?) expressions in prepared statements. The "USING" clause helps reduce the amount of string manipulation needed. If a reference is made to a USING symbol in the SQL string that is not bound to a value in the "USING" clause, an exception will occur.
</para>
</listitem>
<listitem>
@@ -194,7 +194,7 @@
</para>
</listitem>
<listitem>
- <para>VARIABLES.x = SELECT Column1 FROM MyModel.MyTable;
+ <para>VARIABLES.x = SELECT Column1 FROM MySchema.MyTable;
</para>
</listitem>
</itemizedlist>
@@ -303,14 +303,14 @@
<para>Nullable - NO_NULLS, NULLABLE, NULLABLE_UNKNOWN; parameter is optional if nullable, and is not required to be listed when using named parameter syntax</para>
</listitem>
</itemizedlist>
- <para>You reference an input to a virtual procedure by using the fully-qualified name of the param (or less if unambiguous). For example, MyModel.MyProc.Param1.
+ <para>You reference an input to a virtual procedure by using the fully-qualified name of the param (or less if unambiguous). For example, MySchema.MyProc.Param1.
</para>
<example>
<title>Example of Referencing an Input Parameter for 'GetBalance' Procedure</title>
<programlisting>
CREATE VIRTUAL PROCEDURE
BEGIN
- SELECT Balance FROM MyModel.Accts WHERE MyModel.Accts.AccountID = MyModel.GetBalance.AcctID;
+ SELECT Balance FROM MySchema.Accts WHERE MySchema.Accts.AccountID = MySchema.GetBalance.AcctID;
END</programlisting>
</example>
</sect2>
@@ -370,7 +370,7 @@
the procedure has defined inputs, you specify those in a
sequential list, or using "name=value" syntax. You must use the
name of the input parameter, scoped by the full procedure name if
- the parameter name is ambiguous in the context of other elements
+ the parameter name is ambiguous in the context of other columns
or variables in the procedure.</para>
<para> A virtual procedure call will return a result set just like any
SELECT, so you can use this in many places you can use a SELECT.
@@ -489,7 +489,7 @@
<para>You can use the HAS CRITERIA clause to check whether the user’s command has a particular kind of criteria on a particular set of attributes. This clause evaluates to either true or false. You can use it anywhere you can use a criteria within a procedure.</para>
<para>
Usage:
- <synopsis>HAS [criteria operator] CRITERIA [ON (element list)]</synopsis>
+ <synopsis>HAS [criteria operator] CRITERIA [ON (column list)]</synopsis>
</para>
<itemizedlist>
<para>Syntax Rules</para>
@@ -498,11 +498,11 @@
</para>
</listitem>
<listitem>
- <para>If the ON clause is present, HAS CRITERIA will return true only if criteria was present on all of the specified elements.
+ <para>If the ON clause is present, HAS CRITERIA will return true only if criteria was present on all of the specified columns.
</para>
</listitem>
<listitem>
- <para>The elements in a HAS CRITERIA ON clause always refer to virtual elements.
+ <para>The columns in a HAS CRITERIA ON clause always refer to virtual columns.
</para>
</listitem>
</itemizedlist>
@@ -521,11 +521,11 @@
<entry>Checks simply whether there was any criteria at all.</entry>
</row>
<row>
- <entry><code>HAS CRITERIA ON (element1, element2)</code></entry>
- <entry>Checks whether the criteria uses element1 and element2.</entry>
+ <entry><code>HAS CRITERIA ON (column1, column2)</code></entry>
+ <entry>Checks whether the criteria uses column1 and column2.</entry>
</row>
<row>
- <entry><code>HAS = CRITERIA ON (element1)</code></entry>
+ <entry><code>HAS = CRITERIA ON (column1)</code></entry>
<entry>Checks whether the criteria has a comparison criteria with = operator.</entry>
</row>
<row>
@@ -541,10 +541,10 @@
</sect3>
<sect3>
<title>TRANSLATE CRITERIA</title>
- <para>You can use the TRANSLATE CRITERIA clause to convert the criteria from the user application’s SQL command into the form required to interact with the target source or view tables. The TRANSLATE CRITERIA statement uses the SELECT transformation to infer the element mapping. This clause evaluates to a translated criteria that is evaluated in the context of a command.</para>
+ <para>You can use the TRANSLATE CRITERIA clause to convert the criteria from the user application’s SQL command into the form required to interact with the target source or view tables. The TRANSLATE CRITERIA statement uses the SELECT transformation to infer the column mapping. This clause evaluates to a translated criteria that is evaluated in the context of a command.</para>
<para>
Usage:
- <synopsis>TRANSLATE [criteria operator] CRITERIA [ON (element list)] [WITH (mapping list)]</synopsis>
+ <synopsis>TRANSLATE [criteria operator] CRITERIA [ON (column list)] [WITH (mapping list)]</synopsis>
</para>
<itemizedlist>
<para>Syntax Rules</para>
@@ -553,15 +553,15 @@
</para>
</listitem>
<listitem>
- <para>If the ON clause is present, TRANSLATE CRITERIA will only form criteria using the specified elements.
+ <para>If the ON clause is present, TRANSLATE CRITERIA will only form criteria using the specified columns.
</para>
</listitem>
<listitem>
- <para>The elements in a TRANSLATE CRITERIA ON clause always refer to virtual elements.
+ <para>The columns in a TRANSLATE CRITERIA ON clause always refer to virtual columns.
</para>
</listitem>
</itemizedlist>
- <para>You can use these mappings either to replace the default mappings generated from the SELECT transformation or to specify a reverse expression when a virtual element is defined by an expression.</para>
+ <para>You can use these mappings either to replace the default mappings generated from the SELECT transformation or to specify a reverse expression when a virtual column is defined by an expression.</para>
<para>Some samples of the HAS TRANSLATE clause:</para>
<informaltable>
<tgroup cols="2">
@@ -579,21 +579,21 @@
<entry>Translates any user criteria using the default mappings.</entry>
</row>
<row>
- <entry>TRANSLATE CRITERIA WITH (element1 = 'A', element2 = INPUT.element2 + 2)</entry>
- <entry>Translates any criteria with some additional mappings: element1 is always mapped to 'A' and element2 is mapped to the incoming element2 value + 2.</entry>
+ <entry>TRANSLATE CRITERIA WITH (column1 = 'A', column2 = INPUT.column2 + 2)</entry>
+ <entry>Translates any criteria with some additional mappings: column1 is always mapped to 'A' and column2 is mapped to the incoming column2 value + 2.</entry>
</row>
<row>
- <entry><code>TRANSLATE = CRITERIA ON (element1)</code></entry>
- <entry>Translates only criteria that have = comparison operator and involve element1.</entry>
+ <entry><code>TRANSLATE = CRITERIA ON (column1)</code></entry>
+ <entry>Translates only criteria that have = comparison operator and involve column1.</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
- The TRANSLATE CRITERIA, ON clause always refers to virtual elements.
+ The TRANSLATE CRITERIA, ON clause always refers to virtual columns.
The WITH clause always has items with form <elem> = <expression>,
- where the <elem> is a virtual element and the <expression>
- specifies what that virtual element should be
+ where the <elem> is a virtual column and the <expression>
+ specifies what that virtual column should be
replaced with when TRANSLATE CRITERIA translates the virtual
criteria (from UPDATE or DELETE) into a physical criteria in
the command. By default, a mapping is created based on the
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2009-11-18 15:26:22 UTC (rev 1571)
@@ -1736,47 +1736,43 @@
</sect1>
<sect1>
<title>Lookup Function</title>
- <para>The Lookup function allows you to cache a group’s
+ <para>The Lookup function allows you to cache a table’s
data in memory and access it through a scalar function. This caching
- accelerates response time to queries that use the lookup groups, known
- in business terminology as lookup tables or code groups.</para>
- <para>A StatePostalCodes group used to translate postal codes to
+ accelerates response time to queries that use the lookup tables, known
+ in business terminology as lookup tables or code tables.</para>
+ <para>A StatePostalCodes table used to translate postal codes to
complete state names might represent an example of this type of
- lookup group. One element, PostalCode, represents a key element.
- Other groups within the model refer to this two-letter code. A
- second element, StateDisplayName, would represent the complete name
- of the state. Hence, a query to this lookup group would typically
+ lookup table. One column, PostalCode, represents a key column.
+ Other tables refer to this two-letter code. A
+ second column, StateDisplayName, would represent the complete name
+ of the state. Hence, a query to this lookup table would typically
provide the PostalCode and expect the StateDisplayName in response.
</para>
- <para>When you call this function for any combination of codeGroup, returnElement, and
- keyElement for the first time, the Teiid System caches the result.
+ <para>When you call this function for any combination of codeTable, returnColumn, and
+ keyColumn for the first time, the Teiid System caches the result.
The Teiid System uses this cached map for all
- queries, in all sessions, that later access this lookup group. The
- codeGroup requires use of the fully-qualified name, and the
- returnElement and keyElement parameters should use shortened column
+ queries, in all sessions, that later access this lookup table. The
+ codeTable requires use of the fully-qualified name, and the
+ returnColumn and keyColumn parameters should use shortened column
names.</para>
<para>Because the Teiid System caches and indexes this
information in memory, this function provides quick access after the
- Teiid System initially caches the lookup group. The Teiid
- System unloads these cached lookup groups when you stop and restart
+ Teiid System initially caches the lookup table. The Teiid
+ System unloads these cached lookup tables when you stop and restart
the Teiid System. Thus, you should not use this function for
data that is subject to updates. Instead, you can use it against
static data that does not change over time.</para>
<note>
<itemizedlist>
<listitem>
- <para>The keyElement column is expected to contain unique key
- values. If the column contains duplicate values, only the last
- loaded value will be used for lookup purposes. In some cases, this
- may cause unexpected results, so it is strongly recommended that
- only columns without duplicate values be used as the keyElement. The
+ <para>The keyColumn is expected to contain unique key
+ values. If the column contains duplicate values, an exception will be thrown. The
lookup caches can be flushed via the svcmgr.</para>
</listitem>
<listitem>
- <para>Cached lookup groups might consume significant memory. You
- can limit the number and maximum size of these code groups by
- setting properties of the QueryService through the Teiid
- Console.</para>
+ <para>Cached lookup tables might consume significant memory. You
+ can limit the number and maximum size of these code tables by
+ setting configuration properties.</para>
</listitem>
</itemizedlist>
</note>
@@ -1798,20 +1794,20 @@
<tbody>
<row>
<entry>
- <para>LOOKUP(codeGroup, returnElement,
- keyElement, keyValue)</para>
+ <para>LOOKUP(codeTable, returnColumn,
+ keyColumn, keyValue)</para>
</entry>
<entry>
- <para>In the lookup group codeGroup, find the row where
- keyElement has the value keyValue and return the
- associated returnElement</para>
+ <para>In the lookup table codeTable, find the row where
+ keyColumn has the value keyValue and return the
+ associated returnColumn</para>
</entry>
<entry>
- <para>codeGroup must be a fully-qualified string
+ <para>codeTable must be a fully-qualified string
literal containing metadata identifiers, keyValue datatype
- must match datatype of the keyElement, return datatype
- matches that of returnElement. returnElement and
- keyElement parameters should use their shortened names.
+ must match datatype of the keyColumn, return datatype
+ matches that of returnColumn. returnColumn and
+ keyColumn parameters should use their shortened names.
</para>
</entry>
</row>
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 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/sql_support.xml 2009-11-18 15:26:22 UTC (rev 1571)
@@ -24,17 +24,17 @@
are processed in the context of a virtual database, or VDB.
Because information can be federated across multiple sources,
tables and columns must be scoped in some manner to avoid
- conflicts. This scoping is provided by models, which contain the
+ conflicts. This scoping is provided by schemas, which contain the
information for each data source or set of views.</para>
<itemizedlist>
<para>Fully-qualified table and column names are of
the following form, where the separate 'parts' of the identifier
are delimited by periods.</para>
<listitem>
- <para>TABLE: <model_name>.<table_spec></para>
+ <para>TABLE: <schema_name>.<table_spec></para>
</listitem>
<listitem>
- <para>COLUMN: <model_name>.<table_spec>.<column_name></para>
+ <para>COLUMN: <schema_name>.<table_spec>.<column_name></para>
</listitem>
</itemizedlist>
<itemizedlist>
@@ -62,18 +62,15 @@
<para> Some examples of valid fully-qualified table identifiers are:
</para>
<listitem>
- <para>MyModel.MySchema.Portfolios
+ <para>MySchema.Portfolios
</para>
</listitem>
<listitem>
- <para>"MyModel"."MySchema.Portfolios"
+ <para>"MySchema.Portfolios"
</para>
</listitem>
<listitem>
- <para>MyModel.Inventory</para>
- </listitem>
- <listitem>
- <para>MyModel.MyCatalog.dbo.Authors
+ <para>MySchema.MyCatalog.dbo.Authors
</para>
</listitem>
</itemizedlist>
@@ -81,21 +78,17 @@
<para>Some examples of valid fully-qualified column identifiers
are:</para>
<listitem>
- <para>MyModel.MySchema.Portfolios.portfolioID
+ <para>MySchema.Portfolios.portfolioID
</para>
</listitem>
<listitem>
- <para>"MyModel"."MySchema.Portfolios"."portfolioID"
+ <para>"MySchema.Portfolios"."portfolioID"
</para>
</listitem>
<listitem>
- <para>MyModel.Inventory.totalPallets
+ <para>MySchema.MyCatalog.dbo.Authors.lastName
</para>
</listitem>
- <listitem>
- <para>MyModel.MyCatalog.dbo.Authors.lastName
- </para>
- </listitem>
</itemizedlist>
<para> Fully-qualified identifiers can always be used in SQL commands.
Partially- or unqualified forms can also be used, as long as the
@@ -564,7 +557,7 @@
</para>
</listitem>
<listitem>
- <para>The procedure virtual group automatically has an access pattern on its IN and IN_OUT parameters which
+ <para>The procedure virtual table automatically has an access pattern on its IN and IN_OUT parameters which
allows it to be planned correctly as a dependent join when necessary or fail when sufficient criteria cannot be found.
</para>
</listitem>
@@ -605,7 +598,7 @@
</para>
</listitem>
<listitem>
- <para>SELECT <element name>,...INTO <temporary table name> FROM <table name>
+ <para>SELECT <column name>,...INTO <temporary table name> FROM <table name>
</para>
</listitem>
<listitem>
Modified: trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/engine/src/main/java/com/metamatrix/dqp/service/MetadataService.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -24,7 +24,7 @@
import java.util.Map;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.metadata.CompositeMetadataStore;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -39,6 +39,6 @@
CompositeMetadataStore getMetadataObjectSource(String vdbName, String vdbVersion) throws MetaMatrixComponentException;
- Map<String, DatatypeRecordImpl> getBuiltinDatatypes() throws MetaMatrixComponentException;
+ Map<String, Datatype> getBuiltinDatatypes() throws MetaMatrixComponentException;
}
Modified: trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -45,21 +45,6 @@
boolean isMetadataID(String id) throws ParseException {
int length = id.length();
- if(id.indexOf("mmuuid:") >= 0) { //$NON-NLS-1$
- // Validate modeler form. Example: "mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0"
-
- int dotIndex = id.indexOf("."); //$NON-NLS-1$
- if(dotIndex >= 0) {
- String groupPart = id.substring(0, dotIndex);
- String lastPart = id.substring(dotIndex+1);
- if(isModelerID(groupPart) || isMetadataPart(groupPart)) {
- return (lastPart.equals("*") || isModelerID(lastPart)); //$NON-NLS-1$
- }
- return false;
- }
- return isModelerID(id);
- }
-
// Validate server forms:
// group, vdb.group, "group", vdb."group",
// group.*, vdb.group.*, "group".*, vdb."group".*,
@@ -94,26 +79,6 @@
}
/**
- * Check that this is a valid mmuuid
- * @param id Group ID string
- */
- boolean isModelerID(String id) throws ParseException {
- int length = id.length();
-
- if(id.startsWith("mmuuid:")) { //$NON-NLS-1$
- // Validate modeler form. Example: "mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0"
- for(int i=7; i<length; i++) {
- char c = id.charAt(i);
- if( ! (c == '-' || (c >= 'a' && c <= 'f') || StringUtil.isDigit(c)) ) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- /**
* Check that this is a valid function name
* @param id Function name string
*/
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -35,15 +35,15 @@
import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialClob;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
-import org.teiid.connector.metadata.runtime.ForeignKeyRecordImpl;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.Datatype;
+import org.teiid.connector.metadata.runtime.ForeignKey;
import org.teiid.connector.metadata.runtime.KeyRecord;
import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.ModelRecordImpl;
-import org.teiid.connector.metadata.runtime.ProcedureParameterRecordImpl;
+import org.teiid.connector.metadata.runtime.Schema;
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
+import org.teiid.connector.metadata.runtime.Table;
import org.teiid.dqp.internal.process.CodeTableCache.CacheKey;
import org.teiid.metadata.CompositeMetadataStore;
@@ -186,7 +186,7 @@
case MODELS:
case MODELPROPERTIES:
for (MetadataStore store : metadata.getMetadataStores()) {
- for (ModelRecordImpl model : store.getModels().values()) {
+ for (Schema model : store.getSchemas().values()) {
if(checkVisibility(vdbName, vdbVersion, model.getName())) {
if (sysTable == SystemTables.MODELS) {
rows.add(Arrays.asList(model.getName(), model.isPhysical(), model.getUUID(), model.getAnnotation(), model.getPrimaryMetamodelUri()));
@@ -203,7 +203,7 @@
case DATATYPEPROPERTIES:
rows = new LinkedHashSet(); //System types are duplicated in each indexed vdb...
for (MetadataStore store : metadata.getMetadataStores()) {
- for (DatatypeRecordImpl datatype : store.getDatatypes()) {
+ for (Datatype datatype : store.getDatatypes()) {
if (sysTable == SystemTables.DATATYPES) {
rows.add(Arrays.asList(datatype.getName(), datatype.isBuiltin(), datatype.isBuiltin(), datatype.getName(), datatype.getJavaClassName(), datatype.getScale(),
datatype.getLength(), datatype.getNullType().toString(), datatype.isSigned(), datatype.isAutoIncrement(), datatype.isCaseSensitive(), datatype.getPrecisionLength(),
@@ -221,117 +221,121 @@
case PROCEDUREPARAMS:
case PROCEDUREPARAMPROPERTIES:
for (MetadataStore store : metadata.getMetadataStores()) {
- for (ProcedureRecordImpl proc : store.getProcedures().values()) {
- if(!checkVisibility(vdbName, vdbVersion, proc.getModelName())) {
- continue;
- }
- switch (sysTable) {
- case PROCEDURES:
- ModelRecordImpl model = store.getModels().get(proc.getModelName().toLowerCase());
- rows.add(Arrays.asList(proc.getModelName(), proc.getName(), proc.getNameInSource(), proc.getResultSetID() != null, model.getUUID(), proc.getUUID(), proc.getAnnotation(), proc.getFullName()));
- break;
- case PROCEDUREPROPERTIES:
- for (Map.Entry<String, String> entry : proc.getProperties().entrySet()) {
- rows.add(Arrays.asList(proc.getModelName(), proc.getName(), entry.getKey(), entry.getValue(), proc.getUUID()));
+ for (Schema schema : store.getSchemas().values()) {
+ for (ProcedureRecordImpl proc : schema.getProcedures().values()) {
+ if(!checkVisibility(vdbName, vdbVersion, proc.getSchema().getName())) {
+ continue;
}
- break;
- default:
- for (ProcedureParameterRecordImpl param : proc.getParameters()) {
- if (sysTable == SystemTables.PROCEDUREPARAMS) {
- rows.add(Arrays.asList(proc.getModelName(), proc.getFullName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), param.getType().toString(), param.isOptional(),
- param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(), param.getNullType().toString(), param.getUUID()));
- } else {
- for (Map.Entry<String, String> entry : param.getProperties().entrySet()) {
- rows.add(Arrays.asList(proc.getModelName(), proc.getFullName(), param.getName(), entry.getKey(), entry.getValue(), param.getUUID()));
- }
+ switch (sysTable) {
+ case PROCEDURES:
+ Schema model = proc.getSchema();
+ rows.add(Arrays.asList(model.getName(), proc.getName(), proc.getNameInSource(), proc.getResultSetID() != null, model.getUUID(), proc.getUUID(), proc.getAnnotation(), proc.getFullName()));
+ break;
+ case PROCEDUREPROPERTIES:
+ for (Map.Entry<String, String> entry : proc.getProperties().entrySet()) {
+ rows.add(Arrays.asList(proc.getSchema().getName(), proc.getName(), entry.getKey(), entry.getValue(), proc.getUUID()));
}
- }
- if (proc.getResultSetID() != null) {
- for (ColumnRecordImpl param : proc.getResultSet().getColumns()) {
+ break;
+ default:
+ for (ProcedureParameter param : proc.getParameters()) {
if (sysTable == SystemTables.PROCEDUREPARAMS) {
- rows.add(Arrays.asList(proc.getModelName(), proc.getFullName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), ProcedureParameterRecordImpl.Type.ResultSet.toString(), false,
+ rows.add(Arrays.asList(proc.getSchema().getName(), proc.getFullName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), param.getType().toString(), param.isOptional(),
param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(), param.getNullType().toString(), param.getUUID()));
} else {
for (Map.Entry<String, String> entry : param.getProperties().entrySet()) {
- rows.add(Arrays.asList(proc.getModelName(), proc.getFullName(), param.getName(), entry.getKey(), entry.getValue(), param.getUUID()));
+ rows.add(Arrays.asList(proc.getSchema().getName(), proc.getFullName(), param.getName(), entry.getKey(), entry.getValue(), param.getUUID()));
}
}
}
+ if (proc.getResultSetID() != null) {
+ for (Column param : proc.getResultSet().getColumns()) {
+ if (sysTable == SystemTables.PROCEDUREPARAMS) {
+ rows.add(Arrays.asList(proc.getSchema().getName(), proc.getFullName(), param.getName(), param.getDatatype().getRuntimeTypeName(), param.getPosition(), ProcedureParameter.Type.ResultSet.toString(), false,
+ param.getPrecision(), param.getLength(), param.getScale(), param.getRadix(), param.getNullType().toString(), param.getUUID()));
+ } else {
+ for (Map.Entry<String, String> entry : param.getProperties().entrySet()) {
+ rows.add(Arrays.asList(proc.getSchema().getName(), proc.getFullName(), param.getName(), entry.getKey(), entry.getValue(), param.getUUID()));
+ }
+ }
+ }
+ }
+ break;
}
- break;
}
}
}
break;
default:
for (MetadataStore store : metadata.getMetadataStores()) {
- for (TableRecordImpl table : store.getTables().values()) {
- if(!checkVisibility(vdbName, vdbVersion, table.getModelName())) {
- continue;
- }
- switch (sysTable) {
- case GROUPS:
- rows.add(Arrays.asList(table.getModelName(), table.getFullName(), table.getName(), table.getTableType().toString(), table.getNameInSource(),
- table.isPhysical(), table.getName().toUpperCase(), table.supportsUpdate(), table.getUUID(), table.getCardinality(), table.getAnnotation(), table.isSystem(), table.isMaterialized()));
- break;
- case GROUPPROPERTIES:
- for (Map.Entry<String, String> entry : table.getProperties().entrySet()) {
- rows.add(Arrays.asList(table.getModelName(), table.getFullName(), entry.getKey(), entry.getValue(), table.getName(), table.getName().toUpperCase(), table.getUUID()));
+ for (Schema schema : store.getSchemas().values()) {
+ for (Table table : schema.getTables().values()) {
+ if(!checkVisibility(vdbName, vdbVersion, table.getSchema().getName())) {
+ continue;
}
- break;
- case ELEMENTS:
- for (ColumnRecordImpl column : table.getColumns()) {
- if (column.getDatatype() == null) {
- continue; //some mapping classes don't set the datatype
+ switch (sysTable) {
+ case GROUPS:
+ rows.add(Arrays.asList(table.getSchema().getName(), table.getFullName(), table.getName(), table.getTableType().toString(), table.getNameInSource(),
+ table.isPhysical(), table.getName().toUpperCase(), table.supportsUpdate(), table.getUUID(), table.getCardinality(), table.getAnnotation(), table.isSystem(), table.isMaterialized()));
+ break;
+ case GROUPPROPERTIES:
+ for (Map.Entry<String, String> entry : table.getProperties().entrySet()) {
+ rows.add(Arrays.asList(table.getSchema().getName(), table.getFullName(), entry.getKey(), entry.getValue(), table.getName(), table.getName().toUpperCase(), table.getUUID()));
}
- rows.add(Arrays.asList(table.getModelName(), table.getName(), table.getFullName(), column.getName(), column.getPosition(), column.getNameInSource(),
- column.getDatatype().getRuntimeTypeName(), column.getScale(), column.getLength(), column.isFixedLength(), column.isSelectable(), column.isUpdatable(),
- column.isCaseSensitive(), column.isSigned(), column.isCurrency(), column.isAutoIncrementable(), column.getNullType().toString(), column.getMinValue(),
- column.getMaxValue(), column.getSearchType().toString(), column.getFormat(), column.getDefaultValue(), column.getDatatype().getJavaClassName(), column.getPrecision(),
- column.getCharOctetLength(), column.getRadix(), table.getName().toUpperCase(), column.getName().toUpperCase(), column.getUUID(), column.getAnnotation()));
- }
- break;
- case ELEMENTPROPERTIES:
- for (ColumnRecordImpl column : table.getColumns()) {
- for (Map.Entry<String, String> entry : column.getProperties().entrySet()) {
- rows.add(Arrays.asList(table.getModelName(), table.getFullName(), column.getName(), entry.getKey(), entry.getValue(), table.getName(), column.getName().toUpperCase(),
- table.getName().toUpperCase(), column.getUUID()));
- }
- }
- break;
- case KEYS:
- for (KeyRecord key : table.getAllKeys()) {
- rows.add(Arrays.asList(table.getModelName(), table.getFullName(), key.getName(), key.getAnnotation(), key.getNameInSource(), key.getType().toString(),
- false, table.getName(), table.getName().toUpperCase(), (key instanceof ForeignKeyRecordImpl)?((ForeignKeyRecordImpl)key).getUniqueKeyID():null, key.getUUID()));
- }
- break;
- case KEYPROPERTIES:
- for (KeyRecord key : table.getAllKeys()) {
- for (Map.Entry<String, String> entry : key.getProperties().entrySet()) {
- rows.add(Arrays.asList(table.getModelName(), table.getFullName(), key.getName(), entry.getKey(), entry.getValue(), table.getName(), table.getName().toUpperCase(),
- key.getUUID()));
+ break;
+ case ELEMENTS:
+ for (Column column : table.getColumns()) {
+ if (column.getDatatype() == null) {
+ continue; //some mapping classes don't set the datatype
+ }
+ rows.add(Arrays.asList(table.getSchema().getName(), table.getName(), table.getFullName(), column.getName(), column.getPosition(), column.getNameInSource(),
+ column.getDatatype().getRuntimeTypeName(), column.getScale(), column.getLength(), column.isFixedLength(), column.isSelectable(), column.isUpdatable(),
+ column.isCaseSensitive(), column.isSigned(), column.isCurrency(), column.isAutoIncrementable(), column.getNullType().toString(), column.getMinValue(),
+ column.getMaxValue(), column.getSearchType().toString(), column.getFormat(), column.getDefaultValue(), column.getDatatype().getJavaClassName(), column.getPrecision(),
+ column.getCharOctetLength(), column.getRadix(), table.getName().toUpperCase(), column.getName().toUpperCase(), column.getUUID(), column.getAnnotation()));
}
- }
- break;
- case KEYELEMENTS:
- for (KeyRecord key : table.getAllKeys()) {
- int postition = 1;
- for (ColumnRecordImpl column : key.getColumns()) {
- rows.add(Arrays.asList(table.getModelName(), table.getFullName(), column.getName(), key.getName(), key.getType().toString(), table.getName(), table.getName().toUpperCase(),
- (key instanceof ForeignKeyRecordImpl)?((ForeignKeyRecordImpl)key).getUniqueKeyID():null, key.getUUID(), postition++));
+ break;
+ case ELEMENTPROPERTIES:
+ for (Column column : table.getColumns()) {
+ for (Map.Entry<String, String> entry : column.getProperties().entrySet()) {
+ rows.add(Arrays.asList(table.getSchema().getName(), table.getFullName(), column.getName(), entry.getKey(), entry.getValue(), table.getName(), column.getName().toUpperCase(),
+ table.getName().toUpperCase(), column.getUUID()));
+ }
}
- }
- break;
- case REFERENCEKEYCOLUMNS:
- for (ForeignKeyRecordImpl key : table.getForeignKeys()) {
- int postition = 0;
- for (ColumnRecordImpl column : key.getColumns()) {
- TableRecordImpl pkTable = key.getPrimaryKey().getTable();
- rows.add(Arrays.asList(null, vdbName, pkTable.getFullName(), key.getPrimaryKey().getColumns().get(postition).getName(), null, vdbName, table.getFullName(), column.getName(),
- ++postition, 3, 3, key.getName(), key.getPrimaryKey().getName(), 5));
+ break;
+ case KEYS:
+ for (KeyRecord key : table.getAllKeys()) {
+ rows.add(Arrays.asList(table.getSchema().getName(), table.getFullName(), key.getName(), key.getAnnotation(), key.getNameInSource(), key.getType().toString(),
+ false, table.getName(), table.getName().toUpperCase(), (key instanceof ForeignKey)?((ForeignKey)key).getUniqueKeyID():null, key.getUUID()));
}
+ break;
+ case KEYPROPERTIES:
+ for (KeyRecord key : table.getAllKeys()) {
+ for (Map.Entry<String, String> entry : key.getProperties().entrySet()) {
+ rows.add(Arrays.asList(table.getSchema().getName(), table.getFullName(), key.getName(), entry.getKey(), entry.getValue(), table.getName(), table.getName().toUpperCase(),
+ key.getUUID()));
+ }
+ }
+ break;
+ case KEYELEMENTS:
+ for (KeyRecord key : table.getAllKeys()) {
+ int postition = 1;
+ for (Column column : key.getColumns()) {
+ rows.add(Arrays.asList(table.getSchema().getName(), table.getFullName(), column.getName(), key.getName(), key.getType().toString(), table.getName(), table.getName().toUpperCase(),
+ (key instanceof ForeignKey)?((ForeignKey)key).getUniqueKeyID():null, key.getUUID(), postition++));
+ }
+ }
+ break;
+ case REFERENCEKEYCOLUMNS:
+ for (ForeignKey key : table.getForeignKeys()) {
+ int postition = 0;
+ for (Column column : key.getColumns()) {
+ Table pkTable = key.getPrimaryKey().getTable();
+ rows.add(Arrays.asList(null, vdbName, pkTable.getFullName(), key.getPrimaryKey().getColumns().get(postition).getName(), null, vdbName, table.getFullName(), column.getName(),
+ ++postition, 3, 3, key.getName(), key.getPrimaryKey().getName(), 5));
+ }
+ }
+ break;
}
- break;
}
}
}
Modified: trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -29,12 +29,12 @@
import java.util.List;
import java.util.Map;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
+import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.ModelRecordImpl;
+import org.teiid.connector.metadata.runtime.Schema;
import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
-import org.teiid.connector.metadata.runtime.TableRecordImpl.Type;
+import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.connector.metadata.runtime.Table.Type;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -56,28 +56,28 @@
this.metadataSource = metadataSource;
this.metadataStores = metadataStores;
for (MetadataStore metadataStore : metadataStores) {
- for (String model : metadataStore.getModels().keySet()) {
+ for (String model : metadataStore.getSchemas().keySet()) {
storeMap.put(model.toLowerCase(), metadataStore);
}
}
}
- public ModelRecordImpl getModel(String fullName)
+ public Schema getModel(String fullName)
throws QueryMetadataException, MetaMatrixComponentException {
- ModelRecordImpl result = getMetadataStore(fullName).getModels().get(fullName);
+ Schema result = getMetadataStore(fullName).getSchemas().get(fullName);
if (result == null) {
throw new QueryMetadataException(fullName+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
return result;
}
- public TableRecordImpl findGroup(String fullName)
+ public Table findGroup(String fullName)
throws QueryMetadataException {
List<String> tokens = StringUtil.getTokens(fullName, TransformationMetadata.DELIMITER_STRING);
if (tokens.size() < 2) {
throw new QueryMetadataException(fullName+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
- TableRecordImpl result = getMetadataStore(tokens.get(0)).getTables().get(fullName);
+ Table result = getMetadataStore(tokens.get(0)).getSchemas().get(tokens.get(0)).getTables().get(fullName);
if (result == null) {
throw new QueryMetadataException(fullName+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
@@ -87,9 +87,11 @@
public Collection<String> getGroupsForPartialName(String partialGroupName) {
List<String> result = new LinkedList<String>();
for (MetadataStore store : metadataStores) {
- for (Map.Entry<String, TableRecordImpl> entry : store.getTables().entrySet()) {
- if (entry.getKey().endsWith(partialGroupName)) {
- result.add(entry.getValue().getFullName());
+ for (Schema schema : store.getSchemas().values()) {
+ for (Map.Entry<String, Table> entry : schema.getTables().entrySet()) {
+ if (entry.getKey().endsWith(partialGroupName)) {
+ result.add(entry.getValue().getFullName());
+ }
}
}
}
@@ -103,7 +105,7 @@
if (tokens.size() < 2) {
throw new QueryMetadataException(fullyQualifiedProcedureName+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
- ProcedureRecordImpl result = getMetadataStore(tokens.get(0)).getProcedures().get(fullyQualifiedProcedureName);
+ ProcedureRecordImpl result = getMetadataStore(tokens.get(0)).getSchemas().get(tokens.get(0)).getProcedures().get(fullyQualifiedProcedureName);
if (result == null) {
throw new QueryMetadataException(fullyQualifiedProcedureName+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
@@ -130,13 +132,15 @@
* The next methods are hold overs from XML/UUID resolving and will perform poorly
*/
- public ColumnRecordImpl findElement(String elementName) throws QueryMetadataException {
+ public Column findElement(String elementName) throws QueryMetadataException {
if (StringUtil.startsWithIgnoreCase(elementName,UUID.PROTOCOL)) {
for (MetadataStore store : this.metadataStores) {
- for (TableRecordImpl table : store.getTables().values()) {
- for (ColumnRecordImpl column : table.getColumns()) {
- if (column.getUUID().equalsIgnoreCase(elementName)) {
- return column;
+ for (Schema schema : store.getSchemas().values()) {
+ for (Table table : schema.getTables().values()) {
+ for (Column column : table.getColumns()) {
+ if (column.getUUID().equalsIgnoreCase(elementName)) {
+ return column;
+ }
}
}
}
@@ -146,8 +150,8 @@
if (tokens.size() < 3) {
throw new QueryMetadataException(elementName+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
- TableRecordImpl table = findGroup(StringUtil.join(tokens.subList(0, tokens.size() - 1), TransformationMetadata.DELIMITER_STRING));
- for (ColumnRecordImpl column : table.getColumns()) {
+ Table table = findGroup(StringUtil.join(tokens.subList(0, tokens.size() - 1), TransformationMetadata.DELIMITER_STRING));
+ for (Column column : table.getColumns()) {
if (column.getFullName().equalsIgnoreCase(elementName)) {
return column;
}
@@ -156,13 +160,15 @@
throw new QueryMetadataException(elementName+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
- public Collection<TableRecordImpl> getXMLTempGroups(TableRecordImpl tableRecord) throws QueryMetadataException {
- ArrayList<TableRecordImpl> results = new ArrayList<TableRecordImpl>();
- MetadataStore store = getMetadataStore(tableRecord.getModelName().toLowerCase());
+ public Collection<Table> getXMLTempGroups(Table tableRecord) throws QueryMetadataException {
+ ArrayList<Table> results = new ArrayList<Table>();
+ MetadataStore store = getMetadataStore(tableRecord.getSchema().getName().toLowerCase());
String namePrefix = tableRecord.getFullName() + TransformationMetadata.DELIMITER_STRING;
- for (TableRecordImpl table : store.getTables().values()) {
- if (table.getTableType() == Type.XmlStagingTable && table.getName().startsWith(namePrefix)) {
- results.add(table);
+ for (Schema schema : store.getSchemas().values()) {
+ for (Table table : schema.getTables().values()) {
+ if (table.getTableType() == Type.XmlStagingTable && table.getName().startsWith(namePrefix)) {
+ results.add(table);
+ }
}
}
return results;
Modified: trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -36,18 +36,19 @@
import java.util.Properties;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
-import org.teiid.connector.metadata.runtime.ColumnSetRecordImpl;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
-import org.teiid.connector.metadata.runtime.ForeignKeyRecordImpl;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.ColumnSet;
+import org.teiid.connector.metadata.runtime.Datatype;
+import org.teiid.connector.metadata.runtime.ForeignKey;
import org.teiid.connector.metadata.runtime.KeyRecord;
-import org.teiid.connector.metadata.runtime.ModelRecordImpl;
-import org.teiid.connector.metadata.runtime.ProcedureParameterRecordImpl;
+import org.teiid.connector.metadata.runtime.Schema;
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
+import org.teiid.connector.metadata.runtime.SchemaObject;
+import org.teiid.connector.metadata.runtime.Table;
import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl.SearchType;
-import org.teiid.connector.metadata.runtime.ProcedureParameterRecordImpl.Type;
+import org.teiid.connector.metadata.runtime.Column.SearchType;
+import org.teiid.connector.metadata.runtime.ProcedureParameter.Type;
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.query.QueryMetadataException;
@@ -144,19 +145,13 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getModelID(java.lang.Object)
*/
public Object getModelID(final Object groupOrElementID) throws MetaMatrixComponentException, QueryMetadataException {
- if (!(groupOrElementID instanceof TableRecordImpl) && !(groupOrElementID instanceof ColumnRecordImpl)) {
+ if (!(groupOrElementID instanceof SchemaObject)) {
throw createInvalidRecordTypeException(groupOrElementID);
}
- String modelName = ((AbstractMetadataRecord)groupOrElementID).getModelName();
- return getModel(modelName);
+ return ((SchemaObject)groupOrElementID).getSchema();
}
- private Object getModel(String modelName) throws QueryMetadataException,
- MetaMatrixComponentException {
- return getMetadataStore().getModel(modelName.toLowerCase());
- }
-
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getFullName(java.lang.Object)
*/
@@ -215,19 +210,19 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInGroupID(java.lang.Object)
*/
public List getElementIDsInGroupID(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- return ((TableRecordImpl)groupID).getColumns();
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ return ((Table)groupID).getColumns();
}
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupIDForElementID(java.lang.Object)
*/
public Object getGroupIDForElementID(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- ColumnRecordImpl columnRecord = (ColumnRecordImpl) elementID;
+ if(elementID instanceof Column) {
+ Column columnRecord = (Column) elementID;
return this.getGroupID(getGroupName(columnRecord.getFullName()));
- } else if(elementID instanceof ProcedureParameterRecordImpl){
- ProcedureParameterRecordImpl columnRecord = (ProcedureParameterRecordImpl) elementID;
+ } else if(elementID instanceof ProcedureParameter){
+ ProcedureParameter columnRecord = (ProcedureParameter) elementID;
return this.getGroupID(getGroupName(columnRecord.getFullName()));
} else {
throw createInvalidRecordTypeException(elementID);
@@ -257,10 +252,10 @@
procInfo.setProcedureID(procRecord);
// modelID for the procedure
- procInfo.setModelID(getModel(procRecord.getModelName()));
+ procInfo.setModelID(procRecord.getSchema());
// get the parameter metadata info
- for (ProcedureParameterRecordImpl paramRecord : procRecord.getParameters()) {
+ for (ProcedureParameter paramRecord : procRecord.getParameters()) {
String runtimeType = paramRecord.getRuntimeType();
int direction = this.convertParamRecordTypeToStoredProcedureType(paramRecord.getType());
// create a parameter and add it to the procedure object
@@ -272,14 +267,14 @@
// if the procedure returns a resultSet, obtain resultSet metadata
if(procRecord.getResultSet() != null) {
- ColumnSetRecordImpl resultRecord = procRecord.getResultSet();
+ ColumnSet resultRecord = procRecord.getResultSet();
// resultSet is the last parameter in the procedure
int lastParamIndex = procInfo.getParameters().size() + 1;
SPParameter param = new SPParameter(lastParamIndex, SPParameter.RESULT_SET, resultRecord.getFullName());
param.setClassType(java.sql.ResultSet.class);
param.setMetadataID(resultRecord);
- for (ColumnRecordImpl columnRecord : resultRecord.getColumns()) {
+ for (Column columnRecord : resultRecord.getColumns()) {
String colType = columnRecord.getRuntimeType();
param.addResultSetColumn(columnRecord.getFullName(), DataTypeManager.getDataTypeClass(colType), columnRecord);
}
@@ -307,7 +302,7 @@
* @param parameterType
* @return
*/
- private int convertParamRecordTypeToStoredProcedureType(final ProcedureParameterRecordImpl.Type parameterType) {
+ private int convertParamRecordTypeToStoredProcedureType(final ProcedureParameter.Type parameterType) {
switch (parameterType) {
case In : return SPParameter.IN;
case Out : return SPParameter.OUT;
@@ -323,10 +318,10 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementType(java.lang.Object)
*/
public String getElementType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getRuntimeType();
- } else if(elementID instanceof ProcedureParameterRecordImpl){
- return ((ProcedureParameterRecordImpl) elementID).getRuntimeType();
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getRuntimeType();
+ } else if(elementID instanceof ProcedureParameter){
+ return ((ProcedureParameter) elementID).getRuntimeType();
} else {
throw createInvalidRecordTypeException(elementID);
}
@@ -336,19 +331,19 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getDefaultValue(java.lang.String)
*/
public Object getDefaultValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getDefaultValue();
- } else if(elementID instanceof ProcedureParameterRecordImpl){
- return ((ProcedureParameterRecordImpl) elementID).getDefaultValue();
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getDefaultValue();
+ } else if(elementID instanceof ProcedureParameter){
+ return ((ProcedureParameter) elementID).getDefaultValue();
} else {
throw createInvalidRecordTypeException(elementID);
}
}
public Object getMinimumValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getMinValue();
- } else if(elementID instanceof ProcedureParameterRecordImpl){
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getMinValue();
+ } else if(elementID instanceof ProcedureParameter){
return null;
} else {
throw createInvalidRecordTypeException(elementID);
@@ -356,9 +351,9 @@
}
public Object getMaximumValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getMaxValue();
- } else if(elementID instanceof ProcedureParameterRecordImpl){
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getMaxValue();
+ } else if(elementID instanceof ProcedureParameter){
return null;
} else {
throw createInvalidRecordTypeException(elementID);
@@ -369,8 +364,8 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#isVirtualGroup(java.lang.Object)
*/
public boolean isVirtualGroup(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- return ((TableRecordImpl) groupID).isVirtual();
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ return ((Table) groupID).isVirtual();
}
/**
@@ -381,25 +376,25 @@
if(groupID instanceof ProcedureRecordImpl) {
return true;
}
- if(groupID instanceof TableRecordImpl){
+ if(groupID instanceof Table){
return false;
}
throw createInvalidRecordTypeException(groupID);
}
public boolean isVirtualModel(final Object modelID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(ModelRecordImpl.class, modelID);
- ModelRecordImpl modelRecord = (ModelRecordImpl) modelID;
- return modelRecord.getModelType() == ModelRecordImpl.Type.Virtual;
+ ArgCheck.isInstanceOf(Schema.class, modelID);
+ Schema modelRecord = (Schema) modelID;
+ return !modelRecord.isPhysical();
}
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getVirtualPlan(java.lang.Object)
*/
public QueryNode getVirtualPlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
+ ArgCheck.isInstanceOf(Table.class, groupID);
- TableRecordImpl tableRecord = (TableRecordImpl) groupID;
+ Table tableRecord = (Table) groupID;
if (!tableRecord.isVirtual()) {
throw new QueryMetadataException(DQPPlugin.Util.getString("TransformationMetadata.QueryPlan_could_not_be_found_for_physical_group__6")+tableRecord.getFullName()); //$NON-NLS-1$
}
@@ -421,36 +416,36 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getInsertPlan(java.lang.Object)
*/
public String getInsertPlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- TableRecordImpl tableRecordImpl = (TableRecordImpl)groupID;
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ Table tableRecordImpl = (Table)groupID;
if (!tableRecordImpl.isVirtual()) {
throw new QueryMetadataException(DQPPlugin.Util.getString("TransformationMetadata.InsertPlan_could_not_be_found_for_physical_group__8")+tableRecordImpl.getFullName()); //$NON-NLS-1$
}
- return ((TableRecordImpl)groupID).getInsertPlan();
+ return ((Table)groupID).getInsertPlan();
}
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getUpdatePlan(java.lang.Object)
*/
public String getUpdatePlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- TableRecordImpl tableRecordImpl = (TableRecordImpl)groupID;
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ Table tableRecordImpl = (Table)groupID;
if (!tableRecordImpl.isVirtual()) {
throw new QueryMetadataException(DQPPlugin.Util.getString("TransformationMetadata.InsertPlan_could_not_be_found_for_physical_group__10")+tableRecordImpl.getFullName()); //$NON-NLS-1$
}
- return ((TableRecordImpl)groupID).getUpdatePlan();
+ return ((Table)groupID).getUpdatePlan();
}
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getDeletePlan(java.lang.Object)
*/
public String getDeletePlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- TableRecordImpl tableRecordImpl = (TableRecordImpl)groupID;
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ Table tableRecordImpl = (Table)groupID;
if (!tableRecordImpl.isVirtual()) {
throw new QueryMetadataException(DQPPlugin.Util.getString("TransformationMetadata.DeletePlan_could_not_be_found_for_physical_group__12")+tableRecordImpl.getFullName()); //$NON-NLS-1$
}
- return ((TableRecordImpl)groupID).getDeletePlan();
+ return ((Table)groupID).getDeletePlan();
}
/* (non-Javadoc)
@@ -458,7 +453,7 @@
*/
public boolean modelSupports(final Object modelID, final int modelConstant)
throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(ModelRecordImpl.class, modelID);
+ ArgCheck.isInstanceOf(Schema.class, modelID);
switch(modelConstant) {
default:
@@ -471,8 +466,8 @@
*/
public boolean groupSupports(final Object groupID, final int groupConstant)
throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- TableRecordImpl tableRecord = (TableRecordImpl) groupID;
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ Table tableRecord = (Table) groupID;
switch(groupConstant) {
case SupportConstants.Group.UPDATE:
@@ -488,8 +483,8 @@
public boolean elementSupports(final Object elementID, final int elementConstant)
throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- ColumnRecordImpl columnRecord = (ColumnRecordImpl) elementID;
+ if(elementID instanceof Column) {
+ Column columnRecord = (Column) elementID;
switch(elementConstant) {
case SupportConstants.Element.NULL:
return columnRecord.getNullType() == NullType.Nullable;
@@ -518,8 +513,8 @@
default:
throw new UnsupportedOperationException(DQPPlugin.Util.getString("TransformationMetadata.Unknown_support_constant___12") + elementConstant); //$NON-NLS-1$
}
- } else if(elementID instanceof ProcedureParameterRecordImpl) {
- ProcedureParameterRecordImpl columnRecord = (ProcedureParameterRecordImpl) elementID;
+ } else if(elementID instanceof ProcedureParameter) {
+ ProcedureParameter columnRecord = (ProcedureParameter) elementID;
switch(elementConstant) {
case SupportConstants.Element.NULL:
return columnRecord.getNullType() == NullType.Nullable;
@@ -561,7 +556,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaxSetSize(java.lang.Object)
*/
public int getMaxSetSize(final Object modelID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(ModelRecordImpl.class, modelID);
+ ArgCheck.isInstanceOf(Schema.class, modelID);
return 0;
}
@@ -569,8 +564,8 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getIndexesInGroup(java.lang.Object)
*/
public Collection getIndexesInGroup(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- return ((TableRecordImpl)groupID).getIndexes();
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ return ((Table)groupID).getIndexes();
}
/* (non-Javadoc)
@@ -578,9 +573,9 @@
*/
public Collection getUniqueKeysInGroup(final Object groupID)
throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- TableRecordImpl tableRecordImpl = (TableRecordImpl)groupID;
- ArrayList<ColumnSetRecordImpl> result = new ArrayList<ColumnSetRecordImpl>(tableRecordImpl.getUniqueKeys());
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ Table tableRecordImpl = (Table)groupID;
+ ArrayList<ColumnSet> result = new ArrayList<ColumnSet>(tableRecordImpl.getUniqueKeys());
if (tableRecordImpl.getPrimaryKey() != null) {
result.add(tableRecordImpl.getPrimaryKey());
}
@@ -597,8 +592,8 @@
*/
public Collection getForeignKeysInGroup(final Object groupID)
throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- return ((TableRecordImpl)groupID).getForeignKeys();
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ return ((Table)groupID).getForeignKeys();
}
/* (non-Javadoc)
@@ -606,8 +601,8 @@
*/
public Object getPrimaryKeyIDForForeignKeyID(final Object foreignKeyID)
throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(ForeignKeyRecordImpl.class, foreignKeyID);
- ForeignKeyRecordImpl fkRecord = (ForeignKeyRecordImpl) foreignKeyID;
+ ArgCheck.isInstanceOf(ForeignKey.class, foreignKeyID);
+ ForeignKey fkRecord = (ForeignKey) foreignKeyID;
return fkRecord.getPrimaryKey();
}
@@ -616,24 +611,24 @@
*/
public Collection getAccessPatternsInGroup(final Object groupID)
throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- return ((TableRecordImpl)groupID).getAccessPatterns();
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ return ((Table)groupID).getAccessPatterns();
}
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInIndex(java.lang.Object)
*/
public List getElementIDsInIndex(final Object index) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(ColumnSetRecordImpl.class, index);
- return ((ColumnSetRecordImpl)index).getColumns();
+ ArgCheck.isInstanceOf(ColumnSet.class, index);
+ return ((ColumnSet)index).getColumns();
}
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInKey(java.lang.Object)
*/
public List getElementIDsInKey(final Object key) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(ColumnSetRecordImpl.class, key);
- return ((ColumnSetRecordImpl)key).getColumns();
+ ArgCheck.isInstanceOf(ColumnSet.class, key);
+ return ((ColumnSet)key).getColumns();
}
/* (non-Javadoc)
@@ -641,18 +636,18 @@
*/
public List getElementIDsInAccessPattern(final Object accessPattern)
throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(ColumnSetRecordImpl.class, accessPattern);
- return ((ColumnSetRecordImpl)accessPattern).getColumns();
+ ArgCheck.isInstanceOf(ColumnSet.class, accessPattern);
+ return ((ColumnSet)accessPattern).getColumns();
}
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#isXMLGroup(java.lang.Object)
*/
public boolean isXMLGroup(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
+ ArgCheck.isInstanceOf(Table.class, groupID);
- TableRecordImpl tableRecord = (TableRecordImpl) groupID;
- return tableRecord.getTableType() == TableRecordImpl.Type.Document;
+ Table tableRecord = (Table) groupID;
+ return tableRecord.getTableType() == Table.Type.Document;
}
/**
@@ -661,8 +656,8 @@
*/
public boolean hasMaterialization(final Object groupID) throws MetaMatrixComponentException,
QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- TableRecordImpl tableRecord = (TableRecordImpl) groupID;
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ Table tableRecord = (Table) groupID;
return tableRecord.isMaterialized();
}
@@ -672,8 +667,8 @@
*/
public Object getMaterialization(final Object groupID) throws MetaMatrixComponentException,
QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- TableRecordImpl tableRecord = (TableRecordImpl) groupID;
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ Table tableRecord = (Table) groupID;
if(tableRecord.isMaterialized()) {
return tableRecord.getMaterializedTable();
}
@@ -686,8 +681,8 @@
*/
public Object getMaterializationStage(final Object groupID) throws MetaMatrixComponentException,
QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- TableRecordImpl tableRecord = (TableRecordImpl) groupID;
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ Table tableRecord = (Table) groupID;
if(tableRecord.isMaterialized()) {
return tableRecord.getMaterializedStageTable();
}
@@ -698,9 +693,9 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getMappingNode(java.lang.Object)
*/
public MappingNode getMappingNode(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
+ ArgCheck.isInstanceOf(Table.class, groupID);
- TableRecordImpl tableRecord = (TableRecordImpl) groupID;
+ Table tableRecord = (Table) groupID;
final String groupName = tableRecord.getFullName();
if(tableRecord.isVirtual()) {
// get mappin transform
@@ -735,10 +730,10 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getXMLTempGroups(java.lang.Object)
*/
public Collection getXMLTempGroups(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- TableRecordImpl tableRecord = (TableRecordImpl) groupID;
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ Table tableRecord = (Table) groupID;
- if(tableRecord.getTableType() == TableRecordImpl.Type.Document) {
+ if(tableRecord.getTableType() == Table.Type.Document) {
return this.store.getXMLTempGroups(tableRecord);
}
return Collections.EMPTY_SET;
@@ -748,8 +743,8 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getCardinality(java.lang.Object)
*/
public int getCardinality(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- return ((TableRecordImpl) groupID).getCardinality();
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ return ((Table) groupID).getCardinality();
}
/* (non-Javadoc)
@@ -757,8 +752,8 @@
*/
public List getXMLSchemas(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
- ArgCheck.isInstanceOf(TableRecordImpl.class, groupID);
- TableRecordImpl tableRecord = (TableRecordImpl) groupID;
+ ArgCheck.isInstanceOf(Table.class, groupID);
+ Table tableRecord = (Table) groupID;
// lookup transformation record for the group
String groupName = tableRecord.getFullName();
@@ -794,66 +789,66 @@
}
public int getElementLength(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getLength();
- } else if(elementID instanceof ProcedureParameterRecordImpl){
- return ((ProcedureParameterRecordImpl) elementID).getLength();
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getLength();
+ } else if(elementID instanceof ProcedureParameter){
+ return ((ProcedureParameter) elementID).getLength();
} else {
throw createInvalidRecordTypeException(elementID);
}
}
public int getPosition(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getPosition();
- } else if(elementID instanceof ProcedureParameterRecordImpl) {
- return ((ProcedureParameterRecordImpl) elementID).getPosition();
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getPosition();
+ } else if(elementID instanceof ProcedureParameter) {
+ return ((ProcedureParameter) elementID).getPosition();
} else {
throw createInvalidRecordTypeException(elementID);
}
}
public int getPrecision(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getPrecision();
- } else if(elementID instanceof ProcedureParameterRecordImpl) {
- return ((ProcedureParameterRecordImpl) elementID).getPrecision();
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getPrecision();
+ } else if(elementID instanceof ProcedureParameter) {
+ return ((ProcedureParameter) elementID).getPrecision();
} else {
throw createInvalidRecordTypeException(elementID);
}
}
public int getRadix(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getRadix();
- } else if(elementID instanceof ProcedureParameterRecordImpl) {
- return ((ProcedureParameterRecordImpl) elementID).getRadix();
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getRadix();
+ } else if(elementID instanceof ProcedureParameter) {
+ return ((ProcedureParameter) elementID).getRadix();
} else {
throw createInvalidRecordTypeException(elementID);
}
}
public String getFormat(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getFormat();
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getFormat();
}
throw createInvalidRecordTypeException(elementID);
}
public int getScale(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getScale();
- } else if(elementID instanceof ProcedureParameterRecordImpl) {
- return ((ProcedureParameterRecordImpl) elementID).getScale();
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getScale();
+ } else if(elementID instanceof ProcedureParameter) {
+ return ((ProcedureParameter) elementID).getScale();
} else {
throw createInvalidRecordTypeException(elementID);
}
}
public int getDistinctValues(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getDistinctValues();
- } else if(elementID instanceof ProcedureParameterRecordImpl) {
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getDistinctValues();
+ } else if(elementID instanceof ProcedureParameter) {
return -1;
} else {
throw createInvalidRecordTypeException(elementID);
@@ -861,9 +856,9 @@
}
public int getNullValues(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getNullValues();
- } else if(elementID instanceof ProcedureParameterRecordImpl) {
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getNullValues();
+ } else if(elementID instanceof ProcedureParameter) {
return -1;
} else {
throw createInvalidRecordTypeException(elementID);
@@ -871,9 +866,9 @@
}
public String getNativeType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- if(elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl) elementID).getNativeType();
- } else if(elementID instanceof ProcedureParameterRecordImpl) {
+ if(elementID instanceof Column) {
+ return ((Column) elementID).getNativeType();
+ } else if(elementID instanceof ProcedureParameter) {
return null;
} else {
throw createInvalidRecordTypeException(elementID);
@@ -935,7 +930,7 @@
* @since 5.0
*/
public String getModeledType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- DatatypeRecordImpl record = getDatatypeRecord(elementID);
+ Datatype record = getDatatypeRecord(elementID);
if (record != null) {
return record.getDatatypeID();
}
@@ -947,7 +942,7 @@
* @since 5.0
*/
public String getModeledBaseType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- DatatypeRecordImpl record = getDatatypeRecord(elementID);
+ Datatype record = getDatatypeRecord(elementID);
if (record != null) {
return record.getBasetypeID();
}
@@ -959,18 +954,18 @@
* @since 5.0
*/
public String getModeledPrimitiveType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
- DatatypeRecordImpl record = getDatatypeRecord(elementID);
+ Datatype record = getDatatypeRecord(elementID);
if (record != null) {
return record.getPrimitiveTypeID();
}
return null;
}
- private DatatypeRecordImpl getDatatypeRecord(final Object elementID) {
- if (elementID instanceof ColumnRecordImpl) {
- return ((ColumnRecordImpl)elementID).getDatatype();
- } else if (elementID instanceof ProcedureParameterRecordImpl) {
- return ((ProcedureParameterRecordImpl)elementID).getDatatype();
+ private Datatype getDatatypeRecord(final Object elementID) {
+ if (elementID instanceof Column) {
+ return ((Column)elementID).getDatatype();
+ } else if (elementID instanceof ProcedureParameter) {
+ return ((ProcedureParameter)elementID).getDatatype();
} else {
throw createInvalidRecordTypeException(elementID);
}
Modified: trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2009-11-18 15:26:22 UTC (rev 1571)
@@ -194,26 +194,22 @@
| <SQL_TSI_YEAR: "SQL_TSI_YEAR">
}
-TOKEN : /* User variables and literals */
+TOKEN : /* User variables and literals
+ - NOTE IDs are not spec compliant. We allow for
+ - any number of name parts to appear and restrict quoted
+ - IDs to continaing regular identifiers
+ */
{
- < ALL_IN_GROUP: (<GROUP_PART> | <MMUUID_PART>) <PERIOD> <STAR> >
+ < ALL_IN_GROUP: <GROUP_PART> <PERIOD> <STAR> >
-| < VARIABLE: <ID> | <MMUUID> >
+| < ID: <GROUP_PART> ( <PERIOD> <QUOTED_ID> )? >
-| < #ID: <GROUP_PART> // Group name
- ( (<PERIOD>|<SLASH>) (<QUOTED_ID> | <MMUUID_PART>) )? > // Element name extension
-
-| < #ELEMENT: <GROUP_PART> (<PERIOD>|<SLASH>) <QUOTED_ID> >
-| < #GROUP_PART: ("#")? (<QUOTED_ID> (<PERIOD>|<SLASH>))? <QUOTED_ID> >
+| < #GROUP_PART: ("#")? (<QUOTED_ID> <PERIOD>)? <QUOTED_ID> >
| < #QUOTED_ID: <DOTTED_ID> | ("\"" <DOTTED_ID> "\"") >
-| < #DOTTED_ID: <ID_PART> ((<PERIOD>|<SLASH>) <ID_PART>)* >
+| < #DOTTED_ID: <ID_PART> (<PERIOD> <ID_PART>)* >
| < #ID_PART: ("@")? <LETTER> (<ID_CHAR>)* >
| < #ID_CHAR: (<LETTER> | "_" | <DIGIT>) >
-| < #MMUUID: <MMUUID_PART> (<PERIOD> <MMUUID_PART>)? > // Modeler-only mmuuid formats
-| < #MMUUID_PART: "mmuuid:" (<MMUUID_CHAR>)* >
-| < #MMUUID_CHAR: ["a"-"f"] | ["0"-"9"] | "-">
-
| < DATETYPE: "{" "d" >
| < TIMETYPE: "{" "t" >
| < TIMESTAMPTYPE: "{" "ts" >
@@ -313,7 +309,7 @@
}
{
<DROP> <TABLE>
- tableToken = <VARIABLE>
+ tableToken = <ID>
{
drop.setTable(new GroupSymbol(validateMetadataID(tableToken.image)));
return drop;
@@ -334,7 +330,7 @@
}
{
<CREATE> <LOCAL> <TEMPORARY> <TABLE>
- tableToken = <VARIABLE>
+ tableToken = <ID>
<LPAREN>
{
create.setTable(new GroupSymbol(validateMetadataID(tableToken.image)));
@@ -511,7 +507,7 @@
query = queryExpression(info)
<RPAREN>
<AS>
- cursor = <VARIABLE>
+ cursor = <ID>
block = block(info)
{
@@ -583,14 +579,14 @@
[LOOKAHEAD(4)<ON>
<LPAREN>
- elementToken = <VARIABLE>
+ elementToken = <ID>
{
elements.add(new ElementSymbol(validateMetadataID(elementToken.image)));
}
(<COMMA>
- elementToken = <VARIABLE>
+ elementToken = <ID>
{
elements.add(new ElementSymbol(validateMetadataID(elementToken.image)));
@@ -643,7 +639,7 @@
{
<DECLARE>
type = dataType()
- varToken = <VARIABLE>
+ varToken = <ID>
{
variableID = new ElementSymbol(validateMetadataID(varToken.image));
}
@@ -669,7 +665,7 @@
}
{
- varToken = <VARIABLE>
+ varToken = <ID>
{
elementID = new ElementSymbol(validateMetadataID(varToken.image));
}
@@ -750,7 +746,7 @@
critList = new ArrayList();
}
<LPAREN>
- elementToken = <VARIABLE>
+ elementToken = <ID>
<EQ>
value = expression(info)
{
@@ -763,7 +759,7 @@
compCrit = null;
}
( <COMMA>
- elementToken = <VARIABLE>
+ elementToken = <ID>
<EQ>
value = expression(info)
{
@@ -838,7 +834,7 @@
elements = createElementsWithTypes(info)
[<INTO>
- groupToken = <VARIABLE>
+ groupToken = <ID>
{
String groupID = validateMetadataID(groupToken.image);
group = new GroupSymbol(groupID);
@@ -879,7 +875,7 @@
Token elementToken = null;
}
{
- elementToken = <VARIABLE>
+ elementToken = <ID>
<EQ>
{
String symbolName = shortName?validateElementName(elementToken.image):validateMetadataID(elementToken.image);
@@ -888,7 +884,7 @@
using.addClause(symbol, value);
}
(<COMMA>
- elementToken = <VARIABLE>
+ elementToken = <ID>
<EQ>
{
symbolName = shortName?validateElementName(elementToken.image):validateMetadataID(elementToken.image);
@@ -913,7 +909,7 @@
List elements = new ArrayList();
}
{
- elementToken = <VARIABLE>
+ elementToken = <ID>
type = dataType()
{
ElementSymbol symbol = new ElementSymbol(validateElementName(elementToken.image));
@@ -921,7 +917,7 @@
elements.add(symbol);
}
(<COMMA>
- elementToken = <VARIABLE>
+ elementToken = <ID>
type = dataType()
{
symbol = new ElementSymbol(validateElementName(elementToken.image));
@@ -952,13 +948,13 @@
storedProcedure.setParameter(parameter);
}
]
- call = <VARIABLE>
+ call = <ID>
{
if (!"call".equalsIgnoreCase(call.image)) { //$NON-NLS-1$
throw new ParseException(QueryPlugin.Util.getString("SQLParser.call_expected")); //$NON-NLS-1$
}
}
- procNameToken = <VARIABLE>
+ procNameToken = <ID>
{
storedProcedure.setProcedureName(procNameToken.image);
}
@@ -998,7 +994,7 @@
{
(
(<EXEC> | <EXECUTE>)
- procNameToken = <VARIABLE>
+ procNameToken = <ID>
{
storedProcedure.setProcedureName(procNameToken.image);
}
@@ -1007,7 +1003,7 @@
<LPAREN>
(
- LOOKAHEAD(<VARIABLE> <EQ>)
+ LOOKAHEAD(<ID> <EQ>)
storedProcedure = executeNamedParams(info, storedProcedure)
|
storedProcedure = executeUnnamedParams(info, storedProcedure, 1)
@@ -1113,7 +1109,7 @@
}
{
- t=<VARIABLE>
+ t=<ID>
{
parameterName = t.image;
@@ -1139,16 +1135,16 @@
}
{
<INSERT> <INTO>
- groupToken = <VARIABLE>
+ groupToken = <ID>
- [LOOKAHEAD(<LPAREN><VARIABLE>)
+ [LOOKAHEAD(<LPAREN><ID>)
<LPAREN>
- elementToken = <VARIABLE>
+ elementToken = <ID>
{
insert.addVariable(new ElementSymbol(validateMetadataID(elementToken.image)));
}
( <COMMA>
- elementToken = <VARIABLE>
+ elementToken = <ID>
{
insert.addVariable(new ElementSymbol(validateMetadataID(elementToken.image)));
}
@@ -1231,7 +1227,7 @@
}
{
<UPDATE>
- groupToken = <VARIABLE>
+ groupToken = <ID>
<SET>
setClauseList = setClauseList(false, info)
{
@@ -1271,7 +1267,7 @@
}
{
<DELETE> <FROM>
- groupToken = <VARIABLE>
+ groupToken = <ID>
[criteria = where(info)]
[option = option(info)
{
@@ -1407,7 +1403,7 @@
}
{
<INTO>
- (groupID=<VARIABLE>)
+ (groupID=<ID>)
{
into = new Into(new GroupSymbol(groupID.image));
return into;
@@ -1472,7 +1468,7 @@
// Expression
expression=expression(info)
)
- [[<AS>] ( aliasToken=<VARIABLE> |
+ [[<AS>] ( aliasToken=<ID> |
aliasToken=<STRINGVAL>
)
]
@@ -1744,7 +1740,7 @@
command = storedProcedure(info) )
<RPAREN>
[<AS>]
- aliasID = <VARIABLE>
+ aliasID = <ID>
{
clause = new SubqueryFromClause(validateAlias(aliasID.image), command);
@@ -1766,7 +1762,7 @@
UnaryFromClause clause = null;
}
{
- (groupID=<VARIABLE> [[<AS>] aliasID=<VARIABLE>])
+ (groupID=<ID> [[<AS>] aliasID=<ID>])
{
if(aliasID != null) {
group = new GroupSymbol(validateAlias(aliasID.image), validateMetadataID(groupID.image));
@@ -2287,7 +2283,7 @@
}
{
<ORDER> <BY>
- (id=<VARIABLE> | id=<STRINGVAL> | id=<INTEGERVAL>) [<ASC> | type=<DESC>]
+ (id=<ID> | id=<STRINGVAL> | id=<INTEGERVAL>) [<ASC> | type=<DESC>]
{
ascending = true;
if(type != null) {
@@ -2302,7 +2298,7 @@
}
}
(<COMMA>
- (id=<VARIABLE> | id=<STRINGVAL> | id=<INTEGERVAL>) [<ASC> | type=<DESC>]
+ (id=<ID> | id=<STRINGVAL> | id=<INTEGERVAL>) [<ASC> | type=<DESC>]
{
ascending = true;
if(type != null) {
@@ -2379,35 +2375,35 @@
debug = <DEBUG> |
<MAKEDEP>
- id=<VARIABLE>
+ id=<ID>
{
option.addDependentGroup(validateMetadataID(id.image));
}
(<COMMA>
- id=<VARIABLE>
+ id=<ID>
{
option.addDependentGroup(validateMetadataID(id.image));
}
)* |
<MAKENOTDEP>
- id=<VARIABLE>
+ id=<ID>
{
option.addNotDependentGroup(validateMetadataID(id.image));
}
(<COMMA>
- id=<VARIABLE>
+ id=<ID>
{
option.addNotDependentGroup(validateMetadataID(id.image));
}
)* |
nocache = <NOCACHE>
- [id=<VARIABLE>
+ [id=<ID>
{
option.addNoCacheGroup(validateMetadataID(id.image));
}
(<COMMA>
- id=<VARIABLE>
+ id=<ID>
{
option.addNoCacheGroup(validateMetadataID(id.image));
}
@@ -2596,7 +2592,7 @@
LOOKAHEAD(2) (expression=function(info))
|
// ElementSymbol
- (symbol=<VARIABLE>
+ (symbol=<ID>
{
// Check that this isn't actually a string expression. That
// is a possibility due to the token definitions where a
@@ -2841,7 +2837,7 @@
<RPAREN>
)
|
- ( funcToken = <VARIABLE>
+ ( funcToken = <ID>
{
funcName = validateFunctionName(funcToken.image);
}
Modified: trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeMetadataService.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -25,7 +25,7 @@
import java.util.HashMap;
import java.util.Map;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.metadata.CompositeMetadataStore;
import com.metamatrix.api.exception.MetaMatrixComponentException;
@@ -82,7 +82,7 @@
}
@Override
- public Map<String, DatatypeRecordImpl> getBuiltinDatatypes()
+ public Map<String, Datatype> getBuiltinDatatypes()
throws MetaMatrixComponentException {
return null;
}
Modified: trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -2805,111 +2805,6 @@
helpException("SELECT a from db.g where b like '#String' escape '#1'", "Parsing error: Like escape value must be a single character."); //$NON-NLS-1$ //$NON-NLS-2$
}
-
- // ==================== modeler literals ===========================
-
- /** Select mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0 From mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0 */
- public void testModelerID() {
- GroupSymbol g = new GroupSymbol("mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- ElementSymbol a = new ElementSymbol("mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0"); //$NON-NLS-1$
- select.addSymbol(a);
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("Select mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0 From mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0", //$NON-NLS-1$
- "SELECT mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0 FROM mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0", //$NON-NLS-1$
- query);
- }
-
- /** Select mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0.mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0 From mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0 */
- public void testModelerFullID() {
- GroupSymbol g = new GroupSymbol("mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- ElementSymbol a = new ElementSymbol("mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0.mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0"); //$NON-NLS-1$
- select.addSymbol(a);
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("Select mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0.mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0 From mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0", //$NON-NLS-1$
- "SELECT mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0.mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0 FROM mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0", //$NON-NLS-1$
- query);
-
- }
-
- /** Select a.mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0 From mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0 as a */
- public void testModelerAliasElement() {
- GroupSymbol g = new GroupSymbol("a", "mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0"); //$NON-NLS-1$ //$NON-NLS-2$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- ElementSymbol a = new ElementSymbol("a.mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0"); //$NON-NLS-1$
- select.addSymbol(a);
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("Select a.mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0 From mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0 as a", //$NON-NLS-1$
- "SELECT a.mmuuid:abcf22c0-3236-1dfa-9931-e83d04ce10a0 FROM mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0 AS a", //$NON-NLS-1$
- query);
-
- }
-
- /** Select mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0.* From mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0 */
- public void testModelerGroupStar() {
- GroupSymbol g = new GroupSymbol("mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- AllInGroupSymbol a = new AllInGroupSymbol("mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0.*"); //$NON-NLS-1$
- select.addSymbol(a);
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
-
- helpTest("Select mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0.* From mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0", //$NON-NLS-1$
- "SELECT mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0.* FROM mmuuid:345f22c0-3236-1dfa-9931-e83d04ce10a0", //$NON-NLS-1$
- query);
-
- }
-
- /** SELECT * FROM mmuuid:66f628c1-3455-1dfa-9931-e83d04ce10a0 ORDER BY mmuuid:66f628c2-3455-1dfa-9931-e83d04ce10a0 */
- public void testModelerOrderBy() {
- GroupSymbol g = new GroupSymbol("mmuuid:66f628c1-3455-1dfa-9931-e83d04ce10a0"); //$NON-NLS-1$
- From from = new From();
- from.addGroup(g);
-
- Select select = new Select();
- select.addSymbol(new AllSymbol());
-
- OrderBy orderBy = new OrderBy();
- orderBy.addVariable(new ElementSymbol("mmuuid:66f628c2-3455-1dfa-9931-e83d04ce10a0")); //$NON-NLS-1$
-
- Query query = new Query();
- query.setSelect(select);
- query.setFrom(from);
- query.setOrderBy(orderBy);
-
- helpTest("SELECT * FROM mmuuid:66f628c1-3455-1dfa-9931-e83d04ce10a0 ORDER BY mmuuid:66f628c2-3455-1dfa-9931-e83d04ce10a0", //$NON-NLS-1$
- "SELECT * FROM mmuuid:66f628c1-3455-1dfa-9931-e83d04ce10a0 ORDER BY mmuuid:66f628c2-3455-1dfa-9931-e83d04ce10a0", //$NON-NLS-1$
- query);
-
- }
-
/** SELECT "date"."time" from db.g */
public void testReservedWordsInElement() {
GroupSymbol g = new GroupSymbol("db.g"); //$NON-NLS-1$
@@ -6464,7 +6359,7 @@
/** QUERY Tool Format*/
public void testQueryWithQuotes_MSQuery() throws Exception {
- QueryParser.getQueryParser().parseCommand("SELECT \"PART_COLOR\", \"PART_ID\", \"PART_NAME\", \"PART_WEIGHT\" FROM \"VirtualParts/base\".\"Parts\""); //$NON-NLS-1$
+ QueryParser.getQueryParser().parseCommand("SELECT \"PART_COLOR\", \"PART_ID\", \"PART_NAME\", \"PART_WEIGHT\" FROM \"VirtualParts.base\".\"Parts\""); //$NON-NLS-1$
}
/** MS Query Format **/
@@ -6474,17 +6369,17 @@
/** MS Access Format**/
public void testQueryWithQuotes_MSAccess() throws Exception {
- QueryParser.getQueryParser().parseCommand("SELECT \"PART_COLOR\" ,\"PART_ID\" ,\"PART_NAME\" ,\"PART_WEIGHT\" FROM \"parts_oracle/DEV_RRAMESH\".\"PARTS\""); //$NON-NLS-1$
+ QueryParser.getQueryParser().parseCommand("SELECT \"PART_COLOR\" ,\"PART_ID\" ,\"PART_NAME\" ,\"PART_WEIGHT\" FROM \"parts_oracle.DEV_RRAMESH\".\"PARTS\""); //$NON-NLS-1$
}
/** BO Business View Manager**/
public void testQueryWithQuotes_BODesigner() throws Exception {
- QueryParser.getQueryParser().parseCommand("SELECT DISTINCT \"PARTS\".\"PART_NAME\" FROM \"parts_oracle/DEV_RRAMESH\".\"PARTS\" \"PARTS\""); //$NON-NLS-1$
+ QueryParser.getQueryParser().parseCommand("SELECT DISTINCT \"PARTS\".\"PART_NAME\" FROM \"parts_oracle.DEV_RRAMESH\".\"PARTS\" \"PARTS\""); //$NON-NLS-1$
}
/** Crystal Reports **/
public void testQueryWithQuotes_CrystalReports() throws Exception {
- QueryParser.getQueryParser().parseCommand("SELECT \"Oracle_PARTS\".\"PART_COLOR\", \"Oracle_PARTS\".\"PART_ID\", \"Oracle_PARTS\".\"PART_NAME\", \"Oracle_PARTS\".\"PART_WEIGHT\", \"SQL_PARTS\".\"PART_COLOR\", \"SQL_PARTS\".\"PART_ID\", \"SQL_PARTS\".\"PART_NAME\", \"SQL_PARTS\".\"PART_WEIGHT\" FROM \"parts_oracle/DEV_RRAMESH\".\"PARTS\" \"Oracle_PARTS\", \"parts_sqlserver/dv_rreddy/dv_rreddy\".\"PARTS\" \"SQL_PARTS\" WHERE (\"Oracle_PARTS\".\"PART_ID\"=\"SQL_PARTS\".\"PART_ID\")"); //$NON-NLS-1$
+ QueryParser.getQueryParser().parseCommand("SELECT \"Oracle_PARTS\".\"PART_COLOR\", \"Oracle_PARTS\".\"PART_ID\", \"Oracle_PARTS\".\"PART_NAME\", \"Oracle_PARTS\".\"PART_WEIGHT\", \"SQL_PARTS\".\"PART_COLOR\", \"SQL_PARTS\".\"PART_ID\", \"SQL_PARTS\".\"PART_NAME\", \"SQL_PARTS\".\"PART_WEIGHT\" FROM \"parts_oracle.DEV_RRAMESH\".\"PARTS\" \"Oracle_PARTS\", \"parts_sqlserver.dv_rreddy.dv_rreddy\".\"PARTS\" \"SQL_PARTS\" WHERE (\"Oracle_PARTS\".\"PART_ID\"=\"SQL_PARTS\".\"PART_ID\")"); //$NON-NLS-1$
}
public void testOrderByWithNumbers_InQuotes() throws Exception {
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -33,16 +33,16 @@
import java.util.Map;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
-import org.teiid.connector.metadata.runtime.ColumnSetRecordImpl;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
-import org.teiid.connector.metadata.runtime.ForeignKeyRecordImpl;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.ColumnSet;
+import org.teiid.connector.metadata.runtime.Datatype;
+import org.teiid.connector.metadata.runtime.ForeignKey;
import org.teiid.connector.metadata.runtime.KeyRecord;
import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.ModelRecordImpl;
-import org.teiid.connector.metadata.runtime.ProcedureParameterRecordImpl;
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
+import org.teiid.connector.metadata.runtime.Schema;
+import org.teiid.connector.metadata.runtime.Table;
import org.teiid.core.index.IEntryResult;
import org.teiid.internal.core.index.Index;
import org.teiid.metadata.TransformationMetadata;
@@ -61,10 +61,10 @@
public class IndexMetadataFactory {
private Index[] indexes;
- private Map<String, DatatypeRecordImpl> datatypeCache;
+ private Map<String, Datatype> datatypeCache;
private Map<String, KeyRecord> primaryKeyCache = new HashMap<String, KeyRecord>();
- private Map<String, TableRecordImpl> tableCache = new HashMap<String, TableRecordImpl>();
- private MetadataStore store = new MetadataStore();
+ private Map<String, Table> tableCache = new HashMap<String, Table>();
+ private MetadataStore store = new MetadataStore();
public IndexMetadataFactory(MetadataSource source) throws IOException {
ArrayList<Index> tmp = new ArrayList<Index>();
@@ -86,19 +86,19 @@
}
public void getModels() {
- Collection<ModelRecordImpl> records = findMetadataRecords(MetadataConstants.RECORD_TYPE.MODEL, null, false);
- for (ModelRecordImpl modelRecord : records) {
- store.addModel(modelRecord);
+ Collection<Schema> records = findMetadataRecords(MetadataConstants.RECORD_TYPE.MODEL, null, false);
+ for (Schema modelRecord : records) {
+ store.addSchema(modelRecord);
}
}
public void getTables() {
- for (ModelRecordImpl model : store.getModels().values()) {
- List<TableRecordImpl> records = findMetadataRecords(MetadataConstants.RECORD_TYPE.TABLE, model.getName() + IndexConstants.NAME_DELIM_CHAR + IndexConstants.RECORD_STRING.MATCH_CHAR, true);
+ for (Schema model : store.getSchemas().values()) {
+ List<Table> records = findMetadataRecords(MetadataConstants.RECORD_TYPE.TABLE, model.getName() + IndexConstants.NAME_DELIM_CHAR + IndexConstants.RECORD_STRING.MATCH_CHAR, true);
//load non-materialized first, so that the uuid->table cache is populated
- Collections.sort(records, new Comparator<TableRecordImpl>() {
+ Collections.sort(records, new Comparator<Table>() {
@Override
- public int compare(TableRecordImpl o1, TableRecordImpl o2) {
+ public int compare(Table o1, Table o2) {
if (!o1.isMaterialized()) {
return -1;
}
@@ -108,17 +108,17 @@
return 0;
}
});
- for (TableRecordImpl tableRecord : records) {
+ for (Table tableRecord : records) {
tableCache.put(tableRecord.getUUID(), tableRecord);
- List<ColumnRecordImpl> columns = new ArrayList<ColumnRecordImpl>(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.COLUMN));
- for (ColumnRecordImpl columnRecordImpl : columns) {
+ List<Column> columns = new ArrayList<Column>(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.COLUMN));
+ for (Column columnRecordImpl : columns) {
columnRecordImpl.setDatatype(getDatatypeCache().get(columnRecordImpl.getDatatypeUUID()));
}
Collections.sort(columns);
tableRecord.setColumns(columns);
tableRecord.setAccessPatterns(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.ACCESS_PATTERN));
- Map<String, ColumnRecordImpl> uuidColumnMap = new HashMap<String, ColumnRecordImpl>();
- for (ColumnRecordImpl columnRecordImpl : columns) {
+ Map<String, Column> uuidColumnMap = new HashMap<String, Column>();
+ for (Column columnRecordImpl : columns) {
uuidColumnMap.put(columnRecordImpl.getUUID(), columnRecordImpl);
}
for (KeyRecord columnSetRecordImpl : tableRecord.getAccessPatterns()) {
@@ -126,7 +126,7 @@
columnSetRecordImpl.setTable(tableRecord);
}
tableRecord.setForiegnKeys(findChildRecords(tableRecord, MetadataConstants.RECORD_TYPE.FOREIGN_KEY));
- for (ForeignKeyRecordImpl foreignKeyRecord : tableRecord.getForeignKeys()) {
+ for (ForeignKey foreignKeyRecord : tableRecord.getForeignKeys()) {
foreignKeyRecord.setPrimaryKey(getPrimaryKey(foreignKeyRecord.getUniqueKeyID()));
loadColumnSetRecords(foreignKeyRecord, uuidColumnMap);
foreignKeyRecord.setTable(tableRecord);
@@ -177,7 +177,7 @@
tableRecord.setMaterializedStageTable(tableCache.get(tableRecord.getMaterializedStageTable().getUUID()));
tableRecord.setMaterializedTable(tableCache.get(tableRecord.getMaterializedTable().getUUID()));
}
- store.addTable(tableRecord);
+ model.addTable(tableRecord);
}
}
}
@@ -191,11 +191,11 @@
return pk;
}
- public Map<String, DatatypeRecordImpl> getDatatypeCache() {
+ public Map<String, Datatype> getDatatypeCache() {
if (this.datatypeCache == null) {
- this.datatypeCache = new HashMap<String, DatatypeRecordImpl>();
- Collection<DatatypeRecordImpl> dataTypes = findMetadataRecords(MetadataConstants.RECORD_TYPE.DATATYPE, null, false);
- for (DatatypeRecordImpl datatypeRecordImpl : dataTypes) {
+ this.datatypeCache = new HashMap<String, Datatype>();
+ Collection<Datatype> dataTypes = findMetadataRecords(MetadataConstants.RECORD_TYPE.DATATYPE, null, false);
+ for (Datatype datatypeRecordImpl : dataTypes) {
datatypeCache.put(datatypeRecordImpl.getUUID(), datatypeRecordImpl);
this.store.addDatatype(datatypeRecordImpl);
}
@@ -203,8 +203,8 @@
return datatypeCache;
}
- private ColumnRecordImpl findElement(String fullName) {
- ColumnRecordImpl columnRecord = (ColumnRecordImpl)getRecordByType(fullName, MetadataConstants.RECORD_TYPE.COLUMN);
+ private Column findElement(String fullName) {
+ Column columnRecord = (Column)getRecordByType(fullName, MetadataConstants.RECORD_TYPE.COLUMN);
columnRecord.setDatatype(getDatatypeCache().get(columnRecord.getDatatypeUUID()));
return columnRecord;
}
@@ -233,21 +233,21 @@
}
public void getProcedures() {
- for (ModelRecordImpl model : store.getModels().values()) {
+ for (Schema model : store.getSchemas().values()) {
Collection<ProcedureRecordImpl> procedureRecordImpls = findMetadataRecords(MetadataConstants.RECORD_TYPE.CALLABLE, model.getName() + IndexConstants.NAME_DELIM_CHAR + IndexConstants.RECORD_STRING.MATCH_CHAR, true);
for (ProcedureRecordImpl procedureRecord : procedureRecordImpls) {
- procedureRecord.setParameters(new ArrayList<ProcedureParameterRecordImpl>(procedureRecord.getParameterIDs().size()));
+ procedureRecord.setParameters(new ArrayList<ProcedureParameter>(procedureRecord.getParameterIDs().size()));
// get the parameter metadata info
for (String paramID : procedureRecord.getParameterIDs()) {
- ProcedureParameterRecordImpl paramRecord = (ProcedureParameterRecordImpl) this.getRecordByType(paramID, MetadataConstants.RECORD_TYPE.CALLABLE_PARAMETER);
+ ProcedureParameter paramRecord = (ProcedureParameter) this.getRecordByType(paramID, MetadataConstants.RECORD_TYPE.CALLABLE_PARAMETER);
paramRecord.setDatatype(getDatatypeCache().get(paramRecord.getDatatypeUUID()));
procedureRecord.getParameters().add(paramRecord);
}
String resultID = procedureRecord.getResultSetID();
if(resultID != null) {
- ColumnSetRecordImpl resultRecord = (ColumnSetRecordImpl) getRecordByType(resultID, MetadataConstants.RECORD_TYPE.RESULT_SET, false);
+ ColumnSet resultRecord = (ColumnSet) getRecordByType(resultID, MetadataConstants.RECORD_TYPE.RESULT_SET, false);
if (resultRecord != null) {
loadColumnSetRecords(resultRecord, null);
procedureRecord.setResultSet(resultRecord);
@@ -265,7 +265,7 @@
procedureRecord.setQueryPlan(transformRecord.getTransformation());
}
}
- store.addProcedure(procedureRecord);
+ model.addProcedure(procedureRecord);
}
}
}
@@ -286,7 +286,7 @@
return loadRecords(results);
}
- private void loadColumnSetRecords(ColumnSetRecordImpl indexRecord, Map<String, ColumnRecordImpl> columns) {
+ private void loadColumnSetRecords(ColumnSet indexRecord, Map<String, Column> columns) {
for (int i = 0; i < indexRecord.getColumns().size(); i++) {
String uuid = indexRecord.getColumns().get(i).getUUID();
if (columns != null) {
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -29,18 +29,18 @@
import java.util.List;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl;
-import org.teiid.connector.metadata.runtime.ColumnSetRecordImpl;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
-import org.teiid.connector.metadata.runtime.ForeignKeyRecordImpl;
+import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.connector.metadata.runtime.ColumnSet;
+import org.teiid.connector.metadata.runtime.Datatype;
+import org.teiid.connector.metadata.runtime.ForeignKey;
import org.teiid.connector.metadata.runtime.KeyRecord;
-import org.teiid.connector.metadata.runtime.ModelRecordImpl;
-import org.teiid.connector.metadata.runtime.ProcedureParameterRecordImpl;
+import org.teiid.connector.metadata.runtime.Schema;
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
import org.teiid.connector.metadata.runtime.ProcedureRecordImpl;
-import org.teiid.connector.metadata.runtime.TableRecordImpl;
+import org.teiid.connector.metadata.runtime.Table;
import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.ColumnRecordImpl.SearchType;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl.Variety;
+import org.teiid.connector.metadata.runtime.Column.SearchType;
+import org.teiid.connector.metadata.runtime.Datatype.Variety;
import org.teiid.core.index.IEntryResult;
import org.teiid.internal.core.index.EntryResult;
import org.teiid.internal.core.index.IIndexConstants;
@@ -177,7 +177,7 @@
case MetadataConstants.RECORD_TYPE.COLUMN: return createColumnRecord(record);
case MetadataConstants.RECORD_TYPE.ACCESS_PATTERN: return createColumnSetRecord(record, new KeyRecord(KeyRecord.Type.AccessPattern));
case MetadataConstants.RECORD_TYPE.INDEX: return createColumnSetRecord(record, new KeyRecord(KeyRecord.Type.Index));
- case MetadataConstants.RECORD_TYPE.RESULT_SET: return createColumnSetRecord(record, new ColumnSetRecordImpl());
+ case MetadataConstants.RECORD_TYPE.RESULT_SET: return createColumnSetRecord(record, new ColumnSet());
case MetadataConstants.RECORD_TYPE.UNIQUE_KEY: return createColumnSetRecord(record, new KeyRecord(KeyRecord.Type.Unique));
case MetadataConstants.RECORD_TYPE.PRIMARY_KEY: return createColumnSetRecord(record, new KeyRecord(KeyRecord.Type.Primary));
case MetadataConstants.RECORD_TYPE.FOREIGN_KEY: return createForeignKeyRecord(record);
@@ -309,10 +309,10 @@
/**
* Create a ModelRecord instance from the specified index record
*/
- public static ModelRecordImpl createModelRecord(final char[] record) {
+ public static Schema createModelRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
- final ModelRecordImpl model = new ModelRecordImpl();
+ final Schema model = new Schema();
// The tokens are the standard header values
int tokenIndex = 0;
@@ -324,7 +324,7 @@
tokenIndex++;
// The next token is the model type
- model.setModelType(ModelRecordImpl.Type.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
+ model.setPhysical(Integer.parseInt((String)tokens.get(tokenIndex++)) == 0);
// The next token is the primary metamodel Uri
model.setPrimaryMetamodelUri(getObjectValue((String)tokens.get(tokenIndex++)));
@@ -394,10 +394,10 @@
/**
* Create a TableRecord instance from the specified index record
*/
- public static TableRecordImpl createTableRecord(final char[] record) {
+ public static Table createTableRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
- final TableRecordImpl table = new TableRecordImpl();
+ final Table table = new Table();
// Extract the index version information from the record
int indexVersion = getIndexVersion(record);
@@ -412,7 +412,7 @@
table.setCardinality( Integer.parseInt((String)tokens.get(tokenIndex++)) );
// The next token is the tableType
- table.setTableType(TableRecordImpl.Type.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
+ table.setTableType(Table.Type.values()[Integer.parseInt((String)tokens.get(tokenIndex++))]);
// The next token are the supports flags
char[] supportFlags = ((String)tokens.get(tokenIndex++)).toCharArray();
@@ -438,11 +438,11 @@
if(includeMaterializationFlag(indexVersion)) {
// The next token are the UUIDs for the materialized table ID
- TableRecordImpl matTable = new TableRecordImpl();
+ Table matTable = new Table();
matTable.setUUID((String)tokens.get(tokenIndex++));
table.setMaterializedTable(matTable);
// The next token are the UUID for the materialized stage table ID
- matTable = new TableRecordImpl();
+ matTable = new Table();
matTable.setUUID((String)tokens.get(tokenIndex++));
table.setMaterializedStageTable(matTable);
}
@@ -453,10 +453,10 @@
return table;
}
- private static List<ColumnRecordImpl> createColumns(List<String> uuids) {
- List<ColumnRecordImpl> columns = new ArrayList<ColumnRecordImpl>(uuids.size());
+ private static List<Column> createColumns(List<String> uuids) {
+ List<Column> columns = new ArrayList<Column>(uuids.size());
for (String uuid : uuids) {
- ColumnRecordImpl column = new ColumnRecordImpl();
+ Column column = new Column();
column.setUUID(uuid);
columns.add(column);
}
@@ -466,10 +466,10 @@
/**
* Create a ColumnRecord instance from the specified index record
*/
- public static ColumnRecordImpl createColumnRecord(final char[] record) {
+ public static Column createColumnRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
- final ColumnRecordImpl column = new ColumnRecordImpl();
+ final Column column = new Column();
// Extract the index version information from the record
int indexVersion = getIndexVersion(record);
@@ -553,7 +553,7 @@
/**
* Create a ColumnSetRecord instance from the specified index record
*/
- public static ColumnSetRecordImpl createColumnSetRecord(final char[] record, ColumnSetRecordImpl columnSet) {
+ public static ColumnSet createColumnSetRecord(final char[] record, ColumnSet columnSet) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
@@ -583,10 +583,10 @@
/**
* Create a ForeignKeyRecord instance from the specified index record
*/
- public static ForeignKeyRecordImpl createForeignKeyRecord(final char[] record) {
+ public static ForeignKey createForeignKeyRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
- final ForeignKeyRecordImpl fkRecord = new ForeignKeyRecordImpl();
+ final ForeignKey fkRecord = new ForeignKey();
// Extract the index version information from the record
int indexVersion = getIndexVersion(record);
@@ -613,10 +613,10 @@
/**
* Create a DatatypeRecord instance from the specified index record
*/
- public static DatatypeRecordImpl createDatatypeRecord(final char[] record) {
+ public static Datatype createDatatypeRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
- final DatatypeRecordImpl dt = new DatatypeRecordImpl();
+ final Datatype dt = new Datatype();
// Extract the index version information from the record
int indexVersion = getIndexVersion(record);
@@ -645,7 +645,7 @@
dt.setJavaClassName(getObjectValue((String)tokens.get(tokenIndex++)));
// Set the datatype type
- dt.setType(DatatypeRecordImpl.Type.values()[Short.parseShort((String)tokens.get(tokenIndex++))]);
+ dt.setType(Datatype.Type.values()[Short.parseShort((String)tokens.get(tokenIndex++))]);
// Set the search type
dt.setSearchType(SearchType.values()[3 - Integer.parseInt((String)tokens.get(tokenIndex++))]);
@@ -731,11 +731,11 @@
* Create a ProcedureParameterRecord instance from the specified index record
* header|defaultValue|dataType|length|radix|scale|nullType|precision|paramType|footer|
*/
- public static ProcedureParameterRecordImpl createProcedureParameterRecord(final char[] record) {
+ public static ProcedureParameter createProcedureParameterRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
- final ProcedureParameterRecordImpl paramRd = new ProcedureParameterRecordImpl();
+ final ProcedureParameter paramRd = new ProcedureParameter();
// The tokens are the standard header values
int tokenIndex = 0;
@@ -773,22 +773,22 @@
paramRd.setPosition(Integer.parseInt((String)tokens.get(tokenIndex++)) );
// The next token is parameter type
- ProcedureParameterRecordImpl.Type type = null;
+ ProcedureParameter.Type type = null;
switch (Short.parseShort((String)tokens.get(tokenIndex++))) {
case MetadataConstants.PARAMETER_TYPES.IN_PARM:
- type = ProcedureParameterRecordImpl.Type.In;
+ type = ProcedureParameter.Type.In;
break;
case MetadataConstants.PARAMETER_TYPES.INOUT_PARM:
- type = ProcedureParameterRecordImpl.Type.InOut;
+ type = ProcedureParameter.Type.InOut;
break;
case MetadataConstants.PARAMETER_TYPES.OUT_PARM:
- type = ProcedureParameterRecordImpl.Type.Out;
+ type = ProcedureParameter.Type.Out;
break;
case MetadataConstants.PARAMETER_TYPES.RESULT_SET:
- type = ProcedureParameterRecordImpl.Type.ResultSet;
+ type = ProcedureParameter.Type.ResultSet;
break;
case MetadataConstants.PARAMETER_TYPES.RETURN_VALUE:
- type = ProcedureParameterRecordImpl.Type.ReturnValue;
+ type = ProcedureParameter.Type.ReturnValue;
break;
}
paramRd.setType(type);
@@ -1012,16 +1012,17 @@
record.setUUID(getObjectValue(objectID));
if (fullName != null) {
- int index = fullName.indexOf(IndexConstants.NAME_DELIM_CHAR);
- String name = fullName;
- if (index > 0) {
- name = fullName.substring(index + 1);
- }
- if (record instanceof ColumnRecordImpl) {
- index = fullName.indexOf(IndexConstants.NAME_DELIM_CHAR);
+ String name = fullName;
+ if (record instanceof Column) { //take only the last part
+ int index = fullName.lastIndexOf(IndexConstants.NAME_DELIM_CHAR);
if (index > 0) {
name = fullName.substring(index + 1);
}
+ } else { //remove model name
+ int index = fullName.indexOf(IndexConstants.NAME_DELIM_CHAR);
+ if (index > 0) {
+ name = fullName.substring(index + 1);
+ }
}
record.setName(name);
}
Modified: trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeMetadataService.java
===================================================================
--- trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeMetadataService.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/metadata/src/test/java/com/metamatrix/metadata/runtime/FakeMetadataService.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -28,7 +28,7 @@
import java.util.Map;
import java.util.Properties;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.metadata.CompositeMetadataStore;
import org.teiid.metadata.TransformationMetadata;
import org.teiid.metadata.index.IndexMetadataFactory;
@@ -79,7 +79,7 @@
}
@Override
- public Map<String, DatatypeRecordImpl> getBuiltinDatatypes()
+ public Map<String, Datatype> getBuiltinDatatypes()
throws MetaMatrixComponentException {
return null;
}
Modified: trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java
===================================================================
--- trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java 2009-11-17 19:07:47 UTC (rev 1570)
+++ trunk/runtime/src/main/java/com/metamatrix/dqp/embedded/services/EmbeddedMetadataService.java 2009-11-18 15:26:22 UTC (rev 1571)
@@ -38,7 +38,7 @@
import java.util.Properties;
import java.util.Set;
-import org.teiid.connector.metadata.runtime.DatatypeRecordImpl;
+import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.metadata.CompositeMetadataStore;
import org.teiid.metadata.TransformationMetadata;
@@ -205,11 +205,11 @@
return null;
}
- public Map<String, DatatypeRecordImpl> getBuiltinDatatypes() {
- Collection<DatatypeRecordImpl> datatypes = this.systemMetadataStore.getDatatypes();
- Map<String, DatatypeRecordImpl> datatypeMap = new HashMap<String, DatatypeRecordImpl>();
+ public Map<String, Datatype> getBuiltinDatatypes() {
+ Collection<Datatype> datatypes = this.systemMetadataStore.getDatatypes();
+ Map<String, Datatype> datatypeMap = new HashMap<String, Datatype>();
for (Class<?> typeClass : DataTypeManager.getAllDataTypeClasses()) {
- for (DatatypeRecordImpl datatypeRecordImpl : datatypes) {
+ for (Datatype datatypeRecordImpl : datatypes) {
if (datatypeRecordImpl.getJavaClassName().equals(typeClass.getName())) {
datatypeMap.put(DataTypeManager.getDataTypeName(typeClass), datatypeRecordImpl);
break;
15 years, 1 month
teiid SVN: r1570 - in branches/JCA: build/assembly/jboss-container and 9 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-11-17 14:07:47 -0500 (Tue, 17 Nov 2009)
New Revision: 1570
Removed:
branches/JCA/build/kit-jboss-container/conf/jboss-cache-configuration.xml
Modified:
branches/JCA/build/assembly/jboss-container/dependencies.xml
branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
branches/JCA/engine/src/main/java/com/metamatrix/dqp/ResourceFinder.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
branches/JCA/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java
branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
branches/JCA/jboss-integration/pom.xml
branches/JCA/pom.xml
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
Log:
TEIID-833: Initialized the JBoss Cache using the MC framework.
Modified: branches/JCA/build/assembly/jboss-container/dependencies.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/dependencies.xml 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/build/assembly/jboss-container/dependencies.xml 2009-11-17 19:07:47 UTC (rev 1570)
@@ -23,7 +23,7 @@
<include>org.jboss.teiid:teiid-runtime</include>
<include>org.jboss.teiid:teiid-engine</include>
<include>org.jboss.teiid:teiid-metadata</include>
- <include>org.jboss.teiid:jboss-integration</include>
+ <include>org.jboss.teiid:teiid-jboss-integration</include>
</includes>
<binaries>
Deleted: branches/JCA/build/kit-jboss-container/conf/jboss-cache-configuration.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/conf/jboss-cache-configuration.xml 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/build/kit-jboss-container/conf/jboss-cache-configuration.xml 2009-11-17 19:07:47 UTC (rev 1570)
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<jbosscache xmlns="urn:jboss:jbosscache-core:config:3.1">
-
- <locking isolationLevel="READ_COMMITTED" lockAcquisitionTimeout="15000" lockParentForChildInsertRemove="true" />
- <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" />
-
- <shutdown hookBehavior="DEFAULT" />
-
- <loaders passivation="true" shared="false">
- <loader class="org.jboss.cache.loader.FileCacheLoader" fetchPersistentState="true" purgeOnStartup="true">
- <properties>location=./teiid/cache</properties>
- </loader>
- </loaders>
-
- <eviction wakeUpInterval="15000">
- <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="100000">
- <property name="maxNodes" value="10000" />
- <!-- 0 = immediate eviction, -1 = no limit -->
- <property name="timeToLive" value="-1" />
- </default>
- </eviction>
-
-</jbosscache>
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml 2009-11-17 19:07:47 UTC (rev 1570)
@@ -24,6 +24,81 @@
</bean>
+ <!-- JBOSS Cache -->
+ <!-- First we create a Configuration object for the cache -->
+ <bean name="TeiidJBossCacheConfig" class="org.jboss.cache.config.Configuration">
+
+ <!-- Externally injected services -->
+ <property name="runtimeConfig">
+ <bean class="org.jboss.cache.config.RuntimeConfig">
+ <property name="transactionManager">
+ <inject bean="TransactionManager" property="transactionManager"/>
+ </property>
+ </bean>
+ </property>
+
+ <!-- Node locking level : SERIALIZABLE, REPEATABLE_READ (default),READ_COMMITTED,READ_UNCOMMITTED,NONE -->
+ <property name="isolationLevel">READ_COMMITTED</property>
+
+ <!-- Valid modes are LOCAL,REPL_ASYNC,REPL_SYNC -->
+ <property name="cacheMode">LOCAL</property>
+
+ <!-- Max number of milliseconds to wait for a lock acquisition -->
+ <property name="lockAcquisitionTimeout">15000</property>
+
+ <property name="exposeManagementStatistics">true</property>
+
+ <!-- Specific eviction policy configurations. This is LRU -->
+ <property name="evictionConfig">
+ <bean class="org.jboss.cache.config.EvictionConfig">
+ <property name="defaultEvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</property>
+ <property name="wakeupIntervalSeconds">15</property>
+ <property name="evictionRegionConfigs">
+ <list>
+ <bean class="org.jboss.cache.config.EvictionRegionConfig">
+ <property name="regionName">/_default_</property>
+ <property name="evictionPolicyConfig">
+ <bean name="ExampleDefaultLRUConfig" class="org.jboss.cache.eviction.LRUConfiguration">
+ <property name="maxNodes">10000</property>
+ <property name="timeToLiveSeconds">-1</property>
+ </bean>
+ </property>
+ </bean>
+ </list>
+ </property>
+ </bean>
+ </property>
+
+ </bean>
+
+ <!-- Factory to build the Cache. -->
+ <bean name="TeiidDefaultCacheFactory" class="org.jboss.cache.DefaultCacheFactory">
+ <constructor factoryClass="org.jboss.cache.DefaultCacheFactory" factoryMethod="getInstance"/>
+ </bean>
+
+ <!-- The caches themselves -->
+ <bean name="TeiidJBossCache" class="org.jboss.cache.Cache">
+ <constructor factoryMethod="createCache">
+ <factory bean="TeiidDefaultCacheFactory"/>
+ <parameter class="org.jboss.cache.config.Configuration"><inject bean="TeiidJBossCacheConfig"/></parameter>
+ <parameter class="boolean">false</parameter>
+ </constructor>
+ </bean>
+
+ <bean name="TeiidJBossCacheMBean" class="org.jboss.cache.jmx.CacheJmxWrapper">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.cache:service=TeiidCache",exposedInterface=org.jboss.cache.jmx.CacheJmxWrapperMBean.class,registerDirectly=true)</annotation>
+ <constructor>
+ <parameter class="org.jboss.cache.Cache"><inject bean="TeiidJBossCache"/></parameter>
+ </constructor>
+ </bean>
+
+ <bean name="TeiidCache" class="com.metamatrix.cache.jboss.JBossCacheFactory">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name="teiid/cache")</annotation>
+ <property name="cacheName">jboss.cache:service=TeiidCache</property>
+ <demand>TransactionManager</demand>
+ <demand>TeiidJBossCacheMBean</demand>
+ </bean>
+
<!-- Connector Types -->
<bean name="connector-jdbc-template" class="org.teiid.templates.connector.ConnectorTypeTemplate">
<property name="info"><inject bean="connector-jdbc-templateinfo"/></property>
Modified: branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
===================================================================
--- branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java 2009-11-17 19:07:47 UTC (rev 1570)
@@ -22,69 +22,47 @@
package com.metamatrix.cache.jboss;
-import java.util.List;
-import java.util.Properties;
+import java.io.Serializable;
-import org.jboss.cache.DefaultCacheFactory;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MBeanServerInvocationHandler;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
import org.jboss.cache.Region;
import org.jboss.cache.config.EvictionAlgorithmConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.eviction.FIFOAlgorithmConfig;
import org.jboss.cache.eviction.LFUAlgorithmConfig;
import org.jboss.cache.eviction.LRUAlgorithmConfig;
import org.jboss.cache.eviction.MRUAlgorithmConfig;
-import org.jboss.cache.jmx.JmxRegistrationManager;
+import org.jboss.cache.jmx.CacheJmxWrapperMBean;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.name.Named;
import com.metamatrix.cache.Cache;
import com.metamatrix.cache.CacheConfiguration;
import com.metamatrix.cache.CacheFactory;
import com.metamatrix.cache.Cache.Type;
import com.metamatrix.cache.CacheConfiguration.Policy;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-@Singleton
-public class JBossCacheFactory implements CacheFactory {
- //private static final String NAME = "Cache"; //$NON-NLS-1$
- private org.jboss.cache.Cache cacheStore;
+public class JBossCacheFactory implements CacheFactory, Serializable{
+ private transient org.jboss.cache.Cache cacheStore;
private volatile boolean destroyed = false;
- JmxRegistrationManager jmxManager;
- private Properties props;
-
- @Inject
- public JBossCacheFactory(@Named("DQPProperties") Properties props) {
-
- this.props = props;
-
- if (this.cacheStore == null) {
- this.cacheStore = initCache();
- }
-// try {
-// jmxManager = new JmxRegistrationManager(jmx.getMBeanServer(), cacheStore, jmx.buildName(JMXUtil.MBeanType.SERVICE, NAME));
-// jmxManager.registerAllMBeans();
-// } catch (FailedToRegisterException e) {
-// throw new MetaMatrixRuntimeException(e.getCause());
-// }
- }
- private org.jboss.cache.Cache initCache() {
- org.jboss.cache.Cache cache = new DefaultCacheFactory().createCache("jboss-cache-configuration.xml", false); //$NON-NLS-1$
- List<IndividualCacheLoaderConfig> configs = cache.getConfiguration().getCacheLoaderConfig().getIndividualCacheLoaderConfigs();
- Properties p = configs.get(0).getProperties();
- String workspaceDir = this.props.getProperty(DQPEmbeddedProperties.DQP_WORKDIR);
- p.setProperty("location", workspaceDir + "/cache"); //$NON-NLS-1$ //$NON-NLS-2$
- configs.get(0).setProperties(p);
- cache.create();
- cache.start();
- return cache;
- }
+ public void setCacheName(String jmxName) {
+ try {
+ MBeanServer server = MBeanServerFactory.findMBeanServer(null).get(0);
+ ObjectName on = new ObjectName(jmxName);
+ CacheJmxWrapperMBean cacheWrapper = MBeanServerInvocationHandler.newProxyInstance(server, on, CacheJmxWrapperMBean.class, false);
+ this.cacheStore = cacheWrapper.getCache();
+ } catch (MalformedObjectNameException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ }
/**
* {@inheritDoc}
@@ -132,9 +110,11 @@
}
public void destroy() {
- jmxManager.unregisterAllMBeans();
- this.cacheStore.stop();
- this.cacheStore.destroy();
this.destroyed = true;
}
+
+ // this will be called by microcontainer.
+ public void stop() {
+ destroy();
+ }
}
Modified: branches/JCA/engine/src/main/java/com/metamatrix/dqp/ResourceFinder.java
===================================================================
--- branches/JCA/engine/src/main/java/com/metamatrix/dqp/ResourceFinder.java 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/engine/src/main/java/com/metamatrix/dqp/ResourceFinder.java 2009-11-17 19:07:47 UTC (rev 1570)
@@ -23,20 +23,21 @@
package com.metamatrix.dqp;
-import com.google.inject.Injector;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
import com.metamatrix.cache.CacheFactory;
+import com.metamatrix.core.MetaMatrixRuntimeException;
public class ResourceFinder {
- protected static Injector injector;
public static CacheFactory getCacheFactory() {
- if (injector == null) {
- throw new IllegalStateException();
+ try {
+ InitialContext ic = new InitialContext();
+ return (CacheFactory)ic.lookup("teiid/cache");
+ } catch (NamingException e) {
+ throw new MetaMatrixRuntimeException(e);
}
- return injector.getInstance(CacheFactory.class);
}
- public static void setInjector(Injector i) {
- injector = i;
- }
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java 2009-11-17 19:07:47 UTC (rev 1570)
@@ -21,31 +21,27 @@
*/
package org.teiid.dqp.internal.cache;
-import java.util.Properties;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.google.inject.name.Named;
import com.metamatrix.cache.Cache;
import com.metamatrix.cache.CacheConfiguration;
import com.metamatrix.cache.CacheFactory;
import com.metamatrix.cache.CacheConfiguration.Policy;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.util.LogConstants;
-@Singleton
public class DQPContextCache {
private static enum Scope {REQUEST,SESSION,SERVICE,VDB,GLOBAL;}
private Cache cache;
private String processIdentifier;
- @Inject
- public DQPContextCache(@Named("DQPProperties") Properties props, CacheFactory cacheFactory) {
+ // called by mc
+ public void setCacheFactory(CacheFactory cacheFactory) {
this.cache = cacheFactory.get(Cache.Type.SCOPED_CACHE, new CacheConfiguration(Policy.LRU, 600, 10000));
- this.processIdentifier = props.getProperty(DQPEmbeddedProperties.PROCESSNAME);
}
+ //called by mc
+ public void setProcessName(String name) {
+ this.processIdentifier = name;
+ }
public Cache getGlobalScopedCache() {
return this.cache.addChild(Scope.GLOBAL.name());
Modified: branches/JCA/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java
===================================================================
--- branches/JCA/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java 2009-11-17 19:07:47 UTC (rev 1570)
@@ -59,6 +59,9 @@
@Override
public DQPContextCache getContextCache() {
- return new DQPContextCache(new Properties(), new FakeCacheFactory());
+ DQPContextCache cache = new DQPContextCache();
+ cache.setCacheFactory(new FakeCacheFactory());
+ cache.setProcessName("test");
+ return cache;
}
}
Modified: branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
===================================================================
--- branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2009-11-17 19:07:47 UTC (rev 1570)
@@ -21,15 +21,12 @@
*/
package org.teiid.dqp.internal.cache;
-import java.util.Properties;
-
import junit.framework.TestCase;
import org.teiid.dqp.internal.process.DQPWorkContext;
import com.metamatrix.cache.Cache;
import com.metamatrix.cache.FakeCache.FakeCacheFactory;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.platform.security.api.MetaMatrixSessionID;
import com.metamatrix.platform.security.api.SessionToken;
@@ -40,10 +37,9 @@
@Override
protected void setUp() throws Exception {
- Properties p = new Properties();
- p.setProperty(DQPEmbeddedProperties.PROCESSNAME, "host-process"); //$NON-NLS-1$
- cacheContext = new DQPContextCache(p, new FakeCacheFactory());
-
+ cacheContext = new DQPContextCache();
+ cacheContext.setCacheFactory(new FakeCacheFactory());
+ cacheContext.setProcessName("host-process");
}
private DQPWorkContext getContext() {
Modified: branches/JCA/jboss-integration/pom.xml
===================================================================
--- branches/JCA/jboss-integration/pom.xml 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/jboss-integration/pom.xml 2009-11-17 19:07:47 UTC (rev 1570)
@@ -6,7 +6,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
- <artifactId>jboss-integration</artifactId>
+ <artifactId>teiid-jboss-integration</artifactId>
<name>teiid-jboss-integration</name>
<version>6.3.0-SNAPSHOT</version>
<description>JBoss specific integration layer for teiid</description>
Modified: branches/JCA/pom.xml
===================================================================
--- branches/JCA/pom.xml 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/pom.xml 2009-11-17 19:07:47 UTC (rev 1570)
@@ -375,6 +375,7 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
@@ -392,7 +393,7 @@
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
- </exclusion>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
@@ -404,6 +405,20 @@
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-core</artifactId>
<version>3.1.0.GA</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.transaction</groupId>
+ <artifactId>jta</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.man</groupId>
Modified: branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-11-17 19:07:47 UTC (rev 1570)
@@ -165,7 +165,6 @@
EmbeddedGuiceModule config = new EmbeddedGuiceModule(bootstrapURL, props, address, this.ra);
Injector injector = Guice.createInjector(config);
- ResourceFinder.setInjector(injector);
config.setInjector(injector);
// start the DQP
@@ -354,9 +353,6 @@
this.socketTransport = null;
}
- // shutdown the cache.
- ResourceFinder.getCacheFactory().destroy();
-
this.restart = restart;
}
Modified: branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-11-17 13:31:34 UTC (rev 1569)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-11-17 19:07:47 UTC (rev 1570)
@@ -42,14 +42,13 @@
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
import com.google.inject.name.Names;
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.cache.jboss.JBossCacheFactory;
import com.metamatrix.common.application.ApplicationService;
import com.metamatrix.common.application.DQPConfigSource;
import com.metamatrix.common.log.LogConfiguration;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.LogListener;
+import com.metamatrix.dqp.ResourceFinder;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
import com.metamatrix.dqp.embedded.services.EmbeddedBufferService;
import com.metamatrix.dqp.embedded.services.EmbeddedConfigurationService;
@@ -93,9 +92,8 @@
bind(InetAddress.class).annotatedWith(Names.named(DQPEmbeddedProperties.HOST_ADDRESS)).toInstance(bindAddress);
- bind(CacheFactory.class).to(JBossCacheFactory.class).in(Scopes.SINGLETON);
+ bind(DQPContextCache.class).toInstance(getContextCache());
- bind(DQPContextCache.class).in(Scopes.SINGLETON);
bind(DQPCore.class).in(Scopes.SINGLETON);
bind(new TypeLiteral<Collection<AuthorizationPolicy>>(){}).annotatedWith(Names.named("AdminRoles")).toProvider(AdminAuthorizationPolicyProvider.class).in(Scopes.SINGLETON); //$NON-NLS-1$
@@ -105,6 +103,13 @@
binder().requestStaticInjection(LogManager.class);
}
+ private DQPContextCache getContextCache() {
+ DQPContextCache cache = new DQPContextCache();
+ cache.setCacheFactory(ResourceFinder.getCacheFactory());
+ cache.setProcessName(this.props.getProperty(DQPEmbeddedProperties.PROCESSNAME));
+ return cache;
+ }
+
private void configureServices() {
Map<String, Class<? extends ApplicationService>> defaults = getDefaultServiceClasses();
for(int i=0; i<DQPServiceNames.ALL_SERVICES.length; i++) {
15 years, 1 month
teiid SVN: r1569 - in branches/JCA: build/kit-jboss-container/deploy and 27 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-11-17 08:31:34 -0500 (Tue, 17 Nov 2009)
New Revision: 1569
Added:
branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdminMBean.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingImpl.java
branches/JCA/jboss-integration/src/main/java/org/
branches/JCA/jboss-integration/src/main/java/org/teiid/
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
branches/JCA/runtime/src/main/java/org/teiid/adminapi/
branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/
branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java
Removed:
branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMConnectorBinding.java
branches/JCA/common-core/src/main/java/com/metamatrix/common/util/JMXUtil.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java
Modified:
branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml
branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
branches/JCA/client/pom.xml
branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/AdminObject.java
branches/JCA/client/src/main/java/org/teiid/adminapi/ConfigurationAdmin.java
branches/JCA/client/src/main/java/org/teiid/adminapi/ConnectorBinding.java
branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
branches/JCA/jboss-integration/pom.xml
branches/JCA/pom.xml
branches/JCA/runtime/pom.xml
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
branches/JCA/runtime/src/main/java/org/teiid/Server.java
branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java
branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java
branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java
branches/JCA/test-integration/db/src/main/resources/ddl/derby/create_tables.sql
branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql
Log:
TEIID-833: Adding basic framework for adding the admin api. Added support for connector types.
Added: branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml (rev 0)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <interceptor xmlns="urn:jboss:aop-beans:1.0" name="JndiAspect" class="org.jboss.aop.microcontainer.aspects.jndi.JndiIntroduction">
+ <property name="env">
+ <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry><key>java.naming.factory.initial</key><value>org.jnp.interfaces.NamingContextFactory</value></entry>
+ </map>
+ </property>
+ </interceptor>
+
+ <introduction xmlns="urn:jboss:aop-beans:1.0" class="@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding">
+ <interfaces>org.jboss.kernel.spi.dependency.KernelControllerContextAware</interfaces>
+ </introduction>
+
+ <bind xmlns="urn:jboss:aop-beans:1.0" pointcut="execution(* $instanceof{org.jboss.kernel.spi.dependency.KernelControllerContextAware}->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+ <interceptor-ref name="JndiAspect"/>
+ </bind>
+
+
+ <!-- Add User specific beans here -->
+ <bean name="teiid-admin" class="org.teiid.adminapi.jboss.Admin">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding(name="teiid/admin")</annotation>
+ </bean>
+
+
+ <!-- Connector Types -->
+ <bean name="connector-jdbc-template" class="org.teiid.templates.connector.ConnectorTypeTemplate">
+ <property name="info"><inject bean="connector-jdbc-templateinfo"/></property>
+ <property name="targetTemplate"><inject bean="NoTxConnectionFactoryTemplate"/></property>
+ </bean>
+ <bean name="connector-jdbc-templateinfo" class="org.teiid.templates.connector.ConnectorTypeTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="DSDeploymentTemplateInfoFactory"/>
+ <parameter class="java.lang.Class">org.teiid.templates.connector.ConnectorTypeTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.jboss.resource.metadata.mcf.NoTxConnectionFactoryDeploymentMetaData</parameter>
+ <parameter class="java.lang.String">connector-jdbc-template</parameter>
+ <parameter class="java.lang.String">connector-jdbc-6.3.0-SNAPSHOT.rar</parameter>
+ </constructor>
+ </bean>
+</deployment>
Property changes on: branches/JCA/build/kit-jboss-container/deploy/teiid-jboss-beans.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml
===================================================================
--- branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/build/kit-jboss-container/deploy/teiid-runtime-ds.xml 2009-11-17 13:31:34 UTC (rev 1569)
@@ -10,7 +10,7 @@
</no-tx-connection-factory>
<no-tx-connection-factory>
- <jndi-name>teiid-runtime-engine</jndi-name>
+ <jndi-name>teiid/runtime-engine</jndi-name>
<rar-name>teiid-runtime.rar</rar-name>
<connection-definition>com.metamatrix.common.comm.api.ServerConnectionFactory</connection-definition>
<config-property name="DeployPropertiesFile" type="java.lang.String">/home/rareddy/teiid/teiid-6.3.0/deploy.properties</config-property>
Modified: branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java
===================================================================
--- branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/cache-jbosscache/src/main/java/com/metamatrix/cache/jboss/JBossCacheFactory.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -46,14 +46,12 @@
import com.metamatrix.cache.CacheFactory;
import com.metamatrix.cache.Cache.Type;
import com.metamatrix.cache.CacheConfiguration.Policy;
-import com.metamatrix.common.util.JMXUtil;
-import com.metamatrix.common.util.JMXUtil.FailedToRegisterException;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
@Singleton
public class JBossCacheFactory implements CacheFactory {
- private static final String NAME = "Cache"; //$NON-NLS-1$
+ //private static final String NAME = "Cache"; //$NON-NLS-1$
private org.jboss.cache.Cache cacheStore;
private volatile boolean destroyed = false;
JmxRegistrationManager jmxManager;
@@ -61,19 +59,19 @@
private Properties props;
@Inject
- public JBossCacheFactory(@Named("jmx") JMXUtil jmx, @Named("DQPProperties") Properties props) {
+ public JBossCacheFactory(@Named("DQPProperties") Properties props) {
this.props = props;
if (this.cacheStore == null) {
this.cacheStore = initCache();
}
- try {
- jmxManager = new JmxRegistrationManager(jmx.getMBeanServer(), cacheStore, jmx.buildName(JMXUtil.MBeanType.SERVICE, NAME));
- jmxManager.registerAllMBeans();
- } catch (FailedToRegisterException e) {
- throw new MetaMatrixRuntimeException(e.getCause());
- }
+// try {
+// jmxManager = new JmxRegistrationManager(jmx.getMBeanServer(), cacheStore, jmx.buildName(JMXUtil.MBeanType.SERVICE, NAME));
+// jmxManager.registerAllMBeans();
+// } catch (FailedToRegisterException e) {
+// throw new MetaMatrixRuntimeException(e.getCause());
+// }
}
private org.jboss.cache.Cache initCache() {
Modified: branches/JCA/client/pom.xml
===================================================================
--- branches/JCA/client/pom.xml 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/client/pom.xml 2009-11-17 13:31:34 UTC (rev 1569)
@@ -22,5 +22,10 @@
<artifactId>teiid-common-core</artifactId>
<type>test-jar</type>
</dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Deleted: branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMConnectorBinding.java
===================================================================
--- branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMConnectorBinding.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/client/src/main/java/com/metamatrix/admin/objects/MMConnectorBinding.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -1,231 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.admin.objects;
-
-import java.util.Date;
-
-import org.teiid.adminapi.ConnectorBinding;
-
-import com.metamatrix.admin.AdminPlugin;
-
-
-/**
- * A Connector Binding is a Connector Type with properties that have been
- * bond to a Connector.
- *
- * May are may not be assigned to a VDB
- */
-public class MMConnectorBinding extends MMAdminObject implements ConnectorBinding {
-
- private static final long serialVersionUID = 6919562861762280546L;
- private String routingUUID = ""; //$NON-NLS-1$
- private String description = ""; //$NON-NLS-1$
- private String connectorTypeName = ""; //$NON-NLS-1$
- private int currentState;
- private Date stateChangedTime;
- private long serviceID = -1;
-
-
- /**
- * Constructor.
- * @param identifierParts
- * @since 4.3
- */
- public MMConnectorBinding(String[] identifierParts) {
- super(identifierParts);
- }
-
-
-
-
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append(AdminPlugin.Util.getString("MMConnectorBinding.MMConnectorBinding")).append(getIdentifier()); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMConnectorBinding.Description")).append(description); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMConnectorBinding.Created")).append(getCreatedDate()); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMConnectorBinding.Created_By")).append(getCreatedBy()); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMConnectorBinding.Updated")).append(getLastChangedDate()); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMConnectorBinding.Updated_By")).append(getLastChangedBy()); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMConnectorBinding.State")).append(getState()); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMConnectorBinding.State_Changed")).append(getStateChangedTime()); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMConnectorBinding.IsRegistered")).append(isRegistered()); //$NON-NLS-1$
- result.append(AdminPlugin.Util.getString("MMConnectorBinding.Properties")).append(getPropertiesAsString()); //$NON-NLS-1$
- return result.toString();
- }
-
-
-
- /**
- * Returns the description
- * @return description
- */
- public String getDescription() {
- return description;
- }
-
- /**
- * Set the description
- * @param description
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
-
-
- /**
- * Returns the String globally unique routing UUID for this
- * Connector Binding
- * @return Returns the routingUUID.
- * @since 4.3
- */
- public String getRoutingUUID() {
- return this.routingUUID;
- }
-
- /**
- * @param routingUUID The routingUUID to set.
- * @since 4.3
- */
- public void setRoutingUUID(String routingUUID) {
- this.routingUUID = routingUUID;
- }
-
- /**
- * @return the current state of this connector binding.
- */
- public int getState() {
- return this.currentState;
- }
-
- /**
- * @return Returns the currentState as String.
- * @since 4.3
- */
- public String getStateAsString() {
- switch (currentState) {
- case STATE_OPEN:
- return AdminPlugin.Util.getString("MMConnectorBinding.open"); //$NON-NLS-1$
- case STATE_CLOSED:
- return AdminPlugin.Util.getString("MMConnectorBinding.closed"); //$NON-NLS-1$
- case STATE_FAILED:
- return AdminPlugin.Util.getString("MMConnectorBinding.failed"); //$NON-NLS-1$
- case STATE_INIT_FAILED:
- return AdminPlugin.Util.getString("MMConnectorBinding.initializationFailed"); //$NON-NLS-1$
- case STATE_NOT_INITIALIZED:
- return AdminPlugin.Util.getString("MMConnectorBinding.notInitialized"); //$NON-NLS-1$
- case STATE_NOT_REGISTERED:
- return AdminPlugin.Util.getString("MMConnectorBinding.notRegistered"); //$NON-NLS-1$
- case STATE_DATA_SOURCE_UNAVAILABLE:
- return AdminPlugin.Util.getString("MMConnectorBinding.dataSourceUnavailable"); //$NON-NLS-1$
- default:
- return AdminPlugin.Util.getString("MMConnectorBinding.unknown"); //$NON-NLS-1$
- }
- }
-
- /**
- * Set the state
- * @param state
- * @since 4.3
- */
- public void setState(int state) {
- this.currentState = state;
-
- //check on what states mean "registered"
- setRegistered(currentState==STATE_OPEN || currentState==STATE_FAILED || currentState==STATE_DATA_SOURCE_UNAVAILABLE);
- }
-
-
- /**
- * @return Returns time of last state change.
- * @since 4.3
- */
- public Date getStateChangedTime() {
- return stateChangedTime;
- }
-
- /**
- * Set the state changed time
- * @param stateChangedTime
- * @since 4.3
- */
- public void setStateChangedTime(Date stateChangedTime) {
- this.stateChangedTime = stateChangedTime;
- }
-
-
- /**
- * @return Returns the serviceID.
- * @since 4.3
- */
- public long getServiceID() {
- return this.serviceID;
- }
-
- /**
- * @param serviceID The serviceID to set.
- * @since 4.3
- */
- public void setServiceID(long serviceID) {
- this.serviceID = serviceID;
- }
-
-
- /**
- * @return Returns the processID.
- * @since 4.3
- */
- public String getProcessName() {
- return identifierParts[1];
- }
-
-
- /**
- * @return Returns the hostName.
- * @since 4.3
- */
- public String getHostName() {
- return identifierParts[0];
- }
-
-
- /**
- * @param connectorTypeName the identifier for a connector type
- * @since 4.3
- */
- public void setConnectorTypeName(String connectorTypeName) {
- this.connectorTypeName = connectorTypeName;
- }
-
- /**
- * @see org.teiid.adminapi.ConnectorBinding#getConnectorTypeName()
- * @since 4.3
- */
- public String getConnectorTypeName() {
- return this.connectorTypeName;
- }
-}
\ No newline at end of file
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/Admin.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -22,10 +22,5 @@
package org.teiid.adminapi;
-/**
- * Marker interface for all MetaMatrix administration - core.
- *
- * @since 4.3
- */
public interface Admin extends ConfigurationAdmin, MonitoringAdmin, RuntimeStateAdmin, SecurityAdmin {
}
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/AdminObject.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/AdminObject.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/AdminObject.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -22,6 +22,7 @@
package org.teiid.adminapi;
+import java.io.Serializable;
import java.util.Properties;
/**
@@ -36,7 +37,7 @@
*
* @since 4.3
*/
-public interface AdminObject {
+public interface AdminObject extends Serializable {
/**
* The character that delimits the atomic components of the identifier.
@@ -76,17 +77,7 @@
*/
public static final String ESCAPED_WILDCARD = "\\" + WILDCARD; //$NON-NLS-1$
-
/**
- * Get the Full Name for this AdminObject. This identifier will uniquely identify this object in the Teiid
- * system.
- *
- * @return String the unique Identifier
- * @since 4.3
- */
- String getIdentifier();
-
- /**
* Get the name for this AdminObject, usually the last component of the identifier.
*
* @return String Name
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/ConfigurationAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/ConfigurationAdmin.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/ConfigurationAdmin.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -107,63 +107,21 @@
/**
* Deploy a {@link ConnectorBinding} to Configuration
*
- * @param name
- * is the Connector Binding name that will be added to Configuration
- * @param connectorTypeIdentifier
- * Name of the Connector Type
- * @param properties
- * Name & Value pair need to deploy the Connector Binding
- * @param options The perferred options when executing this method. There are choices about
- * what to do when a connector binding with the given identifier already exists in the system.
- * See the interface {@link AdminOptions.OnConflict} for details.
- * <p>
- * Another option is to ignore a binding connection password decrypt error, when adding a connector
- * binding whose password was encrypted with a different keystore, so that the new password property
- * can be set after the connector binding has been added.</p>
- * @throws AdminException
- * if there's a system error.
- * @return the {@link ConnectorBinding} representing the current property values and runtime state.
- * Note that if this is a system with multiple Processes, this method may actually create multiple deployed
- * Connector Bindings (one for each process). This method will return one of them, arbitrarily.
- * @since 4.3
- */
- ConnectorBinding addConnectorBinding(String name,
- String connectorTypeIdentifier,
- Properties properties, AdminOptions options) throws AdminException;
+ * @param deployedName Connector Binding name that will be added to Configuration
+ * @param typeName Connector type name.
+ * @param properties Name & Value pair need to deploy the Connector Binding
- /**
- * Import a {@link ConnectorBinding} into the Configuration.
- *
- * @param name
- * is the Connector Binding name that will be added to Configuration
- * @param xmlFile
- * contents of XML file that will be sent to the server.
- * @param options The perferred options when executing this method. There are choices about
- * what to do when a connector binding with the given identifier already exists in the system.
- * See the interface {@link AdminOptions.OnConflict} for details.
- * <p>
- * Another option is to ignore a binding connection password decrypt error, when adding a connector
- * binding whose password was encrypted with a different keystore, so that the new password property
- * can be set after the connector binding has been added.</p>
- * @throws AdminException
- * if there's a system error.
- * @return the {@link ConnectorBinding} representing the current property values and runtime state.
- * Note that if this is a system with multiple Processes, this method may actually create multiple deployed
- * Connector Bindings (one for each process). This method will return one of them, arbitrarily.
- * @since 4.3
+ * @throws AdminException if there's a system error.
*/
- ConnectorBinding addConnectorBinding(String name,
- char[] xmlFile, AdminOptions options) throws AdminException;
+ void addConnectorBinding(String deployedName, String typeName, Properties properties) throws AdminException;
/**
* Delete the {@link ConnectorBinding} from the Configuration
*
- * @param connectorBindingIdentifier
- * @throws AdminException
- * if there's a system error.
- * @since 4.3
+ * @param deployedName - deployed name of the connector binding
+ * @throws AdminException if there's a system error.
*/
- void deleteConnectorBinding(String connectorBindingIdentifier) throws AdminException;
+ void deleteConnectorBinding(String deployedName) throws AdminException;
/**
* Import a {@link VDB} file.
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/ConnectorBinding.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/ConnectorBinding.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/ConnectorBinding.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -22,83 +22,21 @@
package org.teiid.adminapi;
-import java.util.Date;
/**
- * Represents a connector binding (the instance of a connector type) in the MetaMatrix system.
- *
- * <p>The unique identifier pattern is [host]<{@link #DELIMITER}>[process]<{@link #DELIMITER}>[Connector Binding Name]
- * when running against a MetaMatrix server. The [Connector Binding Name] can itself have spaces in the name.
- * In the case of the MM Query, the [host] and [process] do not apply as MM Query is always local.</p>
- *
- * @since 4.3
+ * Represents a connector binding (the instance of a connector type) in the Teiid system.
*/
-public interface ConnectorBinding extends
- AdminObject {
- /**Registered by not initialized*/
- public static final int STATE_NOT_INITIALIZED = 0;
- /**Open and running*/
- public static final int STATE_OPEN = 1;
- /**Registered but closed*/
- public static final int STATE_CLOSED = 2;
- /**Failed after running successfully*/
- public static final int STATE_FAILED = 3;
- /**Failed during initialization*/
- public static final int STATE_INIT_FAILED = 4;
- /**Not registered*/
- public static final int STATE_NOT_REGISTERED = 5;
- /**Running, but the underlying data source is unavailable*/
- public static final int STATE_DATA_SOURCE_UNAVAILABLE = 6;
- /**Running, not deployed*/
- public static final int STATE_NOT_DEPLOYED = 7;
- /** failed to check the status */
- public static final int STATE_FAILED_TO_CHECK = 8;
+public interface ConnectorBinding extends AdminObject {
- /** Password connector property name */
- public static final String PASSWORD = "Password"; //$NON-NLS-1$
-
-
/**
- * Retrieve the current connector state. This will be one of the constants:
- * {@link ConnectorBinding#STATE_OPEN DQP.STATE_OPEN}.
- * {@link ConnectorBinding#STATE_NOT_INITIALIZED DQP.STATE_NOT_INITIALIZED}.
- * {@link ConnectorBinding#STATE_CLOSED DQP.STATE_CLOSED}.
- * {@link ConnectorBinding#STATE_FAILED DQP.STATE_FAILED}.
- * {@link ConnectorBinding#STATE_INIT_FAILED DQP.STATE_INIT_FAILED}.
- * {@link ConnectorBinding#STATE_NOT_REGISTERED DQP.STATE_NOT_REGISTERED}.
- * {@link ConnectorBinding#STATE_DATA_SOURCE_UNAVAILABLE DQP.STATE_DATA_SOURCE_UNAVAILABLE}.
- * {@link ConnectorBinding#STATE_NOT_DEPLOYED DQP.STATE_NOT_DEPLOYED}.
- * @return current connector state.
+ * Get the identifier for this connector binding's RAR file name
+ * @return Name of the RAR file used to create this binding
*/
- int getState();
+ String getRARFileName();
/**
- * Retrieve the current connector state as a printable <code>String</code>.
- * @return current connector state in String form.
+ * Get the JNDI Name of this connector
+ * @return
*/
- String getStateAsString();
-
- /**
- * Returns time of last state change.
- *
- * @return time of last state change.
- * @since 4.3
- */
- Date getStateChangedTime();
-
- /**
- * Returns the description
- *
- * @return description
- */
- String getDescription();
-
- /**
- * Get the identifier for this connector binding's {@link ConnectorType}.
- * @return the Connector Type identifier which can be used to
- * find the ConnectorType.
- * @since 4.3
- */
- String getConnectorTypeName();
-
+ String getJNDIName();
}
Modified: branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/MonitoringAdmin.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -23,6 +23,7 @@
package org.teiid.adminapi;
import java.util.Collection;
+import java.util.Set;
import com.metamatrix.admin.RolesAllowed;
@@ -39,19 +40,12 @@
public interface MonitoringAdmin {
/**
- * Get the Connector Types that correspond to the specified identifier pattern.
+ * Get the Connector Types available in the configuration.
*
- * @param connectorTypeIdentifier the unique identifier for for a {@link ConnectorType}
- * <ul>
- * <li> <code>"*"</code> - for all connector types in the system
- * <li> <code>"name*"</code> - for all the connector types that begin with given name
- * <li> <code>"name"</code> - for the single connector type identified by name
- * </ul>
- * @return Collection of {@link ConnectorType}
+ * @return Set of connector types.
* @throws AdminException if there's a system error.
- * @since 4.3
*/
- Collection<ConnectorType> getConnectorTypes(String connectorTypeIdentifier) throws AdminException;
+ Set<String> getConnectorTypes() throws AdminException;
/**
* Get the VDBs that correspond to the specified identifier pattern.
@@ -71,19 +65,20 @@
Collection<VDB> getVDBs(String vdbIdentifier) throws AdminException;
/**
- * Get the Connector Bindings that correspond to the specified identifier pattern.
+ * Get the Connector Bindings that are available in the configuration
*
- * @param connectorBindingIdentifier the unique identifier pattern of {@link ConnectorBinding}
- * <ul>
- * <li> <code>"*"</code> - for all connector bindings in the system
- * <li> <code>"name*"</code> - for all connector bindings that begin with given name
- * <li><code>"name"</code> - for single connector binding by the given name
- * </ul>
* @return Collection of {@link ConnectorBinding}
* @throws AdminException if there's a system error.
- * @since 4.3
*/
- Collection<ConnectorBinding> getConnectorBindings(String connectorBindingIdentifier) throws AdminException;
+ Collection<ConnectorBinding> getConnectorBindings() throws AdminException;
+
+ /**
+ * Get the connector binding by the given the deployed name.
+ * @param deployedName - name of the deplyed connector binding
+ * @return null if not found a connector binding by the given name
+ * @throws AdminException if there's a system error.
+ */
+ ConnectorBinding getConnectorBinding(String deployedName) throws AdminException;
/**
* Get all the Connector Bindings for the given VDB identifier pattern
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,402 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+
+import javax.transaction.xa.Xid;
+
+
+public abstract class TeiidAdmin implements TeiidAdminMBean, Serializable {
+
+ @Override
+ public void addConnectorArchive(byte[] archiveContents, AdminOptions options)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+
+ @Override
+ public void addConnectorType(String name, char[] cdkFile)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void addExtensionModule(String type, String sourceName,
+ byte[] source, String description) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void addUDF(byte[] modelFileContents, String classpath)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public VDB addVDB(String name, byte[] vdbFile, AdminOptions options)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void assignBindingToModel(String connectorBindingName,
+ String vdbName, String vdbVersion, String modelName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void assignBindingsToModel(String[] connectorBindingName,
+ String vdbName, String vdbVersion, String modelName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteConnectorBinding(String connectorBindingIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteConnectorType(String name) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteExtensionModule(String sourceName) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteUDF() throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteVDB(String vdbName, String version) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public char[] exportConfiguration() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] exportConnectorArchive(String connectorTypeIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public char[] exportConnectorBinding(String connectorBindingIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public char[] exportConnectorType(String connectorTypeIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] exportExtensionModule(String sourceName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] exportVDB(String name, String version) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void extensionModuleModified(String name) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public LogConfiguration getLogConfiguration() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setConnectorBindingProperty(String deployedName,
+ String propertyName, String propertyValue) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setLogConfiguration(LogConfiguration config)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setLogListener(EmbeddedLogger listener) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setProcessProperty(String processIdentifier,
+ String propertyName, String propertyValue) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Collection<Cache> getCaches(String identifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<? extends ConnectionPool> getConnectionPoolStats(
+ String identifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<ConnectorBinding> getConnectorBindingsInVDB(
+ String vdbName, String vdbVersion) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<PropertyDefinition> getConnectorTypePropertyDefinitions(
+ String connectorTypeIdentifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<ExtensionModule> getExtensionModules(
+ String extensionModuleIdentifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+
+ @Override
+ public Collection<QueueWorkerPool> getQueueWorkerPools(String identifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Request> getRequests(String identifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Session> getSessions(String identifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Request> getSourceRequests(String identifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Transaction> getTransactions() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<VDB> getVDBs(String vdbIdentifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void cancelRequest(String identifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void cancelSourceRequest(String identifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void changeVDBStatus(String name, String version, int status)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clearCache(String cacheIdentifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void restart() throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void shutdown(int millisToWait) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void startConnectorBinding(String connectorBindingIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void stopConnectorBinding(String connectorBindingIdentifier,
+ boolean stopNow) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void terminateSession(String identifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void terminateTransaction(Xid transactionId) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void terminateTransaction(String transactionId, String sessionId)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void assignRoleToGroup(String roleIdentifier, String groupIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+ @Override
+ public char[] exportDataRoles(String vdbName, String vdbVersion)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public List<String> getDomainNames() throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Group> getGroups(String groupIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Group> getGroupsForDomain(String domainName)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Group> getGroupsForUser(String userIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<Role> getRolesForGroup(String groupIdentifier)
+ throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String importDataRoles(String vdbName, String vdbVersion,
+ char[] data, AdminOptions options) throws AdminException {
+ // rameshTODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void removeRoleFromGroup(String roleIdentifier,
+ String groupIdentifier) throws AdminException {
+ // rameshTODO Auto-generated method stub
+
+ }
+
+}
Property changes on: branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdmin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdminMBean.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdminMBean.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdminMBean.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+
+public interface TeiidAdminMBean extends Admin {
+}
Property changes on: branches/JCA/client/src/main/java/org/teiid/adminapi/TeiidAdminMBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,64 @@
+/*
+ * 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.Serializable;
+import java.util.Properties;
+
+import org.teiid.adminapi.AdminObject;
+
+public class AdminObjectImpl implements AdminObject, Serializable {
+
+ private static final long serialVersionUID = -6381303538713462682L;
+ String name;
+ Properties properties;
+
+ public AdminObjectImpl(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public Properties getProperties() {
+ return this.properties;
+ }
+
+ @Override
+ public String getPropertyValue(String name) {
+ return this.properties.getProperty(name);
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = new Properties(properties);
+ }
+
+ public void addProperty(String key, String value) {
+ if (this.properties == null) {
+ this.properties = new Properties();
+ }
+ this.properties.setProperty(key, value);
+ }
+}
Property changes on: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/AdminObjectImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingImpl.java
===================================================================
--- branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingImpl.java (rev 0)
+++ branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,52 @@
+/*
+ * 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 org.teiid.adminapi.ConnectorBinding;
+
+public class ConnectorBindingImpl extends AdminObjectImpl implements ConnectorBinding {
+
+ private static final long serialVersionUID = -4865836616882247016L;
+ private transient Object type;
+
+ public ConnectorBindingImpl(String name) {
+ super(name);
+ }
+
+ @Override
+ public String getRARFileName() {
+ return getPropertyValue("rar-name");
+ }
+
+ @Override
+ public String getJNDIName() {
+ return getPropertyValue("jndi-name");
+ }
+
+ public void setComponentType(Object type) {
+ this.type = type;
+ }
+
+ public Object getComponentType() {
+ return this.type;
+ }
+}
Property changes on: branches/JCA/client/src/main/java/org/teiid/adminapi/impl/ConnectorBindingImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/JCA/common-core/src/main/java/com/metamatrix/common/util/JMXUtil.java
===================================================================
--- branches/JCA/common-core/src/main/java/com/metamatrix/common/util/JMXUtil.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/common-core/src/main/java/com/metamatrix/common/util/JMXUtil.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package com.metamatrix.common.util;
-
-import java.lang.management.ManagementFactory;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-
-import com.metamatrix.core.MetaMatrixCoreException;
-
-public class JMXUtil {
- public enum MBeanType {SERVICE, SERVER, UTIL, ADMINAPI};
-
- String processName;
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-
- public JMXUtil(String processName) {
- this.processName = processName;
- }
-
- public ObjectName buildName(MBeanType type, String name) throws FailedToRegisterException {
- try {
- return new ObjectName("Teiid["+processName+"]:type="+type+",name="+name); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } catch (MalformedObjectNameException e) {
- throw new FailedToRegisterException(e);
- }
- }
-
- public void register(MBeanType type, String name, Object anObj) throws FailedToRegisterException {
- try {
- mbs.registerMBean(anObj, buildName(type, name));
- } catch (InstanceAlreadyExistsException e) {
- throw new FailedToRegisterException(e);
- } catch (MBeanRegistrationException e) {
- throw new FailedToRegisterException(e);
- } catch (NotCompliantMBeanException e) {
- throw new FailedToRegisterException(e);
- }
- }
-
- public void unregister(MBeanType type, String name) throws FailedToRegisterException {
- try {
- mbs.unregisterMBean(buildName(type, name));
- } catch (InstanceNotFoundException e) {
- throw new FailedToRegisterException(e);
- } catch (MBeanRegistrationException e) {
- throw new FailedToRegisterException(e);
- }
- }
-
- public MBeanServer getMBeanServer() {
- return mbs;
- }
-
- public static class FailedToRegisterException extends MetaMatrixCoreException{
- public FailedToRegisterException(Throwable e) {
- super(e);
- }
- }
-
-}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -174,7 +174,7 @@
private void enqueueRequest(ConnectorWorkItem work) throws ConnectorException {
try {
- // the connector is immutable, then we do not want pass-on the transaction context.
+ // if connector is immutable, then we do not want pass-on the transaction context.
if (work.securityContext.isTransactional()) {
this.workManager.scheduleWork(work, 0, work.requestMsg.getTransactionContext(), work);
}
Modified: branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java
===================================================================
--- branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/SynchConnectorWorkItem.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -87,11 +87,11 @@
this.notify();
}
- private void acquireTransactionLock() throws InterruptedException {
- TransactionContext tc = this.requestMsg.getTransactionContext();
- if ( tc == null) {
+ private void acquireTransactionLock() throws InterruptedException {
+ if (!this.requestMsg.isTransactional()) {
return;
}
+ TransactionContext tc = this.requestMsg.getTransactionContext();
Xid key = tc.getXid();
TransactionLock existing = null;
@@ -110,10 +110,10 @@
}
private void releaseTxnLock() {
+ if (!this.requestMsg.isTransactional() || this.lock == null) {
+ return;
+ }
TransactionContext tc = this.requestMsg.getTransactionContext();
- if ( tc == null || this.lock == null) {
- return;
- }
synchronized (TRANSACTION_LOCKS) {
lock.pendingCount--;
if (lock.pendingCount == 0) {
Modified: branches/JCA/jboss-integration/pom.xml
===================================================================
--- branches/JCA/jboss-integration/pom.xml 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/jboss-integration/pom.xml 2009-11-17 13:31:34 UTC (rev 1569)
@@ -18,12 +18,37 @@
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-common-internal</artifactId>
+ <artifactId>teiid-engine</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
- <artifactId>teiid-engine</artifactId>
+ <artifactId>teiid-runtime</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-profileservice-spi</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-connector</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-aop-mc-int</artifactId>
+ <version>2.0.6.GA</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Deleted: branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -1,657 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.embedded.admin;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminObject;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.Cache;
-import org.teiid.adminapi.ExtensionModule;
-import org.teiid.adminapi.Session;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-import org.teiid.dqp.internal.process.Util;
-
-import com.metamatrix.admin.objects.MMConnectorBinding;
-import com.metamatrix.admin.objects.MMConnectorType;
-import com.metamatrix.admin.objects.MMExtensionModule;
-import com.metamatrix.admin.objects.MMLogConfiguration;
-import com.metamatrix.admin.objects.MMModel;
-import com.metamatrix.admin.objects.MMPropertyDefinition;
-import com.metamatrix.admin.objects.MMRequest;
-import com.metamatrix.admin.objects.MMSession;
-import com.metamatrix.admin.objects.MMVDB;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.security.SessionServiceException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ComponentTypeDefn;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.log.LogConfigurationImpl;
-import com.metamatrix.common.object.PropertyDefinition;
-import com.metamatrix.common.util.crypto.CryptoException;
-import com.metamatrix.common.util.crypto.CryptoUtil;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.service.AuthorizationService;
-import com.metamatrix.dqp.service.ConfigurationService;
-import com.metamatrix.dqp.service.ConnectorStatus;
-import com.metamatrix.dqp.service.DQPServiceNames;
-import com.metamatrix.dqp.service.DataService;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.VDBService;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
-import com.metamatrix.platform.security.api.SessionToken;
-import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
-import com.metamatrix.platform.security.api.service.SessionServiceInterface;
-import com.metamatrix.platform.util.ProductInfoConstants;
-import com.metamatrix.server.serverapi.RequestInfo;
-
-
-/**
- * @since 4.3
- */
-abstract class BaseAdmin {
- static final String DOT = "."; //$NON-NLS-1$
- static final String STAR = "*"; //$NON-NLS-1$
- static final String FILE_NAME_REGEX="\\w+\\.\\w+"; //$NON-NLS-1$
- static final String MULTIPLE_WORDS_REGEX = "\\w+([\\s|-]*\\w)*"; //$NON-NLS-1$
- static final String SINGLE_WORD_REGEX = "\\w+"; //$NON-NLS-1$
- static final String MULTIPLE_WORD_WILDCARD_REGEX = "\\w*((\\.)?\\s*\\w)*(\\*)?"; //$NON-NLS-1$
- static final String SINGLE_WORD_WILDCARD_REGEX = "\\w*(\\*)?"; //$NON-NLS-1$
- // This should find word.word.* or word.* kind of patterns (ugly, you can rewrite)
- static final String WORD_AND_DOT_WILDCARD_REGEX = "\\w+((\\.\\*)|(\\.\\w+)|(\\.\\w*\\*))*|\\w*(\\*){1}"; //$NON-NLS-1$
-
- static final String VDB_REGEX = "\\w*(\\*)?(\\.\\d+)?"; //$NON-NLS-1$
- static final String NUMBER_DOT_REGEX = "\\d+((\\.\\*)|(\\.\\d+)|(\\.\\d*\\*))*|\\d*(\\*){1}"; //$NON-NLS-1$
- static final String NUMBER_REGEX = "\\d*(\\*)?"; //$NON-NLS-1$
-
- static final String[] cacheTypes = {Cache.CODE_TABLE_CACHE,
- Cache.CONNECTOR_RESULT_SET_CACHE,
- Cache.PREPARED_PLAN_CACHE,
- Cache.QUERY_SERVICE_RESULT_SET_CACHE
- };
-
- private EmbeddedConnectionFactoryImpl manager = null;
-
- BaseAdmin(EmbeddedConnectionFactoryImpl manager){
- this.manager = manager;
- }
-
- protected AdminException accumulateSystemException(AdminException parent, Exception e) {
- if (parent == null) {
- return new AdminComponentException(e);
- }
- parent.addChild(new AdminComponentException(e));
- return parent;
- }
-
- protected AdminException accumulateProcessingException(AdminException parent, Exception e) {
- if (parent == null) {
- return new AdminProcessingException(e);
- }
- parent.addChild(new AdminProcessingException(e));
- return parent;
- }
-
- protected String prettyPrintBindingNames(List bindings) {
- StringBuffer buffer = new StringBuffer();
- for (Iterator iter = bindings.iterator(); iter.hasNext();) {
- ConnectorBinding binding = (ConnectorBinding) iter.next();
- buffer.append(binding.getDeployedName());
- if (iter.hasNext()) {
- buffer.append(", "); //$NON-NLS-1$
- }
- }
-
- return buffer.toString();
- }
-
- /**
- * @return Returns the manager.
- * @since 4.3
- */
- public EmbeddedConnectionFactoryImpl getManager() {
- return this.manager;
- }
-
- VDBService getVDBService() {
- return (VDBService)getManager().findService(DQPServiceNames.VDB_SERVICE);
- }
-
- DataService getDataService() {
- return (DataService)getManager().findService(DQPServiceNames.DATA_SERVICE);
- }
-
- TransactionService getTransactionService() {
- return (TransactionService)getManager().findService(DQPServiceNames.TRANSACTION_SERVICE);
- }
-
- MembershipServiceInterface getMembershipService() {
- return (MembershipServiceInterface)getManager().findService(DQPServiceNames.MEMBERSHIP_SERVICE);
- }
-
- AuthorizationService getAuthorizationService() {
- return (AuthorizationService)getManager().findService(DQPServiceNames.AUTHORIZATION_SERVICE);
- }
-
- ConfigurationService getConfigurationService() {
- return (ConfigurationService)getManager().findService(DQPServiceNames.CONFIGURATION_SERVICE);
- }
-
- SessionServiceInterface getSessionService() {
- return (SessionServiceInterface)getManager().findService(DQPServiceNames.SESSION_SERVICE);
- }
-
- protected Object convertToAdminObjects(Object src) {
- return convertToAdminObjects(src,null);
- }
-
- protected Object convertToAdminObjects(Object src, Object parent) {
- if (src == null) {
- return src;
- }
-
- if (src instanceof List) {
- List modified = new ArrayList();
- List list = (List)src;
- for (final Iterator i = list.iterator(); i.hasNext();) {
- final Object e = i.next();
- Object converted = convertToAdminObject(e, parent);
- modified.add(converted);
- }
- return modified;
- }
- else if (src instanceof Collection) {
- List modified = new ArrayList();
- for (Iterator i = ((Collection)src).iterator(); i.hasNext();) {
- final Object e = i.next();
- Object converted = convertToAdminObject(e, parent);
- modified.add(converted);
- }
- return modified;
- }
- else if (src instanceof Object[] ) {
- List modified = new ArrayList();
- Object[] srcArray = (Object[])src;
- for (int i = 0; i < srcArray.length; i++) {
- final Object converted = convertToAdminObject(srcArray[i], parent);
- modified.add(converted);
- }
- return modified;
- }
- return convertToAdminObject(src, parent);
- }
-
-
- private Object convertToAdminObject(Object src, Object parent) {
- if (src != null && src instanceof com.metamatrix.common.config.api.ConnectorBinding) {
- com.metamatrix.common.config.api.ConnectorBinding binding = (com.metamatrix.common.config.api.ConnectorBinding)src;
- return convertConnectorType(binding, parent);
- }
- else if (src != null && src instanceof com.metamatrix.common.config.api.ConnectorBindingType) {
- com.metamatrix.common.config.api.ConnectorBindingType type = (com.metamatrix.common.config.api.ConnectorBindingType)src;
- return convertConnectorType(type, parent);
- }
- else if (src != null && src instanceof com.metamatrix.common.vdb.api.VDBDefn) {
- com.metamatrix.common.vdb.api.VDBDefn vdb = (com.metamatrix.common.vdb.api.VDBDefn)src;
- return convertVDB(vdb, parent);
- }
- else if (src != null && src instanceof VDBArchive) {
- VDBArchive vdb = (VDBArchive)src;
- return convertVDB(vdb.getConfigurationDef(), parent);
- }
- else if (src != null && src instanceof com.metamatrix.common.vdb.api.ModelInfo) {
- com.metamatrix.common.vdb.api.ModelInfo model = (com.metamatrix.common.vdb.api.ModelInfo)src;
- return convertModel(model, parent);
- }
- else if (src != null && src instanceof com.metamatrix.common.log.LogConfiguration) {
- com.metamatrix.common.log.LogConfiguration config = (com.metamatrix.common.log.LogConfiguration)src;
- return covertLogConfiguration(config);
- }
- else if (src != null && src instanceof com.metamatrix.server.serverapi.RequestInfo) {
- com.metamatrix.server.serverapi.RequestInfo request = (com.metamatrix.server.serverapi.RequestInfo)src;
- return convertRequest(request);
- }
- else if (src != null && src instanceof com.metamatrix.common.queue.WorkerPoolStats) {
- com.metamatrix.common.queue.WorkerPoolStats stats = (com.metamatrix.common.queue.WorkerPoolStats)src;
- return Util.convertStats(stats, stats.getQueueName());
- }
- else if (src != null && src instanceof MetaMatrixSessionInfo) {
- MetaMatrixSessionInfo conn = (MetaMatrixSessionInfo)src;
- return convertConnection(conn);
- }
- else if (src != null && src instanceof com.metamatrix.common.config.api.ExtensionModule) {
- com.metamatrix.common.config.api.ExtensionModule extModule = (com.metamatrix.common.config.api.ExtensionModule)src;
- return convertExtensionModule(extModule);
- }
- else {
- if (src == null) {
- return null;
- }
- throw new UnsupportedOperationException(DQPEmbeddedPlugin.Util.getString("UnSupported_object_conversion")); //$NON-NLS-1$
- }
- }
-
- Object convertToNativeObjects(Object src) {
- if (src instanceof org.teiid.adminapi.LogConfiguration) {
- org.teiid.adminapi.LogConfiguration config = (org.teiid.adminapi.LogConfiguration)src;
- return covertToNativeLogConfiguration(config);
- }
- throw new UnsupportedOperationException(DQPEmbeddedPlugin.Util.getString("UnSupported_object_conversion")); //$NON-NLS-1$
- }
-
-
- private ExtensionModule convertExtensionModule(com.metamatrix.common.config.api.ExtensionModule src) {
- MMExtensionModule module = new MMExtensionModule(new String[] {src.getFullName()}) ;
- module.setDescription(src.getDescription());
- module.setFileContents(src.getFileContents());
- module.setModuleType(src.getModuleType());
- return module;
- }
-
- private Session convertConnection(MetaMatrixSessionInfo src) {
- MMSession session = new MMSession(new String[] {src.getSessionID().toString()});
- session.setVDBName(src.getProductInfo(ProductInfoConstants.VIRTUAL_DB));
- session.setVDBVersion(src.getProductInfo(ProductInfoConstants.VDB_VERSION));
- session.setApplicationName(src.getApplicationName());
- session.setIPAddress(src.getClientIp());
- session.setHostName(src.getClientHostname());
- session.setUserName(src.getUserName());
- session.setLastPingTime(src.getLastPingTime());
- session.setCreated(new Date(src.getTimeCreated()));
- return session;
- }
-
- /**
- * Convert LogConfiguration to Admin Object
- */
- private org.teiid.adminapi.LogConfiguration covertLogConfiguration(final com.metamatrix.common.log.LogConfiguration src) {
- Map<String, Integer> contextMap = new HashMap<String, Integer>();
- for(String context:src.getContexts()) {
- contextMap.put(context, src.getLogLevel(context));
- }
- return new MMLogConfiguration(contextMap);
- }
-
- /**
- * Convert LogConfiguration to Admin Object
- */
- private com.metamatrix.common.log.LogConfiguration covertToNativeLogConfiguration(final org.teiid.adminapi.LogConfiguration src) {
- Map<String, Integer> contextMap = new HashMap<String, Integer>();
- for(String context:src.getContexts()) {
- contextMap.put(context, src.getLogLevel(context));
- }
- return new LogConfigurationImpl(contextMap);
- }
-
- /**
- * @param binding
- * @return
- * @since 4.3
- */
- private org.teiid.adminapi.ConnectorBinding convertConnectorType(final com.metamatrix.common.config.api.ConnectorBinding src, final Object parent) {
- MMConnectorBinding binding = new MMConnectorBinding(new String[] {src.getDeployedName()});
-
- binding.setConnectorTypeName(src.getComponentTypeID().getFullName());
- binding.setCreated(src.getCreatedDate());
- binding.setCreatedBy(src.getCreatedBy());
- binding.setDescription(src.getDescription());
- binding.setEnabled(src.isEnabled());
- binding.setLastUpdated(src.getLastChangedDate());
- binding.setLastUpdatedBy(src.getLastChangedBy());
- binding.setProperties(src.getProperties());
- binding.setRegistered(true);
- binding.setRoutingUUID(src.getRoutingUUID());
- binding.setServiceID(0); // TODO:
-
- // Binding state needs to be converted into pool state; until then we use
- // binding state as pool state.
-// try {
-// ConnectorStatus status = getDataService().getConnectorBindingState(src.getDeployedName());
-// switch(status) {
-// case OPEN:
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_OPEN);
-// break;
-// case NOT_INITIALIZED:
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_NOT_INITIALIZED);
-// break;
-// case CLOSED:
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_CLOSED);
-// break;
-// case DATA_SOURCE_UNAVAILABLE:
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_DATA_SOURCE_UNAVAILABLE);
-// break;
-// case INIT_FAILED:
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_INIT_FAILED);
-// break;
-// case UNABLE_TO_CHECK:
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_FAILED_TO_CHECK);
-// break;
-// }
-// }catch(MetaMatrixComponentException e) {
-// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_NOT_DEPLOYED);
-// }
- binding.setStateChangedTime(src.getLastChangedDate());
- return binding;
- }
-
- /**
- * @param type
- * @return
- * @since 4.3
- */
- private org.teiid.adminapi.ConnectorType convertConnectorType(final com.metamatrix.common.config.api.ConnectorBindingType src, final Object parent) {
- MMConnectorType type = new MMConnectorType(new String[] {src.getName()});
- type.setCreated(src.getCreatedDate());
- type.setCreatedBy(src.getCreatedBy());
- type.setEnabled(true);
- type.setLastUpdated(src.getLastChangedDate());
- type.setRegistered(true);
-
- return type;
- }
-
- /**
- * @param vdb
- * @return
- * @since 4.3
- */
- private org.teiid.adminapi.VDB convertVDB(final com.metamatrix.common.vdb.api.VDBDefn src, final Object parent) {
-
- MMVDB vdb = new MMVDB(new String[] {src.getName(), src.getVersion()});
- vdb.setCreated(src.getDateCreated());
- vdb.setCreatedBy(src.getCreatedBy());
- vdb.setEnabled(src.isActiveStatus());
- vdb.setLastUpdated(src.getDateCreated());
- vdb.setLastUpdatedBy(src.getCreatedBy());
- vdb.setMaterializedViews(src.getMatertializationModel() != null);
- vdb.setModels((Collection)convertToAdminObjects(src.getModels(), src));
- vdb.setProperties(null);
- vdb.setRegistered(true);
- vdb.setStatus(src.getStatus());
- vdb.setUID(0); // TODO: src.getUUID());
- vdb.setVersionedBy(src.getCreatedBy());
- vdb.setVersionedDate(src.getDateCreated());
- vdb.setHasWSDL(src.hasWSDLDefined());
-
- return vdb;
- }
-
- private org.teiid.adminapi.Model convertModel(final com.metamatrix.common.vdb.api.ModelInfo src, final Object parent) {
- final com.metamatrix.common.vdb.api.VDBDefn vdb = (com.metamatrix.common.vdb.api.VDBDefn)parent;
- MMModel model = new MMModel(new String[] {src.getName()});
- model.setCreated(vdb.getDateCreated());
- model.setCreatedBy(vdb.getCreatedBy());
- model.setEnabled(vdb.isActiveStatus());
- model.setLastUpdated(vdb.getDateCreated());
- model.setLastUpdatedBy(vdb.getCreatedBy());
- model.setModelType(src.getModelTypeName());
- model.setModelURI(src.getModelURI());
- model.setMaterialization(src.isMaterialization());
- model.setPhysical(src.isPhysical());
- model.setRegistered(true);
- model.setSupportsMultiSourceBindings(src.isMultiSourceBindingEnabled());
- model.setVisible(src.isVisible());
- if (src.isPhysical()) {
- List bindings = src.getConnectorBindingNames();
- if (bindings != null && !bindings.isEmpty()) {
- List names = new ArrayList();
- for (int i=0; i<bindings.size();i++) {
- names.add(convertToAdminObject(vdb.getConnectorBindingByName((String)bindings.get(i)), parent));
- }
- model.setConnectorBindingNames(names);
- }
- }
- return model;
- }
-
- private org.teiid.adminapi.Request convertRequest(final RequestInfo src) {
-
- String connId = src.getRequestID().getConnectionID();
-
- MMRequest request = null;
- if (src.getConnectorBindingUUID() != null) {
- request = new MMRequest(new String[] {connId, String.valueOf(src.getRequestID().getExecutionID()), String.valueOf(src.getNodeID()), String.valueOf(src.getExecutionID())});
- }
- else {
- request = new MMRequest(new String[] {connId, String.valueOf(src.getRequestID().getExecutionID())});
- }
-
- request.setSqlCommand(src.getCommand());
-
- request.setCreated(src.getProcessingTimestamp());
-
- if (src.getConnectorBindingUUID() != null) {
- request.setSource(true);
- request.setNodeID(String.valueOf(src.getNodeID()));
- }
- return request;
- }
-
- /**
- * Get the connection connection object for the given id.
- * @param identifier
- * @return
- * @since 4.3
- */
- MetaMatrixSessionInfo getClientConnection(String identifier) throws AdminException {
- Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
- for (MetaMatrixSessionInfo info:sessions) {
- if (info.getSessionID().toString().equals(identifier)) {
- return info;
- }
- }
- return null;
- }
-
- /**
- * Get all the available connections
- * @return
- * @throws AdminException
- */
- Collection<MetaMatrixSessionInfo> getClientConnections() throws AdminException {
- try {
- return getSessionService().getActiveSessions();
- } catch (SessionServiceException e) {
- // SessionServiceException not in the client known exception (in common-internal)
- throw new AdminComponentException(e.getMessage(), e.getCause());
- }
- }
-
- boolean matches(String regEx, String value) {
- regEx = regEx.replaceAll(AdminObject.ESCAPED_WILDCARD, ".*"); //$NON-NLS-1$
- regEx = regEx.replaceAll(AdminObject.ESCAPED_DELIMITER, ""); //$NON-NLS-1$
- return value.matches(regEx);
- }
-
- List matchedCollection(String identifier, List adminObjects) {
- ArrayList matched = new ArrayList();
- for (Iterator i = adminObjects.iterator(); i.hasNext();) {
- AdminObject aObj = (AdminObject)i.next();
- if (matches(identifier, aObj.getName()) || matches(identifier, aObj.getIdentifier())) {
- matched.add(aObj);
- }
- }
- return matched;
- }
-
- /**
- * Get list of available connector bindings
- * @param identifier
- */
- Collection getConnectorBindings(String identifier) throws AdminException{
-// try {
-// List connectorBindings = getDataService().getConnectorBindings();
-// connectorBindings = (List)convertToAdminObjects(connectorBindings);
-// return matchedCollection(identifier, connectorBindings);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return Collections.EMPTY_LIST;
- }
-
-
- /**
- * Get list of available connector types
- * @param identifier
- */
- Collection getConnectorTypes(String identifier) throws AdminException{
-
- try {
- List connectorTypes = getConfigurationService().getConnectorTypes();
- connectorTypes = (List)convertToAdminObjects(connectorTypes);
- return matchedCollection(identifier, connectorTypes);
- } catch (MetaMatrixComponentException err) {
- throw new AdminComponentException(err);
- }
- }
-
- boolean isMaskedProperty(String propName, ComponentType type) {
- if (type != null) {
- ComponentTypeDefn typeDef = type.getComponentTypeDefinition(propName);
- if (typeDef != null && typeDef.getPropertyDefinition().isMasked()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Encrypt a string
- * @param value
- * @return
- * @throws AdminException
- * @since 4.3
- */
- String encryptString(String value) throws AdminException {
- try {
- return CryptoUtil.stringEncrypt(value);
- } catch (CryptoException e) {
- throw new AdminComponentException(e);
- }
- }
-
-
-
- /**
- * Convert a ComponentType and a set of properties into a Collection of
- * com.metamatrix.admin.api.objects.PropertyDefinition objects
- * @param ctype
- * @param properties
- * @return
- * @since 4.3
- */
- protected Collection convertPropertyDefinitions(ComponentType ctype, Properties properties) {
- ArrayList results = new ArrayList();
- for (Iterator iter = ctype.getComponentTypeDefinitions().iterator(); iter.hasNext(); ) {
- ComponentTypeDefn cdefn = (ComponentTypeDefn) iter.next();
- PropertyDefinition pdefn = cdefn.getPropertyDefinition();
-
- MMPropertyDefinition result = new MMPropertyDefinition(new String[] {pdefn.getName()});
- result.setAllowedValues(pdefn.getAllowedValues());
- result.setDefaultValue(pdefn.getDefaultValue());
- result.setDescription(pdefn.getShortDescription());
- result.setDisplayName(pdefn.getDisplayName());
- result.setExpert(pdefn.isExpert());
- result.setMasked(pdefn.isMasked());
- result.setModifiable(pdefn.isModifiable());
- result.setPropertyType(pdefn.getPropertyType().getDisplayName());
- result.setPropertyTypeClassName(pdefn.getPropertyType().getClassName());
- result.setRequired(pdefn.isRequired());
- result.setRequiresRestart(pdefn.getRequiresRestart());
-
- String value = properties.getProperty(pdefn.getName());
- result.setValue(value);
-
- results.add(result);
- }
-
-
- return results;
- }
-
-
- /**
- * Convert a set of properties into a Collection of
- * com.metamatrix.admin.api.objects.PropertyDefinition objects
- *
- * @param ctype
- * @param properties
- * @return
- * @since 4.3
- */
- protected Collection convertPropertyDefinitions(Properties properties) {
- ArrayList results = new ArrayList();
- for (Iterator iter = properties.keySet().iterator(); iter.hasNext(); ) {
- String key = (String) iter.next();
- String value = properties.getProperty(key);
-
- MMPropertyDefinition result = new MMPropertyDefinition(new String[] {key});
- result.setDisplayName(key);
- result.setValue(value);
-
- results.add(result);
- }
-
-
- return results;
- }
-
- protected SessionToken validateSession() {
- return DQPWorkContext.getWorkContext().getSessionToken();
- }
-
- protected void changeVDBStatus(String name, String version, int status)
- throws AdminException {
- try {
-
- if (name == null || version == null || !name.matches(SINGLE_WORD_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name")); //$NON-NLS-1$
- }
-
- // Now change the VDB status it self
- this.getVDBService().changeVDBStatus(name, version, status);
-
- // If the VDB is modified and if its status changed to DELETED, then
- // we can remove all the connector bindings associated with this VDB
- // the above delete will also remove them
- } catch (ApplicationLifecycleException e) {
- throw new AdminComponentException(e);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
-}
Deleted: branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -1,1063 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.embedded.admin;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminOptions;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.ConfigurationAdmin;
-import org.teiid.adminapi.EmbeddedLogger;
-import org.teiid.adminapi.LogConfiguration;
-import org.teiid.adminapi.VDB;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.application.exception.ApplicationLifecycleException;
-import com.metamatrix.common.config.api.ComponentType;
-import com.metamatrix.common.config.api.ComponentTypeDefn;
-import com.metamatrix.common.config.api.ComponentTypeID;
-import com.metamatrix.common.config.api.ConnectorArchive;
-import com.metamatrix.common.config.api.ConnectorBinding;
-import com.metamatrix.common.config.api.ConnectorBindingType;
-import com.metamatrix.common.config.api.ExtensionModule;
-import com.metamatrix.common.config.model.BasicConnectorArchive;
-import com.metamatrix.common.config.model.BasicExtensionModule;
-import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.crypto.CryptoException;
-import com.metamatrix.common.util.crypto.CryptoUtil;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.common.vdb.api.VDBDefn;
-import com.metamatrix.core.vdb.VDBStatus;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.embedded.configuration.ConnectorConfigurationReader;
-import com.metamatrix.dqp.embedded.configuration.ConnectorConfigurationWriter;
-import com.metamatrix.dqp.embedded.configuration.VDBConfigurationReader;
-import com.metamatrix.dqp.service.ConfigurationService;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-
-
-/**
- * DQP implementation of the Config Admin API
- * @since 4.3
- */
-public class DQPConfigAdminImpl extends BaseAdmin implements ConfigurationAdmin {
-
- public DQPConfigAdminImpl(EmbeddedConnectionFactoryImpl manager) {
- super(manager);
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#setProperty(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- * @since 4.3
- */
- public void setConnectorBindingProperty(String deployedName, String propertyName, String propertyValue)
- throws AdminException {
-
-// try {
-// ConnectorBinding binding = getConfigurationService().getConnectorBinding(deployedName);
-// if (binding == null) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.cb_doesnot_exist", deployedName)); //$NON-NLS-1$
-// }
-//
-// ComponentTypeID id = binding.getComponentTypeID();
-// ConnectorBindingType type = getConfigurationService().getConnectorType(id.getName());
-//
-// boolean needsEncryption = isMaskedProperty(propertyName, type);
-// if (needsEncryption) {
-// propertyValue = encryptString(propertyValue);
-// }
-//
-// Properties p = new Properties();
-// p.setProperty(propertyName, propertyValue);
-//
-// //update the configuration
-// binding = ConnectorConfigurationReader.addConnectorBindingProperties(binding, p);
-// getConfigurationService().updateConnectorBinding(binding);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorType(java.lang.String, char[])
- * @since 4.3
- */
- public void addConnectorType(String deployName, char[] cdkFile)
- throws AdminException {
-// try {
-// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
-// }
-// if (cdkFile == null || cdkFile.length == 0) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_source")); //$NON-NLS-1$
-// }
-//
-// // This is only place we check the existence in admin. Generally the Admin is not the
-// // guy to decide, if it can take in or not, it should be the service. I did not
-// // want add in the configuration service beacuse, it may need to allow this behavior
-// // in case we are updating.
-// if (getConfigurationService().getConnectorType(deployName) == null) {
-// ConnectorBindingType type = ConnectorConfigurationReader.loadConnectorType(cdkFile);
-// saveConnectorType(type);
-// }
-// else {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_exists", deployName)); //$NON-NLS-1$
-// }
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#deleteConnectorType(java.lang.String)
- * @since 4.3
- */
- public void deleteConnectorType(String deployName)
- throws AdminException {
-// try {
-// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
-// }
-// getConfigurationService().deleteConnectorType(deployName);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorBinding(java.lang.String, java.lang.String, java.util.Properties, AdminOptions)
- * @since 4.3
- */
- public org.teiid.adminapi.ConnectorBinding addConnectorBinding(String deployName, String type, Properties properties, AdminOptions options)
- throws AdminException {
-// // if the options object is null treat as if it is IGNORE as default
-// if (options == null) {
-// options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
-// }
-//
-// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
-// }
-//
-// if (type == null || !type.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
-// }
-//
-// ConnectorBinding binding = null;
-// try {
-// // Check if the binding exists already, if does take action based on user
-// // preferences in the admin options
-// if (bindingExists(deployName)) {
-// // Based on users preference, either add or replace or ignore
-// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists", deployName)); //$NON-NLS-1$
-// }
-// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
-// binding = getDataService().getConnectorBinding(deployName);
-// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
-// }
-// }
-//
-// // Get the connector type
-// ConnectorBindingType ctype = getConfigurationService().getConnectorType(type);
-// if (ctype == null) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_type_not_exists", type)); //$NON-NLS-1$
-// }
-//
-// // Build the connector binding with informatin we know.
-// binding = ConnectorConfigurationReader.loadConnectorBinding(deployName, properties, ctype);
-//
-// // Check that the connector binding passwords can be decrypted
-// try {
-// checkDecryption(binding, ctype);
-// } catch(CryptoException e) {
-// if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED", binding.getFullName())); //$NON-NLS-1$
-// }
-// }
-//
-// // now that all of the input parameters validated, add the connector binding
-// binding = addConnectorBinding(deployName, binding, ctype, false);
-//
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
-// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
-
- return null;
- }
-
- boolean bindingExists(String name) throws MetaMatrixComponentException {
-// ConnectorBinding binding = getDataService().getConnectorBinding(name);
-// return (binding != null);
- return false;
- }
-
- boolean bindingTypeExists(String name) throws MetaMatrixComponentException {
- ConnectorBindingType type = getConfigurationService().getConnectorType(name);
- return (type != null);
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorBinding(java.lang.String, char[], AdminOptions)
- * @since 4.3
- */
- public org.teiid.adminapi.ConnectorBinding addConnectorBinding(String deployName, char[] xmlFile, AdminOptions options)
- throws AdminException {
-
-// // if the options object is null treat as if it is IGNORE as default
-// if (options == null) {
-// options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
-// }
-//
-// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
-// }
-// if (xmlFile == null || xmlFile.length == 0) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_source")); //$NON-NLS-1$
-// }
-//
-// ConnectorBinding binding = null;
-// try {
-// // Check if the binding exists already, if does take action based on user
-// // preferences in the admin options
-// if (bindingExists(deployName)) {
-// // Based on users preference, either add or replace or ignore
-// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists", deployName)); //$NON-NLS-1$
-// }
-// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
-// binding = getDataService().getConnectorBinding(deployName);
-// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
-// }
-// }
-//
-// // now we are in situation we do have the connector or overwriting it.
-// // before we add the connector binding we need to add the connector type
-// // as the connector binding only references to type by identifier.
-// ConnectorBindingType type = ConnectorConfigurationReader.loadConnectorType(xmlFile);
-//
-// // Check if the binding type exists already, if does take action based on user
-// // preferences in the admin options, same rules apply as binding.
-// boolean addType = true;
-// if (bindingTypeExists(type.getName())) {
-// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBinding_type_exists", deployName, type.getName())); //$NON-NLS-1$
-// }
-// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
-// addType = false;
-// }
-// }
-//
-// binding = ConnectorConfigurationReader.loadConnectorBinding(deployName, xmlFile);
-//
-// // Check that the connector binding passwords can be decrypted
-// try {
-// checkDecryption(binding, type);
-// } catch(CryptoException e) {
-// if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED", binding.getFullName())); //$NON-NLS-1$
-// }
-// }
-//
-// // now that all of the input parameters validated, add the connector binding
-// binding = addConnectorBinding(deployName, binding, type, addType);
-//
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
-//
-// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
- return null;
- }
-
- /**
- * Helper method to add the connector binding..
- * @param deployName
- * @param binding
- * @param type
- * @param options
- * @throws AdminException
- */
- ConnectorBinding addConnectorBinding(String deployName, ConnectorBinding binding, ConnectorBindingType type, boolean addType)
- throws AdminException {
- // Make sure we have both correctly configured
- if (type != null && binding != null) {
- if (binding.getComponentTypeID().getName().equals(type.getName())) {
- try {
-
- // First add the connector type if one is not already in here.
- if (getConfigurationService().getConnectorType(type.getName()) == null || addType) {
- saveConnectorType(type);
- }
- // Now add the connector binding.
- binding = getConfigurationService().addConnectorBinding(deployName, binding, true);
- return binding;
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_load_failed_wrong_type", deployName)); //$NON-NLS-1$
- }
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_load_failed_wrong_contents", deployName)); //$NON-NLS-1$
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#deleteConnectorBinding(java.lang.String)
- * @since 4.3
- */
- public void deleteConnectorBinding(String identifier)
- throws AdminException {
-// try {
-// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
-// }
-// getConfigurationService().deleteConnectorBinding(identifier);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addVDB(java.lang.String, byte[], char[], AdminOptions)
- * @since 4.3
- */
- private VDB addVDB(String deployName, byte[] vdbFile, char[] defFile, AdminOptions options)
- throws AdminException {
-
- // if the options object is null treat as if it is BINDINGS_ADD as default
- if (options == null) {
- options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
- }
-
- if (deployName == null || !deployName.matches(SINGLE_WORD_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name")); //$NON-NLS-1$
- }
- if (vdbFile == null || vdbFile.length == 0) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_source")); //$NON-NLS-1$
- }
-
- if (defFile == null) {
- DQPEmbeddedPlugin.logInfo("Admin.load_combined_vdb", new Object[] {deployName}); //$NON-NLS-1$
- }
-
- VDBArchive vdb = null;
- try {
- // Load the VDB from the files
- if (defFile == null) {
- vdb = VDBConfigurationReader.loadVDB(deployName, vdbFile);
- }
- else {
- vdb = VDBConfigurationReader.loadVDB(deployName, defFile, vdbFile);
- }
-
- // Add the connector binding in the VDB to the system
- validateConnectorBindingsInVdb(vdb, options);
-
- // now deploy the VDB into the system. Flag is to
- VDBArchive deployedVDB = getConfigurationService().addVDB(vdb, !options.containsOption(AdminOptions.OnConflict.IGNORE));
-
- // If the connector bindings are correctly initialized and VDB is active
- // start the bindings automatically.
- if ( (deployedVDB.getStatus() == VDBStatus.ACTIVE) ||
- (deployedVDB.getStatus() == VDBStatus.ACTIVE_DEFAULT) ) {
- try {
- startVDBConnectorBindings(deployedVDB);
- } catch (MetaMatrixComponentException e) {
- } catch (ApplicationLifecycleException e) {
- // we can safely ignore these because the cause of the not starting is already recorded
- // and more likely VDB deployment succeeded.
- }
- }
-
- return (VDB) convertToAdminObjects(deployedVDB);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * Start the connector bindings in the given VDB
- * @param vdb
- */
- private void startVDBConnectorBindings(VDBArchive vdb) throws MetaMatrixComponentException,
- ApplicationLifecycleException {
-//
-// VDBDefn def = vdb.getConfigurationDef();
-// Collection<ConnectorBinding> bindings = def.getConnectorBindings().values();
-// for (ConnectorBinding binding:bindings) {
-// getDataService().startConnectorBinding(binding.getDeployedName());
-// }
- }
-
- /**
- * Validate the connector bindings in a VDB. Since the connector bindings in VDB
- * are VDB scoped there is no meaning for the admin options provided. Just check
- * the decrypt properties.
- */
- void validateConnectorBindingsInVdb(VDBArchive vdb, AdminOptions options)
- throws MetaMatrixComponentException, AdminProcessingException, AdminException {
-
- VDBDefn def = vdb.getConfigurationDef();
-
- int version = 0;
- VDBArchive existing = null;
- do {
- version++;
- existing = getConfigurationService().getVDB(def.getName(), String.valueOf(version));
- } while(existing != null);
-
- // Look for the connector bindings in the VDB
- // Based on users preference, either add or replace or throw exception
- List vdbbindings = new ArrayList(def.getConnectorBindings().values());
-
- for (Iterator i = vdbbindings.iterator(); i.hasNext();) {
- ConnectorBinding binding = (ConnectorBinding)i.next();
-
- String deployName = binding.getDeployedName();
- if (deployName == null) {
- deployName = binding.getFullName();
- }
-
- if (bindingExists(deployName)) {
- if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists", binding.getDeployedName())); //$NON-NLS-1$
- }
- }
-
- // when the binding is not found it falls in "add", "overwrite" or "ignore"
- // first two cases we need to add.
- ConnectorBindingType type = (ConnectorBindingType)def.getConnectorType(binding.getComponentTypeID().getName());
-
- // Check that the connector binding passwords can be decrypted
- try {
- checkDecryption(binding, type);
- } catch(CryptoException e) {
- if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED", binding.getFullName())); //$NON-NLS-1$
- }
- }
- }
- }
-
- /**
- * Check that the properties of the specified ConnectorBinding can be decrypted.
- * @param
- * @return
- * @since 4.3
- */
- private void checkDecryption(ConnectorBinding binding, ConnectorBindingType type) throws CryptoException {
- Properties props = binding.getProperties();
- Iterator it = props.keySet().iterator();
- while (it.hasNext()) {
- String name = (String)it.next();
- if (isMaskedProperty(name, type)) {
- decryptProperty(props.getProperty(name));
- }
- }
- }
-
- /**
- * Check to see if the property read is a masked/encoded property
- * @param propName
- * @param type
- * @return
- */
- boolean isMaskedProperty(String propName, ComponentType type) {
- if (type != null) {
- ComponentTypeDefn typeDef = type.getComponentTypeDefinition(propName);
- if (typeDef != null && typeDef.getPropertyDefinition().isMasked()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Decrypt the given property using the Crypto libraries.
- * @param value
- * @return decrypted property.
- */
- String decryptProperty(String value) throws CryptoException{
- if (value != null && value.length() > 0 && CryptoUtil.isValueEncrypted(value)) {
- return CryptoUtil.stringDecrypt(value);
- }
- return value;
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addVDB(java.lang.String, byte[], AdminOptions)
- * @since 4.3
- */
- public VDB addVDB(String deployName, byte[] vdbFile, AdminOptions options)
- throws AdminException {
- return addVDB(deployName, vdbFile, null, options);
- }
-
- @Override
- public void deleteVDB(String vdbName, String vdbVersion) throws AdminException {
- super.changeVDBStatus(vdbName, vdbVersion, VDB.DELETED);
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addExtensionModule(java.lang.String, java.lang.String, byte[], java.lang.String)
- * @since 4.3
- */
- public void addExtensionModule(String type, String sourceName, byte[] source, String description)
- throws AdminException {
-// try {
-// if (sourceName == null) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name")); //$NON-NLS-1$
-// }
-// if (source == null || source.length == 0) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source")); //$NON-NLS-1$
-// }
-// if (!sourceName.endsWith(".jar") && !sourceName.endsWith(".xmi")) { //$NON-NLS-1$ //$NON-NLS-2$
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_module")); //$NON-NLS-1$
-// }
-// ExtensionModule previousModule = null;
-//
-// try {
-// previousModule = getConfigurationService().getExtensionModule(sourceName);
-// }catch(MetaMatrixComponentException e) {
-// // this is OK, we did not find any thing
-// }
-//
-// if ( previousModule == null) {
-// // Now add it.
-// BasicExtensionModule extModule = new BasicExtensionModule(sourceName, type, description, source);
-// getConfigurationService().saveExtensionModule(extModule);
-// }
-// else {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.extension_module_exists", sourceName)); //$NON-NLS-1$
-// }
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#deleteExtensionModule(java.lang.String)
- * @since 4.3
- */
- public void deleteExtensionModule(String sourceName)
- throws AdminException {
-// try {
-// if (sourceName == null) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name")); //$NON-NLS-1$
-// }
-// getConfigurationService().deleteExtensionModule(sourceName);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#assignBindingToModel(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- * @since 4.3
- */
- public void assignBindingToModel(String deployedConnectorBindingName, String vdbName, String vdbVersion, String modelName)
- throws AdminException {
-
- if (deployedConnectorBindingName == null || !deployedConnectorBindingName.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
- }
-
- if (vdbName == null || vdbVersion == null || !vdbName.matches(SINGLE_WORD_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name")); //$NON-NLS-1$
- }
-
- if (modelName == null || !modelName.matches(MULTIPLE_WORDS_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_model_name")); //$NON-NLS-1$
- }
-
- // find the connector binding if found in the configuration service
- // add to the vdb binding.
- try {
- ConnectorBinding binding = null;//getDataService().getConnectorBinding(deployedConnectorBindingName);
- if (binding != null) {
- List list = new ArrayList();
- list.add(binding);
- getConfigurationService().assignConnectorBinding(vdbName, vdbVersion, modelName, (ConnectorBinding[])list.toArray(new ConnectorBinding[list.size()]));
- }
- else {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Vdb_or_Model_notfound")); //$NON-NLS-1$
- }
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- public void assignBindingsToModel(String[] deployedConnectorBindingName, String vdbName, String vdbVersion, String modelName) throws AdminException {
- if (deployedConnectorBindingName == null || deployedConnectorBindingName.length == 0) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
- }
-
- if (vdbName == null || vdbVersion == null || !vdbName.matches(SINGLE_WORD_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name")); //$NON-NLS-1$
- }
-
- if (modelName == null || !modelName.matches(MULTIPLE_WORDS_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_model_name")); //$NON-NLS-1$
- }
-
- // find the connector binding if found in the configuration service
- // add to the vdb binding.
- try {
- List list = new ArrayList();
- for (int i = 0; i < deployedConnectorBindingName.length; i++) {
- ConnectorBinding binding = null; //getDataService().getConnectorBinding(deployedConnectorBindingName[i]);
- if (binding != null) {
- list.add(binding);
- }
- }
-
- if (!list.isEmpty()) {
- getConfigurationService().assignConnectorBinding(vdbName, vdbVersion, modelName, (ConnectorBinding[])list.toArray(new ConnectorBinding[list.size()]));
- }
- else {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Vdb_or_Model_notfound")); //$NON-NLS-1$
- }
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
-
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#getLogConfiguration()
- * @since 4.3
- */
- public LogConfiguration getLogConfiguration()
- throws AdminException {
- return (LogConfiguration)convertToAdminObjects(LogManager.getLogConfigurationCopy());
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#setLogConfiguration(org.teiid.adminapi.LogConfiguration)
- * @since 4.3
- */
- public void setLogConfiguration(LogConfiguration config)
- throws AdminException {
- LogManager.setLogConfiguration((com.metamatrix.common.log.LogConfiguration)convertToNativeObjects(config));
- }
-
- /**
- * @see com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#setLogListener(java.lang.Object)
- * @since 4.3
- */
- public void setLogListener(EmbeddedLogger listener)
- throws AdminException {
- if(listener != null) {
- LogManager.setLogListener(new DQPLogListener(listener));
- }
- else {
- throw new AdminProcessingException("Admin_invalid_log_listener"); //$NON-NLS-1$
- }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#exportExtensionModule(java.lang.String)
- * @since 4.3
- */
- public byte[] exportExtensionModule(String sourceName) throws AdminException {
-// try {
-// if (sourceName == null) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name")); //$NON-NLS-1$
-// }
-//
-// ExtensionModule extModule = getConfigurationService().getExtensionModule(sourceName);
-// return extModule.getFileContents();
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return null;
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#exportConfiguration()
- * @since 4.3
- */
- public char[] exportConfiguration() throws AdminException {
- try {
- StringWriter sw = new StringWriter();
- Properties props = getConfigurationService().getSystemProperties();
- props.store(sw, "Export of Teiid Configuration Properties"); //$NON-NLS-1$
- return sw.toString().toCharArray();
- } catch (IOException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#exportConnectorBinding(java.lang.String)
- * @since 4.3
- */
- public char[] exportConnectorBinding(String identifier)
- throws AdminException {
-// try {
-// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
-// }
-//
-// List bindingList = getDataService().getConnectorBindings();
-// List matchedList = new ArrayList();
-// for (Iterator i = bindingList.iterator(); i.hasNext();) {
-// ConnectorBinding binding = (ConnectorBinding)i.next();
-// if (matches(identifier, binding.getDeployedName())) {
-// matchedList.add(binding);
-// }
-// }
-//
-// if (!matchedList.isEmpty()) {
-// ConnectorBinding[] bindings = (ConnectorBinding[])matchedList.toArray(new ConnectorBinding[matchedList.size()]);
-// ConnectorBindingType[] types = new ConnectorBindingType[bindings.length];
-//
-// for (int i = 0; i < bindings.length; i++) {
-// types[i] = getConfigurationService().getConnectorType(bindings[i].getComponentTypeID().getName());
-// }
-// return ConnectorConfigurationWriter.writeToCharArray(bindings, types);
-// }
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists", identifier)); //$NON-NLS-1$
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return null;
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#exportConnectorType(java.lang.String)
- * @since 4.3
- */
- public char[] exportConnectorType(String identifier)
- throws AdminException {
-// try {
-// if (identifier == null || !identifier.matches(MULTIPLE_WORDS_REGEX)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
-// }
-//
-// List typesList = getConfigurationService().getConnectorTypes();
-// List matchedList = new ArrayList();
-// for (Iterator i = typesList.iterator(); i.hasNext();) {
-// ConnectorBindingType type = (ConnectorBindingType)i.next();
-// if (matches(identifier, type.getName())) {
-// matchedList.add(type);
-// }
-// }
-//
-// if (!matchedList.isEmpty()) {
-// ConnectorBindingType[] types = (ConnectorBindingType[])matchedList.toArray(new ConnectorBindingType[matchedList.size()]);
-// return ConnectorConfigurationWriter.writeToCharArray(types);
-// }
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_does_not_exists", identifier)); //$NON-NLS-1$
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return null;
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#exportVDB(java.lang.String, java.lang.String)
- * @since 4.3
- */
- public byte[] exportVDB(String name, String version)
- throws AdminException {
-
- try {
- if (name == null || version == null || !name.matches(SINGLE_WORD_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name")); //$NON-NLS-1$
- }
-
- VDBArchive vdb = getConfigurationService().getVDB(name, version);
- if (vdb != null) {
- return VDBArchive.writeToByteArray(vdb);
- }
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.vdb_does_not_exists", name, version)); //$NON-NLS-1$
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorArchive(byte[], org.teiid.adminapi.AdminOptions)
- * @since 4.3.2
- */
- public void addConnectorArchive(byte[] contents, AdminOptions options) throws AdminException {
-
- // if the options object is null treat as if it is IGNORE as default
- if (options == null) {
- options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
- }
-
- if (contents == null || contents.length == 0) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_source")); //$NON-NLS-1$
- }
-
- try {
- // Load the connector Archive from the file
- HashSet previouslyAddedModules = new HashSet();
- ConnectorArchive archive = ConnectorConfigurationReader.loadConnectorArchive(contents);
- ConnectorBindingType[] connectorTypes = archive.getConnectorTypes();
-
- // Loop through each type and add all of them based on the option.
- for (int typeIndex = 0; typeIndex < connectorTypes.length; typeIndex++) {
-
- // first make sure we do not already have this connector type
- String connectorName = connectorTypes[typeIndex].getName();
- ConnectorBindingType type = getConfigurationService().getConnectorType(connectorName);
- if (type == null) {
- type = connectorTypes[typeIndex];
- ExtensionModule[] extModules = archive.getExtensionModules(type);
- checkDuplicateExtensionModules(extModules, options, previouslyAddedModules);
- saveConnectorType(type);
-
- } else {
-
- // if not asked to overwrite/skip writing them
- if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_exists", connectorName)); //$NON-NLS-1$
- } else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
- continue;
- } else if (options.containsOption(AdminOptions.OnConflict.OVERWRITE)){
- deleteConnectorType(connectorName);
- // Now that we know we need to add this to configuration; let's get on with it
- type = connectorTypes[typeIndex];
- ExtensionModule[] extModules = archive.getExtensionModules(type);
- checkDuplicateExtensionModules(extModules, options, previouslyAddedModules);
- saveConnectorType(type);
- }
- }
- // Now that we know we need to add this to configuration; let's get on with it
- type = connectorTypes[typeIndex];
- ExtensionModule[] extModules = archive.getExtensionModules(type);
- checkDuplicateExtensionModules(extModules, options, previouslyAddedModules);
- }
-
- // Now add the extension modules
- for (Iterator i = previouslyAddedModules.iterator(); i.hasNext();) {
- ExtensionModule extModule = (ExtensionModule)i.next();
- addExtensionModule(extModule.getModuleType(), extModule.getFullName(), extModule.getFileContents(), extModule.getDescription());
- }
-
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * This method checks the passed in connector type's extension module is not already in the
- * system, if it there takes the appropriate action. Otherwise keeps tracks of all modules
- * to add.
- * @param type - connector type
- * @param extModules - Extension modules for the Connector Type
- * @param options - Admin Options
- * @param ignorableModules - Modules which are already added, can be ignored for adding
- */
- void checkDuplicateExtensionModules(ExtensionModule[] extModules, AdminOptions options, HashSet ignorableModules)
- throws AdminException {
-
- // Now check if the the extension modules are already there
- for (int i = 0; i < extModules.length; i++) {
- boolean add = true;
-
- String moduleName = extModules[i].getFullName();
- ExtensionModule previousModule = null;
-
- // see if we can ignore this, because we may have just added this during import of
- // another connector type through this archive
- if (ignorableModules.contains(extModules[i])) {
- continue;
- }
-
- // we have not already added this this time around, now check if this available
- // from configuration service
- try {
- previousModule = getConfigurationService().getExtensionModule(moduleName);
- }catch(MetaMatrixComponentException e) {
- // this is OK, we did not find any thing
- }
-
- // if we found it take appropriate action.
- if(previousModule != null && options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.extension_module_exists", previousModule.getFullName())); //$NON-NLS-1$
- }
- else if (previousModule != null && options.containsOption(AdminOptions.OnConflict.IGNORE)) {
- add = false;
- }
- else if (previousModule != null && options.containsOption(AdminOptions.OnConflict.OVERWRITE)) {
- // since we are overwrite, first delete and then add, there is no safe way to overwrite
- deleteExtensionModule(previousModule.getFullName());
- }
-
- // Now keep track what extension modules to add; also to ignore in future
- // adds
- if (add) {
- ignorableModules.add(extModules[i]);
- }
- }
- }
-
- /**
- * @see org.teiid.adminapi.ConfigurationAdmin#exportConnectorArchive(java.lang.String)
- * @since 4.3
- */
- public byte[] exportConnectorArchive(String identifier) throws AdminException {
-// try {
-// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
-// }
-//
-// // first build the connector archive object
-// BasicConnectorArchive archive = new BasicConnectorArchive();
-// List connectorTypes = getConfigurationService().getConnectorTypes();
-//
-// for (Iterator i = connectorTypes.iterator(); i.hasNext();) {
-// ConnectorBindingType type = (ConnectorBindingType)i.next();
-//
-// // If the types name matches with the pattern sent in add to archive
-// if (type != null && matches(identifier, type.getName())) {
-//
-// // Add connector type first
-// archive.addConnectorType(type);
-//
-// // Get the extension modules required for the type
-// String[] extModules = type.getExtensionModules();
-// for (int m = 0; m < extModules.length; m++) {
-// // Get the extension module from the configuration and add to the archive
-// ExtensionModule extModule = getConfigurationService().getExtensionModule(extModules[m]);
-// if (extModule != null) {
-// archive.addExtensionModule(type, extModule);
-// }
-// else {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("DataService.ext_module_not_found", extModules[m])); //$NON-NLS-1$
-// }
-// }
-// }
-// }
-//
-// // if no types found to the identifier pattern, then throw an exception
-// if (archive.getConnectorTypes().length == 0) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_does_not_exists", identifier)); //$NON-NLS-1$
-// }
-//
-// // now convert the object into file form
-// return ConnectorConfigurationWriter.writeToByteArray(archive);
-//
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return null;
- }
-
- private void saveConnectorType(ConnectorBindingType type) throws MetaMatrixComponentException {
- getConfigurationService().saveConnectorType(type);
- }
-
-
- @Override
- public void addUDF(byte[] modelFileContents, String classpath)
- throws AdminException {
- if (modelFileContents == null || modelFileContents.length == 0) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_UDF_contents")); //$NON-NLS-1$
- }
-
- try {
-
- getConfigurationService().unloadUDF();
-
- // delete any extension module by the same name first
- try {
- deleteExtensionModule(ConfigurationService.USER_DEFINED_FUNCTION_MODEL);
- } catch (AdminException e) {
- // if not found then it is OK to fail
- }
-
- // add the function definitions as extension modules
- addExtensionModule(ExtensionModule.FUNCTION_DEFINITION_TYPE,ConfigurationService.USER_DEFINED_FUNCTION_MODEL,modelFileContents, "User Defined Functions File"); //$NON-NLS-1$
-
- String commonpath = getConfigurationService().getSystemProperties().getProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH, ""); //$NON-NLS-1$
-
- StringBuilder sb = new StringBuilder();
- if (classpath != null && classpath.length() > 0 ) {
- StringTokenizer st = new StringTokenizer(classpath, ";"); //$NON-NLS-1$
- while (st.hasMoreTokens()) {
- String partpath = st.nextToken();
- if (commonpath.indexOf(partpath) == -1) {
- sb.append(partpath).append(";"); //$NON-NLS-1$
- }
- }
- }
- getConfigurationService().setSystemProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH, sb.toString()+commonpath);
-
-
- // then update the properties
- Properties p = new Properties();
- p.setProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH, classpath);
- getConfigurationService().updateSystemProperties(p);
- // reload the new UDF
- getConfigurationService().loadUDF();
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public void deleteUDF() throws AdminException {
- try {
- getConfigurationService().unloadUDF();
- deleteExtensionModule(ConfigurationService.USER_DEFINED_FUNCTION_MODEL);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public void extensionModuleModified(String name) throws AdminException {
- try {
- getConfigurationService().clearClassLoaderCache();
- getConfigurationService().loadUDF();
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public void setProcessProperty(String processIdentifier, String propertyName, String propertyValue) throws AdminException{
- try {
- getConfigurationService().setSystemProperty(propertyName, propertyValue);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-}
Deleted: branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.embedded.admin;
-
-import org.teiid.adminapi.EmbeddedLogger;
-import org.teiid.adminapi.LogConfiguration;
-
-import com.metamatrix.core.log.LogListener;
-import com.metamatrix.core.log.MessageLevel;
-
-
-public class DQPLogListener implements LogListener {
-
- private EmbeddedLogger logger;
-
- public DQPLogListener(EmbeddedLogger logger) {
- this.logger = logger;
- }
-
- public void log(int level, String context, Object msg) {
- logger.log(convertLevel(level), System.currentTimeMillis(), context, Thread.currentThread().getName(), msg.toString(), null);
- }
-
- public void log(int level, String context, Throwable t, Object msg) {
- logger.log(convertLevel(level), System.currentTimeMillis(), context, Thread.currentThread().getName(), msg.toString(), t);
- }
-
- private int convertLevel(int level) {
- int logLevel = LogConfiguration.INFO;
-
- switch(level) {
- case MessageLevel.WARNING:
- logLevel = LogConfiguration.WARNING;
- break;
- case MessageLevel.ERROR:
- logLevel = LogConfiguration.ERROR;
- break;
- case MessageLevel.DETAIL:
- logLevel = LogConfiguration.DETAIL;
- break;
- case MessageLevel.TRACE:
- logLevel = LogConfiguration.TRACE;
- break;
- case MessageLevel.NONE:
- logLevel = LogConfiguration.NONE;
- break;
-
- default:
- logLevel = LogConfiguration.INFO;
- }
- return logLevel;
- }
-
- public void shutdown() {
- }
-}
Deleted: branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -1,327 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.embedded.admin;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.Cache;
-import org.teiid.adminapi.ConnectionPool;
-import org.teiid.adminapi.ConnectorBinding;
-import org.teiid.adminapi.ConnectorType;
-import org.teiid.adminapi.ExtensionModule;
-import org.teiid.adminapi.MonitoringAdmin;
-import org.teiid.adminapi.ProcessObject;
-import org.teiid.adminapi.PropertyDefinition;
-import org.teiid.adminapi.QueueWorkerPool;
-import org.teiid.adminapi.Request;
-import org.teiid.adminapi.Session;
-import org.teiid.adminapi.Transaction;
-import org.teiid.adminapi.VDB;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.config.api.ConnectorBindingType;
-import com.metamatrix.common.vdb.api.VDBArchive;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.server.serverapi.RequestInfo;
-
-
-/**
- * DQP implementation of the Monitoring API
- * @since 4.3
- */
-public class DQPMonitoringAdminImpl extends BaseAdmin implements MonitoringAdmin {
-
- public DQPMonitoringAdminImpl(EmbeddedConnectionFactoryImpl manager) {
- super(manager);
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getConnectorTypes(java.lang.String)
- * @since 4.3
- */
- public Collection<ConnectorType> getConnectorTypes(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
-
- return super.getConnectorTypes(identifier);
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getVDBs(java.lang.String)
- * @since 4.3
- */
- public Collection<VDB> getVDBs(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(VDB_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
-
- // if . and * not specified, add a STAR at the end to compensate for the
- // version number matching.
- if (identifier.indexOf(DOT) == -1 && identifier.indexOf(STAR) == -1) {
- identifier = identifier +DOT+STAR;
- }
-
- try {
- List<VDBArchive> vdbs = getVDBService().getAvailableVDBs();
- List matchedVdbs = new ArrayList();
- for (VDBArchive vdb:vdbs) {
- if (matches(identifier, vdb.getName()+"."+vdb.getVersion())) { //$NON-NLS-1$
- matchedVdbs.add(vdb);
- }
- }
- return (List)convertToAdminObjects(matchedVdbs);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getConnectorBindings(java.lang.String)
- * @since 4.3
- */
- public Collection<ConnectorBinding> getConnectorBindings(String identifier)
- throws AdminException {
-
- if (identifier == null) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
- return super.getConnectorBindings(identifier);
- }
-
-
- @Override
- public Collection<ConnectorBinding> getConnectorBindingsInVDB(String vdbName, String vdbVersion) throws AdminException{
- try {
- VDBArchive vdb = getConfigurationService().getVDB(vdbName, vdbVersion);
- if (vdb != null) {
- return (List)convertToAdminObjects(vdb.getConfigurationDef().getConnectorBindings().values());
- }
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.vdb_does_not_exists", vdbVersion, vdbVersion)); //$NON-NLS-1$
-
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getExtensionModules(java.lang.String)
- * @since 4.3
- */
- public Collection<ExtensionModule> getExtensionModules(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(WORD_AND_DOT_WILDCARD_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
-
- try {
- List extModules = getConfigurationService().getExtensionModules();
- extModules = (List)convertToAdminObjects(extModules);
- return matchedCollection(identifier, extModules);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getQueueWorkerPools(java.lang.String)
- * @since 4.3
- */
- public Collection<QueueWorkerPool> getQueueWorkerPools(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
-
- List results = new ArrayList();
- if (matches(identifier, "dqp")) { //$NON-NLS-1$
- // First get the queue statistics for the DQP
- Collection c = getManager().getDQP().getQueueStatistics();;
- if (c != null && !c.isEmpty()) {
- results.addAll(c);
- }
- }
-
- try {
- // Now get for all the connector bindings
- Collection bindings = super.getConnectorBindings(identifier);
- for (Iterator i = bindings.iterator(); i.hasNext();) {
- ConnectorBinding binding = (ConnectorBinding)i.next();
- Collection c = getDataService().getConnectorStatistics(binding.getName());
- if (c != null && !c.isEmpty()) {
- results.addAll(c);
- }
- }
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
-
- if (!results.isEmpty()) {
- return (List)convertToAdminObjects(results);
- }
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getCaches(java.lang.String)
- * @since 4.3
- */
- public Collection<Cache> getCaches(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(SINGLE_WORD_WILDCARD_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
-
- List cacheList = new ArrayList();
- for (int i =0; i < cacheTypes.length; i++) {
- if (matches(identifier, cacheTypes[i])) {
- cacheList.add(cacheTypes[i]);
- }
- }
- return cacheList;
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getSessions(java.lang.String)
- * @since 4.3
- */
- public Collection<Session> getSessions(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(NUMBER_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
- return matchedCollection(identifier, (List)convertToAdminObjects(getClientConnections()));
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getRequests(java.lang.String)
- * @since 4.3
- */
- public Collection<Request> getRequests(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(NUMBER_DOT_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
-
- ArrayList requestList = new ArrayList();
- // List contains both top and atomic requests, only add the top requests
- List<RequestInfo> requests = getManager().getDQP().getRequests();
- for(RequestInfo request:requests) {
- if (request.getConnectorBindingUUID() == null) {
- requestList.add(request);
- }
- }
- return matchedCollection(identifier, (List)convertToAdminObjects(requestList));
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getSourceRequests(java.lang.String)
- * @since 4.3
- */
- public Collection<Request> getSourceRequests(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(NUMBER_DOT_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
-
- ArrayList atomicRequestList = new ArrayList();
- List<RequestInfo> requests = getManager().getDQP().getRequests();
- for (RequestInfo request:requests) {
- if (request.getConnectorBindingUUID() != null) {
- atomicRequestList.add(request);
- }
- }
- return matchedCollection(identifier, (List)convertToAdminObjects(atomicRequestList));
- }
-
- /**
- * @see org.teiid.adminapi.MonitoringAdmin#getPropertyDefinitions(java.lang.String, java.lang.String)
- * @since 4.3
- */
- public Collection<PropertyDefinition> getConnectorTypePropertyDefinitions(String typeName) throws AdminException {
-
- if (typeName == null || !typeName.matches(MULTIPLE_WORDS_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
- }
-
- try {
- ConnectorBindingType type = getConfigurationService().getConnectorType(typeName);
- if (type == null) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.ct_doesnot_exist", typeName)); //$NON-NLS-1$
- }
-
- return convertPropertyDefinitions(type, new Properties());
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public Collection<Transaction> getTransactions()
- throws AdminException {
- TransactionService ts = getTransactionService();
- if (ts == null) {
- return Collections.emptyList();
- }
- return ts.getTransactions();
- }
-
- @Override
- public Collection<? extends ConnectionPool> getConnectionPoolStats(String identifier)
- throws AdminException {
-
-// try {
-// return this.getDataService().getConnectionPoolStatistics(identifier);
-// } catch (MetaMatrixComponentException e) {
-// throw new AdminComponentException(e);
-// }
- return Collections.EMPTY_LIST;
- }
-
- @Override
- public Collection<ProcessObject> getProcesses(String processIdentifier) throws AdminException {
- ArrayList<ProcessObject> list = new ArrayList<ProcessObject>();
- list.add(getManager().getProcess());
- return list;
- }
-}
Deleted: branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -1,302 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.embedded.admin;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import javax.transaction.xa.Xid;
-
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminObject;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.Cache;
-import org.teiid.adminapi.ConnectorBinding;
-import org.teiid.adminapi.Request;
-import org.teiid.adminapi.RuntimeStateAdmin;
-import org.teiid.dqp.internal.process.DQPWorkContext;
-
-import com.metamatrix.admin.objects.MMRequest;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
-
-
-/**
- * @since 4.3
- */
-public class DQPRuntimeStateAdminImpl extends BaseAdmin implements RuntimeStateAdmin {
-
- public DQPRuntimeStateAdminImpl(EmbeddedConnectionFactoryImpl manager) {
- super(manager);
- }
-
- /**
- * @see com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#stop(int)
- * @since 4.3
- */
- public void shutdown(int millisToWait) throws AdminException {
- // TODO: rreddy need to implement the time to wait.
- // First terminate all the sessions to the DQP currently have
- terminateSession(AdminObject.WILDCARD);
-
- getManager().shutdown(false);
- }
-
- /**
- * @see com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#restart()
- * @since 4.3
- */
- public void restart() throws AdminException {
- // First terminate all the sessions to the DQP currently have
- terminateSession(AdminObject.WILDCARD);
-
- // Now shutdown the DQP, it will automatically start next timea new connection is
- // requested.
- getManager().shutdown(true);
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#startConnectorBinding(java.lang.String)
- * @since 4.3
- */
- public void startConnectorBinding(String identifier)
- throws AdminException {
-
-// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
-// }
-//
-// AdminException exceptionWrapper = null;
-// // Get all matching connector bindings
-// Collection bindings = getConnectorBindings(identifier);
-// if (bindings != null && !bindings.isEmpty()) {
-// for (Iterator i = bindings.iterator(); i.hasNext();) {
-// try {
-// AdminObject binding = (AdminObject)i.next();
-// getDataService().startConnectorBinding(binding.getName());
-// } catch (ApplicationLifecycleException e) {
-// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
-// } catch (MetaMatrixComponentException e) {
-// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
-// }
-// }
-// }
-// else {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists", new Object[] {identifier})); //$NON-NLS-1$
-// }
-//
-// // If any errors occurred then thow the exception.
-// if (exceptionWrapper != null) {
-// throw exceptionWrapper;
-// }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#stopConnectorBinding(java.lang.String, boolean)
- * @since 4.3
- */
- public void stopConnectorBinding(String identifier, boolean stopNow)
- throws AdminException {
-// // TODO: need to implement "now" part
-// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
-// }
-//
-// AdminException exceptionWrapper = null;
-// // Get all matching connector bindings
-// Collection bindings = getConnectorBindings(identifier);
-// if (bindings != null && !bindings.isEmpty()) {
-// for (Iterator i = bindings.iterator(); i.hasNext();) {
-// try {
-// AdminObject binding = (AdminObject)i.next();
-// getDataService().stopConnectorBinding(binding.getName());
-// } catch (ApplicationLifecycleException e) {
-// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
-// } catch (MetaMatrixComponentException e) {
-// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
-// }
-// }
-// }
-// else {
-// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists", new Object[] {identifier})); //$NON-NLS-1$
-// }
-//
-// // If any errors occurred then thow the exception.
-// if (exceptionWrapper != null) {
-// throw exceptionWrapper;
-// }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#clearCache(java.lang.String)
- * @since 4.3
- */
- public void clearCache(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches(SINGLE_WORD_WILDCARD_REGEX)) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
- boolean processed = false;
-
- for (int i = 0; i < cacheTypes.length; i++) {
- if (matches(identifier, cacheTypes[i])) {
- if(cacheTypes[i].equals(Cache.CODE_TABLE_CACHE)) {
- processed = true;
- getManager().getDQP().clearCodeTableCache();
- } else if(cacheTypes[i].equals(Cache.PREPARED_PLAN_CACHE)) {
- processed = true;
- getManager().getDQP().clearPlanCache();
- } else if(cacheTypes[i].equals( Cache.QUERY_SERVICE_RESULT_SET_CACHE)) {
- processed = true;
- getManager().getDQP().clearResultSetCache();
- } else if (cacheTypes[i].equals(Cache.CONNECTOR_RESULT_SET_CACHE)) {
- processed = true;
- try {
- // Now get for all the connector bindings
- Collection bindings = super.getConnectorBindings("*"); //$NON-NLS-1$
- for (Iterator iter = bindings.iterator(); iter.hasNext();) {
- ConnectorBinding binding = (ConnectorBinding)iter.next();
- getDataService().clearConnectorBindingCache(binding.getName());
- }
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
- }
- }
-
- if (!processed) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.invalid_request", new Object[] {identifier})); //$NON-NLS-1$
- }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#terminateSession(java.lang.String)
- * @since 4.3
- */
- public void terminateSession(String identifier)
- throws AdminException {
-
- Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
- ArrayList<MetaMatrixSessionInfo> matchedConnections = new ArrayList<MetaMatrixSessionInfo>();
-
- for (MetaMatrixSessionInfo info:sessions) {
- String id = info.getSessionID().toString();
- if (matches(identifier, id)) {
- matchedConnections.add(info);
- }
- }
-
- // terminate the sessions.
- for (MetaMatrixSessionInfo info: matchedConnections) {
- getSessionService().terminateSession(info.getSessionID(), DQPWorkContext.getWorkContext().getSessionId());
- }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#cancelRequest(java.lang.String)
- * @since 4.3
- */
- public void cancelRequest(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches("\\d+\\" + Request.DELIMITER + "\\d+")) { //$NON-NLS-1$ //$NON-NLS-2$
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
-
- String[] identifierParts = MMRequest.buildIdentifierArray(identifier);
- String connId = identifierParts[0];
- long requestId = Long.parseLong(identifierParts[1]);
-
- // get the client connection
- RequestID id = new RequestID(connId, requestId);
-
- try {
- getManager().getDQP().cancelRequest(id);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#cancelSourceRequest(java.lang.String)
- * @since 4.3
- */
- public void cancelSourceRequest(String identifier)
- throws AdminException {
-
- if (identifier == null || !identifier.matches("\\d+\\" + Request.DELIMITER + "\\d+\\" + Request.DELIMITER + "\\d+" + Request.DELIMITER + "\\d+")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
- }
-
- String[] identifierParts = MMRequest.buildIdentifierArray(identifier);
-
- String connId = identifierParts[0];
- long requestId = Long.parseLong(identifierParts[1]);
- int nodeId = Integer.parseInt(identifierParts[2]);
- int executionId = Integer.parseInt(identifierParts[3]);
- AtomicRequestID id = new AtomicRequestID(new RequestID(connId, requestId), nodeId, executionId);
-
- try {
- getManager().getDQP().cancelAtomicRequest(id);
- } catch (MetaMatrixComponentException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see org.teiid.adminapi.RuntimeStateAdmin#changeVDBStatus(java.lang.String, java.lang.String, int)
- * @since 4.3
- */
- public void changeVDBStatus(String name, String version, int status)
- throws AdminException {
- super.changeVDBStatus(name, version, status);
- }
-
-
- @Override
- public void terminateTransaction(String transactionId, String sessionId)
- throws AdminException {
-// TransactionService ts = getTransactionService();
-// if (ts != null) {
-// ts.terminateTransaction(transactionId, sessionId);
-// }
- }
-
- @Override
- public void terminateTransaction(Xid transactionId) throws AdminException {
- TransactionService ts = getTransactionService();
- if (ts != null) {
- ts.terminateTransaction(transactionId);
- }
- }
-
-}
Deleted: branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -1,275 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.embedded.admin;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.teiid.adminapi.AdminComponentException;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminObject;
-import org.teiid.adminapi.AdminOptions;
-import org.teiid.adminapi.AdminProcessingException;
-import org.teiid.adminapi.Group;
-import org.teiid.adminapi.SecurityAdmin;
-import org.xml.sax.SAXException;
-
-import com.metamatrix.admin.api.exception.security.InvalidSessionException;
-import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
-import com.metamatrix.admin.objects.MMGroup;
-import com.metamatrix.admin.objects.MMRole;
-import com.metamatrix.api.exception.security.AuthorizationException;
-import com.metamatrix.api.exception.security.AuthorizationMgmtException;
-import com.metamatrix.api.exception.security.MembershipServiceException;
-import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
-import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
-import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
-import com.metamatrix.platform.security.api.AuthorizationPolicy;
-import com.metamatrix.platform.security.api.AuthorizationPolicyFactory;
-import com.metamatrix.platform.security.api.AuthorizationRealm;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
-import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
-
-
-/**
- * @since 4.3
- */
-public class DQPSecurityAdminImpl extends BaseAdmin implements SecurityAdmin {
-
- public DQPSecurityAdminImpl(EmbeddedConnectionFactoryImpl manager) {
- super(manager);
- }
-
- /**
- * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#addRoleToGroup(java.lang.String, java.lang.String)
- * @since 4.3
- */
- public void assignRoleToGroup(String roleIdentifier, String groupIdentifier) throws AdminException {
- throw new AdminComponentException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.not_implemented")); //$NON-NLS-1$
- }
-
- /**
- * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#removeRoleFromGroup(java.lang.String, java.lang.String)
- * @since 4.3
- */
- public void removeRoleFromGroup(String roleIdentifier, String groupIdentifier) throws AdminException {
- throw new AdminComponentException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.not_implemented")); //$NON-NLS-1$
- }
-
- /**
- * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#getGroupsForUser(java.lang.String, boolean)
- * @since 4.3
- */
- public Collection<Group> getGroupsForUser(String userIdentifier) throws AdminException {
- if (userIdentifier == null) {
- throwProcessingException("AdminImpl.requiredparameter", new Object[] {}); //$NON-NLS-1$
- }
-
- if ( userIdentifier.equals(AdminObject.WILDCARD) ) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.Cant_use_wildcard")); //$NON-NLS-1$
- }
- Collection groups = new ArrayList();
- // Get all memberships - explicit and implicit
- Set allMemberships = null;
- try {
- allMemberships = getMembershipService().getGroupsForUser(userIdentifier);
- } catch (MetaMatrixSecurityException e) {
- throw new AdminComponentException(e);
- }
- Iterator allMembershipsItr = allMemberships.iterator();
- while ( allMembershipsItr.hasNext() ) {
- groups.add(new MMGroup(new String[] {(String)allMembershipsItr.next()}));
- }
- return groups;
- }
-
- /**
- * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#getGroups(java.lang.String)
- * @since 4.3
- */
- public Collection<Group> getGroups(String groupIdentifier) throws AdminException {
- if (groupIdentifier == null) {
- throwProcessingException("AdminImpl.requiredparameter", new Object[] {}); //$NON-NLS-1$
- }
-
- Collection<Group> groups = new ArrayList<Group>();
- Collection allGroups = null;
- // Add all groups from internal membership domain
- try {
- allGroups = getMembershipService().getGroupNames();
- } catch (MetaMatrixSecurityException e) {
- throw new AdminComponentException(e);
- }
-
- Iterator groupItr = allGroups.iterator();
- while ( groupItr.hasNext() ) {
- String groupName = (String) groupItr.next();
-
- if (!groupIdentifier.equals(AdminObject.WILDCARD) && !groupName.equals(groupIdentifier)) {
- continue;
- }
-
- groups.add(new MMGroup(new String[] {groupName}));
- }
- return groups;
- }
-
-
- /**
- * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#getRolesForGroup(java.lang.String)
- * @since 4.3
- */
- public Collection getRolesForGroup(String groupIdentifier) throws AdminException {
- if (groupIdentifier == null) {
- throwProcessingException("AdminImpl.requiredparameter", new Object[] {}); //$NON-NLS-1$
- }
-
- if ( groupIdentifier.equals(AdminObject.WILDCARD) ) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.Cant_use_wildcard")); //$NON-NLS-1$
- }
- Collection roleNames = null;
- try {
- roleNames = getAuthorizationService().getRoleNamesForPrincipal(new MetaMatrixPrincipalName(groupIdentifier, MetaMatrixPrincipal.TYPE_GROUP));
- } catch (InvalidSessionException e) {
- throw new AdminComponentException(e);
- } catch (AuthorizationMgmtException e) {
- throw new AdminComponentException(e);
- } catch (AuthorizationException e) {
- throw new AdminComponentException(e);
- }
- Collection roles = new ArrayList();
- Iterator roleNameItr = roleNames.iterator();
- while ( roleNameItr.hasNext() ) {
- String roleName = (String)roleNameItr.next();
- roles.add(new MMRole(new String[] {roleName}));
- }
- return roles;
- }
-
- /**
- * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#importDataRoles(java.lang.String, java.lang.String, char[], org.teiid.adminapi.AdminOptions)
- */
- public String importDataRoles(String vdbName, String vdbVersion, char[] xmlContents, AdminOptions options)
- throws AdminException{
-
- if (vdbName == null) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbName_can_not_be_null")); //$NON-NLS-1$
- }
-
- if (vdbVersion == null) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbVersion_can_not_be_null")); //$NON-NLS-1$
- }
-
- if (options == null) {
-
- options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
- }
-
- try {
- EntitlementMigrationReport rpt = new EntitlementMigrationReport("from file", vdbName + " " + vdbVersion); //$NON-NLS-1$ //$NON-NLS-2$
-
- Collection<AuthorizationPolicy> roles = AuthorizationPolicyFactory.buildPolicies(vdbName, vdbVersion, xmlContents);
-
- AuthorizationRealm realm = new AuthorizationRealm(vdbName, vdbVersion);
-
- getAuthorizationService().updatePoliciesInRealm(realm, roles);
-
- return rpt.toString();
- } catch (AuthorizationMgmtException e) {
- throw new AdminProcessingException(e);
- } catch (SAXException e) {
- throw new AdminComponentException(e);
- } catch (IOException e) {
- throw new AdminComponentException(e);
- } catch (ParserConfigurationException e) {
- throw new AdminComponentException(e);
- }
- }
-
- /**
- * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#exportDataRoles(java.lang.String, java.lang.String)
- */
- public char[] exportDataRoles(String vdbName, String vdbVersion) throws AdminException {
-
- if (vdbName == null) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbName_can_not_be_null")); //$NON-NLS-1$
- }
-
- if (vdbVersion == null) {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbVersion_can_not_be_null")); //$NON-NLS-1$
- }
-
- Collection roles = null;
- try {
- roles = getAuthorizationService().getPoliciesInRealm(new AuthorizationRealm(vdbName, vdbVersion));
- if (roles != null && !roles.isEmpty()) {
- return AuthorizationPolicyFactory.exportPolicies(roles);
- }
- return null;
- } catch (AuthorizationMgmtException e) {
- throw new AdminProcessingException(e);
- } catch (AuthorizationException e) {
- throw new AdminProcessingException(e);
- } catch (IOException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public List<String> getDomainNames() throws AdminException {
- try {
- return this.getMembershipService().getDomainNames();
- } catch (MembershipServiceException e) {
- throw new AdminComponentException(e);
- }
- }
-
- @Override
- public Collection<Group> getGroupsForDomain(String domainName)
- throws AdminException {
- if (domainName == null) {
- throwProcessingException("AdminImpl.requiredparameter", new Object[] {}); //$NON-NLS-1$
- }
- try {
- Collection<String> groupNames = this.getMembershipService().getGroupsForDomain(domainName);
- List<Group> result = new ArrayList<Group>(groupNames.size());
- for (String groupName : groupNames) {
- result.add(new MMGroup(new String[] {groupName}));
- }
- return result;
- } catch (MembershipServiceException e) {
- throw new AdminComponentException(e);
- }
- }
-
- void throwProcessingException(String key, Object[] objects) throws AdminException {
- throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString(key, objects));
- }
-
-}
Added: branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java (rev 0)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,229 @@
+/*
+ * 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.jboss;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.ManagedOperation.Impact;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
+import org.jboss.managed.api.annotation.ManagementOperation;
+import org.jboss.managed.api.annotation.ManagementParameter;
+import org.jboss.managed.api.annotation.ManagementProperties;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.TeiidAdminMBean;
+import org.teiid.adminapi.impl.BaseAdmin;
+import org.teiid.adminapi.impl.ConnectorBindingImpl;
+
+@ManagementObject(description="Teiid Admin Interface", componentType=@ManagementComponent(type="teiid",subtype="admin"), properties=ManagementProperties.EXPLICIT, isRuntime=true)
+@JMX(name="jboss.teiid:service=teiid-admin", exposedInterface=TeiidAdminMBean.class, registerDirectly=true)
+public class Admin extends BaseAdmin implements TeiidAdminMBean{
+
+ private static final long serialVersionUID = 7081309086056911304L;
+ private ManagementView managementView = null;
+
+ private ManagementView getView() throws AdminComponentException {
+ if (this.managementView == null) {
+ try {
+ InitialContext context = new InitialContext();
+ this.managementView = (ManagementView)context.lookup("java:ManagementView");
+ this.managementView.load();
+ } catch (NamingException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+ return this.managementView;
+ }
+
+ @Override
+ @ManagementOperation(description="Get names of avaialable connector bindings", impact=Impact.ReadOnly)
+ public Collection<ConnectorBinding> getConnectorBindings() throws AdminException {
+ ArrayList<ConnectorBinding> bindings = new ArrayList<ConnectorBinding>();
+ findConnectorBindings(bindings, "NoTx");
+ findConnectorBindings(bindings, "Tx");
+ return bindings;
+ }
+
+ @Override
+ @ManagementOperation(description="Get names of avaialable connector bindings", impact=Impact.ReadOnly)
+ public ConnectorBinding getConnectorBinding(String deployedName) throws AdminException {
+ Collection<ConnectorBinding> bindings = getConnectorBindings();
+ for(ConnectorBinding cb:bindings) {
+ if (cb.getName().equals(deployedName)) {
+ return cb;
+ }
+ }
+ return null;
+ }
+
+ private void findConnectorBindings(ArrayList<ConnectorBinding> bindings, String subType) throws AdminException {
+ try {
+ ComponentType type = new ComponentType("ConnectionFactory", subType);
+ Set<ManagedComponent> jcaConnectors = getView().getComponentsForType(type);
+
+ for(ManagedComponent mc:jcaConnectors) {
+ ManagedProperty mp = mc.getProperty("connection-definition");
+ SimpleValueSupport v = (SimpleValueSupport)mp.getValue();
+ if (v.getValue().equals("org.teiid.connector.api.Connector")){
+
+ ConnectorBindingImpl cb = new ConnectorBindingImpl(mc.getName());
+ cb.setComponentType(type);
+ for (String key:mc.getProperties().keySet()) {
+ ManagedProperty property = mc.getProperty(key);
+ MetaValue value = property.getValue();
+
+ //TODO: All properties need to be added
+ if (value != null) {
+ if(value instanceof SimpleValueSupport) {
+ cb.addProperty(key, ManagedUtil.stringValue(value));
+ }
+ else if (value.getMetaType() instanceof MapCompositeValueSupport) {
+ MapCompositeValueSupport v1 = (MapCompositeValueSupport)value;
+ MapCompositeMetaType metaType = v1.getMetaType();
+ for (String configProperty:metaType.keySet()) {
+ cb.addProperty(configProperty, ManagedUtil.stringValue(v1.get(configProperty)));
+ }
+ }
+ }
+ }
+ bindings.add(cb);
+ }
+ }
+ }catch(Exception e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ @ManagementOperation(description="Add a new Connector Binding",
+ impact=Impact.WriteOnly,
+ params={@ManagementParameter(name="deploymentName", description="Name of the Connector Binding"),
+ @ManagementParameter(name="typeName", description="Connector Type Template name"),
+ @ManagementParameter(name="properties", description="Properties for the Connector Binding")})
+ public void addConnectorBinding(String deploymentName, String typeName, Properties properties) throws AdminException{
+ try {
+ if (getConnectorBinding(deploymentName) != null) {
+ throw new AdminProcessingException("Connector binding with name "+deploymentName+" already exists.");
+ }
+
+ DeploymentTemplateInfo info = getView().getTemplate(typeName);
+ if(info == null) {
+ throw new AdminProcessingException("Connector Type template supplied not found in the configuration."+typeName);
+ }
+
+ // override these properties always.
+ info.getProperties().get("connection-definition").setValue(SimpleValueSupport.wrap("org.teiid.connector.api.Connector"));
+
+ //config-properties list
+ Map<String, String> configProps = new HashMap<String, String>();
+
+ // template properties specific to the template
+ Map<String, ManagedProperty> propertyMap = info.getProperties();
+
+ // walk through the supplied properties and assign properly to either template
+ // of config-properties.
+ for (String key:properties.stringPropertyNames()) {
+ ManagedProperty mp = propertyMap.get(key);
+ if (mp != null) {
+ String value = properties.getProperty(key);
+ if (!ManagedUtil.sameValue(mp.getDefaultValue(), value)){
+ mp.setValue(SimpleValueSupport.wrap(value));
+ }
+ }
+ else {
+ configProps.put(key, properties.getProperty(key));
+ configProps.put(key+".type", "java.lang.String");
+ }
+ }
+
+ if (configProps.size() > 0) {
+ MetaValue metaValue = ManagedUtil.compositeValueMap(configProps);
+ info.getProperties().get("config-property").setValue(metaValue);
+ }
+
+ getView().applyTemplate(deploymentName, info);
+
+ } catch (NoSuchDeploymentException e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ } catch(Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void deleteConnectorBinding(String deployedName) throws AdminException {
+ ConnectorBindingImpl cb = (ConnectorBindingImpl)getConnectorBinding(deployedName);
+ if (cb != null) {
+ try {
+ ManagedComponent mc = getView().getComponent(cb.getName(), (ComponentType)cb.getComponentType());
+ if (mc != null) {
+ getView().removeComponent(mc);
+ }
+ } catch (Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+ }
+
+ @Override
+ public Set<String> getConnectorTypes() throws AdminException{
+ Set<String> names = getView().getTemplateNames();
+ HashSet<String> matched = new HashSet<String>();
+ for(String name:names) {
+ if (name.startsWith("connector-")) {
+ matched.add(name);
+ }
+ }
+ return matched;
+ }
+
+ boolean matches(String regEx, String value) {
+ regEx = regEx.replaceAll(AdminObject.ESCAPED_WILDCARD, ".*"); //$NON-NLS-1$
+ regEx = regEx.replaceAll(AdminObject.ESCAPED_DELIMITER, ""); //$NON-NLS-1$
+ return value.matches(regEx);
+ }
+}
Property changes on: branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/Admin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java (rev 0)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.adminapi.jboss;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Map;
+
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+
+import com.metamatrix.core.MetaMatrixRuntimeException;
+
+public class ManagedUtil {
+
+ public static boolean sameValue(MetaValue v1, String v2) {
+ if (v1 == null || v2 == null) {
+ return false;
+ }
+
+ MetaType type = v1.getMetaType();
+ if (v1 instanceof SimpleValue && type instanceof SimpleMetaType) {
+ SimpleMetaType st = (SimpleMetaType)type;
+ SimpleValue sv = wrap(st, v2);
+ return sv.compareTo((SimpleValue)v1) == 0;
+ }
+ return false;
+ }
+
+ public static boolean sameValue(MetaValue v1, MetaValue v2) {
+ if (v1 == null || v2 == null) {
+ return false;
+ }
+
+ if (v1 instanceof SimpleValue && v2 instanceof SimpleValue) {
+ return ((SimpleValue)v1).compareTo((SimpleValue)v2) == 0;
+ }
+ return false;
+ }
+
+ public static MapCompositeValueSupport compositeValueMap(Map<String, String> map) {
+ MapCompositeValueSupport metaValue = new MapCompositeValueSupport(SimpleMetaType.STRING);
+ for (String key : map.keySet()) {
+ MetaValue value = SimpleValueSupport.wrap(map.get(key));
+ metaValue.put(key, value);
+ }
+ return metaValue;
+ }
+
+ public static String stringValue(MetaValue v1) {
+ if (v1 != null) {
+ MetaType type = v1.getMetaType();
+ if (type instanceof SimpleMetaType) {
+ SimpleValue simple = (SimpleValue)v1;
+ return simple.getValue().toString();
+ }
+ throw new MetaMatrixRuntimeException("Failed to convert value to string value");
+ }
+ return null;
+ }
+
+ public static SimpleValue wrap(MetaType type, String value) {
+ if (type instanceof SimpleMetaType) {
+ SimpleMetaType st = (SimpleMetaType)type;
+
+ if (SimpleMetaType.BIGDECIMAL.equals(st)) {
+ return new SimpleValueSupport(st, new BigDecimal(value));
+ } else if (SimpleMetaType.BIGINTEGER.equals(st)) {
+ return new SimpleValueSupport(st, new BigInteger(value));
+ } else if (SimpleMetaType.BOOLEAN.equals(st)) {
+ return new SimpleValueSupport(st, Boolean.valueOf(value));
+ } else if (SimpleMetaType.BOOLEAN_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Boolean.valueOf(value).booleanValue());
+ } else if (SimpleMetaType.BYTE.equals(st)) {
+ return new SimpleValueSupport(st, new Byte(value.getBytes()[0]));
+ } else if (SimpleMetaType.BYTE_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, value.getBytes()[0]);
+ } else if (SimpleMetaType.CHARACTER.equals(st)) {
+ return new SimpleValueSupport(st, new Character(value.charAt(0)));
+ } else if (SimpleMetaType.CHARACTER_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st,value.charAt(0));
+ } else if (SimpleMetaType.DATE.equals(st)) {
+ try {
+ return new SimpleValueSupport(st, new SimpleDateFormat().parse(value));
+ } catch (ParseException e) {
+ throw new MetaMatrixRuntimeException("Failed to convert the String to date value");
+ }
+ } else if (SimpleMetaType.DOUBLE.equals(st)) {
+ return new SimpleValueSupport(st, Double.valueOf(value));
+ } else if (SimpleMetaType.DOUBLE_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Double.parseDouble(value));
+ } else if (SimpleMetaType.FLOAT.equals(st)) {
+ return new SimpleValueSupport(st, Float.parseFloat(value));
+ } else if (SimpleMetaType.FLOAT_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Float.valueOf(value));
+ } else if (SimpleMetaType.INTEGER.equals(st)) {
+ return new SimpleValueSupport(st, Integer.valueOf(value));
+ } else if (SimpleMetaType.INTEGER_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Integer.parseInt(value));
+ } else if (SimpleMetaType.LONG.equals(st)) {
+ return new SimpleValueSupport(st, Long.valueOf(value));
+ } else if (SimpleMetaType.LONG_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Long.parseLong(value));
+ } else if (SimpleMetaType.SHORT.equals(st)) {
+ return new SimpleValueSupport(st, Short.valueOf(value));
+ } else if (SimpleMetaType.SHORT_PRIMITIVE.equals(st)) {
+ return new SimpleValueSupport(st, Short.parseShort(value));
+ } else if (SimpleMetaType.STRING.equals(st)) {
+ return new SimpleValueSupport(st,value);
+ }
+ }
+ throw new MetaMatrixRuntimeException("Failed to convert from String value to \""+ type.getClassName() +"\" type");
+ }
+}
Property changes on: branches/JCA/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java (rev 0)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,143 @@
+/*
+ * 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.templates.connector;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.spi.management.DeploymentTemplate;
+import org.jboss.managed.api.DeploymentTemplateInfo;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.profileservice.spi.NoSuchDeploymentException;
+import org.jboss.virtual.VirtualFile;
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.jboss.ManagedUtil;
+
+/**
+ * The connection factory template implementation.
+ */
+public class ConnectorTypeTemplate implements DeploymentTemplate {
+
+ /** The deployment template info. */
+ private DeploymentTemplateInfo info;
+ private DeploymentTemplate targetTemplate;
+
+ /** The file suffix. */
+ private static final String FILE_SUFFIX = "-ds.xml";
+
+
+ public String getDeploymentName(String deploymentBaseName) {
+ if (deploymentBaseName == null)
+ throw new IllegalArgumentException("Null base name.");
+
+ if(deploymentBaseName.endsWith(FILE_SUFFIX) == false)
+ deploymentBaseName = deploymentBaseName + FILE_SUFFIX;
+
+ return deploymentBaseName;
+ }
+
+ public VirtualFile applyTemplate(DeploymentTemplateInfo connectorInfo) throws Exception {
+ try {
+
+ ManagedProperty rar = connectorInfo.getProperties().get("rar-name");
+ String rarName = ManagedUtil.stringValue(rar.getValue());
+ if (!isValidRar(rarName)) {
+ throw new AdminProcessingException("Invalid RAR specified; please supply correct RAR file. "+rarName);
+ }
+
+ DeploymentTemplateInfo targetInfo = getTargetTemplate().getInfo();
+
+ // override these properties always.
+ targetInfo.getProperties().get("connection-definition").setValue(SimpleValueSupport.wrap("org.teiid.connector.api.Connector"));
+ connectorInfo.getProperties().get("connection-definition").setValue(SimpleValueSupport.wrap("org.teiid.connector.api.Connector"));
+
+ //config-properties list
+ Map<String, String> configProps = new HashMap<String, String>();
+
+ // template properties specific to the template
+ Map<String, ManagedProperty> propertyMap = targetInfo.getProperties();
+
+ // walk through the supplied properties and assign properly to either template
+ // or config-properties.
+ for (String key:connectorInfo.getProperties().keySet()) {
+ ManagedProperty mp = propertyMap.get(key);
+
+ if (mp != null) {
+ MetaValue value = connectorInfo.getProperties().get(key).getValue();
+ if (ManagedUtil.sameValue(mp.getDefaultValue(), value)) {
+ continue;
+ }
+
+ if (value != null) {
+ mp.setValue(value);
+ }
+ }
+ else {
+ mp = connectorInfo.getProperties().get(key);
+ if (ManagedUtil.sameValue(mp.getDefaultValue(), mp.getValue())) {
+ continue;
+ }
+
+ if (mp.getValue() != null) {
+ configProps.put(key, ManagedUtil.stringValue(mp.getValue()));
+ configProps.put(key+".type", mp.getValue().getMetaType().getClassName());
+ }
+ }
+ }
+
+ if (configProps.size() > 0) {
+ MetaValue metaValue = ManagedUtil.compositeValueMap(configProps);
+ targetInfo.getProperties().get("config-property").setValue(metaValue);
+ }
+ return getTargetTemplate().applyTemplate(targetInfo);
+
+ } catch (NoSuchDeploymentException e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ } catch(Exception e) {
+ throw new AdminComponentException(e.getMessage(), e);
+ }
+ }
+
+ private boolean isValidRar(String rarName) {
+ return true;
+ }
+
+ @Override
+ public DeploymentTemplateInfo getInfo() {
+ return info;
+ }
+
+ public void setInfo(DeploymentTemplateInfo info) {
+ this.info = info;
+ }
+
+ private DeploymentTemplate getTargetTemplate() {
+ return this.targetTemplate;
+ }
+
+ public void setTargetTemplate(DeploymentTemplate target) {
+ this.targetTemplate = target;
+ }
+}
Property changes on: branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplate.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
===================================================================
--- branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java (rev 0)
+++ branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,110 @@
+/*
+ * 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.templates.connector;
+
+import java.util.Collection;
+import java.util.Map;
+
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.jboss.managed.api.Fields;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.plugins.BasicDeploymentTemplateInfo;
+import org.jboss.managed.plugins.DefaultFieldsImpl;
+import org.jboss.managed.plugins.ManagedPropertyImpl;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.resource.metadata.ConfigPropertyMetaData;
+import org.jboss.resource.metadata.ConnectionDefinitionMetaData;
+import org.jboss.resource.metadata.ConnectorMetaData;
+import org.teiid.adminapi.jboss.ManagedUtil;
+
+/**
+ * This class some magic in it. First off all through the configuration it extends the
+ * NoTxConnectionFactoryTemplate. Then using the JMX adds the properties defined inside a connector
+ * RAR file's ra.xml dynamically the above template. The RAR file name is supplied in the "description"
+ * field of the configuration. Also, it uses the NoTxConnectionFactoryTemplate "applyTemplate" to write
+ * the custom properties that have been added thru JMX as "config-property" in the eventual "-ds.xml" file.
+ */
+public class ConnectorTypeTemplateInfo extends BasicDeploymentTemplateInfo {
+
+ private static final long serialVersionUID = 9066758787789280783L;
+
+ public ConnectorTypeTemplateInfo(String arg0, String arg1, Map<String, ManagedProperty> arg2) {
+ super(arg0, arg1, arg2);
+ }
+
+ public void start() {
+ populate();
+ }
+
+ @Override
+ public ConnectorTypeTemplateInfo copy() {
+ ConnectorTypeTemplateInfo copy = new ConnectorTypeTemplateInfo(getName(), getDescription(), getProperties());
+ super.copy(copy);
+ copy.populate();
+ return copy;
+ }
+
+
+ private void populate() {
+ try {
+ MBeanServer server = MBeanServerFactory.findMBeanServer(null).get(0);
+ ObjectName on = new ObjectName("jboss.jca:service=RARDeployment,name='"+getDescription()+"'");
+ ConnectorMetaData obj = (ConnectorMetaData)server.getAttribute(on, "MetaData");
+ ConnectionDefinitionMetaData metadata = obj.getConnectionDefinition("org.teiid.connector.api.Connector");
+ Collection<ConfigPropertyMetaData> props = metadata.getProperties();
+ for (ConfigPropertyMetaData p:props) {
+ addConnectorProperty(p.getName(), p.getType(), p.getDescription().getDescription(), p.getValue(), false);
+ }
+ } catch (MalformedObjectNameException e) {
+ //ignore
+ } catch (AttributeNotFoundException e) {
+ //ignore
+ } catch (InstanceNotFoundException e) {
+ //ignore
+ } catch (MBeanException e) {
+ //ignore
+ } catch (ReflectionException e) {
+ //ignore
+ }
+ }
+
+ private void addConnectorProperty(String name, String type, String description, String value, boolean readOnly) {
+ SimpleMetaType metaType = SimpleMetaType.resolve(type);
+
+ DefaultFieldsImpl fields = new DefaultFieldsImpl(name);
+ fields.setDescription(description);
+ fields.setMetaType(metaType);
+ fields.setField(Fields.DEFAULT_VALUE, ManagedUtil.wrap(metaType, value));
+ fields.setField(Fields.READ_ONLY, readOnly);
+ ManagedPropertyImpl dsTypeMP = new ManagedPropertyImpl(fields);
+ addProperty(dsTypeMP);
+ }
+
+}
Property changes on: branches/JCA/jboss-integration/src/main/java/org/teiid/templates/connector/ConnectorTypeTemplateInfo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java
===================================================================
--- branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.dqp.embedded.admin;
-
-import junit.framework.TestCase;
-
-
-/**
- * @since 4.3
- */
-public class TestBaseAdmin extends TestCase {
-
- public void testRegexStuff() {
- assertTrue("RegEx Failed", "one".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one two".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one two three ".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one9_two_Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one9_two*Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "#one9_two Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertTrue("RegEx Failed", "one".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one ".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one*".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one two".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one_TWO_three".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertTrue("RegEx Failed", "one*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one two *".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "*one two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "#two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one.*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one.two".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one.two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
-
-
- assertTrue("RegEx Failed", "*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one_TWO_three*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "*one".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "* one".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "*.*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one.*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
-
-
- assertTrue("RegEx Failed", "*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one.two".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "*.one".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one_two *".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one.two*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one.two*.three*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one.two**".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one.two.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "one*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "one.".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "0.10.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "0.10..*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "0.10..".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", ".one*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", ".one_two".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertTrue("RegEx Failed", "One".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "One.1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "*.1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "One.One".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "One*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "One*.101".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "*.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "100.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", ".1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- //assertTrue("RegEx Failed", "V0.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertTrue("RegEx Failed", "XML-Relational File Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("RegEx Failed", "XML Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("RegEx Failed", "XML&Relational Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- //assertTrue("RegEx Failed", "".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
Modified: branches/JCA/pom.xml
===================================================================
--- branches/JCA/pom.xml 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/pom.xml 2009-11-17 13:31:34 UTC (rev 1569)
@@ -353,7 +353,12 @@
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-jboss-integration</artifactId>
<version>${project.version}</version>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-runtime</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- External dependencies -->
<dependency>
@@ -400,6 +405,30 @@
<artifactId>jbosscache-core</artifactId>
<version>3.1.0.GA</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <version>2.1.0.SP1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.integration</groupId>
+ <artifactId>jboss-profileservice-spi</artifactId>
+ <version>5.1.0.GA</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <version>2.1.2.GA</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.jbossas</groupId>
+ <artifactId>jboss-as-connector</artifactId>
+ <version>5.1.0.GA</version>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>com.google.code.guice</groupId>
<artifactId>guice</artifactId>
@@ -442,7 +471,6 @@
<module>txn-jbossts</module>
<module>connector-sdk</module>
<module>test-integration</module>
- <module>jboss-integration</module>
-->
<module>common-core</module>
<module>common-internal</module>
@@ -457,6 +485,7 @@
<module>connector-metadata</module>
<module>cache-jbosscache</module>
<module>hibernate-dialect</module>
+ <module>jboss-integration</module>
</modules>
<distributionManagement>
Modified: branches/JCA/runtime/pom.xml
===================================================================
--- branches/JCA/runtime/pom.xml 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/runtime/pom.xml 2009-11-17 13:31:34 UTC (rev 1569)
@@ -84,9 +84,9 @@
</dependency>
<dependency>
- <groupId>javax.resource</groupId>
- <artifactId>connector-api</artifactId>
- <scope>provided</scope>
- </dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Copied: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java (from rev 1544, branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java)
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java (rev 0)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,657 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.dqp.embedded.admin;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.Cache;
+import org.teiid.adminapi.ExtensionModule;
+import org.teiid.adminapi.Session;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.internal.process.Util;
+
+import com.metamatrix.admin.objects.MMConnectorType;
+import com.metamatrix.admin.objects.MMExtensionModule;
+import com.metamatrix.admin.objects.MMLogConfiguration;
+import com.metamatrix.admin.objects.MMModel;
+import com.metamatrix.admin.objects.MMPropertyDefinition;
+import com.metamatrix.admin.objects.MMRequest;
+import com.metamatrix.admin.objects.MMSession;
+import com.metamatrix.admin.objects.MMVDB;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.api.exception.security.SessionServiceException;
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.common.config.api.ComponentType;
+import com.metamatrix.common.config.api.ComponentTypeDefn;
+import com.metamatrix.common.config.api.ConnectorBinding;
+import com.metamatrix.common.log.LogConfigurationImpl;
+import com.metamatrix.common.object.PropertyDefinition;
+import com.metamatrix.common.util.crypto.CryptoException;
+import com.metamatrix.common.util.crypto.CryptoUtil;
+import com.metamatrix.common.vdb.api.VDBArchive;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.service.AuthorizationService;
+import com.metamatrix.dqp.service.ConfigurationService;
+import com.metamatrix.dqp.service.DQPServiceNames;
+import com.metamatrix.dqp.service.DataService;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.dqp.service.VDBService;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
+import com.metamatrix.platform.security.api.SessionToken;
+import com.metamatrix.platform.security.api.service.MembershipServiceInterface;
+import com.metamatrix.platform.security.api.service.SessionServiceInterface;
+import com.metamatrix.platform.util.ProductInfoConstants;
+import com.metamatrix.server.serverapi.RequestInfo;
+
+
+/**
+ * @since 4.3
+ */
+abstract class BaseAdmin {
+ static final String DOT = "."; //$NON-NLS-1$
+ static final String STAR = "*"; //$NON-NLS-1$
+ static final String FILE_NAME_REGEX="\\w+\\.\\w+"; //$NON-NLS-1$
+ static final String MULTIPLE_WORDS_REGEX = "\\w+([\\s|-]*\\w)*"; //$NON-NLS-1$
+ static final String SINGLE_WORD_REGEX = "\\w+"; //$NON-NLS-1$
+ static final String MULTIPLE_WORD_WILDCARD_REGEX = "\\w*((\\.)?\\s*\\w)*(\\*)?"; //$NON-NLS-1$
+ static final String SINGLE_WORD_WILDCARD_REGEX = "\\w*(\\*)?"; //$NON-NLS-1$
+ // This should find word.word.* or word.* kind of patterns (ugly, you can rewrite)
+ static final String WORD_AND_DOT_WILDCARD_REGEX = "\\w+((\\.\\*)|(\\.\\w+)|(\\.\\w*\\*))*|\\w*(\\*){1}"; //$NON-NLS-1$
+
+ static final String VDB_REGEX = "\\w*(\\*)?(\\.\\d+)?"; //$NON-NLS-1$
+ static final String NUMBER_DOT_REGEX = "\\d+((\\.\\*)|(\\.\\d+)|(\\.\\d*\\*))*|\\d*(\\*){1}"; //$NON-NLS-1$
+ static final String NUMBER_REGEX = "\\d*(\\*)?"; //$NON-NLS-1$
+
+ static final String[] cacheTypes = {Cache.CODE_TABLE_CACHE,
+ Cache.CONNECTOR_RESULT_SET_CACHE,
+ Cache.PREPARED_PLAN_CACHE,
+ Cache.QUERY_SERVICE_RESULT_SET_CACHE
+ };
+
+ private EmbeddedConnectionFactoryImpl manager = null;
+
+ BaseAdmin(EmbeddedConnectionFactoryImpl manager){
+ this.manager = manager;
+ }
+
+ protected AdminException accumulateSystemException(AdminException parent, Exception e) {
+ if (parent == null) {
+ return new AdminComponentException(e);
+ }
+ parent.addChild(new AdminComponentException(e));
+ return parent;
+ }
+
+ protected AdminException accumulateProcessingException(AdminException parent, Exception e) {
+ if (parent == null) {
+ return new AdminProcessingException(e);
+ }
+ parent.addChild(new AdminProcessingException(e));
+ return parent;
+ }
+
+ protected String prettyPrintBindingNames(List bindings) {
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator iter = bindings.iterator(); iter.hasNext();) {
+ ConnectorBinding binding = (ConnectorBinding) iter.next();
+ buffer.append(binding.getDeployedName());
+ if (iter.hasNext()) {
+ buffer.append(", "); //$NON-NLS-1$
+ }
+ }
+
+ return buffer.toString();
+ }
+
+ /**
+ * @return Returns the manager.
+ * @since 4.3
+ */
+ public EmbeddedConnectionFactoryImpl getManager() {
+ return this.manager;
+ }
+
+ VDBService getVDBService() {
+ return (VDBService)getManager().findService(DQPServiceNames.VDB_SERVICE);
+ }
+
+ DataService getDataService() {
+ return (DataService)getManager().findService(DQPServiceNames.DATA_SERVICE);
+ }
+
+ TransactionService getTransactionService() {
+ return (TransactionService)getManager().findService(DQPServiceNames.TRANSACTION_SERVICE);
+ }
+
+ MembershipServiceInterface getMembershipService() {
+ return (MembershipServiceInterface)getManager().findService(DQPServiceNames.MEMBERSHIP_SERVICE);
+ }
+
+ AuthorizationService getAuthorizationService() {
+ return (AuthorizationService)getManager().findService(DQPServiceNames.AUTHORIZATION_SERVICE);
+ }
+
+ ConfigurationService getConfigurationService() {
+ return (ConfigurationService)getManager().findService(DQPServiceNames.CONFIGURATION_SERVICE);
+ }
+
+ SessionServiceInterface getSessionService() {
+ return (SessionServiceInterface)getManager().findService(DQPServiceNames.SESSION_SERVICE);
+ }
+
+ protected Object convertToAdminObjects(Object src) {
+ return convertToAdminObjects(src,null);
+ }
+
+ protected Object convertToAdminObjects(Object src, Object parent) {
+ if (src == null) {
+ return src;
+ }
+
+ if (src instanceof List) {
+ List modified = new ArrayList();
+ List list = (List)src;
+ for (final Iterator i = list.iterator(); i.hasNext();) {
+ final Object e = i.next();
+ Object converted = convertToAdminObject(e, parent);
+ modified.add(converted);
+ }
+ return modified;
+ }
+ else if (src instanceof Collection) {
+ List modified = new ArrayList();
+ for (Iterator i = ((Collection)src).iterator(); i.hasNext();) {
+ final Object e = i.next();
+ Object converted = convertToAdminObject(e, parent);
+ modified.add(converted);
+ }
+ return modified;
+ }
+ else if (src instanceof Object[] ) {
+ List modified = new ArrayList();
+ Object[] srcArray = (Object[])src;
+ for (int i = 0; i < srcArray.length; i++) {
+ final Object converted = convertToAdminObject(srcArray[i], parent);
+ modified.add(converted);
+ }
+ return modified;
+ }
+ return convertToAdminObject(src, parent);
+ }
+
+
+ private Object convertToAdminObject(Object src, Object parent) {
+ if (src != null && src instanceof com.metamatrix.common.config.api.ConnectorBinding) {
+ com.metamatrix.common.config.api.ConnectorBinding binding = (com.metamatrix.common.config.api.ConnectorBinding)src;
+ return convertConnectorType(binding, parent);
+ }
+ else if (src != null && src instanceof com.metamatrix.common.config.api.ConnectorBindingType) {
+ com.metamatrix.common.config.api.ConnectorBindingType type = (com.metamatrix.common.config.api.ConnectorBindingType)src;
+ return convertConnectorType(type, parent);
+ }
+ else if (src != null && src instanceof com.metamatrix.common.vdb.api.VDBDefn) {
+ com.metamatrix.common.vdb.api.VDBDefn vdb = (com.metamatrix.common.vdb.api.VDBDefn)src;
+ return convertVDB(vdb, parent);
+ }
+ else if (src != null && src instanceof VDBArchive) {
+ VDBArchive vdb = (VDBArchive)src;
+ return convertVDB(vdb.getConfigurationDef(), parent);
+ }
+ else if (src != null && src instanceof com.metamatrix.common.vdb.api.ModelInfo) {
+ com.metamatrix.common.vdb.api.ModelInfo model = (com.metamatrix.common.vdb.api.ModelInfo)src;
+ return convertModel(model, parent);
+ }
+ else if (src != null && src instanceof com.metamatrix.common.log.LogConfiguration) {
+ com.metamatrix.common.log.LogConfiguration config = (com.metamatrix.common.log.LogConfiguration)src;
+ return covertLogConfiguration(config);
+ }
+ else if (src != null && src instanceof com.metamatrix.server.serverapi.RequestInfo) {
+ com.metamatrix.server.serverapi.RequestInfo request = (com.metamatrix.server.serverapi.RequestInfo)src;
+ return convertRequest(request);
+ }
+ else if (src != null && src instanceof com.metamatrix.common.queue.WorkerPoolStats) {
+ com.metamatrix.common.queue.WorkerPoolStats stats = (com.metamatrix.common.queue.WorkerPoolStats)src;
+ return Util.convertStats(stats, stats.getQueueName());
+ }
+ else if (src != null && src instanceof MetaMatrixSessionInfo) {
+ MetaMatrixSessionInfo conn = (MetaMatrixSessionInfo)src;
+ return convertConnection(conn);
+ }
+ else if (src != null && src instanceof com.metamatrix.common.config.api.ExtensionModule) {
+ com.metamatrix.common.config.api.ExtensionModule extModule = (com.metamatrix.common.config.api.ExtensionModule)src;
+ return convertExtensionModule(extModule);
+ }
+ else {
+ if (src == null) {
+ return null;
+ }
+ throw new UnsupportedOperationException(DQPEmbeddedPlugin.Util.getString("UnSupported_object_conversion")); //$NON-NLS-1$
+ }
+ }
+
+ Object convertToNativeObjects(Object src) {
+ if (src instanceof org.teiid.adminapi.LogConfiguration) {
+ org.teiid.adminapi.LogConfiguration config = (org.teiid.adminapi.LogConfiguration)src;
+ return covertToNativeLogConfiguration(config);
+ }
+ throw new UnsupportedOperationException(DQPEmbeddedPlugin.Util.getString("UnSupported_object_conversion")); //$NON-NLS-1$
+ }
+
+
+ private ExtensionModule convertExtensionModule(com.metamatrix.common.config.api.ExtensionModule src) {
+ MMExtensionModule module = new MMExtensionModule(new String[] {src.getFullName()}) ;
+ module.setDescription(src.getDescription());
+ module.setFileContents(src.getFileContents());
+ module.setModuleType(src.getModuleType());
+ return module;
+ }
+
+ private Session convertConnection(MetaMatrixSessionInfo src) {
+ MMSession session = new MMSession(new String[] {src.getSessionID().toString()});
+ session.setVDBName(src.getProductInfo(ProductInfoConstants.VIRTUAL_DB));
+ session.setVDBVersion(src.getProductInfo(ProductInfoConstants.VDB_VERSION));
+ session.setApplicationName(src.getApplicationName());
+ session.setIPAddress(src.getClientIp());
+ session.setHostName(src.getClientHostname());
+ session.setUserName(src.getUserName());
+ session.setLastPingTime(src.getLastPingTime());
+ session.setCreated(new Date(src.getTimeCreated()));
+ return session;
+ }
+
+ /**
+ * Convert LogConfiguration to Admin Object
+ */
+ private org.teiid.adminapi.LogConfiguration covertLogConfiguration(final com.metamatrix.common.log.LogConfiguration src) {
+ Map<String, Integer> contextMap = new HashMap<String, Integer>();
+ for(String context:src.getContexts()) {
+ contextMap.put(context, src.getLogLevel(context));
+ }
+ return new MMLogConfiguration(contextMap);
+ }
+
+ /**
+ * Convert LogConfiguration to Admin Object
+ */
+ private com.metamatrix.common.log.LogConfiguration covertToNativeLogConfiguration(final org.teiid.adminapi.LogConfiguration src) {
+ Map<String, Integer> contextMap = new HashMap<String, Integer>();
+ for(String context:src.getContexts()) {
+ contextMap.put(context, src.getLogLevel(context));
+ }
+ return new LogConfigurationImpl(contextMap);
+ }
+
+ /**
+ * @param binding
+ * @return
+ * @since 4.3
+ */
+ private org.teiid.adminapi.ConnectorBinding convertConnectorType(final com.metamatrix.common.config.api.ConnectorBinding src, final Object parent) {
+// MMConnectorBinding binding = new MMConnectorBinding(new String[] {src.getDeployedName()});
+//
+// binding.setConnectorTypeName(src.getComponentTypeID().getFullName());
+// binding.setCreated(src.getCreatedDate());
+// binding.setCreatedBy(src.getCreatedBy());
+// binding.setDescription(src.getDescription());
+// binding.setEnabled(src.isEnabled());
+// binding.setLastUpdated(src.getLastChangedDate());
+// binding.setLastUpdatedBy(src.getLastChangedBy());
+// binding.setProperties(src.getProperties());
+// binding.setRegistered(true);
+// binding.setRoutingUUID(src.getRoutingUUID());
+// binding.setServiceID(0); // TODO:
+
+ // Binding state needs to be converted into pool state; until then we use
+ // binding state as pool state.
+// try {
+// ConnectorStatus status = getDataService().getConnectorBindingState(src.getDeployedName());
+// switch(status) {
+// case OPEN:
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_OPEN);
+// break;
+// case NOT_INITIALIZED:
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_NOT_INITIALIZED);
+// break;
+// case CLOSED:
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_CLOSED);
+// break;
+// case DATA_SOURCE_UNAVAILABLE:
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_DATA_SOURCE_UNAVAILABLE);
+// break;
+// case INIT_FAILED:
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_INIT_FAILED);
+// break;
+// case UNABLE_TO_CHECK:
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_FAILED_TO_CHECK);
+// break;
+// }
+// }catch(MetaMatrixComponentException e) {
+// binding.setState(org.teiid.adminapi.ConnectorBinding.STATE_NOT_DEPLOYED);
+// }
+// binding.setStateChangedTime(src.getLastChangedDate());
+// return binding;
+ return null;
+ }
+
+ /**
+ * @param type
+ * @return
+ * @since 4.3
+ */
+ private org.teiid.adminapi.ConnectorType convertConnectorType(final com.metamatrix.common.config.api.ConnectorBindingType src, final Object parent) {
+ MMConnectorType type = new MMConnectorType(new String[] {src.getName()});
+ type.setCreated(src.getCreatedDate());
+ type.setCreatedBy(src.getCreatedBy());
+ type.setEnabled(true);
+ type.setLastUpdated(src.getLastChangedDate());
+ type.setRegistered(true);
+
+ return type;
+ }
+
+ /**
+ * @param vdb
+ * @return
+ * @since 4.3
+ */
+ private org.teiid.adminapi.VDB convertVDB(final com.metamatrix.common.vdb.api.VDBDefn src, final Object parent) {
+
+ MMVDB vdb = new MMVDB(new String[] {src.getName(), src.getVersion()});
+ vdb.setCreated(src.getDateCreated());
+ vdb.setCreatedBy(src.getCreatedBy());
+ vdb.setEnabled(src.isActiveStatus());
+ vdb.setLastUpdated(src.getDateCreated());
+ vdb.setLastUpdatedBy(src.getCreatedBy());
+ vdb.setMaterializedViews(src.getMatertializationModel() != null);
+ vdb.setModels((Collection)convertToAdminObjects(src.getModels(), src));
+ vdb.setProperties(null);
+ vdb.setRegistered(true);
+ vdb.setStatus(src.getStatus());
+ vdb.setUID(0); // TODO: src.getUUID());
+ vdb.setVersionedBy(src.getCreatedBy());
+ vdb.setVersionedDate(src.getDateCreated());
+ vdb.setHasWSDL(src.hasWSDLDefined());
+
+ return vdb;
+ }
+
+ private org.teiid.adminapi.Model convertModel(final com.metamatrix.common.vdb.api.ModelInfo src, final Object parent) {
+ final com.metamatrix.common.vdb.api.VDBDefn vdb = (com.metamatrix.common.vdb.api.VDBDefn)parent;
+ MMModel model = new MMModel(new String[] {src.getName()});
+ model.setCreated(vdb.getDateCreated());
+ model.setCreatedBy(vdb.getCreatedBy());
+ model.setEnabled(vdb.isActiveStatus());
+ model.setLastUpdated(vdb.getDateCreated());
+ model.setLastUpdatedBy(vdb.getCreatedBy());
+ model.setModelType(src.getModelTypeName());
+ model.setModelURI(src.getModelURI());
+ model.setMaterialization(src.isMaterialization());
+ model.setPhysical(src.isPhysical());
+ model.setRegistered(true);
+ model.setSupportsMultiSourceBindings(src.isMultiSourceBindingEnabled());
+ model.setVisible(src.isVisible());
+ if (src.isPhysical()) {
+ List bindings = src.getConnectorBindingNames();
+ if (bindings != null && !bindings.isEmpty()) {
+ List names = new ArrayList();
+ for (int i=0; i<bindings.size();i++) {
+ names.add(convertToAdminObject(vdb.getConnectorBindingByName((String)bindings.get(i)), parent));
+ }
+ model.setConnectorBindingNames(names);
+ }
+ }
+ return model;
+ }
+
+ private org.teiid.adminapi.Request convertRequest(final RequestInfo src) {
+
+ String connId = src.getRequestID().getConnectionID();
+
+ MMRequest request = null;
+ if (src.getConnectorBindingUUID() != null) {
+ request = new MMRequest(new String[] {connId, String.valueOf(src.getRequestID().getExecutionID()), String.valueOf(src.getNodeID()), String.valueOf(src.getExecutionID())});
+ }
+ else {
+ request = new MMRequest(new String[] {connId, String.valueOf(src.getRequestID().getExecutionID())});
+ }
+
+ request.setSqlCommand(src.getCommand());
+
+ request.setCreated(src.getProcessingTimestamp());
+
+ if (src.getConnectorBindingUUID() != null) {
+ request.setSource(true);
+ request.setNodeID(String.valueOf(src.getNodeID()));
+ }
+ return request;
+ }
+
+ /**
+ * Get the connection connection object for the given id.
+ * @param identifier
+ * @return
+ * @since 4.3
+ */
+ MetaMatrixSessionInfo getClientConnection(String identifier) throws AdminException {
+ Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
+ for (MetaMatrixSessionInfo info:sessions) {
+ if (info.getSessionID().toString().equals(identifier)) {
+ return info;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Get all the available connections
+ * @return
+ * @throws AdminException
+ */
+ Collection<MetaMatrixSessionInfo> getClientConnections() throws AdminException {
+ try {
+ return getSessionService().getActiveSessions();
+ } catch (SessionServiceException e) {
+ // SessionServiceException not in the client known exception (in common-internal)
+ throw new AdminComponentException(e.getMessage(), e.getCause());
+ }
+ }
+
+ boolean matches(String regEx, String value) {
+ regEx = regEx.replaceAll(AdminObject.ESCAPED_WILDCARD, ".*"); //$NON-NLS-1$
+ regEx = regEx.replaceAll(AdminObject.ESCAPED_DELIMITER, ""); //$NON-NLS-1$
+ return value.matches(regEx);
+ }
+
+ List matchedCollection(String identifier, List adminObjects) {
+ ArrayList matched = new ArrayList();
+ for (Iterator i = adminObjects.iterator(); i.hasNext();) {
+ AdminObject aObj = (AdminObject)i.next();
+ if (matches(identifier, aObj.getName()) || matches(identifier, aObj.getName())) {
+ matched.add(aObj);
+ }
+ }
+ return matched;
+ }
+
+ /**
+ * Get list of available connector bindings
+ * @param identifier
+ */
+ Collection getConnectorBindings(String identifier) throws AdminException{
+// try {
+// List connectorBindings = getDataService().getConnectorBindings();
+// connectorBindings = (List)convertToAdminObjects(connectorBindings);
+// return matchedCollection(identifier, connectorBindings);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return Collections.EMPTY_LIST;
+ }
+
+
+ /**
+ * Get list of available connector types
+ * @param identifier
+ */
+ Collection getConnectorTypes(String identifier) throws AdminException{
+
+// try {
+// List connectorTypes = getConfigurationService().getConnectorTypes();
+// connectorTypes = (List)convertToAdminObjects(connectorTypes);
+// return matchedCollection(identifier, connectorTypes);
+// } catch (MetaMatrixComponentException err) {
+// throw new AdminComponentException(err);
+// }
+ return null;
+ }
+
+ boolean isMaskedProperty(String propName, ComponentType type) {
+ if (type != null) {
+ ComponentTypeDefn typeDef = type.getComponentTypeDefinition(propName);
+ if (typeDef != null && typeDef.getPropertyDefinition().isMasked()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Encrypt a string
+ * @param value
+ * @return
+ * @throws AdminException
+ * @since 4.3
+ */
+ String encryptString(String value) throws AdminException {
+ try {
+ return CryptoUtil.stringEncrypt(value);
+ } catch (CryptoException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+
+
+ /**
+ * Convert a ComponentType and a set of properties into a Collection of
+ * com.metamatrix.admin.api.objects.PropertyDefinition objects
+ * @param ctype
+ * @param properties
+ * @return
+ * @since 4.3
+ */
+ protected Collection convertPropertyDefinitions(ComponentType ctype, Properties properties) {
+ ArrayList results = new ArrayList();
+ for (Iterator iter = ctype.getComponentTypeDefinitions().iterator(); iter.hasNext(); ) {
+ ComponentTypeDefn cdefn = (ComponentTypeDefn) iter.next();
+ PropertyDefinition pdefn = cdefn.getPropertyDefinition();
+
+ MMPropertyDefinition result = new MMPropertyDefinition(new String[] {pdefn.getName()});
+ result.setAllowedValues(pdefn.getAllowedValues());
+ result.setDefaultValue(pdefn.getDefaultValue());
+ result.setDescription(pdefn.getShortDescription());
+ result.setDisplayName(pdefn.getDisplayName());
+ result.setExpert(pdefn.isExpert());
+ result.setMasked(pdefn.isMasked());
+ result.setModifiable(pdefn.isModifiable());
+ result.setPropertyType(pdefn.getPropertyType().getDisplayName());
+ result.setPropertyTypeClassName(pdefn.getPropertyType().getClassName());
+ result.setRequired(pdefn.isRequired());
+ result.setRequiresRestart(pdefn.getRequiresRestart());
+
+ String value = properties.getProperty(pdefn.getName());
+ result.setValue(value);
+
+ results.add(result);
+ }
+
+
+ return results;
+ }
+
+
+ /**
+ * Convert a set of properties into a Collection of
+ * com.metamatrix.admin.api.objects.PropertyDefinition objects
+ *
+ * @param ctype
+ * @param properties
+ * @return
+ * @since 4.3
+ */
+ protected Collection convertPropertyDefinitions(Properties properties) {
+ ArrayList results = new ArrayList();
+ for (Iterator iter = properties.keySet().iterator(); iter.hasNext(); ) {
+ String key = (String) iter.next();
+ String value = properties.getProperty(key);
+
+ MMPropertyDefinition result = new MMPropertyDefinition(new String[] {key});
+ result.setDisplayName(key);
+ result.setValue(value);
+
+ results.add(result);
+ }
+
+
+ return results;
+ }
+
+ protected SessionToken validateSession() {
+ return DQPWorkContext.getWorkContext().getSessionToken();
+ }
+
+ protected void changeVDBStatus(String name, String version, int status)
+ throws AdminException {
+ try {
+
+ if (name == null || version == null || !name.matches(SINGLE_WORD_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name")); //$NON-NLS-1$
+ }
+
+ // Now change the VDB status it self
+ this.getVDBService().changeVDBStatus(name, version, status);
+
+ // If the VDB is modified and if its status changed to DELETED, then
+ // we can remove all the connector bindings associated with this VDB
+ // the above delete will also remove them
+ } catch (ApplicationLifecycleException e) {
+ throw new AdminComponentException(e);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+}
Property changes on: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/BaseAdmin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java (from rev 1544, branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java)
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java (rev 0)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,1058 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.dqp.embedded.admin;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminOptions;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.ConfigurationAdmin;
+import org.teiid.adminapi.EmbeddedLogger;
+import org.teiid.adminapi.LogConfiguration;
+import org.teiid.adminapi.VDB;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.application.exception.ApplicationLifecycleException;
+import com.metamatrix.common.config.api.ComponentType;
+import com.metamatrix.common.config.api.ComponentTypeDefn;
+import com.metamatrix.common.config.api.ConnectorArchive;
+import com.metamatrix.common.config.api.ConnectorBinding;
+import com.metamatrix.common.config.api.ConnectorBindingType;
+import com.metamatrix.common.config.api.ExtensionModule;
+import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.util.crypto.CryptoException;
+import com.metamatrix.common.util.crypto.CryptoUtil;
+import com.metamatrix.common.vdb.api.VDBArchive;
+import com.metamatrix.common.vdb.api.VDBDefn;
+import com.metamatrix.core.vdb.VDBStatus;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.embedded.configuration.ConnectorConfigurationReader;
+import com.metamatrix.dqp.embedded.configuration.VDBConfigurationReader;
+import com.metamatrix.dqp.service.ConfigurationService;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+
+
+/**
+ * DQP implementation of the Config Admin API
+ * @since 4.3
+ */
+public abstract class DQPConfigAdminImpl extends BaseAdmin implements ConfigurationAdmin {
+
+ public DQPConfigAdminImpl(EmbeddedConnectionFactoryImpl manager) {
+ super(manager);
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#setProperty(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+ * @since 4.3
+ */
+ public void setConnectorBindingProperty(String deployedName, String propertyName, String propertyValue)
+ throws AdminException {
+
+// try {
+// ConnectorBinding binding = getConfigurationService().getConnectorBinding(deployedName);
+// if (binding == null) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.cb_doesnot_exist", deployedName)); //$NON-NLS-1$
+// }
+//
+// ComponentTypeID id = binding.getComponentTypeID();
+// ConnectorBindingType type = getConfigurationService().getConnectorType(id.getName());
+//
+// boolean needsEncryption = isMaskedProperty(propertyName, type);
+// if (needsEncryption) {
+// propertyValue = encryptString(propertyValue);
+// }
+//
+// Properties p = new Properties();
+// p.setProperty(propertyName, propertyValue);
+//
+// //update the configuration
+// binding = ConnectorConfigurationReader.addConnectorBindingProperties(binding, p);
+// getConfigurationService().updateConnectorBinding(binding);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorType(java.lang.String, char[])
+ * @since 4.3
+ */
+ public void addConnectorType(String deployName, char[] cdkFile)
+ throws AdminException {
+// try {
+// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
+// }
+// if (cdkFile == null || cdkFile.length == 0) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_source")); //$NON-NLS-1$
+// }
+//
+// // This is only place we check the existence in admin. Generally the Admin is not the
+// // guy to decide, if it can take in or not, it should be the service. I did not
+// // want add in the configuration service beacuse, it may need to allow this behavior
+// // in case we are updating.
+// if (getConfigurationService().getConnectorType(deployName) == null) {
+// ConnectorBindingType type = ConnectorConfigurationReader.loadConnectorType(cdkFile);
+// saveConnectorType(type);
+// }
+// else {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_exists", deployName)); //$NON-NLS-1$
+// }
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#deleteConnectorType(java.lang.String)
+ * @since 4.3
+ */
+ public void deleteConnectorType(String deployName)
+ throws AdminException {
+// try {
+// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
+// }
+// getConfigurationService().deleteConnectorType(deployName);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorBinding(java.lang.String, java.lang.String, java.util.Properties, AdminOptions)
+ * @since 4.3
+ */
+ public org.teiid.adminapi.ConnectorBinding addConnectorBinding(String deployName, String type, Properties properties, AdminOptions options)
+ throws AdminException {
+// // if the options object is null treat as if it is IGNORE as default
+// if (options == null) {
+// options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
+// }
+//
+// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
+// }
+//
+// if (type == null || !type.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
+// }
+//
+// ConnectorBinding binding = null;
+// try {
+// // Check if the binding exists already, if does take action based on user
+// // preferences in the admin options
+// if (bindingExists(deployName)) {
+// // Based on users preference, either add or replace or ignore
+// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists", deployName)); //$NON-NLS-1$
+// }
+// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
+// binding = getDataService().getConnectorBinding(deployName);
+// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
+// }
+// }
+//
+// // Get the connector type
+// ConnectorBindingType ctype = getConfigurationService().getConnectorType(type);
+// if (ctype == null) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_type_not_exists", type)); //$NON-NLS-1$
+// }
+//
+// // Build the connector binding with informatin we know.
+// binding = ConnectorConfigurationReader.loadConnectorBinding(deployName, properties, ctype);
+//
+// // Check that the connector binding passwords can be decrypted
+// try {
+// checkDecryption(binding, ctype);
+// } catch(CryptoException e) {
+// if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED", binding.getFullName())); //$NON-NLS-1$
+// }
+// }
+//
+// // now that all of the input parameters validated, add the connector binding
+// binding = addConnectorBinding(deployName, binding, ctype, false);
+//
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
+
+ return null;
+ }
+
+ boolean bindingExists(String name) throws MetaMatrixComponentException {
+// ConnectorBinding binding = getDataService().getConnectorBinding(name);
+// return (binding != null);
+ return false;
+ }
+
+ boolean bindingTypeExists(String name) throws MetaMatrixComponentException {
+// ConnectorBindingType type = getConfigurationService().getConnectorType(name);
+// return (type != null);
+ return false;
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorBinding(java.lang.String, char[], AdminOptions)
+ * @since 4.3
+ */
+ public org.teiid.adminapi.ConnectorBinding addConnectorBinding(String deployName, char[] xmlFile, AdminOptions options)
+ throws AdminException {
+
+// // if the options object is null treat as if it is IGNORE as default
+// if (options == null) {
+// options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
+// }
+//
+// if (deployName == null || !deployName.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
+// }
+// if (xmlFile == null || xmlFile.length == 0) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_source")); //$NON-NLS-1$
+// }
+//
+// ConnectorBinding binding = null;
+// try {
+// // Check if the binding exists already, if does take action based on user
+// // preferences in the admin options
+// if (bindingExists(deployName)) {
+// // Based on users preference, either add or replace or ignore
+// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists", deployName)); //$NON-NLS-1$
+// }
+// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
+// binding = getDataService().getConnectorBinding(deployName);
+// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
+// }
+// }
+//
+// // now we are in situation we do have the connector or overwriting it.
+// // before we add the connector binding we need to add the connector type
+// // as the connector binding only references to type by identifier.
+// ConnectorBindingType type = ConnectorConfigurationReader.loadConnectorType(xmlFile);
+//
+// // Check if the binding type exists already, if does take action based on user
+// // preferences in the admin options, same rules apply as binding.
+// boolean addType = true;
+// if (bindingTypeExists(type.getName())) {
+// if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBinding_type_exists", deployName, type.getName())); //$NON-NLS-1$
+// }
+// else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
+// addType = false;
+// }
+// }
+//
+// binding = ConnectorConfigurationReader.loadConnectorBinding(deployName, xmlFile);
+//
+// // Check that the connector binding passwords can be decrypted
+// try {
+// checkDecryption(binding, type);
+// } catch(CryptoException e) {
+// if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED", binding.getFullName())); //$NON-NLS-1$
+// }
+// }
+//
+// // now that all of the input parameters validated, add the connector binding
+// binding = addConnectorBinding(deployName, binding, type, addType);
+//
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+//
+// return (org.teiid.adminapi.ConnectorBinding) convertToAdminObjects(binding);
+ return null;
+ }
+
+ /**
+ * Helper method to add the connector binding..
+ * @param deployName
+ * @param binding
+ * @param type
+ * @param options
+ * @throws AdminException
+ */
+ ConnectorBinding addConnectorBinding(String deployName, ConnectorBinding binding, ConnectorBindingType type, boolean addType)
+ throws AdminException {
+ // Make sure we have both correctly configured
+ if (type != null && binding != null) {
+ if (binding.getComponentTypeID().getName().equals(type.getName())) {
+ try {
+
+ // First add the connector type if one is not already in here.
+// if (getConfigurationService().getConnectorType(type.getName()) == null || addType) {
+// saveConnectorType(type);
+// }
+ // Now add the connector binding.
+ binding = getConfigurationService().addConnectorBinding(deployName, binding, true);
+ return binding;
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_load_failed_wrong_type", deployName)); //$NON-NLS-1$
+ }
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.connector_load_failed_wrong_contents", deployName)); //$NON-NLS-1$
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#deleteConnectorBinding(java.lang.String)
+ * @since 4.3
+ */
+ public void deleteConnectorBinding(String identifier)
+ throws AdminException {
+// try {
+// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
+// }
+// getConfigurationService().deleteConnectorBinding(identifier);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addVDB(java.lang.String, byte[], char[], AdminOptions)
+ * @since 4.3
+ */
+ private VDB addVDB(String deployName, byte[] vdbFile, char[] defFile, AdminOptions options)
+ throws AdminException {
+
+ // if the options object is null treat as if it is BINDINGS_ADD as default
+ if (options == null) {
+ options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
+ }
+
+ if (deployName == null || !deployName.matches(SINGLE_WORD_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name")); //$NON-NLS-1$
+ }
+ if (vdbFile == null || vdbFile.length == 0) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_source")); //$NON-NLS-1$
+ }
+
+ if (defFile == null) {
+ DQPEmbeddedPlugin.logInfo("Admin.load_combined_vdb", new Object[] {deployName}); //$NON-NLS-1$
+ }
+
+ VDBArchive vdb = null;
+ try {
+ // Load the VDB from the files
+ if (defFile == null) {
+ vdb = VDBConfigurationReader.loadVDB(deployName, vdbFile);
+ }
+ else {
+ vdb = VDBConfigurationReader.loadVDB(deployName, defFile, vdbFile);
+ }
+
+ // Add the connector binding in the VDB to the system
+ validateConnectorBindingsInVdb(vdb, options);
+
+ // now deploy the VDB into the system. Flag is to
+ VDBArchive deployedVDB = getConfigurationService().addVDB(vdb, !options.containsOption(AdminOptions.OnConflict.IGNORE));
+
+ // If the connector bindings are correctly initialized and VDB is active
+ // start the bindings automatically.
+ if ( (deployedVDB.getStatus() == VDBStatus.ACTIVE) ||
+ (deployedVDB.getStatus() == VDBStatus.ACTIVE_DEFAULT) ) {
+ try {
+ startVDBConnectorBindings(deployedVDB);
+ } catch (MetaMatrixComponentException e) {
+ } catch (ApplicationLifecycleException e) {
+ // we can safely ignore these because the cause of the not starting is already recorded
+ // and more likely VDB deployment succeeded.
+ }
+ }
+
+ return (VDB) convertToAdminObjects(deployedVDB);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * Start the connector bindings in the given VDB
+ * @param vdb
+ */
+ private void startVDBConnectorBindings(VDBArchive vdb) throws MetaMatrixComponentException,
+ ApplicationLifecycleException {
+//
+// VDBDefn def = vdb.getConfigurationDef();
+// Collection<ConnectorBinding> bindings = def.getConnectorBindings().values();
+// for (ConnectorBinding binding:bindings) {
+// getDataService().startConnectorBinding(binding.getDeployedName());
+// }
+ }
+
+ /**
+ * Validate the connector bindings in a VDB. Since the connector bindings in VDB
+ * are VDB scoped there is no meaning for the admin options provided. Just check
+ * the decrypt properties.
+ */
+ void validateConnectorBindingsInVdb(VDBArchive vdb, AdminOptions options)
+ throws MetaMatrixComponentException, AdminProcessingException, AdminException {
+
+ VDBDefn def = vdb.getConfigurationDef();
+
+ int version = 0;
+ VDBArchive existing = null;
+ do {
+ version++;
+ existing = getConfigurationService().getVDB(def.getName(), String.valueOf(version));
+ } while(existing != null);
+
+ // Look for the connector bindings in the VDB
+ // Based on users preference, either add or replace or throw exception
+ List vdbbindings = new ArrayList(def.getConnectorBindings().values());
+
+ for (Iterator i = vdbbindings.iterator(); i.hasNext();) {
+ ConnectorBinding binding = (ConnectorBinding)i.next();
+
+ String deployName = binding.getDeployedName();
+ if (deployName == null) {
+ deployName = binding.getFullName();
+ }
+
+ if (bindingExists(deployName)) {
+ if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.addBindingEixists", binding.getDeployedName())); //$NON-NLS-1$
+ }
+ }
+
+ // when the binding is not found it falls in "add", "overwrite" or "ignore"
+ // first two cases we need to add.
+ ConnectorBindingType type = (ConnectorBindingType)def.getConnectorType(binding.getComponentTypeID().getName());
+
+ // Check that the connector binding passwords can be decrypted
+ try {
+ checkDecryption(binding, type);
+ } catch(CryptoException e) {
+ if (!options.containsOption(AdminOptions.BINDINGS_IGNORE_DECRYPT_ERROR)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.CODE_DECRYPTION_FAILED", binding.getFullName())); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ /**
+ * Check that the properties of the specified ConnectorBinding can be decrypted.
+ * @param
+ * @return
+ * @since 4.3
+ */
+ private void checkDecryption(ConnectorBinding binding, ConnectorBindingType type) throws CryptoException {
+ Properties props = binding.getProperties();
+ Iterator it = props.keySet().iterator();
+ while (it.hasNext()) {
+ String name = (String)it.next();
+ if (isMaskedProperty(name, type)) {
+ decryptProperty(props.getProperty(name));
+ }
+ }
+ }
+
+ /**
+ * Check to see if the property read is a masked/encoded property
+ * @param propName
+ * @param type
+ * @return
+ */
+ boolean isMaskedProperty(String propName, ComponentType type) {
+ if (type != null) {
+ ComponentTypeDefn typeDef = type.getComponentTypeDefinition(propName);
+ if (typeDef != null && typeDef.getPropertyDefinition().isMasked()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Decrypt the given property using the Crypto libraries.
+ * @param value
+ * @return decrypted property.
+ */
+ String decryptProperty(String value) throws CryptoException{
+ if (value != null && value.length() > 0 && CryptoUtil.isValueEncrypted(value)) {
+ return CryptoUtil.stringDecrypt(value);
+ }
+ return value;
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addVDB(java.lang.String, byte[], AdminOptions)
+ * @since 4.3
+ */
+ public VDB addVDB(String deployName, byte[] vdbFile, AdminOptions options)
+ throws AdminException {
+ return addVDB(deployName, vdbFile, null, options);
+ }
+
+ @Override
+ public void deleteVDB(String vdbName, String vdbVersion) throws AdminException {
+ super.changeVDBStatus(vdbName, vdbVersion, VDB.DELETED);
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addExtensionModule(java.lang.String, java.lang.String, byte[], java.lang.String)
+ * @since 4.3
+ */
+ public void addExtensionModule(String type, String sourceName, byte[] source, String description)
+ throws AdminException {
+// try {
+// if (sourceName == null) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name")); //$NON-NLS-1$
+// }
+// if (source == null || source.length == 0) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source")); //$NON-NLS-1$
+// }
+// if (!sourceName.endsWith(".jar") && !sourceName.endsWith(".xmi")) { //$NON-NLS-1$ //$NON-NLS-2$
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_module")); //$NON-NLS-1$
+// }
+// ExtensionModule previousModule = null;
+//
+// try {
+// previousModule = getConfigurationService().getExtensionModule(sourceName);
+// }catch(MetaMatrixComponentException e) {
+// // this is OK, we did not find any thing
+// }
+//
+// if ( previousModule == null) {
+// // Now add it.
+// BasicExtensionModule extModule = new BasicExtensionModule(sourceName, type, description, source);
+// getConfigurationService().saveExtensionModule(extModule);
+// }
+// else {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.extension_module_exists", sourceName)); //$NON-NLS-1$
+// }
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#deleteExtensionModule(java.lang.String)
+ * @since 4.3
+ */
+ public void deleteExtensionModule(String sourceName)
+ throws AdminException {
+// try {
+// if (sourceName == null) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name")); //$NON-NLS-1$
+// }
+// getConfigurationService().deleteExtensionModule(sourceName);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#assignBindingToModel(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+ * @since 4.3
+ */
+ public void assignBindingToModel(String deployedConnectorBindingName, String vdbName, String vdbVersion, String modelName)
+ throws AdminException {
+
+ if (deployedConnectorBindingName == null || !deployedConnectorBindingName.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
+ }
+
+ if (vdbName == null || vdbVersion == null || !vdbName.matches(SINGLE_WORD_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name")); //$NON-NLS-1$
+ }
+
+ if (modelName == null || !modelName.matches(MULTIPLE_WORDS_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_model_name")); //$NON-NLS-1$
+ }
+
+ // find the connector binding if found in the configuration service
+ // add to the vdb binding.
+ try {
+ ConnectorBinding binding = null;//getDataService().getConnectorBinding(deployedConnectorBindingName);
+ if (binding != null) {
+ List list = new ArrayList();
+ list.add(binding);
+ getConfigurationService().assignConnectorBinding(vdbName, vdbVersion, modelName, (ConnectorBinding[])list.toArray(new ConnectorBinding[list.size()]));
+ }
+ else {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Vdb_or_Model_notfound")); //$NON-NLS-1$
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ public void assignBindingsToModel(String[] deployedConnectorBindingName, String vdbName, String vdbVersion, String modelName) throws AdminException {
+ if (deployedConnectorBindingName == null || deployedConnectorBindingName.length == 0) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
+ }
+
+ if (vdbName == null || vdbVersion == null || !vdbName.matches(SINGLE_WORD_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name")); //$NON-NLS-1$
+ }
+
+ if (modelName == null || !modelName.matches(MULTIPLE_WORDS_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_model_name")); //$NON-NLS-1$
+ }
+
+ // find the connector binding if found in the configuration service
+ // add to the vdb binding.
+ try {
+ List list = new ArrayList();
+ for (int i = 0; i < deployedConnectorBindingName.length; i++) {
+ ConnectorBinding binding = null; //getDataService().getConnectorBinding(deployedConnectorBindingName[i]);
+ if (binding != null) {
+ list.add(binding);
+ }
+ }
+
+ if (!list.isEmpty()) {
+ getConfigurationService().assignConnectorBinding(vdbName, vdbVersion, modelName, (ConnectorBinding[])list.toArray(new ConnectorBinding[list.size()]));
+ }
+ else {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Vdb_or_Model_notfound")); //$NON-NLS-1$
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#getLogConfiguration()
+ * @since 4.3
+ */
+ public LogConfiguration getLogConfiguration()
+ throws AdminException {
+ return (LogConfiguration)convertToAdminObjects(LogManager.getLogConfigurationCopy());
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#setLogConfiguration(org.teiid.adminapi.LogConfiguration)
+ * @since 4.3
+ */
+ public void setLogConfiguration(LogConfiguration config)
+ throws AdminException {
+ LogManager.setLogConfiguration((com.metamatrix.common.log.LogConfiguration)convertToNativeObjects(config));
+ }
+
+ /**
+ * @see com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#setLogListener(java.lang.Object)
+ * @since 4.3
+ */
+ public void setLogListener(EmbeddedLogger listener)
+ throws AdminException {
+ if(listener != null) {
+ LogManager.setLogListener(new DQPLogListener(listener));
+ }
+ else {
+ throw new AdminProcessingException("Admin_invalid_log_listener"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#exportExtensionModule(java.lang.String)
+ * @since 4.3
+ */
+ public byte[] exportExtensionModule(String sourceName) throws AdminException {
+// try {
+// if (sourceName == null) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ext_source_name")); //$NON-NLS-1$
+// }
+//
+// ExtensionModule extModule = getConfigurationService().getExtensionModule(sourceName);
+// return extModule.getFileContents();
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#exportConfiguration()
+ * @since 4.3
+ */
+ public char[] exportConfiguration() throws AdminException {
+ try {
+ StringWriter sw = new StringWriter();
+ Properties props = getConfigurationService().getSystemProperties();
+ props.store(sw, "Export of Teiid Configuration Properties"); //$NON-NLS-1$
+ return sw.toString().toCharArray();
+ } catch (IOException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#exportConnectorBinding(java.lang.String)
+ * @since 4.3
+ */
+ public char[] exportConnectorBinding(String identifier)
+ throws AdminException {
+// try {
+// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_cb_name")); //$NON-NLS-1$
+// }
+//
+// List bindingList = getDataService().getConnectorBindings();
+// List matchedList = new ArrayList();
+// for (Iterator i = bindingList.iterator(); i.hasNext();) {
+// ConnectorBinding binding = (ConnectorBinding)i.next();
+// if (matches(identifier, binding.getDeployedName())) {
+// matchedList.add(binding);
+// }
+// }
+//
+// if (!matchedList.isEmpty()) {
+// ConnectorBinding[] bindings = (ConnectorBinding[])matchedList.toArray(new ConnectorBinding[matchedList.size()]);
+// ConnectorBindingType[] types = new ConnectorBindingType[bindings.length];
+//
+// for (int i = 0; i < bindings.length; i++) {
+// types[i] = getConfigurationService().getConnectorType(bindings[i].getComponentTypeID().getName());
+// }
+// return ConnectorConfigurationWriter.writeToCharArray(bindings, types);
+// }
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists", identifier)); //$NON-NLS-1$
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#exportConnectorType(java.lang.String)
+ * @since 4.3
+ */
+ public char[] exportConnectorType(String identifier)
+ throws AdminException {
+// try {
+// if (identifier == null || !identifier.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
+// }
+//
+// List typesList = getConfigurationService().getConnectorTypes();
+// List matchedList = new ArrayList();
+// for (Iterator i = typesList.iterator(); i.hasNext();) {
+// ConnectorBindingType type = (ConnectorBindingType)i.next();
+// if (matches(identifier, type.getName())) {
+// matchedList.add(type);
+// }
+// }
+//
+// if (!matchedList.isEmpty()) {
+// ConnectorBindingType[] types = (ConnectorBindingType[])matchedList.toArray(new ConnectorBindingType[matchedList.size()]);
+// return ConnectorConfigurationWriter.writeToCharArray(types);
+// }
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_does_not_exists", identifier)); //$NON-NLS-1$
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#exportVDB(java.lang.String, java.lang.String)
+ * @since 4.3
+ */
+ public byte[] exportVDB(String name, String version)
+ throws AdminException {
+
+ try {
+ if (name == null || version == null || !name.matches(SINGLE_WORD_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_vdb_name")); //$NON-NLS-1$
+ }
+
+ VDBArchive vdb = getConfigurationService().getVDB(name, version);
+ if (vdb != null) {
+ return VDBArchive.writeToByteArray(vdb);
+ }
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.vdb_does_not_exists", name, version)); //$NON-NLS-1$
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#addConnectorArchive(byte[], org.teiid.adminapi.AdminOptions)
+ * @since 4.3.2
+ */
+ public void addConnectorArchive(byte[] contents, AdminOptions options) throws AdminException {
+
+ // if the options object is null treat as if it is IGNORE as default
+ if (options == null) {
+ options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
+ }
+
+ if (contents == null || contents.length == 0) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_source")); //$NON-NLS-1$
+ }
+
+ try {
+ // Load the connector Archive from the file
+ HashSet previouslyAddedModules = new HashSet();
+ ConnectorArchive archive = ConnectorConfigurationReader.loadConnectorArchive(contents);
+ ConnectorBindingType[] connectorTypes = archive.getConnectorTypes();
+
+ // Loop through each type and add all of them based on the option.
+ for (int typeIndex = 0; typeIndex < connectorTypes.length; typeIndex++) {
+
+ // first make sure we do not already have this connector type
+ String connectorName = connectorTypes[typeIndex].getName();
+// ConnectorBindingType type = getConfigurationService().getConnectorType(connectorName);
+ ConnectorBindingType type = null;
+ if (type == null) {
+ type = connectorTypes[typeIndex];
+ ExtensionModule[] extModules = archive.getExtensionModules(type);
+ checkDuplicateExtensionModules(extModules, options, previouslyAddedModules);
+ saveConnectorType(type);
+
+ } else {
+
+ // if not asked to overwrite/skip writing them
+ if (options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_exists", connectorName)); //$NON-NLS-1$
+ } else if (options.containsOption(AdminOptions.OnConflict.IGNORE)) {
+ continue;
+ } else if (options.containsOption(AdminOptions.OnConflict.OVERWRITE)){
+ deleteConnectorType(connectorName);
+ // Now that we know we need to add this to configuration; let's get on with it
+ type = connectorTypes[typeIndex];
+ ExtensionModule[] extModules = archive.getExtensionModules(type);
+ checkDuplicateExtensionModules(extModules, options, previouslyAddedModules);
+ saveConnectorType(type);
+ }
+ }
+ // Now that we know we need to add this to configuration; let's get on with it
+ type = connectorTypes[typeIndex];
+ ExtensionModule[] extModules = archive.getExtensionModules(type);
+ checkDuplicateExtensionModules(extModules, options, previouslyAddedModules);
+ }
+
+ // Now add the extension modules
+ for (Iterator i = previouslyAddedModules.iterator(); i.hasNext();) {
+ ExtensionModule extModule = (ExtensionModule)i.next();
+ addExtensionModule(extModule.getModuleType(), extModule.getFullName(), extModule.getFileContents(), extModule.getDescription());
+ }
+
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * This method checks the passed in connector type's extension module is not already in the
+ * system, if it there takes the appropriate action. Otherwise keeps tracks of all modules
+ * to add.
+ * @param type - connector type
+ * @param extModules - Extension modules for the Connector Type
+ * @param options - Admin Options
+ * @param ignorableModules - Modules which are already added, can be ignored for adding
+ */
+ void checkDuplicateExtensionModules(ExtensionModule[] extModules, AdminOptions options, HashSet ignorableModules)
+ throws AdminException {
+
+// // Now check if the the extension modules are already there
+// for (int i = 0; i < extModules.length; i++) {
+// boolean add = true;
+//
+// String moduleName = extModules[i].getFullName();
+// ExtensionModule previousModule = null;
+//
+// // see if we can ignore this, because we may have just added this during import of
+// // another connector type through this archive
+// if (ignorableModules.contains(extModules[i])) {
+// continue;
+// }
+//
+// // we have not already added this this time around, now check if this available
+// // from configuration service
+// try {
+// previousModule = getConfigurationService().getExtensionModule(moduleName);
+// }catch(MetaMatrixComponentException e) {
+// // this is OK, we did not find any thing
+// }
+//
+// // if we found it take appropriate action.
+// if(previousModule != null && options.containsOption(AdminOptions.OnConflict.EXCEPTION)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.extension_module_exists", previousModule.getFullName())); //$NON-NLS-1$
+// }
+// else if (previousModule != null && options.containsOption(AdminOptions.OnConflict.IGNORE)) {
+// add = false;
+// }
+// else if (previousModule != null && options.containsOption(AdminOptions.OnConflict.OVERWRITE)) {
+// // since we are overwrite, first delete and then add, there is no safe way to overwrite
+// deleteExtensionModule(previousModule.getFullName());
+// }
+//
+// // Now keep track what extension modules to add; also to ignore in future
+// // adds
+// if (add) {
+// ignorableModules.add(extModules[i]);
+// }
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.ConfigurationAdmin#exportConnectorArchive(java.lang.String)
+ * @since 4.3
+ */
+ public byte[] exportConnectorArchive(String identifier) throws AdminException {
+// try {
+// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
+// }
+//
+// // first build the connector archive object
+// BasicConnectorArchive archive = new BasicConnectorArchive();
+// List connectorTypes = getConfigurationService().getConnectorTypes();
+//
+// for (Iterator i = connectorTypes.iterator(); i.hasNext();) {
+// ConnectorBindingType type = (ConnectorBindingType)i.next();
+//
+// // If the types name matches with the pattern sent in add to archive
+// if (type != null && matches(identifier, type.getName())) {
+//
+// // Add connector type first
+// archive.addConnectorType(type);
+//
+// // Get the extension modules required for the type
+// String[] extModules = type.getExtensionModules();
+// for (int m = 0; m < extModules.length; m++) {
+// // Get the extension module from the configuration and add to the archive
+// ExtensionModule extModule = getConfigurationService().getExtensionModule(extModules[m]);
+// if (extModule != null) {
+// archive.addExtensionModule(type, extModule);
+// }
+// else {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("DataService.ext_module_not_found", extModules[m])); //$NON-NLS-1$
+// }
+// }
+// }
+// }
+//
+// // if no types found to the identifier pattern, then throw an exception
+// if (archive.getConnectorTypes().length == 0) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_type_does_not_exists", identifier)); //$NON-NLS-1$
+// }
+//
+// // now convert the object into file form
+// return ConnectorConfigurationWriter.writeToByteArray(archive);
+//
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ private void saveConnectorType(ConnectorBindingType type) throws MetaMatrixComponentException {
+ // getConfigurationService().saveConnectorType(type);
+ }
+
+
+ @Override
+ public void addUDF(byte[] modelFileContents, String classpath)
+ throws AdminException {
+// if (modelFileContents == null || modelFileContents.length == 0) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_UDF_contents")); //$NON-NLS-1$
+// }
+//
+// try {
+//
+// getConfigurationService().unloadUDF();
+//
+// // delete any extension module by the same name first
+// try {
+// deleteExtensionModule(ConfigurationService.USER_DEFINED_FUNCTION_MODEL);
+// } catch (AdminException e) {
+// // if not found then it is OK to fail
+// }
+//
+// // add the function definitions as extension modules
+// addExtensionModule(ExtensionModule.FUNCTION_DEFINITION_TYPE,ConfigurationService.USER_DEFINED_FUNCTION_MODEL,modelFileContents, "User Defined Functions File"); //$NON-NLS-1$
+//
+// String commonpath = getConfigurationService().getSystemProperties().getProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH, ""); //$NON-NLS-1$
+//
+// StringBuilder sb = new StringBuilder();
+// if (classpath != null && classpath.length() > 0 ) {
+// StringTokenizer st = new StringTokenizer(classpath, ";"); //$NON-NLS-1$
+// while (st.hasMoreTokens()) {
+// String partpath = st.nextToken();
+// if (commonpath.indexOf(partpath) == -1) {
+// sb.append(partpath).append(";"); //$NON-NLS-1$
+// }
+// }
+// }
+// getConfigurationService().setSystemProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH, sb.toString()+commonpath);
+//
+//
+// // then update the properties
+// Properties p = new Properties();
+// p.setProperty(DQPEmbeddedProperties.COMMON_EXTENSION_CLASPATH, classpath);
+// getConfigurationService().updateSystemProperties(p);
+// // reload the new UDF
+// getConfigurationService().loadUDF();
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ @Override
+ public void deleteUDF() throws AdminException {
+ try {
+ getConfigurationService().unloadUDF();
+ deleteExtensionModule(ConfigurationService.USER_DEFINED_FUNCTION_MODEL);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ public void extensionModuleModified(String name) throws AdminException {
+// try {
+// getConfigurationService().clearClassLoaderCache();
+// getConfigurationService().loadUDF();
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+
+ @Override
+ public void setProcessProperty(String processIdentifier, String propertyName, String propertyValue) throws AdminException{
+// try {
+// getConfigurationService().setSystemProperty(propertyName, propertyValue);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ }
+}
Property changes on: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPConfigAdminImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java (from rev 1544, branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java)
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java (rev 0)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.dqp.embedded.admin;
+
+import org.teiid.adminapi.EmbeddedLogger;
+import org.teiid.adminapi.LogConfiguration;
+
+import com.metamatrix.core.log.LogListener;
+import com.metamatrix.core.log.MessageLevel;
+
+
+public class DQPLogListener implements LogListener {
+
+ private EmbeddedLogger logger;
+
+ public DQPLogListener(EmbeddedLogger logger) {
+ this.logger = logger;
+ }
+
+ public void log(int level, String context, Object msg) {
+ logger.log(convertLevel(level), System.currentTimeMillis(), context, Thread.currentThread().getName(), msg.toString(), null);
+ }
+
+ public void log(int level, String context, Throwable t, Object msg) {
+ logger.log(convertLevel(level), System.currentTimeMillis(), context, Thread.currentThread().getName(), msg.toString(), t);
+ }
+
+ private int convertLevel(int level) {
+ int logLevel = LogConfiguration.INFO;
+
+ switch(level) {
+ case MessageLevel.WARNING:
+ logLevel = LogConfiguration.WARNING;
+ break;
+ case MessageLevel.ERROR:
+ logLevel = LogConfiguration.ERROR;
+ break;
+ case MessageLevel.DETAIL:
+ logLevel = LogConfiguration.DETAIL;
+ break;
+ case MessageLevel.TRACE:
+ logLevel = LogConfiguration.TRACE;
+ break;
+ case MessageLevel.NONE:
+ logLevel = LogConfiguration.NONE;
+ break;
+
+ default:
+ logLevel = LogConfiguration.INFO;
+ }
+ return logLevel;
+ }
+
+ public void shutdown() {
+ }
+}
Property changes on: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPLogListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java (from rev 1544, branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java)
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java (rev 0)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,320 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.dqp.embedded.admin;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.Cache;
+import org.teiid.adminapi.ConnectionPool;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.ConnectorType;
+import org.teiid.adminapi.ExtensionModule;
+import org.teiid.adminapi.MonitoringAdmin;
+import org.teiid.adminapi.PropertyDefinition;
+import org.teiid.adminapi.QueueWorkerPool;
+import org.teiid.adminapi.Request;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.Transaction;
+import org.teiid.adminapi.VDB;
+
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.common.vdb.api.VDBArchive;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+import com.metamatrix.server.serverapi.RequestInfo;
+
+
+/**
+ * DQP implementation of the Monitoring API
+ * @since 4.3
+ */
+public abstract class DQPMonitoringAdminImpl extends BaseAdmin implements MonitoringAdmin {
+
+ public DQPMonitoringAdminImpl(EmbeddedConnectionFactoryImpl manager) {
+ super(manager);
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getConnectorTypes(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<ConnectorType> getConnectorTypes(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+ }
+
+ return super.getConnectorTypes(identifier);
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getVDBs(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<VDB> getVDBs(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(VDB_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+ }
+
+ // if . and * not specified, add a STAR at the end to compensate for the
+ // version number matching.
+ if (identifier.indexOf(DOT) == -1 && identifier.indexOf(STAR) == -1) {
+ identifier = identifier +DOT+STAR;
+ }
+
+ try {
+ List<VDBArchive> vdbs = getVDBService().getAvailableVDBs();
+ List matchedVdbs = new ArrayList();
+ for (VDBArchive vdb:vdbs) {
+ if (matches(identifier, vdb.getName()+"."+vdb.getVersion())) { //$NON-NLS-1$
+ matchedVdbs.add(vdb);
+ }
+ }
+ return (List)convertToAdminObjects(matchedVdbs);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getConnectorBindings(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<ConnectorBinding> getConnectorBindings(String identifier)
+ throws AdminException {
+
+ if (identifier == null) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+ }
+ return super.getConnectorBindings(identifier);
+ }
+
+
+ @Override
+ public Collection<ConnectorBinding> getConnectorBindingsInVDB(String vdbName, String vdbVersion) throws AdminException{
+ try {
+ VDBArchive vdb = getConfigurationService().getVDB(vdbName, vdbVersion);
+ if (vdb != null) {
+ return (List)convertToAdminObjects(vdb.getConfigurationDef().getConnectorBindings().values());
+ }
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.vdb_does_not_exists", vdbVersion, vdbVersion)); //$NON-NLS-1$
+
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getExtensionModules(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<ExtensionModule> getExtensionModules(String identifier)
+ throws AdminException {
+
+// if (identifier == null || !identifier.matches(WORD_AND_DOT_WILDCARD_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+// }
+//
+// try {
+// List extModules = getConfigurationService().getExtensionModules();
+// extModules = (List)convertToAdminObjects(extModules);
+// return matchedCollection(identifier, extModules);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getQueueWorkerPools(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<QueueWorkerPool> getQueueWorkerPools(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+ }
+
+ List results = new ArrayList();
+ if (matches(identifier, "dqp")) { //$NON-NLS-1$
+ // First get the queue statistics for the DQP
+ Collection c = getManager().getDQP().getQueueStatistics();;
+ if (c != null && !c.isEmpty()) {
+ results.addAll(c);
+ }
+ }
+
+ try {
+ // Now get for all the connector bindings
+ Collection bindings = super.getConnectorBindings(identifier);
+ for (Iterator i = bindings.iterator(); i.hasNext();) {
+ ConnectorBinding binding = (ConnectorBinding)i.next();
+ Collection c = getDataService().getConnectorStatistics(binding.getName());
+ if (c != null && !c.isEmpty()) {
+ results.addAll(c);
+ }
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+
+ if (!results.isEmpty()) {
+ return (List)convertToAdminObjects(results);
+ }
+ return Collections.EMPTY_LIST;
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getCaches(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<Cache> getCaches(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(SINGLE_WORD_WILDCARD_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+ }
+
+ List cacheList = new ArrayList();
+ for (int i =0; i < cacheTypes.length; i++) {
+ if (matches(identifier, cacheTypes[i])) {
+ cacheList.add(cacheTypes[i]);
+ }
+ }
+ return cacheList;
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getSessions(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<Session> getSessions(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(NUMBER_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+ }
+ return matchedCollection(identifier, (List)convertToAdminObjects(getClientConnections()));
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getRequests(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<Request> getRequests(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(NUMBER_DOT_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+ }
+
+ ArrayList requestList = new ArrayList();
+ // List contains both top and atomic requests, only add the top requests
+ List<RequestInfo> requests = getManager().getDQP().getRequests();
+ for(RequestInfo request:requests) {
+ if (request.getConnectorBindingUUID() == null) {
+ requestList.add(request);
+ }
+ }
+ return matchedCollection(identifier, (List)convertToAdminObjects(requestList));
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getSourceRequests(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<Request> getSourceRequests(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(NUMBER_DOT_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+ }
+
+ ArrayList atomicRequestList = new ArrayList();
+ List<RequestInfo> requests = getManager().getDQP().getRequests();
+ for (RequestInfo request:requests) {
+ if (request.getConnectorBindingUUID() != null) {
+ atomicRequestList.add(request);
+ }
+ }
+ return matchedCollection(identifier, (List)convertToAdminObjects(atomicRequestList));
+ }
+
+ /**
+ * @see org.teiid.adminapi.MonitoringAdmin#getPropertyDefinitions(java.lang.String, java.lang.String)
+ * @since 4.3
+ */
+ public Collection<PropertyDefinition> getConnectorTypePropertyDefinitions(String typeName) throws AdminException {
+
+// if (typeName == null || !typeName.matches(MULTIPLE_WORDS_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_ct_name")); //$NON-NLS-1$
+// }
+//
+// try {
+// ConnectorBindingType type = getConfigurationService().getConnectorType(typeName);
+// if (type == null) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.ct_doesnot_exist", typeName)); //$NON-NLS-1$
+// }
+//
+// return convertPropertyDefinitions(type, new Properties());
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return null;
+ }
+
+ @Override
+ public Collection<Transaction> getTransactions()
+ throws AdminException {
+ TransactionService ts = getTransactionService();
+ if (ts == null) {
+ return Collections.emptyList();
+ }
+ return ts.getTransactions();
+ }
+
+ @Override
+ public Collection<? extends ConnectionPool> getConnectionPoolStats(String identifier)
+ throws AdminException {
+
+// try {
+// return this.getDataService().getConnectionPoolStatistics(identifier);
+// } catch (MetaMatrixComponentException e) {
+// throw new AdminComponentException(e);
+// }
+ return Collections.EMPTY_LIST;
+ }
+
+}
Property changes on: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPMonitoringAdminImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java (from rev 1544, branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java)
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java (rev 0)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,302 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.dqp.embedded.admin;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.transaction.xa.Xid;
+
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.Cache;
+import org.teiid.adminapi.ConnectorBinding;
+import org.teiid.adminapi.Request;
+import org.teiid.adminapi.RuntimeStateAdmin;
+import org.teiid.dqp.internal.process.DQPWorkContext;
+
+import com.metamatrix.admin.objects.MMRequest;
+import com.metamatrix.api.exception.MetaMatrixComponentException;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.dqp.message.AtomicRequestID;
+import com.metamatrix.dqp.message.RequestID;
+import com.metamatrix.dqp.service.TransactionService;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
+
+
+/**
+ * @since 4.3
+ */
+public abstract class DQPRuntimeStateAdminImpl extends BaseAdmin implements RuntimeStateAdmin {
+
+ public DQPRuntimeStateAdminImpl(EmbeddedConnectionFactoryImpl manager) {
+ super(manager);
+ }
+
+ /**
+ * @see com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#stop(int)
+ * @since 4.3
+ */
+ public void shutdown(int millisToWait) throws AdminException {
+ // TODO: rreddy need to implement the time to wait.
+ // First terminate all the sessions to the DQP currently have
+ terminateSession(AdminObject.WILDCARD);
+
+ getManager().shutdown(false);
+ }
+
+ /**
+ * @see com.metamatrix.admin.api.embedded.EmbeddedRuntimeStateAdmin#restart()
+ * @since 4.3
+ */
+ public void restart() throws AdminException {
+ // First terminate all the sessions to the DQP currently have
+ terminateSession(AdminObject.WILDCARD);
+
+ // Now shutdown the DQP, it will automatically start next timea new connection is
+ // requested.
+ getManager().shutdown(true);
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#startConnectorBinding(java.lang.String)
+ * @since 4.3
+ */
+ public void startConnectorBinding(String identifier)
+ throws AdminException {
+
+// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+// }
+//
+// AdminException exceptionWrapper = null;
+// // Get all matching connector bindings
+// Collection bindings = getConnectorBindings(identifier);
+// if (bindings != null && !bindings.isEmpty()) {
+// for (Iterator i = bindings.iterator(); i.hasNext();) {
+// try {
+// AdminObject binding = (AdminObject)i.next();
+// getDataService().startConnectorBinding(binding.getName());
+// } catch (ApplicationLifecycleException e) {
+// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
+// } catch (MetaMatrixComponentException e) {
+// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
+// }
+// }
+// }
+// else {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists", new Object[] {identifier})); //$NON-NLS-1$
+// }
+//
+// // If any errors occurred then thow the exception.
+// if (exceptionWrapper != null) {
+// throw exceptionWrapper;
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#stopConnectorBinding(java.lang.String, boolean)
+ * @since 4.3
+ */
+ public void stopConnectorBinding(String identifier, boolean stopNow)
+ throws AdminException {
+// // TODO: need to implement "now" part
+// if (identifier == null || !identifier.matches(MULTIPLE_WORD_WILDCARD_REGEX)) {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+// }
+//
+// AdminException exceptionWrapper = null;
+// // Get all matching connector bindings
+// Collection bindings = getConnectorBindings(identifier);
+// if (bindings != null && !bindings.isEmpty()) {
+// for (Iterator i = bindings.iterator(); i.hasNext();) {
+// try {
+// AdminObject binding = (AdminObject)i.next();
+// getDataService().stopConnectorBinding(binding.getName());
+// } catch (ApplicationLifecycleException e) {
+// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
+// } catch (MetaMatrixComponentException e) {
+// exceptionWrapper = accumulateSystemException(exceptionWrapper, e);
+// }
+// }
+// }
+// else {
+// throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Connector_binding_does_not_exists", new Object[] {identifier})); //$NON-NLS-1$
+// }
+//
+// // If any errors occurred then thow the exception.
+// if (exceptionWrapper != null) {
+// throw exceptionWrapper;
+// }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#clearCache(java.lang.String)
+ * @since 4.3
+ */
+ public void clearCache(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches(SINGLE_WORD_WILDCARD_REGEX)) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+ }
+ boolean processed = false;
+
+ for (int i = 0; i < cacheTypes.length; i++) {
+ if (matches(identifier, cacheTypes[i])) {
+ if(cacheTypes[i].equals(Cache.CODE_TABLE_CACHE)) {
+ processed = true;
+ getManager().getDQP().clearCodeTableCache();
+ } else if(cacheTypes[i].equals(Cache.PREPARED_PLAN_CACHE)) {
+ processed = true;
+ getManager().getDQP().clearPlanCache();
+ } else if(cacheTypes[i].equals( Cache.QUERY_SERVICE_RESULT_SET_CACHE)) {
+ processed = true;
+ getManager().getDQP().clearResultSetCache();
+ } else if (cacheTypes[i].equals(Cache.CONNECTOR_RESULT_SET_CACHE)) {
+ processed = true;
+ try {
+ // Now get for all the connector bindings
+ Collection bindings = super.getConnectorBindings("*"); //$NON-NLS-1$
+ for (Iterator iter = bindings.iterator(); iter.hasNext();) {
+ ConnectorBinding binding = (ConnectorBinding)iter.next();
+ getDataService().clearConnectorBindingCache(binding.getName());
+ }
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+ }
+ }
+
+ if (!processed) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.invalid_request", new Object[] {identifier})); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#terminateSession(java.lang.String)
+ * @since 4.3
+ */
+ public void terminateSession(String identifier)
+ throws AdminException {
+
+ Collection<MetaMatrixSessionInfo> sessions = getClientConnections();
+ ArrayList<MetaMatrixSessionInfo> matchedConnections = new ArrayList<MetaMatrixSessionInfo>();
+
+ for (MetaMatrixSessionInfo info:sessions) {
+ String id = info.getSessionID().toString();
+ if (matches(identifier, id)) {
+ matchedConnections.add(info);
+ }
+ }
+
+ // terminate the sessions.
+ for (MetaMatrixSessionInfo info: matchedConnections) {
+ getSessionService().terminateSession(info.getSessionID(), DQPWorkContext.getWorkContext().getSessionId());
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#cancelRequest(java.lang.String)
+ * @since 4.3
+ */
+ public void cancelRequest(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches("\\d+\\" + Request.DELIMITER + "\\d+")) { //$NON-NLS-1$ //$NON-NLS-2$
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+ }
+
+ String[] identifierParts = MMRequest.buildIdentifierArray(identifier);
+ String connId = identifierParts[0];
+ long requestId = Long.parseLong(identifierParts[1]);
+
+ // get the client connection
+ RequestID id = new RequestID(connId, requestId);
+
+ try {
+ getManager().getDQP().cancelRequest(id);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#cancelSourceRequest(java.lang.String)
+ * @since 4.3
+ */
+ public void cancelSourceRequest(String identifier)
+ throws AdminException {
+
+ if (identifier == null || !identifier.matches("\\d+\\" + Request.DELIMITER + "\\d+\\" + Request.DELIMITER + "\\d+" + Request.DELIMITER + "\\d+")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("Admin.Invalid_identifier")); //$NON-NLS-1$
+ }
+
+ String[] identifierParts = MMRequest.buildIdentifierArray(identifier);
+
+ String connId = identifierParts[0];
+ long requestId = Long.parseLong(identifierParts[1]);
+ int nodeId = Integer.parseInt(identifierParts[2]);
+ int executionId = Integer.parseInt(identifierParts[3]);
+ AtomicRequestID id = new AtomicRequestID(new RequestID(connId, requestId), nodeId, executionId);
+
+ try {
+ getManager().getDQP().cancelAtomicRequest(id);
+ } catch (MetaMatrixComponentException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see org.teiid.adminapi.RuntimeStateAdmin#changeVDBStatus(java.lang.String, java.lang.String, int)
+ * @since 4.3
+ */
+ public void changeVDBStatus(String name, String version, int status)
+ throws AdminException {
+ super.changeVDBStatus(name, version, status);
+ }
+
+
+ @Override
+ public void terminateTransaction(String transactionId, String sessionId)
+ throws AdminException {
+// TransactionService ts = getTransactionService();
+// if (ts != null) {
+// ts.terminateTransaction(transactionId, sessionId);
+// }
+ }
+
+ @Override
+ public void terminateTransaction(Xid transactionId) throws AdminException {
+ TransactionService ts = getTransactionService();
+ if (ts != null) {
+ ts.terminateTransaction(transactionId);
+ }
+ }
+
+}
Property changes on: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPRuntimeStateAdminImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java (from rev 1544, branches/JCA/jboss-integration/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java)
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java (rev 0)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,275 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.dqp.embedded.admin;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.teiid.adminapi.AdminComponentException;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminObject;
+import org.teiid.adminapi.AdminOptions;
+import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.Group;
+import org.teiid.adminapi.SecurityAdmin;
+import org.xml.sax.SAXException;
+
+import com.metamatrix.admin.api.exception.security.InvalidSessionException;
+import com.metamatrix.admin.api.exception.security.MetaMatrixSecurityException;
+import com.metamatrix.admin.objects.MMGroup;
+import com.metamatrix.admin.objects.MMRole;
+import com.metamatrix.api.exception.security.AuthorizationException;
+import com.metamatrix.api.exception.security.AuthorizationMgmtException;
+import com.metamatrix.api.exception.security.MembershipServiceException;
+import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+import com.metamatrix.platform.admin.api.EntitlementMigrationReport;
+import com.metamatrix.platform.security.api.AuthorizationPolicy;
+import com.metamatrix.platform.security.api.AuthorizationPolicyFactory;
+import com.metamatrix.platform.security.api.AuthorizationRealm;
+import com.metamatrix.platform.security.api.MetaMatrixPrincipal;
+import com.metamatrix.platform.security.api.MetaMatrixPrincipalName;
+
+
+/**
+ * @since 4.3
+ */
+public abstract class DQPSecurityAdminImpl extends BaseAdmin implements SecurityAdmin {
+
+ public DQPSecurityAdminImpl(EmbeddedConnectionFactoryImpl manager) {
+ super(manager);
+ }
+
+ /**
+ * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#addRoleToGroup(java.lang.String, java.lang.String)
+ * @since 4.3
+ */
+ public void assignRoleToGroup(String roleIdentifier, String groupIdentifier) throws AdminException {
+ throw new AdminComponentException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.not_implemented")); //$NON-NLS-1$
+ }
+
+ /**
+ * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#removeRoleFromGroup(java.lang.String, java.lang.String)
+ * @since 4.3
+ */
+ public void removeRoleFromGroup(String roleIdentifier, String groupIdentifier) throws AdminException {
+ throw new AdminComponentException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.not_implemented")); //$NON-NLS-1$
+ }
+
+ /**
+ * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#getGroupsForUser(java.lang.String, boolean)
+ * @since 4.3
+ */
+ public Collection<Group> getGroupsForUser(String userIdentifier) throws AdminException {
+ if (userIdentifier == null) {
+ throwProcessingException("AdminImpl.requiredparameter", new Object[] {}); //$NON-NLS-1$
+ }
+
+ if ( userIdentifier.equals(AdminObject.WILDCARD) ) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.Cant_use_wildcard")); //$NON-NLS-1$
+ }
+ Collection groups = new ArrayList();
+ // Get all memberships - explicit and implicit
+ Set allMemberships = null;
+ try {
+ allMemberships = getMembershipService().getGroupsForUser(userIdentifier);
+ } catch (MetaMatrixSecurityException e) {
+ throw new AdminComponentException(e);
+ }
+ Iterator allMembershipsItr = allMemberships.iterator();
+ while ( allMembershipsItr.hasNext() ) {
+ groups.add(new MMGroup(new String[] {(String)allMembershipsItr.next()}));
+ }
+ return groups;
+ }
+
+ /**
+ * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#getGroups(java.lang.String)
+ * @since 4.3
+ */
+ public Collection<Group> getGroups(String groupIdentifier) throws AdminException {
+ if (groupIdentifier == null) {
+ throwProcessingException("AdminImpl.requiredparameter", new Object[] {}); //$NON-NLS-1$
+ }
+
+ Collection<Group> groups = new ArrayList<Group>();
+ Collection allGroups = null;
+ // Add all groups from internal membership domain
+ try {
+ allGroups = getMembershipService().getGroupNames();
+ } catch (MetaMatrixSecurityException e) {
+ throw new AdminComponentException(e);
+ }
+
+ Iterator groupItr = allGroups.iterator();
+ while ( groupItr.hasNext() ) {
+ String groupName = (String) groupItr.next();
+
+ if (!groupIdentifier.equals(AdminObject.WILDCARD) && !groupName.equals(groupIdentifier)) {
+ continue;
+ }
+
+ groups.add(new MMGroup(new String[] {groupName}));
+ }
+ return groups;
+ }
+
+
+ /**
+ * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#getRolesForGroup(java.lang.String)
+ * @since 4.3
+ */
+ public Collection getRolesForGroup(String groupIdentifier) throws AdminException {
+ if (groupIdentifier == null) {
+ throwProcessingException("AdminImpl.requiredparameter", new Object[] {}); //$NON-NLS-1$
+ }
+
+ if ( groupIdentifier.equals(AdminObject.WILDCARD) ) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.Cant_use_wildcard")); //$NON-NLS-1$
+ }
+ Collection roleNames = null;
+ try {
+ roleNames = getAuthorizationService().getRoleNamesForPrincipal(new MetaMatrixPrincipalName(groupIdentifier, MetaMatrixPrincipal.TYPE_GROUP));
+ } catch (InvalidSessionException e) {
+ throw new AdminComponentException(e);
+ } catch (AuthorizationMgmtException e) {
+ throw new AdminComponentException(e);
+ } catch (AuthorizationException e) {
+ throw new AdminComponentException(e);
+ }
+ Collection roles = new ArrayList();
+ Iterator roleNameItr = roleNames.iterator();
+ while ( roleNameItr.hasNext() ) {
+ String roleName = (String)roleNameItr.next();
+ roles.add(new MMRole(new String[] {roleName}));
+ }
+ return roles;
+ }
+
+ /**
+ * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#importDataRoles(java.lang.String, java.lang.String, char[], org.teiid.adminapi.AdminOptions)
+ */
+ public String importDataRoles(String vdbName, String vdbVersion, char[] xmlContents, AdminOptions options)
+ throws AdminException{
+
+ if (vdbName == null) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbName_can_not_be_null")); //$NON-NLS-1$
+ }
+
+ if (vdbVersion == null) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbVersion_can_not_be_null")); //$NON-NLS-1$
+ }
+
+ if (options == null) {
+
+ options = new AdminOptions(AdminOptions.OnConflict.IGNORE);
+ }
+
+ try {
+ EntitlementMigrationReport rpt = new EntitlementMigrationReport("from file", vdbName + " " + vdbVersion); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Collection<AuthorizationPolicy> roles = AuthorizationPolicyFactory.buildPolicies(vdbName, vdbVersion, xmlContents);
+
+ AuthorizationRealm realm = new AuthorizationRealm(vdbName, vdbVersion);
+
+ getAuthorizationService().updatePoliciesInRealm(realm, roles);
+
+ return rpt.toString();
+ } catch (AuthorizationMgmtException e) {
+ throw new AdminProcessingException(e);
+ } catch (SAXException e) {
+ throw new AdminComponentException(e);
+ } catch (IOException e) {
+ throw new AdminComponentException(e);
+ } catch (ParserConfigurationException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ /**
+ * @see com.metamatrix.admin.api.server.ServerSecurityAdmin#exportDataRoles(java.lang.String, java.lang.String)
+ */
+ public char[] exportDataRoles(String vdbName, String vdbVersion) throws AdminException {
+
+ if (vdbName == null) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbName_can_not_be_null")); //$NON-NLS-1$
+ }
+
+ if (vdbVersion == null) {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString("ServerSecurityAdminImpl.vdbVersion_can_not_be_null")); //$NON-NLS-1$
+ }
+
+ Collection roles = null;
+ try {
+ roles = getAuthorizationService().getPoliciesInRealm(new AuthorizationRealm(vdbName, vdbVersion));
+ if (roles != null && !roles.isEmpty()) {
+ return AuthorizationPolicyFactory.exportPolicies(roles);
+ }
+ return null;
+ } catch (AuthorizationMgmtException e) {
+ throw new AdminProcessingException(e);
+ } catch (AuthorizationException e) {
+ throw new AdminProcessingException(e);
+ } catch (IOException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ public List<String> getDomainNames() throws AdminException {
+ try {
+ return this.getMembershipService().getDomainNames();
+ } catch (MembershipServiceException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ @Override
+ public Collection<Group> getGroupsForDomain(String domainName)
+ throws AdminException {
+ if (domainName == null) {
+ throwProcessingException("AdminImpl.requiredparameter", new Object[] {}); //$NON-NLS-1$
+ }
+ try {
+ Collection<String> groupNames = this.getMembershipService().getGroupsForDomain(domainName);
+ List<Group> result = new ArrayList<Group>(groupNames.size());
+ for (String groupName : groupNames) {
+ result.add(new MMGroup(new String[] {groupName}));
+ }
+ return result;
+ } catch (MembershipServiceException e) {
+ throw new AdminComponentException(e);
+ }
+ }
+
+ void throwProcessingException(String key, Object[] objects) throws AdminException {
+ throw new AdminProcessingException(DQPEmbeddedPlugin.Util.getString(key, objects));
+ }
+
+}
Property changes on: branches/JCA/runtime/src/main/java/com/metamatrix/dqp/embedded/admin/DQPSecurityAdminImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedConnectionFactoryImpl.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -26,8 +26,6 @@
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.InetAddress;
import java.net.URL;
@@ -35,6 +33,8 @@
import java.util.Date;
import java.util.Properties;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
@@ -42,7 +42,7 @@
import org.teiid.TeiidManagedConnectionFactory;
import org.teiid.TeiidResourceAdapter;
import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.adminapi.impl.BaseAdmin;
import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.transport.AdminAuthorizationInterceptor;
import org.teiid.transport.LogonImpl;
@@ -63,12 +63,10 @@
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.protocol.URLHelper;
import com.metamatrix.common.queue.WorkerPoolStats;
-import com.metamatrix.common.util.JMXUtil;
import com.metamatrix.common.util.NetUtils;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.core.MetaMatrixCoreException;
import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.MixinProxy;
import com.metamatrix.dqp.ResourceFinder;
import com.metamatrix.dqp.client.ClientSideDQP;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
@@ -94,7 +92,6 @@
private ClientServiceRegistry clientServices;
private String workspaceDirectory;
private SocketTransport socketTransport;
- private JMXUtil jmxServer;
private boolean restart = false;
private InetAddress address;
private TeiidResourceAdapter ra;
@@ -164,10 +161,9 @@
throw new ApplicationInitializationException(e);
}
- this.jmxServer = new JMXUtil(processName);
- address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
+ this.address = resolveHostAddress(props.getProperty(DQPEmbeddedProperties.BIND_ADDRESS));
- EmbeddedGuiceModule config = new EmbeddedGuiceModule(bootstrapURL, props, this.jmxServer, address, this.ra);
+ EmbeddedGuiceModule config = new EmbeddedGuiceModule(bootstrapURL, props, address, this.ra);
Injector injector = Guice.createInjector(config);
ResourceFinder.setInjector(injector);
config.setInjector(injector);
@@ -221,7 +217,7 @@
SessionServiceInterface sessionService = (SessionServiceInterface)this.dqp.getEnvironment().findService(DQPServiceNames.SESSION_SERVICE);
services.registerClientService(ILogon.class, new LogonImpl(sessionService, configService.getClusterName()), com.metamatrix.common.util.LogConstants.CTX_SERVER);
- Admin roleCheckedServerAdmin = wrapAdminService(Admin.class, getAdminAPI());
+ Admin roleCheckedServerAdmin = wrapAdminService(Admin.class, getAdminAPI());
services.registerClientService(Admin.class, roleCheckedServerAdmin, com.metamatrix.common.util.LogConstants.CTX_ADMIN);
services.registerClientService(ClientSideDQP.class, this.dqp, LogConstants.CTX_QUERY_SERVICE);
@@ -364,38 +360,17 @@
this.restart = restart;
}
- private Admin getAdminAPI() {
-
- InvocationHandler handler = new MixinProxy(new Object[] {
-// TODO: This is hook for the admin API - NEEDS TO BE FIXED
-// new DQPConfigAdminImpl(this),
-// new DQPMonitoringAdminImpl(this),
-// new DQPRuntimeStateAdminImpl(this),
-// new DQPSecurityAdminImpl(this)
- }) {
-
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- // We we perform any DQP functions check if the DQP is still alive
- if (!isAlive()) {
- throw new AdminProcessingException(JDBCPlugin.Util.getString("EmbeddedConnection.DQP_shutDown")); //$NON-NLS-1$
- }
-
- ClassLoader callingClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- // Set the class loader to current class classloader so that the this classe's class loader gets used
- Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
- return super.invoke(proxy, method, args);
- }
- finally {
- Thread.currentThread().setContextClassLoader(callingClassLoader);
- }
- }
- };
- return (Admin) Proxy.newProxyInstance(this.getClass().getClassLoader(),new Class[] {Admin.class}, handler);
- }
-
- public JMXUtil getJMXServer() {
- return this.jmxServer;
+ private Admin getAdminAPI() {
+ try {
+ InitialContext ic = new InitialContext();
+ Admin admin = (Admin)ic.lookup("teiid/admin");
+ if (admin instanceof BaseAdmin) {
+ ((BaseAdmin) admin).setManager(this);
+ }
+ return admin;
+ } catch (NamingException e) {
+ throw new MetaMatrixRuntimeException("admin implementation not found");
+ }
}
public MMProcess getProcess() {
Modified: branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java
===================================================================
--- branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/runtime/src/main/java/com/metamatrix/jdbc/EmbeddedGuiceModule.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -48,7 +48,6 @@
import com.metamatrix.common.application.DQPConfigSource;
import com.metamatrix.common.log.LogConfiguration;
import com.metamatrix.common.log.LogManager;
-import com.metamatrix.common.util.JMXUtil;
import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.LogListener;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
@@ -69,15 +68,13 @@
private Properties props;
private URL bootstrapURL;
- private JMXUtil jmx;
private InetAddress bindAddress;
Injector injector;
TeiidResourceAdapter ra;
- public EmbeddedGuiceModule(URL bootstrapURL, Properties props, JMXUtil jmxUtil, InetAddress bindAddress, TeiidResourceAdapter ra) {
+ public EmbeddedGuiceModule(URL bootstrapURL, Properties props, InetAddress bindAddress, TeiidResourceAdapter ra) {
this.bootstrapURL = bootstrapURL;
this.props = props;
- this.jmx = jmxUtil;
this.bindAddress = bindAddress;
this.ra = ra;
}
@@ -93,7 +90,6 @@
bind(URL.class).annotatedWith(Names.named("BootstrapURL")).toInstance(bootstrapURL); //$NON-NLS-1$
bind(Properties.class).annotatedWith(Names.named("DQPProperties")).toInstance(this.props); //$NON-NLS-1$
- bind(JMXUtil.class).annotatedWith(Names.named("jmx")).toInstance(this.jmx); //$NON-NLS-1$
bind(InetAddress.class).annotatedWith(Names.named(DQPEmbeddedProperties.HOST_ADDRESS)).toInstance(bindAddress);
Modified: branches/JCA/runtime/src/main/java/org/teiid/Server.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/Server.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/runtime/src/main/java/org/teiid/Server.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -27,25 +27,14 @@
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
-import java.util.Iterator;
import java.util.Properties;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-import com.metamatrix.common.config.api.ExtensionModule;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.ApplicationInfo;
import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.common.util.JMXUtil.FailedToRegisterException;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.MessageLevel;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.ZipFileUtil;
import com.metamatrix.dqp.embedded.DQPEmbeddedPlugin;
import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-import com.metamatrix.dqp.embedded.services.EmbeddedConfigurationService;
-import com.metamatrix.dqp.service.DQPServiceNames;
import com.metamatrix.dqp.util.LogConstants;
import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
@@ -58,31 +47,31 @@
this.props = props;
}
- private void start() {
- try {
- // start the engine.
- initialize(this.props);
-
- getJMXServer().register(TYPE, NAME, this);
-
- } catch (FailedToRegisterException e) {
- throw new MetaMatrixRuntimeException(e.getCause());
- } catch (MetaMatrixCoreException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- }
-
- private void stopS(boolean restart) {
- if (isAlive()) {
- shutdown(restart);
- }
-
- try {
- getJMXServer().unregister(TYPE, NAME);
- } catch (FailedToRegisterException e) {
- // ignore
- }
- }
+// private void start() {
+// try {
+// // start the engine.
+// initialize(this.props);
+//
+// getJMXServer().register(TYPE, NAME, this);
+//
+// } catch (FailedToRegisterException e) {
+// throw new MetaMatrixRuntimeException(e.getCause());
+// } catch (MetaMatrixCoreException e) {
+// throw new MetaMatrixRuntimeException(e);
+// }
+// }
+//
+// private void stopS(boolean restart) {
+// if (isAlive()) {
+// shutdown(restart);
+// }
+//
+// try {
+// getJMXServer().unregister(TYPE, NAME);
+// } catch (FailedToRegisterException e) {
+// // ignore
+// }
+// }
private static boolean duplicateProcess(Properties props) {
try {
@@ -128,12 +117,12 @@
@Override
public void shutdown() {
- new Thread(){
- public void run(){
- System.out.println("Server being shutdown..."); //$NON-NLS-1$
- stopS(false);
- }
- }.start();
+// new Thread(){
+// public void run(){
+// System.out.println("Server being shutdown..."); //$NON-NLS-1$
+// stopS(false);
+// }
+// }.start();
}
@Override
@@ -148,12 +137,12 @@
@Override
public void restart() {
- new Thread(){
- public void run(){
- System.out.println("Server being shutdown..."); //$NON-NLS-1$
- stopS(true);
- }
- }.start();
+// new Thread(){
+// public void run(){
+// System.out.println("Server being shutdown..."); //$NON-NLS-1$
+// stopS(true);
+// }
+// }.start();
}
/**
@@ -180,7 +169,7 @@
// load the server
Server s = new Server(props);
- s.start();
+ //s.start();
String port = props.getProperty(DQPEmbeddedProperties.SERVER_PORT);
long time = System.currentTimeMillis() - startTime;
@@ -202,7 +191,7 @@
// if for some reason engine is still alive kill it.
if (s.isAlive()) {
- s.stopS(false);
+ //s.stopS(false);
}
// exit code to restart the process.
Modified: branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/runtime/src/main/java/org/teiid/ServerMBean.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -21,11 +21,10 @@
*/
package org.teiid;
-import com.metamatrix.common.util.JMXUtil;
public interface ServerMBean {
public static final String NAME = "Server"; //$NON-NLS-1$
- public static final JMXUtil.MBeanType TYPE = JMXUtil.MBeanType.SERVER;
+ //public static final JMXUtil.MBeanType TYPE = JMXUtil.MBeanType.SERVER;
boolean isAlive();
Modified: branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/runtime/src/main/java/org/teiid/Shutdown.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -2,7 +2,6 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.Properties;
@@ -12,9 +11,6 @@
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
-import com.metamatrix.common.util.JMXUtil;
-import com.metamatrix.dqp.embedded.DQPEmbeddedProperties;
-
public class Shutdown {
public static void main(String[] args) throws Exception {
@@ -25,17 +21,17 @@
Properties props = Server.loadConfiguration(args[0]);
- JMXUtil jmx = new JMXUtil(props.getProperty(DQPEmbeddedProperties.PROCESSNAME));
+// JMXUtil jmx = new JMXUtil(props.getProperty(DQPEmbeddedProperties.PROCESSNAME));
JMXServiceURL serviceURL = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:"+args[1]+"/jmxrmi"); //$NON-NLS-1$ //$NON-NLS-2$
JMXConnector connector = JMXConnectorFactory.connect(serviceURL);
MBeanServerConnection mbsc = connector.getMBeanServerConnection();
- ServerProxyHandler handler = new ServerProxyHandler(mbsc, jmx.buildName(ServerMBean.TYPE, ServerMBean.NAME));
- Class<?>[] ifaces = { ServerMBean.class };
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- ServerMBean server = (ServerMBean) Proxy.newProxyInstance(tcl, ifaces,handler);
- server.shutdown();
+// ServerProxyHandler handler = new ServerProxyHandler(mbsc, jmx.buildName(ServerMBean.TYPE, ServerMBean.NAME));
+// Class<?>[] ifaces = { ServerMBean.class };
+// ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+// ServerMBean server = (ServerMBean) Proxy.newProxyInstance(tcl, ifaces,handler);
+// server.shutdown();
}
/**
Added: branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java
===================================================================
--- branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java (rev 0)
+++ branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,46 @@
+/*
+ * 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.util.ArrayList;
+import java.util.Collection;
+
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.ProcessObject;
+import org.teiid.adminapi.TeiidAdmin;
+
+import com.metamatrix.jdbc.EmbeddedConnectionFactoryImpl;
+
+public abstract class BaseAdmin extends TeiidAdmin {
+ EmbeddedConnectionFactoryImpl manager;
+
+ public void setManager(EmbeddedConnectionFactoryImpl manager) {
+ this.manager = manager;
+ }
+
+ @Override
+ public Collection<ProcessObject> getProcesses(String processIdentifier) throws AdminException {
+ ArrayList<ProcessObject> list = new ArrayList<ProcessObject>();
+ list.add(manager.getProcess());
+ return list;
+ }
+}
Property changes on: branches/JCA/runtime/src/main/java/org/teiid/adminapi/impl/BaseAdmin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java
===================================================================
--- branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/TestEmbeddedConfigSource.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -38,7 +38,6 @@
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.metamatrix.common.protocol.URLHelper;
-import com.metamatrix.common.util.JMXUtil;
import com.metamatrix.core.util.UnitTestUtil;
import com.metamatrix.dqp.service.ConfigurationService;
import com.metamatrix.dqp.service.FakeAbstractService;
@@ -64,7 +63,7 @@
TeiidResourceAdapter ra = Mockito.mock(TeiidResourceAdapter.class);
Mockito.stub(ra.getWorkManager()).toReturn(new FakeWorkManager());
Mockito.stub(ra.getXATerminator()).toReturn(Mockito.mock(XATerminator.class));
- EmbeddedGuiceModule source = new EmbeddedGuiceModule(url, p, new JMXUtil("test"), InetAddress.getLocalHost(), ra); //$NON-NLS-1$
+ EmbeddedGuiceModule source = new EmbeddedGuiceModule(url, p, InetAddress.getLocalHost(), ra); //$NON-NLS-1$
Injector injector = Guice.createInjector(source);
source.setInjector(injector);
Copied: branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java (from rev 1544, branches/JCA/jboss-integration/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java)
===================================================================
--- branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java (rev 0)
+++ branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java 2009-11-17 13:31:34 UTC (rev 1569)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.dqp.embedded.admin;
+
+import junit.framework.TestCase;
+
+
+/**
+ * @since 4.3
+ */
+public class TestBaseAdmin extends TestCase {
+
+ public void testRegexStuff() {
+ assertTrue("RegEx Failed", "one".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one two".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one two three ".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one9_two_Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one9_two*Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "#one9_two Three".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("RegEx Failed", "one".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one ".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one*".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one two".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one_TWO_three".matches(BaseAdmin.SINGLE_WORD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("RegEx Failed", "one*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one two *".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "*one two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "#two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one.*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one.two".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one.two*".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ assertTrue("RegEx Failed", "*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one_TWO_three*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "*one".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "* one".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "*.*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one.*".matches(BaseAdmin.SINGLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ assertTrue("RegEx Failed", "*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one.two".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "*.one".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one_two *".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one.two*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one.two*.three*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one.two**".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one.two.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "one*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "one.".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "0.10.*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "0.10..*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "0.10..".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", ".one*".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", ".one_two".matches(BaseAdmin.WORD_AND_DOT_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("RegEx Failed", "One".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "One.1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "*.1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "One.One".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "One*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "One*.101".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "*.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "100.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", ".1".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ //assertTrue("RegEx Failed", "V0.*".matches(BaseAdmin.VDB_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertTrue("RegEx Failed", "XML-Relational File Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertTrue("RegEx Failed", "XML Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ assertFalse("RegEx Failed", "XML&Relational Connector".matches(BaseAdmin.MULTIPLE_WORDS_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ //assertTrue("RegEx Failed", "".matches(BaseAdmin.MULTIPLE_WORD_WILDCARD_REGEX)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+}
Property changes on: branches/JCA/runtime/src/test/java/com/metamatrix/dqp/embedded/admin/TestBaseAdmin.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: branches/JCA/test-integration/db/src/main/resources/ddl/derby/create_tables.sql
===================================================================
--- branches/JCA/test-integration/db/src/main/resources/ddl/derby/create_tables.sql 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/test-integration/db/src/main/resources/ddl/derby/create_tables.sql 2009-11-17 13:31:34 UTC (rev 1569)
@@ -2,12 +2,12 @@
-- these tables are used by custom junit test for testing transactions
create Table g1 (
- e1 NUMERIC(5),
+ e1 INTEGER,
e2 varchar(50),
PRIMARY KEY (e1)
);
create Table g2 (
- e1 NUMERIC(5) REFERENCES g1 (e1),
+ e1 INTEGER REFERENCES g1 (e1),
e2 varchar(50)
);
-
\ No newline at end of file
+
Modified: branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql
===================================================================
--- branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql 2009-11-17 13:11:25 UTC (rev 1568)
+++ branches/JCA/test-integration/db/src/main/resources/ddl/mysql/create_tables.sql 2009-11-17 13:31:34 UTC (rev 1569)
@@ -1,6 +1,6 @@
-- these tables are used by custom junit test for testing transactions
-create Table g1 (e1 NUMERIC(5) PRIMARY KEY, e2 varchar(50))ENGINE=InnoDB;
-create Table g2 (e1 NUMERIC(5), e2 varchar(50), FOREIGN KEY (e1) REFERENCES g1(e1))ENGINE=InnoDB;
-
\ No newline at end of file
+create Table g1 (e1 INT PRIMARY KEY, e2 varchar(50))ENGINE=InnoDB;
+create Table g2 (e1 INT, e2 varchar(50), FOREIGN KEY (e1) REFERENCES g1(e1))ENGINE=InnoDB;
+
15 years, 1 month
teiid SVN: r1568 - branches/JCA/build/assembly/jboss-container.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2009-11-17 08:11:25 -0500 (Tue, 17 Nov 2009)
New Revision: 1568
Modified:
branches/JCA/build/assembly/jboss-container/dependencies.xml
Log:
TEIID-833: Adding basic framework for adding the admin api.
Modified: branches/JCA/build/assembly/jboss-container/dependencies.xml
===================================================================
--- branches/JCA/build/assembly/jboss-container/dependencies.xml 2009-11-16 22:03:56 UTC (rev 1567)
+++ branches/JCA/build/assembly/jboss-container/dependencies.xml 2009-11-17 13:11:25 UTC (rev 1568)
@@ -23,6 +23,7 @@
<include>org.jboss.teiid:teiid-runtime</include>
<include>org.jboss.teiid:teiid-engine</include>
<include>org.jboss.teiid:teiid-metadata</include>
+ <include>org.jboss.teiid:jboss-integration</include>
</includes>
<binaries>
15 years, 1 month
teiid SVN: r1567 - in trunk/test-integration/db/src/main/java/org/teiid/test/framework: query and 1 other directories.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 17:03:56 -0500 (Mon, 16 Nov 2009)
New Revision: 1567
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
Log:
Teiid 773 - renamed interface so that it would collide with the tests that are suppose to run
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-11-16 21:08:22 UTC (rev 1566)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2009-11-16 22:03:56 UTC (rev 1567)
@@ -48,13 +48,13 @@
this.getConnectionStrategy().getEnvironment().setProperty(key, value);
}
- protected void before(TransactionQueryTest test) {
+ protected void before(TransactionQueryTestCase test) {
}
- protected void after(TransactionQueryTest test) {
+ protected void after(TransactionQueryTestCase test) {
}
- public void runTransaction(TransactionQueryTest test) {
+ public void runTransaction(TransactionQueryTestCase test) {
this.testClassName = StringUtil.getLastToken(test.getClass().getName(),
".");
@@ -94,7 +94,7 @@
}
- protected void runTest(TransactionQueryTest test) {
+ protected void runTest(TransactionQueryTestCase test) {
debug("Start runTest: " + test.getTestName());
try {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-11-16 21:08:22 UTC (rev 1566)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/AbstractQueryTransactionTest.java 2009-11-16 22:03:56 UTC (rev 1567)
@@ -12,7 +12,7 @@
import javax.sql.XAConnection;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
import org.teiid.test.framework.connection.ConnectionStrategy;
import org.teiid.test.framework.datasource.DataStore;
@@ -22,7 +22,7 @@
/**
* The AbstractQueryTransactionTest is the base implementation for the
- * {@link TransactionQueryTest}. This provides the default logic for perform a testcase.
+ * {@link TransactionQueryTestCase}. This provides the default logic for perform a testcase.
* The only method to implement in order to perform a basic, single datasource, test
* is the {@link #testCase()} method.
*
@@ -43,7 +43,7 @@
*
*/
public abstract class AbstractQueryTransactionTest extends com.metamatrix.jdbc.api.AbstractQueryTest
- implements TransactionQueryTest {
+ implements TransactionQueryTestCase {
private static boolean initialized = false;
@@ -97,7 +97,8 @@
CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP,
txnautowrap);
- this.print("TransactionAutoWrap = " + txnautowrap);
+
+// this.print("TransactionAutoWrap = " + txnautowrap);
}
String fetchSizeStr = executionProperties
@@ -239,7 +240,7 @@
* At end of each test, perform any cleanup that your test requires. Note:
* Do not cleanup any connections by calling {@link ConnectionStrategy#shutdown()}.
* That is performed by the
- * {@link TransactionContainer#runTransaction(TransactionQueryTest)} at the
+ * {@link TransactionContainer#runTransaction(TransactionQueryTestCase)} at the
* end of the test.
*/
public void cleanup() {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java 2009-11-16 21:08:22 UTC (rev 1566)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/query/QueryExecution.java 2009-11-16 22:03:56 UTC (rev 1567)
@@ -13,9 +13,10 @@
*
*/
public class QueryExecution extends AbstractQueryTest {
-
+
public QueryExecution(Connection conn) {
super(conn);
}
+
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java 2009-11-16 21:08:22 UTC (rev 1566)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/JNDITransaction.java 2009-11-16 22:03:56 UTC (rev 1567)
@@ -7,9 +7,8 @@
import javax.naming.InitialContext;
import javax.transaction.UserTransaction;
-import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -19,11 +18,12 @@
public class JNDITransaction extends TransactionContainer {
UserTransaction userTxn = null;
-// public JNDITransaction(ConfigPropertyLoader config) {
-// super(config);
-// }
- protected void before(TransactionQueryTest test) {
+ public JNDITransaction() {
+ super();
+ }
+
+ protected void before(TransactionQueryTestCase test) {
if (this.props.getProperty(CONNECTION_STRATEGY_PROPS.JNDINAME_USERTXN) == null) {
throw new TransactionRuntimeException("No JNDI name found for the User Transaction to look up in application server");
}
@@ -39,7 +39,7 @@
}
}
- protected void after(TransactionQueryTest test) {
+ protected void after(TransactionQueryTestCase test) {
try {
if (this.userTxn != null) {
if (test.rollbackAllways()|| test.exceptionOccurred()) {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java 2009-11-16 21:08:22 UTC (rev 1566)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/LocalTransaction.java 2009-11-16 22:03:56 UTC (rev 1567)
@@ -9,7 +9,7 @@
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -23,7 +23,7 @@
public LocalTransaction() {
super();
}
- protected void before(TransactionQueryTest test) {
+ protected void before(TransactionQueryTestCase test) {
this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
try {
@@ -34,7 +34,7 @@
}
}
- protected void after(TransactionQueryTest test) {
+ protected void after(TransactionQueryTestCase test) {
boolean exception = false;
try {
if (test.rollbackAllways()|| test.exceptionOccurred()) {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java 2009-11-16 21:08:22 UTC (rev 1566)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OffWrapTransaction.java 2009-11-16 22:03:56 UTC (rev 1567)
@@ -6,7 +6,7 @@
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
@@ -23,13 +23,13 @@
super();
}
- public void before(TransactionQueryTest test) {
+ public void before(TransactionQueryTestCase test) {
this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OFF);
}
- public void after(TransactionQueryTest test) {
+ public void after(TransactionQueryTestCase test) {
}
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java 2009-11-16 21:08:22 UTC (rev 1566)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OnWrapTransaction.java 2009-11-16 22:03:56 UTC (rev 1567)
@@ -6,7 +6,7 @@
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
@@ -21,13 +21,13 @@
super();
}
- public void before(TransactionQueryTest test) {
+ public void before(TransactionQueryTestCase test) {
this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_ON);
}
- public void after(TransactionQueryTest test) {
+ public void after(TransactionQueryTestCase test) {
}
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java 2009-11-16 21:08:22 UTC (rev 1566)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java 2009-11-16 22:03:56 UTC (rev 1567)
@@ -6,7 +6,7 @@
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
@@ -21,12 +21,12 @@
super();
}
- public void before(TransactionQueryTest test) {
+ public void before(TransactionQueryTestCase test) {
this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OPTIMISTIC);
}
- public void after(TransactionQueryTest test) {
+ public void after(TransactionQueryTestCase test) {
}
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java 2009-11-16 21:08:22 UTC (rev 1566)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java 2009-11-16 22:03:56 UTC (rev 1567)
@@ -6,7 +6,7 @@
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
@@ -21,12 +21,12 @@
super();
}
- public void before(TransactionQueryTest test) {
+ public void before(TransactionQueryTestCase test) {
this.setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP, TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_PESSIMISTIC);
}
- public void after(TransactionQueryTest test) {
+ public void after(TransactionQueryTestCase test) {
}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java 2009-11-16 21:08:22 UTC (rev 1566)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/XATransaction.java 2009-11-16 22:03:56 UTC (rev 1567)
@@ -11,7 +11,7 @@
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTest;
+import org.teiid.test.framework.TransactionQueryTestCase;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
@@ -25,7 +25,7 @@
super();
}
- protected void before(TransactionQueryTest test) {
+ protected void before(TransactionQueryTestCase test) {
try {
xid = createXid();
XAResource xaResource = getXAConnection().getXAResource();
@@ -46,7 +46,7 @@
return new MMXid(0, gid, bid);
}
- protected void after(TransactionQueryTest test) {
+ protected void after(TransactionQueryTestCase test) {
boolean delistSuccessful = false;
boolean commit = false;
15 years, 1 month
teiid SVN: r1566 - trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection.
by teiid-commits@lists.jboss.org
Author: vhalbert(a)redhat.com
Date: 2009-11-16 16:08:22 -0500 (Mon, 16 Nov 2009)
New Revision: 1566
Removed:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
Log:
Teiid 773 - refactored back in the way jbedsp transaction classes where defined
Deleted: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java 2009-11-16 21:07:42 UTC (rev 1565)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionUtil.java 2009-11-16 21:08:22 UTC (rev 1566)
@@ -1,54 +0,0 @@
-package org.teiid.test.framework.connection;
-
-import java.sql.Connection;
-import java.util.Map;
-
-import javax.sql.XAConnection;
-
-import org.teiid.test.framework.datasource.DataSource;
-import org.teiid.test.framework.exception.QueryTestFailedException;
-import org.teiid.test.framework.exception.TransactionRuntimeException;
-
-// identifier should be the model name that is identfied in the config properties
-public class ConnectionUtil {
- public static final Connection getConnection(String identifier, Map<String, DataSource> datasources, ConnectionStrategy connstrategy) throws QueryTestFailedException {
- DataSource ds = null;
- if (identifier != null) {
- ds = datasources.get(identifier);
- if (ds == null) {
- throw new TransactionRuntimeException("DataSource is not mapped to Identifier "
- + identifier);
- }
-
- }
-
- Connection conn = connstrategy.createDriverStrategy(identifier,
- ds.getProperties()).getConnection();
- // force autocommit back to true, just in case the last user didnt
- try {
- conn.setAutoCommit(true);
- } catch (Exception sqle) {
- throw new QueryTestFailedException(sqle);
- }
-
- return conn;
-
- }
-
- public static final XAConnection getXAConnection(String identifier, Map<String, DataSource> datasources, ConnectionStrategy connstrategy) throws QueryTestFailedException {
- DataSource ds = null;
- if (identifier != null) {
- ds = datasources.get(identifier);
- if (ds == null) {
- throw new TransactionRuntimeException("DataSource is not mapped to Identifier "
- + identifier);
- }
-
- }
-
- return connstrategy.createDataSourceStrategy(
- identifier, ds.getProperties()).getXAConnection();
-
- }
-
-}
15 years, 1 month