public Map<String, String> getRoleIdentifiers() {
   Map<String, String> idMap = new Hashtable<String, String>();
   for (Role r : getRoles()) {
     idMap.put(r.getID(), r.getName());
   }
   return idMap;
 }
 public Map<String, String> getOrgGroupIdentifiers() {
   Map<String, String> idMap = new Hashtable<String, String>();
   for (OrgGroup o : getOrgGroups()) {
     idMap.put(o.getID(), o.getGroupName());
   }
   return idMap;
 }
 public Map<String, String> getNonHumanCategoryIdentifiers() {
   Map<String, String> idMap = new Hashtable<String, String>();
   for (NonHumanCategory r : getNonHumanCategories()) {
     idMap.put(r.getID(), r.getName());
   }
   return idMap;
 }
 public Map<String, String> getNonHumanResourceIdentifiers() {
   Map<String, String> idMap = new Hashtable<String, String>();
   for (NonHumanResource r : getNonHumanResources()) {
     idMap.put(r.getID(), r.getName());
   }
   return idMap;
 }
 private void initUnitMaps(DataSource source) {
   long now = System.currentTimeMillis();
   for (ResUnit unit : ResUnit.values()) {
     _sources.put(unit, source);
     _changeStamp.put(unit, now);
   }
 }
 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;
 }
 public Map<String, String> getCapabilityIdentifiers() {
   Map<String, String> idMap = new Hashtable<String, String>();
   for (Capability c : getCapabilities()) {
     idMap.put(c.getID(), c.getCapability());
   }
   return idMap;
 }
 public String getNonHumanResourceNames() {
   XNode node = new XNode("nonHumanResourceNames");
   for (NonHumanResource r : nonHumanMap.values()) {
     node.addChild("name", r.getName());
   }
   return node.toString();
 }
 public Set<NonHumanSubCategory> getNonHumanSubCategories() {
   Set<NonHumanSubCategory> set = new HashSet<NonHumanSubCategory>();
   for (NonHumanCategory c : nonHumanCategoryMap.values()) {
     set.addAll(c.getSubCategories());
   }
   return set;
 }
 public long getLastChangeStamp() {
   long lastChange = 0;
   for (Long stamp : _changeStamp.values()) {
     if (stamp > lastChange) lastChange = stamp;
   }
   return lastChange;
 }
 public Set<Participant> getOrgGroupMembers(OrgGroup o) {
   Set<Participant> result = new HashSet<Participant>();
   for (Participant p : participantMap.values()) {
     if (p.isOrgGroupMember(o)) result.add(p);
   }
   return result;
 }
 public String getNonHumanCategoryNames() {
   XNode node = new XNode("nonHumanCategoryNames");
   for (NonHumanCategory r : nonHumanCategoryMap.values()) {
     node.addChild("name", r.getName());
   }
   return node.toString();
 }
  public String getNonHumanCategoriesAsXML() {
    Set<NonHumanCategory> rList = new TreeSet<NonHumanCategory>(nonHumanCategoryMap.values());

    StringBuilder xml = new StringBuilder("<nonhumancategories>");
    for (NonHumanCategory r : rList) xml.append(r.toXML());
    xml.append("</nonhumancategories>");
    return xml.toString();
  }
  public String getNonHumanResourcesAsXML() {
    Set<NonHumanResource> rList = new TreeSet<NonHumanResource>(nonHumanMap.values());

    StringBuilder xml = new StringBuilder("<nonhumanresources>");
    for (NonHumanResource r : rList) xml.append(r.toXML());
    xml.append("</nonhumanresources>");
    return xml.toString();
  }
 // @return a csv listing of the full name of each role
 public String getRoleNames() {
   StringBuilder csvList = new StringBuilder();
   for (Role r : roleMap.values()) {
     if (csvList.length() > 0) csvList.append(",");
     csvList.append(r.getName());
   }
   return csvList.toString();
 }
 public Capability getCapabilityByLabel(String label) {
   for (Capability c : capabilityMap.values()) {
     if (c.getCapability().equals(label)) {
       return c;
     }
   }
   return null;
 }
 public Position getPositionByLabel(String label) {
   for (Position p : positionMap.values()) {
     if (p.getTitle().equals(label)) {
       return p;
     }
   }
   return null;
 }
 public OrgGroup getOrgGroupByLabel(String label) {
   for (OrgGroup o : orgGroupMap.values()) {
     if (o.getGroupName().equals(label)) {
       return o;
     }
   }
   return null;
 }
  public String getRolesAsXML() {
    ArrayList<Role> rList = new ArrayList<Role>(roleMap.values());
    Collections.sort(rList);

    StringBuilder xml = new StringBuilder("<roles>");
    for (Role r : rList) xml.append(r.toXML());
    xml.append("</roles>");
    return xml.toString();
  }
  public String getCapabilitiesAsXML() {
    ArrayList<Capability> cList = new ArrayList<Capability>(capabilityMap.values());
    Collections.sort(cList);

    StringBuilder xml = new StringBuilder("<capabilities>");
    for (Capability c : cList) xml.append(c.toXML());
    xml.append("</capabilities>");
    return xml.toString();
  }
  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();
  }
  public String getOrgGroupsAsXML() {
    ArrayList<OrgGroup> oList = new ArrayList<OrgGroup>(orgGroupMap.values());
    Collections.sort(oList);

    StringBuilder xml = new StringBuilder("<orggroups>");
    for (OrgGroup o : oList) xml.append(o.toXML());
    xml.append("</orggroups>");
    return xml.toString();
  }
 public String getNonHumanCategorySet() {
   XNode node = new XNode("nonHumanCategorySet");
   for (NonHumanCategory category : nonHumanCategoryMap.values()) {
     XNode categoryNode = node.addChild("category");
     categoryNode.addAttribute("name", category.getName());
     for (String subcategory : category.getSubCategoryNames()) {
       categoryNode.addChild("subcategory", subcategory);
     }
   }
   return node.toString();
 }
 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;
 }
 public boolean isKnownNonHumanCategory(String rid) {
   return nonHumanCategoryMap.containsKey(rid);
 }
 public boolean isKnownNonHumanResource(String rid) {
   return nonHumanMap.containsKey(rid);
 }
 private void setChangeStamp(ResUnit unit) {
   _changeStamp.put(unit, System.currentTimeMillis());
 }
 public boolean isKnownOrgGroup(String oid) {
   return orgGroupMap.containsKey(oid);
 }
 public boolean isKnownPosition(String pid) {
   return positionMap.containsKey(pid);
 }
 public boolean isKnownCapability(String cid) {
   return capabilityMap.containsKey(cid);
 }