Search in sources :

Example 26 with IdmTreeNodeFilter

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

the class DefaultTreeSynchronizationServiceTest method doStartSyncB_Linked_doEntityUpdate.

@Test
public void doStartSyncB_Linked_doEntityUpdate() {
    SysSyncConfigFilter configFilter = new SysSyncConfigFilter();
    configFilter.setName(SYNC_CONFIG_NAME);
    List<AbstractSysSyncConfigDto> syncConfigs = syncConfigService.find(configFilter, null).getContent();
    // Change node code to changed
    this.getBean().changeOne();
    Assert.assertEquals(1, syncConfigs.size());
    AbstractSysSyncConfigDto syncConfigCustom = syncConfigs.get(0);
    Assert.assertFalse(syncConfigService.isRunning(syncConfigCustom));
    // Set sync config
    syncConfigCustom.setLinkedAction(SynchronizationLinkedActionType.UPDATE_ENTITY);
    syncConfigCustom.setUnlinkedAction(SynchronizationUnlinkedActionType.IGNORE);
    syncConfigCustom.setMissingEntityAction(SynchronizationMissingEntityActionType.IGNORE);
    syncConfigCustom.setMissingAccountAction(ReconciliationMissingAccountActionType.IGNORE);
    syncConfigService.save(syncConfigCustom);
    // Check state before sync
    IdmTreeNodeFilter nodeFilter = new IdmTreeNodeFilter();
    nodeFilter.setProperty(NODE_NAME);
    nodeFilter.setValue("111");
    nodeFilter.setTreeTypeId(DtoUtils.getEmbedded(syncConfigCustom, SysSyncConfig_.systemMapping, SysSystemMappingDto.class).getTreeType());
    IdmTreeNodeDto treeNode = treeNodeService.find(nodeFilter, null).getContent().get(0);
    Assert.assertEquals("111", treeNode.getCode());
    helper.startSynchronization(syncConfigCustom);
    // 
    SysSyncLogFilter logFilter = new SysSyncLogFilter();
    logFilter.setSynchronizationConfigId(syncConfigCustom.getId());
    List<SysSyncLogDto> logs = syncLogService.find(logFilter, null).getContent();
    Assert.assertEquals(1, logs.size());
    SysSyncLogDto log = logs.get(0);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    SysSyncActionLogFilter actionLogFilter = new SysSyncActionLogFilter();
    actionLogFilter.setSynchronizationLogId(log.getId());
    List<SysSyncActionLogDto> actions = syncActionLogService.find(actionLogFilter, null).getContent();
    Assert.assertEquals(1, actions.size());
    SysSyncActionLogDto actionLog = actions.stream().filter(action -> {
        return SynchronizationActionType.UPDATE_ENTITY == action.getSyncAction();
    }).findFirst().get();
    SysSyncItemLogFilter itemLogFilter = new SysSyncItemLogFilter();
    itemLogFilter.setSyncActionLogId(actionLog.getId());
    List<SysSyncItemLogDto> items = syncItemLogService.find(itemLogFilter, null).getContent();
    Assert.assertEquals(6, items.size());
    // Check state after sync
    treeNode = treeNodeService.get(treeNode.getId());
    Assert.assertEquals(CHANGED, treeNode.getCode());
    // Delete log
    syncLogService.delete(log);
}
Also used : IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) SysSyncActionLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter) SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) SysSyncItemLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncItemLogFilter) SysSyncActionLogFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncActionLogFilter) SysSyncConfigFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 27 with IdmTreeNodeFilter

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

the class DefaultTreeSynchronizationServiceTest method provisioningB_CreateAccounts_withException.

// Provisioning tree in incorrect order
@Test(expected = ProvisioningException.class)
public void provisioningB_CreateAccounts_withException() {
    IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
    filter.setProperty(NODE_NAME);
    filter.setValue("P1");
    IdmTreeNodeDto nodeRoot = treeNodeService.find(filter, null).getContent().get(0);
    Assert.assertNotNull(nodeRoot);
    filter.setValue("P12");
    IdmTreeNodeDto nodeOne = treeNodeService.find(filter, null).getContent().get(0);
    Assert.assertNotNull(nodeOne);
    // Check state before provisioning
    TestTreeResource one = entityManager.find(TestTreeResource.class, "P12");
    Assert.assertNull(one);
    // Create mapping for provisioning
    this.createProvisionigMapping();
    // Save IDM node (must invoke provisioning)
    // We didn't provisioning for root first ... expect throw exception
    treeNodeService.save(nodeOne);
}
Also used : TestTreeResource(eu.bcvsolutions.idm.acc.entity.TestTreeResource) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 28 with IdmTreeNodeFilter

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

the class DefaultIdmTreeNodeServiceIntegrationTest method testForestIndexAfterBulkMoveWithoutTransaction.

@Test
public // @Transactional - TODO: fix recount index in transaction
void testForestIndexAfterBulkMoveWithoutTransaction() {
    int rootCount = 5;
    // prepare new tree type
    IdmTreeTypeDto treeType = getHelper().createTreeType();
    // create root nodes
    for (int i = 0; i < rootCount; i++) {
        getHelper().createTreeNode(treeType, null);
    }
    // move nodes to the first node
    IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
    filter.setTreeTypeId(treeType.getId());
    List<IdmTreeNodeDto> nodes = service.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 = service.save(node);
    }
    // check
    Assert.assertEquals(1L, service.findRoots(treeType.getId(), null).getTotalElements());
    Assert.assertEquals(rootCount - 1, service.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) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 29 with IdmTreeNodeFilter

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

the class TreeTypeDeleteBulkAction method end.

@Override
protected OperationResult end(OperationResult result, Exception exception) {
    if (exception != null || (result != null && OperationState.EXECUTED != result.getState())) {
        return super.end(result, exception);
    }
    // success
    boolean forceDelete = isForceDelete();
    if (!forceDelete) {
        return super.end(result, exception);
    }
    // 
    for (UUID treeTypeId : processedIds) {
        IdmTreeTypeDto treeType = getService().get(treeTypeId);
        if (treeType != null) {
            // delete tree nodes => tree node related records are removed asynchronously, but tree node itself will be removed here
            IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
            filter.setTreeTypeId(treeTypeId);
            filter.setRoots(Boolean.TRUE);
            for (IdmTreeNodeDto treeNode : treeNodeService.find(filter, null).getContent()) {
                OperationResult errorResult = treeNodeDeleteBulkAction.deleteTreeNode(treeNode, result);
                if (errorResult != null) {
                    return errorResult;
                }
            }
            // 
            treeTypeService.delete(treeType);
            // 
            LOG.debug("Tree type [{}] deleted.", treeType.getCode());
        } else {
            LOG.debug("Tree type [{}] already deleted.", treeTypeId);
        }
        // clean up all states
        entityStateManager.deleteStates(new IdmTreeTypeDto(treeTypeId), null, null);
    }
    return super.end(result, exception);
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmTreeNodeFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) UUID(java.util.UUID)

Example 30 with IdmTreeNodeFilter

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

the class IdmTreeNodeController method findRoots.

@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.TREENODE_AUTOCOMPLETE + "')")
@RequestMapping(value = "/search/roots", method = RequestMethod.GET)
@ApiOperation(value = "Search root tree nodes", nickname = "searchRootTreeNodes", tags = { IdmTreeNodeController.TAG }, notes = "Tree type parameter can be used. If no tree type ios given, then configured default tree type is used." + " If no default tree type is configured, then all roots are returnde")
@ApiImplicitParams({ @ApiImplicitParam(name = "page", dataType = "string", paramType = "query", value = "Results page you want to retrieve (0..N)"), @ApiImplicitParam(name = "size", dataType = "string", paramType = "query", value = "Number of records per page."), @ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query", value = "Sorting criteria in the format: property(,asc|desc). " + "Default sort order is ascending. " + "Multiple sort criteria are supported.") })
public Resources<?> findRoots(@ApiParam(value = "Tree type uuid identifier.", required = false) @RequestParam(value = "treeTypeId", required = false) String treeTypeId, @RequestParam(required = false) MultiValueMap<String, Object> parameters, @PageableDefault Pageable pageable) {
    UUID treeTypeIdentifier = null;
    if (StringUtils.isNotEmpty(treeTypeId)) {
        treeTypeIdentifier = DtoUtils.toUuid(treeTypeId);
    } else {
        IdmTreeTypeDto defaultType = treeConfiguration.getDefaultType();
        if (defaultType != null) {
            treeTypeIdentifier = defaultType.getId();
        }
    }
    IdmTreeNodeFilter filter = toFilter(parameters);
    filter.setRoots(Boolean.TRUE);
    if (treeTypeIdentifier != null) {
        filter.setTreeTypeId(treeTypeIdentifier);
    }
    // 
    Page<IdmTreeNodeDto> roots = find(filter, pageable, IdmBasePermission.AUTOCOMPLETE);
    return toResources(roots, IdmTreeNode.class);
}
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) UUID(java.util.UUID) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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