Esempio n. 1
0
  public List<String> getDepartmentsForPrincipalInRoles(
      String principalId, List<String> roleIds, DateTime asOfDate, boolean isActiveOnly) {
    Set<String> departments = new HashSet<String>();

    Map<String, String> qualifiers = new HashMap<String, String>();
    qualifiers.put(KPMERoleMemberAttribute.WORK_AREA.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), "%");
    List<Map<String, String>> roleQualifiers =
        getRoleQualifiers(principalId, roleIds, qualifiers, asOfDate, isActiveOnly);

    for (Map<String, String> roleQualifier : roleQualifiers) {
      String department =
          MapUtils.getString(
              roleQualifier, KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName());
      String groupKeyCode =
          MapUtils.getString(
              roleQualifier, KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName());
      if (department != null && groupKeyCode != null) {
        departments.add(groupKeyCode + "|" + department);
      }
    }

    List<String> locations =
        getLocationsForPrincipalInRoles(principalId, roleIds, asOfDate, isActiveOnly);
    departments.addAll(
        getDepartmentService().getDepartmentValuesWithLocations(locations, asOfDate.toLocalDate()));

    return new ArrayList<String>(departments);
  }
  @Override
  public List<Map<String, String>> resolveMultipleRoleQualifiers(
      @WebParam(name = "kewTypeId") String kewTypeId,
      @WebParam(name = "roleId") String roleId,
      @WebParam(name = "document") Document document,
      @WebParam(name = "documentContent") DocumentContent documentContent) {
    List<Map<String, String>> deptQualifiers = new ArrayList<Map<String, String>>();
    // try to get values from maintainable object if instance of position
    try {
      org.kuali.rice.krad.document.Document doc =
          KRADServiceLocatorWeb.getDocumentService()
              .getByDocumentHeaderId(document.getDocumentId());
      if (doc instanceof MaintenanceDocument) {
        MaintenanceDocument md = (MaintenanceDocument) doc;
        if (md.getNewMaintainableObject().getDataObject() instanceof PositionBo) {
          PositionBo position = (PositionBo) (md.getNewMaintainableObject().getDataObject());

          for (PositionDepartmentBo positionDepartment : position.getDepartmentList()) {
            if (!positionDepartment.getDeptAfflObj().isPrimaryIndicator()) {
              Map<String, String> qualifiers = new HashMap<String, String>();
              qualifiers.put(
                  KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(),
                  String.valueOf(positionDepartment.getDepartment()));
              qualifiers.put(
                  KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(),
                  String.valueOf(positionDepartment.getGroupKeyCode()));
              deptQualifiers.add(qualifiers);
            }
          }
        }
      }
    } catch (WorkflowException e) {
      LOG.error("Unable to retrieve document with documemnt ID: " + document.getDocumentId());
    }

    if (deptQualifiers.isEmpty()) {
      Map<String, String> qualifiers = new HashMap<String, String>();
      qualifiers.put(
          KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), StringUtils.EMPTY);
      qualifiers.put(
          KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), StringUtils.EMPTY);
      deptQualifiers.add(qualifiers);
    }
    return deptQualifiers;
  }
Esempio n. 3
0
 public List<RoleMember> getRoleMembersInDepartment(
     String namespaceCode,
     String roleName,
     String department,
     String groupKeyCode,
     DateTime asOfDate,
     boolean isActiveOnly) {
   Map<String, String> qualification = new HashMap<String, String>();
   qualification.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), department);
   qualification.put(
       KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), groupKeyCode);
   return getRoleMembers(namespaceCode, roleName, qualification, asOfDate, isActiveOnly);
 }
Esempio n. 4
0
 public boolean principalHasRoleInDepartment(
     String principalId,
     String namespaceCode,
     String roleName,
     String department,
     String groupKeyCode,
     DateTime asOfDate) {
   Map<String, String> qualification = new HashMap<String, String>();
   qualification.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), department);
   qualification.put(
       KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), groupKeyCode);
   return principalHasRole(principalId, namespaceCode, roleName, qualification, asOfDate);
 }
  protected void addRoleQualification(Object dataObject, Map<String, String> attributes) {
    super.addRoleQualification(dataObject, attributes);

    // put in the department qualifier for the role membership attributes
    if (dataObject instanceof AssignmentBo && dataObject != null) {
      attributes.put(
          KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(),
          ((AssignmentBo) dataObject).getDept());
      attributes.put(
          KPMERoleMemberAttribute.WORK_AREA.getRoleMemberAttributeName(),
          ((AssignmentBo) dataObject).getWorkArea().toString());
    }
  }
Esempio n. 6
0
  public List<String> getLocationsForPrincipalInRoles(
      String principalId, List<String> roleIds, DateTime asOfDate, boolean isActiveOnly) {
    Set<String> locations = new HashSet<String>();

    Map<String, String> qualifiers = new HashMap<String, String>();
    qualifiers.put(KPMERoleMemberAttribute.WORK_AREA.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.DEPARTMENT.getRoleMemberAttributeName(), "%");
    qualifiers.put(KPMERoleMemberAttribute.GROUP_KEY_CODE.getRoleMemberAttributeName(), "%");
    List<Map<String, String>> roleQualifiers =
        getRoleQualifiers(principalId, roleIds, qualifiers, asOfDate, isActiveOnly);

    for (Map<String, String> roleQualifier : roleQualifiers) {
      String location =
          MapUtils.getString(
              roleQualifier, KPMERoleMemberAttribute.LOCATION.getRoleMemberAttributeName());

      if (location != null) {
        locations.add(location);
      }
    }

    return new ArrayList<String>(locations);
  }