Defect #1397
closedCannot set char value to IdMFormValueDto
100%
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.
Updated by Radek Tomiška almost 6 years ago
This option was never implemented, but it's logical improvement. Persistent type 'CHAR' was used just for length validation.
Updated by Radek Tomiška almost 6 years ago
- Status changed from New to In Progress
- Target version changed from Opal (9.4.0-rc.1) to Onyx (9.3.2)
Updated by Radek Tomiška almost 6 years ago
- Status changed from In Progress to Needs feedback
- Assignee changed from Radek Tomiška to Peter Štrunc
- % Done changed from 0 to 90
It's implemented. Character value can be given as form value, commit:
https://github.com/bcvsolutions/CzechIdMng/commit/02a442bc1f941dcf702dce9a181363b2da062629
Could you do a feedback please?
Updated by Radek Tomiška almost 6 years ago
- Assignee changed from Peter Štrunc to Ondřej Kopr
Updated by Ondřej Kopr almost 6 years ago
- % Done changed from 90 to 100
I checked this functionality on my virtual with older version and via frontend works everything well before. I create script with similar behavior as exists in tests and this works well now. Maybe Petr had to make a review because he knew exactly what he had broken.
For my script and your tests works set character well. Thank you for implementing this.
Updated by Ondřej Kopr almost 6 years ago
- Status changed from Needs feedback to Resolved
- Assignee changed from Ondřej Kopr to Radek Tomiška
Updated by Radek Tomiška almost 6 years ago
- Status changed from Resolved to Closed