Defect #1397

Cannot set char value to IdMFormValueDto

Added by Peter Šourek 8 months ago. Updated 7 months ago.

Target version:
Start date:
Due date:
% Done:



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())

        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.


#1 Updated by Radek Tomiška 8 months ago

This option was never implemented, but it's logical improvement. Persistent type 'CHAR' was used just for length validation.

#2 Updated by Radek Tomiška 7 months ago

  • Status changed from New to In Progress
  • Target version changed from Opal (9.4.0-rc.1) to Onyx (9.3.2)

#3 Updated by Radek Tomiška 7 months ago

  • Status changed from In Progress to Needs feedback
  • Assignee changed from Radek Tomiška to Peter Šourek
  • % Done changed from 0 to 90

It's implemented. Character value can be given as form value, commit:

Could you do a feedback please?

#4 Updated by Radek Tomiška 7 months ago

  • Assignee changed from Peter Šourek to Ondřej Kopr

#5 Updated by Ondřej Kopr 7 months 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.

#6 Updated by Ondřej Kopr 7 months ago

  • Status changed from Needs feedback to Resolved
  • Assignee changed from Ondřej Kopr to Radek Tomiška

#7 Updated by Radek Tomiška 7 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF