Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » About temporary/on-the-fly (~) model attributes
About temporary/on-the-fly (~) model attributes [message #1735329] Fri, 17 June 2016 12:04 Go to next message
Bugra M. Yildiz is currently offline Bugra M. YildizFriend
Messages: 106
Registered: July 2014
Senior Member
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 #1735330 is a reply to message #1735329] Fri, 17 June 2016 12:05 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1595
Registered: July 2009
Location: York, UK
Senior Member

Hi Bugra,

A minimal example would help a lot with investigating this.

Cheers,
Dimitris
Re: About temporary/on-the-fly (~) model attributes [message #1735342 is a reply to message #1735330] Fri, 17 June 2016 13:17 Go to previous messageGo to next message
Bugra M. Yildiz is currently offline Bugra M. YildizFriend
Messages: 106
Registered: July 2014
Senior Member
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]

Report message to a moderator

Re: About temporary/on-the-fly (~) model attributes [message #1736224 is a reply to message #1735342] Mon, 27 June 2016 15:17 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1595
Registered: July 2009
Location: York, UK
Senior Member

Hi Bugra,

I'm not sure I follow I'm afraid. A minimal example would certainly help clear things up.

Cheers,
Dimitris
Previous Topic:EGL: How to generate the system date/time
Next Topic:EGL: How to send a sequence as a parameter to a template
Goto Forum:
  


Current Time: Thu Oct 18 15:50:36 GMT 2018

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

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

Back to the top