Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Problem: Create new UML Model and apply Stereotypes(UML Profile has been applied but applicableStereotypes is an empty list)
icon5.gif  [ATL] Problem: Create new UML Model and apply Stereotypes [message #534503] Wed, 19 May 2010 11:37 Go to next message
Helko Glathe is currently offline Helko GlatheFriend
Messages: 55
Registered: July 2009
Member
Hello,

I've a new strange Problem. Now with applying UML Stereotypes. Hope that anyone can help me to find a solution.

First of all, the Example Relational2UML ( http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.m2m/org .eclipse.m2m.atl/tests/org.eclipse.m2m.atl.tests/data/inputs /Relational2UML/?root=Modeling_Project&hideattic=0) works fine using the Eclipse ATL Launch Wizard.

Than I refined this example a little bit to use an other UML Profile from the ATESST2 Project (EAST-ADL2 Extension for UML see Eclipse Update Site http://www.papyrusuml.org/home/liblocal/docs/updates/papyrus -extensions to get the UML Profile).

The URI for this UML Profile is uri:http://www.papyrusuml.org/EAST-ADL2/1. You can find it in the EMF Registry after the Eclipse Plugin has been installed. Thus, you can also see it when using the Eclipse ATL Launch Wizard.

As I said, I refined the Relational2UML Example. The ATL Module looks now:
-- @nsURI UML=http://www.eclipse.org/uml2/3.0.0/UML
-- @path Relational=/org.eclipse.m2m.atl.tests/data/inputs/Relational2UML/relational.ecore

module Relational2UMLNew;
create OUT : UML from IN : Relational, PRO : UML;

-------------------------------------------------------------------------------------------
-- HELPERS --------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------

helper def : stringType : UML!PrimitiveType = OclUndefined;
helper def : integerType : UML!PrimitiveType = OclUndefined;

helper def: printAllStereotypes: UML!Stereotype = UML!Stereotype.allInstances() -> debug('Stereotypes of Profile ');

helper def : getStereotype(name : String) : UML!Stereotype =
    UML!Stereotype.allInstancesFrom('PRO')->select(p | p.name = name)->first();
    
-------------------------------------------------------------------------------------------
-- RULES ----------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------

rule Database2Model {
	from
		d : Relational!Database
	to
		out : UML!Model (
			name <- d.name,
			packagedElement <- Sequence{d.ownedSchemas,integer,string} -> flatten()
		),
		integer : UML!PrimitiveType (
			name <- 'Integer'
		),
		string : UML!PrimitiveType (
			name <- 'String'
		)
	do {
		thisModule.stringType <- string;
	    thisModule.integerType <- integer;
	    out.applyProfile(UML!Profile.allInstancesFrom('PRO')->select(p | p.name = 'EAST-ADL2')->first());
	    thisModule.printAllStereotypes;	
	}
}  

rule Schema2Class {
	from
		s : Relational!Schema 
	to
		out : UML!Class (
			name <- s.name
			--packagedElement <- s.ownedTables
		)
	do {
	  	--out.applyStereotype(out.RequirementsModel);
	  	out.getApplicableStereotypes()->debug('Applicable Stereotypes ');
		out.applyStereotype(thisModule.getStereotype('Requirement'));
		--out.applyStereotype(thisModule.getStereotype('RequirementsModel')->debug('Hmm '));
		--out.applyStereotype(out.getApplicableStereotype('SystemModel')->debug('Testtt: '));
	}
}


[First Problem:]
The ATL Launch Configuration is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2m.atl.adt.launching.atlTransformation">
<stringAttribute key="ATL File Name" value="/Relational2UML/Relational2UMLNew.atl"/>
<stringAttribute key="ATL VM" value="EMF-specific VM"/>
<stringAttribute key="ATL_COMPILER" value="atl2006"/>
<booleanAttribute key="IS_REFINING" value="false"/>
<mapAttribute key="Input">
<mapEntry key="IN" value="Relational"/>
<mapEntry key="PRO" value="UML"/>
</mapAttribute>
<mapAttribute key="Libs"/>
<mapAttribute key="Model Handler">
<mapEntry key="Relational" value="EMF"/>
<mapEntry key="UML" value="EMF"/>
</mapAttribute>
<mapAttribute key="ModelType">
<mapEntry key="Relational" value="METAMODELINPUT"/>
<mapEntry key="IN" value="MODELINPUT"/>
<mapEntry key="OUT" value="MODELOUTPUT"/>
<mapEntry key="PRO" value="MODELINPUT"/>
<mapEntry key="UML" value="METAMODELOUTPUT"/>
</mapAttribute>
<mapAttribute key="Options">
<mapEntry key="supportUML2Stereotypes" value="true"/>
<mapEntry key="printExecutionTime" value="false"/>
<mapEntry key="OPTION_CLEAR" value="true"/>
<mapEntry key="OPTION_DERIVED" value="true"/>
<mapEntry key="allowInterModelReferences" value="false"/>
<mapEntry key="step" value="false"/>
</mapAttribute>
<mapAttribute key="Output">
<mapEntry key="OUT" value="UML"/>
</mapAttribute>
<mapAttribute key="Path">
<mapEntry key="IN" value="/Relational2UML/sample-Relational.xmi"/>
<mapEntry key="Relational" value="/Relational2UML/relational.ecore"/>
<mapEntry key="OUT" value="/Relational2UML/output.uml"/>
<mapEntry key="PRO" value="uri:http://www.papyrusuml.org/EAST-ADL2/1"/>
<mapEntry key="UML" value="uri:http://www.eclipse.org/uml2/3.0.0/UML"/>
</mapAttribute>
<listAttribute key="Superimpose"/>
</launchConfiguration>


You can see that the input model for the UML Profile (PRO) is referenced using "uri:http://www.papyrusuml.org/EAST-ADL2/1", that is the registered UML Profile.

The output after running the Launch Configuration is:
Stereotypes of Profile : OrderedSet {}
org.eclipse.m2m.atl.engine.emfvm.VMException: Operation not found: OUT!sample_database:UML!Model.applyProfile(org.eclipse.m2m.atl.engine.emfvm.lib.OclUndefined)
	at __applyDatabase2Model(Relational2UMLNew.atl[40:6-40:102])
		local variables: self=thisModule, link=org.eclipse.m2m.atl.engine.emfvm.lib.TransientLink@1ab7757, d=IN!sample_database:Relational!Database, out=OUT!sample_database:UML!Model, integer=OUT!Integer:UML!PrimitiveType, string=OUT!String:UML!PrimitiveType
	at __exec__(Relational2UMLNew.atl)
		local variables: self=thisModule, e=org.eclipse.m2m.atl.engine.emfvm.lib.TransientLink@1ab7757
	at main(Relational2UMLNew.atl)
		local variables: self=thisModule


It is interesting that "Stereotypes of Profile : OrderedSet {}" is stating an empty set (see debiug statement in ATL Module above). I assume, that the model for the UML Profile has not been loaded successfully. Thus no stereotypes can be found. Moreover the operation applyProfile fails.



Now a refined Launch Configuration...
[Second Problem:]
The Launch Configuration now looks:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.m2m.atl.adt.launching.atlTransformation">
<stringAttribute key="ATL File Name" value="/Relational2UML/Relational2UMLNew.atl"/>
<stringAttribute key="ATL VM" value="EMF-specific VM"/>
<stringAttribute key="ATL_COMPILER" value="atl2006"/>
<booleanAttribute key="IS_REFINING" value="false"/>
<mapAttribute key="Input">
<mapEntry key="IN" value="Relational"/>
<mapEntry key="PRO" value="UML"/>
</mapAttribute>
<mapAttribute key="Libs"/>
<mapAttribute key="Model Handler">
<mapEntry key="Relational" value="EMF"/>
<mapEntry key="UML" value="EMF"/>
</mapAttribute>
<mapAttribute key="ModelType">
<mapEntry key="Relational" value="METAMODELINPUT"/>
<mapEntry key="IN" value="MODELINPUT"/>
<mapEntry key="OUT" value="MODELOUTPUT"/>
<mapEntry key="PRO" value="MODELINPUT"/>
<mapEntry key="UML" value="METAMODELOUTPUT"/>
</mapAttribute>
<mapAttribute key="Options">
<mapEntry key="supportUML2Stereotypes" value="true"/>
<mapEntry key="printExecutionTime" value="false"/>
<mapEntry key="OPTION_CLEAR" value="true"/>
<mapEntry key="OPTION_DERIVED" value="true"/>
<mapEntry key="allowInterModelReferences" value="false"/>
<mapEntry key="step" value="false"/>
</mapAttribute>
<mapAttribute key="Output">
<mapEntry key="OUT" value="UML"/>
</mapAttribute>
<mapAttribute key="Path">
<mapEntry key="IN" value="/Relational2UML/sample-Relational.xmi"/>
<mapEntry key="Relational" value="/Relational2UML/relational.ecore"/>
<mapEntry key="OUT" value="/Relational2UML/output.uml"/>
<mapEntry key="PRO" value="/Relational2UML/eastadl.profile.uml"/>
<mapEntry key="UML" value="uri:http://www.eclipse.org/uml2/3.0.0/UML"/>
</mapAttribute>
<listAttribute key="Superimpose"/>
</launchConfiguration>


Instead of using the reference "uri:http://www.papyrusuml.org/EAST-ADL2/1" for the registered UML Profile, I copied the UML profile file "eastadl.profile.uml" out of the Plugin jar file into the ATL projects workspace and make a workspace reference for the Profile input model (PRO).

The output of running this configuration is:
Quote:

Stereotypes of Profile : OrderedSet {PRO!VariationGroup:UML!Stereotype, PRO!ReuseMetaInformation:UML!Stereotype, PRO!ConfigurableContainer:UML!Stereotype, PRO!VariableElement:UML!Stereotype, PRO!Variability:UML!Stereotype,
Snip...Snap
PRO!ArchitecturalModel:UML!Stereotype, PRO!GenericConstraint:UML!Stereotype, PRO!GenericConstraintSet:UML!Stereotype, PRO!TakeRateConstraint:UML!Stereotype}
Applicable Stereotypes : Sequence {}
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.fi nalizeModel(UML2ModelAdapter.java:51)
at org.eclipse.m2m.atl.engine.emfvm.lib.ExecEnv.terminated(Exec Env.java:2304)
at org.eclipse.m2m.atl.engine.emfvm.ASM.run(ASM.java:199)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.launch (EMFVMLauncher.java:162)
at org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher.launch (EMFVMLauncher.java:135)
at org.eclipse.m2m.atl.core.service.LauncherService.launch(Laun cherService.java:135)
at org.eclipse.m2m.atl.core.ui.launch.AtlLaunchConfigurationDel egate.launch(AtlLaunchConfigurationDelegate.java:222)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:853)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:703)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:866)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1069)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
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.ap plyDelayedInvocations(UML2ModelAdapter.java:136)
at org.eclipse.m2m.atl.engine.emfvm.adapter.UML2ModelAdapter.fi nalizeModel(UML2ModelAdapter.java:49)
... 11 more
Caused by: java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@4bfd7f (name: Requirement, visibility: <unset>) (isLeaf: false, isAbstract: false) (isActive: false)
at org.eclipse.uml2.uml.internal.operations.ElementOperations.a pplyStereotype(ElementOperations.java:1411)
at org.eclipse.uml2.uml.internal.impl.ElementImpl.applyStereoty pe(ElementImpl.java:499)
... 17 more



Here, "Stereotypes of Profile :" is not an empty set. All available Stereotypes are there which is fine. Applying the profile in the ATL transformation worked fine. But now the retrieval of applicable stereotypes of the new UML element of type UML!Class (see Rule Schema2Class) doesn't work as expected: "Applicable Stereotypes : Sequence {}" is an empty set. Thus I get a "java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl" when calling applyStereotype on the UML Element of type UML!Class.

Does anyone know how to solve this problem?

Many thanks in advance, Helko

ps: I tried to come quickly to the point as possible, but it's hard to explain it ... sorry for the large content.
Please, be back to me, if you need further clarrification or input.

[Updated on: Wed, 19 May 2010 21:02]

Report message to a moderator

Re: [ATL] Problem: Create new UML Model and apply Stereotypes [message #642511 is a reply to message #534503] Wed, 01 December 2010 16:02 Go to previous messageGo to next message
Pejman  is currently offline Pejman Friend
Messages: 18
Registered: June 2010
Junior Member
Hi,
I have the same problem. Can I ask you how do you set up the framework. I mean when you want to run the project what are your input and output models/metamodels?

Pejman
Re: [ATL] Problem: Create new UML Model and apply Stereotypes [message #643143 is a reply to message #534503] Sun, 05 December 2010 08:44 Go to previous messageGo to next message
Frank Alleman is currently offline Frank AllemanFriend
Messages: 1
Registered: November 2010
Location: Netherlands
Junior Member
Hi Helko,

I had some similar troubles with a script base on the example relational2uml, but when I changed some code they were solved.

In the example I replaced
'out.applyStereotype(thisModule.getStereotype('Column'));'
by
'out.applyStereotype(out.getApplicableStereotype('relational::Column'));
out(setValue(out.getAppliedStereotype('relational::Column'), 'isPrimaryKey', p.isPrimaryKey);'

Maybe this solves your ploblem as well,
Frank
Re: [ATL] Problem: Create new UML Model and apply Stereotypes [message #643231 is a reply to message #643143] Mon, 06 December 2010 08:10 Go to previous message
Helko Glathe is currently offline Helko GlatheFriend
Messages: 55
Registered: July 2009
Member
Hello,

I've already solved the problem. In general, there is a difference, if you state the UML Profile explicitely as output model in addition to the UML output model and using the Profile elements as First Class Elements in ATL OR having the UML Profile as input model and call "applyProfile", "applyStereotype" etc. on the UML output model.

E.g. see my last post on this issue: http://www.eclipse.org/forums/index.php?t=msg&goto=53979 5&S=9115fac6ca5ad6c93267129ecb8cc17b#msg_539795


BR / Helko
Previous Topic:[QVTo] Is qvtotrace loaded?
Next Topic:[QVTO] Example of a where-clause for a mapping operation
Goto Forum:
  


Current Time: Thu Mar 28 19:44:10 GMT 2024

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

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

Back to the top