Program: 73509
Project: 73509
Buggy source:
public IBaseCubeQueryDefinition createCubeQuery(IDataQueryDefinition parent) throws BirtException {
  CubeHandle cubeHandle=handle.getCube();
  ICubeQueryDefinition cubeQuery=null;
  if (cubeHandle == null) {
    cubeHandle=ChartXTabUtil.getBindingCube(handle);
    if (cubeHandle == null) {
      throw new ChartException(ChartReportItemPlugin.ID,ChartException.NULL_DATASET,Messages.getString("String_Node_Str"));
    }
    CrosstabReportItemHandle xtab=ChartXTabUtil.getXtabContainerCell(handle).getCrosstab();
    LevelViewHandle levelColumn=ChartXTabUtil.getInnermostLevelCell(xtab,ICrosstabConstants.COLUMN_AXIS_TYPE);
    LevelViewHandle levelRow=ChartXTabUtil.getInnermostLevelCell(xtab,ICrosstabConstants.ROW_AXIS_TYPE);
    if (cm instanceof ChartWithAxes) {
      if (((ChartWithAxes)cm).isTransposed()) {
        if (levelColumn != null) {
          ISubCubeQueryDefinition subCubeQuery=ChartXTabUtil.getCubeElementFactory().createSubCubeQuery(cubeHandle.getQualifiedName());
          subCubeQuery.setStartingLevelOnColumn(ChartXTabUtil.createDimensionExpression(levelColumn.getCubeLevel()));
          return subCubeQuery;
        }
 else         if (ChartXTabUtil.getLevelCount(xtab,ICrosstabConstants.ROW_AXIS_TYPE) > 1) {
          ISubCubeQueryDefinition subCubeQuery=ChartXTabUtil.getCubeElementFactory().createSubCubeQuery(cubeHandle.getQualifiedName());
          subCubeQuery.setStartingLevelOnRow(ChartXTabUtil.createDimensionExpression(levelRow.getCubeLevel()));
          return subCubeQuery;
        }
      }
 else {
        if (levelRow != null) {
          ISubCubeQueryDefinition subCubeQuery=ChartXTabUtil.getCubeElementFactory().createSubCubeQuery(cubeHandle.getQualifiedName());
          subCubeQuery.setStartingLevelOnRow(ChartXTabUtil.createDimensionExpression(levelRow.getCubeLevel()));
          return subCubeQuery;
        }
 else         if (ChartXTabUtil.getLevelCount(xtab,ICrosstabConstants.COLUMN_AXIS_TYPE) > 1) {
          ISubCubeQueryDefinition subCubeQuery=ChartXTabUtil.getCubeElementFactory().createSubCubeQuery(cubeHandle.getQualifiedName());
          subCubeQuery.setStartingLevelOnColumn(ChartXTabUtil.createDimensionExpression(levelColumn.getCubeLevel()));
          return subCubeQuery;
        }
      }
    }
  }
  cubeQuery=ChartXTabUtil.getCubeElementFactory().createCubeQuery(cubeHandle.getQualifiedName());
  initBindings(cubeQuery,cubeHandle);
  List sdList=getAllSeriesDefinitions(cm);
  for (int i=0; i < sdList.size(); i++) {
    SeriesDefinition sd=(SeriesDefinition)sdList.get(i);
    List queryList=sd.getDesignTimeSeries().getDataDefinition();
    for (int j=0; j < queryList.size(); j++) {
      Query query=(Query)queryList.get(j);
      bindSeriesQuery(query,cubeQuery,cubeHandle);
    }
    bindSeriesQuery(sd.getQuery(),cubeQuery,cubeHandle);
  }
  for (int i=0; i < sdList.size(); i++) {
    SeriesDefinition sd=(SeriesDefinition)sdList.get(i);
    addSorting(cubeQuery,cubeHandle,sd,i);
  }
  addCubeFilter(cubeQuery);
  return cubeQuery;
}

Fixed version (ground truth):
public IBaseCubeQueryDefinition createCubeQuery(IDataQueryDefinition parent) throws BirtException {
  CubeHandle cubeHandle=handle.getCube();
  ICubeQueryDefinition cubeQuery=null;
  if (cubeHandle == null) {
    cubeHandle=ChartXTabUtil.getBindingCube(handle);
    if (cubeHandle == null) {
      throw new ChartException(ChartReportItemPlugin.ID,ChartException.NULL_DATASET,Messages.getString("String_Node_Str"));
    }
    CrosstabReportItemHandle xtab=ChartXTabUtil.getXtabContainerCell(handle).getCrosstab();
    LevelViewHandle levelColumn=ChartXTabUtil.getInnermostLevel(xtab,ICrosstabConstants.COLUMN_AXIS_TYPE);
    LevelViewHandle levelRow=ChartXTabUtil.getInnermostLevel(xtab,ICrosstabConstants.ROW_AXIS_TYPE);
    if (cm instanceof ChartWithAxes) {
      if (((ChartWithAxes)cm).isTransposed()) {
        if (levelColumn != null) {
          ISubCubeQueryDefinition subCubeQuery=ChartXTabUtil.getCubeElementFactory().createSubCubeQuery(cubeHandle.getQualifiedName());
          subCubeQuery.setStartingLevelOnColumn(ChartXTabUtil.createDimensionExpression(levelColumn.getCubeLevel()));
          return subCubeQuery;
        }
 else         if (ChartXTabUtil.getLevelCount(xtab,ICrosstabConstants.ROW_AXIS_TYPE) > 1) {
          ISubCubeQueryDefinition subCubeQuery=ChartXTabUtil.getCubeElementFactory().createSubCubeQuery(cubeHandle.getQualifiedName());
          subCubeQuery.setStartingLevelOnRow(ChartXTabUtil.createDimensionExpression(levelRow.getCubeLevel()));
          return subCubeQuery;
        }
      }
 else {
        if (levelRow != null) {
          ISubCubeQueryDefinition subCubeQuery=ChartXTabUtil.getCubeElementFactory().createSubCubeQuery(cubeHandle.getQualifiedName());
          subCubeQuery.setStartingLevelOnRow(ChartXTabUtil.createDimensionExpression(levelRow.getCubeLevel()));
          return subCubeQuery;
        }
 else         if (ChartXTabUtil.getLevelCount(xtab,ICrosstabConstants.COLUMN_AXIS_TYPE) > 1) {
          ISubCubeQueryDefinition subCubeQuery=ChartXTabUtil.getCubeElementFactory().createSubCubeQuery(cubeHandle.getQualifiedName());
          subCubeQuery.setStartingLevelOnColumn(ChartXTabUtil.createDimensionExpression(levelColumn.getCubeLevel()));
          return subCubeQuery;
        }
      }
    }
  }
  cubeQuery=ChartXTabUtil.getCubeElementFactory().createCubeQuery(cubeHandle.getQualifiedName());
  initBindings(cubeQuery,cubeHandle);
  List sdList=getAllSeriesDefinitions(cm);
  for (int i=0; i < sdList.size(); i++) {
    SeriesDefinition sd=(SeriesDefinition)sdList.get(i);
    List queryList=sd.getDesignTimeSeries().getDataDefinition();
    for (int j=0; j < queryList.size(); j++) {
      Query query=(Query)queryList.get(j);
      bindSeriesQuery(query,cubeQuery,cubeHandle);
    }
    bindSeriesQuery(sd.getQuery(),cubeQuery,cubeHandle);
  }
  for (int i=0; i < sdList.size(); i++) {
    SeriesDefinition sd=(SeriesDefinition)sdList.get(i);
    addSorting(cubeQuery,cubeHandle,sd,i);
  }
  addCubeFilter(cubeQuery);
  return cubeQuery;
}