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);
}
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);
}
Aggregations