public LogicalColumn findLogicalColumn( IPhysicalColumn column, ModelerPerspective perspective ) { LogicalColumn col = null; IPhysicalTable physicalTable = column.getPhysicalTable(); LogicalModel logicalModel = this.getLogicalModel( perspective ); if ( logicalModel == null ) { return col; } for ( LogicalTable table : logicalModel.getLogicalTables() ) { if ( table.getPhysicalTable().getId().equals( physicalTable.getId() ) ) { if ( ( perspective == ModelerPerspective.ANALYSIS && table.getId().endsWith( BaseModelerWorkspaceHelper.OLAP_SUFFIX ) ) || ( perspective == ModelerPerspective.REPORTING && !table.getId().endsWith( BaseModelerWorkspaceHelper.OLAP_SUFFIX ) ) ) { for ( LogicalColumn lCol : table.getLogicalColumns() ) { if ( lCol.getPhysicalColumn().getId().equals( column.getId() ) ) { return lCol; } } } } } return col; }
@Override public Object clone() { LogicalTable clone = new LogicalTable(); // shallow copy clone( clone ); clone.setParent( getParent() ); clone.setPhysicalConcept( getPhysicalConcept() ); // deep copy clone.setLogicalColumns( new ArrayList<LogicalColumn>() ); for ( LogicalColumn col : logicalColumns ) { clone.addLogicalColumn( col ); } return clone; } }
public boolean equals( Object obj ) { AliasedPathLogicalTable apbt = (AliasedPathLogicalTable) obj; return apbt.alias.equals( alias ) && apbt.table.equals( table ); }
public String toString() { StringBuffer buff = new StringBuffer(); buff.append( "Node[" + id + "]: Table " ); if ( ( table != null ) && ( table.getPhysicalTable() != null ) ) { buff.append( table.getPhysicalTable().getName( "" ) ); } else if ( table != null ) { buff.append( table.getName( "" ) ); // Business Table } else { buff.append( "*null*" ); // Business } return buff.toString(); } }
for ( int i = 0; i < bizTables.getLength(); i++ ) { Element biztable = (Element) bizTables.item( i ); LogicalTable table = new LogicalTable(); table.setId( biztable.getAttribute( "name" ) ); //$NON-NLS-1$ bindParentConcept( biztable, domain, table ); Map<String, String> logicalModel.setPhysicalModel( physTable.getPhysicalModel() ); table.setPhysicalTable( physTable ); table.setLogicalModel( logicalModel ); table.setProperty( "__LEGACY_TABLE_IS_DRAWN", nvp.get( "TABLE_IS_DRAWN" ) ); //$NON-NLS-1$ //$NON-NLS-2$ table.setProperty( "__LEGACY_TAG_POSITION_Y", nvp.get( "TAG_POSITION_Y" ) ); //$NON-NLS-1$ //$NON-NLS-2$ table.setProperty( "__LEGACY_TAG_POSITION_X", nvp.get( "TAG_POSITION_X" ) ); //$NON-NLS-1$ //$NON-NLS-2$ if ( parent != null ) { col.setLogicalTable( parent ); parent.addLogicalColumn( col ); for ( IPhysicalColumn phycol : parent.getPhysicalTable().getPhysicalColumns() ) { if ( phycol.getId().equals( pcol ) ) { col.setPhysicalColumn( phycol );
LogicalTable copiedTable = (LogicalTable) table.clone(); copiedTable.setId( copiedTable.getId() + BaseModelerWorkspaceHelper.OLAP_SUFFIX ); for ( LogicalColumn col : table.getLogicalColumns() ) { LogicalColumn olapCol = new LogicalColumn(); olapCol.setLogicalTable( copiedTable ); "LC_" + ModelerWorkspace.toId( table.getPhysicalTable().getName( locale ) ) + "_" + ModelerWorkspace.toId( col.getPhysicalColumn().getId() ) + BaseModelerWorkspaceHelper.OLAP_SUFFIX; copiedTable.getLogicalColumns().clear(); copiedTable.getLogicalColumns().addAll( olapColumns );
LogicalTable logicalTable = new LogicalTable(); IPhysicalTable physicalTable = domain.findPhysicalTable( businessTable.getPhysicalTable().getId() ); if ( physicalTable != null && logicalModel.getPhysicalModel() == null ) { logicalModel.setPhysicalModel( physicalTable.getPhysicalModel() ); logicalTable.setPhysicalTable( physicalTable ); logicalTable.setLogicalModel( logicalModel ); logicalTable.setProperty( "__LEGACY_TAG_POSITION_X", "" + businessTable.getLocation().x ); logicalTable.setProperty( "__LEGACY_TAG_POSITION_Y", "" + businessTable.getLocation().y ); logicalTable.setProperty( "__LEGACY_TABLE_IS_DRAWN", "" + businessTable.isDrawn() ); logicalTable.getLogicalColumns().add( logicalColumn ); logicalRelationshipId += fromTable.getId(); if ( fromColumn != null ) { logicalRelationshipId += "." + fromColumn.getId(); logicalRelationshipId += toTable.getId(); if ( toColumn != null ) { logicalRelationshipId += "." + toColumn.getId();
private LogicalColumn findBusinessColumn( LogicalTable logicalTable, String columnName ) { for ( LogicalColumn logicalColumn : logicalTable.getLogicalColumns() ) { if ( columnName.equals( ( (SqlPhysicalColumn) logicalColumn.getPhysicalColumn() ).getTargetColumn() ) ) { return logicalColumn; } } return null; }
"RELATIONSHIP_TABLENAME_CHILD", rel.getToTable().getId(), idGen.getNextId() ) ); //$NON-NLS-1$ "RELATIONSHIP_TABLENAME_PARENT", rel.getFromTable().getId(), idGen.getNextId() ) ); //$NON-NLS-1$ sd.appendChild( dim ); dim.setAttribute( "isAbstract", "false" ); //$NON-NLS-1$ //$NON-NLS-2$ dim.setAttribute( "name", table.getId() ); //$NON-NLS-1$ String tblidstr = idGen.getNextId(); dim.setAttribute( "xmi.id", tblidstr ); //$NON-NLS-1$ createDescriptions( doc, table, "CWMMDB:Dimension", tblidstr, allDescriptions, idGen ); //$NON-NLS-1$ Element modelElement = doc.createElement( "CWM:ModelElement.taggedValue" ); //$NON-NLS-1$ if ( table.getProperty( "__LEGACY_TABLE_IS_DRAWN" ) != null ) { //$NON-NLS-1$ modelElement.appendChild( createTaggedValue( doc, "TABLE_IS_DRAWN", (String) table.getProperty( "__LEGACY_TABLE_IS_DRAWN" ), if ( table.getProperty( "__LEGACY_TAG_POSITION_Y" ) != null ) { //$NON-NLS-1$ modelElement.appendChild( createTaggedValue( doc, "TAG_POSITION_Y", (String) table.getProperty( "__LEGACY_TAG_POSITION_Y" ), if ( table.getProperty( "__LEGACY_TAG_POSITION_X" ) != null ) { //$NON-NLS-1$ modelElement.appendChild( createTaggedValue( doc, "TAG_POSITION_X", (String) table.getProperty( "__LEGACY_TAG_POSITION_X" ), if ( table.getParentConcept() != null ) { modelElement.appendChild( createTaggedValue( doc, "CONCEPT_PARENT_NAME", table.getParentConcept().getId(), idGen.getNextId() ) ); //$NON-NLS-1$ "BUSINESS_TABLE_PHYSICAL_TABLE_NAME", table.getPhysicalTable().getId(),
Object prop; for ( LogicalTable lTable : logicalModel.getLogicalTables() ) { prop = lTable.getPhysicalTable().getProperty( "FACT_TABLE" ); if ( prop == null ) { continue; if ( !olapCloneLTable.getLogicalColumns().contains( lCol ) ) { olapCloneLTable.addLogicalColumn( lCol ); OlapMeasure measure = new OlapMeasure(); String colKey = lTable.getId() + "." + lCol.getId(); clone.setId( uniquify( clone.getId(), lTable.getLogicalColumns() ) ); lCol = clone; } else { if ( !lTable.getLogicalColumns().contains( lCol ) ) { lTable.addLogicalColumn( lCol );
private LogicalTable createBusinessTable( SqlPhysicalTable physicalTable, String locale ) { // Create a business table with a new ID and localized name // LogicalTable businessTable = new LogicalTable( null, physicalTable ); // Try to set the name of the business table to something nice (beautify) // String tableName = PhysicalTableImporter.beautifyName( physicalTable.getTargetTable() ); businessTable.setName( new LocalizedString( locale, tableName ) ); businessTable.setId( Util.proposeSqlBasedLogicalTableId( locale, businessTable, physicalTable ) ); // Add columns to this by copying the physical columns to the business // columns... // for ( IPhysicalColumn physicalColumn : physicalTable.getPhysicalColumns() ) { LogicalColumn businessColumn = new LogicalColumn(); businessColumn.setPhysicalColumn( physicalColumn ); businessColumn.setLogicalTable( businessTable ); // We're done, add the business column. // // Propose a new ID businessColumn.setId( Util.proposeSqlBasedLogicalColumnId( locale, businessTable, (SqlPhysicalColumn) physicalColumn ) ); businessTable.addLogicalColumn( businessColumn ); } return businessTable; }
private void addFieldsToTables( Domain domain, AbstractModelList<JoinTableModel> availableTables ) { String locale = LocalizedString.DEFAULT_LOCALE; Outter: for ( JoinTableModel table : availableTables ) { for ( LogicalTable tbl : domain.getLogicalModels().get( 0 ).getLogicalTables() ) { if ( tbl.getPhysicalTable().getProperty( "target_table" ).equals( table.getName() ) ) { for ( LogicalColumn col : tbl.getLogicalColumns() ) { JoinFieldModel field = new JoinFieldModel(); field.setName( col.getName( locale ) ); field.setParentTable( table ); table.getFields().add( field ); } continue Outter; } } } }
throw new IllegalStateException( "Fact table not found" ); } else { factTable.getPhysicalTable().setProperty( "FACT_TABLE", true ); workspace.getAvailableTables().setFactTable( factTable.getPhysicalTable() ); businessTable.setName( new LocalizedString( locale, businessTable.getPhysicalTable().getName( locale ) ) ); businessTable.setName( new LocalizedString( locale, businessTable.getPhysicalTable().getName( locale ) ) );
mainCategory.setName( new LocalizedString( locale.getCode(), modelName ) ); LogicalTable logicalTable = new LogicalTable( logicalModel, table ); logicalTable.setId( "LOGICAL_TABLE_1" ); //$NON-NLS-1$ logicalColumn.setLogicalTable( logicalTable ); logicalTable.addLogicalColumn( logicalColumn ); mainCategory.addLogicalColumn( logicalColumn );
"LC_" + toId( lTab.getPhysicalTable().getName( locale ) ) + "_" + toId( field.getPhysicalColumn().getId() ); colId = BaseModelerWorkspaceHelper.uniquify( colId, lTab.getLogicalColumns() ); lCol.setId( colId ); lTab.addLogicalColumn( lCol );
private LogicalTable findFactTable( String table, LogicalModel logicalModel ) { LogicalTable factTable = null; for ( LogicalTable lTable : logicalModel.getLogicalTables() ) { if ( lTable.getId().endsWith( BaseModelerWorkspaceHelper.OLAP_SUFFIX ) ) { Object prop = lTable.getPhysicalTable().getProperty( "target_table" ); if ( prop != null && prop.equals( table ) ) { factTable = lTable; break; } } } return factTable; }
protected void populateCategories( ModelerWorkspace workspace ) { RelationalModelNode model = workspace.getRelationalModel(); LogicalModel logicalModel = workspace.getDomain().getLogicalModels().get( 0 ); logicalModel.getCategories().clear(); for ( CategoryMetaData catMeta : model.getCategories() ) { Category cat = new Category(); cat.setName( new LocalizedString( this.getLocale(), catMeta.getName() ) ); cat.setId( catMeta.getName() ); for ( FieldMetaData fieldMeta : catMeta ) { LogicalColumn lCol = fieldMeta.getLogicalColumn(); LogicalTable lTable = lCol.getLogicalTable(); if ( !lTable.getLogicalColumns().contains( lCol ) ) { lTable.addLogicalColumn( lCol ); } lCol.setName( new LocalizedString( locale, fieldMeta.getName() ) ); AggregationType type = fieldMeta.getDefaultAggregation(); lCol.setAggregationType( type ); setLogicalColumnFormat( fieldMeta.getFormat(), lCol ); Set<AggregationType> possibleAggs = new HashSet<AggregationType>(); possibleAggs.add( fieldMeta.getDefaultAggregation() ); possibleAggs.addAll( fieldMeta.getSelectedAggregations() ); lCol.setAggregationList( Arrays.<AggregationType>asList( possibleAggs .toArray( new AggregationType[possibleAggs.size()] ) ) ); cat.addLogicalColumn( lCol ); } logicalModel.addCategory( cat ); } }
if ( !table.getId().endsWith( BaseModelerWorkspaceHelper.OLAP_SUFFIX ) ) { table.getLogicalColumns().clear();