/** * finds a logical table within the model. * * @param tableId the table to find * @return a logical table object. */ public LogicalTable findLogicalTable( String tableId ) { for ( LogicalTable table : getLogicalTables() ) { if ( tableId.equals( table.getId() ) ) { return table; } } return null; }
/** * finds a logical column within the model. * * @param columnId the column to find * @return a logical column object. */ public LogicalColumn findLogicalColumn( String columnId ) { for ( LogicalTable table : getLogicalTables() ) { for ( LogicalColumn column : table.getLogicalColumns() ) { if ( columnId.equals( column.getId() ) ) { return column; } } } return null; }
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; }
private LogicalTable findOlapCloneForTableInDomain( LogicalTable supposedLTable, Domain domain ) { if ( supposedLTable.getId().endsWith( BaseModelerWorkspaceHelper.OLAP_SUFFIX ) ) { return supposedLTable; } for ( LogicalTable table : domain.getLogicalModels().get( 1 ).getLogicalTables() ) { if ( table.getId().equals( supposedLTable.getId() + BaseModelerWorkspaceHelper.OLAP_SUFFIX ) ) { return table; } } throw new IllegalStateException( "Unable to find a OLAP copy for table: " + supposedLTable.getId() ); }
public LogicalColumn findLogicalColumn( String id ) { LogicalColumn col = null; for ( LogicalColumn c : getLogicalModel( currentModelerPerspective ).getLogicalTables().get( 0 ) .getLogicalColumns() ) { if ( c.getName( workspaceHelper.getLocale() ).equals( id ) ) { col = c; break; } } return col; }
private void assignFactTable( final ModelerWorkspace workspace ) { List<LogicalTable> logicalTables = workspace.getLogicalModel( ModelerPerspective.ANALYSIS ).getLogicalTables(); logicalTables.get( 0 ).getPhysicalTable().setProperty( "FACT_TABLE", true ); }
protected LogicalColumn locateLogicalColumn( final ModelerWorkspace workspace, final String columnName ) { String locale = workspace.getWorkspaceHelper().getLocale(); LogicalModel logicalModel = workspace.getLogicalModel( ModelerPerspective.ANALYSIS ); logicalModel.getLogicalTables(); for ( LogicalTable logicalTable : logicalModel.getLogicalTables() ) { for ( LogicalColumn logicalColumn : logicalTable.getLogicalColumns() ) { if ( logicalColumn.getName( locale ).equalsIgnoreCase( columnName ) || logicalColumn.getName( locale ).equalsIgnoreCase( beautify( columnName ) ) ) { return logicalColumn; } } } return null; }
protected static LogicalTable findCorrespondingOlapTable( LogicalTable relationalTable, LogicalModel olapModel ) { for ( LogicalTable table : olapModel.getLogicalTables() ) { if ( table.getPhysicalTable().getId().equals( relationalTable.getPhysicalTable().getId() ) ) { return table; } } return null; }
iter.remove(); } else { Iterator<LogicalTable> tbliter = model.getLogicalTables().iterator(); while ( tbliter.hasNext() ) { LogicalTable table = tbliter.next();
public LogicalTable findLogicalTable( IPhysicalTable table, ModelerPerspective perspective ) { LogicalModel logicalModel = this.getLogicalModel( perspective ); if ( logicalModel == null ) { return null; } for ( LogicalTable logicalTable : logicalModel.getLogicalTables() ) { if ( logicalTable.getPhysicalTable().equals( table ) || logicalTable.getPhysicalTable().getId().equals( table.getId() ) || logicalTable.getId().equals( table.getId() ) ) { return logicalTable; // boolean isOlapTable = logicalTable.getId().endsWith(BaseModelerWorkspaceHelper.OLAP_SUFFIX); // if (perspective == ModelerPerspective.ANALYSIS && isOlapTable) { // return logicalTable; // } else if (perspective == ModelerPerspective.REPORTING && !isOlapTable) { // return logicalTable; // } } } return null; }
if ( model.getLogicalTables().size() == domain.getLogicalModels().get( 1 ).getLogicalTables().size() ) { return currentVersion;
@Override public void clearTreeModel() { workspace.setRelationalModelIsChanging( true ); // remove all logical columns from existing logical tables for ( LogicalTable table : workspace.getLogicalModel( ModelerPerspective.REPORTING ).getLogicalTables() ) { table.getLogicalColumns().clear(); } workspace.getRelationalModel().getCategories().clear(); workspace.setRelationalModelIsChanging( false, true ); }
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; }
private void moveDimensionToModel( final ModelerWorkspace dimensionWorkspace, final ModelerWorkspace factWorkspace, final String factKey, final String dimKey ) throws ModelerException { DimensionMetaData dimension = getLastDimension( dimensionWorkspace ); dimension.setName( getName() ); removeExistingDimension( factWorkspace ); factWorkspace.addDimension( dimension ); LogicalTable dimTable = dimensionWorkspace.getLogicalModel( ModelerPerspective.ANALYSIS ).getLogicalTables().get( 0 ); LogicalTable factTable = factWorkspace.getLogicalModel( ModelerPerspective.ANALYSIS ).getLogicalTables().get( 0 ); LogicalModel logicalModel = factWorkspace.getLogicalModel( ModelerPerspective.ANALYSIS ); logicalModel.addLogicalTable( dimTable ); @SuppressWarnings( "unchecked" ) List<SqlPhysicalTable> physicalTables = (List<SqlPhysicalTable>) factWorkspace.getDomain().getPhysicalModels().get( 0 ).getPhysicalTables(); physicalTables.add( (SqlPhysicalTable) dimTable.getPhysicalTable() ); logicalModel.addLogicalRelationship( new LogicalRelationship( logicalModel, factTable, dimTable, locateLogicalColumn( factWorkspace, factKey ), locateLogicalColumn( dimensionWorkspace, dimKey ) ) ); }
for ( LogicalTable table : combinedModel.getLogicalTables() ) { if ( table.getId().endsWith( BaseModelerWorkspaceHelper.OLAP_SUFFIX ) ) { table.setLogicalModel( olapModel ); combinedModel.getLogicalTables().clear(); combinedModel.getLogicalTables().addAll( relationalTables ); olapModel.getLogicalTables().addAll( olapTables );
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; } } } }
private void upConvertMeasuresAndDimensions() { if ( domain.getLogicalModels().size() == 1 ) { return; } LogicalModel model = domain.getLogicalModels().get( 1 ); // clean out the tables, we'll recreate the logical columns for ( LogicalTable table : model.getLogicalTables() ) { table.getLogicalColumns().clear(); } // set the dimension logical column references to the new olap columns for ( DimensionMetaData dim : getModel().getDimensions() ) { for ( HierarchyMetaData hier : dim ) { for ( LevelMetaData level : hier ) { // create new logical columns AvailableField field = new AvailableField( level.getLogicalColumn().getPhysicalColumn() ); ColumnBackedNode node = createColumnBackedNode( field, ModelerPerspective.ANALYSIS ); level.setLogicalColumn( node.getLogicalColumn() ); } } } // set the measure logical column references to the new olap columns for ( MeasureMetaData measure : getModel().getMeasures() ) { AvailableField field = new AvailableField( measure.getLogicalColumn().getPhysicalColumn() ); ColumnBackedNode node = createColumnBackedNode( field, ModelerPerspective.ANALYSIS ); measure.setLogicalColumn( node.getLogicalColumn() ); } // make sure the relationships are set too ModelerConversionUtil.duplicateRelationshipsForOlap( domain.getLogicalModels().get( 0 ), model ); return; }
protected void doInputWiring( Query query, TransMeta transMeta ) { // // CSV FILE LOCATION AND FIELDS // InlineEtlPhysicalModel physicalModel = (InlineEtlPhysicalModel) query.getLogicalModel().getPhysicalModel(); CsvInputMeta csvinput = (CsvInputMeta) getStepMeta( transMeta, "CSV file input" ).getStepMetaInterface(); //$NON-NLS-1$ // the file name might need to be translated to the correct location here if ( csvFileLoc != null ) { csvinput.setFilename( csvFileLoc + physicalModel.getFileLocation() ); } else { csvinput.setFilename( physicalModel.getFileLocation() ); } csvinput.setDelimiter( physicalModel.getDelimiter() ); csvinput.setEnclosure( physicalModel.getEnclosure() ); csvinput.setHeaderPresent( physicalModel.getHeaderPresent() ); // update fields LogicalTable table = query.getLogicalModel().getLogicalTables().get( 0 ); csvinput.allocate( table.getLogicalColumns().size() ); for ( int i = 0; i < csvinput.getInputFields().length; i++ ) { // Update csv input LogicalColumn col = table.getLogicalColumns().get( i ); csvinput.getInputFields()[i] = new TextFileInputField(); String fieldName = (String) col.getProperty( InlineEtlPhysicalColumn.FIELD_NAME ); if ( logger.isDebugEnabled() ) { logger.debug( "FROM CSV: " + fieldName ); //$NON-NLS-1$ } csvinput.getInputFields()[i].setName( fieldName ); csvinput.getInputFields()[i].setType( convertType( col.getDataType() ) ); } }
for ( LogicalTable table : workspace.getDomain().getLogicalModels().get( 0 ).getLogicalTables() ) { if ( !table.getId().endsWith( BaseModelerWorkspaceHelper.OLAP_SUFFIX ) ) { table.getLogicalColumns().clear();
@Override public boolean apply( final ModelerWorkspace workspace, final IMetaStore metaStore ) throws ModelerException { List<LogicalTable> logicalTables = workspace.getLogicalModel( ModelerPerspective.ANALYSIS ).getLogicalTables(); for ( LogicalTable logicalTable : logicalTables ) { List<LogicalColumn> logicalColumns = logicalTable.getLogicalColumns();