[ETL] Problems of applying stereotype [message #1346377] |
Sat, 10 May 2014 15:37 |
Xue Liu Messages: 21 Registered: May 2014 |
Junior Member |
|
|
Hello,
I am a newbie of Epsilon project. Now I want to use Epsilon Transformation Language to make transformation from ecore model to UML Class file with UML Profile.
In the attachment you can find the whole project, where CloudStructure2UML.etl is the Epsilon file. In this transformation. "CloudStructure" refers to the ecore metamodel in the metamodel/CloudStructure.ecore. "UML2" refers to http://www.eclipse.org/uml2/4.0.0/uml. "PROFILE" refers to UML Profile profile/CloudStructure4UML.profile.uml.
According to http://www.eclipse.org/forums/index.php?t=msg&th=207272/, I apply stereotype in the post section.
post postCloudModel2Model {
"Running ATL post".println();
var UMLModel : new UML2!Model;
UMLModel.applyProfile(PROFILE!Profile.allInstances -> selectOne(p | p.name = 'CloudStructure4UML'));
UMLModel.applyProfile(PROFILE!Profile.allInstances -> selectOne(p | p.name = 'Profile'));
UMLModel.applyStereotype(PROFILE!Stereotype.allInstances -> selectOne(p | p.name = 'CloudModel')); // Works !!
var cloudelement : new UML2!Stereotype;
cloudelement = PROFILE!Stereotype.all.selectOne(s|s.name = 'CloudElement');
for (cl in UML2!Class.all) {
cl.applyStereotype(cloudelement); // Error !!
}
}
Strangely,
UMLModel.applyStereotype(PROFILE!Stereotype.allInstances -> selectOne(p | p.name = 'CloudModel'));
is working but
cl.applyStereotype(cloudelement);
does not. The error message is shown below:
Internal error: java.lang.IllegalArgumentException: org.eclipse.uml2.uml.internal.impl.StereotypeImpl@4a2a76e9 [name: CloudElement, 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]
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.epsilon.eol.util.ReflectionUtil.executeMethod[ReflectionUtil.java:187]
at org.eclipse.epsilon.eol.util.ReflectionUtil.executeMethod[ReflectionUtil.java:163]
at org.eclipse.epsilon.eol.execute.PointExecutor.executeOperation[PointExecutor.java:174]
at org.eclipse.epsilon.eol.execute.PointExecutor.execute[PointExecutor.java:89]
at org.eclipse.epsilon.eol.execute.PointExecutor.execute[PointExecutor.java:49]
at org.eclipse.epsilon.eol.execute.PointExecutor.execute[PointExecutor.java:104]
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST[ExecutorFactory.java:190]
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST[ExecutorFactory.java:160]
at org.eclipse.epsilon.eol.execute.StatementBlockExecutor.execute[StatementBlockExecutor.java:26]
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST[ExecutorFactory.java:190]
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST[ExecutorFactory.java:160]
at org.eclipse.epsilon.eol.execute.ForStatementExecutor.execute[ForStatementExecutor.java:111]
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST[ExecutorFactory.java:190]
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST[ExecutorFactory.java:160]
at org.eclipse.epsilon.eol.execute.StatementBlockExecutor.execute[StatementBlockExecutor.java:26]
at org.eclipse.epsilon.eol.execute.ExecutorFactory.executeAST[ExecutorFactory.java:190]
at org.eclipse.epsilon.erl.ErlModule.execute[ErlModule.java:88]
at org.eclipse.epsilon.etl.EtlModule.execute[EtlModule.java:129]
at org.eclipse.epsilon.eol.dt.launching.EpsilonLaunchConfigurationDelegate.launch[EpsilonLaunchConfigurationDelegate.java:79]
at org.eclipse.epsilon.eol.dt.launching.EpsilonLaunchConfigurationDelegate.launch[EpsilonLaunchConfigurationDelegate.java:56]
at org.eclipse.debug.internal.core.LaunchConfiguration.launch[LaunchConfiguration.java:858]
at org.eclipse.debug.internal.core.LaunchConfiguration.launch[LaunchConfiguration.java:707]
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch[DebugUIPlugin.java:1018]
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run[DebugUIPlugin.java:1222]
at org.eclipse.core.internal.jobs.Worker.run[Worker.java:53]
[Updated on: Mon, 12 May 2014 13:20] Report message to a moderator
|
|
|
|
|
|
Re: [ETL] Problems of applying stereotype [message #1351973 is a reply to message #1350839] |
Tue, 13 May 2014 08:38 |
Stephan Faßbender Messages: 2 Registered: March 2014 |
Junior Member |
|
|
Hi Xue,
there are several issues. Some of them i could fix, one remains open. maybe Dimitri has a solution for it.
post postCloudModel2Model {
var UMLModel : new UML2!Model;
At this point you are adding a second model as root element to the target UML model. But what you want to do is to refer to the model element already create while doing the transformation. Hence, you want to do something like:
post postCloudModel2Model {
var UMLModel = UML2!Model.allInstances->first();
The next issue is related to the first.
var cloudelement : new UML2!Stereotype;
cloudelement = PROFILE!Stereotype.allInstances -> selectOne(s|s.name = 'CloudElement');
for (cl in UML2!Class.all) {
cl.applyStereotype(cloudelement); // Error !!
}
This also will break the transformation, because the line
var cloudelement : new UML2!Stereotype;
creates an uninstantiated class of the type stereotype which is immediately added to the UML model . Thus, when iterating over all classes you with
for (cl in UML2!Class.all) {
cl.applyStereotype(cloudelement); // Error !!
}
you get your null pointer.
This will fix this issue:
var cloudelement = PROFILE!Stereotype.allInstances -> selectOne(p | p.name = 'CloudElement');
for (cl in UML2!Class.all) {
cl.applyStereotype(cloudelement); // No Error !!
}
Then i was wondering why don't you apply the profile right away while transforming. This works just fine:
rule CloudModel2Model
transform s: CloudStructure!CloudModel
to t : UML2!Model {
t.name = 'Model';
t.packagedElement.add(s.containedCloud.equivalent());
t.applyProfile(PROFILE!Profile.allInstances -> selectOne(p | p.name = 'CloudStructure4UML'));
t.applyProfile(PROFILE!Profile.allInstances -> selectOne(p | p.name = 'Profile'));
t.applyStereotype(PROFILE!Stereotype.allInstances -> selectOne(p | p.name = 'CloudModel'));
}
I tried the same for the Class, but surprisingly it does not work:
rule CloudElement2Class // Transform Ecore!CloudElement to a UML!Class with stereotype <<CloudElement>>
transform s : CloudStructure!CloudElement
to t : UML2!Class {
t.name = s.name;// -> debug('*self defined debug output*') -- the debug statement prints out information in the console view
t.applyStereotype(PROFILE!Stereotype.allInstances -> selectOne(p | p.name = 'CloudElement'));
}
The reason seems to be, that the new generated Class is not nested correctly at this very moment. Thus, the applied profiles are not known from the according Model element. Anyone has a solution for this? In the mean time you can use your solution with post. This solution is just fine as long as all classes generated are cloudelements .
With kind regards,
Stephan
|
|
|
Re: [ETL] Problems of applying stereotype [message #1353107 is a reply to message #1351973] |
Tue, 13 May 2014 19:38 |
|
Hi Stephan,
Thanks for your insightful response! You're right in your observation re CloudElement2Class; the new Class (t) needs to be added to the output model (UML2!Model.all.first()) or one of its children before the stereotype can be applied to it.
Cheers,
Dimitris
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03452 seconds