Actions
Defect #1397
closedCannot set char value to IdMFormValueDto
Start date:
12/03/2018
Due date:
% Done:
100%
Estimated time:
Affected versions:
Owner:
Description
The problem is in method eu.bcvsolutions.idm.core.eav.api.dto.IdMFormValueDto.setValue(Serializable). If CHAR type was selected as IdMFormAttribute persistence type, then calling setValue with char results in an error. It works in GUI, because FE sends characters as one character Strings, but when you call the method in a way i just described, it does not work.
To give an example. Registration module copies values between two EAV attributes. It uses following code:
private void setEav(IdmIdentityDto user, IdmFormAttributeDto attribute) { IdmFormDefinitionDto definition = formService.getDefinition(IdmIdentity.class, "default"); IdmFormDefinitionDto regDefinition = formService.getDefinition(IdmIdentity.class, RegModuleDescriptor.MODULE_ID); List<Serializable> values = formService.getValues(user.getId(), IdmIdentity.class, regDefinition, attribute.getCode()) .stream().map(IdmFormValueDto::getValue).collect(toList()); if (!values.isEmpty() && definition.getFormAttributes().stream().anyMatch(a -> a.getCode().equals(attribute.getCode()))) { formService.saveValues(user.getId(), IdmIdentity.class, definition, attribute.getCode(), values); } }
The above code failed on CHAR EAVs which i think it should not have. In other words, calling getValue and then passing result to setValue method should work without an error.
Actions