Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » Problems with appling Stereotypes to UML2 elements #1905 at yahooList
Problems with appling Stereotypes to UML2 elements #1905 at yahooList [message #11938] Sun, 21 January 2007 10:31 Go to next message
Eclipse UserFriend
Hello everybody,
I am a Newbie to ATL and I have a big problem on UML2 transformations
with the UML2 metamodel 1.1.0 from the uml2 subproject on eclipse,
which my knowledge is getting on my borders and I don
I want to advice a standard stereotype like "entity" to the output
model. I read the discussion about that topic found in the ATL
Troubleshooter
http://wiki.eclipse.org/index.php/ATL_Language_Troubleshoote r
and
http://tech.groups.yahoo.com/group/atl_discussion/message/12 02?l=1

So I tried the same way with a standard stereotype but it doesnt work.

I drawed my input model with MagicDraw 11.5 and export it to an *.uml2
file. In this process MagicDraw also creates two additional files
- UML_Standard_Profile.MagicDraw_Profile.profile.uml2
and
- UML_Standard_Profile.UML_Standard_Profile.profile.uml2

I found out, that there are no stereotypes in the UML2 metamodel, but
in the UML_Standard_Profile.UML_Standard_Profile.profile.uml2 file
they can be found, so I tried to apply it from THIS file by including
it as an Input Model. It works so far that I can see the different
stereotypes with the help of the debug command in the console but I
cant apply them to a model element. So my big question is now: "Why I
cant apply them to model elements???" and in addition which is more
important for my progress "How I can apply them to model elements???"
I print my ATL file and the Console output below to reconstruct my
problem:
ATL-File:
module testNew2testNew; -- Module Template
create OUT : UML2 from IN : UML2, PRO : PROFILE;

rule C2C {
from
s : UML2!Class (s.name = 'TestKL1')

to
t : UML2!Class (
name <- s.name,
ownedAttribute <- s.ownedAttribute
)
do {

for(p in UML2!Stereotype.allInstances()) {
self.debug(p.toString());
}

for(q in PROFILE!Stereotype.allInstances()) {
self.debug(q.toString());
}

t.apply(PROFILE!Stereotype.allInstances()
->select(e | e.name = 'entity').first());
}
}

Corresponding Output (only relevant parts):

PRO!delegate: testNew2testNew : ASMModule
..
..
..
PRO!entity: testNew2testNew : ASMModule
PRO!delegate: testNew2testNew : ASMModule
PRO!file: testNew2testNew : ASMModule
..
..
..
PRO!buildComponent: testNew2testNew : ASMModule
PRO!entity: testNew2testNew : ASMModule
****** BEGIN Stack Trace
message: ERROR: exception during invocation of operation apply on
UML2!Class (java method: public void
org.eclipse.uml2.impl.ElementImpl.apply(org.eclipse.uml2.Ste reotype))
exception:
java.lang.IllegalArgumentException:
org.eclipse.uml2.impl.StereotypeImpl@b07663 (name: entity, visibility:
public) (isLeaf: false) (isActive: false)
at
org.eclipse.uml2.internal.operation.StereotypeOperations.app ly(StereotypeOperati\
ons.java:284)
at org.eclipse.uml2.impl.ElementImpl.apply(ElementImpl.java:374 )
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.atl.engine.repositories.emf4atl.ASMEMFModelElement.invok e(ASMEMFModelElement\
java:501)
at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:21 4)
at org.atl.engine.vm.ASMOperation.exec(ASMOperation.java:155)
at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 60)
at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 50)
at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:21 4)
at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:30 9)
at org.atl.engine.vm.ASMOperation.exec(ASMOperation.java:155)
at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 60)
at org.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java: 50)
at org.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:21 4)
at org.atl.engine.vm.ASMOperation.exec(ASMOperation.java:155)
at org.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:276)
at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:9 8)
at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:7 0)
at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:5 3)
at org.atl.eclipse.engine.AtlLauncher.launch(AtlLauncher.java:4 9)
at
org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlL\
aunchConfigurationDelegate.java:209)
at
org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlL\
aunchConfigurationDelegate.java:154)
at
org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlL\
aunchConfigurationDelegate.java:136)
at
org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .runAtlLauncher(AtlL\
aunchConfigurationDelegate.java:117)
at
org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate .launch(AtlLaunchCon\
figurationDelegate.java:95)
at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.j\
ava:639)
at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.j\
ava:565)
at
org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:75\
4)
at
org.eclipse.debug.internal.ui.DebugUIPlugin$6.run(DebugUIPlu gin.java:944)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
..
..
..
****** END Stack Trace


The solution could be very simple but i dont see it at this time so I
would be very pleased for all help which direct me on the correect way
Best regards
Re: Problems with appling Stereotypes to UML2 elements #1905 at yahooList [message #11954 is a reply to message #11938] Sun, 21 January 2007 10:46 Go to previous messageGo to next message
Eclipse UserFriend
Message poreviously posted by Tom.

Hello Tom,

First, as you can see in wiki, applying profiles cannot be done due to UML
restriction that obliges to apply first the profile on a Package, then
apply the setereotypes.

This issue is on going and a new UML2 handler is written to solve this
problem.
Probably it will soon published.

you can check the following ATL to have an idea of what is remaining from
your transformation :
(This example comes from a contribution of another ATL user : Thanks to
him).

module ApplyProfile; -- Module Template
create OUT : UML2 from IN : UML2, PRO : UML2;


--Global varialbe to store the UML model (root)
helper def: Global_UmlModel : UML2!Model = '';

helper context UML2!Element def : hasStereotype(s : String) : Boolean =
self.getAppliedStereotype(s)->oclIsKindOf(UML2!Stereotype);

-- copies a stereotype from one element to another
helper context UML2!Element def : copyStereotype(e : UML2!Element, s :
String) : UML2!Element =
self.applyStereotype(e.getApplicableStereotype(s));

-- copies a stereotype attribute value from one element to another
-- does nothing if either element does not have the stereotype applied
helper context UML2!Element def : copyValue(e : IN!Element, s : String, n
: String) : UML2!Element =
if e.hasStereotype(s) and self.hasStereotype(s) then
self.setValue(self.getAppliedStereotype(s), n,
e.getValue(e.getAppliedStereotype(s), n))
else
self
endif;

rule M2M {
from mIn : UML2!Model
to mOut : UML2!Model (
name <- mIn.name
)
do {
--Store the Model node in a global variable
thisModule.Global_UmlModel <- mOut ;

--apply the profile to the OUT model
mOut.applyProfile(mIn.getAppliedProfile('SimpleProfile'));
}
}


rule C2C {
from s:UML2!Class(s.name <> 'myStereoType')
to t:UML2!Class (
name <- 'out_'.concat(s.name)
)
do {
-- display the current Class name created
let st : String = '' in ('RULE:C2C> s.name=<' + s.name + '>').println();

let ster1 : String = '' in ('RULE:C2C> s.stereotype defini=<' +
s.getAppliedStereotypes()->first().toString() + '>').println();
let stere : UML2!Stereotype = s.getAppliedStereotypes()->first() in
('RULE:C2C> s.stereotype hasValue =<' +
s.hasValue(stere,'alwaysTrue').toString()+ '>>>>').println();

let stere : UML2!Stereotype = s.getAppliedStereotypes()->first() in
('RULE:C2C> s.stereotype isApplicable =<' +
s.isStereotypeApplicable(stere).toString()+ '>>>>').println();

--add the class to the model
thisModule.Global_UmlModel.packagedElement <-
thisModule.Global_UmlModel.packagedElement ->including(t);
-- let u : String = '' in ('RULE:C2C=> getApplicableStereotype=<' +
s.getApplicableStereotype('ExempleProfileJPB::Singleton').ge tName() +
'>').println();
--apply the stereotype
--t.apply(UML2!Stereotype.allInstances()->select(st | st.name =
'Singleton').first());
if s.getAppliedStereotypes()->first()->oclIsKindOf(UML2!Stereotype) then

--let ster12 : String = '' in ('RULE:C2C> classe name =<' + s.name
+ '>').println()

t.applyStereotype(s.getApplicableStereotype('SimpleProfile:: myStereoType'))
else
self
endif;

--set the property value "myProperty" to the value "myValue"
if s.getAppliedStereotypes()->first()->oclIsKindOf(UML2!Stereotype) then

let typeStere : UML2!Stereotype = s.getAppliedStereotypes()->first()
in
t.setValue(typeStere, 'alwaysTrue', s.getValue(typeStere ,
'alwaysTrue'))
else
''
endif;
}
}

Once the UML2 driver will be available you can apply the
profiles/stereotypes.

Best Regards
Christophe
Re: Problems with appling Stereotypes to UML2 elements #1905 at yahooList [message #12941 is a reply to message #11954] Fri, 26 January 2007 09:30 Go to previous message
Eclipse UserFriend
Originally posted by: jean-pierre.bourey.ec-lille.fr

Hi all,

I'm trying to perform the following transformation, which works well on
(Eclipse 3.1.2., UML2 1.1.1) , on (Eclipse 3.2.1, UML2 2.0.2) by replacing
the "apply" method I used previously by "applyProfile" or "applyStereotype"

My simple input model is the following(sorry for the manual copy of the
content of the UML editor;-):
platform:/resource/First_ATL_Project/MyOutputModel.uml
|<Model>MyModel
|----|---<Class>MyClass
|----|----|----<Property>myAttribute

I try to transform it into an output model (simple copy) and to apply a
Profile named "MyProfile" which contains one stereotype ("myStereotype")
which extends the metaclass "Class"

I have written the following transformation:

-- @atlcompiler atl2006
module ApplyProfile; -- Module Template
create OUT : UML2 from IN : UML2 , PRO : UML2;

--Global varialbe to store the UML model (root)
helper def: Global_UmlModel : UML2!Model = '';

rule M2M {
from IN : UML2!Model
to OUT : UML2!Model (
name <- IN.name
)
do {
--Store the Model node in a global variable
thisModule.Global_UmlModel <- OUT ;

-- display the current input Model name
let s : String = '' in ('RULE:M2M=> IN.name=<' + IN.name + '>').println();

-- display the current Model name created
let s : String = '' in ('RULE:M2M=> OUT.name=<' + OUT.name +
'>').println();

-- display the first profile name
let s : String = '' in ('RULE:M2M=>
UML2!Profile.allInstances().asSequence().first().name=<' +
UML2!Profile.allInstances().asSequence().first().name + '>').println();

--apply the profile to the model created
OUT.applyProfile(UML2!Profile.allInstances()->select(e | e.name =
'MyProfile').asSequence().first());
}
}

rule C2C {
from s:UML2!Class (not s.oclIsKindOf(UML2!Stereotype) )
to t:UML2!Class (
name <- s.name
)
do {
-- display the current Class name created
let s : String = '' in ('RULE:C2C=> t.name=<' + t.name + '>').println();

--add the class to the model
thisModule.Global_UmlModel.packagedElement <-
thisModule.Global_UmlModel.packagedElement ->including(t);

--display and apply the stereotype "myStereotype"
let u : String = '' in ('RULE:C2C=> getApplicableStereotype=<' +
t.getApplicableStereotype('MyProfile::myStereotype').getName () +
'>').println();
t.applyStereotype(t.getApplicableStereotype('MyProfile::mySt ereotype'));
--t.applyStereotype(UML2!Stereotype.allInstances()->select(st |
st.name = 'myStereotype').first());

--display the applied stereotype
let u : String = '' in ('RULE:C2C=> getAppliedStereotypes=<' +
t.getAppliedStereotypes().first().getName() + '>').println();

--set a property value "myProperty" to the value "myValue"
--t.setValue(t.getAppliedStereotype('MyProfile::myStereotype '),
'myProperty', 'myValue');


}
}
------------------------------------------------------------ ---

On the console I've got the following trace :

------------------------------------------------------------ ---
RULE:M2M=> IN.name=<MyModel>
RULE:M2M=> OUT.name=<MyModel>
RULE:M2M=> UML2!Profile.allInstances().asSequence().first().name=<MyProfile >
RULE:C2C=> t.name=<MyClass>
RULE:C2C=> getApplicableStereotype=<OUT!myStereotype>
RULE:C2C=> getAppliedStereotypes=<OUT!myStereotype>
------------------------------------------------------------ ---

The stereotype seems to be well applied to the target element ,BUT, when I
look to the output model with the UML editor, I get something which looks
like:

platform:/resource/First_ATL_Project/MyOutputModel.uml
|--<Model>MyModel
|----|----<Class>MyClass
|----|----+<ProfileApplication> MyProfile
|----My Stereotype
|----|----base_Class='/0/MyClass'
platform:/resource/First_ATL_Project/MyProfile.profile.uml

I can apply manually the sterotype (with the menu "UML
Editor->Element->apply Stereotype...") and then I get what I expected to get
, that means :
platform:/resource/First_ATL_Project/MyOutputModel.uml
|--<Model>MyModel
|----|----<<myStereotype>><Class>MyClass
|----|----+<ProfileApplication> MyProfile
....

So, my questions are:
Does anyone encounter the same problem?
Does it come from the UML2 2.0.2 plugin (I tried also with Eclipse 3.3.0 and
UML2 2.1.0, with the same result)
Should I wait a more stable version of UML2 as Christophe mentioned it in
his post or did I miss an important (new) step in my transformation?

Many thanks in advance for any comment and answer
best regards
jean-pierre




"C. le Camus" <christophe.le-camus@c-s.fr> a
Previous Topic:[ATL] Interleave and union two collections
Next Topic:Problem when creating output objects using Called Rules
Goto Forum:
  


Current Time: Fri May 09 18:16:46 EDT 2025

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

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

Back to the top