Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Using UML profile as metamodel
Using UML profile as metamodel [message #1027965] Wed, 27 March 2013 16:51 Go to next message
Dave Carlson is currently offline Dave Carlson
Messages: 399
Registered: July 2009
Senior Member
I am new to ATL and attempting to write some transformation of UML to UML, where different profiles are applied to the input and output models, and the models are restructured. My UML profiles are generated as Ecore static profiles, and they do show in the list of available ATL metamodels.

The problem I have is always getting OclUndefined when attempting to access toe base_* attributes of the stereotype instance. I have seen other forum posts where this worked. Are the other posters using only dynamic UML profiles (as annotations within UML profile model)?

I have been working in eclipse 3.7.2, but just tried 4.3M6 with the same problem.

My ATL source looks something like the fragment below, where StereotypeA is applied to a UML Enumeration. I get a runtime error that base_Enumeration is undefined. However, if I use a modified rule where MyProfile!StereotypeA is replaced with UML!Enumeration, then the rule (with modified output) works fine.

I really like the idea of writing ATL transformations using static UML profiles, which allows me to ass additional methods onto the stereotypes to be implemented in the generated Ecore, and used by ATL. Any help is appreciated!

module TestProfiles;
create OUT : UML from IN : MyProfile;

rule ResolvedValueSet {
from
s : MyProfile!StereotypeA
to
t : UML!Enumeration (
name <- s.debug('stereotype A: ').base_Enumeration.debug('baseEnum: ').name
)
}
Re: Using UML profile as metamodel [message #1027972 is a reply to message #1027965] Wed, 27 March 2013 17:03 Go to previous messageGo to next message
Federico Toledo is currently offline Federico Toledo
Messages: 97
Registered: April 2012
Location: Ciudad Real, Spain
Member
Hi,

I'll tell you the way I use it, I'm not an expert, but it works for me


rule myRule{
from myElement: UML!Class in IN (
myElement.hasStereotype('myStereotype')
)
to
target : UML!Class(
name <- 'name'
)
do{
target.applyStereotype(thisModule.getStereotype('targetStereotype'));
}
}


using these helpers:



helper context UML!Element def: hasStereotype(stereotype : String) : Boolean =
self.getAppliedStereotypes()->exists(e|e.name=stereotype);

helper def : getStereotype(name : String) : UML!Stereotype =
UML!Stereotype.allInstances()->any(p | p.name = name);

helper def: getProfile(name: String): UML!Profile =
UML!Profile.allInstances()->any(p | p.name = name);



Hope it helps!
Re: Using UML profile as metamodel [message #1032588 is a reply to message #1027972] Wed, 03 April 2013 07:25 Go to previous messageGo to next message
sams good is currently offline sams good
Messages: 11
Registered: March 2013
Junior Member
thank you frederico
Re: Using UML profile as metamodel [message #1035832 is a reply to message #1027965] Sun, 07 April 2013 13:55 Go to previous message
Dennis Wagelaar is currently offline Dennis Wagelaar
Messages: 166
Registered: September 2012
Senior Member

Op 27-03-13 17:51, Dave Carlson schreef:
> I am new to ATL and attempting to write some transformation of UML to UML,
> where different profiles are applied to the input and output models, and the
> models are restructured. My UML profiles are generated as Ecore static
> profiles, and they do show in the list of available ATL metamodels.
>
> The problem I have is always getting OclUndefined when attempting to access
> toe base_* attributes of the stereotype instance. I have seen other forum
> posts where this worked. Are the other posters using only dynamic UML
> profiles (as annotations within UML profile model)?

I'm not familiar with Ecore static profiles, just the regular (dynamic?) UML
profiles with embedded parts of Ecore in there.

If you can already manage to trigger ATL rules on your stereotype
applications, you've covered the problem of providing ATL with the right
metaclasses for your stereotypes. All I can say from here is that the ATL code
does not do anything special with the "base_*" references: they are treated
the same as other references. Also, getting OclUndefined as a value means that
ATL did find the actual reference, but it wasn't set for some reason.

> My ATL source looks something like the fragment below, where StereotypeA is
> applied to a UML Enumeration. I get a runtime error that base_Enumeration is
> undefined. However, if I use a modified rule where MyProfile!StereotypeA is
> replaced with UML!Enumeration, then the rule (with modified output) works fine.

Please also show us the modified rule.

> I really like the idea of writing ATL transformations using static UML
> profiles, which allows me to ass additional methods onto the stereotypes to be
> implemented in the generated Ecore, and used by ATL. Any help is appreciated!

This is indeed a nice idea, and would tackle one of the major drawbacks of UML
profiles vs. Ecore metamodel extensions!

Dennis

> module TestProfiles;
> create OUT : UML from IN : MyProfile;
>
> rule ResolvedValueSet {
> from
> s : MyProfile!StereotypeA
> to
> t : UML!Enumeration (
> name <- s.debug('stereotype A:
> ').base_Enumeration.debug('baseEnum: ').name
> )
> }
>


Cheers,
Dennis
Previous Topic:Order of Transformation
Next Topic:HOW CAI I DO
Goto Forum:
  


Current Time: Thu Oct 23 14:45:20 GMT 2014

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

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