Task refill = thePG.getRefillProjection(currentBucket);   if (refill != null) { start = (long)PluginHelper.getPreferenceBestValue(refill, AspectType.START_TIME); end = (long)PluginHelper.getPreferenceBestValue(refill, AspectType.END_TIME); todayRefill = thePG.getProjectionTaskDemand(refill, currentBucket, start, end);
if (currentBucket <= thePG.getLastRefillRequisition()) { todayRefill = findCommittedRefill(currentBucket, thePG);
  private void determineProjectionAllocations(int startBucket, int endBucket, 					      Inventory inv, 					      LogisticsInventoryPG thePG) {    //calculate levels by adding in all refill projection results    // go through each projectwithdraw - allocate to the inventory    int currentBucket = startBucket;    double qty = 0;    double runningQty = 0;    double todayLevel, yesterdayLevel, todayRefill, testLevel, testQty;    long start, end;    Task failedProjection = null;    int endOfLevelSixBucket = thePG.getEndOfLevelSixBucket();    endBucket = Math.min(endOfLevelSixBucket-1, endBucket);    // loop through the bucket in the inventory    while (currentBucket <= endBucket) {      yesterdayLevel = thePG.getLevel(currentBucket - 1);      Task refill = thePG.getRefillProjection(currentBucket);      //!!!NOTE getRefillProjection can return a null for a bucket check to make sure      // you have a real task and not a null.      if (refill != null) {	start = (long)PluginHelper.getPreferenceBestValue(refill, AspectType.START_TIME);	end = (long)PluginHelper.getPreferenceBestValue(refill, AspectType.END_TIME);	todayRefill = thePG.getProjectionTaskDemand(refill, currentBucket, start, end);      } else {	todayRefill = 0;      }      runningQty = 0;      if (! trailingPointersHash.isEmpty()) {  	runningQty = processLateWithdraws(currentBucket, yesterdayLevel+todayRefill, 					  inv, thePG);      }      Collection wdTasks = thePG.getActualDemandTasks(currentBucket);      Iterator wdIter = wdTasks.iterator();      while (wdIter.hasNext()) {	Task projWdraw = (Task)wdIter.next();	if (projWdraw.getVerb().equals(Constants.Verb.PROJECTWITHDRAW)) {	  start = (long)PluginHelper.getPreferenceBestValue(projWdraw, AspectType.START_TIME);	  end = (long)PluginHelper.getPreferenceBestValue(projWdraw, AspectType.END_TIME);	  qty = thePG.getProjectionTaskDemand(projWdraw, currentBucket, start, end);	  testQty = runningQty + qty;	  testLevel = yesterdayLevel - testQty + todayRefill;	  	  if (testLevel >= 0.0) {	    // if its ok give it a pe and update the quantity  	    runningQty = runningQty + qty;	    if (projWdraw.getPlanElement() == null) {	      TaskDeficit taskdeficit = (TaskDeficit)trailingPointersHash.get(projWdraw);	      if (taskdeficit == null) {		allocatedProjections.add(projWdraw);//  		if(logger.isWarnEnabled()) {//  		  logger.warn("AA.determineProjectionAllocations Adding to allocated projections "+//  			      getTaskUtils().taskDesc(projWdraw));//  		}	      } else {		taskdeficit.addBucket(qty, 0);	      }	    }	  } else {//  	    System.out.println("&&&&&&&&&&Failed projectWithdraw, todayRefill ="+//  			       todayRefill+" "+			       //    			       getTaskUtils().taskDesc(projWdraw));//  	    int cb=1;//  	    while (cb <= currentBucket+2) {//  	      System.out.println("bucket: "+cb+" "+//  				 TimeUtils.dateString(thePG.convertBucketToTime(cb))+//  				 " level="+//  				 thePG.getLevel(cb));//  	      cb=cb+1;//  	    }	    failedProjection=projWdraw;	    allocatedProjections.remove(projWdraw);	    TaskDeficit taskdeficit = (TaskDeficit)trailingPointersHash.get(projWdraw);	    if (taskdeficit == null) {	      trailingPointersHash.put(projWdraw, new TaskDeficit(currentBucket, 0, qty));	    } else {	      taskdeficit.addBucket(0, qty);	    }	  }	} else {	  logger.debug("AA.determineProjectionAllocations " +		       "Got SUPPLY task while processing ProjecWithdraws : " +		       getTaskUtils().taskDesc(projWdraw));	}      }      todayLevel = yesterdayLevel - runningQty + todayRefill;      thePG.setLevel(currentBucket, todayLevel);      currentBucket = currentBucket + 1;    }  }