public static String getCleanCategoryName( String name, ModelerWorkspace workspace, int index ) { if ( name == null ) { return "Category " + index; } else if ( name.equals( "LOGICAL_TABLE_1" ) || name.equals( "INLINE_SQL_1" ) ) { if ( workspace.getModel().getName() != null ) { return workspace.getModel().getName(); } else { return "Category " + index; } } else { return name; } }
@Override protected MainModelNode getMainModelNode( ModelerWorkspace workspace ) { MainModelNode mainModel = null; if ( workspace.getModel() == null ) { mainModel = new MainModelNode(); mainModel.setWorkspace( workspace ); } else { workspace.getModel().getMeasures().clear(); workspace.getModel().getDimensions().clear(); mainModel = workspace.getModel(); } return mainModel; }
/** * Retrieves the measure based on the formula. * * @param workspace Workspace to search for formula * @param formula Formula to search for (ex [MEASURES].[SALES]) * @return Measure otherwise null */ private MeasureMetaData locateMeasureFromFormula( final ModelerWorkspace workspace, final String formula ) { if ( formula == null || workspace == null ) { return null; } for ( MeasureMetaData measureMetaData : workspace.getModel().getMeasures() ) { StringBuilder formulaBuilder = new StringBuilder(); formulaBuilder.append( "[" + MEASURES_DIMENSION + "].[" ); formulaBuilder.append( measureMetaData.getName() ); formulaBuilder.append( "]" ); if ( formula.equals( formulaBuilder.toString() ) ) { return measureMetaData; } } return null; }
protected LevelMetaData locateLocationLevel( final ModelerWorkspace workspace ) throws ModelerException { workspace.getModel().getDimensions(); for ( DimensionMetaData dimensionMetaData : workspace.getModel().getDimensions() ) { for ( HierarchyMetaData hierarchyMetaData : dimensionMetaData ) { for ( LevelMetaData levelMetaData : hierarchyMetaData ) { IMemberAnnotation geoAnnotation = levelMetaData.getMemberAnnotations().get( ANNOTATION_GEO_ROLE ); if ( null != geoAnnotation && LocationRole.LOCATION.equalsIgnoreCase( geoAnnotation.getName() ) ) { return levelMetaData; } } } } return null; }
private LevelMetaData locateLevelFromFormula( final ModelerWorkspace workspace, final String formula ) { if ( formula == null || workspace == null ) { return null; } for ( DimensionMetaData dimensionMetaData : workspace.getModel().getDimensions() ) { for ( HierarchyMetaData hierarchyMetaData : dimensionMetaData ) { for ( LevelMetaData levelMetaData : hierarchyMetaData ) { StringBuffer formulaBuffer = new StringBuffer(); formulaBuffer.append( "[" ); formulaBuffer.append( dimensionMetaData.getName() ); if ( StringUtils.isNotEmpty( hierarchyMetaData.getName() ) ) { formulaBuffer.append( "." ); formulaBuffer.append( hierarchyMetaData.getName() ); } formulaBuffer.append( "].[" ); formulaBuffer.append( levelMetaData.getName( ) ); formulaBuffer.append( "]" ); if ( formula.equals( formulaBuffer.toString() ) ) { return levelMetaData; } } } } return null; }
protected void removeAutoMeasure( final ModelerWorkspace workspace, final String column ) { MeasureMetaData measure = locateMeasure( workspace, column ); if ( measure != null && !measure.getMemberAnnotations().containsKey( GeneratedbyMemberAnnotation.GEBERATED_BY_STRING ) ) { workspace.getModel().getMeasures().remove( measure ); } }
@Override public void clearTreeModel() { workspace.setModelIsChanging( true ); // remove all logical columns from existing logical tables // for (LogicalTable table : workspace.getLogicalModel(ModelerPerspective.ANALYSIS).getLogicalTables()) { // table.getLogicalColumns().clear(); // } workspace.getModel().getDimensions().clear(); workspace.getModel().getMeasures().clear(); workspace.setModelIsChanging( false, true ); }
private DimensionMetaData getLastDimension( final ModelerWorkspace dimensionWorkspace ) { DimensionMetaDataCollection dimensions = dimensionWorkspace.getModel().getDimensions(); return dimensions.get( dimensions.size() - 1 ); }
private HierarchyMetaData locateHierarchy( final ModelerWorkspace workspace, final String name ) { for ( DimensionMetaData dimensionMetaData : workspace.getModel().getDimensions() ) { if ( dimensionMetaData.getName().equals( getDimension() ) ) { for ( HierarchyMetaData hierarchyMetaData : dimensionMetaData ) { if ( hierarchyMetaData.getName().equals( Const.isEmpty( name ) ? getDimension() : name ) ) { return hierarchyMetaData; } } } } return null; }
protected LevelMetaData locateLevel( final ModelerWorkspace workspace, final String column ) throws ModelerException { String locale = workspace.getWorkspaceHelper().getLocale(); workspace.getModel().getDimensions(); for ( DimensionMetaData dimensionMetaData : workspace.getModel().getDimensions() ) { for ( HierarchyMetaData hierarchyMetaData : dimensionMetaData ) { for ( LevelMetaData levelMetaData : hierarchyMetaData ) { if ( levelMetaData.getLogicalColumn().getName( locale ).equalsIgnoreCase( column ) || levelMetaData.getLogicalColumn().getName( locale ).equals( beautify( column ) ) ) { return levelMetaData; } } } } return null; }
private void removeExistingDimension( final ModelerWorkspace factWorkspace ) { DimensionMetaDataCollection dimensions = factWorkspace.getModel().getDimensions(); for ( int i = 0; i < dimensions.size(); i++ ) { final DimensionMetaData dimension = dimensions.get( i ); if ( dimension.getName().equalsIgnoreCase( getName() ) ) { dimensions.remove( i ); return; } } }
private void removeAutoGeo( final ModelerWorkspace workspace ) { DimensionMetaDataCollection dimensions = workspace.getModel().getDimensions(); DimensionMetaData toRemove = null; GeoContext geoContext = workspace.getGeoContext(); for ( DimensionMetaData dimensionMetaData : dimensions ) { if ( geoContext != null && dimensionMetaData.getName().equals( geoContext.getDimensionName() ) ) { for ( HierarchyMetaData hierarchyMetaData : dimensionMetaData ) { if ( hierarchyMetaData.getName().equals( geoContext.getDimensionName() ) ) { for ( LevelMetaData levelMetaData : hierarchyMetaData ) { if ( levelMetaData.getMemberAnnotations().get( "Data.Role" ) != null ) { toRemove = dimensionMetaData; break; } } } } } } if ( toRemove != null ) { dimensions.remove( toRemove ); } }
private MeasureMetaData locateMeasure( final ModelerWorkspace workspace, final String column ) { MeasuresCollection measures = workspace.getModel().getMeasures(); for ( MeasureMetaData measure : measures ) { if ( measure.getLogicalColumn().getName( workspace.getWorkspaceHelper().getLocale() ).equals( column ) || measure.getLogicalColumn().getName( workspace.getWorkspaceHelper().getLocale() ).equals( beautify( column ) ) ) { return measure; } } return null; }
@Bindable public void showValidationMessagesDialog() { AbstractMetaDataModelNode node; if ( workspace.getCurrentModelerPerspective() == ModelerPerspective.ANALYSIS ) { node = workspace.getSelectedNode(); if ( node == null ) { node = workspace.getModel(); } } else { node = workspace.getSelectedRelationalNode(); if ( node == null ) { node = workspace.getRelationalModel(); } } showValidationMessages( new ArrayList<String>( node.getValidationMessages() ) ); }
public boolean saveWorkspace( String fileName ) throws ModelerException { workspace.getModel().validateTree(); if ( workspace.isValid() == false ) { showValidationMessages(); return false; } workspace.setFileName( fileName ); workspace.setDirty( false ); workspace.setTemporary( false ); return true; }
@Override protected void removeAutoMeasure( final ModelerWorkspace workspace, final String column ) { LogicalColumn logicalColumn = locateLogicalColumn( workspace, column ); String locale = workspace.getWorkspaceHelper().getLocale(); for ( MeasureMetaData measure : workspace.getModel().getMeasures() ) { if ( measureNameEquals( column, measure ) && measure.getLogicalColumn().getPhysicalColumn().getName( locale ).equals( logicalColumn.getPhysicalColumn().getName( locale ) ) && measure.getDefaultAggregation().equals( AggregationType.SUM ) && !measure.getMemberAnnotations().containsKey( GeneratedbyMemberAnnotation.GEBERATED_BY_STRING ) ) { workspace.getModel().getMeasures().remove( measure ); break; } } }
protected void removeAutoLevel( final ModelerWorkspace workspace, final LevelMetaData levelMetaData, boolean force ) { if ( levelMetaData == null ) { return; } HierarchyMetaData hierarchy = levelMetaData.getHierarchyMetaData(); DimensionMetaData dimension = hierarchy.getDimensionMetaData(); if ( hierarchy.getLevels().size() > 1 || ( !force && dimension.getMemberAnnotations().containsKey( GeneratedbyMemberAnnotation.GEBERATED_BY_STRING ) ) ) { return; } if ( dimension.contains( hierarchy ) ) { dimension.remove( hierarchy ); } if ( dimension.size() > 0 ) { return; } DimensionMetaDataCollection dimensions = workspace.getModel().getDimensions(); if ( dimensions.contains( dimension ) ) { dimensions.remove( dimension ); } }
@Bindable public void showAutopopulatePrompt() { try { if ( getModelerPerspective() == ModelerPerspective.ANALYSIS ) { MainModelNode model = workspace.getModel(); if ( model.getDimensions().isEmpty() && model.getMeasures().isEmpty() ) { autoPopulate(); } else { showAutoModelConfirmDialog(); } } else { RelationalModelNode model = workspace.getRelationalModel(); if ( model.getCategories().isEmpty() ) { autoPopulate(); } else { showAutoModelConfirmDialog(); } } } catch ( XulException e ) { e.printStackTrace(); } }