use of org.kuali.kfs.kim.impl.type.KimType in project cu-kfs by CU-CommunityApps.
the class IdentityManagementGroupDocument method initializeDocumentForNewGroup.
public void initializeDocumentForNewGroup() {
if (StringUtils.isBlank(this.groupId)) {
SequenceAccessorService sas = getSequenceAccessorService();
Long nextSeq = sas.getNextAvailableSequenceNumber(KimConstants.SequenceNames.KRIM_GROUP_ID_S, this.getClass());
this.groupId = nextSeq.toString();
}
if (StringUtils.isBlank(this.groupTypeId)) {
/*
* CU Customization: Backport the FINP-7913 fix.
*/
final KimType defaultKimType = KimApiServiceLocator.getKimTypeInfoService().findKimTypeByNameAndNamespace(KFSConstants.CoreModuleNamespaces.KFS, KimConstants.KIM_TYPE_DEFAULT_NAME);
if (defaultKimType != null) {
groupTypeId = defaultKimType.getId();
}
}
}
use of org.kuali.kfs.kim.impl.type.KimType 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);
}
use of org.kuali.kfs.kim.impl.type.KimType 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.KimType 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.KimType in project cu-kfs by CU-CommunityApps.
the class PermissionServiceImpl method getPermissionTypeService.
protected PermissionTypeService getPermissionTypeService(PermissionTemplate permissionTemplate) {
if (permissionTemplate == null) {
throw new IllegalArgumentException("permissionTemplate may not be null");
}
KimType kimType = kimTypeInfoService.getKimType(permissionTemplate.getKimTypeId());
String serviceName = kimType.getServiceName();
// if no service specified, return a default implementation
if (StringUtils.isBlank(serviceName)) {
return defaultPermissionTypeService;
}
try {
PermissionTypeService service = SpringContext.getBean(PermissionTypeService.class, serviceName);
// if we have a service name, it must exist
if (service == null) {
throw new RuntimeException("null returned for permission type service for service name: " + serviceName);
}
return service;
} catch (Exception ex) {
// sometimes service locators throw exceptions rather than returning null, handle that
throw new RuntimeException("Error retrieving service: " + serviceName + " from the SpringContext.", ex);
}
}
Aggregations