use of eu.bcvsolutions.idm.core.eav.entity.IdmFormValue_ in project CzechIdMng by bcvsolutions.
the class IdentityProvisioningExecutor method convertToAssignedRoleDto.
public static AssignedRoleDto convertToAssignedRoleDto(IdmIdentityRoleDto identityRole) {
if (identityRole == null) {
return null;
}
AssignedRoleDto dto = new AssignedRoleDto();
dto.setId(identityRole.getId());
dto.setExternalId(identityRole.getExternalId());
dto.setValidFrom(identityRole.getValidFrom());
dto.setValidTill(identityRole.getValidTill());
dto.setRole(DtoUtils.getEmbedded(identityRole, IdmIdentityRole_.role, IdmRoleDto.class, null));
dto.setIdentityContract(DtoUtils.getEmbedded(identityRole, IdmIdentityRole_.identityContract, IdmIdentityContractDto.class, null));
dto.setContractPosition(DtoUtils.getEmbedded(identityRole, IdmIdentityRole_.contractPosition, IdmContractPositionDto.class, null));
dto.setDirectRole(DtoUtils.getEmbedded(identityRole, IdmIdentityRole_.directRole, IdmIdentityRoleDto.class, null));
dto.setRoleTreeNode(DtoUtils.getEmbedded(identityRole, IdmIdentityRoleDto.PROPERTY_ROLE_TREE_NODE, AbstractIdmAutomaticRoleDto.class, null));
dto.setRoleComposition(DtoUtils.getEmbedded(identityRole, IdmIdentityRole_.roleComposition, IdmRoleCompositionDto.class, null));
UUID definition = dto.getRole().getIdentityRoleAttributeDefinition();
if (definition != null) {
// Definition for role attributes exists
IdmFormInstanceDto formInstanceDto = //
identityRole.getEavs().stream().filter(//
formInstance -> definition.equals(formInstance.getFormDefinition().getId())).findFirst().orElse(null);
if (formInstanceDto != null) {
List<IdmFormValueDto> values = formInstanceDto.getValues();
// Search all attributes
values.stream().map(//
IdmFormValueDto::getFormAttribute).distinct().forEach(attribute -> {
List<IdmFormValueDto> formValues = // Search all values for one attribute
values.stream().filter(//
value -> attribute.equals(value.getFormAttribute())).collect(//
Collectors.toList());
IdmFormAttributeDto formAttributeDto = DtoUtils.getEmbedded(formValues.get(0), IdmFormValue_.formAttribute, IdmFormAttributeDto.class);
dto.getAttributes().put(formAttributeDto.getCode(), //
formValues.stream().map(// Value is always list
IdmFormValueDto::getValue).collect(//
Collectors.toList()));
});
}
}
return dto;
}
Aggregations