Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Assigning values to a Map owned by a target element(creation of an EAnnotation)
Assigning values to a Map owned by a target element [message #1860807] Mon, 04 September 2023 08:14 Go to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 146
Registered: July 2014
Senior Member
I'm trying to get a transformation that can create EAnnotation. For that purpose, I wrote the following called rule:

rule createEAnnotation(source: String, key: String, value: String) {
	
	to 
		tgt: ECORE!EAnnotation (
			source <- source
			,details <- Map{(key, value)}
		)
}

But at runtime, calling this rule generates the following exception:

org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.IllegalArgumentException: Cannot assign Map{'derivation'='-- some OCL code'} to multi-valued field EAnnotation::details

However the eCore javadoc actually says that this attribute is typed by EMap<java.lang.String,java.lang.String>

What is wrong?


Yves

[Updated on: Mon, 04 September 2023 12:51]

Report message to a moderator

Re: Assigning values to a Map owned by a target element [message #1860817 is a reply to message #1860807] Mon, 04 September 2023 15:33 Go to previous messageGo to next message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 146
Registered: July 2014
Senior Member
It looks like I already report this issue and that I got the solution... So, sorry for having asking this question again. I provide the solution here for the record, in case somebody would look for it as well.

This is the proper way to do it:
rule createEAnnotation(source: String, key: String, value: String) {
	to 
	tgt: ECORE!EAnnotation (
		source <- source	
		,details <- Set{entry}
	),
	
	entry: ECORE!EStringToStringMapEntry(
		key <- key
		,value <- value
	)

}


Yves
Re: Assigning values to a Map owned by a target element [message #1860819 is a reply to message #1860817] Mon, 04 September 2023 18:40 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

That is indeed the solution, because:
public interface EMap<K, V> extends EList<Map.Entry<K, V>>

which means ATL treats EAnnotation::details as a Sequence.


Cheers,
Dennis
Re: Assigning values to a Map owned by a target element [message #1861041 is a reply to message #1860819] Fri, 15 September 2023 08:29 Go to previous message
Yves BERNARD is currently offline Yves BERNARDFriend
Messages: 146
Registered: July 2014
Senior Member
Ok, so:
details <- Sequence{entry}

is even better.


Yves
Previous Topic:Issue with cached Helpers
Next Topic:ATL rules doesn't match
Goto Forum:
  


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

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

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

Back to the top