Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » transformation involving UML profiles
transformation involving UML profiles [message #986551] Tue, 20 November 2012 22:03 Go to next message
Alessandro Ranieri is currently offline Alessandro RanieriFriend
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 08:03 Go to previous messageGo to next message
Alessandro Ranieri is currently offline Alessandro RanieriFriend
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 09:48 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
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, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: transformation involving UML profiles [message #986708 is a reply to message #986645] Wed, 21 November 2012 11:54 Go to previous messageGo to next message
Alessandro Ranieri is currently offline Alessandro RanieriFriend
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 #986711 is a reply to message #986708] Wed, 21 November 2012 12:17 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
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, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: transformation involving UML profiles [message #986728 is a reply to message #986711] Wed, 21 November 2012 13:23 Go to previous messageGo to next message
Alessandro Ranieri is currently offline Alessandro RanieriFriend
Messages: 16
Registered: November 2012
Junior Member
Hugo Bruneliere wrote on Wed, 21 November 2012 07:17
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)?


I redefined the helper function getSteretypeGraph as you said:
helper def : getStereotypeGraph(qname : String) : UML!Stereotype =
	UML!Stereotype.allInstances()->select(p | p.qualifiedName = qname)->first();


So the call becomes:
target.applyStereotype(thisModule.getStereotypeGraph('graphprofile::node')); 


but it returns the same error above.


Re: transformation involving UML profiles [message #986812 is a reply to message #986728] Wed, 21 November 2012 18:01 Go to previous messageGo to next message
Alessandro Ranieri is currently offline Alessandro RanieriFriend
Messages: 16
Registered: November 2012
Junior Member
I've just found a bug report here that seems to describe the same error occured to me.

The reporter wrote:

If an ATL transformation is run against a UML model which has a profile attached that is, a) not exported using a EMF URL PATHMAP or b) not located on the file system locally, then ATL will crash with the following exception:


[...]

We can avoid the exception normally by exposing profiles we use as both GMF and EMF pathmaps. However, if a modeller add a previously unknown profile without assigning a EMF pathmap then ATL will fail with the above exception.


I don't understand the workaround.
I created my profiles and my input model in Papyrus and then I used those as they are. Have I to modify the model or the profiles in any way before to execute the trasformation?

Thanks again for the help.
Re: transformation involving UML profiles [message #986836 is a reply to message #986812] Wed, 21 November 2012 21:31 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
The error you see does not sound like it related to that issue in Bugzilla. The issue in Bugzilla, reported by me, occurs when ATL encounters a profiled UML model, whose profile has not been exposed in a way ATL can process it i.e. EMF Pathmap

The issue you see "org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.finalizeModel(UML2ModelAdapter.java:51)" is nearly always because you are generating an invalid/malformed output UML model. The error is a little cryptic but it stems from the fact the model is not serializable and so the profile cannot be applied correctly.

Try running the transform without applying the profile on the output model. I would bet your model isn't valid. Try running a validate on it. You will probably see an element sitting outside the model, when it really should be nested somewhere else. Assuming that is the problem, fix the offending rule, then put back in the profile application code.

Regards,
Ronan
Re: transformation involving UML profiles [message #987578 is a reply to message #986836] Tue, 27 November 2012 08:50 Go to previous messageGo to next message
Alessandro Ranieri is currently offline Alessandro RanieriFriend
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

Re: transformation involving UML profiles [message #1200626 is a reply to message #987578] Thu, 21 November 2013 10:26 Go to previous messageGo to next message
N G is currently offline N GFriend
Messages: 1
Registered: February 2013
Junior Member
Hello,

I've a new strange Problem. Now with applying UML Stereotypes. Hope that anyone can help me to find a solution.
I like transform in input Model= UML model+profil1+profile2 in to output Model=UML model+profil1+profile3

profile1=SysML
profile2=MuseML
profile3=Sym


-- @nsURI MModelicaMLProfile=http://www.eclipse.org/papyrus/0.10.0/SysML4Modelica
-- @nsURI MMsysml=http://www.eclipse.org/papyrus/0.7.0/SysML
-- @nsURI MMuml=http://www.eclipse.org/uml2/4.0.0/UML
-- @nsURI MMmuseMLProfile=http://www.eclipse.org/papyrus/MuseML/1

create OUT : MMuml from INuml : MMuml, INsysml : MMsysml, INmuseMLProfile: MMmuseMLProfile, ImodelicaMLProfile: MModelicaMLProfile ;

rule applyprofil{

from museml: MMuml!Model

to
sym: MMuml!Model(
name<- museml.name

)

do{


sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='SysML').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='Blocks').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='ModelElements').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='PortAndFlows').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='Constraints').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='Activities').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='Allocations').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='Requirements').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='Interactions').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='StateMachines').first());

sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='UseCases').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='SysML4Modelica').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='Classes').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='Components').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='EquationsAndAlgorithms').first());
sym.applyProfile(MMuml!Profile.allInstances()->select(p | p.name ='Other').first());

}

}
rule Muse2ModelicaModel{
from museml: MMuml!Class(
thisModule.isBlockStereotyped(museml) and
museml.isMuseMLClassDefinitionStereotyped()
)
to
sym: MMuml!Class(
name<- museml.name
-- name <- sym.namee
)

do{

sym.applyStereotype(museml.getApplicableStereotype('SysML::Blocks::Block'));

}


}

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:43)
at org.eclipse.m2m.atl.core.service.LauncherService.launch(LauncherService.java:136)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDelegate$1.run(AtlLaunchConfigurationDelegate.java:274)
Caused by: java.lang.reflect.InvocationTargetException
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.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.applyDelayedInvocations(UML2ModelAdapter.java:136)
at org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.finalizeModel(UML2ModelAdapter.java:49)
... 6 more
Caused by: java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@1791d92 (name: Block, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: 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)
... 12 more





Re: transformation involving UML profiles [message #1200977 is a reply to message #1200626] Thu, 21 November 2013 14:07 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
Your model is not serializable to UML. Thus the error. Where have you assigned the classes you generate to the model? The model must be serializable to correct UML before you start applying stereotypes.
Regards,
Ronan
Re: transformation involving UML profiles [message #1698716 is a reply to message #1200977] Wed, 17 June 2015 12:13 Go to previous message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 343
Registered: August 2013
Senior Member
Hi

I had a similar problem. Maybe my solution will be helpful for someone... I'm using QVTo instead of ATL, but I guess that the idea is the same.

The following code:
modeltype ISO20022 uses 'urn:iso:std:iso:20022:2013:ecore';
modeltype UML uses 'http://www.eclipse.org/uml2/3.0.0/UML';

transformation ModelToDatabase(in m : ISO20022, in p : UML, out uml : UML);

property profile : Profile = p.rootObjects()![Profile];

main()
{
    m.objectsOfType(Repository)->toModel();
}

mapping Repository::toModel() : UML::Model
{
	result.applyProfile(profile);
	name := 'Repository';
	packagedElement += self.dataDictionary->toPackage(); // 2 add nested package to the model
}

mapping DataDictionary::toPackage() : UML::Package
{
	name := 'DataDictionary';
	result.applyStereotype(profile.getStereotype(name)); // 1 apply stereotype
}

query Profile::getStereotype(name : String) : Stereotype =
	profile.ownedStereotype->any(st|st.name = name);


causes the exception:
Caused by: java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@d36f83e7 (name: DataDictionary, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
	at org.eclipse.uml2.uml.internal.operations.ElementOperations.applyStereotype(ElementOperations.java:1411)
	at org.eclipse.uml2.uml.internal.impl.ElementImpl.applyStereotype(ElementImpl.java:510)


I think that the exception is raised because I tried to apply the stereotype to the nested package before the later one is added to the model.
Here is a fix, take a look at comments:
modeltype ISO20022 uses 'urn:iso:std:iso:20022:2013:ecore';
modeltype UML uses 'http://www.eclipse.org/uml2/3.0.0/UML';

transformation ModelToDatabase(in m : ISO20022, in p : UML, out uml : UML);

property profile : Profile = p.rootObjects()![Profile];

main()
{
    m.objectsOfType(Repository)->toModel();
}

mapping Repository::toModel() : UML::Model
{
	result.applyProfile(profile);
	name := 'Repository';
	self.dataDictionary->toPackage(result);
}

mapping DataDictionary::toPackage(owner : Package) : UML::Package
{
	nestingPackage := owner; // 1 add nested package to the model
	name := 'DataDictionary';
	result.applyStereotype(profile.getStereotype(name)); // 2 apply stereotype
}

query Profile::getStereotype(name : String) : Stereotype =
	profile.ownedStereotype->any(st|st.name = name);
Previous Topic:Drools Meta Model
Next Topic:[ATL] How programmatically know name and referenceModelName in ATL transformations
Goto Forum:
  


Current Time: Fri Mar 29 06:28:10 GMT 2024

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

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

Back to the top