コード例 #1
0
 public Set<Participant> resolveParticipantsFromResourceName(String anyName) {
   Set<Participant> pSet = new HashSet<Participant>();
   Participant p = getParticipantFromUserID(anyName);
   if (p != null) {
     pSet.add(p);
     return pSet;
   }
   Role r = getRoleByName(anyName);
   if (r != null) {
     pSet.addAll(getRoleParticipants(r.getID()));
     return pSet;
   }
   Position pos = getPositionByLabel(anyName);
   if (pos != null) {
     pSet.addAll(getPositionParticipants(pos.getID()));
     return pSet;
   }
   OrgGroup o = getOrgGroupByLabel(anyName);
   if (o != null) {
     pSet.addAll(getOrgGroupParticipants(o.getID()));
     return pSet;
   }
   Capability c = getCapabilityByLabel(anyName);
   if (c != null) {
     pSet.addAll(getCapabilityParticipants(c.getID()));
   }
   return pSet;
 }
コード例 #2
0
 public Map<String, String> getPositionIdentifiers() {
   Map<String, String> idMap = new Hashtable<String, String>();
   for (Position p : getPositions()) {
     idMap.put(p.getID(), p.getTitle());
   }
   return idMap;
 }
コード例 #3
0
 public Position getPositionByLabel(String label) {
   for (Position p : positionMap.values()) {
     if (p.getTitle().equals(label)) {
       return p;
     }
   }
   return null;
 }
コード例 #4
0
  public String getPositionsAsXML() {
    ArrayList<Position> pList = new ArrayList<Position>(positionMap.values());
    Collections.sort(pList);

    StringBuilder xml = new StringBuilder("<positions>");
    for (Position p : pList) xml.append(p.toXML());
    xml.append("</positions>");
    return xml.toString();
  }
コード例 #5
0
 public String getParticpantsWithPositionAsXML(String positionName) {
   String result = "<participants/>";
   if (positionName != null) {
     Position p = getPositionByLabel(positionName);
     if (p != null) {
       result = getPositionParticipantsAsXML(p.getID());
     }
   }
   return result;
 }
コード例 #6
0
 public String getParticipantPositionsAsXML(String pid) {
   Set<Position> posSet = getParticipantPositions(pid);
   if (posSet != null) {
     String header = String.format("<positions participantid=\"%s\">", pid);
     StringBuilder xml = new StringBuilder(header);
     for (Position p : posSet) xml.append(p.toXML());
     xml.append("</positions>");
     return xml.toString();
   } else return ("<positions/>");
 }
コード例 #7
0
 /**
  * Gets the set of Participants the ultimately report to the Position passed
  *
  * @param manager the 'manager' Position
  * @return the set of Particpants 'managed' by this Position
  */
 public Set<Participant> getParticipantsReportingToPosition(Position manager) {
   Set<Participant> result = new HashSet<Participant>();
   Set<Position> posSet = getPositions();
   for (Position pos : posSet) {
     if (pos.ultimatelyReportsTo(manager)) {
       result.addAll(castToParticipantSet(pos.getResources()));
     }
   }
   return result;
 }
コード例 #8
0
 public Set<Participant> getParticipantsWithPosition(String positionName) {
   Set<Participant> result = null;
   if (positionName != null) {
     Position p = getPositionByLabel(positionName);
     if (p != null) {
       result = getPositionParticipants(p.getID());
     }
   }
   return result;
 }
コード例 #9
0
 /**
  * Gets the immediate supervisor of a participant. If the participant holds multiple positions,
  * and therefore has multiple supervisors, one is returned as a random selection.
  *
  * @param p the participant to get the supervisor of
  * @return the Participant who is the supervisor of the pid passed, or null if there is no
  *     supervisor.
  */
 public Participant getImmediateSupervisor(Participant p) {
   if (p != null) {
     for (Position position : p.getPositions()) {
       Position superPosition = position.getReportsTo();
       if (superPosition != null) {
         Set<AbstractResource> resources = superPosition.getResources();
         if (!resources.isEmpty()) {
           return (Participant) resources.iterator().next();
         }
       }
     }
   }
   return null;
 }
コード例 #10
0
 public String addPosition(Position p) {
   if (isDataEditable(ResUnit.Position)) {
     String newID = getDataSource(ResUnit.Position).insert(p); // persist it
     if (!hasDefaultDataSource(ResUnit.Position)) p.setID(newID);
     putPosition(p); // ...and add it to the data set
     return newID;
   } else return fail("External Position dataset is read-only");
 }
コード例 #11
0
  public synchronized void removeOrgGroup(OrgGroup o) {
    if (isDataEditable(ResUnit.OrgGroup)) {
      for (Position position : getPositions()) {
        OrgGroup group = position.getOrgGroup();
        if ((group != null) && group.getID().equals(o.getID())) {
          position.setOrgGroup((OrgGroup) null);
          getDataSource(ResUnit.Position).update(position);
        }
      }

      for (OrgGroup group : getOrgGroups()) {
        OrgGroup owner = group.getBelongsTo();
        if ((owner != null) && owner.getID().equals(o.getID())) {
          group.setBelongsTo((OrgGroup) null);
          getDataSource(ResUnit.OrgGroup).update(group);
        }
      }
      delOrgGroup(o);
      getDataSource(ResUnit.OrgGroup).delete(o);
    }
  }
コード例 #12
0
 public synchronized void removePosition(Position p) {
   if (isDataEditable(ResUnit.Position)) {
     disconnectResources(p);
     for (Position position : getPositions()) {
       Position boss = position.getReportsTo();
       if ((boss != null) && boss.getID().equals(p.getID())) {
         position.setReportsTo((Position) null);
         getDataSource(ResUnit.Position).update(position);
       }
     }
     delPosition(p);
     getDataSource(ResUnit.Position).delete(p);
   }
 }
コード例 #13
0
 public String checkCyclicPositionReference(Position position, String refID) {
   String result = null;
   List<String> hierarchy = new ArrayList<String>();
   hierarchy.add(position.getTitle());
   Position owner = getPosition(refID);
   String refName = owner.getTitle(); // title of posn attempting to add to
   while (owner != null) {
     hierarchy.add(owner.getTitle());
     if (owner.equals(position)) {
       result = constructCyclicAttributeErrorMessage(hierarchy, "position", refName);
       break;
     }
     owner = owner.getReportsTo();
   }
   return result;
 }
コード例 #14
0
 public void delPosition(Position p) {
   positionMap.remove(p.getID());
   setChangeStamp(ResUnit.Position);
 }
コード例 #15
0
 public void putPosition(Position p) {
   positionMap.put(p.getID(), p);
   setChangeStamp(ResUnit.Position);
 }
コード例 #16
0
 public Set<Participant> getPositionParticipants(String pid) {
   Position p = positionMap.get(pid);
   return (p != null) ? castToParticipantSet(p.getResources()) : null;
 }