Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Programmatically using EML(How to execute an EML program from standalone Java code)
Programmatically using EML [message #1793148] Tue, 31 July 2018 16:01 Go to next message
Flavio Costa is currently offline Flavio CostaFriend
Messages: 23
Registered: February 2018
Junior Member
Hello,

While I can successfully run ETL programs at runtime from Java code, I realize that that a certain transformation will need two heterogeneous input models to be merged into one, so I'm obviously looking into EML to do that.

From the example [1] on the Epsilon site, I see we may need both an .ecl file and an .eml file. But how do I load and connect these? I could create an instance of EclModule and EmlModule, parse the scripts, but then how do I make EmlModule to use the EclModule? Should I run the comparison, then somehow pass its results as an input model for EmlModule? Can I just share the same ModelRepository?

Thanks,

Flavio
-------------

[1] https://www.eclipse.org/epsilon/examples/index.php?example=org.eclipse.epsilon.examples.mergeentitywithvocabulary
Re: Programmatically using EML [message #1793171 is a reply to message #1793148] Tue, 31 July 2018 21:06 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1613
Registered: July 2009
Location: York, UK
Senior Member

Hi Flavio,

I've just pushed the following example to the Epsilon repo

https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/tree/examples/org.eclipse.epsilon.examples.standalone/src/org/eclipse/epsilon/examples/standalone/eml/EmlStandaloneExample.java

Cheers,
Dimitris
Re: Programmatically using EML [message #1793213 is a reply to message #1793171] Wed, 01 August 2018 14:51 Go to previous messageGo to next message
Flavio Costa is currently offline Flavio CostaFriend
Messages: 23
Registered: February 2018
Junior Member
Dimitris, thanks for putting this up together! This is exactly the line I was looking for:
emlModule.getContext().setMatchTrace(eclModule.getContext().getMatchTrace().getReduced());


However, once I started writing the EML program, I realize I am not sure how to implement exactly what I need to do, or even if EML is the best option to do it. Since it's a bit difficult to create a minimum example to demonstrate the requirement, let me try to explain it here in conceptual terms:

The entities in my models would be "schools", "classrooms" and "persons". I have an Xtext grammar that allows be to specify a school and its classrooms, so these are part of one single model and they are directly related. On each classroom, I have a list of student names that refer to the students that belong to that classroom.

Then I have another model including "persons". If I do person.equivalent(), it would return a Teacher, Student or SchoolStaff object, something that is easy to do with ETL transformations. What I need to have at the end is each classroom with its respective Student instances matched by the person's name, with something like this:

rule MergeClassroomAndPeople
    merge c : Source!Classroom
    with p : Persons!Person
    into r : Target!Room {

    r.type = Target!RoomType#CLASSROOM;
    r.number = r.number;
    r.students = p.equivalents(); // I need several students, not just one!
}

rule ConvertStudent
    transform p : Persons!Person 
    to s: Target!Student {

   s.name = p.name; 
}

rule MatchClassroomWithStudents
    match c : Source!Classroom
    with p : Persons!Person {

    compare : c.studentNames.includes(p.name);
}


How could something like this work? Without testing it, I have the impression that the line I added a comment to does not really do what I would expect.

Also, will the ConvertStudent rule transform all entities in the Persons model into Students? For processing efficiency purposes, I'd prefer that it transforms only the people that are assigned as a student in a classroom, since many records in the Persons model are actually teachers or school staff, so transforming these objects would be useless in this context.

Thanks,

Flavio
Re: Programmatically using EML [message #1793215 is a reply to message #1793213] Wed, 01 August 2018 15:06 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1613
Registered: July 2009
Location: York, UK
Senior Member

Hi Flavio,

Merging classrooms with students doesn't sound right. If looks like your first rule should be a transformation rule from Classrooms to Room and the third statement should be as follows:

r.students = Persons!Person.all.select(p|c.studentNames.includes(p.name)).equivalent();


Cheers,
Dimitris
Previous Topic:Retrieve the Epsilon Simulink preferences programatically
Next Topic:redistribute to non-mde users
Goto Forum:
  


Current Time: Tue Nov 20 08:41:48 GMT 2018

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

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

Back to the top