Search in sources :

Example 16 with IdmContractGuaranteeFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter in project CzechIdMng by bcvsolutions.

the class IdentityAddContractGuaranteeBulkActionTest method isContractGuarantee.

/**
 * Tests if there are all identities contract guarantees
 * If some of them are not contract guarantees, they are returned
 * Empty returned List means that there are all identities contract guarantees
 *
 * @param contract
 * @param guarantees
 * @return
 */
private List<IdmIdentityDto> isContractGuarantee(IdmIdentityContractDto contract, List<IdmIdentityDto> guarantees) {
    IdmContractGuaranteeFilter filt = new IdmContractGuaranteeFilter();
    filt.setIdentityContractId(contract.getId());
    Set<UUID> cgUUIDs = contractGuaranteeService.find(filt, null).getContent().stream().map(IdmContractGuaranteeDto::getGuarantee).collect(Collectors.toSet());
    return guarantees.stream().filter(ident -> !cgUUIDs.contains(ident.getId())).collect(Collectors.toList());
}
Also used : Arrays(java.util.Arrays) Autowired(org.springframework.beans.factory.annotation.Autowired) AbstractBulkActionTest(eu.bcvsolutions.idm.test.api.AbstractBulkActionTest) HashMap(java.util.HashMap) IdmContractGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter) IdmContractGuarantee(eu.bcvsolutions.idm.core.model.entity.IdmContractGuarantee) CoreGroupPermission(eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) IdmBasePermission(eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission) Map(java.util.Map) After(org.junit.After) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Before(org.junit.Before) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) Set(java.util.Set) Test(org.junit.Test) UUID(java.util.UUID) IdmContractGuaranteeService(eu.bcvsolutions.idm.core.api.service.IdmContractGuaranteeService) Collectors(java.util.stream.Collectors) IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) List(java.util.List) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) Assert(org.junit.Assert) Transactional(org.springframework.transaction.annotation.Transactional) UUID(java.util.UUID) IdmContractGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter)

Example 17 with IdmContractGuaranteeFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter in project CzechIdMng by bcvsolutions.

the class IdentityRemoveContractGuaranteeBulkActionTest method getGuaranteesForContract.

/**
 * Gets all contractGuarantees for contract
 * @param contract
 * @return
 */
private List<IdmContractGuaranteeDto> getGuaranteesForContract(UUID contract) {
    IdmContractGuaranteeFilter filt = new IdmContractGuaranteeFilter();
    filt.setIdentityContractId(contract);
    return contractGuaranteeService.find(filt, null).getContent();
}
Also used : IdmContractGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter)

Example 18 with IdmContractGuaranteeFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter in project CzechIdMng by bcvsolutions.

the class ContractGuaranteeSaveAndDeleteProcessorTest method testCreateGuaranteeOfContractWithSlice.

@Test
public void testCreateGuaranteeOfContractWithSlice() {
    IdmIdentityDto sliceGuarantee = getHelper().createIdentity();
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmContractSliceDto slice = getHelper().createContractSlice(identity, null, LocalDate.now().minusDays(1), null, null);
    UUID contractId = slice.getParentContract();
    // guarantee can't be created directly
    try {
        getHelper().createContractGuarantee(contractId, sliceGuarantee.getId());
        fail("Contract guarantee can't be created directly when slice is applied");
    } catch (ResultCodeException ex) {
        Assert.assertTrue(CoreResultCode.CONTRACT_IS_CONTROLLED_GUARANTEE_CANNOT_BE_MODIFIED.toString().equals(ex.getError().getErrors().get(0).getStatusEnum()));
    }
    IdmContractGuaranteeFilter guaranteeFilter = new IdmContractGuaranteeFilter();
    guaranteeFilter.setIdentityContractId(contractId);
    List<IdmContractGuaranteeDto> contractGuarantees = contractGuaranteeService.find(guaranteeFilter, null).getContent();
    Assert.assertEquals(0, contractGuarantees.size());
    // contract slice guarantee can be created
    getHelper().createContractSliceGuarantee(slice.getId(), sliceGuarantee.getId());
    IdmContractSliceGuaranteeFilter sliceGuaranteefilter = new IdmContractSliceGuaranteeFilter();
    sliceGuaranteefilter.setGuaranteeId(sliceGuarantee.getId());
    List<IdmContractSliceGuaranteeDto> sliceGuarantees = contractSliceGuaranteeService.find(sliceGuaranteefilter, null).getContent();
    Assert.assertEquals(1, sliceGuarantees.size());
    // applying slice with guarantee causes creating of contract guarantee which is correct
    contractGuarantees = contractGuaranteeService.find(guaranteeFilter, null).getContent();
    Assert.assertEquals(1, contractGuarantees.size());
    IdmIdentityDto sliceGuaranteeIdent = DtoUtils.getEmbedded(sliceGuarantees.get(0), IdmContractSliceGuarantee_.guarantee);
    IdmIdentityDto contractGuaranteeIdent = DtoUtils.getEmbedded(contractGuarantees.get(0), IdmContractSliceGuarantee_.guarantee);
    Assert.assertEquals(sliceGuaranteeIdent.getId(), contractGuaranteeIdent.getId());
}
Also used : IdmContractSliceGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceGuaranteeFilter) IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmContractSliceGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceGuaranteeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) UUID(java.util.UUID) IdmContractGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 19 with IdmContractGuaranteeFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter in project CzechIdMng by bcvsolutions.

the class AbstractContractGuaranteeBulkAction method findGuarantees.

/**
 * Get all guarantees for identity
 *
 * @param identity
 * @param permissions
 * @return
 */
protected List<IdmContractGuaranteeDto> findGuarantees(UUID identity, BasePermission... permissions) {
    IdmContractGuaranteeFilter filter = new IdmContractGuaranteeFilter();
    filter.setIdentity(identity);
    return contractGuaranteeService.find(filter, null, permissions).getContent();
}
Also used : IdmContractGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter)

Example 20 with IdmContractGuaranteeFilter

use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter in project CzechIdMng by bcvsolutions.

the class IdmContractGuaranteeController method toFilter.

@Override
protected IdmContractGuaranteeFilter toFilter(MultiValueMap<String, Object> parameters) {
    IdmContractGuaranteeFilter filter = super.toFilter(parameters);
    // codeable decorator
    filter.setIdentity(getParameterConverter().toEntityUuid(parameters, IdmContractGuaranteeFilter.PARAMETER_IDENTITY, IdmIdentityDto.class));
    // 
    return filter;
}
Also used : IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmContractGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter)

Aggregations

IdmContractGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter)27 IdmContractGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto)20 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)20 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)18 Test (org.junit.Test)15 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)12 UUID (java.util.UUID)12 IdmContractGuaranteeService (eu.bcvsolutions.idm.core.api.service.IdmContractGuaranteeService)8 List (java.util.List)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 HashMap (java.util.HashMap)7 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)6 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)6 Map (java.util.Map)6 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)5 Collectors (java.util.stream.Collectors)5 ImmutableMap (com.google.common.collect.ImmutableMap)4 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)4 IdmContractPositionFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter)4 IdmIdentityContractFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)4