Search in sources :

Example 56 with IdmTreeNodeDto

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);
    });
}
Also used : SynchronizationContext(eu.bcvsolutions.idm.acc.domain.SynchronizationContext) SysSystemAttributeMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassDto(eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 57 with IdmTreeNodeDto

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);
        });
    }
}
Also used : SysSyncItemLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)

Example 58 with IdmTreeNodeDto

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());
    }
}
Also used : EntityAccountDto(eu.bcvsolutions.idm.acc.dto.EntityAccountDto) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)

Example 59 with IdmTreeNodeDto

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());
}
Also used : IdmTreeTypeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto) IdmRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmRoleDto) AccIdentityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityAccountFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) LocalDate(org.joda.time.LocalDate) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 60 with IdmTreeNodeDto

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());
}
Also used : IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) TestResource(eu.bcvsolutions.idm.acc.entity.TestResource) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) AccIdentityAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)79 Test (org.junit.Test)48 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)44 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)35 IdmTreeTypeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto)31 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)26 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)21 UUID (java.util.UUID)13 IdmTreeNodeFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmTreeNodeFilter)12 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)12 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)9 LocalDate (org.joda.time.LocalDate)9 IdmIdentityContractFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter)7 SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)6 IdmRoleTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleTreeNodeDto)6 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 ApiOperation (io.swagger.annotations.ApiOperation)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)5