Skip to content

Commit

Permalink
Allow explicitly defined tables (in XML) to attempt to populate their…
Browse files Browse the repository at this point in the history
… relationships from the database's metadata.
  • Loading branch information
johncurrier committed Aug 19, 2008
1 parent ebf8a3f commit 412b7e2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/net/sourceforge/schemaspy/model/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,11 @@ public Table addRemoteTable(String remoteSchema, String remoteTableName, String
String fullName = remoteSchema + "." + remoteTableName;
Table remoteTable = remoteTables.get(fullName);
if (remoteTable == null) {
remoteTable = new RemoteTable(this, remoteSchema, remoteTableName, baseSchema, properties);
if (properties != null)
remoteTable = new RemoteTable(this, remoteSchema, remoteTableName, baseSchema, properties);
else
remoteTable = new ExplicitRemoteTable(this, remoteSchema, remoteTableName, baseSchema);

remoteTable.connectForeignKeys(tables, this, properties);
remoteTables.put(fullName, remoteTable);
}
Expand Down Expand Up @@ -574,7 +578,7 @@ private void updateFromXmlMetadata(SchemaMeta schemaMeta) throws SQLException {
if (tableMeta.getRemoteSchema() != null) {
Table table = remoteTables.get(tableMeta.getName());
if (table == null) {
table = addRemoteTable(tableMeta. getRemoteSchema(), tableMeta.getName(), getSchema(), null);
table = addRemoteTable(tableMeta.getRemoteSchema(), tableMeta.getName(), getSchema(), null);
}

table.update(tableMeta, tables, remoteTables);
Expand Down
24 changes: 24 additions & 0 deletions src/net/sourceforge/schemaspy/model/ExplicitRemoteTable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.sourceforge.schemaspy.model;

import java.sql.SQLException;
import java.util.Map;
import java.util.Properties;

/**
* A remote table (exists in another schema) that was explicitly created via XML metadata.
*
* @author John Currier
*/
public class ExplicitRemoteTable extends RemoteTable {
public ExplicitRemoteTable(Database db, String schema, String name, String baseSchema) throws SQLException {
super(db, schema, name, baseSchema, null);
}

@Override
public void connectForeignKeys(Map<String, Table> tables, Database db, Properties properties) throws SQLException {
// this probably won't work, so ignore any failures...but try anyways just in case
try {
super.connectForeignKeys(tables, db, properties);
} catch (SQLException ignore) {}
}
}

0 comments on commit 412b7e2

Please sign in to comment.