/** * Creates a new {@link TableAliasManager} instance. */ public TableAliasManager() { rootTableAlias = generateNew(); }
private void followJoins( List<TableJoin> joinedTables ) { if ( joinedTables != null ) { for ( TableJoin joinedTable : joinedTables ) { String fromTable = currentTable; String fromTableAlias = currentTableAlias; String toTable = joinedTable.getToTable().toString(); String toTableAlias = aliasManager.generateNew(); List<String> fromColumns = new ArrayList<String>( joinedTable.getFromColumns().size() ); for ( SQLIdentifier fromColumn : joinedTable.getFromColumns() ) { fromColumns.add( fromColumn.toString() ); } List<String> toColumns = new ArrayList<String>( joinedTable.getToColumns().size() ); for ( SQLIdentifier toColumn : joinedTable.getToColumns() ) { toColumns.add( toColumn.toString() ); } Join appliedJoin = new Join( fromTable, fromTableAlias, fromColumns, toTable, toTableAlias, toColumns ); joins.add( appliedJoin ); currentTable = toTable; currentTableAlias = toTableAlias; } } } }
private void map( FeatureMapping mapping, List<MappableStep> remaining ) throws UnmappableException { // followJoins( mapping.getJoinedTable() ); if ( remaining.size() < 2 ) { throw new UnmappableException( "Not enough steps." ); } MappableStep ftStep = remaining.get( 0 ); if ( !( ftStep instanceof ElementStep ) ) { throw new UnmappableException( "Must provide a feature type name." ); } QName ftName = ( (ElementStep) ftStep ).getNodeName(); FeatureTypeMapping ftMapping = schema.getFtMapping( ftName ); if ( ftMapping == null ) { throw new UnmappableException( "Feature type '" + ftName + " is not mapped to a table." ); } String fromTable = currentTable; String fromTableAlias = currentTableAlias; // TODO what do do with Href mappings here? Needs proper reference resolving code for mapping here... String fromColumn = mapping.getJoinedTable().get( 0 ).getFromColumns().get( 0 ).toString(); String toTable = ftMapping.getFtTable().toString(); String toTableAlias = aliasManager.generateNew(); String toColumn = ftMapping.getFidMapping().getColumn(); Join appliedJoin = new Join( fromTable, fromTableAlias, Collections.singletonList( fromColumn ), toTable, toTableAlias, Collections.singletonList( toColumn ) ); joins.add( appliedJoin ); currentTable = toTable; currentTableAlias = toTableAlias; map( ftMapping.getMappings(), remaining.subList( 1, remaining.size() ) ); }
String fromColumn = id; String toTable = tableColumn.first.first; String toTableAlias = aliasManager.generateNew(); String toColumn = fk_main; joins.add( new Join( fromTable, fromTableAlias, fromColumn, toTable, toTableAlias, toColumn ) );