Program: 75846
Project: 75846
Buggy source:
/** 
 * @param query
 * @param resultMetaList
 * @param levelNameColumnNamePair
 * @param hierHandle
 * @throws AdapterException 
 */
private void prepareLevels(QueryDefinition query,TabularHierarchyHandle hierHandle,List metaList,String timeLevelName,String leafLevelName) throws AdapterException {
  List levels=hierHandle.getContents(TabularHierarchyHandle.LEVELS_PROP);
  for (int j=0; j < levels.size(); j++) {
    TabularLevelHandle level=(TabularLevelHandle)levels.get(j);
    ColumnMeta temp=null;
    String exprString=ExpressionUtil.createJSDataSetRowExpression(level.getColumnName());
    int type=ModelAdapter.adaptModelDataType(level.getDataType());
    if (isTimeType(type)) {
      temp=new ColumnMeta(level.getName(),true,new TimeValueProcessor(level.getDateTimeLevelType()));
      temp.setDataType(DataType.INTEGER_TYPE);
    }
 else {
      IDataProcessor processor=null;
      if (DesignChoiceConstants.LEVEL_TYPE_DYNAMIC.equals(level.getLevelType())) {
        int interval=GroupAdapter.intervalFromModel(level.getInterval());
        if (interval != IGroupDefinition.NO_INTERVAL)         processor=new DataProcessorWrapper(GroupCalculatorFactory.getGroupCalculator(interval,type,level.getIntervalBase(),level.getIntervalRange()));
      }
 else       if (DesignChoiceConstants.LEVEL_TYPE_MIRRORED.equals(level.getLevelType())) {
        Iterator it=level.staticValuesIterator();
        List dispExpr=new ArrayList();
        List filterExpr=new ArrayList();
        while (it.hasNext()) {
          RuleHandle o=(RuleHandle)it.next();
          dispExpr.add(o.getDisplayExpression());
          filterExpr.add(o.getRuleExpression());
        }
        exprString="String_Node_Str";
        for (int i=0; i < dispExpr.size(); i++) {
          String disp="String_Node_Str" + JavascriptEvalUtil.transformToJsConstants(String.valueOf(dispExpr.get(i))) + "String_Node_Str";
          String filter=String.valueOf(filterExpr.get(i));
          exprString+="String_Node_Str" + filter + "String_Node_Str"+ disp+ "String_Node_Str";
        }
      }
      temp=new ColumnMeta(level.getName(),true,processor);
      temp.setDataType(type);
    }
    metaList.add(temp);
    Iterator it=level.attributesIterator();
    while (it.hasNext()) {
      LevelAttributeHandle levelAttr=(LevelAttributeHandle)it.next();
      ColumnMeta meta=new ColumnMeta(OlapExpressionUtil.getAttributeColumnName(level.getName(),levelAttr.getName()),false,null);
      meta.setDataType(ModelAdapter.adaptModelDataType(levelAttr.getDataType()));
      metaList.add(meta);
      query.addResultSetExpression(meta.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(levelAttr.getName())));
    }
    query.addResultSetExpression(level.getName(),new ScriptExpression(exprString));
    GroupDefinition gd=new GroupDefinition();
    gd.setKeyExpression(ExpressionUtil.createJSRowExpression(level.getName()));
    if (level.getLevelType() != null) {
      gd.setIntervalRange(level.getIntervalRange());
      gd.setIntervalStart(level.getIntervalBase());
      gd.setInterval(GroupAdapter.intervalFromModel(level.getInterval()));
    }
    query.addGroup(gd);
  }
  if (timeLevelName != null) {
    populateSpecialLevel(query,metaList,timeLevelName,DataType.DATE_TYPE);
  }
  if (leafLevelName != null) {
    populateSpecialLevel(query,metaList,leafLevelName,DataType.STRING_TYPE);
  }
}

Fixed version (ground truth):
/** 
 * @param query
 * @param resultMetaList
 * @param levelNameColumnNamePair
 * @param hierHandle
 * @throws AdapterException 
 */
private void prepareLevels(QueryDefinition query,TabularHierarchyHandle hierHandle,List metaList,String timeLevelName,String leafLevelName) throws AdapterException {
  List levels=hierHandle.getContents(TabularHierarchyHandle.LEVELS_PROP);
  for (int j=0; j < levels.size(); j++) {
    TabularLevelHandle level=(TabularLevelHandle)levels.get(j);
    ColumnMeta temp=null;
    String exprString=ExpressionUtil.createJSDataSetRowExpression(level.getColumnName());
    int type=ModelAdapter.adaptModelDataType(level.getDataType());
    if (type == DataType.UNKNOWN_TYPE || type == DataType.ANY_TYPE)     type=DataType.STRING_TYPE;
    if (isTimeType(type)) {
      temp=new ColumnMeta(level.getName(),true,new TimeValueProcessor(level.getDateTimeLevelType()));
      temp.setDataType(DataType.INTEGER_TYPE);
    }
 else {
      IDataProcessor processor=null;
      if (DesignChoiceConstants.LEVEL_TYPE_DYNAMIC.equals(level.getLevelType())) {
        int interval=GroupAdapter.intervalFromModel(level.getInterval());
        if (interval != IGroupDefinition.NO_INTERVAL)         processor=new DataProcessorWrapper(GroupCalculatorFactory.getGroupCalculator(interval,type,level.getIntervalBase(),level.getIntervalRange()));
      }
 else       if (DesignChoiceConstants.LEVEL_TYPE_MIRRORED.equals(level.getLevelType())) {
        Iterator it=level.staticValuesIterator();
        List dispExpr=new ArrayList();
        List filterExpr=new ArrayList();
        while (it.hasNext()) {
          RuleHandle o=(RuleHandle)it.next();
          dispExpr.add(o.getDisplayExpression());
          filterExpr.add(o.getRuleExpression());
        }
        exprString="String_Node_Str";
        for (int i=0; i < dispExpr.size(); i++) {
          String disp="String_Node_Str" + JavascriptEvalUtil.transformToJsConstants(String.valueOf(dispExpr.get(i))) + "String_Node_Str";
          String filter=String.valueOf(filterExpr.get(i));
          exprString+="String_Node_Str" + filter + "String_Node_Str"+ disp+ "String_Node_Str";
        }
      }
      temp=new ColumnMeta(level.getName(),true,processor);
      temp.setDataType(type);
    }
    metaList.add(temp);
    Iterator it=level.attributesIterator();
    while (it.hasNext()) {
      LevelAttributeHandle levelAttr=(LevelAttributeHandle)it.next();
      ColumnMeta meta=new ColumnMeta(OlapExpressionUtil.getAttributeColumnName(level.getName(),levelAttr.getName()),false,null);
      meta.setDataType(ModelAdapter.adaptModelDataType(levelAttr.getDataType()));
      metaList.add(meta);
      query.addResultSetExpression(meta.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(levelAttr.getName())));
    }
    query.addResultSetExpression(level.getName(),new ScriptExpression(exprString));
    GroupDefinition gd=new GroupDefinition();
    gd.setKeyExpression(ExpressionUtil.createJSRowExpression(level.getName()));
    if (level.getLevelType() != null) {
      gd.setIntervalRange(level.getIntervalRange());
      gd.setIntervalStart(level.getIntervalBase());
      gd.setInterval(GroupAdapter.intervalFromModel(level.getInterval()));
    }
    query.addGroup(gd);
  }
  if (timeLevelName != null) {
    populateSpecialLevel(query,metaList,timeLevelName,DataType.DATE_TYPE);
  }
  if (leafLevelName != null) {
    populateSpecialLevel(query,metaList,leafLevelName,DataType.STRING_TYPE);
  }
}