Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xtend] Wrong parameter type
[Xtend] Wrong parameter type [message #525412] Tue, 06 April 2010 14:21 Go to next message
MaximeLecourt  is currently offline MaximeLecourt Friend
Messages: 108
Registered: February 2010
Location: France
Senior Member
Still trying my m2m transformation with Xtend, I get a problem with types.

Quote:
import metamodel;
import relationnel;

extension metamodel::Extensions reexport;
extension object2relationnal::SQLExtensions reexport;

//takes a Package as parameter, and creating a Database from it
create relationnel::Base transform (metamodel::Package p) :
this.setTables(p.classes().createTable());

// transforms all classes into SQL tables
create relationnel::Table createTable (metamodel::Class c) :
this.setName(c.name) ->
this.setColumn(c.attributs().createColumn());

// create a Column for every attribute which is not a composition or agregation
create relationnel::Column createColumn(metamodel::Attribute a) :
this.setName(a.name) ->
this.setType(a.type.name);


On last line, I get "couldn't find operation 'setType(String)' for type 'relationnel::Column'

But type is an Eattribute of Column, points to Type (abstract), which is either a Domain or a Datatype.
All of those types have only one Eattribute, called name, of type EString (inherited).

So what is wrong ?


One day I shall master M2T, but that day has yet to come...
Re: [Xtend] Wrong parameter type [message #525438 is a reply to message #525412] Tue, 06 April 2010 15:04 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

An EAttribute cannot refer to an EClass, only to EDatatype. If you have the need to refer to another type then ise an EReference instead of EAttribute.

So 'type' in Column should rather be an EReference.

HTH,
~Karsten


Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
icon9.gif  Re: [Xtend] Wrong parameter type [message #525598 is a reply to message #525412] Wed, 07 April 2010 06:21 Go to previous messageGo to next message
MaximeLecourt  is currently offline MaximeLecourt Friend
Messages: 108
Registered: February 2010
Location: France
Senior Member
I'm sorry, I made a dumb mistake writing my former post, type is a EReference, and references Type, it's not a EAttribute.

That is the complete message I get running the workflow.

0    INFO  WorkflowRunner     - --------------------------------------------------------------------------------------
0    INFO  WorkflowRunner     - EMF Modeling Workflow Engine 0.7.2, Build v200908120417
0    INFO  WorkflowRunner     - (c) 2005-2009 openarchitectureware.org and contributors
0    INFO  WorkflowRunner     - --------------------------------------------------------------------------------------
0    INFO  WorkflowRunner     - running workflow: C:/Documents and Settings/Lecourt/workspace/genCPP/src/object2relationnal/m2m.mwe
0    INFO  WorkflowRunner     - 
281  INFO  StandaloneSetup    - Registering platform uri 'C:\Documents and Settings\Lecourt\workspace'
390  INFO  StandaloneSetup    - Adding dynamic EPackage 'http://www.example.org/metamodel' from 'platform:/resource/genCPP/src/metamodel/metamodel.ecore'
390  INFO  StandaloneSetup    - Adding dynamic EPackage 'http://relationnel/1.0' from 'platform:/resource/genCPP/src/metamodel/relationnel.ecore'
484  INFO  CompositeComponent - Reader: Loading model from src/Model.xmi
500  INFO  CompositeComponent - XtendComponent: executing 'object2relationnal::object2relationnal'
812  ERROR AbstractExpressionsUsingWorkflowComponent - Error in Component  of type org.eclipse.xtend.XtendComponent: 
	EvaluationException : Couldn't find operation 'setType(String)' for relationnel::Column.
	object2relationnal::object2relationnal.ext[671,25] on line 19 'this.setType(a.type.name)'   
	object2relationnal::object2relationnal.ext[462,28] on line 14 'c.attributs().createColumn()'
	object2relationnal::object2relationnal.ext[284,25] on line 9 'p.classes().createTable()'    
	nofile[0,16] on line 1 'transform(model)'                                                   

812  ERROR WorkflowRunner     - Workflow interrupted. Reason: Couldn't find operation 'setType(String)' for relationnel::Column.
812  ERROR WorkflowRunner     - [ERROR]: Couldn't find operation 'setType(String)' for relationnel::Column.(Element: this.setType(a.type.name); Reported by: XtendComponent: executing 'object2relationnal::object2relationnal')
812  ERROR WorkflowRunner     - [ERROR]: Couldn't find operation 'setType(String)' for relationnel::Column.(Element: this.setName(a.name)->this.setType(a.type.name); Reported by: XtendComponent: executing 'object2relationnal::object2relationnal')
812  ERROR WorkflowRunner     - [ERROR]: Couldn't find operation 'setType(String)' for relationnel::Column.(Element: c.attributs().createColumn(); Reported by: XtendComponent: executing 'object2relationnal::object2relationnal')
812  ERROR WorkflowRunner     - [ERROR]: Couldn't find operation 'setType(String)' for relationnel::Column.(Element: this.setColumn(c.attributs().createColumn()); Reported by: XtendComponent: executing 'object2relationnal::object2relationnal')
812  ERROR WorkflowRunner     - [ERROR]: Couldn't find operation 'setType(String)' for relationnel::Column.(Element: this.setName(c.name)->this.setColumn(c.attributs().createColumn()); Reported by: XtendComponent: executing 'object2relationnal::object2relationnal')
812  ERROR WorkflowRunner     - [ERROR]: Couldn't find operation 'setType(String)' for relationnel::Column.(Element: p.classes().createTable(); Reported by: XtendComponent: executing 'object2relationnal::object2relationnal')
812  ERROR WorkflowRunner     - [ERROR]: Couldn't find operation 'setType(String)' for relationnel::Column.(Element: this.setTables(p.classes().createTable()); Reported by: XtendComponent: executing 'object2relationnal::object2relationnal')
812  ERROR WorkflowRunner     - [ERROR]: Couldn't find operation 'setType(String)' for relationnel::Column.(Element: transform(model); Reported by: XtendComponent: executing 'object2relationnal::object2relationnal')


Weirdly, since yesterday, when running the workflow messages are in black and no more in red, and are displayed differently than before.


One day I shall master M2T, but that day has yet to come...
Re: [Xtend] Wrong parameter type [message #525606 is a reply to message #525598] Wed, 07 April 2010 07:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hello, when type is a reference to a Type, why do you call setType with a String?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 07 April 2010 07:26]

Report message to a moderator

Re: [Xtend] Wrong parameter type [message #525610 is a reply to message #525606] Wed, 07 April 2010 07:47 Go to previous message
MaximeLecourt  is currently offline MaximeLecourt Friend
Messages: 108
Registered: February 2010
Location: France
Senior Member
I'm only interested in the name of the type.

To simplify modelisation, I created types in my source metamodel (GBool, GInteger, and so on), but I don't need that in my destination model, which I want to use to generate SQL. I only need the name, and with Xpand I'll print the according SQL type in my sql file.

Do you think I should modify my metamodel and have the EReference Type become a EAttribute (which would be a GString) ?

I thought I could just map the types from my source model into a generic Datatype, using type (the EReference) to keep the type, and name to keep (obviously) the name.

So having a GBool called isActive in my source model, in destination model I would get a Column, of type GBool, of name isActive, and I would use that in Xpand to generate my sql file.


I guess I understand where the problem lies, GBool doesn't exist as a type in my destination metamodel. As Type is abstract, and can be a Datatype, or a Domain, I have to think about it again.


One day I shall master M2T, but that day has yet to come...
Re: [Xtend] Wrong parameter type [message #525615 is a reply to message #525598] Wed, 07 April 2010 07:11 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Maxime Lecourt schrieb:
> I'm sorry, I made a dumb mistake writing my former post, type is a
> EReference, and references Type, it's not a EAttribute.

So you can't set a string, because a Type is expected.
But "this.setType(a.type.name)" sets the type's name not the type.

Sven

--
Need professional support for Xtext and EMF?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : blog.efftinge.de
Previous Topic:xpand, xtend help
Next Topic:Workflow Javadoc ?
Goto Forum:
  


Current Time: Sat Apr 20 02:21:28 GMT 2024

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

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

Back to the top