Project

General

Profile

Actions

Defect #1397

closed

Cannot set char value to IdMFormValueDto

Added by Peter Štrunc over 5 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Radek Tomiška
Category:
Eav
Target version:
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 #1

Updated by Radek Tomiška over 5 years ago

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

Actions #2

Updated by Radek Tomiška over 5 years ago

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

Updated by Radek Tomiška over 5 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?

Actions #4

Updated by Radek Tomiška over 5 years ago

  • Assignee changed from Peter Štrunc to Ondřej Kopr
Actions #5

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

Actions #6

Updated by Ondřej Kopr over 5 years ago

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

Updated by Radek Tomiška over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF