Search in sources :

Example 1 with IdmTreeNodeFilter

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

the class TreeSynchronizationExecutor method findByAttribute.

@Override
protected IdmTreeNodeDto findByAttribute(String idmAttributeName, String value) {
    CorrelationFilter filter = getEntityFilter();
    filter.setProperty(idmAttributeName);
    filter.setValue(value);
    List<IdmTreeNodeDto> entities = treeNodeService.find((IdmTreeNodeFilter) filter, null).getContent();
    if (CollectionUtils.isEmpty(entities)) {
        return null;
    }
    if (entities.size() > 1) {
        throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_CORRELATION_TO_MANY_RESULTS, ImmutableMap.of("correlationAttribute", idmAttributeName, "value", value));
    }
    if (entities.size() == 1) {
        return entities.get(0);
    }
    return null;
}
Also used : CorrelationFilter(eu.bcvsolutions.idm.core.api.dto.filter.CorrelationFilter) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)

Example 2 with IdmTreeNodeFilter

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

the class IdmTreeNodeServiceIntegrationTest method testForestIndexAfterBulkMove.

@Test
public void testForestIndexAfterBulkMove() {
    int rootCount = 5;
    // prepare new tree type
    IdmTreeTypeDto treeType = helper.createTreeType();
    // create root nodes
    for (int i = 0; i < rootCount; i++) {
        helper.createTreeNode(treeType, null);
    }
    // move nodes to the first node
    IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
    filter.setTreeTypeId(treeType.getId());
    List<IdmTreeNodeDto> nodes = treeNodeService.find(filter, null).getContent();
    IdmTreeNodeDto root = nodes.get(0);
    for (int i = 0; i < nodes.size(); i++) {
        IdmTreeNodeDto node = nodes.get(i);
        if (node.equals(root)) {
            continue;
        }
        node.setParent(root.getId());
        node = treeNodeService.save(node);
    }
    // check
    Assert.assertEquals(1L, treeNodeService.findRoots(treeType.getId(), null).getTotalElements());
    Assert.assertEquals(rootCount - 1, treeNodeService.findChildrenByParent(root.getId(), null).getTotalElements());
    Assert.assertEquals(rootCount - 1, treeNodeForestContentService.findDirectChildren(root.getId(), null).getTotalElements());
    Assert.assertEquals(rootCount - 1, treeNodeForestContentService.findAllChildren(root.getId(), null).getTotalElements());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 3 with IdmTreeNodeFilter

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

the class ComplexHrProcessIntegrationTest method organizationStructureCleanup.

private void organizationStructureCleanup() {
    IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
    filter.setCode(dep1NodeName);
    treeNodeService.find(filter, null).getContent().forEach(node -> treeNodeService.delete(node));
    filter.setCode(dep2NodeName);
    treeNodeService.find(filter, null).getContent().forEach(node -> treeNodeService.delete(node));
}
Also used : IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)

Example 4 with IdmTreeNodeFilter

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

the class ComplexHrProcessIntegrationTest method matchContractWithPattern.

// ******* Contract checks ********
private void matchContractWithPattern(String username, Map<String, String> pattern) {
    IdmIdentityDto identity = identityService.getByUsername(username);
    Assert.assertNotNull(identity);
    IdmIdentityContractFilter filt = new IdmIdentityContractFilter();
    filt.setIdentity(identity.getId());
    if (pattern.containsKey("extId")) {
        String id = pattern.get("extId");
        // attribute position is used as field with contract unique identifier
        filt.setPosition(id);
    }
    if (pattern.containsKey("validFrom")) {
        String dateStr = pattern.get("validFrom");
        LocalDate date = dateStr == null ? null : LocalDate.parse(dateStr);
        filt.setValidFrom(date);
    }
    if (pattern.containsKey("validTill")) {
        String dateStr = pattern.get("validTill");
        LocalDate date = dateStr == null ? null : LocalDate.parse(dateStr);
        filt.setValidTill(date);
    }
    if (pattern.containsKey("workPosition")) {
        IdmTreeNodeFilter nodeFilt = new IdmTreeNodeFilter();
        nodeFilt.setCode(pattern.get("workPosition"));
        List<IdmTreeNodeDto> nodes = treeNodeService.find(nodeFilt, null).getContent();
        Assert.assertEquals(1, nodes.size());
        filt.setWorkPosition(nodes.get(0).getId());
    }
    List<IdmIdentityContractDto> contracts = identityContractService.find(filt, null).getContent();
    Assert.assertEquals(1, contracts.size());
    if (pattern.containsKey("contractType")) {
        IdmIdentityContractDto contract = contracts.get(0);
        IdmFormAttributeDto attr = formService.getAttribute(contract.getClass(), eavAutoRoleAttrName);
        List<IdmFormValueDto> values = formService.getValues(contract, attr);
        Assert.assertEquals(1, values.size());
        Assert.assertEquals(pattern.get("contractType"), values.get(0).getShortTextValue());
    }
}
Also used : IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) LocalDate(java.time.LocalDate) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)

Example 5 with IdmTreeNodeFilter

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

the class ComplexHrProcessIntegrationTest method createAutoRoleByStructure.

/**
 * Defines automatic roles assigned based on organization structure
 */
private void createAutoRoleByStructure() {
    IdmTreeNodeFilter treeNodeFilt = new IdmTreeNodeFilter();
    IdmRoleFilter roleFilt = new IdmRoleFilter();
    IdmRoleTreeNodeDto roleTreeNode = null;
    IdmRoleDto role = null;
    // root
    treeNodeFilt.setCode(rootNodeName);
    IdmTreeNodeDto node = treeNodeService.find(treeNodeFilt, null).getContent().get(0);
    // node root, role AD-users
    roleFilt.setText(adUsersRole);
    role = roleService.find(roleFilt, null).getContent().get(0);
    roleTreeNode = new IdmRoleTreeNodeDto();
    roleTreeNode.setName(adUsersRole);
    roleTreeNode.setTreeNode(node.getId());
    roleTreeNode.setRole(role.getId());
    roleTreeNode.setRecursionType(RecursionType.DOWN);
    roleTreeNodeService.save(roleTreeNode);
    // node root, role All
    roleFilt.setText(allBusinessRole);
    role = roleService.find(roleFilt, null).getContent().get(0);
    roleTreeNode = new IdmRoleTreeNodeDto();
    roleTreeNode.setName(allBusinessRole);
    roleTreeNode.setTreeNode(node.getId());
    roleTreeNode.setRole(role.getId());
    roleTreeNode.setRecursionType(RecursionType.DOWN);
    roleTreeNodeService.save(roleTreeNode);
    // Department 1 AD-group-department1
    treeNodeFilt.setCode(dep1NodeName);
    node = treeNodeService.find(treeNodeFilt, null).getContent().get(0);
    roleFilt.setText(adGroupDep1Role);
    role = roleService.find(roleFilt, null).getContent().get(0);
    roleTreeNode = new IdmRoleTreeNodeDto();
    roleTreeNode.setName(adGroupDep1Role);
    roleTreeNode.setTreeNode(node.getId());
    roleTreeNode.setRole(role.getId());
    roleTreeNode.setRecursionType(RecursionType.DOWN);
    roleTreeNodeService.save(roleTreeNode);
    // Department 2 AD-group-department2
    treeNodeFilt.setCode(dep2NodeName);
    node = treeNodeService.find(treeNodeFilt, null).getContent().get(0);
    roleFilt.setText(adGroupDep2Role);
    role = roleService.find(roleFilt, null).getContent().get(0);
    roleTreeNode = new IdmRoleTreeNodeDto();
    roleTreeNode.setName(adGroupDep2Role);
    roleTreeNode.setTreeNode(node.getId());
    roleTreeNode.setRole(role.getId());
    roleTreeNode.setRecursionType(RecursionType.DOWN);
    roleTreeNodeService.save(roleTreeNode);
}
Also used : IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) IdmRoleTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto) IdmRoleFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmRoleFilter) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)

Aggregations

IdmTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)35 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)30 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)20 Test (org.junit.Test)20 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)15 UUID (java.util.UUID)11 Transactional (org.springframework.transaction.annotation.Transactional)7 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)5 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)5 AbstractReadWriteDtoControllerRestTest (eu.bcvsolutions.idm.core.api.rest.AbstractReadWriteDtoControllerRestTest)5 SysSyncLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter)4 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)3 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)3 TestTreeResource (eu.bcvsolutions.idm.acc.entity.TestTreeResource)3 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)3 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)3 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)3 IdmRoleTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)3 List (java.util.List)3 Assert (org.junit.Assert)3