Home » Modeling » Epsilon » [EGL] Can't get the type name of an operation(UML to Java tranformation)
[EGL] Can't get the type name of an operation [message #941153] |
Fri, 12 October 2012 04:53  |
Eclipse User |
|
|
|
Hello,
I've the following .egl file:
[% for (oper in currentClass.AllOperations) {%]
[%=oper.visibility%] [%=oper.type.name%] [%=oper.name%] () {
}
[%}%]
The problem is that [%=oper.type.name%] is not working. It gives me an Called feature name on undefined object error. If I put [%=oper.type%] it shows me:
org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl@14f6ce4 (name: Boolean, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false)
And, as I want to get the name of the type, I wrote [%=oper.type.name%] but it's not working.
I made a similar file with attributes instead of operations, and [%=attr.type.name%] worked fine.
If anyone could help me.
Thanks in advance.
[Updated on: Fri, 12 October 2012 04:54] by Moderator
|
|
| | | | |
Re: [EGL] Can't get the type name of an operation [message #959149 is a reply to message #953913] |
Fri, 26 October 2012 09:48   |
Eclipse User |
|
|
|
Hi Patricia,
I did some debug printing, you can try this:
// Operations of the class [%=currentClass.name%]
[%currentClass.println("class ");%]
[% for (oper in currentClass.AllOperations) {%]
[% oper.println("oper "); %]
[% oper.type.println("type "); %]
[%=oper.visibility%] [%=oper.type%] [%=oper.name%] () {
}
[%}%]
And I got:
...
oper Operation [name=addAlumno, qualifiedName=Data::Grupo::addAlumno, visibility=public, isLeaf=false, isStatic=false, concurrency=sequential, isAbstract=false, isOrdered=false, isQuery=false, isUnique=true, lower=1, upper=1]
type
class Class [name=Profesor, qualifiedName=Data::Profesor, visibility=public, isLeaf=false, isAbstract=false, isFinalSpecialization=false, isActive=false, ]
oper Operation [name=vincular_departamento, qualifiedName=Data::Profesor::vincular_departamento, visibility=public, isLeaf=false, isStatic=false, concurrency=sequential, isAbstract=false, isOrdered=false, isQuery=false, isUnique=true, lower=1, upper=1]
type PrimitiveType [name=Boolean, qualifiedName=PrimitiveTypes::Boolean, visibility=public, isLeaf=false, isAbstract=false, isFinalSpecialization=false, ]
...
So the addAlumno has no type, but the vincular_departamento does.
Looking at the uml model, addAlumno has no return type (probably void?) while the vincular_departamento operation has a boolean return type. So I guess the operation type is null if the operation has no return parameter. Guess you have to add some logic to test this and set the java operation return type to void if the uml operation's type is null.
In the future using this "debug printing" can help you understand what is happening (if you don't know a lot about models and decide to run the egl in debug mode )
Hope this solves your problem,
[Updated on: Fri, 26 October 2012 09:51] by Moderator
|
|
|
Re: [EGL] Can't get the type name of an operation [message #959154 is a reply to message #959149] |
Fri, 26 October 2012 09:50   |
Eclipse User |
|
|
|
Horacio Hoyos wrote on Fri, 26 October 2012 09:48Hi Patricia,
I did some debug printing, you can try this:
// Operations of the class [%=currentClass.name%]
[%currentClass.println("class ");%]
[% for (oper in currentClass.AllOperations) {%]
[% oper.println("oper "); %]
[% oper.type.println("type "); %]
[%=oper.visibility%] [%=oper.type%] [%=oper.name%] () {
}
[%}%]
And I got:
...
oper Operation [name=addAlumno, qualifiedName=Data::Grupo::addAlumno, visibility=public, isLeaf=false, isStatic=false, concurrency=sequential, isAbstract=false, isOrdered=false, isQuery=false, isUnique=true, lower=1, upper=1]
type
class Class [name=Profesor, qualifiedName=Data::Profesor, visibility=public, isLeaf=false, isAbstract=false, isFinalSpecialization=false, isActive=false, ]
oper Operation [name=vincular_departamento, qualifiedName=Data::Profesor::vincular_departamento, visibility=public, isLeaf=false, isStatic=false, concurrency=sequential, isAbstract=false, isOrdered=false, isQuery=false, isUnique=true, lower=1, upper=1]
...
So the addAlumno has no type, but the vincular_departamento does.
Looking at the uml model, addAlumno has no return type (probably void?) while the vincular_departamento operation has a boolean return type. So I guess the operation type is null if the operation has no return parameter. Guess you have to add some logic to test this and set the java operation return type to null if the uml operation's type is null.
In the future using this "debug printing" can help you understand what is happening (if you don't know a lot about models and decide to run the egl in debug mode )
Hope this solves your problem,
Thank you so much for taking the time and answer me. I will try that! 
|
|
| |
Goto Forum:
Current Time: Thu Jul 17 10:42:39 EDT 2025
Powered by FUDForum. Page generated in 0.07006 seconds
|