Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » M2M transformation for ENUM
M2M transformation for ENUM [message #1835028] Mon, 23 November 2020 16:29 Go to next message
John Henbergs is currently offline John HenbergsFriend
Messages: 239
Registered: October 2020
Senior Member
Hi all,

I am writing some transformation rules between a UML Profile and XText. This is the ecore for my Xtext
index.php/fa/39393/0/
and this is the ecore for the UML Profile
index.php/fa/39394/0/

This is the tranformation rule I am writing so I can transform from graphical to textual.

rule Graphical2Textual
transform g: coronagraphical!Country
to t: coronatextual!Country

{
t.name = g.name;
t.population = g.population;
t.zone = g.zone;
} 



However, I do believe I will need some sort of rule also for enum, because when I try to run it I get:

The value of type 'class org.eclipse.emf.ecore.impl.EEnumLiteralImpl' must be of type 'org.eclipse.emf.ecore.impl.EEnumImpl@27cd4e69 (name: zonelabelcolour) (instanceClassName: null) (serializable: true)'


Can you help me out with this?

Thank you!
Re: M2M transformation for ENUM [message #1835035 is a reply to message #1835028] Mon, 23 November 2020 17:46 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hello,

ETL does not support transformation rules between enumerations. You will need to use an operation for this e.g.

rule Graphical2Textual
transform g: coronagraphical!Country
to t: coronatextual!Country {
  t.name = g.name;
  t.population = g.population;
  t.zone = g.zone.toContextualZone();
} 

operation Any toContextualZone() {
  if (self == coronagraphical!zonelabel#low) return contextual!zonelabel#low;
  // etc.
}


Thanks,
Dimitris

[Updated on: Mon, 23 November 2020 17:46]

Report message to a moderator

Re: M2M transformation for ENUM [message #1835041 is a reply to message #1835035] Mon, 23 November 2020 20:54 Go to previous messageGo to next message
John Henbergs is currently offline John HenbergsFriend
Messages: 239
Registered: October 2020
Senior Member
Hi Dimitris,

Thank you for your answer. It works perfectly well!

I tried the same thing before but instead of using g.zone.toCoronaTextualzone(), I used g.toCoronaTextualzone(), therefore it was not working.

Many thanks!

Re: M2M transformation for ENUM [message #1835066 is a reply to message #1835041] Tue, 24 November 2020 08:39 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

> I tried the same thing before but instead of using g.zone.toCoronaTextualzone(), I used g.toCoronaTextualzone(), therefore it was not working.

That should also work fine as long as your operation looks like this:

operation coronagraphical!Country toContextualZone() {
  if (self.zone == coronagraphical!zonelabel#low) return contextual!zonelabel#low;
  // etc.
}
Previous Topic:Bag equality implementation seems unintuitive
Next Topic:Containment reference ETL
Goto Forum:
  


Current Time: Thu Apr 25 11:02:19 GMT 2024

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

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

Back to the top