use of org.kuali.kfs.kim.impl.type.KimTypeAttribute in project cu-kfs by CU-CommunityApps.
the class RoleServiceBase method getAttributeNameToAttributeIdMappings.
/*
* CU Customization: Create mappings from attribute names to attribute IDs.
*/
protected Map<String, String> getAttributeNameToAttributeIdMappings(Collection<String> roleIds, Map<String, String> qualification) {
if (CollectionUtils.isEmpty(roleIds) || qualification == null || qualification.isEmpty()) {
return Collections.emptyMap();
}
KimTypeInfoService typeInfoService = getKimTypeInfoService();
Set<String> attributeNames = qualification.keySet();
Map<String, String> validAttributeIds = new HashMap<>();
roleIds.stream().map(this::getRoleLite).filter(ObjectUtils::isNotNull).map(RoleLite::getKimTypeId).distinct().map(typeInfoService::getKimType).filter(ObjectUtils::isNotNull).flatMap(kimType -> kimType.getAttributeDefinitions().stream()).map(KimTypeAttribute::getKimAttribute).filter(attribute -> ObjectUtils.isNotNull(attribute) && attributeNames.contains(attribute.getAttributeName())).forEach(attribute -> validAttributeIds.put(attribute.getAttributeName(), attribute.getId()));
for (String attributeName : attributeNames) {
validAttributeIds.computeIfAbsent(attributeName, this::getAttributeIdByName);
}
return validAttributeIds;
}
use of org.kuali.kfs.kim.impl.type.KimTypeAttribute in project cu-kfs by CU-CommunityApps.
the class RoleServiceBase method getAttributeIdFromKimType.
protected String getAttributeIdFromKimType(String kimTypeId, String attributeName) {
KimType kimType = getKimTypeInfoService().getKimType(kimTypeId);
if (ObjectUtils.isNull(kimType)) {
return null;
}
KimTypeAttribute attribute = kimType.getAttributeDefinitionByName(attributeName);
if (ObjectUtils.isNotNull(attribute) && ObjectUtils.isNotNull(attribute.getKimAttribute())) {
return attribute.getKimAttribute().getId();
} else {
return null;
}
}
use of org.kuali.kfs.kim.impl.type.KimTypeAttribute in project cu-kfs by CU-CommunityApps.
the class KSRUtil method isQualificationChangeRequested.
public static boolean isQualificationChangeRequested(SecurityRequestRole securityRequestRole) {
boolean changeRequested = false;
List<KimTypeAttribute> typeAttributes = getTypeAttributesForRoleRequest(securityRequestRole);
List<Map<String, String>> requestedQualifications = new ArrayList<Map<String, String>>();
for (SecurityRequestRoleQualification requestRoleQualification : securityRequestRole.getRequestRoleQualifications()) {
requestedQualifications.add(requestRoleQualification.buildQualificationAttributeSet());
}
String qualificationsString = KSRUtil.buildQualificationString(requestedQualifications, typeAttributes);
if (StringUtils.isBlank(qualificationsString)) {
qualificationsString = null;
}
if (!StringUtils.equals(qualificationsString, securityRequestRole.getCurrentQualifications())) {
changeRequested = true;
}
return changeRequested;
}
use of org.kuali.kfs.kim.impl.type.KimTypeAttribute in project cu-kfs by CU-CommunityApps.
the class OrgReviewRole method getAttributeSetAsQualifierList.
public List<KfsKimDocumentAttributeData> getAttributeSetAsQualifierList(Map<String, String> qualifiers) {
KimType kimTypeInfo = KimApiServiceLocator.getKimTypeInfoService().getKimType(kimTypeId);
List<KfsKimDocumentAttributeData> attributesList = new ArrayList<>();
KfsKimDocumentAttributeData attribData;
if (LOG.isDebugEnabled()) {
LOG.debug("passed qualifiers: " + StringUtils.join(qualifiers.keySet(), ", "));
}
for (String key : qualifiers.keySet()) {
KimTypeAttribute attribInfo = kimTypeInfo.getAttributeDefinitionByName(key);
if (attribInfo == null) {
LOG.debug("attribute info for qualifier " + key + " is null");
}
attribData = new KfsKimDocumentAttributeData();
attribData.setKimAttribute(attribInfo.getKimAttribute());
attribData.setKimTypId(kimTypeInfo.getId());
attribData.setKimAttrDefnId(attribInfo.getId());
// attribData.setAttrDataId(attrDataId) - Not Available
attribData.setAttrVal(qualifiers.get(key));
attributesList.add(attribData);
}
return attributesList;
}
use of org.kuali.kfs.kim.impl.type.KimTypeAttribute in project cu-kfs by CU-CommunityApps.
the class PersonInquirableImpl method buildRowsWithQualifierFields.
private List<Row> buildRowsWithQualifierFields(String sectionId, PersonImpl person, int memberIndex) {
List<KimTypeAttribute> attributeDefinitions;
List<KimAttributeData> attributeDetails;
if (StringUtils.equals(sectionId, "rolesSection")) {
attributeDefinitions = person.getRoleMembers().get(memberIndex).getRole().getKimType().getAttributeDefinitions();
attributeDetails = new ArrayList<>(person.getRoleMembers().get(memberIndex).getAttributeDetails());
} else {
attributeDefinitions = person.getDelegateMembers().get(memberIndex).getRoleMember().getRole().getKimType().getAttributeDefinitions();
attributeDetails = new ArrayList<>(person.getDelegateMembers().get(memberIndex).getAttributeDetails());
}
Map<String, Field> fieldsToAdd = new LinkedHashMap<>(buildQualifierAttributeFieldMap(attributeDefinitions));
setFieldValuesForMember(attributeDetails, fieldsToAdd);
List<Row> qualifierRows = fieldsToAdd.values().stream().map(Row::new).collect(Collectors.toList());
if (!fieldsToAdd.isEmpty()) {
qualifierRows.add(0, new Row(buildSeparatorField(SUB_SECTION_LABELS.get(sectionId))));
}
return qualifierRows;
}
Aggregations