use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class TreeSynchronizationExecutor method startExport.
/**
* Start export entities to target resource
*
* @param entityType
* @param config
* @param mappedAttributes
* @param log
* @param actionsLog
*/
@Override
protected void startExport(SystemEntityType entityType, AbstractSysSyncConfigDto config, List<SysSystemAttributeMappingDto> mappedAttributes, SysSyncLogDto log, List<SysSyncActionLogDto> actionsLog) {
SysSystemMappingDto systemMapping = systemMappingService.get(config.getSystemMapping());
SysSchemaObjectClassDto schemaObjectClassDto = schemaObjectClassService.get(systemMapping.getObjectClass());
SysSystemDto system = DtoUtils.getEmbedded(schemaObjectClassDto, SysSchemaObjectClass_.system, SysSystemDto.class);
SysSystemAttributeMappingDto uidAttribute = attributeHandlingService.getUidAttribute(mappedAttributes, system);
List<IdmTreeNodeDto> roots = treeNodeService.findRoots(systemMapping.getTreeType(), null).getContent();
roots.stream().forEach(root -> {
SynchronizationContext itemBuilder = new SynchronizationContext();
//
itemBuilder.addConfig(config).addSystem(//
system).addEntityType(//
entityType).addLog(//
log).addActionLogs(actionsLog);
// Start export for this entity
exportChildrenRecursively(root, itemBuilder, uidAttribute);
});
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class TreeSynchronizationExecutor method exportChildrenRecursively.
private void exportChildrenRecursively(IdmTreeNodeDto treeNode, SynchronizationContext itemBuilder, SysSystemAttributeMappingDto uidAttribute) {
SysSyncItemLogDto logItem = itemBuilder.getLogItem();
List<IdmTreeNodeDto> children = treeNodeService.findChildrenByParent(treeNode.getId(), null).getContent();
if (children.isEmpty()) {
this.exportEntity(itemBuilder, uidAttribute, treeNode);
} else {
addToItemLog(logItem, MessageFormat.format("Tree node [{0}] has children [count={1}].", treeNode.getName(), children.size()));
this.exportEntity(itemBuilder, uidAttribute, treeNode);
children.forEach(child -> {
exportChildrenRecursively(child, itemBuilder, uidAttribute);
});
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class TreeSynchronizationExecutor method doCreateEntity.
/**
* Create and persist new entity by data from IC attributes
*
* @param entityType
* @param mappedAttributes
* @param logItem
* @param uid
* @param icAttributes
* @param account
*/
@SuppressWarnings("unchecked")
@Override
protected void doCreateEntity(SystemEntityType entityType, List<SysSystemAttributeMappingDto> mappedAttributes, SysSyncItemLogDto logItem, String uid, List<IcAttribute> icAttributes, AccAccountDto account, SynchronizationContext context) {
// We will create new TreeNode
addToItemLog(logItem, "Missing entity action is CREATE_ENTITY, we will create a new entity.");
IdmTreeNodeDto treeNode = new IdmTreeNodeDto();
// Fill entity by mapped attribute
treeNode = fillEntity(mappedAttributes, uid, icAttributes, treeNode, true, context);
treeNode.setTreeType(this.getSystemMapping(mappedAttributes).getTreeType());
// Create new Entity
treeNode = this.save(treeNode, true);
// Update extended attribute (entity must be persisted first)
updateExtendedAttributes(mappedAttributes, uid, icAttributes, treeNode, true, context);
// Update confidential attribute (entity must be persisted first)
updateConfidentialAttributes(mappedAttributes, uid, icAttributes, treeNode, true, context);
// Create new Entity account relation
EntityAccountDto entityAccount = this.createEntityAccountDto();
entityAccount.setAccount(account.getId());
entityAccount.setEntity(treeNode.getId());
entityAccount.setOwnership(true);
this.getEntityAccountService().save(entityAccount);
// Call provisioning for entity
this.callProvisioningForEntity(treeNode, entityType, logItem);
// Entity Created
addToItemLog(logItem, MessageFormat.format("Tree node with id {0} was created", treeNode.getId()));
if (logItem != null) {
logItem.setDisplayName(treeNode.getName());
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleValidRequestSchedulerTest method createNonValidRole.
@Test
public void createNonValidRole() {
IdmIdentityDto identity = createAndSaveIdentity();
IdmRoleDto role = createAndSaveRole();
createAndSaveRoleSystem(role, system);
IdmTreeTypeDto treeType = createAndSaveTreeType();
IdmTreeNodeDto treeNode = createAndSaveTreeNode(treeType);
IdmIdentityContractDto identityContract = createAndSaveIdentityContract(identity, treeNode);
LocalDate validFrom = new LocalDate();
// set plus days
validFrom = validFrom.plusDays(5);
// provisioning is not executed
createAndSaveIdentityRole(identityContract, role, null, validFrom);
AccIdentityAccountFilter filter = new AccIdentityAccountFilter();
filter.setIdentityId(identity.getId());
List<AccIdentityAccountDto> list = identityAccountService.find(filter, null).getContent();
// it must not exists
assertEquals(true, list.isEmpty());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningServiceTest method doIdentityProvisioningChangeManagersContract.
/**
* Call provisioning for subordinates, after managers's contract changes - filled managers could be provisioned
*/
@Test
public void doIdentityProvisioningChangeManagersContract() {
IdmIdentityDto managerOne = createIdentity();
IdmIdentityDto subordinateOne = createIdentity();
IdmTreeNodeDto managerOnePosition = createTreeNode(null);
IdmIdentityContractDto managersContract = createIdentityContact(managerOne, managerOnePosition);
IdmTreeNodeDto subordinateOnePositionOne = createTreeNode(managerOnePosition);
createIdentityContact(subordinateOne, subordinateOnePositionOne);
AccIdentityAccountDto subordinateAccount = prepareAccount(subordinateOne);
//
provisioningService.doProvisioning(DtoUtils.getEmbedded(subordinateAccount, AccIdentityAccount_.identity, IdmIdentityDto.class));
//
TestResource account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
Assert.assertNotNull(account);
Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
//
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setSubordinatesFor(managerOne.getId());
List<IdmIdentityDto> subordinates = idmIdentityService.find(filter, null).getContent();
Assert.assertEquals(1, subordinates.size());
Assert.assertEquals(subordinateOne.getId(), subordinates.get(0).getId());
//
// change subordinate
subordinateOne.setFirstName("first-name-change-one");
subordinateOne = idmIdentityService.saveInternal(subordinateOne);
//
// change managers contract
managersContract.setWorkPosition(null);
managersContract = identityContractService.save(managersContract);
//
account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
Assert.assertNotNull(account);
Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
subordinates = idmIdentityService.find(filter, null).getContent();
Assert.assertEquals(0, subordinates.size());
//
// change subordinate again
subordinateOne.setFirstName("first-name-change-two");
subordinateOne = idmIdentityService.saveInternal(subordinateOne);
//
managersContract.setWorkPosition(managerOnePosition.getId());
managersContract = identityContractService.save(managersContract);
//
account = entityManager.find(TestResource.class, accountService.get(subordinateAccount.getAccount()).getUid());
Assert.assertNotNull(account);
Assert.assertEquals(subordinateOne.getFirstName(), account.getFirstname());
subordinates = idmIdentityService.find(filter, null).getContent();
Assert.assertEquals(1, subordinates.size());
Assert.assertEquals(subordinateOne.getId(), subordinates.get(0).getId());
}
Aggregations