Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Setting a multi-valued tagged value
Setting a multi-valued tagged value [message #1858709] Mon, 17 April 2023 13:42 Go to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 146
Registered: July 2014
Senior Member
I'm struggling in setting tagged values of stereotypes with collections of values.

Reading such tagged values works fine by using the EMF getValue utility like this:

mv: Bag(OclAny) = element.getValue(element.getAppliedStereotype("MyStereotypeQualifiedName"), "myMVTaggedValue")->asBag();

However, using setValue in a similar way does not works:
mv: Bag(OclAny) = Bag{1, 2, 3};
element.setValue(element.getAppliedStereotype("MyStereotypeQualifiedName"), "myMVTaggedValue", mv);

Here is the kind of error message I get:
org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.IllegalArgumentException: [org.eclipse.emf.ecore.impl.DynamicEObjectImpl@44e0e3bd (eClass: org.eclipse.emf.ecore.impl.EClassImpl@615dc3b8 (name: MyClass) (instanceClassName: null) (abstract: false, interface: false))]
at public abstract void org.eclipse.uml2.uml.Element.setValue(org.eclipse.uml2.uml.Stereotype,java.lang.String,java.lang.Object)

Not that "setValue" works fine with mono-valued tagged values.



Yves
Re: Setting a multi-valued tagged value [message #1858717 is a reply to message #1858709] Tue, 18 April 2023 06:45 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 146
Registered: July 2014
Senior Member
Based on this discussion: https://www.eclipse.org/forums/index.php?t=msg&th=151899&goto=478214&#msg_478214
The value passed to setValue() for a multi-valued tagged value shall be a java.lang.List. So the question is how to have an OCL collection, as implemented in ATL, transformed to a java.lang.List?


Yves
Re: Setting a multi-valued tagged value [message #1858733 is a reply to message #1858717] Tue, 18 April 2023 17:32 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

That would be a Sequence.

Cheers,
Dennis
Re: Setting a multi-valued tagged value [message #1858744 is a reply to message #1858733] Wed, 19 April 2023 06:35 Go to previous message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 146
Registered: July 2014
Senior Member
Thanks for your reply.
I actually started with a Sequence but I got the same error. That's the reason why I tried with something more "generic" (i.e. Bag).

That said, I just tried this morning to set the tagged value with an empty Sequence and it works, actually. So I understand that the issue does not come from the collection itself (even if I probably have to use a Sequence) but from its content that could not be of the expected type (e.g. because it would not have been properly transformed).


Yves
Previous Topic:Sharing a library module over several projects
Next Topic:Bug in default trace resolution?
Goto Forum:
  


Current Time: Sat Nov 11 08:16:56 GMT 2023

Powered by FUDForum. Page generated in 0.01793 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top