+ ". My currentStages has : " + currentStages.size());
+ ". My currentStages has : " + currentStages.getStages().size());
  private void requestOplans(Task glsTask) {    dbp.put(AGENT_PARAMETER, orgId);        ContextOfOplanIds cIds = (ContextOfOplanIds) glsTask.getContext();    // There should always be exactly one oplan    String oplanId = (String) cIds.iterator().next();    PrepositionalPhrase c0pp = glsTask.getPrepositionalPhrase(WITH_C0);    long c0_date = ((Long)(c0pp.getIndirectObject())).longValue();    cDay = new Date(c0_date);    myOplan = findOplan(oplanId);    dbp.put(OPLAN_ID_PARAMETER, oplanId);    if (myOplan == null) {      if (logger.isInfoEnabled())	logger.info(getAgentIdentifier() + ".requestOplans: no Oplan on BBoard yet.");      try {	myOplan = (Oplan) oplanQueryHandler.readObject();	if (myOplan == null) {	  logger.error(getAgentIdentifier() + " still has null Oplan for id " + oplanId + "! This agent wont have anything to do!");	  return;	}	Number num = (Number) activeStagesQueryHandler.readObject();	int minRequiredStage;	if (num == null) {	  minRequiredStage = 0;	} else {	  minRequiredStage = num.intValue();	}	myOplan.setMinRequiredStage(minRequiredStage);	myOplan.setCday(cDay);	uidService.registerUniqueObject(myOplan);	myOplan.setOwner(getAgentIdentifier());	myOplan.setOplanId(oplanId);	oplans.add(myOplan);	if (logger.isInfoEnabled())	  logger.info(getAgentIdentifier() + " publishing Oplan");	blackboard.publishAdd(myOplan);      } catch (Exception e) {	logger.error("Exception reading oplan" + oplanId, e);	return;      }    }    currentActivities.clear();    addedActivities.clear();    changedActivities.clear();    removedActivities.clear();    orgActivityPredicate.setOplan(myOplan);    currentActivities.addAll(blackboard.query(orgActivityPredicate));        PrepositionalPhrase stagespp = glsTask.getPrepositionalPhrase(FOR_OPLAN_STAGES);    SortedSet newStages = (SortedSet) stagespp.getIndirectObject();    if (logger.isInfoEnabled())      logger.info(getAgentIdentifier() + ".requestOplans: GLS task lists OplanStages size: "                                        + newStages.size()                                        + ". My currentStages has : " + currentStages.size());    boolean currentStagesChanged = false;    if (!newStages.containsAll(currentStages)) {      // Some stages have been removed, we start all over      // this shouldn't ever happen      for (Iterator j = currentActivities.iterator(); j.hasNext(); ) {	OrgActivity oa = (OrgActivity) j.next();	removedActivities.add(oa);	j.remove();      }      currentStages.clear();      currentStagesChanged = true;    }        if (logger.isInfoEnabled())      logger.info(getAgentIdentifier() + ".requestOplans: OrgActivities to remove: " + removedActivities.size());        SortedSet addedStages = new TreeSet(newStages);    addedStages.removeAll(currentStages); // Leaves only the added stages    for (Iterator j = addedStages.iterator(); j.hasNext(); ) {      OplanStage stage = (OplanStage) j.next();      dbp.put(OPLAN_STAGE_PARAMETER, String.valueOf(stage.getNumber()));      try {	Collection orgActivities = orgActivityQueryHandler.readCollection();	updateOrgActivities(myOplan, orgActivities);        } catch (Exception e) {          logger.error("Error running org activity query", e);        }        currentStagesChanged |= currentStages.add(stage);    }        if (currentStagesChanged) {      blackboard.publishChange(currentStages);      if (currentStages.isEmpty()) {	myOplan.setMaxActiveStage(-1); // No stages are active      } else {	OplanStage maxActiveStage = (OplanStage) newStages.last();	myOplan.setMaxActiveStage(maxActiveStage.getNumber());      }      blackboard.publishChange(myOplan);    }        for (Iterator j = removedActivities.iterator(); j.hasNext(); ) {      OrgActivity oa = (OrgActivity) j.next();      blackboard.publishRemove(oa);    }        if (logger.isInfoEnabled())      logger.info(getAgentIdentifier() + ".requestOplans: OrgActivities to add: " + addedActivities.size());        for (Iterator j = addedActivities.iterator(); j.hasNext(); ) {      OrgActivity oa = (OrgActivity) j.next();      blackboard.publishAdd(oa);      if (logger.isDebugEnabled())	logger.debug("Adding OrgActivity: "+oa.getActivityType());    }        if (logger.isInfoEnabled())      logger.info(getAgentIdentifier() + ".requestOplans: OrgActivities to change: " + changedActivities.size());        for (Iterator j = changedActivities.iterator(); j.hasNext(); ) {      OrgActivity oa = (OrgActivity) j.next();      blackboard.publishChange(oa);    }  }