AspectValue[] rollup = { AspectValue.newAspectValue(AspectType.QUANTITY, quantity), AspectValue.newAspectValue(AspectType.END_TIME, maxEndTime) };
AspectValue[] rollup = { AspectValue.newAspectValue(AspectType.END_TIME, maxEndTime), AspectValue.newAspectValue(AspectType.QUANTITY, quantity)};
  private void reconcilePredictions(Collection demandTasks, Collection committedPreds) {    List sortedTasks = sortTasksByEndTime(demandTasks);    List sortedPreds = sortTasksByEndTime(committedPreds);    if (logger.isDebugEnabled() && debugAgent()) {      logger.debug("Number of tasks in the gap Predictions:  " + sortedPreds.size()                   + " \n\t\t DemandTasks: " + sortedTasks.size());    }    int i = 0;    int lastIndex = sortedTasks.size() -1;    for(i = 0; i <= lastIndex; i++) {      Task task = (Task) sortedTasks.get(i);      long endTime = taskUtils.getEndTime(task);      double quantity = 0.0;      long maxEndTime = endTime;      List taskPhasedValues = new ArrayList();      for (Iterator iter = sortedPreds.iterator(); iter.hasNext();) {        Task pred = (Task) iter.next();        long predEndTime = taskUtils.getEndTime(pred);        if (predEndTime > endTime && i < lastIndex) {          break;        }        PlanElement pe = pred.getPlanElement();        AllocationResult ar = pe.getEstimatedResult();        if (! ar.isSuccess()) {          // prediction failed no reconcilation needed          if (logger.isDebugEnabled()) {            logger.debug("Found a failed prediction, no reconcilation");          }          continue;        }        List phasedResults = ar.getPhasedAspectValueResults();        taskPhasedValues.addAll(phasedResults);        for (Iterator phaseIter = phasedResults.iterator(); phaseIter.hasNext();) {          AspectValue[] aspectValues = (AspectValue[]) phaseIter.next();          for (int l = 0; l < aspectValues.length; l++) {            AspectValue aspectValue = aspectValues[l];            switch (aspectValue.getAspectType()) {              case AspectType.QUANTITY:                quantity += aspectValue.getValue();                break;              case AspectType.END_TIME:                maxEndTime = Math.max(maxEndTime, aspectValue.longValue());                break;              default: logger.warn("Unexpected aspect type " + aspectValue.getAspectType());            }          }        }      }      AspectValue[] rollup = { AspectValue.newAspectValue(AspectType.QUANTITY, quantity),                               AspectValue.newAspectValue(AspectType.END_TIME, maxEndTime)      };      AllocationResult ar = new AllocationResult(1.0, true, rollup, taskPhasedValues);      if (logger.isDebugEnabled() && debugAgent()) {        logger.debug("Published new disposition on task " + task.getUID() + " end Time " +                     new Date(endTime) + " original quantity " + taskUtils.getQuantity(task) +                     " new quantity " + quantity);      }      inventoryPlugin.publishRemove(task.getPlanElement());      Disposition disp = inventoryPlugin.getPlanningFactory().createDisposition(task.getPlan(), task, ar);      inventoryPlugin.publishAdd(disp);    }  }