Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PrintUtil for multi-valued attributes #277

Merged
merged 1 commit into from
Feb 11, 2025
Merged

Fix PrintUtil for multi-valued attributes #277

merged 1 commit into from
Feb 11, 2025

Conversation

vhemery
Copy link
Contributor

@vhemery vhemery commented Jan 9, 2025

Displays multi-valued attributes correctly.

The example plugin does not have tests, and registered models do not have mutivalued attributes.
Adding a new test module may not be relevant.
However, one can simply test this fix by executing :

package org.eclipse.emfcloud.modelserver.example.util;

import java.util.List;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.emf.ecore.EcorePackage;
import org.eclipse.emf.ecore.util.EcoreUtil;

public class PrintUtilTest {

   public static void main(final String[] args) {
      var ep = EcoreFactory.eINSTANCE.createEPackage();
      ep.setName("testModel");
      var ec = EcoreFactory.eINSTANCE.createEClass();
      ec.setName("TestManyAttribute");
      var att = EcoreFactory.eINSTANCE.createEAttribute();
      att.setName("values");
      att.setEType(EcorePackage.Literals.ESTRING);
      att.setUpperBound(-1);
      ec.getEStructuralFeatures().add(att);
      ep.getEClassifiers().add(ec);

      var obj = EcoreUtil.create(ec);
      EList<String> values = (EList<String>) obj.eGet(att);
      values.addAll(List.of("1", "2", "3"));
      // displays value successfully as "values: [1, 2, 3]"
      System.out.println(PrintUtil.toPrettyString(obj));
   }

}

Fixes #276

@vhemery vhemery requested a review from ndoschek January 9, 2025 10:18
@vhemery
Copy link
Contributor Author

vhemery commented Jan 9, 2025

Needs rebase after #280

Signed-off-by: Vincent Hémery <vincent.hemery@bonitasoft.com>
@ndoschek
Copy link
Contributor

Hi @vhemery,
We’re currently experiencing an issue with the model server's deployment workflow. I’m already working on fixing it. Once it’s resolved, I’ll proceed with approving your PRs. Thanks!

Copy link
Contributor

@ndoschek ndoschek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I ran your provided Test case and it works great! 👍

@ndoschek ndoschek merged commit 6feb264 into master Feb 11, 2025
8 checks passed
@ndoschek ndoschek deleted the issues/276 branch February 11, 2025 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PrintUtil fails with multi-valued attributes
2 participants