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