[EMFTVM] Accessin output elements' attributes [message #1219523] |
Wed, 04 December 2013 12:01 |
Javier García 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 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.01944 seconds