Search in sources :

Example 1 with AccIdentityRoleAccountDto

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

the class IdentityRoleProvisioningExecutor method doProvisioning.

public void doProvisioning(AccAccountDto account) {
    Assert.notNull(account, "Account is required.");
    AccIdentityRoleAccountFilter filter = new AccIdentityRoleAccountFilter();
    filter.setAccountId(account.getId());
    List<AccIdentityRoleAccountDto> entityAccoutnList = identityRoleAccountService.find(filter, null).getContent();
    if (entityAccoutnList == null) {
        return;
    }
    entityAccoutnList.stream().filter(entityAccount -> {
        return entityAccount.isOwnership();
    }).forEach((identityRoleAccount) -> {
        doProvisioning(account, DtoUtils.getEmbedded(identityRoleAccount, AccIdentityRoleAccount_.identityRole, IdmIdentityRoleDto.class));
    });
}
Also used : ProvisioningExecutor(eu.bcvsolutions.idm.acc.service.api.ProvisioningExecutor) IcConnectorFacade(eu.bcvsolutions.idm.ic.service.api.IcConnectorFacade) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) AccIdentityRoleAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityRoleAccountFilter) SysSystemEntityService(eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService) Autowired(org.springframework.beans.factory.annotation.Autowired) EntityAccountDto(eu.bcvsolutions.idm.acc.dto.EntityAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AccIdentityRoleAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityRoleAccountDto) SysSystemMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemMappingService) Lists(com.google.common.collect.Lists) 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) SysRoleSystemAttributeService(eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService) IdmIdentityRoleService(eu.bcvsolutions.idm.core.api.service.IdmIdentityRoleService) AccIdentityRoleAccount_(eu.bcvsolutions.idm.acc.entity.AccIdentityRoleAccount_) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) IdmRoleService(eu.bcvsolutions.idm.core.api.service.IdmRoleService) AccIdentityRoleAccountService(eu.bcvsolutions.idm.acc.service.api.AccIdentityRoleAccountService) AccRoleAccountService(eu.bcvsolutions.idm.acc.service.api.AccRoleAccountService) SysRoleSystemAttributeDto(eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto) SysSchemaAttributeService(eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService) List(java.util.List) AccAccountService(eu.bcvsolutions.idm.acc.service.api.AccAccountService) SysSchemaObjectClassService(eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService) SysSystemAttributeMappingService(eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) Assert(org.springframework.util.Assert) AccIdentityRoleAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityRoleAccountFilter) IdmIdentityRoleDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto) AccIdentityRoleAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityRoleAccountDto)

Example 2 with AccIdentityRoleAccountDto

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

the class DefaultAccIdentityRoleAccountService method delete.

@Override
@Transactional
public void delete(AccIdentityRoleAccountDto entity, boolean deleteTargetAccount, BasePermission... permission) {
    Assert.notNull(entity, "Entity is required.");
    super.delete(entity, permission);
    UUID account = entity.getAccount();
    // We check if exists another (ownership) identityAccounts, if not
    // then
    // we will delete account
    AccIdentityRoleAccountFilter filter = new AccIdentityRoleAccountFilter();
    filter.setAccountId(account);
    filter.setOwnership(Boolean.TRUE);
    List<AccIdentityRoleAccountDto> entityAccounts = this.find(filter, null).getContent();
    boolean moreEntityAccounts = entityAccounts.stream().filter(treeAccount -> {
        return treeAccount.isOwnership() && !treeAccount.equals(entity);
    }).findAny().isPresent();
    if (!moreEntityAccounts && entity.isOwnership()) {
        // We delete all entity accounts first
        entityAccounts.forEach(identityAccount -> {
            super.delete(identityAccount);
        });
        // Finally we can delete account
        accountService.publish(new AccountEvent(AccountEventType.DELETE, accountService.get(account), ImmutableMap.of(AccAccountService.DELETE_TARGET_ACCOUNT_PROPERTY, deleteTargetAccount, AccAccountService.ENTITY_ID_PROPERTY, entity.getEntity())));
    }
}
Also used : AccountEvent(eu.bcvsolutions.idm.acc.event.AccountEvent) UUID(java.util.UUID) AccIdentityRoleAccountFilter(eu.bcvsolutions.idm.acc.dto.filter.AccIdentityRoleAccountFilter) AccIdentityRoleAccountDto(eu.bcvsolutions.idm.acc.dto.AccIdentityRoleAccountDto) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AccIdentityRoleAccountDto (eu.bcvsolutions.idm.acc.dto.AccIdentityRoleAccountDto)2 AccIdentityRoleAccountFilter (eu.bcvsolutions.idm.acc.dto.filter.AccIdentityRoleAccountFilter)2 Lists (com.google.common.collect.Lists)1 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)1 AccAccountDto (eu.bcvsolutions.idm.acc.dto.AccAccountDto)1 EntityAccountDto (eu.bcvsolutions.idm.acc.dto.EntityAccountDto)1 SysRoleSystemAttributeDto (eu.bcvsolutions.idm.acc.dto.SysRoleSystemAttributeDto)1 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)1 AccIdentityRoleAccount_ (eu.bcvsolutions.idm.acc.entity.AccIdentityRoleAccount_)1 AccountEvent (eu.bcvsolutions.idm.acc.event.AccountEvent)1 AccAccountService (eu.bcvsolutions.idm.acc.service.api.AccAccountService)1 AccIdentityRoleAccountService (eu.bcvsolutions.idm.acc.service.api.AccIdentityRoleAccountService)1 AccRoleAccountService (eu.bcvsolutions.idm.acc.service.api.AccRoleAccountService)1 ProvisioningExecutor (eu.bcvsolutions.idm.acc.service.api.ProvisioningExecutor)1 SysRoleSystemAttributeService (eu.bcvsolutions.idm.acc.service.api.SysRoleSystemAttributeService)1 SysRoleSystemService (eu.bcvsolutions.idm.acc.service.api.SysRoleSystemService)1 SysSchemaAttributeService (eu.bcvsolutions.idm.acc.service.api.SysSchemaAttributeService)1 SysSchemaObjectClassService (eu.bcvsolutions.idm.acc.service.api.SysSchemaObjectClassService)1 SysSystemAttributeMappingService (eu.bcvsolutions.idm.acc.service.api.SysSystemAttributeMappingService)1 SysSystemEntityService (eu.bcvsolutions.idm.acc.service.api.SysSystemEntityService)1