Search in sources :

Example 6 with IdmContractPositionFilter

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

the class IdmContractPositionControllerRestTest method testFilterByContract.

@Test
public void testFilterByContract() {
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmIdentityContractDto primeContract = getHelper().getPrimeContract(identity);
    IdmIdentityContractDto otherContract = getHelper().createContract(identity);
    // 
    IdmContractPositionDto dtoOne = createDto(new IdmContractPositionDto(primeContract.getId(), null));
    // other
    createDto(new IdmContractPositionDto(otherContract.getId(), null));
    // 
    IdmContractPositionFilter filter = new IdmContractPositionFilter();
    filter.setIdentityContractId(primeContract.getId());
    // 
    List<IdmContractPositionDto> results = find(filter);
    // 
    Assert.assertEquals(1, results.size());
    Assert.assertEquals(dtoOne.getId(), results.get(0).getId());
}
Also used : IdmContractPositionDto(eu.bcvsolutions.idm.core.api.dto.IdmContractPositionDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmContractPositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 7 with IdmContractPositionFilter

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

the class IdmContractPositionControllerRestTest method testFilterByWorkPosition.

@Test
public void testFilterByWorkPosition() {
    IdmIdentityDto identity = getHelper().createIdentity();
    IdmIdentityContractDto primeContract = getHelper().getPrimeContract(identity);
    // 
    IdmTreeNodeDto treeNodeOne = getHelper().createTreeNode();
    IdmContractPositionDto dtoOne = createDto(new IdmContractPositionDto(primeContract.getId(), treeNodeOne.getId()));
    // other
    createDto(new IdmContractPositionDto(primeContract.getId(), getHelper().createTreeNode().getId()));
    // 
    IdmContractPositionFilter filter = new IdmContractPositionFilter();
    filter.setWorkPosition(treeNodeOne.getId());
    // 
    List<IdmContractPositionDto> results = find(filter);
    // 
    Assert.assertEquals(1, results.size());
    Assert.assertEquals(dtoOne.getId(), results.get(0).getId());
}
Also used : IdmContractPositionDto(eu.bcvsolutions.idm.core.api.dto.IdmContractPositionDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmContractPositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) Test(org.junit.Test) AbstractReadWriteDtoControllerRestTest(eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)

Example 8 with IdmContractPositionFilter

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

the class DefaultIdmContractPositionService method findAllByWorkPosition.

@Override
@Transactional(readOnly = true)
public List<IdmContractPositionDto> findAllByWorkPosition(UUID workPositionId, RecursionType recursionType) {
    Assert.notNull(workPositionId, "Work position is required to get related contracts.");
    // 
    IdmContractPositionFilter filter = new IdmContractPositionFilter();
    filter.setWorkPosition(workPositionId);
    filter.setRecursionType(recursionType);
    // 
    return find(filter, null).getContent();
}
Also used : IdmContractPositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with IdmContractPositionFilter

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

the class IdentityContractSyncTest method testContractPositions.

@Test
public void testContractPositions() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
    Assert.assertTrue(config instanceof SysSyncContractConfigDto);
    helper.createIdentity(CONTRACT_OWNER_THREE);
    // Set default tree type to sync configuration
    IdmTreeTypeDto treeType = treeTypeService.getByCode(InitApplicationData.DEFAULT_TREE_TYPE);
    Assert.assertNotNull(treeType);
    SysSyncContractConfigDto configContract = (SysSyncContractConfigDto) config;
    configContract.setDefaultTreeType(treeType.getId());
    config = syncConfigService.save(configContract);
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setProperty(IdmIdentityContract_.position.getName());
    // Set work positions to resources
    this.getBean().initContractPositionTest();
    // Start sync again (we want to see some work positions)
    helper.startSynchronization(config);
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 1);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    // For contract One must be found workposition (one)
    contractFilter.setValue("1");
    IdmIdentityContractDto contractOne = contractService.find(contractFilter, null).getContent().get(0);
    Assert.assertNotNull(contractOne);
    // 
    IdmContractPositionFilter positionFitler = new IdmContractPositionFilter();
    positionFitler.setIdentityContractId(contractOne.getId());
    List<IdmContractPositionDto> positions = contractPositionService.find(positionFitler, null).getContent();
    Assert.assertEquals(1, positions.size());
    Assert.assertEquals("one", DtoUtils.getEmbedded(positions.get(0), IdmContractPosition_.workPosition, IdmTreeNodeDto.class).getCode());
    // Delete log
    syncLogService.delete(log);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmContractPositionDto(eu.bcvsolutions.idm.core.api.dto.IdmContractPositionDto) IdmContractPositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter) 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 10 with IdmContractPositionFilter

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

the class IdentityContractSyncTest method testDifferentSyncChangePositions.

@Test
public void testDifferentSyncChangePositions() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
    Assert.assertTrue(config instanceof SysSyncContractConfigDto);
    helper.createIdentity(CONTRACT_OWNER_THREE);
    // Set default tree type to sync configuration
    IdmTreeTypeDto treeType = treeTypeService.getByCode(InitApplicationData.DEFAULT_TREE_TYPE);
    Assert.assertNotNull(treeType);
    SysSyncContractConfigDto configContract = (SysSyncContractConfigDto) config;
    configContract.setDefaultTreeType(treeType.getId());
    config = syncConfigService.save(configContract);
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setProperty(IdmIdentityContract_.position.getName());
    // Set work positions to resources
    this.getBean().initContractPositionTest();
    helper.startSynchronization(config);
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 1);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    // For contract One must be found workposition (one)
    contractFilter.setValue("1");
    IdmIdentityContractDto contractOne = contractService.find(contractFilter, null).getContent().get(0);
    Assert.assertNotNull(contractOne);
    IdmContractPositionFilter positionFitler = new IdmContractPositionFilter();
    positionFitler.setIdentityContractId(contractOne.getId());
    List<IdmContractPositionDto> positions = contractPositionService.find(positionFitler, null).getContent();
    Assert.assertEquals(1, positions.size());
    Assert.assertEquals("one", DtoUtils.getEmbedded(positions.get(0), IdmContractPosition_.workPosition, IdmTreeNodeDto.class).getCode());
    // Enable different sync.
    config.setDifferentialSync(true);
    config = syncConfigService.save(config);
    Assert.assertTrue(config.isDifferentialSync());
    // Start sync with enable different sync - no change was made on so only ignore update should be made.
    helper.startSynchronization(config);
    log = helper.checkSyncLog(config, SynchronizationActionType.UPDATE_ENTITY, 1, OperationResultType.IGNORE);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    // Delete position name
    contractPositionService.delete(positions.get(0));
    // Start sync with enable different sync - position name was changed, standard update should be made.
    helper.startSynchronization(config);
    log = helper.checkSyncLog(config, SynchronizationActionType.UPDATE_ENTITY, 1, OperationResultType.SUCCESS);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    // For contract One must be found workposition (one)
    contractFilter.setValue("1");
    contractOne = contractService.find(contractFilter, null).getContent().get(0);
    Assert.assertNotNull(contractOne);
    positionFitler = new IdmContractPositionFilter();
    positionFitler.setIdentityContractId(contractOne.getId());
    positions = contractPositionService.find(positionFitler, null).getContent();
    Assert.assertEquals(1, positions.size());
    Assert.assertEquals("one", DtoUtils.getEmbedded(positions.get(0), IdmContractPosition_.workPosition, IdmTreeNodeDto.class).getCode());
    // Delete log
    syncLogService.delete(log);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmContractPositionDto(eu.bcvsolutions.idm.core.api.dto.IdmContractPositionDto) IdmContractPositionFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter) 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

IdmContractPositionFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter)16 IdmContractPositionDto (eu.bcvsolutions.idm.core.api.dto.IdmContractPositionDto)10 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)10 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)7 UUID (java.util.UUID)7 IdmIdentityContractFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)6 Test (org.junit.Test)6 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)4 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)4 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)4 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)4 IdmContractGuaranteeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmContractGuaranteeFilter)4 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)4 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)3 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)3 IdmContractGuaranteeDto (eu.bcvsolutions.idm.core.api.dto.IdmContractGuaranteeDto)3 EntityEvent (eu.bcvsolutions.idm.core.api.event.EntityEvent)3 EventContext (eu.bcvsolutions.idm.core.api.event.EventContext)3 EventResult (eu.bcvsolutions.idm.core.api.event.EventResult)3 AutomaticRoleManager (eu.bcvsolutions.idm.core.api.service.AutomaticRoleManager)3