private LogicalColumn findPrimaryKeyFor( LogicalModel model, LogicalTable factTable, LogicalTable dimTable ) { LogicalRelationship ship = model.findRelationshipUsing( dimTable, factTable ); if ( ship == null ) { throw new IllegalStateException( "Unable to find a primary key for table: " + dimTable.getId() ); } if ( ship.getFromTable().equals( dimTable ) ) { return ship.getFromColumn(); } else { return ship.getToColumn(); } }
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 ); } }
&& relation.relation.getFromColumn() != null && relation.relation.getToColumn() != null ) { String rightAlias = relation.relation.getToTable().getId(); if ( !relation.rightAlias.equals( DEFAULT_ALIAS ) ) { join += "."; //$NON-NLS-1$ join += databaseMeta.quoteField( (String) relation.relation.getToColumn().getProperty( SqlPhysicalColumn.TARGET_COLUMN ) );
LogicalColumn keyColumn; if ( relationshipMeta.getFromTable().equals( dimTable ) ) { keyColumn = relationshipMeta.getToColumn(); } else { keyColumn = relationshipMeta.getFromColumn();
"RELATIONSHIP_TYPE", rel.getRelationshipType().getType(), idGen.getNextId() ) ); //$NON-NLS-1$ if ( rel.getToColumn() != null ) { modelElement.appendChild( createTaggedValue( doc, "RELATIONSHIP_FIELDNAME_CHILD", rel.getToColumn().getId(), idGen.getNextId() ) ); //$NON-NLS-1$
&& relation.getToColumn() != null ) { rightTableAlias = tableAliases.get( relation.getToColumn().getLogicalTable() ); } else { rightTableAlias = relation.getToColumn().getLogicalTable().getId(); join += databaseMeta.quoteField( (String) relation.getToColumn().getProperty( SqlPhysicalColumn.TARGET_COLUMN ) ); } else { throw new PentahoMetadataException( Messages.getErrorString(
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; }