Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] UML2 Profiles support
[ATL] UML2 Profiles support [message #28138] Tue, 03 April 2007 12:42 Go to next message
Eclipse UserFriend
Originally posted by: benois.argia-engineering.fr

Hi All,

I read newsgroup archives, the work of Christophe Le Camus and Dennis
Wagelaar about UML2 Profiles. But it seems ATL doesn't support completely
UML2 Profiles. I want to write a simple transformation in order to
extract stereotyped class and populate another DSL model. Can you help me
to start please ?

I copy my code here :

-- @atlcompiler atl2006
module UML22DSL;
create OUT : DSL from IN : UML2;

helper context UML2!uml::Element def: hasStereotype(name : String) :
Boolean =
--true;
self.getAppliedStereotypes()->exists(e | e.name = name);
--self.getAppliedStereotype(name)->oclIsKindOf(UML2!Stereotype);

rule UML2Stereotype1ToConcept1 {
from
s : UML2!uml::Class (s.hasStereotype('Stereotype1'))
to
t : DSL!Concept1 (
name <- s.name
)
do{
('RULE:UML2Stereotype1ToConcept1> Stereotype1 applied').println();
let st : String = '' in ('RULE:UML2Stereotype1ToConcept1> s.name=<' +
s.name + '>').println();
}
}

My transfo failed on :

****** BEGIN Stack Trace
message: ERROR: could not find operation getAppliedStereotypes on
UML2!Class having supertypes: [UML2!BehavioredClassifier,
UML2!EncapsulatedClassifier, OclType, OclAny] (including Java operations)
A.main() : ??#22 null
local variables = {self=UML22DSL : ASMModule} local stack = []

Regards,
Jérôme.
Re: [ATL] UML2 Profiles support [message #29254 is a reply to message #28138] Wed, 04 April 2007 14:38 Go to previous messageGo to next message
Bert Vanhooff is currently offline Bert VanhooffFriend
Messages: 6
Registered: July 2009
Junior Member
Hi Jérome,

The getAppliedStereotypes() is no standard operation I believe. You
need to define it as a helper yourself.

This one works:
helper context UML!Class def: appliedStereotypes :
Sequence(UML!Stereotype) =
self.eAnnotations->select(e |
e.source = 'appliedStereotypes'
)->collect(e |
e.contents
)->flatten()->collect(e |
e.oclType().eAnnotations->select(e | e.source =
'stereotype')->first().references
)->flatten();


Hope this helps,
Bert.

Jérôme BENOIS wrote:
> Hi All,
>
> I read newsgroup archives, the work of Christophe Le Camus and Dennis
> Wagelaar about UML2 Profiles. But it seems ATL doesn't support completely
> UML2 Profiles. I want to write a simple transformation in order to
> extract stereotyped class and populate another DSL model. Can you help me
> to start please ?
>
> I copy my code here :
>
> -- @atlcompiler atl2006
> module UML22DSL;
> create OUT : DSL from IN : UML2;
>
> helper context UML2!uml::Element def: hasStereotype(name : String) :
> Boolean =
> --true;
> self.getAppliedStereotypes()->exists(e | e.name = name);
> --self.getAppliedStereotype(name)->oclIsKindOf(UML2!Stereotype);
>
> rule UML2Stereotype1ToConcept1 {
> from
> s : UML2!uml::Class (s.hasStereotype('Stereotype1'))
> to
> t : DSL!Concept1 (
> name <- s.name
> )
> do{
> ('RULE:UML2Stereotype1ToConcept1> Stereotype1 applied').println();
> let st : String = '' in ('RULE:UML2Stereotype1ToConcept1> s.name=<' +
> s.name + '>').println();
> }
> }
>
> My transfo failed on :
>
> ****** BEGIN Stack Trace
> message: ERROR: could not find operation getAppliedStereotypes on
> UML2!Class having supertypes: [UML2!BehavioredClassifier,
> UML2!EncapsulatedClassifier, OclType, OclAny] (including Java operations)
> A.main() : ??#22 null
> local variables = {self=UML22DSL : ASMModule} local stack = []
>
> Regards,
> Jérôme.
Re: [ATL] UML2 Profiles support [message #29330 is a reply to message #28138] Wed, 04 April 2007 15:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lw_mailme_00.yahoo.com

Jérôme,

which version of the UML2 plugins are you using? This definitely works
with UML2 2.0.3; I don't know about UML2 1.x.x.
Your helper could also be defined as

not s.getAppliedStereotype(name).oclIsUndefined()

In this case the name must have the form <profile name>::<stereotype
name>, for example, 'myProfile::myStereotype'

- Lutz

Jérôme BENOIS wrote, on 4/3/2007 8:42 AM:
> Hi All,
>
> I read newsgroup archives, the work of Christophe Le Camus and Dennis
> Wagelaar about UML2 Profiles. But it seems ATL doesn't support completely
> UML2 Profiles. I want to write a simple transformation in order to
> extract stereotyped class and populate another DSL model. Can you help me
> to start please ?
>
> I copy my code here :
>
> -- @atlcompiler atl2006
> module UML22DSL;
> create OUT : DSL from IN : UML2;
>
> helper context UML2!uml::Element def: hasStereotype(name : String) :
> Boolean =
> --true;
> self.getAppliedStereotypes()->exists(e | e.name = name);
> --self.getAppliedStereotype(name)->oclIsKindOf(UML2!Stereotype);
>
> rule UML2Stereotype1ToConcept1 {
> from
> s : UML2!uml::Class (s.hasStereotype('Stereotype1'))
> to
> t : DSL!Concept1 (
> name <- s.name
> )
> do{
> ('RULE:UML2Stereotype1ToConcept1> Stereotype1 applied').println();
> let st : String = '' in ('RULE:UML2Stereotype1ToConcept1> s.name=<' +
> s.name + '>').println();
> }
> }
>
> My transfo failed on :
>
> ****** BEGIN Stack Trace
> message: ERROR: could not find operation getAppliedStereotypes on
> UML2!Class having supertypes: [UML2!BehavioredClassifier,
> UML2!EncapsulatedClassifier, OclType, OclAny] (including Java operations)
> A.main() : ??#22 null
> local variables = {self=UML22DSL : ASMModule} local stack = []
>
> Regards,
> Jérôme.
Re: [ATL] UML2 Profiles support [message #29575 is a reply to message #29330] Wed, 04 April 2007 19:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: benois.argia-engineering.fr

Hi Lutz,

I use UML2 2.0.3 with eclipse 3.2.1. Ans when your method, i obtain a
same error : message: ERROR: could not find operation
getAppliedStereotype on UML2!Class ...

Jérôme.

Le Wed, 04 Apr 2007 11:10:56 -0400, Lutz Wrage a écrit :

> Jérôme,
>
> which version of the UML2 plugins are you using? This definitely works
> with UML2 2.0.3; I don't know about UML2 1.x.x.
> Your helper could also be defined as
>
> not s.getAppliedStereotype(name).oclIsUndefined()
>
> In this case the name must have the form <profile name>::<stereotype
> name>, for example, 'myProfile::myStereotype'
>
> - Lutz
>
Re: [ATL] UML2 Profiles support [message #29598 is a reply to message #29254] Wed, 04 April 2007 19:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: benois.argia-engineering.fr

Hi Bert,

Thanks for your help. But when i test your code, another error occured :

****** BEGIN Stack Trace
message: feature eAnnotations does not exist on UML2!Class

Cheers,
Jérôme.
Re: [ATL] UML2 Profiles support [message #30029 is a reply to message #29330] Thu, 05 April 2007 08:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: touzitou.enstimac.fr

Hi Jerome,

i confirm that it works with UML2 2.0.3. Profiles Work well and nice.
it confirms that now ATl and UML2 can work together using profiles.
to use stereotype please use that form <profile name>::<stereotype
> name>.

Jihed.




Lutz Wrage a écrit :
> Jérôme,
>
> which version of the UML2 plugins are you using? This definitely works
> with UML2 2.0.3; I don't know about UML2 1.x.x.
> Your helper could also be defined as
>
> not s.getAppliedStereotype(name).oclIsUndefined()
>
> In this case the name must have the form <profile name>::<stereotype
> name>, for example, 'myProfile::myStereotype'
>
> - Lutz
>
> Jérôme BENOIS wrote, on 4/3/2007 8:42 AM:
>> Hi All,
>>
>> I read newsgroup archives, the work of Christophe Le Camus and Dennis
>> Wagelaar about UML2 Profiles. But it seems ATL doesn't support completely
>> UML2 Profiles. I want to write a simple transformation in order to
>> extract stereotyped class and populate another DSL model. Can you
>> help me
>> to start please ?
>>
>> I copy my code here :
>>
>> -- @atlcompiler atl2006
>> module UML22DSL;
>> create OUT : DSL from IN : UML2;
>>
>> helper context UML2!uml::Element def: hasStereotype(name : String) :
>> Boolean =
>> --true;
>> self.getAppliedStereotypes()->exists(e | e.name = name);
>> --self.getAppliedStereotype(name)->oclIsKindOf(UML2!Stereotype);
>>
>> rule UML2Stereotype1ToConcept1 {
>> from
>> s : UML2!uml::Class (s.hasStereotype('Stereotype1'))
>> to
>> t : DSL!Concept1 (
>> name <- s.name
>> )
>> do{
>> ('RULE:UML2Stereotype1ToConcept1> Stereotype1 applied').println();
>> let st : String = '' in ('RULE:UML2Stereotype1ToConcept1>
>> s.name=<' +
>> s.name + '>').println();
>> }
>> }
>>
>> My transfo failed on :
>>
>> ****** BEGIN Stack Trace
>> message: ERROR: could not find operation getAppliedStereotypes on
>> UML2!Class having supertypes: [UML2!BehavioredClassifier,
>> UML2!EncapsulatedClassifier, OclType, OclAny] (including Java operations)
>> A.main() : ??#22 null
>> local variables = {self=UML22DSL : ASMModule} local stack = []
>>
>> Regards,
>> Jérôme.
Re: [ATL] UML2 Profiles support [message #30106 is a reply to message #30029] Thu, 05 April 2007 17:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: benois.argia-engineering.fr

Hi All,

First thanks for your help.

I confirm usage of UML2 2.0.3 and eclipse 3.2.1. I apply your tips, but i
don't understand why ATL doesn't work with my config.

My Simple Rule :

-- @atlcompiler atl2006
-- UML To DSL UseCase
module UML2DSL;
create OUT : DSL from IN : UML, PRO : UML;

rule UML2Stereotype1ToConcept1 {
from
UML!uml::Class (not
s.getAppliedStereotype('MyProfile::MyStereotype').oclIsUndef ined())
to
t : DSL!Concept1 (name <- s.name)
}

You can download my sample project here
: http://sharengo.org/pragmatic/UML2DSLUseCase.tar.gz

This archive contains :

UML2DSLUseCase/
|-- launch
| `-- Start-UML2ToDSL.launch : a launcher configuration
|
|-- metamodels
| `-- Ecore.ecore
| `-- UML.ecore UML2 2.0.3 metamodel
| `-- dsl.ecore My simple DSL
| `-- dsl.km3 My simple DSL in km3 |-- models
| `-- MyModel.uml An example of UML model produce by Topcased
| `-- MyModel.umldi
|
|-- profiles
| `-- MyProfile.uml An example of UML Profile produce by Topcased
| `-- MyProfile.umldi
|
`-- transformations
`-- UML2DSL.asm
`-- UML2DSL.atl My simple ATL transformation


Can you help me please ?

Regards,
Jérôme.
Re: [ATL] UML2 Profiles support [message #30142 is a reply to message #30106] Thu, 05 April 2007 20:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: lw_mailme_00.yahoo.com

Jérôme BENOIS wrote, on 4/5/2007 1:37 PM:
> Hi All,
>
> First thanks for your help.
>
> I confirm usage of UML2 2.0.3 and eclipse 3.2.1. I apply your tips, but i
> don't understand why ATL doesn't work with my config.
>
> My Simple Rule :
>
> -- @atlcompiler atl2006
> -- UML To DSL UseCase
> module UML2DSL;
> create OUT : DSL from IN : UML, PRO : UML;
>
> rule UML2Stereotype1ToConcept1 {
> from
> UML!uml::Class (not
> s.getAppliedStereotype('MyProfile::MyStereotype').oclIsUndef ined())
> to
> t : DSL!Concept1 (name <- s.name)
> }
>
> You can download my sample project here
> : http://sharengo.org/pragmatic/UML2DSLUseCase.tar.gz
>
> This archive contains :
>
> UML2DSLUseCase/
> |-- launch
> | `-- Start-UML2ToDSL.launch : a launcher configuration
> |
> |-- metamodels
> | `-- Ecore.ecore
> | `-- UML.ecore UML2 2.0.3 metamodel
> | `-- dsl.ecore My simple DSL
> | `-- dsl.km3 My simple DSL in km3 |-- models
> | `-- MyModel.uml An example of UML model produce by Topcased
> | `-- MyModel.umldi
> |
> |-- profiles
> | `-- MyProfile.uml An example of UML Profile produce by Topcased
> | `-- MyProfile.umldi
> |
> `-- transformations
> `-- UML2DSL.asm
> `-- UML2DSL.atl My simple ATL transformation
>
>
> Can you help me please ?
>
> Regards,
> Jérôme.

The problem is in your launch configuration. You load the UML metamodel
from an ecore file. In that case you dont' have access to
getAppliedStereotypes because it's a method implemented in Java. If you
select the metamodel by URI ATL will use the generated classes from the
UML plugin as the metamodel, such that you can call Java methods.

- Lutz
Re: [ATL] UML2 Profiles support [message #30177 is a reply to message #30142] Fri, 06 April 2007 08:25 Go to previous message
Eclipse UserFriend
Originally posted by: benois.argia-engineering.fr

Hi Lutz,

Thanks ! it's works great now, and i begin to understand the power of ATL :-)

Cheers,
Jérôme.
Previous Topic:resolveTemp howto
Next Topic:[ATL]Package with uri 'BPMN' not found....
Goto Forum:
  


Current Time: Fri Apr 19 21:52:09 GMT 2024

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

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

Back to the top