use of eu.bcvsolutions.idm.core.model.entity.IdmAutomaticRoleRequest in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleRequestService method toEntity.
@Override
protected IdmAutomaticRoleRequest toEntity(IdmAutomaticRoleRequestDto dto, IdmAutomaticRoleRequest entity) {
if (this.isNew(dto)) {
dto.setResult(new OperationResultDto(OperationState.CREATED));
dto.setState(RequestState.CONCEPT);
if (dto.getRequestType() == null) {
dto.setRequestType(AutomaticRoleRequestType.ATTRIBUTE);
}
}
IdmAutomaticRoleRequest requestEntity = super.toEntity(dto, entity);
// Convert type of automatic role
if (dto != null) {
UUID automaticRoleId = dto.getAutomaticRole();
if (automaticRoleId != null && AutomaticRoleRequestType.ATTRIBUTE == dto.getRequestType()) {
requestEntity.setAutomaticRole((IdmAutomaticRoleAttribute) lookupService.lookupEntity(IdmAutomaticRoleAttribute.class, automaticRoleId));
}
if (automaticRoleId != null && AutomaticRoleRequestType.TREE == dto.getRequestType()) {
requestEntity.setAutomaticRole((IdmRoleTreeNode) lookupService.lookupEntity(IdmRoleTreeNode.class, automaticRoleId));
}
}
if (requestEntity != null && requestEntity.getAutomaticRole() != null) {
requestEntity.setRole(requestEntity.getAutomaticRole().getRole());
if (Strings.isNullOrEmpty(requestEntity.getName())) {
requestEntity.setName(requestEntity.getAutomaticRole().getName());
}
}
return requestEntity;
}
Aggregations