예제 #1
0
  public Set<AbstractResource> getRoleParticipantsWithCapability(String rid, String cid) {
    Set<AbstractResource> resourceSet = new HashSet<AbstractResource>();
    Role role = getRole(rid);
    if (role != null) {

      // filter role members by capability
      if (cid != null) {
        Capability cap = getCapability(cid);
        if (cap != null) {
          for (AbstractResource member : role.getResources()) {
            if (((Participant) member).getCapabilities().contains(cap)) {
              resourceSet.add(member);
            }
          }
        }
      } else resourceSet = role.getResources(); // no cid means don't filter
    }
    return resourceSet;
  }
예제 #2
0
 public Set<Participant> getParticipantsInDescendantRoles(Role owner) {
   Set<Participant> result = new HashSet<Participant>();
   Set<Role> roleSet = getRoles();
   for (Role role : roleSet) {
     if (role.ultimatelyBelongsTo(owner)) {
       result.addAll(castToParticipantSet(role.getResources()));
     }
   }
   return result;
 }
  /**
   * 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;
  }
예제 #4
0
 public Set<Participant> getRoleParticipants(String rid) {
   Role r = roleMap.get(rid);
   return (r != null) ? castToParticipantSet(r.getResources()) : null;
 }