logger.error("DemandForecastPlugin: myOrganization is null, not ready to process tasks for " +ais.getMessageAddress().toString());
if (logger.isErrorEnabled()) { logger.error("DemandForecastPlugin: myOrganization is null, not ready to process tasks for " + ais.getMessageAddress().toString()); }
  protected void execute() {    if ((supplyClassPG == null) ||        (oplanSubscription.isEmpty()) ||        (orgActivities.isEmpty())) {      processedDetReq = false;      return;    }    genProjTaskScheduler.initForExecuteCycle();    if (!detReqSubscription.isEmpty()) {      Iterator detReqIt = detReqSubscription.iterator();      Task detReqTask = (Task) detReqIt.next();      processedDetReq = (!(detReqTask.getPlanElement() == null));      //There should be both a determineRequirements task      //and an oplan before kicking off the expander for the first time.      //from then on out we should be catching additional assets added, or removed.      //It is also possible that this agent has no assets and the expander has to dispose of the detReqTask.      //if there is a new determine requirements task or new oplan do this      if (((!orgActivities.getAddedCollection().isEmpty()) && (!processedDetReq))  ||          (!detReqSubscription.getAddedCollection().isEmpty())) {        processDetReq(detReqSubscription,                      assetsWithPGSubscription);      }      //otherwise just issue a new      else if (!assetsWithPGSubscription.getAddedCollection().isEmpty()) {        processDetReq(detReqSubscription,                      assetsWithPGSubscription.getAddedCollection());      }       else if (!assetsWithPGSubscription.getRemovedCollection().isEmpty()) {        removeFromDetReq(detReqSubscription,                         assetsWithPGSubscription.getRemovedCollection());      }    }    if (myOrganization == null) {      myOrganization = getMyOrganization(selfOrganizations.elements());      if (myOrganization != null) {        projectSupplySubscription = (IncrementalSubscription)            blackboard.subscribe(new ProjectSupplyPredicate(supplyType, getOrgName(), taskUtils));      }    }    if (myOrganization == null) {      if (logger.isInfoEnabled()) {        logger.info("\n DemandForecastPlugin " + supplyType +                    " not ready to process tasks yet." +                    " my org is: " + myOrganization);      }      logger.error("DemandForecastPlugin: myOrganization is null, not ready to process tasks for " +ais.getMessageAddress().toString());      return;    }    // get the Logistics OPlan (our homegrown version with specific dates).    logOPlan = logisticsPlan.updateOrgActivities(oplanSubscription, allOrgActivities);    //Only after we have all the constituent parts to start going - oplan, orgActitivities, logOplan do we    //lay down    if (logOPlan != null) {      if(logOPlan.getArrivalTime() != Long.MIN_VALUE){        if((supplyClassPG != null) && (genProjTaskScheduler == null)) {          setupTaskScheduler();          //genProjSubscription = (IncrementalSubscription) blackboard.subscribe(new GenProjPredicate(supplyType, taskUtils));        }      }      else {        logOPlan = null;        if (logger.isDebugEnabled()) {          logger.debug("DemandForecastPlugin for " +ais.getMessageAddress().toString()                        + " returning b/c logOPlan arrivalTime not set.");        }        return;      }    } else { // wait for logOPlan      return;    }//    if (genProjSubscription != null) {    HashSet justExpandedPGs = new HashSet();    if (! genProjTaskScheduler.isEmpty()) {      Collection removed = genProjTaskScheduler.getRemovedCollection();      Collection added = genProjTaskScheduler.getAddedCollection();      TimeSpan timeSpan = null;      if(turnOffTaskSched) {	  //  timeSpan = new ScheduleElementImpl(oplan.getCday(),oplan.getEndDay());	  timeSpan = new ScheduleElementImpl(getLogOPlanStartTime(),					     getLogOPlanEndTime());      }      else {	  timeSpan = genProjTaskScheduler.getCurrentTimeSpan();      }      if (! removed.isEmpty())        processRemovedGenProjs (removed, timeSpan);      if (! added.isEmpty())        justExpandedPGs = processNewGenProjs (added, timeSpan);      genProjTaskScheduler.finishedExecuteCycle();    }    if (processedDetReq) {      checkAndProcessHashSubscriptions(justExpandedPGs);    }    //Update the Allocation results on new or changed GP PlanElements    if (genProjPESubscription.hasChanged()) {      if (!genProjPESubscription.getAddedCollection().isEmpty()) {        generateProjectionsExpander.updateAllocationResults(genProjPESubscription.getAddedCollection());      }      if (!genProjPESubscription.getChangedCollection().isEmpty()) {        generateProjectionsExpander.updateAllocationResults(genProjPESubscription.getChangedCollection());      }    }    //Update the Allocation results on new or changed DR PlanElements    if (detReqPESubscription.hasChanged()) {      if (!detReqPESubscription.getAddedCollection().isEmpty()) {        determineRequirementsExpander.updateAllocationResults(detReqPESubscription.getAddedCollection());      }      if (!detReqPESubscription.getChangedCollection().isEmpty()) {        determineRequirementsExpander.updateAllocationResults(detReqPESubscription.getChangedCollection());      }    }    //deal with rehydration    if (rehydrate) {      rehydrateHashMaps();      rehydrate = false;    }  }