use of eu.bcvsolutions.idm.core.eav.api.service.DelegationType in project CzechIdMng by bcvsolutions.
the class DefaultDelegationManager method findDelegation.
@Override
public List<IdmDelegationDefinitionDto> findDelegation(String type, UUID delegatorId, UUID delegatorContractId, BaseDto owner) {
Assert.notNull(type, "Delegation type cannot be null!");
Assert.notNull(delegatorId, "Delegator cannot be null!");
DelegationType delegateType = this.getDelegateType(type);
if (delegateType == null) {
// of delegatio type for this code missing ) -> throw exception.
throw new ResultCodeException(CoreResultCode.DELEGATION_UNSUPPORTED_TYPE, ImmutableMap.of("type", type));
}
List<IdmDelegationDefinitionDto> definitions = delegateType.findDelegation(delegatorId, delegatorContractId, owner);
if (CollectionUtils.isEmpty(definitions)) {
if (DefaultDelegationType.NAME.equals(type)) {
return null;
}
// Try to default delegation.
DelegationType defaultDelegateType = this.getDelegateType(DefaultDelegationType.NAME);
definitions = defaultDelegateType.findDelegation(delegatorId, delegatorContractId, owner);
if (CollectionUtils.isEmpty(definitions)) {
return null;
}
}
definitions.forEach(definition -> {
LOG.debug("Delegation definition found [{}] for type [{}] and delegator [{}]", definition.getId(), type, delegatorId);
});
return definitions;
}
use of eu.bcvsolutions.idm.core.eav.api.service.DelegationType in project CzechIdMng by bcvsolutions.
the class DefaultIdmDelegationDefinitionService method toDto.
@Override
protected IdmDelegationDefinitionDto toDto(IdmDelegationDefinition entity, IdmDelegationDefinitionDto dto, IdmDelegationDefinitionFilter filter) {
dto = super.toDto(entity, dto, filter);
if (dto != null && dto.getType() != null) {
// Add delegation type DTO to the delegation definition.
DelegationType delegateType = delegationManager.getDelegateType(dto.getType());
if (delegateType != null) {
DelegationTypeDto delegationTypeDto = delegationManager.convertDelegationTypeToDto(delegateType);
// I cannot use a key "type", because EnumSelect on FE try to use complex value from embedded.
dto.getEmbedded().put(DelegationManager.WORKFLOW_DELEGATION_TYPE_KEY, delegationTypeDto);
}
}
return dto;
}
use of eu.bcvsolutions.idm.core.eav.api.service.DelegationType in project CzechIdMng by bcvsolutions.
the class DefaultDelegationManager method delegate.
@Override
public IdmDelegationDto delegate(BaseDto owner, IdmDelegationDefinitionDto definition) {
Assert.notNull(owner, "Delegation goal/owner cannot be null!");
Assert.notNull(definition, "Delegation definition cannot be null!");
DelegationType delegateType = this.getDelegateType(definition.getType());
if (delegateType == null) {
// of delegation type for this code missing ) -> throw exception.
throw new ResultCodeException(CoreResultCode.DELEGATION_UNSUPPORTED_TYPE, ImmutableMap.of("type", definition.getType()));
}
return delegateType.delegate(owner, definition);
}
Aggregations