Program: 57935
Project: 57935
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 createDimensions(LoadDataParameters loadDataParameters){
  ArrayList<Integer> dimensionIds=null;
  boolean createDimensionsFromExistingIDs=false;
  if (loadDataParameters.getDimensionIds() == null)   dimensionIds=new ArrayList<Integer>();
 else {
    dimensionIds=loadDataParameters.getDimensionIds();
    createDimensionsFromExistingIDs=true;
  }
  TabularAsciiDataReader reader=new TabularAsciiDataReader(null,loadDataParameters.getDataDomain());
  reader.setTokenPattern(loadDataParameters.getInputPattern());
  ArrayList<DimensionType> dataTypes=reader.getColumnDataTypes();
  boolean abort=false;
  Iterator<String> dimensionLabelIterator=loadDataParameters.getDimensionLabels().iterator();
  CmdDataCreateDimension cmdCreateDimension;
  String dimensionLabel;
  for (int tableIndex=0; tableIndex < dataTypes.size(); tableIndex++) {
    DimensionType dataType=dataTypes.get(tableIndex);
switch (dataType) {
case FLOAT:
      cmdCreateDimension=(CmdDataCreateDimension)GeneralManager.get().getCommandManager().createCommandByType(CommandType.CREATE_DIMENSION);
    if (createDimensionsFromExistingIDs)     cmdCreateDimension.setAttributes(ManagedObjectType.DIMENSION_NUMERICAL,dimensionIds.get(tableIndex));
 else     cmdCreateDimension.setAttributes(ManagedObjectType.DIMENSION_NUMERICAL);
  cmdCreateDimension.doCommand();
dimensionLabel=dimensionLabelIterator.next();
NumericalDimension dimension=(NumericalDimension)cmdCreateDimension.getCreatedObject();
dimension.setLabel(dimensionLabel);
if (!createDimensionsFromExistingIDs) dimensionIds.add(dimension.getID());
break;
case STRING:
cmdCreateDimension=(CmdDataCreateDimension)GeneralManager.get().getCommandManager().createCommandByType(CommandType.CREATE_DIMENSION);
if (createDimensionsFromExistingIDs) cmdCreateDimension.setAttributes(ManagedObjectType.DIMENSION_NOMINAL,dimensionIds.get(tableIndex));
 else {
cmdCreateDimension.setAttributes(ManagedObjectType.DIMENSION_NOMINAL);
}
cmdCreateDimension.doCommand();
dimensionLabel=dimensionLabelIterator.next();
NominalDimension<?> nominalDimension=(NominalDimension<?>)cmdCreateDimension.getCreatedObject();
nominalDimension.setLabel(dimensionLabel);
if (!createDimensionsFromExistingIDs) dimensionIds.add(nominalDimension.getID());
case SKIP:
break;
case ABORT:
abort=true;
break;
default :
break;
}
if (abort) {
break;
}
}
loadDataParameters.setDimensionIds(dimensionIds);
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 createDimensions(LoadDataParameters loadDataParameters){
  ArrayList<Integer> dimensionIds=null;
  boolean createDimensionsFromExistingIDs=false;
  if (loadDataParameters.getDimensionIds() == null)   dimensionIds=new ArrayList<Integer>();
 else {
    dimensionIds=loadDataParameters.getDimensionIds();
    createDimensionsFromExistingIDs=true;
  }
  TabularAsciiDataReader reader=new TabularAsciiDataReader(null,loadDataParameters.getDataDomain());
  reader.setTokenPattern(loadDataParameters.getInputPattern());
  ArrayList<DimensionType> dataTypes=reader.getColumnDataTypes();
  boolean abort=false;
  Iterator<String> dimensionLabelIterator=loadDataParameters.getDimensionLabels().iterator();
  CmdDataCreateDimension cmdCreateDimension;
  String dimensionLabel;
  int dimensionCount=0;
  for (  DimensionType dataType : dataTypes) {
switch (dataType) {
case FLOAT:
      cmdCreateDimension=(CmdDataCreateDimension)GeneralManager.get().getCommandManager().createCommandByType(CommandType.CREATE_DIMENSION);
    if (createDimensionsFromExistingIDs)     cmdCreateDimension.setAttributes(ManagedObjectType.DIMENSION_NUMERICAL,dimensionIds.get(dimensionCount++));
 else     cmdCreateDimension.setAttributes(ManagedObjectType.DIMENSION_NUMERICAL);
  cmdCreateDimension.doCommand();
dimensionLabel=dimensionLabelIterator.next();
NumericalDimension dimension=(NumericalDimension)cmdCreateDimension.getCreatedObject();
dimension.setLabel(dimensionLabel);
if (!createDimensionsFromExistingIDs) dimensionIds.add(dimension.getID());
break;
case STRING:
cmdCreateDimension=(CmdDataCreateDimension)GeneralManager.get().getCommandManager().createCommandByType(CommandType.CREATE_DIMENSION);
if (createDimensionsFromExistingIDs) cmdCreateDimension.setAttributes(ManagedObjectType.DIMENSION_NOMINAL,dimensionIds.get(dimensionCount++));
 else cmdCreateDimension.setAttributes(ManagedObjectType.DIMENSION_NOMINAL);
cmdCreateDimension.doCommand();
dimensionLabel=dimensionLabelIterator.next();
NominalDimension<?> nominalDimension=(NominalDimension<?>)cmdCreateDimension.getCreatedObject();
nominalDimension.setLabel(dimensionLabel);
if (!createDimensionsFromExistingIDs) dimensionIds.add(nominalDimension.getID());
case SKIP:
break;
case ABORT:
abort=true;
break;
default :
break;
}
if (abort) {
break;
}
}
loadDataParameters.setDimensionIds(dimensionIds);
return true;
}