Program: 75400
Project: 75400
Buggy source:
/** 
 * @param query
 * @param resultMetaList
 * @param levelNameColumnNamePair
 * @param hierHandle
 * @throws AdapterException
 */
private void prepareLevels(QueryDefinition query,TabularHierarchyHandle hierHandle,List metaList) throws AdapterException {
  try {
    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=DataAdapterUtil.adaptModelDataType(level.getDataType());
      if (type == DataType.UNKNOWN_TYPE || type == DataType.ANY_TYPE)       type=DataType.STRING_TYPE;
      if (level.getDateTimeLevelType() != null) {
        temp=new ColumnMeta(level.getName(),true,new DataProcessorWrapper(GroupCalculatorFactory.getGroupCalculator(IGroupDefinition.NUMERIC_INTERVAL,DataType.INTEGER_TYPE,String.valueOf(getDefaultStartValue(level.getDateTimeLevelType(),level.getIntervalBase())),level.getIntervalRange())));
        temp.setDataType(DataType.INTEGER_TYPE);
        exprString=this.createDateTransformerExpr(level.getDateTimeLevelType(),exprString);
      }
 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(DataAdapterUtil.adaptModelDataType(levelAttr.getDataType()));
        metaList.add(meta);
        query.addBinding(new Binding(meta.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(levelAttr.getName()))));
      }
      if (level.getDisplayColumnName() != null) {
        ColumnMeta meta=new ColumnMeta(OlapExpressionUtil.getDisplayColumnName(level.getName()),false,null);
        meta.setDataType(DataType.STRING_TYPE);
        metaList.add(meta);
        query.addBinding(new Binding(meta.getName(),new ScriptExpression(level.getDisplayColumnName())));
      }
      query.addBinding(new Binding(level.getName(),new ScriptExpression(exprString)));
      GroupDefinition gd=new GroupDefinition(String.valueOf(query.getGroups().size()));
      gd.setKeyExpression(ExpressionUtil.createJSRowExpression(level.getName()));
      if (level.getLevelType() != null && level.getDateTimeLevelType() == null) {
        gd.setIntervalRange(level.getIntervalRange());
        gd.setIntervalStart(level.getIntervalBase());
        gd.setInterval(GroupAdapter.intervalFromModel(level.getInterval()));
      }
      if (level.getDateTimeLevelType() != null) {
        gd.setIntervalRange(level.getIntervalRange() == 0 ? 1 : level.getIntervalRange());
        gd.setIntervalStart(String.valueOf(getDefaultStartValue(level.getDateTimeLevelType(),level.getIntervalBase())));
        gd.setInterval(IGroupDefinition.NUMERIC_INTERVAL);
      }
      query.addGroup(gd);
    }
  }
 catch (  DataException e) {
    throw new AdapterException(e.getLocalizedMessage());
  }
}

Fixed version (ground truth):
/** 
 * @param query
 * @param resultMetaList
 * @param levelNameColumnNamePair
 * @param hierHandle
 * @throws AdapterException
 */
private void prepareLevels(QueryDefinition query,TabularHierarchyHandle hierHandle,List metaList) throws AdapterException {
  try {
    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=DataAdapterUtil.adaptModelDataType(level.getDataType());
      if (type == DataType.UNKNOWN_TYPE || type == DataType.ANY_TYPE)       type=DataType.STRING_TYPE;
      if (level.getDateTimeLevelType() != null) {
        temp=new ColumnMeta(level.getName(),new DataProcessorWrapper(GroupCalculatorFactory.getGroupCalculator(IGroupDefinition.NUMERIC_INTERVAL,DataType.INTEGER_TYPE,String.valueOf(getDefaultStartValue(level.getDateTimeLevelType(),level.getIntervalBase())),level.getIntervalRange())),ColumnMeta.LEVEL_KEY_TYPE);
        temp.setDataType(DataType.INTEGER_TYPE);
        exprString=this.createDateTransformerExpr(level.getDateTimeLevelType(),exprString);
      }
 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(),processor,ColumnMeta.LEVEL_KEY_TYPE);
        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()),null,ColumnMeta.UNKNOWN_TYPE);
        meta.setDataType(DataAdapterUtil.adaptModelDataType(levelAttr.getDataType()));
        metaList.add(meta);
        query.addBinding(new Binding(meta.getName(),new ScriptExpression(ExpressionUtil.createJSDataSetRowExpression(levelAttr.getName()))));
      }
      if (level.getDisplayColumnName() != null) {
        ColumnMeta meta=new ColumnMeta(OlapExpressionUtil.getDisplayColumnName(level.getName()),null,ColumnMeta.UNKNOWN_TYPE);
        meta.setDataType(DataType.STRING_TYPE);
        metaList.add(meta);
        query.addBinding(new Binding(meta.getName(),new ScriptExpression(level.getDisplayColumnName())));
      }
      query.addBinding(new Binding(level.getName(),new ScriptExpression(exprString)));
      GroupDefinition gd=new GroupDefinition(String.valueOf(query.getGroups().size()));
      gd.setKeyExpression(ExpressionUtil.createJSRowExpression(level.getName()));
      if (level.getLevelType() != null && level.getDateTimeLevelType() == null) {
        gd.setIntervalRange(level.getIntervalRange());
        gd.setIntervalStart(level.getIntervalBase());
        gd.setInterval(GroupAdapter.intervalFromModel(level.getInterval()));
      }
      if (level.getDateTimeLevelType() != null) {
        gd.setIntervalRange(level.getIntervalRange() == 0 ? 1 : level.getIntervalRange());
        gd.setIntervalStart(String.valueOf(getDefaultStartValue(level.getDateTimeLevelType(),level.getIntervalBase())));
        gd.setInterval(IGroupDefinition.NUMERIC_INTERVAL);
      }
      query.addGroup(gd);
    }
  }
 catch (  DataException e) {
    throw new AdapterException(e.getLocalizedMessage());
  }
}