Search in sources :

Example 6 with IdmRoleGuaranteeRoleDto

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);
}
Also used : IdmRoleGuaranteeRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto)

Example 7 with IdmRoleGuaranteeRoleDto

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;
}
Also used : IdmRoleGuaranteeRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto)

Example 8 with IdmRoleGuaranteeRoleDto

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());
}
Also used : IdmRoleGuaranteeRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeRoleFilter) IdmRoleGuaranteeRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto)

Example 9 with IdmRoleGuaranteeRoleDto

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);
}
Also used : DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IdmRoleGuaranteeRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto)

Example 10 with IdmRoleGuaranteeRoleDto

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()));
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleGuaranteeRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto) IdmRoleGuaranteeRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeRoleFilter) UUID(java.util.UUID) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Aggregations

IdmRoleGuaranteeRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleGuaranteeRoleDto)12 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)6 Test (org.junit.Test)6 IdmRoleGuaranteeRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeRoleFilter)4 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)3 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)2 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)2 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)2 AbstractRestTest (eu.bcvsolutions.idm.test.api.AbstractRestTest)2 UUID (java.util.UUID)2 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)1 IdmExportImportDto (eu.bcvsolutions.idm.core.api.dto.IdmExportImportDto)1 IdmRoleFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter)1 IdmRoleGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleGuaranteeFilter)1 IdmRoleGuaranteeRoleService (eu.bcvsolutions.idm.core.api.service.IdmRoleGuaranteeRoleService)1 IdmRoleService (eu.bcvsolutions.idm.core.api.service.IdmRoleService)1 CoreGroupPermission (eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission)1 IdmRoleGuaranteeRole (eu.bcvsolutions.idm.core.model.entity.IdmRoleGuaranteeRole)1 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)1 AbstractEvaluatorIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractEvaluatorIntegrationTest)1