Search in sources :

Example 1 with IdmIdentityContractFilter

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

the class HrEndContractProcess method getItemsToProcess.

/**
 * {@inheritDoc}
 *
 * Find all identity contracts, that are both valid and enabled.
 */
@Override
public Page<IdmIdentityContractDto> getItemsToProcess(Pageable pageable) {
    IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
    filter.setValid(Boolean.FALSE);
    return identityContractService.find(filter, pageable);
}
Also used : IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)

Example 2 with IdmIdentityContractFilter

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

the class IdmIdentityContractController method toFilter.

@Override
protected IdmIdentityContractFilter toFilter(MultiValueMap<String, Object> parameters) {
    IdmIdentityContractFilter filter = new IdmIdentityContractFilter(parameters);
    filter.setText(getParameterConverter().toString(parameters, "text"));
    filter.setIdentity(getParameterConverter().toEntityUuid(parameters, "identity", IdmIdentity.class));
    filter.setValid(getParameterConverter().toBoolean(parameters, "valid"));
    filter.setExterne(getParameterConverter().toBoolean(parameters, "externe"));
    filter.setDisabled(getParameterConverter().toBoolean(parameters, "disabled"));
    filter.setMain(getParameterConverter().toBoolean(parameters, "main"));
    filter.setValidNowOrInFuture(getParameterConverter().toBoolean(parameters, "validNowOrInFuture"));
    // TODO: localdate converters
    return filter;
}
Also used : IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity)

Example 3 with IdmIdentityContractFilter

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

the class IdentityContractSyncTest method defaultLeaderTest.

@Test
public void defaultLeaderTest() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
    Assert.assertTrue(config instanceof SysSyncContractConfigDto);
    helper.createIdentity(CONTRACT_OWNER_ONE);
    helper.createIdentity(CONTRACT_OWNER_TWO);
    helper.createIdentity(CONTRACT_LEADER_ONE);
    IdmIdentityDto defaultLeader = helper.createIdentity(CONTRACT_LEADER_TWO);
    // Set default leader to sync configuration
    SysSyncContractConfigDto configContract = (SysSyncContractConfigDto) config;
    configContract.setDefaultLeader(defaultLeader.getId());
    config = syncConfigService.save(configContract);
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setProperty(IdmIdentityContract_.position.getName());
    contractFilter.setValue("1");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    contractFilter.setValue("2");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    synchornizationService.setSynchronizationConfigId(config.getId());
    synchornizationService.process();
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    contractFilter.setValue("1");
    List<IdmIdentityContractDto> contractsOne = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsOne.size());
    IdmContractGuaranteeFilter guaranteeFilter = new IdmContractGuaranteeFilter();
    guaranteeFilter.setIdentityContractId(contractsOne.get(0).getId());
    List<IdmContractGuaranteeDto> gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
    Assert.assertEquals(1, gurantees.size());
    IdmIdentityDto guarantee = DtoUtils.getEmbedded(gurantees.get(0), IdmContractGuarantee_.guarantee, IdmIdentityDto.class);
    // Direct leader from resource
    Assert.assertEquals(CONTRACT_LEADER_ONE, guarantee.getUsername());
    contractFilter.setValue("2");
    List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsTwo.size());
    guaranteeFilter.setIdentityContractId(contractsTwo.get(0).getId());
    gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
    Assert.assertEquals(1, gurantees.size());
    guarantee = DtoUtils.getEmbedded(gurantees.get(0), IdmContractGuarantee_.guarantee, IdmIdentityDto.class);
    // Default leader
    Assert.assertEquals(CONTRACT_LEADER_TWO, guarantee.getUsername());
    contractFilter.setValue("3");
    List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsThree.size());
    guaranteeFilter.setIdentityContractId(contractsThree.get(0).getId());
    gurantees = guaranteeService.find(guaranteeFilter, null).getContent();
    Assert.assertEquals(1, gurantees.size());
    guarantee = DtoUtils.getEmbedded(gurantees.get(0), IdmContractGuarantee_.guarantee, IdmIdentityDto.class);
    // Default leader
    Assert.assertEquals(CONTRACT_LEADER_TWO, guarantee.getUsername());
    // Delete log
    syncLogService.delete(log);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) IdmContractGuaranteeDto(eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) IdmContractGuaranteeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 4 with IdmIdentityContractFilter

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

the class IdentityContractSyncTest method checkContractDisableTest.

@Test
public void checkContractDisableTest() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
    Assert.assertTrue(config instanceof SysSyncContractConfigDto);
    helper.createIdentity(CONTRACT_OWNER_ONE);
    helper.createIdentity(CONTRACT_OWNER_TWO);
    helper.createIdentity(CONTRACT_LEADER_ONE);
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setProperty(IdmIdentityContract_.position.getName());
    contractFilter.setValue("1");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    contractFilter.setValue("2");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    // Change resources (set state on disable) .. must be call in
    // transaction
    this.getBean().initContractCheckDisableTest();
    synchornizationService.setSynchronizationConfigId(config.getId());
    synchornizationService.process();
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    contractFilter.setValue("1");
    List<IdmIdentityContractDto> contractsOne = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsOne.size());
    Assert.assertEquals(ContractState.DISABLED, contractsOne.get(0).getState());
    contractFilter.setValue("2");
    List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsTwo.size());
    Assert.assertEquals(null, contractsTwo.get(0).getState());
    contractFilter.setValue("3");
    List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsThree.size());
    Assert.assertEquals(ContractState.DISABLED, contractsThree.get(0).getState());
    // Delete log
    syncLogService.delete(log);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 5 with IdmIdentityContractFilter

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

the class IdentityContractSyncTest method checkContractExcludeTest.

@Test
public void checkContractExcludeTest() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
    Assert.assertTrue(config instanceof SysSyncContractConfigDto);
    helper.createIdentity(CONTRACT_OWNER_ONE);
    helper.createIdentity(CONTRACT_OWNER_TWO);
    helper.createIdentity(CONTRACT_LEADER_ONE);
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setProperty(IdmIdentityContract_.position.getName());
    contractFilter.setValue("1");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    contractFilter.setValue("2");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    // Change resources (set state on exclude) .. must be call in
    // transaction
    this.getBean().initContractCheckExcludeTest();
    synchornizationService.setSynchronizationConfigId(config.getId());
    synchornizationService.process();
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    contractFilter.setValue("1");
    Assert.assertEquals(1, contractService.find(contractFilter, null).getTotalElements());
    contractFilter.setValue("2");
    List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsTwo.size());
    Assert.assertEquals(null, contractsTwo.get(0).getState());
    contractFilter.setValue("3");
    List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsThree.size());
    Assert.assertEquals(ContractState.EXCLUDED, contractsThree.get(0).getState());
    // Delete log
    syncLogService.delete(log);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmIdentityContractFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)19 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)15 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)14 Test (org.junit.Test)14 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)9 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)9 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)9 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)9 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)8 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)7 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)2 IdentityContractEvent (eu.bcvsolutions.idm.core.model.event.IdentityContractEvent)2 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)1 AccContractAccountDto (eu.bcvsolutions.idm.acc.dto.AccContractAccountDto)1 AccContractAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccContractAccountFilter)1 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)1 IdmContractGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto)1 CorrelationFilter (eu.bcvsolutions.idm.core.api.dto.filter.CorrelationFilter)1 IdmContractGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter)1 IdmTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)1