use of eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysRoleSystemServiceFilterTest method testSystemMappingIdFilter.
@Test
public void testSystemMappingIdFilter() {
IdmRoleDto role1 = helper.createRole();
IdmRoleDto role2 = helper.createRole();
SysSystemDto system1 = helper.createTestResourceSystem(true);
SysSystemDto system2 = helper.createTestResourceSystem(true);
//
SysSystemMappingDto sysSystemMappingDto1 = mappingService.findBySystemId(system1.getId(), SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
SysSystemMappingDto sysSystemMappingDto2 = mappingService.findBySystemId(system2.getId(), SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
SysRoleSystemDto roleSystem1 = createRoleSystem(role1.getId(), system1.getId(), sysSystemMappingDto1.getId());
createRoleSystem(role2.getId(), system1.getId(), sysSystemMappingDto2.getId());
//
SysRoleSystemFilter roleFilter = new SysRoleSystemFilter();
roleFilter.setSystemMappingId(sysSystemMappingDto1.getId());
Page<SysRoleSystemDto> pages = roleSystemService.find(roleFilter, null);
assertEquals(1, pages.getTotalElements());
assertEquals(roleSystem1.getId(), pages.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysRoleSystemServiceFilterTest method testRoleIdFilter.
@Test
public void testRoleIdFilter() {
IdmRoleDto role = helper.createRole();
IdmRoleDto role2 = helper.createRole();
SysSystemDto system = helper.createTestResourceSystem(true);
//
SysSystemMappingDto sysSystemMappingDto = mappingService.findBySystemId(system.getId(), SystemOperationType.PROVISIONING, SystemEntityType.IDENTITY).get(0);
SysRoleSystemDto roleSystem = createRoleSystem(role.getId(), system.getId(), sysSystemMappingDto.getId());
createRoleSystem(role2.getId(), system.getId(), sysSystemMappingDto.getId());
//
SysRoleSystemFilter roleFilter = new SysRoleSystemFilter();
roleFilter.setRoleId(role.getId());
Page<SysRoleSystemDto> pages = roleSystemService.find(roleFilter, null);
//
assertEquals(1, pages.getTotalElements());
assertEquals(roleSystem.getId(), pages.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter in project CzechIdMng by bcvsolutions.
the class SystemMappingDeleteProcessor method process.
@Override
public EventResult<SysSystemMappingDto> process(EntityEvent<SysSystemMappingDto> event) {
SysSystemMappingDto systemMapping = event.getContent();
//
if (configService.countBySystemMapping(systemMapping) > 0) {
throw new ResultCodeException(AccResultCode.SYSTEM_MAPPING_DELETE_FAILED_USED_IN_SYNC, ImmutableMap.of("mapping", systemMapping.getName()));
}
//
// remove all handled attributes
SysSystemAttributeMappingFilter filter = new SysSystemAttributeMappingFilter();
filter.setSystemMappingId(systemMapping.getId());
systemAttributeMappingService.find(filter, null).forEach(systemAttributeMapping -> {
systemAttributeMappingService.delete(systemAttributeMapping);
});
//
// delete mapped roles
SysRoleSystemFilter roleSystemFilter = new SysRoleSystemFilter();
roleSystemFilter.setSystemMappingId(systemMapping.getId());
roleSystemService.find(roleSystemFilter, null).forEach(roleSystem -> {
roleSystemService.delete(roleSystem);
});
//
systemMappingService.deleteInternal(systemMapping);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter in project CzechIdMng by bcvsolutions.
the class SysRoleSystemController method toFilter.
@Override
protected SysRoleSystemFilter toFilter(MultiValueMap<String, Object> parameters) {
SysRoleSystemFilter filter = new SysRoleSystemFilter();
filter.setRoleId(getParameterConverter().toUuid(parameters, "roleId"));
filter.setSystemId(getParameterConverter().toUuid(parameters, "systemId"));
return filter;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysRoleSystemFilter in project CzechIdMng by bcvsolutions.
the class CoreReferentialIntegrityIntegrationTest method testRoleReferentialIntegrity.
@Test
public void testRoleReferentialIntegrity() {
IdmRoleDto role = helper.createRole();
// role systems
SysSystemDto system = new SysSystemDto();
system.setName("system_" + System.currentTimeMillis());
system = systemService.save(system);
// schema
SysSchemaObjectClassDto objectClass = new SysSchemaObjectClassDto();
objectClass.setSystem(system.getId());
objectClass.setObjectClassName("__ACCOUNT__");
objectClass = schemaObjectClassService.save(objectClass);
SysSystemMappingDto systemMapping = new SysSystemMappingDto();
systemMapping.setName("default_" + System.currentTimeMillis());
systemMapping.setObjectClass(objectClass.getId());
systemMapping.setOperationType(SystemOperationType.PROVISIONING);
systemMapping.setEntityType(SystemEntityType.IDENTITY);
systemMapping = systemEntityHandlingService.save(systemMapping);
SysRoleSystemDto roleSystem = new SysRoleSystemDto();
roleSystem.setSystem(system.getId());
roleSystem.setRole(role.getId());
roleSystem.setSystemMapping(systemMapping.getId());
roleSystemService.save(roleSystem);
SysRoleSystemFilter filter = new SysRoleSystemFilter();
filter.setRoleId(role.getId());
assertNotNull(roleService.getByCode(role.getName()));
assertEquals(1, roleSystemService.find(filter, null).getTotalElements());
roleService.delete(role);
assertNull(roleService.getByCode(role.getName()));
assertEquals(0, roleSystemService.find(filter, null).getTotalElements());
}
Aggregations