if (!previous.equals(failed)) { if ((inventoryPlugin.getClusterId().toString().indexOf("2-NLOS-BTY") >= 0) && (task.getDirectObject().getTypeIdentificationPG().getTypeIdentification().indexOf("155mm-DPICM") >= 0)) { System.out.println("Previous pe ER does not match new one... publish changing - Extra??"); }
if (!previous.isEqual(failed)) {
  private void createFailedAllocation(Task task, Inventory inventory, LogisticsInventoryPG thePG) {    //check if the task already has a failed allocation on it - don't even bother to compare    //failed should equal failed at this point.    PlanElement prevPE = task.getPlanElement();    if (prevPE != null) {      if (!prevPE.getEstimatedResult().isSuccess()) {        return;      }    }    if (logger.isDebugEnabled()) {      logger.debug("Failing task: " + getTaskUtils().taskDesc(task) + " at agent: "                    + inventoryPlugin.getClusterId().toString() +                   " Inventory initial level is: " + thePG.getLevel(0));    }     // make the failed time the day after the end of the oplan    long failed_time = inventoryPlugin.getOPlanEndTime() + TimeUtils.MSEC_PER_DAY;    AspectValue avs[];    if (task.getVerb().equals(Constants.Verb.WITHDRAW)) {      avs = new AspectValue[2];      avs[0] = AspectValue.newAspectValue(AspectType.END_TIME, failed_time);      avs[1] = AspectValue.newAspectValue(AspectType.QUANTITY,                                          PluginHelper.getPreferenceBestValue(task, AspectType.QUANTITY));    } else {      // projection... set start and end to failed_time and set the rate to the pref over 1 bucket      avs = new AspectValue[3];      long failed_start = PluginHelper.getStartTime(task);      AspectValue failedAV;      Duration dur = new Duration(failed_time - failed_start, Duration.MILLISECONDS);      if (getTaskUtils().getRate(task) instanceof FlowRate) {        Volume vol = new Volume(0.0, Volume.GALLONS);        failedAV = AspectValue.newAspectValue(AlpineAspectType.DEMANDRATE,                                              new FlowRate(vol,dur));      } else {        Count cnt = new Count(0.0, Count.EACHES);        failedAV = AspectValue.newAspectValue(AlpineAspectType.DEMANDRATE,                                              new CountRate(cnt, dur));      }                                                    avs[0] = AspectValue.newAspectValue(AspectType.START_TIME, failed_start);      avs[1] = AspectValue.newAspectValue(AspectType.END_TIME, failed_time);      avs[2] = failedAV;    }    AllocationResult failed =            inventoryPlugin.getPlanningFactory().newAllocationResult(Constants.Confidence.SCHEDULED, false, avs);    //PlanElement prevPE = task.getPlanElement();    if (prevPE == null) {      Allocation alloc = inventoryPlugin.getPlanningFactory().              createAllocation(task.getPlan(), task, inventory,                               failed, myRole);      inventoryPlugin.publishAdd(alloc);    } else {      AllocationResult previous = prevPE.getEstimatedResult();      if (!previous.equals(failed)) {        if ((inventoryPlugin.getClusterId().toString().indexOf("2-NLOS-BTY") >= 0) &&              (task.getDirectObject().getTypeIdentificationPG().getTypeIdentification().indexOf("155mm-DPICM") >= 0)) {          System.out.println("Previous pe ER does not match new one... publish changing - Extra??");        }        prevPE.setEstimatedResult(failed);        inventoryPlugin.publishChange(prevPE);      }    }  }