[MGNLPN-663] Trait storage differs between Magnolia 5.7 and Magnolia 6.2 Created: 11/Jul/22  Updated: 23/Aug/22  Resolved: 23/Aug/22

Status: Closed
Project: Magnolia Personalization
Component/s: None
Affects Version/s: 2.1.3
Fix Version/s: None

Type: Bug Priority: Blocker
Reporter: Carlos Cantalapiedra Assignee: Lam Nguyen Bao
Resolution: Done Votes: 2
Labels: cs-bk
Σ Remaining Estimate: 0d Remaining Estimate: Not Specified
Σ Time Spent: 6.75d Time Spent: 6d 5.75h
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Attachments: PNG File 5.7-storage.png     PNG File 6.2-storage.png     File config.modules.mgnl-common-module.traits.TESTING5UI.yaml     File config.modules.mgnl-common-module.traits.TESTING6UI.yaml    
Issue Links:
Problem/Incident
Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLPN-684 DOC: Update ruleField description for... Documentation Task Closed Adrian Brooks  
MGNLPN-685 DOC: Review PR drafts Sub-task Closed Lam Nguyen Bao  
Template:
Acceptance criteria:
Empty
Task DoD:
[X]* Doc/release notes changes? Comment present?
[X]* Downstream builds green?
[X]* Solution information and context easily available?
[X]* Tests
[X]* FixVersion filled and not yet released
[X]  Architecture Decision Record (ADR)
Bug DoR:
[X]* Steps to reproduce, expected, and actual results filled
[X]* Affected version filled
Documentation update required:
Yes
Date of First Response:
Epic Link: AuthorX Support
Sprint: AuthX 15, AuthX 16
Story Points: 5
Team: AuthorX

 Description   

Description

A trait defined as a multivalue field which contains a composite composed by two textFields is stored at JCR in different ways on Magnolia 5.7 and Magnolia 6.2.

Steps to reproduce

  1. On Magnolia 5.7, import the trait in the attachments named config.modules.mgnl-common-module.traits.TESTING5UI.yaml
  2. Create a page, add a Variant and on the Choose audience option, select the new trait
  3. Create a couple of composite fields and fulfilled the both textfields (text and link)
  4. Save the trait and move to JCR tools
  5. On the variant, open the voter and check that the structure is as in the 5.7-storage.png image
  6. Now, start a > 6.2.18 Magnolia project
  7. Import the config.modules.mgnl-common-module.traits.TESTING6UI.yaml
  8. Double check that the migration to the new UI has been made following the official guide
    # Create a page, add a Variant and on the Choose audience option, select the new trait
  9. Create a couple of composite fields and fulfilled the both textfields (text and link)
  10. Save the trait and move to JCR tools
  11. On the variant, open the voter and check that the structure is as in the 6.2-storage.png image

Expected results

By following the official Magnolia 6 UI ports of 5 UI field transformer classes, the data is stored same way on Magnolia 5 and on Magnolia 6

Actual results

The data is missing a contentNode which prevents the node2Bean transformer to work as supposed

Workaround

N/A

Development notes

Its very important to achieve the very same storage behavior as far as the contentNode which contains the voters (named "fields", "items" whatever) must match the property List<Bean> nodeName so the node2Bean maps into a List all the voters.



 Comments   
Comment by Michail Botas [ 26/Jul/22 ]

Hello,

Could you please inform us when do you plan to start fixing this bug?

I am asking because this is quite important for us and we need to know your plan since your plan affects our planning.

 

Thanks,

Michail

Comment by Laura Delnevo [ 28/Jul/22 ]

Hi michail_botas, we have started looking into this bug as of this sprint. I can see already that you're watching this issue so you should be able to monitor our progress via Jira. Thank you, Laura 

Comment by Lam Nguyen Bao [ 16/Aug/22 ]

Hi ccantalapiedra michail_botas,

After investigating, I can confirm that the behavior is working as expected.

Technically ruleField be wrapped inside Multi-field (implicit). So for the definition we can have structure:

  • Multi-field(Voters)
    • Multi Field
      • compositeField

With this configuration, we will have similar data-structure in every apps.

In order to have the result as same as 5.2, we can provide composite field between those multi fields and it should work fine (custom traits with complex fields)

'TESTINGMULTIFIELD':
  'converterClass': 'info.magnolia.personalization.preview.parameter.DateParameterConverter'
  'traitClass': 'java.util.Date'
  'voterClass': 'info.magnolia.personalization.date.system.DateVoter'
  'ruleField':
    '$type': 'compositeField'
    'itemProvider':
      'class': 'info.magnolia.ui.editor.CurrentItemProvider'
    'properties':
      'fields':
        '$type': 'jcrMultiField'
        'label': 'Add this trait to see…’
        'entryResolution':
          'class': 'info.magnolia.ui.editor.MultiFieldEntryResolution$Definition'
          'propertyNameDecorator': 'info.magnolia.ui.field.AlwaysEmptyPrefixNameDecorator'
        'itemProvider':
          '$type': 'jcrChildNodeProvider'
          'supportI18N': false
          'nodeName': 'fields'
        'field':
          '$type': 'compositeField'
          'properties':
            'text':
              '$type': 'textField'
              'label': 'text'
              'name': 'text'
              'type': 'java.lang.String'
            'link':
              '$type': 'textField'
              'label': 'link'
              'name': 'link'
  'valueField':
    'extends': '../ruleField' 

 

 

Comment by Michail Botas [ 16/Aug/22 ]

Hi @lam.nguyen,

Indeed you are totally right!!! 

In the definition that I provided to Carlos I did not have the 1st composite field! So this was causing issues.

 
In short (as it is mentioned in Creating-custom-traits-with-complex-fields in provided definition example) structure for complex field should be

  • composite field
    • multifield
      • composite field
        • fields (in my case 2 textField)

It is not so clear to understand this from documentation page with first reading. After your detailed comment it is purely clear what is required. 

I believe this ticket and SUPPORT-15118 can be closed.

 

Many many thanks for your help,

Michail

Comment by Laura Delnevo [ 16/Aug/22 ]

michail_botas thanks for the feedback, and good point about the documentation. I will take a look and we'll update it 

Generated at Mon Feb 12 06:39:51 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.