@Override public int compareTo(Identifier o) { return getCanonicalName().compareTo( o.getCanonicalName() ); } }
@Override public boolean equals(Object o) { if ( !(o instanceof Identifier) ) { return false; } final Identifier that = (Identifier) o; return getCanonicalName().equals( that.getCanonicalName() ); }
@Override public int compare(Identifier o1, Identifier o2) { return o1.getCanonicalName().compareTo( o2.getCanonicalName() ); } }
@Override public int compare(Identifier o1, Identifier o2) { return o1.getCanonicalName().compareTo( o2.getCanonicalName() ); } }
public Column getColumn(Identifier name) { if ( name == null ) { return null; } return (Column) columns.get( name.getCanonicalName() ); }
public Join locateJoin(Identifier tableName) { if ( tableName == null ) { return null; } Join join = null; if ( secondaryTableJoinMap != null ) { join = secondaryTableJoinMap.get( tableName.getCanonicalName() ); } if ( join != null ) { return join; } if ( superEntityTableXref != null ) { return superEntityTableXref.locateJoin( tableName ); } return null; } }
secondaryTableJoinMap.put( logicalName.getCanonicalName(), secondaryTableJoin ); final Join existing = secondaryTableJoinMap.put( logicalName.getCanonicalName(), secondaryTableJoin );
final String catalogName = catalog == null ? "" : catalog.getCanonicalName(); final String schemaName = schema == null ? "" : schema.getCanonicalName();
@Override public Table resolveTable(Identifier tableName) { if ( tableName == null ) { return primaryTable; } if ( Identifier.areEqual( primaryTableLogicalName, tableName ) ) { return primaryTable; } Join secondaryTableJoin = null; if ( secondaryTableJoinMap != null ) { //secondaryTableJoin = secondaryTableJoinMap.get( tableName ); secondaryTableJoin = secondaryTableJoinMap.get( tableName.getCanonicalName() ); } if ( secondaryTableJoin != null ) { return secondaryTableJoin.getTable(); } if ( superEntityTableXref != null ) { return superEntityTableXref.resolveTable( tableName ); } return null; }
public void addColumn(Column column) { Column old = getColumn( column ); if ( old == null ) { if ( primaryKey != null ) { for ( Column c : primaryKey.getColumns() ) { if ( c.getCanonicalName().equals( column.getCanonicalName() ) ) { column.setNullable( false ); log.debugf( "Forcing column [%s] to be non-null as it is part of the primary key for table [%s]", column.getCanonicalName(), getNameIdentifier().getCanonicalName() ); } } } this.columns.put( column.getCanonicalName(), column ); column.uniqueInteger = this.columns.size(); } else { column.uniqueInteger = old.uniqueInteger; } }
@Override public void addSecondaryTable(QualifiedTableName logicalQualifiedTableName, Join secondaryTableJoin) { Identifier logicalName = logicalQualifiedTableName.getTableName(); if ( Identifier.areEqual( Identifier.toIdentifier( new QualifiedTableName( Identifier.toIdentifier( primaryTable.getCatalog() ), Identifier.toIdentifier( primaryTable.getSchema() ), primaryTableLogicalName ).render() ), Identifier.toIdentifier( logicalQualifiedTableName.render() ) ) ) { throw new DuplicateSecondaryTableException( logicalName ); } if ( secondaryTableJoinMap == null ) { //secondaryTableJoinMap = new HashMap<Identifier,Join>(); //secondaryTableJoinMap.put( logicalName, secondaryTableJoin ); secondaryTableJoinMap = new HashMap<>(); secondaryTableJoinMap.put( logicalName.getCanonicalName(), secondaryTableJoin ); } else { //final Join existing = secondaryTableJoinMap.put( logicalName, secondaryTableJoin ); final Join existing = secondaryTableJoinMap.put( logicalName.getCanonicalName(), secondaryTableJoin ); if ( existing != null ) { throw new DuplicateSecondaryTableException( logicalName ); } } }
protected String getTableNameForLogging(Column column) { if ( getTable() != null ) { if ( getTable().getNameIdentifier() != null ) { return getTable().getNameIdentifier().getCanonicalName(); } else { return "<unknown>"; } } else if ( column.getValue() != null && column.getValue().getTable() != null ) { return column.getValue().getTable().getNameIdentifier().getCanonicalName(); } return "<unknown>"; }
String existingReferencedTable = m.getReferencedColumnMetadata().getContainingTableInformation().getName().getTableName().getCanonicalName(); return referencingColumn.equals( existingReferencingColumn ) && referencedTable.equals( existingReferencedTable ); };
@Override public Identifier toPhysicalTableName(final Identifier name, final JdbcEnvironment jdbcEnvironment) { val propsResult = ApplicationContextProvider.getCasProperties(); if (propsResult.isEmpty()) { LOGGER.error("Could not load configuration settings. CAS application context may not have initialized correctly."); return super.toPhysicalTableName(name, jdbcEnvironment); } val tableName = name.getCanonicalName(); val casProperties = propsResult.get(); val tableNames = casProperties.getJdbc().getPhysicalTableNames(); if (tableNames.isEmpty()) { LOGGER.trace("No configured table names are defined to map [{}]", tableName); return super.toPhysicalTableName(name, jdbcEnvironment); } LOGGER.trace("Locating physical table name for [{}] based on configured table names [{}]", tableName, tableNames); if (tableNames.containsKey(tableName)) { val physicalName = tableNames.get(tableName); if (ScriptingUtils.isExternalGroovyScript(physicalName)) { LOGGER.trace("Executing script [{}] to determine physical table name for [{}]", physicalName, tableName); val scriptResource = ApplicationContextProvider.getResourceLoader().getResource(physicalName); val args = new Object[]{name, jdbcEnvironment, ApplicationContextProvider.getApplicationContext(), LOGGER}; val identifier = ScriptingUtils.executeGroovyScript(scriptResource, args, Identifier.class, true); LOGGER.trace("Determine table physical name from script [{}] to be [{}]", scriptResource, identifier); return identifier; } LOGGER.trace("Located physical table name [{}] for [{}]", physicalName, tableName); return Identifier.toIdentifier(physicalName); } return super.toPhysicalTableName(name, jdbcEnvironment); }