Home » Modeling » ATL » transformation involving UML profiles
| transformation involving UML profiles [message #986551] |
Tue, 20 November 2012 17:03  |
Alessandro Ranieri Messages: 16 Registered: November 2012 |
Junior Member |
|
|
Hi to everyone,
I'm trying to make an ATL transformation from a model M1 obtained in Papyrus by applying a profile P1. My objective is to obtain another model M2 with another profile P2 applyed on.
My question is:
How can I specify in the "create" clause the metamodels (UML I suppose) and the profiles involved in the transformation?
I look at the Rational2UML example, and I don't understand how the output profiles is supplyed to ATL.
Thanks in advance for the help.
|
|
|
| Re: transformation involving UML profiles [message #986610 is a reply to message #986551] |
Wed, 21 November 2012 03:03   |
Alessandro Ranieri Messages: 16 Registered: November 2012 |
Junior Member |
|
|
I have made an example of trasformation from a simple Network model based on a profile called "lanprofile" to a simple graph model based on "graphprofile".
I coded only two rules and when I test the module I get an error.
The code is the following:
-- @nsURI UML=http://www.eclipse.org/uml2/3.0.0/UML
module lan2graph;
create OUT : UML from IN : UML, GRAPHPROF : UML;
helper def : getStereotype(name : String) : UML!Stereotype =
UML!Stereotype.allInstances()->select(p | p.name = name)->first();
helper context UML!Model def: hasStereotype(name : String) : Boolean =
not self.getAppliedStereotype(name).oclIsUndefined();
helper context UML!Class def: hasStereotype(name : String) : Boolean =
not self.getAppliedStereotype(name).oclIsUndefined();
rule init {
from
s: UML!Model
to
t: UML!Model (name <- 'graphModel')
do {
t.applyProfile(UML!Profile.allInstances()->select(p | p.name = 'graphprofile')->first());
}
}
rule class {
from
source: UML!Class( source.hasStereotype('lanprofile::Host') )
to
target: UML!Class( name<-'NodeIstance' )
do
{
target.applyStereotype(thisModule.getStereotypeGraph('node'));
target.setValue(thisModule.getStereotypeGraph('node'), 'name', source.getTagValue(thisModule.getStereotypeGraph('node'),'Name') );
}
}
The last lines of infromation execution and error ATL returns are:
getStereotypeGraph:17 enditerate
stack: Sequence {GRAPHPROF!node}
locals: self=lan2graph : ASMModule, name='node'
getStereotypeGraph:18 call J.first():J
locals: self=lan2graph : ASMModule, name='node' Calling Sequence {GRAPHPROF!node}.first()
stack: GRAPHPROF!node
locals:
stack: OUT!Nodo, GRAPHPROF!node
locals: self=lan2graph : ASMModule, link=TransientLink {rule = class, sourceElements = {source = org.eclipse.uml2.uml.internal.impl.ClassImpl@5eefda (name: Host, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, targetElements = {target = org.eclipse.uml2.uml.internal.impl.ClassImpl@1bc1cae (name: Nodo, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, variables = {}}, source=IN!Host, target=OUT!Nodo
__applyclass:19 pcall J.applyStereotype(J):J
locals: self=lan2graph : ASMModule, link=TransientLink {rule = class, sourceElements = {source = org.eclipse.uml2.uml.internal.impl.ClassImpl@5eefda (name: Host, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, targetElements = {target = org.eclipse.uml2.uml.internal.impl.ClassImpl@1bc1cae (name: Nodo, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, variables = {}}, source=IN!Host, target=OUT!Nodo Calling OUT!Nodo.applyStereotype(GRAPHPROF!node)
org.eclipse.m2m.atl.engine.emfvm.VMException: Exception during invocation of operation applyStereotype on org.eclipse.uml2.uml.internal.impl.ClassImpl@1bc1cae (name: Nodo, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
Java Stack:
org.eclipse.m2m.atl.engine.emfvm.VMException: Exception during invocation of operation applyStereotype on org.eclipse.uml2.uml.internal.impl.ClassImpl@1bc1cae (name: Nodo, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
at org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.invoke(EMFModelAdapter.java:767)
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:425)
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:388)
at org.eclipse.m2m.atl.engine.emfvm.ASMOperation.exec(ASMOperation.java:388)
at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:208)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.internalLaunch(EMFVMLauncher.java:170)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMUILauncher.launch(EMFVMUILauncher.java:46)
at org.eclipse.m2m.atl.core.service.LauncherService.launch(LauncherService.java:136)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launchOrDebug(AtlLaunchConfigurationDelegate.java:300)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:237)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:937)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1141)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@1f0779c (name: node, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
at org.eclipse.uml2.uml.internal.operations.ElementOperations.applyStereotype(ElementOperations.java:1413)
at org.eclipse.uml2.uml.internal.impl.ElementImpl.applyStereotype(ElementImpl.java:510)
at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.m2m.atl.engine.emfvm.adapter.EMFModelAdapter.invoke(EMFModelAdapter.java:760)
... 14 more
|
|
|
| Re: transformation involving UML profiles [message #986645 is a reply to message #986610] |
Wed, 21 November 2012 04:48   |
Hugo Bruneliere Messages: 494 Registered: July 2009 |
Senior Member |
|
|
Hello,
To answer to your first post: M1, P1 & P2 will be the input models of your transformation whereas M2 will be the only output model (all of them conform to the UML metamodel of course).
Concerning your second post, have you set the "Support UML2 stereotypes application" and "Allow inter-model dependencies" options in your ATL launch configuration (cf. the "Advanced" tab of the ATL Launch Configuration UI)?
Hugo
------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
|
|
|
| Re: transformation involving UML profiles [message #986708 is a reply to message #986645] |
Wed, 21 November 2012 06:54   |
Alessandro Ranieri Messages: 16 Registered: November 2012 |
Junior Member |
|
|
Thanks Hugo, I think your suggests are useful but now I have another strange error.
The code that get the error is:
-- @nsURI UML=http://www.eclipse.org/uml2/3.0.0/UML
module lan2graph;
create OUT : UML from IN : UML, GRAPHPROF : UML, LANPROF : UML;
helper def : getStereotypeGraph(name : String) : UML!Stereotype =
UML!Stereotype.allInstancesFrom('GRAPHPROF')->select(p | p.name = name)->first();
helper def : getStereotypeLan(name : String) : UML!Stereotype =
UML!Stereotype.allInstancesFrom('LANPROF')->select(p | p.name = name)->first();
helper context UML!Model def: hasStereotype(name : String) : Boolean =
not self.getAppliedStereotype(name).oclIsUndefined();
helper context UML!Class def: hasStereotype(name : String) : Boolean =
not self.getAppliedStereotype(name).oclIsUndefined();
rule init {
from
s: UML!Model
to
t: UML!Model (name <- 'graphModel')
do {
t.applyProfile(UML!Profile.allInstances()->select(p | p.name = 'graphprofile')->first());
}
}
rule class {
from
source: UML!Class( source.hasStereotype('lanprofile::Host') )
to
target: UML!Class( name<-'Nodo' )
do
{
target.applyStereotype(thisModule.getStereotypeGraph('node'));
}
}
and the error is:
getStereotypeGraph:19 call J.first():J
locals: self=lan2graph : ASMModule, name='node' Calling Sequence {GRAPHPROF!node}.first()
stack: GRAPHPROF!node
locals:
stack: OUT!Nodo, GRAPHPROF!node
locals: self=lan2graph : ASMModule, link=TransientLink {rule = class, sourceElements = {source = org.eclipse.uml2.uml.internal.impl.ClassImpl@1194d7d (name: Host, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, targetElements = {target = org.eclipse.uml2.uml.internal.impl.ClassImpl@c833aa (name: Nodo, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, variables = {}}, source=IN!Host, target=OUT!Nodo
__applyclass:19 pcall J.applyStereotype(J):J
locals: self=lan2graph : ASMModule, link=TransientLink {rule = class, sourceElements = {source = org.eclipse.uml2.uml.internal.impl.ClassImpl@1194d7d (name: Host, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, targetElements = {target = org.eclipse.uml2.uml.internal.impl.ClassImpl@c833aa (name: Nodo, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)}, variables = {}}, source=IN!Host, target=OUT!Nodo Calling OUT!Nodo.applyStereotype(GRAPHPROF!node)
stack:
locals:
stack:
locals: self=lan2graph : ASMModule
__exec__:19 enditerate
stack:
locals:
stack:
locals:
org.eclipse.m2m.atl.engine.emfvm.VMException
Java Stack:
org.eclipse.m2m.atl.engine.emfvm.VMException
at org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.finalizeModel(UML2ModelAdapter.java:51)
at org.eclipse.m2m.atl.engine.emfvm.lib.ExecEnv.terminated(ExecEnv.java:2557)
at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:210)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.internalLaunch(EMFVMLauncher.java:170)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMUILauncher.launch(EMFVMUILauncher.java:46)
at org.eclipse.m2m.atl.core.service.LauncherService.launch(LauncherService.java:136)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launchOrDebug(AtlLaunchConfigurationDelegate.java:300)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:237)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:854)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:937)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1141)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor67.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.applyDelayedInvocations(UML2ModelAdapter.java:136)
at org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.finalizeModel(UML2ModelAdapter.java:49)
... 12 more
Caused by: java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@3b7999 (name: node, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
at org.eclipse.uml2.uml.internal.operations.ElementOperations.applyStereotype(ElementOperations.java:1413)
at org.eclipse.uml2.uml.internal.impl.ElementImpl.applyStereotype(ElementImpl.java:510)
... 17 more
I hope you can still help me.
[Updated on: Wed, 21 November 2012 07:08] Report message to a moderator
|
|
|
| Re: transformation involving UML profiles [message #986711 is a reply to message #986708] |
Wed, 21 November 2012 07:17   |
Hugo Bruneliere Messages: 494 Registered: July 2009 |
Senior Member |
|
|
Maybe the name of the stereotype is not correctly set when calling to getStereotypeGraph: does something like getStereotypeGraph('GRAPHPROF::Node') work better (with GRAPHPROF as actual profile name in your profile file and Node as stereotype name)?
Hugo
------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
|
|
| | | |
| Re: transformation involving UML profiles [message #987578 is a reply to message #986836] |
Tue, 27 November 2012 03:50  |
Alessandro Ranieri Messages: 16 Registered: November 2012 |
Junior Member |
|
|
Thank you, very much! You guessed the cause of the error. But now i have another question.
To solve the problem, that is creating alle the elements inside the Model, I wrote a general rule and some lazy rules:
rule main {
from
s: UML!Model ( s.name = 'model')
to
container1 : UML!Model (
name<- 'graphModel',
packagedElement <- UML!Class.allInstancesFrom('IN')->select( c |
c.hasStereotype('lanprofile::Host'))->collect( t |
thisModule.host2node(t) ),
packagedElment <- [...]
packagedElment <- [...]
[...]
)
do {
container1.applyProfile(UML!Profile.allInstances()->select(p |
p.name = 'graphprofile')->first());
}
}
lazy rule host2node {
from
source: UML!Class
to
target: UML!Class ( name <- 'Node')
do
{
target.applyStereotype(thisModule.getStereotypeGraph('graphprofile::node'));
target.setValue(thisModule.getStereotypeGraph('graphprofile::node'), 'name',
source.getTagValue('lanprofile::Host','Name') );
}
}
The problem now is that I can't use the simple approach of Matched Rules, and so I can't look for patterns in my input model.
So my question is: there's a way to move the target pattern elements inside the Model, for example in the "do" section of a matched rule?
More clearly, I would like to write rules like this:
rule host_router {
from
host1 : UML!Class,
host2 : UML!Class,
host1_host2 : UML!Association (
host1.hasStereotype('lanprofile::Router') and
host2.hasStereotype('lanprofile::Host') and
(host1_host2.endType.first() = host1 and
host1_host2.endType.last() = host2
)
)
to
node_host1 : UML!Class ( name <- host1.getTagValue('lanprofile::Router','Name') ),
node_host2 : UML!Class ( name <- host2.getTagValue('lanprofile::Host','Name') ),
node1_node2 : UML!Association
do
{
moveToModel(node_host1);
moveToModel(node_host2);
moveToModel(node1_node2);
}
}
Regards
[Updated on: Tue, 27 November 2012 04:06] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Jun 17 23:41:37 EDT 2013
Powered by FUDForum. Page generated in 0.09099 seconds
|