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