Program: 65772
Project: 65772
Buggy source:
private ITimePeriod populateBaseTimePeriod(ComputedColumnHandle periodHandle) throws DataException, BirtException {
  String calculateType=periodHandle.getCalculationType();
  TimePeriod baseTimePeriod=null;
  if (IBuildInBaseTimeFunction.CURRENT_QUARTER.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.QUARTER,true);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_YEAR.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.YEAR,true);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_QUARTER.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.QUARTER,true);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_MONTH.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.MONTH,true);
  }
 else   if (IBuildInBaseTimeFunction.CURRENT_MONTH.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.MONTH,true);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_30_DAYS.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(-30,TimePeriodType.DAY);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_60_DAYS.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(-60,TimePeriodType.DAY);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_90_DAYS.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(-90,TimePeriodType.DAY);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_120_DAYS.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(-120,TimePeriodType.DAY);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_12_MONTHS.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(-12,TimePeriodType.MONTH);
  }
 else   if (IBuildInBaseTimeFunction.YEAR_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.YEAR);
  }
 else   if (IBuildInBaseTimeFunction.QUARTER_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.QUARTER);
  }
 else   if (IBuildInBaseTimeFunction.MONTH_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.MONTH);
  }
 else   if (IBuildInBaseTimeFunction.CURRENT_YEAR.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.YEAR,true);
  }
 else   if (IBuildInBaseTimeFunction.WEEK_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.WEEK);
  }
 else   if (IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.WEEK);
  }
 else   if (IBuildInBaseTimeFunction.MONTH_TO_DATE_LAST_YEAR.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.MONTH);
  }
 else   if (IBuildInBaseTimeFunction.QUARTER_TO_DATE_LAST_YEAR.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.QUARTER);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_WEEK_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.WEEK);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_MONTH_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.MONTH);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_QUARTER_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.QUARTER);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_YEAR_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.YEAR);
  }
 else   if (IBuildInBaseTimeFunction.CURRENT_PERIOD_FROM_N_PERIOD_AGO.equals(calculateType) || IBuildInBaseTimeFunction.PERIOD_TO_DATE_FROM_N_PERIOD_AGO.equals(calculateType)) {
    Iterator iter=periodHandle.calculationArgumentsIterator();
    String period1=null;
    while (iter.hasNext()) {
      CalculationArgumentHandle argument=(CalculationArgumentHandle)iter.next();
      if (IArgumentInfo.PERIOD_1.equals(argument.getName())) {
        period1=argument.getValue().getStringExpression();
        break;
      }
    }
    if (IBuildInBaseTimeFunction.CURRENT_PERIOD_FROM_N_PERIOD_AGO.equals(calculateType)) {
      baseTimePeriod=new TimePeriod(0,DataAdapterUtil.toTimePeriodType(period1),true);
    }
 else {
      baseTimePeriod=new TimePeriod(0,DataAdapterUtil.toTimePeriodType(period1));
    }
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_N_MONTHS.equals(calculateType)) {
    Iterator iter=periodHandle.calculationArgumentsIterator();
    String n=null;
    while (iter.hasNext()) {
      CalculationArgumentHandle argument=(CalculationArgumentHandle)iter.next();
      if (IArgumentInfo.N_PERIOD1.equals(argument.getName())) {
        n=argument.getValue().getStringExpression();
      }
    }
    baseTimePeriod=new TimePeriod(0 - evaluatePeriodsNForTrailingFunction(n),TimePeriodType.MONTH);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_N_DAYS.equals(calculateType)) {
    Iterator iter=periodHandle.calculationArgumentsIterator();
    String n=null;
    while (iter.hasNext()) {
      CalculationArgumentHandle argument=(CalculationArgumentHandle)iter.next();
      if (IArgumentInfo.N_PERIOD1.equals(argument.getName())) {
        n=argument.getValue().getStringExpression();
      }
    }
    baseTimePeriod=new TimePeriod(0 - evaluatePeriodsNForTrailingFunction(n),TimePeriodType.DAY);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_N_PERIOD_FROM_N_PERIOD_AGO.equals(calculateType)) {
    Iterator iter=periodHandle.calculationArgumentsIterator();
    String period1=null, n=null;
    while (iter.hasNext()) {
      CalculationArgumentHandle argument=(CalculationArgumentHandle)iter.next();
      if (IArgumentInfo.PERIOD_1.equals(argument.getName())) {
        period1=argument.getValue().getStringExpression();
      }
      if (IArgumentInfo.N_PERIOD1.equals(argument.getName())) {
        n=argument.getValue().getStringExpression();
      }
    }
    baseTimePeriod=new TimePeriod(0 - evaluatePeriodsNForTrailingFunction(n),DataAdapterUtil.toTimePeriodType(period1));
  }
 else   if (IBuildInBaseTimeFunction.NEXT_N_PERIODS.equals(calculateType)) {
    Iterator iter=periodHandle.calculationArgumentsIterator();
    String n=null, period1=null;
    while (iter.hasNext()) {
      CalculationArgumentHandle argument=(CalculationArgumentHandle)iter.next();
      if (IArgumentInfo.PERIOD_1.equals(argument.getName())) {
        period1=argument.getValue().getStringExpression();
      }
      if (IArgumentInfo.N_PERIOD1.equals(argument.getName())) {
        n=argument.getValue().getStringExpression();
      }
    }
    baseTimePeriod=new TimePeriod(evaluatePeriodsNForTrailingFunction(n),DataAdapterUtil.toTimePeriodType(period1));
  }
  return baseTimePeriod;
}

Fixed version (ground truth):
private ITimePeriod populateBaseTimePeriod(ComputedColumnHandle periodHandle) throws DataException, BirtException {
  String calculateType=periodHandle.getCalculationType();
  TimePeriod baseTimePeriod=null;
  Object expression=null;
  if (IBuildInBaseTimeFunction.CURRENT_QUARTER.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.QUARTER,true);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_YEAR.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.YEAR,true);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_QUARTER.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.QUARTER,true);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_MONTH.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.MONTH,true);
  }
 else   if (IBuildInBaseTimeFunction.CURRENT_MONTH.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.MONTH,true);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_30_DAYS.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(-30,TimePeriodType.DAY);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_60_DAYS.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(-60,TimePeriodType.DAY);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_90_DAYS.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(-90,TimePeriodType.DAY);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_120_DAYS.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(-120,TimePeriodType.DAY);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_12_MONTHS.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(-12,TimePeriodType.MONTH);
  }
 else   if (IBuildInBaseTimeFunction.YEAR_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.YEAR);
  }
 else   if (IBuildInBaseTimeFunction.QUARTER_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.QUARTER);
  }
 else   if (IBuildInBaseTimeFunction.MONTH_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.MONTH);
  }
 else   if (IBuildInBaseTimeFunction.CURRENT_YEAR.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.YEAR,true);
  }
 else   if (IBuildInBaseTimeFunction.WEEK_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.WEEK);
  }
 else   if (IBuildInBaseTimeFunction.WEEK_TO_DATE_LAST_YEAR.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.WEEK);
  }
 else   if (IBuildInBaseTimeFunction.MONTH_TO_DATE_LAST_YEAR.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.MONTH);
  }
 else   if (IBuildInBaseTimeFunction.QUARTER_TO_DATE_LAST_YEAR.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.QUARTER);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_WEEK_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.WEEK);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_MONTH_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.MONTH);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_QUARTER_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.QUARTER);
  }
 else   if (IBuildInBaseTimeFunction.PREVIOUS_YEAR_TO_DATE.equals(calculateType)) {
    baseTimePeriod=new TimePeriod(0,TimePeriodType.YEAR);
  }
 else   if (IBuildInBaseTimeFunction.CURRENT_PERIOD_FROM_N_PERIOD_AGO.equals(calculateType) || IBuildInBaseTimeFunction.PERIOD_TO_DATE_FROM_N_PERIOD_AGO.equals(calculateType)) {
    Iterator iter=periodHandle.calculationArgumentsIterator();
    String period1=null;
    while (iter.hasNext()) {
      CalculationArgumentHandle argument=(CalculationArgumentHandle)iter.next();
      if (IArgumentInfo.PERIOD_1.equals(argument.getName())) {
        period1=argument.getValue().getStringExpression();
        break;
      }
    }
    if (IBuildInBaseTimeFunction.CURRENT_PERIOD_FROM_N_PERIOD_AGO.equals(calculateType)) {
      baseTimePeriod=new TimePeriod(0,DataAdapterUtil.toTimePeriodType(period1),true);
    }
 else {
      baseTimePeriod=new TimePeriod(0,DataAdapterUtil.toTimePeriodType(period1));
    }
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_N_MONTHS.equals(calculateType)) {
    Iterator iter=periodHandle.calculationArgumentsIterator();
    String n=null;
    while (iter.hasNext()) {
      CalculationArgumentHandle argument=(CalculationArgumentHandle)iter.next();
      if (IArgumentInfo.N_PERIOD1.equals(argument.getName())) {
        n=argument.getValue().getStringExpression();
        expression=argument.getValue().getValue();
      }
    }
    baseTimePeriod=new TimePeriod(0 - evaluatePeriodsNForTrailingFunction(n,expression),TimePeriodType.MONTH);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_N_DAYS.equals(calculateType)) {
    Iterator iter=periodHandle.calculationArgumentsIterator();
    String n=null;
    while (iter.hasNext()) {
      CalculationArgumentHandle argument=(CalculationArgumentHandle)iter.next();
      if (IArgumentInfo.N_PERIOD1.equals(argument.getName())) {
        n=argument.getValue().getStringExpression();
        expression=argument.getValue().getValue();
      }
    }
    baseTimePeriod=new TimePeriod(0 - evaluatePeriodsNForTrailingFunction(n,expression),TimePeriodType.DAY);
  }
 else   if (IBuildInBaseTimeFunction.TRAILING_N_PERIOD_FROM_N_PERIOD_AGO.equals(calculateType)) {
    Iterator iter=periodHandle.calculationArgumentsIterator();
    String period1=null, n=null;
    while (iter.hasNext()) {
      CalculationArgumentHandle argument=(CalculationArgumentHandle)iter.next();
      if (IArgumentInfo.PERIOD_1.equals(argument.getName())) {
        period1=argument.getValue().getStringExpression();
      }
      if (IArgumentInfo.N_PERIOD1.equals(argument.getName())) {
        n=argument.getValue().getStringExpression();
        expression=argument.getValue().getValue();
      }
    }
    baseTimePeriod=new TimePeriod(0 - evaluatePeriodsNForTrailingFunction(n,expression),DataAdapterUtil.toTimePeriodType(period1));
  }
 else   if (IBuildInBaseTimeFunction.NEXT_N_PERIODS.equals(calculateType)) {
    Iterator iter=periodHandle.calculationArgumentsIterator();
    String n=null, period1=null;
    while (iter.hasNext()) {
      CalculationArgumentHandle argument=(CalculationArgumentHandle)iter.next();
      if (IArgumentInfo.PERIOD_1.equals(argument.getName())) {
        period1=argument.getValue().getStringExpression();
      }
      if (IArgumentInfo.N_PERIOD1.equals(argument.getName())) {
        n=argument.getValue().getStringExpression();
        expression=argument.getValue().getValue();
      }
    }
    baseTimePeriod=new TimePeriod(evaluatePeriodsNForTrailingFunction(n,expression),DataAdapterUtil.toTimePeriodType(period1));
  }
  return baseTimePeriod;
}