About temporary/on-the-fly (~) model attributes [message #1735329] |
Fri, 17 June 2016 12:04 |
Eclipse User |
|
|
|
Hello,
I have a model transformation that takes two models, A and A_ext. A_ext is an extension of A and gives reference to A. A is a stand-alone model.
For increasing tracebility from model A to model A_ext, I create on-the-fly attribute ~backReference to the related elements in A. This on-the-fly attribute is basically a reverse reference of the already existing reference from A_ext to A. However, the problem is, even if I set the ~backReference, it always evaluates to null instead of showing related/set element of the model A_ext.
I wonder if this is a bug or there is a known limitation of (~) on-the-fly attribute creation/setting.
|
|
|
|
Re: About temporary/on-the-fly (~) model attributes [message #1735342 is a reply to message #1735330] |
Fri, 17 June 2016 13:17 |
Eclipse User |
|
|
|
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
}
return hashToReturn;
}
pre
{
var hash = getHash();
}
@greedy
rule A_MainEClass2A_ext_ReferringEClass
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] by Moderator Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03925 seconds