コード例 #1
0
ファイル: CreateMeasure.java プロジェクト: pentaho/modeler
  @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;
  }
コード例 #2
0
ファイル: CreateMeasure.java プロジェクト: pentaho/modeler
 private boolean measureNameEquals(String column, MeasureMetaData measure) {
   return measure.getName().equalsIgnoreCase(column)
       || measure.getName().equalsIgnoreCase(PhysicalTableImporter.beautifyName(column));
 }