Search in sources :

Example 1 with ResponsibilityTypeService

use of org.kuali.kfs.kim.framework.responsibility.ResponsibilityTypeService in project cu-kfs by CU-CommunityApps.

the class ResponsibilityServiceImpl method getMatchingResponsibilities.

/**
 * Compare each of the passed in responsibilities with the given responsibilityDetails. Those that match are
 * added to the result list.
 */
private List<Responsibility> getMatchingResponsibilities(List<Responsibility> responsibilities, Map<String, String> responsibilityDetails) {
    // if no details passed, assume that all match
    if (responsibilityDetails == null || responsibilityDetails.isEmpty()) {
        return responsibilities;
    }
    final List<Responsibility> applicableResponsibilities = new ArrayList<>();
    // otherwise, attempt to match the permission details
    // build a map of the template IDs to the type services
    Map<String, ResponsibilityTypeService> responsibilityTypeServices = getResponsibilityTypeServicesByTemplateId(responsibilities);
    // build a map of permissions by template ID
    Map<String, List<Responsibility>> responsibilityMap = groupResponsibilitiesByTemplate(responsibilities);
    // service at once
    for (Map.Entry<String, List<Responsibility>> respEntry : responsibilityMap.entrySet()) {
        ResponsibilityTypeService responsibilityTypeService = responsibilityTypeServices.get(respEntry.getKey());
        List<Responsibility> responsibilityInfos = respEntry.getValue();
        if (responsibilityTypeService == null) {
            responsibilityTypeService = defaultResponsibilityTypeService;
        }
        applicableResponsibilities.addAll(responsibilityTypeService.getMatchingResponsibilities(responsibilityDetails, responsibilityInfos));
    }
    return Collections.unmodifiableList(applicableResponsibilities);
}
Also used : ResponsibilityTypeService(org.kuali.kfs.kim.framework.responsibility.ResponsibilityTypeService) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RoleResponsibility(org.kuali.kfs.kim.impl.role.RoleResponsibility) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with ResponsibilityTypeService

use of org.kuali.kfs.kim.framework.responsibility.ResponsibilityTypeService in project cu-kfs by CU-CommunityApps.

the class ResponsibilityServiceImpl method getResponsibilityTypeServicesByTemplateId.

private Map<String, ResponsibilityTypeService> getResponsibilityTypeServicesByTemplateId(Collection<Responsibility> responsibilities) {
    Map<String, ResponsibilityTypeService> responsibilityTypeServices = new HashMap<>(responsibilities.size());
    for (Responsibility responsibility : responsibilities) {
        final Template t = responsibility.getTemplate();
        final KimType type = kimTypeInfoService.getKimType(t.getKimTypeId());
        final String serviceName = type.getServiceName();
        if (serviceName != null) {
            ResponsibilityTypeService responsibiltyTypeService = GlobalResourceLoader.getService(QName.valueOf(serviceName));
            if (responsibiltyTypeService != null) {
                responsibilityTypeServices.put(responsibility.getTemplate().getId(), responsibiltyTypeService);
            } else {
                responsibilityTypeServices.put(responsibility.getTemplate().getId(), defaultResponsibilityTypeService);
            }
        }
    }
    return Collections.unmodifiableMap(responsibilityTypeServices);
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) HashMap(java.util.HashMap) ResponsibilityTypeService(org.kuali.kfs.kim.framework.responsibility.ResponsibilityTypeService) RoleResponsibility(org.kuali.kfs.kim.impl.role.RoleResponsibility) Template(org.kuali.kfs.kim.impl.common.template.Template)

Aggregations

HashMap (java.util.HashMap)2 ResponsibilityTypeService (org.kuali.kfs.kim.framework.responsibility.ResponsibilityTypeService)2 RoleResponsibility (org.kuali.kfs.kim.impl.role.RoleResponsibility)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Template (org.kuali.kfs.kim.impl.common.template.Template)1 KimType (org.kuali.kfs.kim.impl.type.KimType)1