|Re: About temporary/on-the-fly (~) model attributes [message #1735342 is a reply to message #1735330]
||Fri, 17 June 2016 13:17
| Bugra M. Yildiz
Registered: July 2014
Hello Dimitris, |
I will provide a minimal example as soon as I can. On the other hand, I try to come up with a work-around. Before providing a minimal example, let me describe my experience in an abstract way:
In metamodel A, I have an EClass called MainEClass.
In metamodel A_ext, I have an EClass called ReferringEClass that has a 1..1 "reference" to an instance of MainEClass.
In the following transformation code, I try to reverse this reference using a hash (Map in Epsilon) by using MainEClass instances as key and ReferringEClass instances as value.
//This operation returns a hash (<A!MainEClass>, <A_ext!ReferringEClass>)
operation getHash(): Map
var hashToReturn = new Map();
for(re: A_ext!ReferringEClass in A_ext!ReferringEClass.all)
hashToReturn.put(re.reference, re); //re.reference refers to A!MainEClass
var hash = getHash();
transform me:A!MainEClass to re: A_ext!ReferringEClass
//Guard is to make sure that this rule is triggered only if no A_ext!ReferringEClass instances are referring to this me:A!MainEClass
guard: hash.get(me) = null
The guard fails even if an instance of A!MainEClass already has a related A_ext!ReferringEClass instance. The reason is the following: The owning model of the keys in the hash (re.reference) is evaluated to be A_ext instead of A! I was naturally expecting the owning model of these keys to be A since their type is A!MainEClass. As a result, the guard evaluates based on the elements of A, which gives a different hash value.
The reason why on-the-fly values are not working can be the same. From developer perspective, I am expecting to attach this on-the-fly values to the elements of model A, however, if this attachment is implemented through the "reference" of A_ext!ReferringEClass, then it is not attached to the model element I am expecting.
[Updated on: Fri, 17 June 2016 16:22]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01378 seconds