Program: 56784
Project: 56784
Buggy source:
/** 
 * Exports the dataset identified through the perspectives to the file specified.
 * @param dataDomain
 * @param fileName
 * @param recordPerspective
 * @param dimensionPerspective
 * @param targetRecordIDType the id type to be used in the file. If this is null the  {@link IDCategory#getHumanReadableIDType()}will be used.
 * @param targetDimensionIDType same as targetRecordIDType for dimensions
 * @param includeClusterInfo true if you want to add information about the clustering to the file, else false
 * @return true if export was successful, else false.
 */
public static boolean export(ATableBasedDataDomain dataDomain,String fileName,Perspective recordPerspective,Perspective dimensionPerspective,IDType targetRecordIDType,IDType targetDimensionIDType,boolean includeClusterInfo){
  if (targetRecordIDType == null)   targetRecordIDType=dataDomain.getRecordIDCategory().getHumanReadableIDType();
  if (targetDimensionIDType == null)   targetDimensionIDType=dataDomain.getDimensionIDCategory().getHumanReadableIDType();
  IDType rowTargetIDType;
  IDType rowSourceIDType;
  IDType colTargetIDType;
  IDType colSourceIDType;
  VirtualArray rowVA;
  VirtualArray colVA;
  if (dataDomain.isColumnDimension()) {
    rowVA=recordPerspective.getVirtualArray();
    colVA=dimensionPerspective.getVirtualArray();
    rowTargetIDType=targetRecordIDType;
    colTargetIDType=targetDimensionIDType;
    rowSourceIDType=dataDomain.getRecordIDType();
    colSourceIDType=dataDomain.getDimensionIDType();
  }
 else {
    rowVA=dimensionPerspective.getVirtualArray();
    colVA=recordPerspective.getVirtualArray();
    rowTargetIDType=targetDimensionIDType;
    colTargetIDType=targetRecordIDType;
    rowSourceIDType=dataDomain.getDimensionIDType();
    colSourceIDType=dataDomain.getRecordIDType();
  }
  if (rowVA == null || colVA == null)   throw new IllegalArgumentException("String_Node_Str");
  IDMappingManager rowIDMappingManager=IDMappingManagerRegistry.get().getIDMappingManager(rowSourceIDType);
  IDMappingManager colIDMappingManager=IDMappingManagerRegistry.get().getIDMappingManager(colSourceIDType);
  try {
    PrintWriter out=new PrintWriter(new BufferedWriter(new FileWriter(fileName)));
    out.print("String_Node_Str");
    for (    Integer colID : colVA) {
      Set<Object> colTargetIDs=colIDMappingManager.getIDAsSet(colSourceIDType,colTargetIDType,colID);
      String id="String_Node_Str";
      for (      Object colTargetID : colTargetIDs) {
        id=colTargetID.toString();
        break;
      }
      out.print(id + "String_Node_Str");
    }
    if (includeClusterInfo && rowVA.getGroupList() != null)     out.print("String_Node_Str");
    out.println();
    int cnt=-1;
    int cluster=0;
    int example=0;
    int offset=0;
    String id;
    for (    Integer rowID : rowVA) {
      Set<Object> rowTargetIDs=rowIDMappingManager.getIDAsSet(rowSourceIDType,rowTargetIDType,rowID);
      id="String_Node_Str";
      for (      Object rowTargetID : rowTargetIDs) {
        id=rowTargetID.toString();
        break;
      }
      out.print(id + "String_Node_Str");
      for (      Integer colID : colVA) {
        if (dataDomain.isColumnDimension()) {
          out.print(dataDomain.getTable().getRawAsString(colID,rowID));
        }
 else {
          out.print(dataDomain.getTable().getRawAsString(rowID,colID));
        }
        out.print("String_Node_Str");
      }
      if (includeClusterInfo) {
        if (rowVA.getGroupList() != null) {
          if (cnt == rowVA.getGroupList().get(cluster).getSize() - 1) {
            offset=offset + rowVA.getGroupList().get(cluster).getSize();
            cluster++;
            cnt=0;
          }
 else {
            cnt++;
          }
          example=rowVA.getGroupList().get(cluster).getRepresentativeElementIndex();
          out.print(cluster + "String_Node_Str" + example+ "String_Node_Str");
        }
      }
      out.println();
    }
    if (!includeClusterInfo) {
      out.close();
      return true;
    }
    if (colVA.getGroupList() != null) {
      String clusterNr="String_Node_Str";
      String clusterRep="String_Node_Str";
      cluster=0;
      cnt=-1;
      for (      @SuppressWarnings("String_Node_Str") Integer colIndex : colVA) {
        if (cnt == colVA.getGroupList().get(cluster).getSize() - 1) {
          offset=offset + colVA.getGroupList().get(cluster).getSize();
          cluster++;
          cnt=0;
        }
 else {
          cnt++;
        }
        example=colVA.getGroupList().get(cluster).getRepresentativeElementIndex();
        clusterNr+=cluster + "String_Node_Str";
        clusterRep+=example + "String_Node_Str";
      }
      clusterNr+="String_Node_Str";
      clusterRep+="String_Node_Str";
      out.print(clusterNr);
      out.print(clusterRep);
    }
    out.close();
  }
 catch (  IOException e) {
    Logger.log(new Status(IStatus.ERROR,"String_Node_Str","String_Node_Str",e));
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Exports the dataset identified through the perspectives to the file specified.
 * @param dataDomain
 * @param fileName
 * @param recordPerspective
 * @param dimensionPerspective
 * @param targetRecordIDType the id type to be used in the file. If this is null the  {@link IDCategory#getHumanReadableIDType()}will be used.
 * @param targetDimensionIDType same as targetRecordIDType for dimensions
 * @param includeRecordClusterInfo true if you want to add information about the clustering of records to the file, else false
 * @param includeDimensionClusterInfo true if you want to add information about the clustering of dimensions to the file, else false
 * @return true if export was successful, else false.
 */
public static boolean export(ATableBasedDataDomain dataDomain,String fileName,Perspective recordPerspective,Perspective dimensionPerspective,IDType targetRecordIDType,IDType targetDimensionIDType,boolean includeRecordClusterInfo,boolean includeDimensionClusterInfo){
  if (targetRecordIDType == null)   targetRecordIDType=dataDomain.getRecordIDCategory().getHumanReadableIDType();
  if (targetDimensionIDType == null)   targetDimensionIDType=dataDomain.getDimensionIDCategory().getHumanReadableIDType();
  IDType rowTargetIDType;
  IDType rowSourceIDType;
  IDType colTargetIDType;
  IDType colSourceIDType;
  VirtualArray rowVA;
  VirtualArray colVA;
  rowVA=recordPerspective.getVirtualArray();
  colVA=dimensionPerspective.getVirtualArray();
  rowTargetIDType=targetRecordIDType;
  colTargetIDType=targetDimensionIDType;
  rowSourceIDType=dataDomain.getRecordIDType();
  colSourceIDType=dataDomain.getDimensionIDType();
  if (rowVA == null || colVA == null)   throw new IllegalArgumentException("String_Node_Str");
  IDMappingManager rowIDMappingManager=IDMappingManagerRegistry.get().getIDMappingManager(rowSourceIDType);
  IDMappingManager colIDMappingManager=IDMappingManagerRegistry.get().getIDMappingManager(colSourceIDType);
  try {
    PrintWriter out=new PrintWriter(new BufferedWriter(new FileWriter(fileName)));
    int cnt=-1;
    int cluster=0;
    int example=0;
    int offset=0;
    if (includeDimensionClusterInfo && colVA.getGroupList() != null) {
      String clusterNr="String_Node_Str" + (includeRecordClusterInfo ? "String_Node_Str" : "String_Node_Str");
      String clusterRep="String_Node_Str" + (includeRecordClusterInfo ? "String_Node_Str" : "String_Node_Str");
      cluster=0;
      cnt=-1;
      for (      @SuppressWarnings("String_Node_Str") Integer colIndex : colVA) {
        if (cnt == colVA.getGroupList().get(cluster).getSize() - 1) {
          offset=offset + colVA.getGroupList().get(cluster).getSize();
          cluster++;
          cnt=0;
        }
 else {
          cnt++;
        }
        example=colVA.getGroupList().get(cluster).getRepresentativeElementIndex();
        clusterNr+=cluster + "String_Node_Str";
        clusterRep+=example + "String_Node_Str";
      }
      clusterNr+="String_Node_Str";
      clusterRep+="String_Node_Str";
      out.print(clusterNr);
      out.print(clusterRep);
    }
    if (includeRecordClusterInfo && rowVA.getGroupList() != null)     out.print("String_Node_Str");
    out.print("String_Node_Str");
    for (    Integer colID : colVA) {
      Set<Object> colTargetIDs=colIDMappingManager.getIDAsSet(colSourceIDType,colTargetIDType,colID);
      String id="String_Node_Str";
      for (      Object colTargetID : colTargetIDs) {
        id=colTargetID.toString();
        break;
      }
      out.print(id + "String_Node_Str");
    }
    out.println();
    cnt=-1;
    cluster=0;
    example=0;
    offset=0;
    String id;
    for (    Integer rowID : rowVA) {
      if (includeRecordClusterInfo) {
        if (rowVA.getGroupList() != null) {
          if (cnt == rowVA.getGroupList().get(cluster).getSize() - 1) {
            offset=offset + rowVA.getGroupList().get(cluster).getSize();
            cluster++;
            cnt=0;
          }
 else {
            cnt++;
          }
          example=rowVA.getGroupList().get(cluster).getRepresentativeElementIndex();
          out.print(cluster + "String_Node_Str" + example+ "String_Node_Str");
        }
      }
      Set<Object> rowTargetIDs=rowIDMappingManager.getIDAsSet(rowSourceIDType,rowTargetIDType,rowID);
      id="String_Node_Str";
      for (      Object rowTargetID : rowTargetIDs) {
        id=rowTargetID.toString();
        break;
      }
      out.print(id + "String_Node_Str");
      for (      Integer colID : colVA) {
        out.print(dataDomain.getTable().getRawAsString(colID,rowID));
        out.print("String_Node_Str");
      }
      out.println();
    }
    out.close();
  }
 catch (  IOException e) {
    Logger.log(new Status(IStatus.ERROR,"String_Node_Str","String_Node_Str",e));
    return false;
  }
  return true;
}