Beispiel #1
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;
  }
  public ColumnBackedNode createColumnBackedNode(
      AvailableField field, ModelerPerspective perspective) {
    String locale = workspaceHelper.getLocale();
    ColumnBackedNode node = new BaseColumnBackedMetaData(field.getName());
    LogicalTable lTab = findLogicalTable(field.getPhysicalColumn().getPhysicalTable(), perspective);
    LogicalColumn lCol = null;

    if (lCol == null) {
      lCol = new LogicalColumn();
      lCol.setLogicalTable(lTab);
      // lCol.setParentConcept(lTab);
      lCol.setPhysicalColumn(field.getPhysicalColumn());
      lCol.setDataType(field.getPhysicalColumn().getDataType());
      if (field.getPhysicalColumn().getAggregationList() != null) {
        lCol.setAggregationList(field.getPhysicalColumn().getAggregationList());
      }
      if (field.getPhysicalColumn().getAggregationType() != null) {
        lCol.setAggregationType(field.getPhysicalColumn().getAggregationType());
      }
      lCol.setName(new LocalizedString(locale, field.getPhysicalColumn().getName(locale)));
      String colId =
          "LC_"
              + toId(lTab.getPhysicalTable().getName(locale))
              + "_"
              + toId(field.getPhysicalColumn().getId());

      // lCol.setDescription(new LocalizedString(locale,
      // field.getPhysicalColumn().getName(locale)));

      if (perspective == ModelerPerspective.ANALYSIS) {
        colId += BaseModelerWorkspaceHelper.OLAP_SUFFIX;
      }

      colId = BaseModelerWorkspaceHelper.uniquify(colId, lTab.getLogicalColumns());
      lCol.setId(colId);

      lTab.addLogicalColumn(lCol);
    }

    node.setLogicalColumn(lCol);
    return node;
  }