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;
  }
Beispiel #2
0
  @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();
      for (LogicalColumn logicalColumn : logicalColumns) {
        if (columnMatches(workspace, resolveField(workspace), logicalColumn)
            || columnMatches(
                workspace,
                PhysicalTableImporter.beautifyName(resolveField(workspace)),
                logicalColumn)) {
          String targetColumn =
              (String)
                  logicalColumn.getPhysicalColumn().getProperty(SqlPhysicalColumn.TARGET_COLUMN);
          MeasureMetaData measureMetaData =
              new MeasureMetaData(
                  targetColumn,
                  getFormatString(),
                  getName(),
                  workspace.getWorkspaceHelper().getLocale());

          LogicalColumn columnClone = (LogicalColumn) logicalColumn.clone();
          columnClone.setId(
              BaseModelerWorkspaceHelper.uniquify(columnClone.getId(), logicalColumns));
          measureMetaData.setLogicalColumn(columnClone);
          measureMetaData.setName(getName());
          measureMetaData.setDefaultAggregation(getAggregateType());
          measureMetaData.setHidden(isHidden());
          measureMetaData
              .getMemberAnnotations()
              .put(
                  GeneratedbyMemberAnnotation.GEBERATED_BY_STRING,
                  new GeneratedbyMemberAnnotation(this.getName()));
          if (getDescription() != null) {
            measureMetaData.setDescription(getDescription());
          }
          removeAutoMeasure(workspace, resolveField(workspace));
          removeMeasure(workspace, getName());
          workspace.getModel().getMeasures().add(measureMetaData);
          removeAutoLevel(workspace, locateLevel(workspace, resolveField(workspace)));
          workspace.getWorkspaceHelper().populateDomain(workspace);
          return true;
        }
      }
    }
    return false;
  }
Beispiel #3
0
 @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;
     }
   }
 }