Search in sources :

Example 6 with AccTreeAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccTreeAccountFilter in project CzechIdMng by bcvsolutions.

the class TreeProvisioningExecutor method getAttributeValue.

@Override
protected Object getAttributeValue(String uid, IdmTreeNodeDto entity, AttributeMapping attribute) {
    Object idmValue = super.getAttributeValue(uid, entity, attribute);
    if (attribute.isEntityAttribute() && TreeSynchronizationExecutor.PARENT_FIELD.equals(attribute.getIdmPropertyName())) {
        // parent format (UID of parent)
        if (idmValue instanceof UUID) {
            // Generally we expect IdmTreeNode as parent (we will do
            // transform)
            AccTreeAccountFilter treeAccountFilter = new AccTreeAccountFilter();
            treeAccountFilter.setSystemId(this.getSytemFromSchemaAttribute(attribute.getSchemaAttribute()).getId());
            treeAccountFilter.setTreeNodeId(((UUID) idmValue));
            List<AccTreeAccountDto> treeAccounts = treeAccountService.find(treeAccountFilter, null).getContent();
            if (treeAccounts.isEmpty()) {
                throw new ProvisioningException(AccResultCode.PROVISIONING_TREE_PARENT_ACCOUNT_NOT_FOUND, ImmutableMap.of("parentNode", idmValue));
            }
            if (treeAccounts.size() != 1) {
                throw new ProvisioningException(AccResultCode.PROVISIONING_TREE_TOO_MANY_PARENT_ACCOUNTS, ImmutableMap.of("parentNode", idmValue));
            }
            AccTreeAccountDto treeAccount = treeAccounts.get(0);
            String parentUid = accountService.get(treeAccount.getAccount()).getUid();
            return parentUid;
        } else {
            // without any transform
            return idmValue;
        }
    }
    return idmValue;
}
Also used : AccTreeAccountDto(eu.bcvsolutions.idm.acc.dto.AccTreeAccountDto) AccTreeAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccTreeAccountFilter) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) UUID(java.util.UUID)

Example 7 with AccTreeAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccTreeAccountFilter in project CzechIdMng by bcvsolutions.

the class TreeSynchronizationExecutor method doUnlink.

/**
 * Operation remove EntityAccount relations and linked roles
 *
 * @param account
 * @param removeIdentityRole
 * @param log
 * @param logItem
 * @param actionLogs
 */
@Override
protected void doUnlink(AccAccountDto account, boolean removeIdentityRole, SysSyncLogDto log, SysSyncItemLogDto logItem, List<SysSyncActionLogDto> actionLogs) {
    AccTreeAccountFilter treeAccountFilter = new AccTreeAccountFilter();
    treeAccountFilter.setAccountId(account.getId());
    List<AccTreeAccountDto> treeAccounts = treeAccountService.find(treeAccountFilter, null).getContent();
    if (treeAccounts.isEmpty()) {
        addToItemLog(logItem, "Tree account relation was not found!");
        initSyncActionLog(SynchronizationActionType.UPDATE_ENTITY, OperationResultType.WARNING, logItem, log, actionLogs);
        return;
    }
    addToItemLog(logItem, MessageFormat.format("Tree-account relations to delete {0}", treeAccounts));
    treeAccounts.stream().forEach(treeAccount -> {
        // We will remove tree account, but without delete connected
        // account
        treeAccountService.delete(treeAccount, false);
        addToItemLog(logItem, MessageFormat.format("Tree-account relation deleted (without call delete provisioning) (treeNode: {0}, id: {1})", treeAccount.getTreeNode(), treeAccount.getId()));
    });
    return;
}
Also used : AccTreeAccountDto(eu.bcvsolutions.idm.acc.dto.AccTreeAccountDto) AccTreeAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccTreeAccountFilter)

Example 8 with AccTreeAccountFilter

use of eu.bcvsolutions.idm.acc.dto.filter.AccTreeAccountFilter in project CzechIdMng by bcvsolutions.

the class TreeProvisioningExecutor method doProvisioning.

public void doProvisioning(AccAccountDto account) {
    Assert.notNull(account);
    AccTreeAccountFilter filter = new AccTreeAccountFilter();
    filter.setAccountId(account.getId());
    List<AccTreeAccountDto> treeAccoutnList = treeAccountService.find(filter, null).getContent();
    if (treeAccoutnList == null) {
        return;
    }
    treeAccoutnList.stream().filter(treeAccount -> {
        return treeAccount.isOwnership();
    }).forEach((treeAccount) -> {
        doProvisioning(account, DtoUtils.getEmbedded(treeAccount, AccTreeAccount_.treeNode, IdmTreeNodeDto.class));
    });
}
Also used : ProvisioningExecutor(eu.bcvsolutions.idm.acc.service.api.ProvisioningExecutor) IdmTreeNodeService(eu.bcvsolutions.idm.core.api.service.IdmTreeNodeService) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) AccTreeAccount_(eu.bcvsolutions.idm.acc.entity.AccTreeAccount_) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto) Autowired(org.springframework.beans.factory.annotation.Autowired) EntityAccountDto(eu.bcvsolutions.idm.acc.dto.EntityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AccTreeAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccTreeAccountFilter) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) ArrayList(java.util.ArrayList) AccAccountManagementService(eu.bcvsolutions.idm.acc.service.api.AccAccountManagementService) AccTreeAccountService(eu.bcvsolutions.idm.acc.service.api.AccTreeAccountService) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) SysRoleSystemService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService) SystemEntityType(eu.bcvsolutions.idm.acc.domain.SystemEntityType) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) Service(org.springframework.stereotype.Service) Qualifier(org.springframework.beans.factory.annotation.Qualifier) SysSystemMappingFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemMappingFilter) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) ImmutableMap(com.google.common.collect.ImmutableMap) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) SystemOperationType(eu.bcvsolutions.idm.acc.domain.SystemOperationType) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) UUID(java.util.UUID) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) AttributeMapping(eu.bcvsolutions.idm.acc.domain.AttributeMapping) List(java.util.List) EntityAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.EntityAccountFilter) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) SysSystemMappingDto(eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) AccResultCode(eu.bcvsolutions.idm.acc.domain.AccResultCode) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) AccTreeAccountDto(eu.bcvsolutions.idm.acc.dto.AccTreeAccountDto) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) Assert(org.springframework.util.Assert) AccTreeAccountDto(eu.bcvsolutions.idm.acc.dto.AccTreeAccountDto) AccTreeAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccTreeAccountFilter) IdmTreeNodeDto(eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)

Aggregations

AccTreeAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccTreeAccountFilter)8 AccTreeAccountDto (eu.bcvsolutions.idm.acc.dto.AccTreeAccountDto)6 UUID (java.util.UUID)5 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)3 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)3 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)2 IdmTreeNodeDto (eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto)2 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 AccResultCode (eu.bcvsolutions.idm.acc.domain.AccResultCode)1 AttributeMapping (eu.bcvsolutions.idm.acc.domain.AttributeMapping)1 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)1 SystemOperationType (eu.bcvsolutions.idm.acc.domain.SystemOperationType)1 AccContractAccountDto (eu.bcvsolutions.idm.acc.dto.AccContractAccountDto)1 AccIdentityAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityAccountDto)1 AccRoleAccountDto (eu.bcvsolutions.idm.acc.dto.AccRoleAccountDto)1 AccRoleCatalogueAccountDto (eu.bcvsolutions.idm.acc.dto.AccRoleCatalogueAccountDto)1 EntityAccountDto (eu.bcvsolutions.idm.acc.dto.EntityAccountDto)1 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)1 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)1