externalAllocator.allocateRefillTasks(partialsToAlloc);
if (! failedSplits.isEmpty()) { externalAllocator.rescindTaskAllocations(failedSplits); externalAllocator.allocateRefillTasks(failedSplits); } if (! partialsToAlloc.isEmpty()) { externalAllocator.allocateRefillTasks(partialsToAlloc); }
  protected void getOverlappingTasks(Collection refill_allocations, Verb verb, HashMap providersSched) {     RelationshipSchedule myOrgRelSched = myOrganization.getRelationshipSchedule();    Iterator raIt = refill_allocations.iterator();    ArrayList unprovidedTasks = new ArrayList();    ArrayList partial = new ArrayList();    Role myRole = getRole(supplyType);    while (raIt.hasNext()) {      Allocation alloc = (Allocation)raIt.next();      Task task = alloc.getTask();      if ((alloc != null) && (task.getVerb().equals(verb))){        long taskEnd = TaskUtils.getEndTime(task);        //if the task is totally in the past, don't touch it!        if (currentTimeMillis() > taskEnd) {          continue;        }        Organization provider  = (Organization)alloc.getAsset();        if (alloc.getRole() != getRole(supplyType)) {          if (logger.isWarnEnabled())            logger.warn("SDSD MISMATCH: " + alloc.getRole() + " " + task + "\n");        }        Schedule availSched = (Schedule) providersSched.get(provider);        Date start = null;         // just a place holder        Collection enclosed;        if (availSched != null) {          if (verb.equals(Constants.Verb.ProjectSupply)) {            // only need provider from start to end - bucketSize            long taskStart = TaskUtils.getStartTime(task);            start = new Date(taskStart);            EnclosedPredicate enclosedPred = new EnclosedPredicate(myOrgRelSched, myRole, provider, taskStart, taskEnd);            int size = myOrgRelSched.getMatchingRelationships(enclosedPred).size();            //System.out.println("Task times " + new Date(taskStart) + " " + start + " size of enclosed" + size);            if (size == 0) {              //if (availSched.getEncapsulatedScheduleElements(taskStart, taskEnd - bucketSize).size() == 0) {              if (availSched.getOverlappingScheduleElements(taskStart, taskEnd - bucketSize).size() > 0) {                partial.add(task);              } else {                unprovidedTasks.add(task);              }            }          } else { // it is Supply Task            enclosed = availSched.getScheduleElementsWithTime(taskEnd);            if (enclosed.size() == 0) {              if (myOrgName.indexOf("1-35-ARBN") >= 0 && supplyType.equals("BulkPOL") && logger.isDebugEnabled()) {                logger.debug("Adding task to list  " + start + "  " + new Date(taskEnd) +                                   unprovidedTasks.size());              }              unprovidedTasks.add(task);            }          }        }      }    }    if (myOrgName.indexOf("1-35-ARBN") >= 0 && supplyType.equals("BulkPOL") && logger.isDebugEnabled()) {      logger.debug("number of unprovided tasks is " + unprovidedTasks.size());    }    if (!unprovidedTasks.isEmpty()){      if (logger.isWarnEnabled()) {        logger.warn("Trying to rescind and reallocate unprovided supply refill tasks...");      }      externalAllocator.rescindTaskAllocations(unprovidedTasks);      externalAllocator.allocateRefillTasks(unprovidedTasks);    }    if (!partial.isEmpty()) {      ArrayList partialsToAlloc = new ArrayList();      Iterator partIt = partial.iterator();      while (partIt.hasNext()) {        Task taskToSplit = (Task) partIt.next();        List splitTimes = getSplitTimes(taskToSplit, providersSched);        Collection newPartialTasks = getTaskUtils().splitProjection(taskToSplit, splitTimes, this);        partialsToAlloc.addAll(newPartialTasks);      }      externalAllocator.allocateRefillTasks(partialsToAlloc);    }    //return unprovidedTasks;  }