[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2m] Re: [ATL] UML stereotype problem

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.