throw new IllegalArgumentException("node '" + node + "' should be a String, not a "
+ node.getClass().getName());
}
String tableName = (String) node;
QualifiedTableName qualifiedTableName = new QualifiedTableName(tableName, schema);
schema = qualifiedTableName.getSchema();
tableName = qualifiedTableName.getTable();
ResultSet rs = null;
try {
IMetadataHandler metadataHandler = (IMetadataHandler)
this.connection.getConfig().getProperty(DatabaseConfig.PROPERTY_METADATA_HANDLER);
// Validate if the table exists
if(!metadataHandler.tableExists(metaData, schema, tableName))
{
throw new NoSuchTableException("The table '"+tableName+"' does not exist in schema '"+schema+"'");
}
switch (type) {
case IMPORT:
rs = metaData.getImportedKeys(null, schema, tableName);
break;
case EXPORT:
rs = metaData.getExportedKeys(null, schema, tableName);
break;
}
DatabaseConfig dbConfig = this.connection.getConfig();
while (rs.next()) {
int index = TABLENAME_INDEXES[type];
int schemaindex = SCHEMANAME_INDEXES[type];
String dependentTableName = rs.getString(index);
String dependentSchemaName = rs.getString(schemaindex);
String pkColumn = rs.getString( PK_INDEXES[type] );
String fkColumn = rs.getString( FK_INDEXES[type] );
// set the schema in front if there is none ("SCHEMA.TABLE") - depending on the "qualified table names" feature
tableName = new QualifiedTableName(tableName, schema).getQualifiedNameIfEnabled(dbConfig);
dependentTableName = new QualifiedTableName(dependentTableName, dependentSchemaName).getQualifiedNameIfEnabled(dbConfig);
IEdge edge = newEdge(rs, type, tableName, dependentTableName, fkColumn, pkColumn );
if ( logger.isDebugEnabled() ) {
logger.debug("Adding edge " + edge);
}