Search in sources :

Example 6 with KimType

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();
        }
    }
}
Also used : SequenceAccessorService(org.kuali.kfs.krad.service.SequenceAccessorService) KimType(org.kuali.kfs.kim.impl.type.KimType)

Example 7 with KimType

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

Example 8 with KimType

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;
}
Also used : KimApiServiceLocator(org.kuali.kfs.kim.api.services.KimApiServiceLocator) KimAttribute(org.kuali.kfs.kim.impl.common.attribute.KimAttribute) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) KimTypeInfoService(org.kuali.kfs.kim.api.type.KimTypeInfoService) HashMap(java.util.HashMap) DelegationType(org.kuali.kfs.core.api.delegation.DelegationType) StringUtils(org.apache.commons.lang3.StringUtils) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) DelegateType(org.kuali.kfs.kim.impl.common.delegate.DelegateType) ResponsibilityInternalService(org.kuali.kfs.kim.impl.responsibility.ResponsibilityInternalService) KimType(org.kuali.kfs.kim.impl.type.KimType) Map(java.util.Map) LookupService(org.kuali.kfs.krad.service.LookupService) GroupService(org.kuali.kfs.kim.api.group.GroupService) MemberType(org.kuali.kfs.core.api.membership.MemberType) Group(org.kuali.kfs.kim.impl.group.Group) DelegateMember(org.kuali.kfs.kim.impl.common.delegate.DelegateMember) KRADServiceLocatorWeb(org.kuali.kfs.krad.service.KRADServiceLocatorWeb) Collection(java.util.Collection) KimConstants(org.kuali.kfs.kim.api.KimConstants) KRADServiceLocator(org.kuali.kfs.krad.service.KRADServiceLocator) Set(java.util.Set) KimImplServiceLocator(org.kuali.kfs.kim.impl.services.KimImplServiceLocator) KRADPropertyConstants(org.kuali.kfs.krad.util.KRADPropertyConstants) ObjectUtils(org.kuali.kfs.krad.util.ObjectUtils) IdentityService(org.kuali.kfs.kim.api.identity.IdentityService) List(java.util.List) Logger(org.apache.logging.log4j.Logger) BusinessObjectService(org.kuali.kfs.krad.service.BusinessObjectService) Principal(org.kuali.kfs.kim.impl.identity.principal.Principal) RoleContract(org.kuali.kfs.kim.api.role.RoleContract) RoleTypeService(org.kuali.kfs.kim.framework.role.RoleTypeService) Collections(java.util.Collections) LogManager(org.apache.logging.log4j.LogManager) CriteriaLookupService(org.kuali.kfs.core.api.criteria.CriteriaLookupService) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute) HashMap(java.util.HashMap) KimTypeInfoService(org.kuali.kfs.kim.api.type.KimTypeInfoService) ObjectUtils(org.kuali.kfs.krad.util.ObjectUtils)

Example 9 with KimType

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;
    }
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) KimTypeAttribute(org.kuali.kfs.kim.impl.type.KimTypeAttribute)

Example 10 with KimType

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);
    }
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) PermissionTypeService(org.kuali.kfs.kim.framework.permission.PermissionTypeService)

Aggregations

KimType (org.kuali.kfs.kim.impl.type.KimType)13 KimTypeAttribute (org.kuali.kfs.kim.impl.type.KimTypeAttribute)7 ArrayList (java.util.ArrayList)3 SecurityRequestRoleQualification (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification)2 SecurityRequestRoleQualificationDetail (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualificationDetail)2 HashMap (java.util.HashMap)2 RoleTypeService (org.kuali.kfs.kim.framework.role.RoleTypeService)2 KimTypeService (org.kuali.kfs.kim.framework.type.KimTypeService)2 KimAttribute (org.kuali.kfs.kim.impl.common.attribute.KimAttribute)2 DelegateType (org.kuali.kfs.kim.impl.common.delegate.DelegateType)2 SecurityProvisioning (edu.cornell.kfs.ksr.businessobject.SecurityProvisioning)1 SecurityProvisioningGroup (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup)1 SecurityRequestRole (edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)1 SecurityRequestDocument (edu.cornell.kfs.ksr.document.SecurityRequestDocument)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Stream (java.util.stream.Stream)1