Search in sources :

Example 26 with IdmRoleCompositionDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleCompositionService method internalExport.

@Override
protected IdmRoleCompositionDto internalExport(UUID id) {
    IdmRoleCompositionDto dto = this.get(id);
    // Advanced pairing
    // We cannot clear all embedded data, because we need to export DTO for
    // connected sub and superior role.
    BaseDto roleSubDto = dto.getEmbedded().get(IdmRoleComposition_.sub.getName());
    BaseDto roleSuperDto = dto.getEmbedded().get(IdmRoleComposition_.superior.getName());
    dto.getEmbedded().clear();
    dto.getEmbedded().put(IdmRoleComposition_.sub.getName(), roleSubDto);
    dto.getEmbedded().put(IdmRoleComposition_.superior.getName(), roleSuperDto);
    return dto;
}
Also used : IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto)

Example 27 with IdmRoleCompositionDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleCompositionService method findAllSubRoles.

private void findAllSubRoles(List<IdmRoleCompositionDto> results, List<IdmRoleCompositionDto> parents, UUID superiorId, BasePermission... permission) {
    IdmRoleCompositionFilter filter = new IdmRoleCompositionFilter();
    filter.setSuperiorId(superiorId);
    // 
    find(filter, null, permission).stream().filter(// cyclic composition in the first level is ignored
    subRole -> !subRole.getSuperior().equals(subRole.getSub())).forEach(subRole -> {
        if (!// duplicate composition is enabled, but from different superior role => is not cycle, is duplicate but ok
        parents.stream().map(IdmRoleCompositionDto::getSuperior).anyMatch(superior -> superior.equals(subRole.getSub()))) {
            results.add(subRole);
            List<IdmRoleCompositionDto> lineParents = Lists.newArrayList(parents);
            lineParents.add(subRole);
            // 
            IdmRoleDto subRoleDto = DtoUtils.getEmbedded(subRole, IdmRoleComposition_.sub);
            if (subRoleDto.getChildrenCount() > 0) {
                findAllSubRoles(results, lineParents, subRole.getSub(), permission);
            }
        }
    });
}
Also used : DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmRoleCompositionRepository(eu.bcvsolutions.idm.core.model.repository.IdmRoleCompositionRepository) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) IdmRoleCompositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCompositionFilter) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) ValueWrapper(eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) IdmRoleComposition(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) Lists(com.google.common.collect.Lists) Predicate(javax.persistence.criteria.Predicate) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) BasePermission(eu.bcvsolutions.idm.core.security.api.domain.BasePermission) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) IdentityRoleEventType(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent.IdentityRoleEventType) IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Root(javax.persistence.criteria.Root) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) IdmRole_(eu.bcvsolutions.idm.core.model.entity.IdmRole_) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmRoleComposition_(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_) AbstractEventableDtoService(eu.bcvsolutions.idm.core.api.service.AbstractEventableDtoService) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) Set(java.util.Set) IdmRoleCompositionService(eu.bcvsolutions.idm.core.api.service.IdmRoleCompositionService) IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent) UUID(java.util.UUID) Serializable(java.io.Serializable) List(java.util.List) ExportDescriptorDto(eu.bcvsolutions.idm.core.api.dto.ExportDescriptorDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) AuthorizableType(eu.bcvsolutions.idm.core.security.api.dto.AuthorizableType) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) IdmRoleCompositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCompositionFilter)

Example 28 with IdmRoleCompositionDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto in project CzechIdMng by bcvsolutions.

the class DefaultIdmRoleCompositionService method findAllSuperiorRoles.

/**
 * @param results found parents
 * @param subId original role, for which parent are found => used for prevent cycles
 * @param subChildId curently processed sub role
 * @param permission
 */
private void findAllSuperiorRoles(List<IdmRoleCompositionDto> results, UUID subId, UUID subChildId, BasePermission... permission) {
    IdmRoleCompositionFilter filter = new IdmRoleCompositionFilter();
    filter.setSubId(subChildId);
    // 
    find(filter, null, permission).filter(// cyclic composition in the first level is ignored
    superiorRole -> !superiorRole.getSuperior().equals(superiorRole.getSub())).filter(// cyclic to original
    superiorRole -> !superiorRole.getSuperior().equals(subId)).forEach(superiorRole -> {
        if (!results.contains(superiorRole)) {
            results.add(superiorRole);
            // 
            findAllSuperiorRoles(results, subId, superiorRole.getSuperior(), permission);
        }
    });
}
Also used : DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmRoleCompositionRepository(eu.bcvsolutions.idm.core.model.repository.IdmRoleCompositionRepository) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) IdmAccountDto(eu.bcvsolutions.idm.core.api.dto.IdmAccountDto) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto) IdmRoleCompositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCompositionFilter) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) ValueWrapper(eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) IdmRoleComposition(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) Lists(com.google.common.collect.Lists) Predicate(javax.persistence.criteria.Predicate) CollectionUtils(org.apache.commons.collections.CollectionUtils) Map(java.util.Map) BasePermission(eu.bcvsolutions.idm.core.security.api.domain.BasePermission) CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) IdentityRoleEventType(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent.IdentityRoleEventType) IdmExportImportDto(eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) Root(javax.persistence.criteria.Root) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) IdmRole_(eu.bcvsolutions.idm.core.model.entity.IdmRole_) IdmIdentityRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter) IdmRoleComposition_(eu.bcvsolutions.idm.core.model.entity.IdmRoleComposition_) AbstractEventableDtoService(eu.bcvsolutions.idm.core.api.service.AbstractEventableDtoService) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) Set(java.util.Set) IdmRoleCompositionService(eu.bcvsolutions.idm.core.api.service.IdmRoleCompositionService) IdentityRoleEvent(eu.bcvsolutions.idm.core.model.event.IdentityRoleEvent) UUID(java.util.UUID) Serializable(java.io.Serializable) List(java.util.List) ExportDescriptorDto(eu.bcvsolutions.idm.core.api.dto.ExportDescriptorDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) AuthorizableType(eu.bcvsolutions.idm.core.security.api.dto.AuthorizableType) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) IdmRoleCompositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleCompositionFilter)

Example 29 with IdmRoleCompositionDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto in project CzechIdMng by bcvsolutions.

the class IdmRoleCompositionControllerRestTest method prepareDto.

@Override
protected IdmRoleCompositionDto prepareDto() {
    IdmRoleCompositionDto dto = new IdmRoleCompositionDto();
    dto.setSuperior(getHelper().createRole().getId());
    dto.setSub(getHelper().createRole().getId());
    // 
    return dto;
}
Also used : IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto)

Example 30 with IdmRoleCompositionDto

use of eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto in project CzechIdMng by bcvsolutions.

the class ComplexHrProcessIntegrationTest method createBusinessRole.

/**
 * Aggregation of roles into business roles
 */
private void createBusinessRole() {
    IdmRoleDto roleSuper = null;
    IdmRoleDto roleSub = null;
    IdmRoleCompositionDto roleCompose = null;
    // All business role
    roleSuper = roleService.getByCode(allBusinessRole);
    // Group all
    roleSub = roleService.getByCode(adGroupAllRole);
    roleCompose = new IdmRoleCompositionDto();
    roleCompose.setSuperior(roleSuper.getId());
    roleCompose.setSub(roleSub.getId());
    roleCompositionService.save(roleCompose);
    // Group Pki
    roleSub = roleService.getByCode(adGroupPkiRole);
    roleCompose = new IdmRoleCompositionDto();
    roleCompose.setSuperior(roleSuper.getId());
    roleCompose.setSub(roleSub.getId());
    roleCompositionService.save(roleCompose);
    // Consultant business role
    roleSuper = roleService.getByCode(consultantBusinessRole);
    // Consultant1
    roleSub = roleService.getByCode(adGroupCons1Role);
    roleCompose = new IdmRoleCompositionDto();
    roleCompose.setSuperior(roleSuper.getId());
    roleCompose.setSub(roleSub.getId());
    roleCompositionService.save(roleCompose);
    // Consultant2
    roleSub = roleService.getByCode(adGroupCons2Role);
    roleCompose = new IdmRoleCompositionDto();
    roleCompose.setSuperior(roleSuper.getId());
    roleCompose.setSub(roleSub.getId());
    roleCompositionService.save(roleCompose);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleCompositionDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto)

Aggregations

IdmRoleCompositionDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleCompositionDto)47 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)35 Test (org.junit.Test)24 UUID (java.util.UUID)23 List (java.util.List)22 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)21 Autowired (org.springframework.beans.factory.annotation.Autowired)21 IdmRoleCompositionService (eu.bcvsolutions.idm.core.api.service.IdmRoleCompositionService)20 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)19 IdmIdentityRoleService (eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService)18 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)16 Set (java.util.Set)16 IdmRoleService (eu.bcvsolutions.idm.core.api.service.IdmRoleService)15 Assert (org.junit.Assert)15 Transactional (org.springframework.transaction.annotation.Transactional)15 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)14 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)13 IdmIdentityRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityRoleFilter)13 ArrayList (java.util.ArrayList)13 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)12