Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Transforming into target structure
Transforming into target structure [message #1860839] Tue, 05 September 2023 17:33 Go to next message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 101
Registered: March 2020
Senior Member
Hello,

I am new to ETL and am currently trying to build a transformation between two languages that I have built. I want to be able to complete a transformation into an already created file with only the model root object existing. And I want all of the transformed object to be under the model root in the target file. How do I build that? I think I'm essentially looking for a way to state as part of the transformation:

target.setContainer = target.ModelRoot

index.php/fa/43477/0/

By extension I may also want to preserve some of the object structure from the source in the target file as well. Haven't tackled that yet but figured they might be similar enough to have similar solutions.

Thanks,
Thomas

[Updated on: Tue, 05 September 2023 17:44]

Report message to a moderator

Re: Transforming into target structure [message #1860840 is a reply to message #1860839] Tue, 05 September 2023 19:39 Go to previous messageGo to next message
Thomas Chiang is currently offline Thomas ChiangFriend
Messages: 101
Registered: March 2020
Senior Member
Digging through the documentation I found the eSet() function. Not sure if I'm heading down the right path but I am currently trying to figure out how to use it in a fashion like this:

target.eSet(container);

The problem that I'm running into is that my there isn't a way to reference the structural feature that is the container from the contained element to define how to set a new container. Any advice would be helpful for how to resolve this reference or set the container of the transformed target to the ModelRoot of the target.
Re: Transforming into target structure [message #1860841 is a reply to message #1860840] Tue, 05 September 2023 21:06 Go to previous message
Horacio Hoyos is currently offline Horacio HoyosFriend
Messages: 242
Registered: October 2009
Location: Mexico
Senior Member

How did you build your languages and/or how are your models persisted? I will assume your models are instances of an Ecore metamodel, i.e. Ecore models. In that case, all the properties of the model elements are accessible via dot notation. For example, if you have two classes in your language:

class A {
  attr String name;
  val B[*] children;
}
class B {
  attr String name;
  attr int age;
}


Then in ETL (or any other Epsilon language) you can use dot notation to access the model element properties:
a.name = "Martin";  // a is an instance of A
b.name = "Juan";  // b is an instance of B
b.age = 13;
a.children.add(b);


Now for the root containment part, in ETL all elements created as part of the "to" statement of the rule are added to the root of output model. So for example:
rule AllBs
  transform b:In!B    // Input model is 'In'
  to x:Out!X  {   // Output model is 'Out'
  
  x.name = a.name;
}

For each instance of B in the input model, a new X will be created in the output model. All the x's will be in the root. If you want a root element to containment, your output models metamodel (language) must have a class that contains x's.
class Root {
  val X[*] under;
}

Then you can do:
rule Root
  transform a:In!A
  to r:Out!Root {
  r.name = a.name;
  r.under.addAll(a.children.equivalents());
}

Several notes here:

  • It assumes the input model has a single 'a' element
  • We use the 'equivalents' operation so that all x's created from b's are added to the root,





Horacio Hoyos Rodriguez
Kinori Tech
Need professional support for Epsilon, EMF?
Go to: https://kinori.tech
Previous Topic:Export model as image using simulink API
Next Topic:Flexmi anonymous root
Goto Forum:
  


Current Time: Sat Apr 27 06:02:08 GMT 2024

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

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

Back to the top