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