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