Home » Modeling » ATL » transformation involving UML profiles
|
Re: transformation involving UML profiles [message #986610 is a reply to message #986551] |
Wed, 21 November 2012 08: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 #986708 is a reply to message #986645] |
Wed, 21 November 2012 11: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 12:08] Report message to a moderator
|
|
| | | | |
Re: transformation involving UML profiles [message #987578 is a reply to message #986836] |
Tue, 27 November 2012 08: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 09:06] Report message to a moderator
|
|
| | | |
Goto Forum:
Current Time: Wed Sep 25 11:29:01 GMT 2024
Powered by FUDForum. Page generated in 0.09519 seconds
|