public List<LogicalTable> getUsedTables() { Set<LogicalTable> treeSet = new TreeSet<LogicalTable>(); for ( int i = 0; i < size(); i++ ) { LogicalRelationship rel = getRelationship( i ); treeSet.add( rel.getFromTable() ); treeSet.add( rel.getToTable() ); } return new ArrayList<LogicalTable>( treeSet ); } }
public boolean contains( LogicalRelationship rel ) { if ( rel == null ) { return false; } for ( int i = 0; i < size(); i++ ) { LogicalRelationship check = getRelationship( i ); LogicalTable from = check.getFromTable(); LogicalTable to = check.getToTable(); if ( ( rel.getFromTable().equals( from ) && rel.getToTable().equals( to ) ) || ( rel.getFromTable().equals( to ) && rel.getToTable().equals( from ) ) ) { return true; } } return false; }
public int score() { int score = 0; Number relSize = null; for ( int i = 0; i < size(); i++ ) { LogicalRelationship rel = getRelationship( i ); LogicalTable from = rel.getFromTable(); relSize = (Number) from.getProperty( SqlPhysicalTable.RELATIVE_SIZE ); if ( ( relSize != null ) && ( relSize.intValue() > 0 ) ) { score += relSize.intValue(); } } if ( size() > 0 ) { LogicalTable to = getLastRelationship().getToTable(); relSize = (Number) to.getProperty( SqlPhysicalTable.RELATIVE_SIZE ); if ( ( relSize != null ) && ( relSize.intValue() > 0 ) ) { score += relSize.intValue(); } } return score; }
protected static void splitOlapRelationships( LogicalModel relationalModel, LogicalModel olapModel ) { List<LogicalRelationship> relationalRelationships = new ArrayList<LogicalRelationship>(); List<LogicalRelationship> olapRelationships = new ArrayList<LogicalRelationship>(); if ( relationalModel.getLogicalRelationships() != null ) { for ( LogicalRelationship rel : relationalModel.getLogicalRelationships() ) { if ( isOlap( rel.getFromColumn() ) && isOlap( rel.getToColumn() ) && isOlap( rel.getFromTable() ) && isOlap( rel.getToTable() ) ) { LogicalRelationship olapRel = duplicateRelationshipForOlap( rel, olapModel ); olapRelationships.add( olapRel ); } else { relationalRelationships.add( rel ); } } relationalModel.getLogicalRelationships().clear(); relationalModel.getLogicalRelationships().addAll( relationalRelationships ); olapModel.getLogicalRelationships().addAll( olapRelationships ); } }
public String toString() { String thisPath = ""; //$NON-NLS-1$ for ( int i = 0; i < size(); i++ ) { LogicalRelationship relationship = getRelationship( i ); if ( i > 0 ) { thisPath += ", "; //$NON-NLS-1$ } thisPath += "[" + relationship.getFromTable().getId() + "-" + relationship.getToTable().getId() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return thisPath; }
/** * Builds this graph based on data stored in list of relationships * * @param relationships * List of relationships that describe the graph */ private void build( List<LogicalRelationship> relationships ) { // loop through relationships and add necessary arcs // to the graph for ( LogicalRelationship relationship : relationships ) { // obtains nodes corresponding to tables Node left = getNodeForTable( relationship.getFromTable() ); Node right = getNodeForTable( relationship.getToTable() ); // record arcs that correspond to change Arc arc = createArc( left, right, relationship ); // TODO: if any table requires a relationship when the table is // used to ensure proper filtering, add dependency here // // if (relationship.getTableFrom() requires relationship) // left.addRequiredArc(arc); // // if (relationship.getTableTo() requires relationship) // right.addRequiredArc(arc); } }
for ( LogicalRelationship rel : rels ) { t3 = rel.getFromTable(); t4 = rel.getToTable(); if ( ( t3.equals( t1 ) && t4.equals( t2 ) ) || ( t3.equals( t2 ) && t4.equals( t1 ) ) ) { Path rtn = new Path();
Map<String, String> LogicalTableToAliasMap = new HashMap<String, String>(); if ( !relation.rightAlias.equals( DEFAULT_ALIAS ) ) { LogicalTableToAliasMap.put( relation.relation.getToTable().getId(), relation.rightAlias ); join = formula.generateSQL( locale ); } else if ( relation.relation.getFromTable() != null && relation.relation.getToTable() != null && relation.relation.getFromColumn() != null && relation.relation.getToColumn() != null ) { String rightAlias = relation.relation.getToTable().getId(); if ( !relation.rightAlias.equals( DEFAULT_ALIAS ) ) { rightAlias = rightAlias + "_" + relation.rightAlias; //$NON-NLS-1$
LogicalTable tbl = rel.getFromTable() == aliasedTable ? rel.getToTable() : rel.getFromTable(); traversePath( alias, tbl, aliasedPath, aliasedTables, defaultTables, allTables, allRelationships );
"RELATIONSHIP_FIELDNAME_PARENT", rel.getFromColumn().getId(), idGen.getNextId() ) ); //$NON-NLS-1$ if ( rel.getToTable() != null ) { modelElement.appendChild( createTaggedValue( doc, "RELATIONSHIP_TABLENAME_CHILD", rel.getToTable().getId(), idGen.getNextId() ) ); //$NON-NLS-1$
String leftTable = (String) aliasedRelation.relation.getFromTable().getProperty( SqlPhysicalTable.TARGET_TABLE ); String rightSchema = (String) aliasedRelation.relation.getToTable().getProperty( SqlPhysicalTable.TARGET_SCHEMA ); String rightTable = (String) aliasedRelation.relation.getToTable().getProperty( SqlPhysicalTable.TARGET_TABLE ); String rightTableAlias = aliasedRelation.relation.getToTable().getId(); if ( !aliasedRelation.rightAlias.equals( DEFAULT_ALIAS ) ) { rightTableAlias = rightTableAlias + "_" + aliasedRelation.rightAlias; //$NON-NLS-1$
String leftTableAlias = databaseMeta.quoteField( tableAliases.get( relation.getFromTable() ) ); String rightTableName = databaseMeta.getQuotedSchemaTableCombination( (String) relation.getToTable().getProperty( SqlPhysicalTable.TARGET_SCHEMA ), (String) relation.getToTable().getProperty( SqlPhysicalTable.TARGET_TABLE ) ); String rightTableAlias = databaseMeta.quoteField( tableAliases.get( relation.getToTable() ) );
private static LogicalRelationship duplicateRelationshipForOlap( LogicalRelationship rel, LogicalModel olapModel ) { LogicalTable olapFromTable = findCorrespondingOlapTable( rel.getFromTable(), olapModel ); LogicalTable olapToTable = findCorrespondingOlapTable( rel.getToTable(), olapModel ); LogicalColumn olapFromCol = findCorrespondingOlapColumn( rel.getFromColumn(), olapModel ); LogicalColumn olapToCol = findCorrespondingOlapColumn( rel.getToColumn(), olapModel ); LogicalRelationship olapRel = new LogicalRelationship( olapModel, olapFromTable, olapToTable, olapFromCol, olapToCol ); olapRel.setComplex( rel.isComplex() ); olapRel.setRelationshipType( rel.getRelationshipType() ); olapRel.setJoinOrderKey( rel.getJoinOrderKey() ); olapRel.setComplexJoin( rel.getComplexJoin() ); olapRel.setRelationshipDescription( rel.getRelationshipDescription() ); return olapRel; }
join = relation.getComplexJoin(); } else if ( relation.getFromTable() != null && relation.getToTable() != null && relation.getFromColumn() != null && relation.getToColumn() != null ) {