Program: 140164
Project: 140164
Buggy source:
static IDataEntity createDataset(EIndicatorChartType chartType,List<IndicatorUnit> indicatorUnitList){
  CustomerDataset dataset=new CustomerDataset();
  for (int index=0; index < indicatorUnitList.size(); index++) {
    IndicatorUnit unit=indicatorUnitList.get(index);
    IndicatorCommonUtil.compositeIndicatorMap(unit);
  }
switch (chartType) {
case FREQUENCE_STATISTICS:
case LOW_FREQUENCE_STATISTICS:
case PATTERN_FREQUENCE_STATISTICS:
case PATTERN_LOW_FREQUENCE_STATISTICS:
    for (    IndicatorUnit unit : indicatorUnitList) {
      if (unit.isExcuted()) {
        FrequencyExt[] frequencyExt=(FrequencyExt[])unit.getValue();
        if (chartType == EIndicatorChartType.FREQUENCE_STATISTICS || chartType == EIndicatorChartType.PATTERN_FREQUENCE_STATISTICS) {
          ComparatorsFactory.sort(frequencyExt,ComparatorsFactory.FREQUENCY_COMPARATOR_ID);
        }
        if (chartType == EIndicatorChartType.LOW_FREQUENCE_STATISTICS || chartType == EIndicatorChartType.PATTERN_LOW_FREQUENCE_STATISTICS) {
          ComparatorsFactory.sort(frequencyExt,ComparatorsFactory.LOW_FREQUENCY_COMPARATOR_ID);
        }
        int numOfShown=frequencyExt.length;
        IndicatorParameters parameters=unit.getIndicator().getParameters();
        if (parameters != null) {
          if (parameters.getTopN() < frequencyExt.length) {
            numOfShown=parameters.getTopN();
          }
        }
        for (int i=0; i < numOfShown; i++) {
          final FrequencyExt freqExt=frequencyExt[i];
          final String keyLabel=String.valueOf(freqExt.getKey());
          dataset.addValue(freqExt.getValue(),"String_Node_Str",keyLabel);
          ChartDataEntity entity=new ChartDataEntity();
          entity.setIndicator(unit.getIndicator());
          entity.setLabelNull(freqExt.getKey() == null);
          entity.setLabel(keyLabel);
          entity.setValue(String.valueOf(freqExt.getValue()));
          entity.setPercent(String.valueOf(freqExt.getFrequency()));
          dataset.addDataEntity(entity);
        }
      }
    }
  break;
case SQL_PATTERN_MATCHING:
case PATTERN_MATCHING:
for (IndicatorUnit unit : indicatorUnitList) {
  if (unit.isExcuted()) {
    String label=unit.getIndicatorName();
    PatternMatchingExt patternExt=(PatternMatchingExt)unit.getValue();
    double notMathCount=patternExt.getNotMatchingValueCount();
    double machCount=patternExt.getMatchingValueCount();
    dataset.addValue(machCount,"String_Node_Str",label);
    dataset.addValue(notMathCount,"String_Node_Str",label);
    PatternChartDataEntity patternEntity=new PatternChartDataEntity();
    patternEntity.setIndicator(unit.getIndicator());
    patternEntity.setLabel(unit.getIndicatorName());
    patternEntity.setNumMatch(String.valueOf(machCount));
    patternEntity.setNumNoMatch(String.valueOf(notMathCount));
    dataset.addDataEntity(patternEntity);
  }
}
break;
case TEXT_STATISTICS:
ComparatorsFactory.sort(indicatorUnitList,ComparatorsFactory.TEXT_STATISTICS_COMPARATOR_ID);
case SIMPLE_STATISTICS:
for (IndicatorUnit unit : indicatorUnitList) {
if (unit.isExcuted()) {
double value=Double.parseDouble(unit.getValue().toString());
String label=unit.getIndicatorName();
dataset.addValue(value,label,"String_Node_Str");
ChartDataEntity entity=new ChartDataEntity();
entity.setIndicator(unit.getIndicator());
entity.setLabel(label);
entity.setValue(String.valueOf(value));
entity.setPercent(String.valueOf(value / unit.getIndicator().getCount()));
dataset.addDataEntity(entity);
}
}
break;
case MODE_INDICATOR:
for (IndicatorUnit unit : indicatorUnitList) {
if (unit.isExcuted()) {
String label=unit.getIndicatorName();
ChartDataEntity entity=new ChartDataEntity();
entity.setIndicator(unit.getIndicator());
entity.setLabel(label);
entity.setValue(unit.getValue().toString());
dataset.addDataEntity(entity);
}
}
break;
case SUMMARY_STATISTICS:
CustomerBoxDataset defaultDataset=new CustomerBoxDataset();
Map<IndicatorEnum,Double> map=new HashMap<IndicatorEnum,Double>();
for (IndicatorUnit unit : indicatorUnitList) {
if (unit.isExcuted()) {
double doubleValue=Double.parseDouble(unit.getValue().toString());
map.put(unit.getType(),doubleValue);
ChartDataEntity entity=new ChartDataEntity();
entity.setIndicator(unit.getIndicator());
entity.setLabel(unit.getIndicatorName());
entity.setValue(String.valueOf(unit.getValue()));
defaultDataset.addDataEntity(entity);
dataset.addDataEntity(entity);
}
}
if (map.size() == 6) {
dataset=null;
BoxAndWhiskerItem item=createBoxAndWhiskerItem(map.get(IndicatorEnum.MeanIndicatorEnum),map.get(IndicatorEnum.MedianIndicatorEnum),map.get(IndicatorEnum.LowerQuartileIndicatorEnum),map.get(IndicatorEnum.UpperQuartileIndicatorEnum),map.get(IndicatorEnum.MinValueIndicatorEnum),map.get(IndicatorEnum.MaxValueIndicatorEnum),null);
defaultDataset.add(item,"String_Node_Str","String_Node_Str");
Double range=map.get(IndicatorEnum.MaxValueIndicatorEnum) - map.get(IndicatorEnum.MinValueIndicatorEnum);
Double quartile=map.get(IndicatorEnum.UpperQuartileIndicatorEnum) - map.get(IndicatorEnum.LowerQuartileIndicatorEnum);
defaultDataset.addDataEntity(new ChartDataEntity(null,IndicatorEnum.RangeIndicatorEnum.getLabel(),range.toString()));
defaultDataset.addDataEntity(new ChartDataEntity(null,IndicatorEnum.IQRIndicatorEnum.getLabel(),quartile.toString()));
return defaultDataset;
}
 else {
defaultDataset=null;
for (IndicatorEnum indicatorEnum : map.keySet()) {
dataset.addValue(map.get(indicatorEnum),"String_Node_Str",indicatorEnum.getLabel());
}
}
break;
default :
return null;
}
return dataset;
}

Fixed version (ground truth):
static IDataEntity createDataset(EIndicatorChartType chartType,List<IndicatorUnit> indicatorUnitList){
  CustomerDataset dataset=new CustomerDataset();
  for (int index=0; index < indicatorUnitList.size(); index++) {
    IndicatorUnit unit=indicatorUnitList.get(index);
    IndicatorCommonUtil.compositeIndicatorMap(unit);
  }
switch (chartType) {
case FREQUENCE_STATISTICS:
case LOW_FREQUENCE_STATISTICS:
case PATTERN_FREQUENCE_STATISTICS:
case PATTERN_LOW_FREQUENCE_STATISTICS:
    for (    IndicatorUnit unit : indicatorUnitList) {
      if (unit.isExcuted()) {
        FrequencyExt[] frequencyExt=(FrequencyExt[])unit.getValue();
        if (chartType == EIndicatorChartType.FREQUENCE_STATISTICS || chartType == EIndicatorChartType.PATTERN_FREQUENCE_STATISTICS) {
          ComparatorsFactory.sort(frequencyExt,ComparatorsFactory.FREQUENCY_COMPARATOR_ID);
        }
        if (chartType == EIndicatorChartType.LOW_FREQUENCE_STATISTICS || chartType == EIndicatorChartType.PATTERN_LOW_FREQUENCE_STATISTICS) {
          ComparatorsFactory.sort(frequencyExt,ComparatorsFactory.LOW_FREQUENCY_COMPARATOR_ID);
        }
        int numOfShown=frequencyExt.length;
        IndicatorParameters parameters=unit.getIndicator().getParameters();
        if (parameters != null) {
          if (parameters.getTopN() < frequencyExt.length) {
            numOfShown=parameters.getTopN();
          }
        }
        for (int i=0; i < numOfShown; i++) {
          final FrequencyExt freqExt=frequencyExt[i];
          final String keyLabel=String.valueOf(freqExt.getKey());
          dataset.addValue(freqExt.getValue(),"String_Node_Str",keyLabel);
          ChartDataEntity entity=new ChartDataEntity();
          entity.setIndicator(unit.getIndicator());
          entity.setLabelNull(freqExt.getKey() == null);
          entity.setLabel(keyLabel);
          entity.setValue(String.valueOf(freqExt.getValue()));
          entity.setPercent(String.valueOf(freqExt.getFrequency()));
          dataset.addDataEntity(entity);
        }
      }
    }
  break;
case SQL_PATTERN_MATCHING:
case PATTERN_MATCHING:
for (IndicatorUnit unit : indicatorUnitList) {
  if (unit.isExcuted()) {
    String label=unit.getIndicatorName();
    PatternMatchingExt patternExt=(PatternMatchingExt)unit.getValue();
    double notMathCount=patternExt.getNotMatchingValueCount();
    double machCount=patternExt.getMatchingValueCount();
    dataset.addValue(machCount,"String_Node_Str",label);
    dataset.addValue(notMathCount,"String_Node_Str",label);
    PatternChartDataEntity patternEntity=new PatternChartDataEntity();
    patternEntity.setIndicator(unit.getIndicator());
    patternEntity.setLabel(unit.getIndicatorName());
    patternEntity.setNumMatch(String.valueOf(machCount));
    patternEntity.setNumNoMatch(String.valueOf(notMathCount));
    dataset.addDataEntity(patternEntity);
  }
}
break;
case TEXT_STATISTICS:
ComparatorsFactory.sort(indicatorUnitList,ComparatorsFactory.TEXT_STATISTICS_COMPARATOR_ID);
case SIMPLE_STATISTICS:
for (IndicatorUnit unit : indicatorUnitList) {
if (unit.isExcuted()) {
double value=Double.parseDouble(unit.getValue().toString());
String label=unit.getIndicatorName();
dataset.addValue(value,label,"String_Node_Str");
ChartDataEntity entity=new ChartDataEntity();
entity.setIndicator(unit.getIndicator());
entity.setLabel(label);
entity.setValue(String.valueOf(value));
entity.setPercent(String.valueOf(value / unit.getIndicator().getCount()));
dataset.addDataEntity(entity);
}
}
break;
case MODE_INDICATOR:
for (IndicatorUnit unit : indicatorUnitList) {
if (unit.isExcuted()) {
String label=unit.getIndicatorName();
ChartDataEntity entity=new ChartDataEntity();
entity.setIndicator(unit.getIndicator());
entity.setLabel(label);
entity.setValue(unit.getValue().toString());
dataset.addDataEntity(entity);
}
}
break;
case SUMMARY_STATISTICS:
CustomerBoxDataset defaultDataset=new CustomerBoxDataset();
Map<IndicatorEnum,Double> map=new HashMap<IndicatorEnum,Double>();
for (IndicatorUnit unit : indicatorUnitList) {
if (unit.isExcuted()) {
double doubleValue=Double.parseDouble(unit.getValue().toString());
map.put(unit.getType(),doubleValue);
ChartDataEntity entity=new ChartDataEntity();
entity.setIndicator(unit.getIndicator());
entity.setLabel(unit.getIndicatorName());
entity.setValue(String.valueOf(unit.getValue()));
defaultDataset.addDataEntity(entity);
dataset.addDataEntity(entity);
}
}
if (map.containsKey(IndicatorEnum.MaxValueIndicatorEnum) && map.containsKey(IndicatorEnum.MinValueIndicatorEnum)) {
Double range=map.get(IndicatorEnum.MaxValueIndicatorEnum) - map.get(IndicatorEnum.MinValueIndicatorEnum);
ChartDataEntity entity=new ChartDataEntity(null,IndicatorEnum.RangeIndicatorEnum.getLabel(),range.toString());
defaultDataset.addDataEntity(entity);
dataset.addDataEntity(entity);
}
if (map.containsKey(IndicatorEnum.UpperQuartileIndicatorEnum) && map.containsKey(IndicatorEnum.LowerQuartileIndicatorEnum)) {
Double quartile=map.get(IndicatorEnum.UpperQuartileIndicatorEnum) - map.get(IndicatorEnum.LowerQuartileIndicatorEnum);
ChartDataEntity entity=new ChartDataEntity(null,IndicatorEnum.IQRIndicatorEnum.getLabel(),quartile.toString());
defaultDataset.addDataEntity(entity);
dataset.addDataEntity(entity);
}
if (map.size() == 6) {
dataset=null;
BoxAndWhiskerItem item=createBoxAndWhiskerItem(map.get(IndicatorEnum.MeanIndicatorEnum),map.get(IndicatorEnum.MedianIndicatorEnum),map.get(IndicatorEnum.LowerQuartileIndicatorEnum),map.get(IndicatorEnum.UpperQuartileIndicatorEnum),map.get(IndicatorEnum.MinValueIndicatorEnum),map.get(IndicatorEnum.MaxValueIndicatorEnum),null);
defaultDataset.add(item,"String_Node_Str","String_Node_Str");
return defaultDataset;
}
 else {
defaultDataset=null;
for (IndicatorEnum indicatorEnum : map.keySet()) {
dataset.addValue(map.get(indicatorEnum),"String_Node_Str",indicatorEnum.getLabel());
}
}
break;
default :
return null;
}
return dataset;
}