Program: 57838
Project: 57838
Buggy source:
/** 
 * Creates the dimensions from a previously prepared dimension definition.
 * @param loadDataParameters definition how to create the dimensions
 * @return <code>true</code>if the creation was successful, <code>false</code> otherwise
 */
public static boolean createColumns(LoadDataParameters loadDataParameters){
  ArrayList<Integer> columnIds=null;
  boolean createColumnsFromExistingIDs=false;
  if (loadDataParameters.getColumnIds() == null)   columnIds=new ArrayList<Integer>();
 else {
    columnIds=loadDataParameters.getColumnIds();
    createColumnsFromExistingIDs=true;
  }
  TabularAsciiDataReader reader=new TabularAsciiDataReader(null,loadDataParameters.getDataDomain());
  reader.setTokenPattern(loadDataParameters.getInputPattern());
  ArrayList<EDimensionType> dataTypes=reader.getColumnDataTypes();
  boolean abort=false;
  Iterator<String> columnLabelIterator=loadDataParameters.getColumnLabels().iterator();
  CmdDataCreateColumn cmdCreateColumn;
  String columnLabel;
  ATableBasedDataDomain dataDomain=loadDataParameters.getDataDomain();
  IDMappingManager columnIDMappingManager;
  IDType columnIDType;
  IDType hrColumnIDType;
  if (dataDomain.isColumnDimension()) {
    columnIDMappingManager=dataDomain.getDimensionIDMappingManager();
    columnIDType=dataDomain.getDimensionIDType();
    hrColumnIDType=dataDomain.getHumanReadableDimensionIDType();
  }
 else {
    columnIDMappingManager=dataDomain.getRecordIDMappingManager();
    columnIDType=dataDomain.getRecordIDType();
    hrColumnIDType=dataDomain.getHumanReadableRecordIDType();
  }
  MappingType mappingType=columnIDMappingManager.createMap(columnIDType,hrColumnIDType,false);
  Map<Integer,String> dimensionIDMap=columnIDMappingManager.getMap(mappingType);
  int columnCount=0;
  for (  EDimensionType dataType : dataTypes) {
switch (dataType) {
case FLOAT:
      cmdCreateColumn=(CmdDataCreateColumn)GeneralManager.get().getCommandManager().createCommandByType(CommandType.CREATE_COLUMN);
    if (createColumnsFromExistingIDs)     cmdCreateColumn.setAttributes(ManagedObjectType.COLUMN_NUMERICAL,columnIds.get(columnCount++));
 else     cmdCreateColumn.setAttributes(ManagedObjectType.COLUMN_NUMERICAL);
  cmdCreateColumn.doCommand();
columnLabel=columnLabelIterator.next();
NumericalColumn column=(NumericalColumn)cmdCreateColumn.getCreatedObject();
column.setLabel(columnLabel);
dimensionIDMap.put(column.getID(),columnLabel);
if (!createColumnsFromExistingIDs) columnIds.add(column.getID());
break;
case STRING:
cmdCreateColumn=(CmdDataCreateColumn)GeneralManager.get().getCommandManager().createCommandByType(CommandType.CREATE_COLUMN);
if (createColumnsFromExistingIDs) cmdCreateColumn.setAttributes(ManagedObjectType.COLUMN_NOMINAL,columnIds.get(columnCount++));
 else cmdCreateColumn.setAttributes(ManagedObjectType.COLUMN_NOMINAL);
cmdCreateColumn.doCommand();
columnLabel=columnLabelIterator.next();
NominalColumn<?> nominalColumn=(NominalColumn<?>)cmdCreateColumn.getCreatedObject();
nominalColumn.setLabel(columnLabel);
if (!createColumnsFromExistingIDs) columnIds.add(nominalColumn.getID());
case SKIP:
break;
case ABORT:
abort=true;
break;
default :
break;
}
if (abort) {
break;
}
}
columnIDMappingManager.createReverseMap(mappingType);
loadDataParameters.setDimensionIds(columnIds);
return true;
}

Fixed version (ground truth):
/** 
 * Creates the dimensions from a previously prepared dimension definition.
 * @param loadDataParameters definition how to create the dimensions
 * @return <code>true</code>if the creation was successful, <code>false</code> otherwise
 */
public static boolean createColumns(LoadDataParameters loadDataParameters){
  ArrayList<Integer> columnIds=null;
  boolean createColumnsFromExistingIDs=false;
  if (loadDataParameters.getColumnIds() == null)   columnIds=new ArrayList<Integer>();
 else {
    columnIds=loadDataParameters.getColumnIds();
    createColumnsFromExistingIDs=true;
  }
  TabularAsciiDataReader reader=new TabularAsciiDataReader(null,loadDataParameters.getDataDomain());
  reader.setTokenPattern(loadDataParameters.getInputPattern());
  ArrayList<EColumnType> dataTypes=reader.getColumnDataTypes();
  boolean abort=false;
  Iterator<String> columnLabelIterator=loadDataParameters.getColumnLabels().iterator();
  CmdDataCreateColumn cmdCreateColumn;
  String columnLabel;
  ATableBasedDataDomain dataDomain=loadDataParameters.getDataDomain();
  IDMappingManager columnIDMappingManager;
  IDType columnIDType;
  IDType hrColumnIDType;
  if (dataDomain.isColumnDimension()) {
    columnIDMappingManager=dataDomain.getDimensionIDMappingManager();
    columnIDType=dataDomain.getDimensionIDType();
    hrColumnIDType=dataDomain.getHumanReadableDimensionIDType();
  }
 else {
    columnIDMappingManager=dataDomain.getRecordIDMappingManager();
    columnIDType=dataDomain.getRecordIDType();
    hrColumnIDType=dataDomain.getHumanReadableRecordIDType();
  }
  MappingType mappingType=columnIDMappingManager.createMap(columnIDType,hrColumnIDType,false);
  Map<Integer,String> dimensionIDMap=columnIDMappingManager.getMap(mappingType);
  int columnCount=0;
  for (  EColumnType dataType : dataTypes) {
switch (dataType) {
case FLOAT:
      cmdCreateColumn=(CmdDataCreateColumn)GeneralManager.get().getCommandManager().createCommandByType(CommandType.CREATE_COLUMN);
    if (createColumnsFromExistingIDs)     cmdCreateColumn.setAttributes(ManagedObjectType.COLUMN_NUMERICAL,columnIds.get(columnCount++));
 else     cmdCreateColumn.setAttributes(ManagedObjectType.COLUMN_NUMERICAL);
  cmdCreateColumn.doCommand();
columnLabel=columnLabelIterator.next();
NumericalColumn column=(NumericalColumn)cmdCreateColumn.getCreatedObject();
column.setLabel(columnLabel);
dimensionIDMap.put(column.getID(),columnLabel);
if (!createColumnsFromExistingIDs) columnIds.add(column.getID());
break;
case STRING:
cmdCreateColumn=(CmdDataCreateColumn)GeneralManager.get().getCommandManager().createCommandByType(CommandType.CREATE_COLUMN);
if (createColumnsFromExistingIDs) cmdCreateColumn.setAttributes(ManagedObjectType.COLUMN_NOMINAL,columnIds.get(columnCount++));
 else cmdCreateColumn.setAttributes(ManagedObjectType.COLUMN_NOMINAL);
cmdCreateColumn.doCommand();
columnLabel=columnLabelIterator.next();
NominalColumn<?> nominalColumn=(NominalColumn<?>)cmdCreateColumn.getCreatedObject();
nominalColumn.setLabel(columnLabel);
if (!createColumnsFromExistingIDs) columnIds.add(nominalColumn.getID());
case SKIP:
break;
case ABORT:
abort=true;
break;
default :
break;
}
if (abort) {
break;
}
}
columnIDMappingManager.createReverseMap(mappingType);
loadDataParameters.setDimensionIds(columnIds);
return true;
}