use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method initOverloadedAttributes.
private void initOverloadedAttributes(List<SysRoleSystemAttributeDto> overloadingAttributes, List<AttributeMapping> defaultAttributes) {
SysSchemaAttributeDto attOne = new SysSchemaAttributeDto();
attOne.setName("attOne");
attOne.setObjectClass(objectClasses.get(0).getId());
attOne.setClassType(String.class.getName());
attOne = schemaAttributeService.save(attOne);
SysSchemaAttributeDto attTwo = new SysSchemaAttributeDto();
attTwo.setName("attTwo");
attTwo.setObjectClass(objectClasses.get(0).getId());
attTwo.setClassType(String.class.getName());
attTwo = schemaAttributeService.save(attTwo);
SysSystemAttributeMappingDto defOne = new SysSystemAttributeMappingDto();
defOne.setEntityAttribute(true);
defOne.setIdmPropertyName("one");
defOne.setName("defOne");
defOne.setDisabledAttribute(true);
defOne.setSchemaAttribute(attOne.getId());
defOne.setSystemMapping(systemMapping.getId());
defOne = systemAttributeMappingService.save(defOne);
defaultAttributes.add(defOne);
SysSystemAttributeMappingDto defTwo = new SysSystemAttributeMappingDto();
defTwo.setEntityAttribute(true);
defTwo.setIdmPropertyName("two");
defTwo.setName("defTwo");
defTwo.setSchemaAttribute(attTwo.getId());
defTwo.setSystemMapping(systemMapping.getId());
defTwo = systemAttributeMappingService.save(defTwo);
defaultAttributes.add(defTwo);
IdmRoleDto roleTwo = new IdmRoleDto();
roleTwo.setName("roleTwo");
roleTwo.setPriority(100);
roleTwo = roleService.save(roleTwo);
IdmRoleDto roleOne = new IdmRoleDto();
roleOne.setName("roleOne");
roleOne.setPriority(100);
roleOne = roleService.save(roleOne);
SysRoleSystemDto roleSystemTwo = new SysRoleSystemDto();
roleSystemTwo.setRole(roleTwo.getId());
roleSystemTwo.setSystem(system.getId());
roleSystemTwo.setSystemMapping(systemMapping.getId());
roleSystemTwo = roleSystemService.save(roleSystemTwo);
SysRoleSystemDto roleSystemOne = new SysRoleSystemDto();
roleSystemOne.setRole(roleOne.getId());
roleSystemOne.setSystem(system.getId());
roleSystemOne.setSystemMapping(systemMapping.getId());
roleSystemOne = roleSystemService.save(roleSystemOne);
SysRoleSystemAttributeDto overloadedRoleOne = new SysRoleSystemAttributeDto();
overloadedRoleOne.setSystemAttributeMapping(defOne.getId());
overloadedRoleOne.setEntityAttribute(true);
overloadedRoleOne.setIdmPropertyName("one");
overloadedRoleOne.setName("defOneOverloaded");
overloadedRoleOne.setDisabledDefaultAttribute(false);
overloadedRoleOne.setRoleSystem(roleSystemOne.getId());
overloadedRoleOne = roleSystemAttributeService.save(overloadedRoleOne);
overloadingAttributes.add(overloadedRoleOne);
SysRoleSystemAttributeDto overloadedRoleTwo = new SysRoleSystemAttributeDto();
overloadedRoleTwo.setSystemAttributeMapping(defOne.getId());
overloadedRoleTwo.setEntityAttribute(true);
overloadedRoleTwo.setIdmPropertyName("one");
overloadedRoleTwo.setName("defOneOverloadedRoleTwo");
overloadedRoleTwo.setDisabledDefaultAttribute(false);
overloadedRoleTwo.setRoleSystem(roleSystemTwo.getId());
overloadedRoleTwo = roleSystemAttributeService.save(overloadedRoleTwo);
overloadingAttributes.add(overloadedRoleTwo);
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysRoleSystemServiceFilterTest method createRoleSystem.
/**
* Create {@link SysRoleSystemDto}
*
* @param roleId
* @param systemId
* @param systemMappingId
* @return
*/
private SysRoleSystemDto createRoleSystem(UUID roleId, UUID systemId, UUID systemMappingId) {
helper.createRole();
SysRoleSystemDto role = new SysRoleSystemDto();
role.setRole(roleId);
role.setSystem(systemId);
role.setSystemMapping(systemMappingId);
return roleSystemService.save(role);
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysRoleSystemServiceFilterTest method testSystemIdFilter.
@Test
public void testSystemIdFilter() {
IdmRoleDto role1 = helper.createRole();
IdmRoleDto role2 = helper.createRole();
SysSystemDto system1 = helper.createTestResourceSystem(true);
SysSystemDto system2 = helper.createTestResourceSystem(true);
//
SysSystemMappingDto sysSystemMappingDto = mappingService.findBySystemId(system1.getId(), SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
createRoleSystem(role1.getId(), system1.getId(), sysSystemMappingDto.getId());
SysRoleSystemDto roleSystem2 = createRoleSystem(role2.getId(), system2.getId(), sysSystemMappingDto.getId());
//
SysRoleSystemFilter roleFilter = new SysRoleSystemFilter();
roleFilter.setSystemId(system2.getId());
Page<SysRoleSystemDto> pages = roleSystemService.find(roleFilter, null);
//
assertEquals(1, pages.getTotalElements());
assertEquals(roleSystem2.getId(), pages.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultSysRoleSystemService method save.
@Override
public SysRoleSystemDto save(SysRoleSystemDto dto, BasePermission... permission) {
Assert.notNull(dto, "RoleSystem cannot be null!");
Assert.notNull(dto.getRole(), "Role cannot be null!");
Assert.notNull(dto.getSystem(), "System cannot be null!");
SysRoleSystemFilter filter = new SysRoleSystemFilter();
filter.setRoleId(dto.getRole());
filter.setSystemId(dto.getSystem());
List<SysRoleSystemDto> roleSystems = this.find(filter, null).getContent();
boolean isDuplicated = roleSystems.stream().filter(roleSystem -> {
return !roleSystem.getId().equals(dto.getId());
}).findFirst().isPresent();
if (isDuplicated) {
IdmRoleDto roleDto = roleService.get(dto.getRole());
SysSystemDto systemDto = DtoUtils.getEmbedded(dto, SysRoleSystem_.system, SysSystemDto.class);
throw new ResultCodeException(AccResultCode.ROLE_SYSTEM_ALREADY_EXISTS, ImmutableMap.of("role", roleDto.getName(), "system", systemDto.getName()));
}
return super.save(dto, permission);
}
use of eu.bcvsolutions.idm.acc.dto.SysRoleSystemDto in project CzechIdMng by bcvsolutions.
the class DefaultTestHelper method createRoleSystem.
@Override
public SysRoleSystemDto createRoleSystem(IdmRoleDto role, SysSystemDto system) {
SysRoleSystemDto roleSystem = new SysRoleSystemDto();
roleSystem.setRole(role.getId());
roleSystem.setSystem(system.getId());
// default mapping
List<SysSystemMappingDto> mappings = systemMappingService.findBySystem(system, SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY);
//
roleSystem.setSystemMapping(mappings.get(0).getId());
return roleSystemService.save(roleSystem);
}
Aggregations