Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » [EMFTVM] Accessin output elements' attributes
[EMFTVM] Accessin output elements' attributes [message #1219523] Wed, 04 December 2013 12:01 Go to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Hi all,
I've been using EMFTVM for a while and I was under the impression that you couldn't access output elements in any way, but I tried something and it works, let me share an example:

endpoint rule ApplyAllStereotypes() {
	do {
--- Create dependencies for subjects->datamodels:
		for (elem in Sequence{thisModule.componentsMap.get(thisModule.subjectStereotype)}.flatten()->reject(e|e.oclIsUndefined())){
			elem.getOwner().packagedElement<-elem.getOwner()->debug('ELEMENTSUBJECTSTEREOTYPE').allOwnedElements()->reject(e|e.getOwner()<>elem.getOwner())
			.union(thisModule.componentsMap.get(thisModule.dataModelStereotype)->select(e|e.oclIsTypeOf(UML2!Component))->asSet()->collect(e|thisModule.createDependency(elem,e))->debug('dependencies')->asSequence()).flatten();
		}
}


This code is inside of an endpoint rule as you can see, and componentsMap contains a series of output elements created from lazyrules.
So as you can see I have elem, which is always an element from the output model, and if I try to do something like
elem.owner.allOwnedElements()
then I would get an error, same if I wrote packagedElement instead of allOwnedElements, the exception claimed that I couldn't check the data as it was in an output element.
So then I decided to check if I could use elem.getOwner() and it actually worked, same with other "helpers" such as getName(), etc. Note that all those helpers are not defined by me, they come predefined.

So my question is: is this working as intended? is this a feature or a bug? is it ok to use it to access output elements?
I thought I wasn't supposed to be able to access information from the output model so that's why I'm a bit confused.

Thanks in advance,
regards,
Javier
Re: [EMFTVM] Accessin output elements' attributes [message #1219564 is a reply to message #1219523] Wed, 04 December 2013 16:34 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

This is intended behaviour: EMFTVM does not prevent you from invoking operations on output elements. You need this to apply stereotypes, for example. Note that you can bypass the entire restriction if you use reflection to access properties; you do so at your own risk, of course.

Cheers,
Dennis
Re: [EMFTVM] Accessin output elements' attributes [message #1219648 is a reply to message #1219564] Thu, 05 December 2013 08:14 Go to previous message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Ok that's awesome then and it really makes things easier, thanks Dennis!
Previous Topic:Generated model with wrong xmi tags
Next Topic:Invitation to Engage in a Study
Goto Forum:
  


Current Time: Fri Apr 19 11:11:30 GMT 2024

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

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

Back to the top