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);
}
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);
}
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());
}
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);
}
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);
}
Aggregations