Revision: 3357
Author: [email protected]
Date: Thu Mar 4 15:28:57 2010
Log: Removed the getChildByName method that only took the name and not the
class type. This should fix up bugs that got a child
with the correct name but the wrong type. The old behaviour is still
possible if you pass SQLObject as the class but
code doing so should be aware and check the object returned is of the
correct type.
http://code.google.com/p/power-architect/source/detail?r=3357
Modified:
/trunk/regress/ca/sqlpower/architect/swingui/TestDBTree.java
/trunk/regress/ca/sqlpower/architect/swingui/TestSwingUIProject.java
/trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java
/trunk/src/ca/sqlpower/architect/swingui/ASUtils.java
=======================================
--- /trunk/regress/ca/sqlpower/architect/swingui/TestDBTree.java Mon Dec 21
08:27:43 2009
+++ /trunk/regress/ca/sqlpower/architect/swingui/TestDBTree.java Thu Mar 4
15:28:57 2010
@@ -198,8 +198,8 @@
//The SQLDatabase representing the SPDataSource
SQLDatabase db = (SQLDatabase)
dbTree.getModel().getChild(dbTree.getModel().getRoot(), 2);
db.populate();
- SQLObject schema = db.getChildByName("PUBLIC");
- SQLObject table = schema.getChildByName("TEST1");
+ SQLObject schema = db.getChildByName("PUBLIC", SQLSchema.class);
+ SQLObject table = schema.getChildByName("TEST1", SQLTable.class);
assertNotNull(table);
TreePath path = new TreePath(new
Object[]{dbTree.getModel().getRoot(), db, schema, table});
dbTree.setSelectionPath(path);
@@ -226,8 +226,8 @@
//The SQLDatabase representing the SPDataSource
SQLDatabase db = (SQLDatabase)
dbTree.getModel().getChild(dbTree.getModel().getRoot(), 2);
db.populate();
- SQLObject schema = db.getChildByNameIgnoreCase("PUBLIC");
- SQLTable table = (SQLTable)
schema.getChildByNameIgnoreCase("TEST2");
+ SQLObject schema = db.getChildByNameIgnoreCase("PUBLIC",
SQLSchema.class);
+ SQLTable table = schema.getChildByNameIgnoreCase("TEST2",
SQLTable.class);
SQLObject col1 = table.getColumnByName("COL1");
SQLObject col2 = table.getColumnByName("COL2");
assertNotNull(col1);
@@ -263,11 +263,11 @@
//The SQLDatabase representing the SPDataSource
SQLDatabase db = (SQLDatabase)
dbTree.getModel().getChild(dbTree.getModel().getRoot(), 2);
db.populate();
- SQLObject schema = db.getChildByNameIgnoreCase("PUBLIC");
- SQLTable table = (SQLTable)
schema.getChildByNameIgnoreCase("TEST3");
+ SQLSchema schema = db.getChildByNameIgnoreCase("PUBLIC",
SQLSchema.class);
+ SQLTable table = schema.getChildByNameIgnoreCase("TEST3",
SQLTable.class);
SQLObject col1 = table.getColumnByName("COL1");
SQLObject col2 = table.getColumnByName("COL2");
- SQLObject table2 = schema.getChildByNameIgnoreCase("test4");
+ SQLTable table2 = schema.getChildByNameIgnoreCase("test4",
SQLTable.class);
assertNotNull(col1);
assertNotNull(col2);
TreePath tablePath = new TreePath(new
Object[]{dbTree.getModel().getRoot(), db, schema, table2});
=======================================
--- /trunk/regress/ca/sqlpower/architect/swingui/TestSwingUIProject.java
Thu Mar 4 08:08:10 2010
+++ /trunk/regress/ca/sqlpower/architect/swingui/TestSwingUIProject.java
Thu Mar 4 15:28:57 2010
@@ -272,7 +272,7 @@
SQLDatabase target = session.getTargetDatabase();
- SQLTable t1 = (SQLTable) target.getChildByName("mm_project");
+ SQLTable t1 = target.getChildByName("mm_project", SQLTable.class);
assertEquals(1, t1.getPkSize());
assertEquals(t1.getPrimaryKeyIndex().getChild(0).getColumn(),
t1.getColumn(0));
assertTrue(t1.getColumn(0).isPrimaryKey());
@@ -807,7 +807,7 @@
// grab the second database in the dbtree's model (the first is
the play pen)
ppdb = (SQLDatabase) session2.getTargetDatabase();
- index = (SQLIndex) ((SQLTable)
ppdb.getTableByName(tableName)).getChildByName(index.getName());
+ index = ((SQLTable)
ppdb.getTableByName(tableName)).getChildByName(index.getName(),
SQLIndex.class);
Map<String, Object> newDescription =
ca.sqlpower.testutil.TestUtils.getAllInterestingProperties(index,
propertiesToIgnore);
@@ -1107,7 +1107,7 @@
SQLDatabase db = new SQLDatabase(ds);
dbtreeRoot.addChild(db);
- SQLSchema mooSchema = (SQLSchema) db.getChildByName("moo_schema");
+ SQLSchema mooSchema = db.getChildByName("moo_schema",
SQLSchema.class);
// we were only running into this bug on schemas that are already
populated
// so this step is the key to waking up the bug!
=======================================
--- /trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java Thu Jul 2 16:31:05
2009
+++ /trunk/src/ca/sqlpower/architect/olap/OLAPUtil.java Thu Mar 4 15:28:57
2010
@@ -395,7 +395,7 @@
String qualifier = table.getSchema();
String name = table.getName();
if (qualifier == null || qualifier.length() == 0) {
- return (SQLTable) database.getChildByName(name);
+ return database.getChildByName(name, SQLTable.class);
} else if (qualifier.contains(".")) {
String cat = qualifier.substring(0, qualifier.indexOf('.'));
String schema = qualifier.substring(qualifier.indexOf('.') +
1);
=======================================
--- /trunk/src/ca/sqlpower/architect/swingui/ASUtils.java Mon Feb 8
14:34:01 2010
+++ /trunk/src/ca/sqlpower/architect/swingui/ASUtils.java Thu Mar 4
15:28:57 2010
@@ -632,7 +632,7 @@
for (int i = 2; i < ancestors.size(); i++) {
SQLObject ancestor = ancestors.get(i);
System.out.println("Child " + child + " ancestor " +
ancestor);
- child = child.getChildByName(ancestor.getName());
+ child = child.getChildByName(ancestor.getName(),
ancestor.getClass());
}
column.setSourceColumn((SQLColumn) child);