Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Patricia Fernández is currently offline Patricia Fernández
Messages: 41
Registered: October 2012
Member
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]

Report message to a moderator

Re: [EGL] Can't get the type name of an operation [message #941292 is a reply to message #941153] Fri, 12 October 2012 07:21 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-Dominguez
Messages: 304
Registered: January 2010
Senior Member
It's strange that oper.type.name fails in that way if oper.type is defined.

Could you set up a minimal example that reproduces the problem?

http://eclipse.org/epsilon/doc/articles/minimal-examples/

Re: [EGL] Can't get the type name of an operation [message #943211 is a reply to message #941292] Sun, 14 October 2012 04:52 Go to previous messageGo to next message
Patricia Fernández is currently offline Patricia Fernández
Messages: 41
Registered: October 2012
Member
Antonio Garcia-Dominguez wrote on Fri, 12 October 2012 07:21
It's strange that oper.type.name fails in that way if oper.type is defined.

Could you set up a minimal example that reproduces the problem?

http://eclipse.org/epsilon/doc/articles/minimal-examples/


Hello,

Sorry for the delay in my reply.
Minimal example attached.
  • Attachment: Minimal.zip
    (Size: 30.68KB, Downloaded 96 times)

[Updated on: Sun, 14 October 2012 04:56]

Report message to a moderator

Re: [EGL] Can't get the type name of an operation [message #953824 is a reply to message #943211] Mon, 22 October 2012 11:05 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio Hoyos
Messages: 153
Registered: October 2009
Senior Member

Patricia,

Wanted to give a go at this but I didn't saw the launch configuration on your minimal example. Could you please add this?


Horacio Hoyos Rodriguez
EngD Student
University Of York
Re: [EGL] Can't get the type name of an operation [message #953913 is a reply to message #953824] Mon, 22 October 2012 12:32 Go to previous messageGo to next message
Patricia Fernández is currently offline Patricia Fernández
Messages: 41
Registered: October 2012
Member
Horacio Hoyos wrote on Mon, 22 October 2012 11:05
Patricia,

Wanted to give a go at this but I didn't saw the launch configuration on your minimal example. Could you please add this?


Hello Horacio,

I don't use a launch configuration file, instead I do the following:

> Run
> Run Configurations
> EGL Template
> Tab Template-> Name: X / Source: Select the Operations.egl file.
> Tab Models-> Add -> EMF Model -> Name: X / Model file: Select Ejemplo.uml / Meta-model URI: http://www.eclipse.org/uml2/3.0.0/UML (In the EMF section unselect Meta-model is file based)-> OK
> Apply
> Run

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 Go to previous messageGo to next message
Horacio Hoyos is currently offline Horacio Hoyos
Messages: 153
Registered: October 2009
Senior Member

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 Wink )

Hope this solves your problem,


Horacio Hoyos Rodriguez
EngD Student
University Of York

[Updated on: Fri, 26 October 2012 09:51]

Report message to a 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 Go to previous messageGo to next message
Patricia Fernández is currently offline Patricia Fernández
Messages: 41
Registered: October 2012
Member
Horacio Hoyos wrote on Fri, 26 October 2012 09:48
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]
...

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 Wink )

Hope this solves your problem,



Thank you so much for taking the time and answer me. I will try that! Smile
Re: [EGL] Can't get the type name of an operation [message #959157 is a reply to message #959154] Fri, 26 October 2012 09:52 Go to previous message
Horacio Hoyos is currently offline Horacio Hoyos
Messages: 153
Registered: October 2009
Senior Member

I just corrected two typos in my answer (sorry) the java method return type should be void!



Horacio Hoyos Rodriguez
EngD Student
University Of York

[Updated on: Fri, 26 October 2012 09:53]

Report message to a moderator

Previous Topic:Using Epsilon for model refinement/update
Next Topic:Customizing ModeLink/Exeed Editor
Goto Forum:
  


Current Time: Fri Aug 22 15:58:28 EDT 2014

Powered by FUDForum. Page generated in 0.01927 seconds