Skip to content

Commit

Permalink
TEIID-5473 adding javadocs and a similar method for foreign keys
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Sep 18, 2018
1 parent 32f5bc1 commit ad327c5
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private Map<String, TableInfo> getTables(MetadataFactory metadataFactory,
}
TableInfo ti = new TableInfo(tableCatalog, tableSchema, tableName, table);
ti.type = tables.getString(4);
table.setProperty(TYPE, ti.type); //$NON-NLS-1$
table.setProperty(TYPE, ti.type);
tableMap.put(fullName, ti);
tableMap.put(tableName, ti);
}
Expand Down Expand Up @@ -642,6 +642,9 @@ private void getForeignKeys(MetadataFactory metadataFactory,
DatabaseMetaData metadata, Collection<TableInfo> tables, Map<String, TableInfo> tableMap) throws SQLException {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, "JDBCMetadataProcessor - Importing foreign keys"); //$NON-NLS-1$
for (TableInfo tableInfo : tables) {
if (!getForeignKeysForTable(tableInfo.catalog, tableInfo.schema, tableInfo.name, tableInfo.type)) {
continue;
}
ResultSet fks = null;
try {
fks = metadata.getImportedKeys(tableInfo.catalog, tableInfo.schema, tableInfo.name);
Expand Down Expand Up @@ -709,7 +712,20 @@ private void getForeignKeys(MetadataFactory metadataFactory,
}
}

private KeyRecord autoCreateUniqueKeys(boolean create, MetadataFactory factory, String name, TreeMap<Short, String> referencedKeyColumns, Table pkTable) {
/**
* Override to control or disable the default foreign key logic
* @param catalogName
* @param schemaName
* @param tableName
* @param tableType
* @return true if the default logic should still be used, or false if the default foreign key logic should not run
*/
private boolean getForeignKeysForTable(String catalogName, String schemaName,
String tableName, String tableType) {
return true;
}

private KeyRecord autoCreateUniqueKeys(boolean create, MetadataFactory factory, String name, TreeMap<Short, String> referencedKeyColumns, Table pkTable) {
if (referencedKeyColumns != null && pkTable.getPrimaryKey() == null && pkTable.getUniqueKeys().isEmpty()) {
factory.addIndex(name + "_unique", false, new ArrayList<String>(referencedKeyColumns.values()), pkTable); //$NON-NLS-1$
}
Expand Down Expand Up @@ -878,13 +894,14 @@ protected String getSequenceNextSQL(String fullyQualifiedName) {
}

/**
* Override to control or disable the default index logic
* @param catalogName
* @param schemaName
* @param tableName
* @param uniqueOnly
* @param approximateIndexes
* @param tableType
* @return
* @return true if the default logic should still be used, or false if the default index logic should not run
*/
protected boolean getIndexInfoForTable(String catalogName, String schemaName, String tableName, boolean uniqueOnly,
boolean approximateIndexes, String tableType) {
Expand Down

0 comments on commit ad327c5

Please sign in to comment.