if(GLMDebug.printDebug()) GLMDebug.DEBUG("InventoryBG", "UpdateInventoryLevelsSchedule(), No Demand Schedule Set.");
if (logger.isDebugEnabled()) { logger.debug("UpdateInventoryLevelsSchedule(), No Demand Schedule Set."); }
  public int updateInventoryLevelsSchedule(Inventory inventory) {    InventoryLevelsPG ilp = inventory.getInventoryLevelsPG();    QuantityScheduleElement dse, rlse, glse;    Vector new_av_demand_elements = new Vector();    Vector new_reorder_elements = new Vector();    Vector new_goal_elements = new Vector();    if (demandSchedule_ == null) {      if(GLMDebug.printDebug()) GLMDebug.DEBUG("InventoryBG", "UpdateInventoryLevelsSchedule(), No Demand Schedule Set.");      clearInventoryLevelsSchedule(inventory);    }    else {      int days = demandSchedule_.length;//  	    if(GLMDebug.printDebug()) GLMDebug.DEBUG("InventoryBG", "UpdateInventoryLevelsSchedule(), Creating new Schedule for "+AssetUtils.assetDesc(inventory));      for (int i = 0; i < days; i++) {	// start time is eigher today or time 1st request was received + number of planning days	long start = TimeUtils.addNDaysTime(getStartTime(), i);	// end time is a millisecond before start time of next day	long end = TimeUtils.addNDaysTime(getStartTime(), (i+1));	try {	  dse = ScheduleUtils.buildQuantityScheduleElement(demandSchedule_[i], start, end);	  rlse = ScheduleUtils.buildQuantityScheduleElement(getReorderLevel(i), start, end);	  glse = ScheduleUtils.buildQuantityScheduleElement(getGoalLevel(i), start, end);	} catch (IllegalArgumentException iae) {	  iae.printStackTrace();	  continue;	}//  	if(GLMDebug.printDebug()) GLMDebug.DEBUG("InventoryBG", "UpdateInventoryLevelschedule(), Start:"+TimeUtils.dateString(start)+//  			       ", End:"+TimeUtils.dateString(end)+", Qty: "+level_[i]);	new_av_demand_elements.add(dse);	new_reorder_elements.add(rlse);	new_goal_elements.add(glse);      }    }    Schedule new_av_demand_schedule =       GLMFactory.newQuantitySchedule(new_av_demand_elements.elements(), 				     PlanScheduleType.TOTAL_INVENTORY);    Schedule new_reorder_schedule =       GLMFactory.newQuantitySchedule(new_reorder_elements.elements(), 				     PlanScheduleType.TOTAL_INVENTORY);    Schedule new_goal_schedule =       GLMFactory.newQuantitySchedule(new_goal_elements.elements(), 				     PlanScheduleType.TOTAL_INVENTORY);    if (ScheduleUtils.isOffendingSchedule(new_av_demand_schedule)) {      GLMDebug.ERROR("InventoryBG", "UpdateInventoryLevelschedule(),  CREATED BAD nDays SCHEDULE  ");      printQuantityScheduleTimes(new_av_demand_schedule);    }    if (ScheduleUtils.isOffendingSchedule(new_reorder_schedule)) {      GLMDebug.ERROR("InventoryBG", "UpdateInventoryLevelschedule(),  CREATED BAD reorder SCHEDULE  ");      printQuantityScheduleTimes(new_reorder_schedule);    }    if (ScheduleUtils.isOffendingSchedule(new_goal_schedule)) {      GLMDebug.ERROR("InventoryBG", "UpdateInventoryLevelschedule(),  CREATED BAD goal SCHEDULE  ");      printQuantityScheduleTimes(new_goal_schedule);    }    ((NewInventoryLevelsPG)ilp).setAverageDemandSchedule(new_av_demand_schedule);    ((NewInventoryLevelsPG)ilp).setReorderLevelSchedule(new_reorder_schedule);    ((NewInventoryLevelsPG)ilp).setGoalLevelSchedule(new_goal_schedule);    return 0;  }