use of eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultTestHelper method createRoleGuaranteeRole.
@Override
public IdmRoleGuaranteeRoleDto createRoleGuaranteeRole(IdmRoleDto role, IdmRoleDto guarantee, String guaranteeType) {
IdmRoleGuaranteeRoleDto dto = new IdmRoleGuaranteeRoleDto();
dto.setRole(role.getId());
dto.setGuaranteeRole(guarantee.getId());
dto.setType(guaranteeType);
//
return roleGuaranteeRoleService.save(dto);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleGuaranteeRoleService method internalExport.
@Override
protected IdmRoleGuaranteeRoleDto internalExport(UUID id) {
IdmRoleGuaranteeRoleDto dto = this.get(id);
// Advanced pairing
// We cannot clear all embedded data, because we need to export DTO for
// connected guarantee.
BaseDto guaranteeDto = dto.getEmbedded().get(IdmRoleGuaranteeRole_.guaranteeRole.getName());
dto.getEmbedded().clear();
dto.getEmbedded().put(IdmRoleGuaranteeRole_.guaranteeRole.getName(), guaranteeDto);
return dto;
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto in project CzechIdMng by bcvsolutions.
the class RoleExportBulkAction method exportRoleGuarantees.
/**
* Export role gurantees for given role.
*
* @param role
*/
private void exportRoleGuarantees(IdmRoleDto role) {
IdmRoleGuaranteeRoleFilter filter = new IdmRoleGuaranteeRoleFilter();
filter.setRole(role.getId());
List<IdmRoleGuaranteeRoleDto> dtos = roleGuaranteeRoleService.find(filter, null).getContent();
if (dtos.isEmpty()) {
roleGuaranteeRoleService.export(ExportManager.BLANK_UUID, this.getBatch());
}
dtos.forEach(dto -> {
roleGuaranteeRoleService.export(dto.getId(), this.getBatch());
});
// Set parent field -> set authoritative mode.
this.getExportManager().setAuthoritativeMode(IdmRoleGuaranteeRole_.role.getName(), IdmRoleGuaranteeFilter.PARAMETER_ROLE, IdmRoleGuaranteeRoleDto.class, this.getBatch());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto in project CzechIdMng by bcvsolutions.
the class RoleGuaranteeRoleSaveProcessor method process.
@Override
public EventResult<IdmRoleGuaranteeRoleDto> process(EntityEvent<IdmRoleGuaranteeRoleDto> event) {
IdmRoleGuaranteeRoleDto entity = event.getContent();
entity = service.saveInternal(entity);
event.setContent(entity);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRoleGuaranteeServiceIntegrationTest method testFindRoleGuaranteeByRoleGuarantee.
@Test
public void testFindRoleGuaranteeByRoleGuarantee() {
IdmRoleDto guaranteeRole = getHelper().createRole();
IdmRoleDto guaranteeRoleTwo = getHelper().createRole();
//
IdmRoleDto role1 = getHelper().createRole();
IdmRoleDto role2 = getHelper().createRole();
IdmRoleDto role3 = getHelper().createRole();
//
IdmRoleGuaranteeRoleDto roleGuaranteeOne = new IdmRoleGuaranteeRoleDto();
roleGuaranteeOne.setRole(role1.getId());
roleGuaranteeOne.setGuaranteeRole(guaranteeRole.getId());
roleGuaranteeOne = roleGuaranteeRoleService.save(roleGuaranteeOne);
//
IdmRoleGuaranteeRoleDto roleGuaranteeTwo = new IdmRoleGuaranteeRoleDto();
roleGuaranteeTwo.setRole(role2.getId());
roleGuaranteeTwo.setGuaranteeRole(guaranteeRoleTwo.getId());
roleGuaranteeTwo = roleGuaranteeRoleService.save(roleGuaranteeTwo);
//
IdmRoleGuaranteeRoleDto roleGuaranteeThree = new IdmRoleGuaranteeRoleDto();
roleGuaranteeThree.setRole(role3.getId());
roleGuaranteeThree.setGuaranteeRole(guaranteeRole.getId());
roleGuaranteeThree = roleGuaranteeRoleService.save(roleGuaranteeThree);
//
IdmRoleGuaranteeRoleFilter filter = new IdmRoleGuaranteeRoleFilter();
filter.setGuaranteeRole(guaranteeRole.getId());
List<IdmRoleGuaranteeRoleDto> list = roleGuaranteeRoleService.find(filter, null).getContent();
Assert.assertEquals(2, list.size());
//
List<UUID> roles = list.stream().map(IdmRoleGuaranteeRoleDto::getRole).collect(Collectors.toList());
IdmRoleGuaranteeRoleDto roleGuaranteeFirst = list.get(0);
Assert.assertEquals(guaranteeRole.getId(), roleGuaranteeFirst.getGuaranteeRole());
Assert.assertTrue(roles.contains(role1.getId()));
Assert.assertFalse(roles.contains(role2.getId()));
Assert.assertTrue(roles.contains(role3.getId()));
}
Aggregations