Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] UML stereotype problem
[ATL] UML stereotype problem [message #83132] Sat, 31 May 2008 09:54 Go to next message
Eclipse UserFriend
Originally posted by: hr_mi.live.cn

Hi everyone,
I make a helper to check the stereotype of a class ,the code is as
following :
--------------------------------------------------------
helper context UML!Class def: hasStereotype(stereotype : String) : Boolean =
self.getAppliedStereotypes()->exists(e|e.name=stereotype);

-------------------------------------------------------



My code is like this :

--------------------------
module uml2bpel; -- Module Template
create OUT : BPEL from IN : UML;

rule toProcess{
from
u : UML!"uml::Activity",c : UML!"uml::Class"
(u.oclIsTypeOf(UML!"uml::Activity") and
c.oclIsTypeOf(UML!"uml::Class") and c.name='onlinesale' and
c.hasStereotype('Process')
)
to
p : BPEL!Process(......
)
}

-------------------------------------

I select the UML metamodel by URI:http://www.eclipse.org/uml2/2.0.0/UML
but it dosen't work correctly.

Anyone can help me ??

Thanks very much.
Best for wishes!
Re: [ATL] UML stereotype problem [message #83147 is a reply to message #83132] Sat, 31 May 2008 10:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: me.urszeidler.de

unique schrieb:
> Hi everyone,
> I make a helper to check the stereotype of a class ,the code is as
> following :
> --------------------------------------------------------
> helper context UML!Class def: hasStereotype(stereotype : String) : Boolean =
> self.getAppliedStereotypes()->exists(e|e.name=stereotype);
>
> -------------------------------------------------------
>
Looks ok, but "UML!Class" means this context works only for UML!Class,
you want element.("UML!Element")
Because in the matching phase your guard "c.hasStereotype('Process')"
will be testes with all elements and not all of them are "UML!Class".
If you stick to your helper your guard should be :
"
(
if u.oclIsTypeOf(UML!"uml::Activity") and
c.oclIsTypeOf(UML!"uml::Class") then c.name='onlinesale' and
c.hasStereotype('Process')
else
false
endif
> )
"
>
>
> My code is like this :
>
> --------------------------
> module uml2bpel; -- Module Template
> create OUT : BPEL from IN : UML;
>
> rule toProcess{
> from
> u : UML!"uml::Activity",c : UML!"uml::Class"
> (u.oclIsTypeOf(UML!"uml::Activity") and
> c.oclIsTypeOf(UML!"uml::Class") and c.name='onlinesale' and
> c.hasStereotype('Process')
> )
> to
> p : BPEL!Process(......
> )
> }
>
> -------------------------------------
>
> I select the UML metamodel by URI:http://www.eclipse.org/uml2/2.0.0/UML
> but it dosen't work correctly.
>
> Anyone can help me ??
>
> Thanks very much.
> Best for wishes!
Re: [ATL] UML stereotype problem [message #83179 is a reply to message #83147] Sat, 31 May 2008 11:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hr_mi.live.cn

urs zeidler 写道:
> unique schrieb:
>> Hi everyone,
>> I make a helper to check the stereotype of a class ,the code is as
>> following :
>> --------------------------------------------------------
>> helper context UML!Class def: hasStereotype(stereotype : String) : Boolean =
>> self.getAppliedStereotypes()->exists(e|e.name=stereotype);
>>
>> -------------------------------------------------------
>>
> Looks ok, but "UML!Class" means this context works only for UML!Class,
> you want element.("UML!Element")
> Because in the matching phase your guard "c.hasStereotype('Process')"
> will be testes with all elements and not all of them are "UML!Class".
> If you stick to your helper your guard should be :
> "
> (
> if u.oclIsTypeOf(UML!"uml::Activity") and
> c.oclIsTypeOf(UML!"uml::Class") then c.name='onlinesale' and
> c.hasStereotype('Process')
> else
> false
> endif
>> )
> "
>>
>> My code is like this :
>>
>> --------------------------
>> module uml2bpel; -- Module Template
>> create OUT : BPEL from IN : UML;
>>
>> rule toProcess{
>> from
>> u : UML!"uml::Activity",c : UML!"uml::Class"
>> (u.oclIsTypeOf(UML!"uml::Activity") and
>> c.oclIsTypeOf(UML!"uml::Class") and c.name='onlinesale' and
>> c.hasStereotype('Process')
>> )
>> to
>> p : BPEL!Process(......
>> )
>> }
>>
>> -------------------------------------
>>
>> I select the UML metamodel by URI:http://www.eclipse.org/uml2/2.0.0/UML
>> but it dosen't work correctly.
>>
>> Anyone can help me ??
>>
>> Thanks very much.
>> Best for wishes!

Hi urs zeidler,
Thanks for your help.
I acted as you advise, but it didn't work correctly. I mean that I
have a class named "onlinesale" and it has a stereotype named "Process"
in fact, but when I run my code , it didn't test it successfully .

what would the problem be ?

Thanks !
Re: [ATL] UML stereotype problem [message #83192 is a reply to message #83179] Sat, 31 May 2008 12:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: me.urszeidler.de

unique schrieb:
> urs zeidler 写道:
>> unique schrieb:
>>> Hi everyone,
>>> I make a helper to check the stereotype of a class ,the code is as
>>> following :
>>> --------------------------------------------------------
>>> helper context UML!Class def: hasStereotype(stereotype : String) : Boolean =
>>> self.getAppliedStereotypes()->exists(e|e.name=stereotype);
>>>
>>> -------------------------------------------------------
>>>
>> Looks ok, but "UML!Class" means this context works only for UML!Class,
>> you want element.("UML!Element")
>> Because in the matching phase your guard "c.hasStereotype('Process')"
>> will be testes with all elements and not all of them are "UML!Class".
>> If you stick to your helper your guard should be :
>> "
>> (
>> if u.oclIsTypeOf(UML!"uml::Activity") and
>> c.oclIsTypeOf(UML!"uml::Class") then c.name='onlinesale' and
>> c.hasStereotype('Process')
>> else
>> false
>> endif
>>> )
>> "
>>> My code is like this :
>>>
>>> --------------------------
>>> module uml2bpel; -- Module Template
>>> create OUT : BPEL from IN : UML;
>>>
>>> rule toProcess{
>>> from
>>> u : UML!"uml::Activity",c : UML!"uml::Class"
>>> (u.oclIsTypeOf(UML!"uml::Activity") and
>>> c.oclIsTypeOf(UML!"uml::Class") and c.name='onlinesale' and
>>> c.hasStereotype('Process')
>>> )
>>> to
>>> p : BPEL!Process(......
>>> )
>>> }
>>>
>>> -------------------------------------
>>>
>>> I select the UML metamodel by URI:http://www.eclipse.org/uml2/2.0.0/UML
>>> but it dosen't work correctly.
>>>
>>> Anyone can help me ??
>>>
>>> Thanks very much.
>>> Best for wishes!
>
> Hi urs zeidler,
> Thanks for your help.
> I acted as you advise, but it didn't work correctly. I mean that I
> have a class named "onlinesale" and it has a stereotype named "Process"
> in fact, but when I run my code , it didn't test it successfully .
>
> what would the problem be ?
>
> Thanks !
try this helper

helper def : isStereotypeApplied (invar : UML2!"uml::Element", name
:String) : Boolean =
if invar.oclIsUndefined() then
false
else
not invar.getAppliedStereotypes() -> select(s| s.name=name)-> isEmpty()
endif
;

greetings,urs.
Re: [ATL] UML stereotype problem [message #83203 is a reply to message #83192] Sat, 31 May 2008 13:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: amehmood.sophia.inria.fr

Hi,

this simple helper also works well:

-- Checks if the given stereotype is applied or not.
helper context UML2!Element def : isStereotypeApplied(name :
String):Boolean =

not self.getAppliedStereotypes()->select(p | p.name = name).isEmpty();


and call it like this:

rule ABC{
from
s : UML2!Element (s.isStereotypeApplied('MyStereotype'))
Re: [ATL] UML stereotype problem [message #83210 is a reply to message #83203] Sun, 01 June 2008 03:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hr_mi.live.cn

Aamir Mehmood 写道:
> Hi,
>
> this simple helper also works well:
>
> -- Checks if the given stereotype is applied or not.
> helper context UML2!Element def : isStereotypeApplied(name :
> String):Boolean =
>
> not self.getAppliedStereotypes()->select(p | p.name = name).isEmpty();
>
>
> and call it like this:
>
> rule ABC{
> from
> s : UML2!Element (s.isStereotypeApplied('MyStereotype'))

Hi Aamir Mehmood,

Thanks for your help .I acted as you advised , I rewrite the code as
following :

helper context UML!Class def : isStereotypeApplied(name :
String):Boolean =
not self.getAppliedStereotypes()->select(p | p.name = name).isEmpty();

----------------------
rule toProcess{
from
u : UML!"uml::Activity", c :
UML!"uml::Class"(u.oclIsTypeOf(UML!"uml::Activity") and
if c.oclIsTypeOf(UML!"uml::Class") and c.name='onlinesale'
then c.isStereotypeApplied('BPEL::Process')
else false
endif
)
to
p :BPEL!"model::Process"(...)



but when I debug it ,the result is empty .It didn't test the class named
"onlinesale" having stereotype "Process".
What's the problem??

best regards!
Re: [ATL] UML stereotype problem [message #83233 is a reply to message #83192] Sun, 01 June 2008 03:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hr_mi.live.cn

This is a multi-part message in MIME format.
--------------060808040303000502020308
Content-Type: text/plain; charset=GB2312
Content-Transfer-Encoding: 8bit

urs zeidler д
Re: [ATL] UML stereotype problem [message #83261 is a reply to message #83233] Sun, 01 June 2008 10:29 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: me.urszeidler.de

> rule toProcess{
> from
> u : UML!"uml::Activity", c :
> UML!"uml::Class"(u.oclIsTypeOf(UML!"uml::Activity") and
> if c.oclIsTypeOf(UML!"uml::Class") and c.name='onlinesale'
> then c.isStereotypeApplied(c,'Process')
> else false
> endif
> )
> to
> p :BPEL!"model::Process"(...)
>
> I annex my *.atl file , the meta-models and models ,would you please
> check it ??

This helper has no context, so you need to call it with
thisModule.isStereotypeApplied(c,'Process').

greetings, urs.
Re: [ATL] UML stereotype problem [message #83427 is a reply to message #83261] Mon, 02 June 2008 12:08 Go to previous message
Eclipse UserFriend
Originally posted by: hr_mi.live.cn

urs zeidler 写道:
>> rule toProcess{
>> from
>> u : UML!"uml::Activity", c :
>> UML!"uml::Class"(u.oclIsTypeOf(UML!"uml::Activity") and
>> if c.oclIsTypeOf(UML!"uml::Class") and c.name='onlinesale'
>> then c.isStereotypeApplied(c,'Process')
>> else false
>> endif
>> )
>> to
>> p :BPEL!"model::Process"(...)
>>
>> I annex my *.atl file , the meta-models and models ,would you please
>> check it ??
>
> This helper has no context, so you need to call it with
> thisModule.isStereotypeApplied(c,'Process').
>
> greetings, urs.
>

Hi urs ,

I really thank you for you help . I acted it , but it didn't test the
calss what I wanted to get. Actually there is a class named 'onlinesale'
having stereotype named "Process",but the result is empty , I cannot
find where the problem is .

Best regards!
Previous Topic:Problem with Inter-model reference
Next Topic:ATL rule transform: output model format
Goto Forum:
  


Current Time: Fri Apr 19 04:30:50 GMT 2024

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

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

Back to the top