@Override public DatabaseRelationDefinition getDatabaseRelation(RelationID id) { DatabaseRelationDefinition def = tables.get(id); if (def == null && id.hasSchema()) { def = tables.get(id.getSchemalessID()); } return def; }
@Override public RelationDefinition getRelation(RelationID name) { RelationDefinition def = relations.get(name); if (def == null && name.hasSchema()) { def = relations.get(name.getSchemalessID()); } return def; }
@Override public DatabaseRelationDefinition getDatabaseRelation(RelationID id) { DatabaseRelationDefinition def = tables.get(id); if (def == null && id.hasSchema()) { def = tables.get(id.getSchemalessID()); } return def; }
@Override public RelationDefinition getRelation(RelationID name) { RelationDefinition def = relations.get(name); if (def == null && name.hasSchema()) { def = relations.get(name.getSchemalessID()); } return def; }
/** * Retrieve the normalized list of tables from a given list of RelationIDs */ private static List<RelationID> getTableList(String defaultTableSchema, Set<RelationID> realTables, QuotedIDFactory idfac) throws SQLException { List<RelationID> fks = new LinkedList<>(); for (RelationID table : realTables) { // defaultTableSchema is non-empty only for Oracle and DUAL is a special Oracle table if (table.hasSchema() || (defaultTableSchema == null) || table.getTableName().equals("DUAL")) fks.add(table); else { RelationID qualifiedTableId = idfac.createRelationID(defaultTableSchema, table.getTableNameSQLRendering()); fks.add(qualifiedTableId); } } return fks; }
/** * Retrieve the normalized list of tables from a given list of RelationIDs */ private static List<RelationID> getTableList(String defaultTableSchema, Set<RelationID> realTables, QuotedIDFactory idfac) throws SQLException { List<RelationID> fks = new LinkedList<>(); for (RelationID table : realTables) { // defaultTableSchema is non-empty only for Oracle and DUAL is a special Oracle table if (table.hasSchema() || (defaultTableSchema == null) || table.getTableName().equals("DUAL")) fks.add(table); else { RelationID qualifiedTableId = idfac.createRelationID(defaultTableSchema, table.getTableNameSQLRendering()); fks.add(qualifiedTableId); } } return fks; }
/** * Inserts a new data definition to this metadata object. * * @param td * The data definition. It can be a {@link DatabaseRelationDefinition} or a * {@link ParserViewDefinition} object. */ protected <T extends RelationDefinition> void add(T td, Map<RelationID, T> schema) { if (!isStillMutable) { throw new IllegalStateException("Too late, cannot add a schema"); } schema.put(td.getID(), td); if (td.getID().hasSchema()) { RelationID noSchemaID = td.getID().getSchemalessID(); if (!schema.containsKey(noSchemaID)) { schema.put(noSchemaID, td); } else { LOGGER.warn("DUPLICATE TABLE NAMES, USE QUALIFIED NAMES:\n" + td + "\nAND\n" + schema.get(noSchemaID)); //schema.remove(noSchemaID); // TODO (ROMAN 8 Oct 2015): think of a better way of resolving ambiguities } } }
/** * Inserts a new data definition to this metadata object. * * @param td * The data definition. It can be a {@link DatabaseRelationDefinition} or a * {@link ParserViewDefinition} object. */ protected <T extends RelationDefinition> void add(T td, Map<RelationID, T> schema) { if (!isStillMutable) { throw new IllegalStateException("Too late, cannot add a schema"); } schema.put(td.getID(), td); if (td.getID().hasSchema()) { RelationID noSchemaID = td.getID().getSchemalessID(); if (!schema.containsKey(noSchemaID)) { schema.put(noSchemaID, td); } else { LOGGER.warn("DUPLICATE TABLE NAMES, USE QUALIFIED NAMES:\n" + td + "\nAND\n" + schema.get(noSchemaID)); //schema.remove(noSchemaID); // TODO (ROMAN 8 Oct 2015): think of a better way of resolving ambiguities } } }