Program: 69286
Project: 69286
Buggy source:
private Chart getConvertedChart(Chart currentChart,String sNewSubType,Orientation newOrientation,String sNewDimension){
  Chart helperModel=currentChart.copyInstance();
  ChartCacheManager.getInstance().cacheSeries(ChartUIUtil.getAllOrthogonalSeriesDefinitions(helperModel));
  if ((currentChart instanceof ChartWithAxes)) {
    if (currentChart.getType().equals(TYPE_LITERAL)) {
      if (!currentChart.getSubType().equals(sNewSubType)) {
        currentChart.setSubType(sNewSubType);
        EList axes=((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes();
        for (int i=0; i < axes.size(); i++) {
          ((Axis)axes.get(i)).setPercent(false);
          EList seriesdefinitions=((Axis)axes.get(i)).getSeriesDefinitions();
          for (int j=0; j < seriesdefinitions.size(); j++) {
            Series series=((SeriesDefinition)seriesdefinitions.get(j)).getDesignTimeSeries();
            series.setStacked(false);
          }
        }
      }
      if (currentChart instanceof ChartWithAxes && !((ChartWithAxes)currentChart).getOrientation().equals(newOrientation)) {
        ((ChartWithAxes)currentChart).setOrientation(newOrientation);
      }
      return currentChart;
    }
 else     if (currentChart.getType().equals(LineChart.TYPE_LITERAL) || currentChart.getType().equals(AreaChart.TYPE_LITERAL) || currentChart.getType().equals(BarChart.TYPE_LITERAL)|| currentChart.getType().equals(TubeChart.TYPE_LITERAL)|| currentChart.getType().equals(ConeChart.TYPE_LITERAL)|| currentChart.getType().equals(PyramidChart.TYPE_LITERAL)|| currentChart.getType().equals(ScatterChart.TYPE_LITERAL)|| currentChart.getType().equals(StockChart.TYPE_LITERAL)|| currentChart.getType().equals(BubbleChart.TYPE_LITERAL)|| currentChart.getType().equals(DifferenceChart.TYPE_LITERAL)) {
      currentChart.setType(TYPE_LITERAL);
      ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).setCategoryAxis(true);
      currentChart.setSubType(sNewSubType);
      currentChart.getTitle().getLabel().getCaption().setValue(CHART_TITLE);
      EList axes=((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes();
      for (int i=0, seriesIndex=0; i < axes.size(); i++) {
        ((Axis)axes.get(i)).setPercent(false);
        ((Axis)axes.get(i)).setType(AxisType.DATE_TIME_LITERAL);
        EList seriesdefinitions=((Axis)axes.get(i)).getSeriesDefinitions();
        for (int j=0; j < seriesdefinitions.size(); j++) {
          Series series=((SeriesDefinition)seriesdefinitions.get(j)).getDesignTimeSeries();
          series=getConvertedSeries(series,seriesIndex++);
          series.setStacked(false);
          ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().clear();
          ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().add(series);
        }
      }
      currentChart.setSampleData(getConvertedSampleData(currentChart.getSampleData(),((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getType()));
    }
 else {
      return null;
    }
  }
 else {
    currentChart=ChartWithAxesImpl.create();
    currentChart.setType(TYPE_LITERAL);
    currentChart.setSubType(sNewSubType);
    ((ChartWithAxes)currentChart).setOrientation(newOrientation);
    currentChart.setDimension(getDimensionFor(sNewDimension));
    ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).setOrientation(Orientation.HORIZONTAL_LITERAL);
    ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).setType(AxisType.TEXT_LITERAL);
    ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).setCategoryAxis(true);
    ((Axis)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes().get(0)).setOrientation(Orientation.VERTICAL_LITERAL);
    ((Axis)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes().get(0)).setType(AxisType.DATE_TIME_LITERAL);
    currentChart.setBlock(helperModel.getBlock());
    currentChart.setDescription(helperModel.getDescription());
    currentChart.setGridColumnCount(helperModel.getGridColumnCount());
    currentChart.setSampleData(getConvertedSampleData(helperModel.getSampleData(),((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getType()));
    currentChart.setScript(helperModel.getScript());
    currentChart.setSeriesThickness(helperModel.getSeriesThickness());
    currentChart.setUnits(helperModel.getUnits());
    if (helperModel.getType().equals(PieChart.TYPE_LITERAL) || helperModel.getType().equals(MeterChart.TYPE_LITERAL)) {
      ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().clear();
      ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().add(((ChartWithoutAxes)helperModel).getSeriesDefinitions().get(0));
      ((Axis)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes().get(0)).getSeriesDefinitions().clear();
      ((Axis)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes().get(0)).getSeriesDefinitions().addAll(((SeriesDefinition)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().get(0)).getSeriesDefinitions());
      Series series=((SeriesDefinition)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().get(0)).getDesignTimeSeries();
      ((SeriesDefinition)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().get(0)).getSeries().clear();
      ((SeriesDefinition)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().get(0)).getSeries().add(series);
      EList seriesdefinitions=((Axis)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes().get(0)).getSeriesDefinitions();
      for (int j=0; j < seriesdefinitions.size(); j++) {
        series=((SeriesDefinition)seriesdefinitions.get(j)).getDesignTimeSeries();
        series=getConvertedSeries(series,j);
        series.getLabel().setVisible(false);
        series.setStacked(false);
        ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().clear();
        ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().add(series);
      }
    }
 else {
      return null;
    }
    currentChart.getLegend().setItemType(LegendItemType.SERIES_LITERAL);
    currentChart.getTitle().getLabel().getCaption().setValue(CHART_TITLE);
  }
  if (currentChart instanceof ChartWithAxes && !((ChartWithAxes)currentChart).getOrientation().equals(newOrientation)) {
    ((ChartWithAxes)currentChart).setOrientation(newOrientation);
  }
  if (!currentChart.getDimension().equals(getDimensionFor(sNewDimension))) {
    currentChart.setDimension(getDimensionFor(sNewDimension));
  }
  return currentChart;
}

Fixed version (ground truth):
private Chart getConvertedChart(Chart currentChart,String sNewSubType,Orientation newOrientation,String sNewDimension){
  Chart helperModel=currentChart.copyInstance();
  ChartCacheManager.getInstance().cacheSeries(ChartUIUtil.getAllOrthogonalSeriesDefinitions(helperModel));
  if ((currentChart instanceof ChartWithAxes)) {
    if (currentChart.getType().equals(TYPE_LITERAL)) {
      if (!currentChart.getSubType().equals(sNewSubType)) {
        currentChart.setSubType(sNewSubType);
        EList axes=((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes();
        for (int i=0; i < axes.size(); i++) {
          ((Axis)axes.get(i)).setPercent(false);
          EList seriesdefinitions=((Axis)axes.get(i)).getSeriesDefinitions();
          for (int j=0; j < seriesdefinitions.size(); j++) {
            Series series=((SeriesDefinition)seriesdefinitions.get(j)).getDesignTimeSeries();
            series.setStacked(false);
          }
        }
      }
      if (currentChart instanceof ChartWithAxes && !((ChartWithAxes)currentChart).getOrientation().equals(newOrientation)) {
        ((ChartWithAxes)currentChart).setOrientation(newOrientation);
      }
      return currentChart;
    }
 else     if (currentChart.getType().equals(LineChart.TYPE_LITERAL) || currentChart.getType().equals(AreaChart.TYPE_LITERAL) || currentChart.getType().equals(BarChart.TYPE_LITERAL)|| currentChart.getType().equals(TubeChart.TYPE_LITERAL)|| currentChart.getType().equals(ConeChart.TYPE_LITERAL)|| currentChart.getType().equals(PyramidChart.TYPE_LITERAL)|| currentChart.getType().equals(ScatterChart.TYPE_LITERAL)|| currentChart.getType().equals(StockChart.TYPE_LITERAL)|| currentChart.getType().equals(BubbleChart.TYPE_LITERAL)|| currentChart.getType().equals(DifferenceChart.TYPE_LITERAL)) {
      currentChart.setType(TYPE_LITERAL);
      ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).setCategoryAxis(true);
      currentChart.setSubType(sNewSubType);
      currentChart.getTitle().getLabel().getCaption().setValue(CHART_TITLE);
      EList axes=((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes();
      for (int i=0, seriesIndex=0; i < axes.size(); i++) {
        ((Axis)axes.get(i)).setPercent(false);
        ((Axis)axes.get(i)).setType(AxisType.DATE_TIME_LITERAL);
        EList seriesdefinitions=((Axis)axes.get(i)).getSeriesDefinitions();
        for (int j=0; j < seriesdefinitions.size(); j++) {
          Series series=((SeriesDefinition)seriesdefinitions.get(j)).getDesignTimeSeries();
          series=getConvertedSeries(series,seriesIndex++);
          series.setStacked(false);
          ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().clear();
          ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().add(series);
        }
      }
      currentChart.setSampleData(getConvertedSampleData(currentChart.getSampleData(),((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getType()));
    }
 else {
      return null;
    }
  }
 else {
    currentChart=ChartWithAxesImpl.create();
    currentChart.setType(TYPE_LITERAL);
    currentChart.setSubType(sNewSubType);
    ((ChartWithAxes)currentChart).setOrientation(newOrientation);
    currentChart.setDimension(getDimensionFor(sNewDimension));
    ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).setOrientation(Orientation.HORIZONTAL_LITERAL);
    ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).setType(AxisType.TEXT_LITERAL);
    ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).setCategoryAxis(true);
    ((Axis)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes().get(0)).setOrientation(Orientation.VERTICAL_LITERAL);
    ((Axis)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes().get(0)).setType(AxisType.DATE_TIME_LITERAL);
    currentChart.setBlock(helperModel.getBlock());
    currentChart.setDescription(helperModel.getDescription());
    currentChart.setGridColumnCount(helperModel.getGridColumnCount());
    currentChart.setSampleData(getConvertedSampleData(helperModel.getSampleData(),((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getType()));
    currentChart.setScript(helperModel.getScript());
    currentChart.setSeriesThickness(helperModel.getSeriesThickness());
    currentChart.setUnits(helperModel.getUnits());
    if (helperModel.getType().equals(PieChart.TYPE_LITERAL) || helperModel.getType().equals(MeterChart.TYPE_LITERAL)) {
      ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().clear();
      ((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().add(((ChartWithoutAxes)helperModel).getSeriesDefinitions().get(0));
      ((Axis)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes().get(0)).getSeriesDefinitions().clear();
      ((Axis)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes().get(0)).getSeriesDefinitions().addAll(((SeriesDefinition)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().get(0)).getSeriesDefinitions());
      Series series=((SeriesDefinition)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().get(0)).getDesignTimeSeries();
      ((SeriesDefinition)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().get(0)).getSeries().clear();
      ((SeriesDefinition)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getSeriesDefinitions().get(0)).getSeries().add(series);
      EList seriesdefinitions=((Axis)((Axis)((ChartWithAxes)currentChart).getAxes().get(0)).getAssociatedAxes().get(0)).getSeriesDefinitions();
      for (int j=0; j < seriesdefinitions.size(); j++) {
        series=((SeriesDefinition)seriesdefinitions.get(j)).getDesignTimeSeries();
        series=getConvertedSeries(series,j);
        series.getLabel().setVisible(false);
        series.setStacked(false);
        ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().clear();
        ((SeriesDefinition)seriesdefinitions.get(j)).getSeries().add(series);
      }
    }
 else {
      return null;
    }
    currentChart.getLegend().setItemType(LegendItemType.SERIES_LITERAL);
    currentChart.getTitle().getLabel().getCaption().setValue(CHART_TITLE);
  }
  if (currentChart instanceof ChartWithAxes && !((ChartWithAxes)currentChart).getOrientation().equals(newOrientation)) {
    ((ChartWithAxes)currentChart).setOrientation(newOrientation);
  }
  if (!currentChart.getDimension().equals(getDimensionFor(sNewDimension))) {
    currentChart.setDimension(getDimensionFor(sNewDimension));
  }
  ChartUIUtil.updateDefaultAggregations(currentChart);
  return currentChart;
}