コード例 #1
0
  public ParameterHelper(AbstractScalarParameterHandle param, ULocale ulocale, TimeZone timezone) {
    this.labelColumnName = getLabelColumnName(param);
    this.valueColumnName = getValueColumnName(param);
    this.valueType = param.getDataType();
    this.alreadySorted = param.getSortByColumn() != null;
    this.distinct = param.distinct();

    String sortDirection = param.getSortDirection();
    boolean sortByLabel = "label".equalsIgnoreCase(param.getSortBy());
    if (param instanceof ScalarParameterHandle) {
      parameterType = SCALAR_PARAMETER;
      ScalarParameterHandle parameter = (ScalarParameterHandle) param;
      this.fixedOrder = parameter.isFixedOrder();
      if (param.getLabelExpr()
          == null) { // if no label expression was set, apply pattern to value column
        pattern = parameter.getPattern();
      }
    } else {
      parameterType = FILTER_PARAMETER;
    }

    if (!(parameterType == SCALAR_PARAMETER && fixedOrder)
        && !alreadySorted
        && sortDirection != null) {
      boolean sortDirectionValue =
          DesignChoiceConstants.SORT_DIRECTION_ASC.equalsIgnoreCase(sortDirection);
      Comparator choiceComparator =
          new SelectionChoiceComparator(sortByLabel, pattern, sortDirectionValue, ulocale);
      this.comparator = new DistinctComparatorDecorator(choiceComparator, distinct);
    }
    this.converter = new ReportParameterConverter(pattern, ulocale, timezone);
  }
コード例 #2
0
 public static void addParameterSortBy(
     QueryDefinition queryDefn, AbstractScalarParameterHandle parameter, IModelAdapter adapter) {
   String sortBy = parameter.getSortByColumn();
   if (sortBy != null) {
     String sortDirection = parameter.getSortDirection();
     if (sortDirection != null) {
       org.eclipse.birt.report.model.api.Expression mexpr =
           (org.eclipse.birt.report.model.api.Expression)
               parameter
                   .getExpressionProperty(AbstractScalarParameter.SORT_BY_COLUMN_PROP)
                   .getValue();
       ScriptExpression dexpr = adapter.adaptExpression(mexpr);
       SortDefinition sort = new SortDefinition();
       sort.setExpression(dexpr);
       boolean direction =
           DesignChoiceConstants.SORT_DIRECTION_ASC.equalsIgnoreCase(sortDirection);
       sort.setSortDirection(direction ? ISortDefinition.SORT_ASC : ISortDefinition.SORT_DESC);
       queryDefn.addSort(sort);
     }
   }
 }