private void addParticipantToDistributionSet(
     HashSet<Participant> distributionSet, ArrayList<String> uniqueIDs, Participant p) {
   if (!uniqueIDs.contains(p.getID())) {
     uniqueIDs.add(p.getID());
     distributionSet.add(p);
   }
 }
예제 #2
0
 public String resolveParticipantIdsAsXML(String anyID) {
   XNode node = new XNode("participantids");
   for (Participant p : resolveParticipants(anyID)) {
     node.addChild("id", p.getID());
   }
   return node.toString();
 }
예제 #3
0
 public Set<String> resolveParticipantIds(String anyID) {
   Set<String> idSet = new HashSet<String>();
   for (Participant p : resolveParticipants(anyID)) {
     idSet.add(p.getID());
   }
   return idSet;
 }
예제 #4
0
 private long getEarliestTime(List events, Participant p) {
   long result = Long.MAX_VALUE;
   Iterator itr = events.iterator();
   while (itr.hasNext()) {
     ResourceEvent event = (ResourceEvent) itr.next();
     if (event.get_resourceID().equals(p.getID()) && (event.get_timeStamp() < result))
       result = event.get_timeStamp();
   }
   return result;
 }
  /** ***************************************************************************** */
  public String toXML() {
    StringBuilder xml = new StringBuilder("<offer ");

    xml.append("initiator=\"").append(getInitiatorString()).append("\">");

    // the rest of the xml is only needed if it's system initiated
    if (isSystemInitiated()) {
      xml.append("<distributionSet>");
      xml.append("<initialSet>");

      if (_participants != null) {
        for (Participant p : _participants) {
          xml.append("<participant>").append(p.getID()).append("</participant>");
        }
      }
      if (_roles != null) {
        for (Role r : _roles) {
          xml.append("<role>").append(r.getID()).append("</role>");
        }
      }
      if (_dynParams != null) {
        for (DynParam p : _dynParams) {
          xml.append(p.toXML());
        }
      }

      xml.append("</initialSet>");

      if ((_filters != null) && (!_filters.isEmpty())) {
        xml.append("<filters>");
        for (AbstractFilter filter : _filters) {
          xml.append(filter.toXML());
        }
        xml.append("</filters>");
      }

      if ((_constraints != null) && (!_constraints.isEmpty())) {
        xml.append("<constraints>");
        for (AbstractConstraint constraint : _constraints) {
          xml.append(constraint.toXML());
        }
        xml.append("</constraints>");
      }

      xml.append("</distributionSet>");

      if (_familiarParticipantTask != null) {
        xml.append("<familiarParticipant taskID=\"");
        xml.append(_familiarParticipantTask).append("\"/>");
      }
    }

    xml.append("</offer>");
    return xml.toString();
  }
  /**
   * Takes the initial distribution set of participants, then expands any roles and/or dynamic
   * parameters to their 'set of participants' equivalents, then applies the specified filters
   * and/or constraints, and returns the final distribution set of participants.
   *
   * @param wir the workitem being offered
   * @return the final distribution set of Participant objects
   */
  public Set<Participant> performOffer(WorkItemRecord wir) {
    _distributionSet = new HashSet<Participant>();

    // if familiar task specified, get the participant(s) who completed that task,
    // & offer this item to them - no more to do
    if (_familiarParticipantTask != null) {
      Set<Participant> pSet = _rm.getWhoCompletedTask(_familiarParticipantTask, wir);
      if (pSet != null) _distributionSet.addAll(pSet);
    } else {
      // make sure each participant is added only once
      ArrayList<String> uniqueIDs = new ArrayList<String>();

      // add Participants
      for (Participant p : _participants) {
        uniqueIDs.add(p.getID());
        _distributionSet.add(p);
      }

      // add roles
      for (Role role : _roles) {
        Set<Participant> pSet = _rm.getOrgDataSet().castToParticipantSet(role.getResources());
        pSet.addAll(_rm.getOrgDataSet().getParticipantsInDescendantRoles(role));
        for (Participant p : pSet) {
          addParticipantToDistributionSet(_distributionSet, uniqueIDs, p);
        }
      }

      // add dynamic params
      for (DynParam param : _dynParams) {
        Set<Participant> pSet = param.evaluate(wir);
        for (Participant p : pSet) {
          addParticipantToDistributionSet(_distributionSet, uniqueIDs, p);
        }
      }

      // apply each filter
      for (AbstractFilter filter : _filters)
        _distributionSet = (HashSet<Participant>) filter.performFilter(_distributionSet);

      // apply each constraint
      for (AbstractConstraint constraint : _constraints)
        _distributionSet =
            (HashSet<Participant>) constraint.performConstraint(_distributionSet, wir);
    }

    // ok - got our final set
    return _distributionSet;
  }
  public void withdrawOffer(WorkItemRecord wir, HashSet<Participant> offeredSet) {
    if (offeredSet != null) {
      for (Participant p : offeredSet) {
        p.getWorkQueues().removeFromQueue(wir, WorkQueue.OFFERED);
        _rm.announceModifiedQueue(p.getID());
      }
    }

    // a fired instance of a multi-instance workitem on the unoffered queue will
    // never have been offered, so the warning should be suppressed for those
    else if (!wir.getStatus().equals(WorkItemRecord.statusFired)) {
      _log.warn(
          "Workitem '"
              + wir.getID()
              + "' does not have 'Offered' status, "
              + "or is no longer active");
    }
  }
예제 #8
0
 public Map<String, String> getParticipantIdentifiers(Identifier idType) {
   Map<String, String> idMap = new Hashtable<String, String>();
   for (Participant p : getParticipants()) {
     String nameValue;
     switch (idType) {
       case FullName:
         nameValue = p.getFullName();
         break;
       case ReverseFullName:
         nameValue = p.getLastName() + ", " + p.getFirstName();
         break;
       case LastName:
         nameValue = p.getLastName();
         break;
       default:
         nameValue = p.getUserID();
     }
     idMap.put(p.getID(), nameValue);
   }
   return idMap;
 }
 /**
  * variation of the above
  *
  * @param p - the Participant object to add to the initial distribution list
  */
 public void addParticipant(Participant p) {
   if (_rm.getOrgDataSet().isKnownParticipant(p)) _participants.add(p);
   else _log.warn("Could not add unknown Participant to Offer: " + p.getID());
 }
예제 #10
0
 public boolean isKnownParticipant(Participant p) {
   return isKnownParticipant(p.getID());
 }
예제 #11
0
 /** ********************************* */
 public void delParticipant(Participant p) {
   participantMap.remove(p.getID());
   setChangeStamp(ResUnit.Participant);
 }
예제 #12
0
 /** ********************************* */
 public void putParticipant(Participant p) {
   participantMap.put(p.getID(), p);
   setChangeStamp(ResUnit.Participant);
 }