Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [ECL] How to match hierarchical models?
[ECL] How to match hierarchical models? [message #1387578] Wed, 25 June 2014 09:29 Go to next message
Steven te Brinke is currently offline Steven te BrinkeFriend
Messages: 2
Registered: June 2014
Junior Member
Hi,

I want to match two models with ECL, but couldn't figure out how to do it properly, so hopefully someone can help. The basic idea is as follows.

Each model has multiple templates that can be identified by name, so t1 and t2 can be matched using:
compare : t1.name = t2.name


Each template has a list of locations, which can also identified by name, but only within the same template. So my challenge is matching two locations. So l1 and l2 are equal if:
l1.name = l2.name and l1 is part of the same template as l2

However, this last part is hard to check, as the location has no reference to its template. What I thought about was creating a lazy rule that matches locations by name only, and then invoking it from the do-block of the template match. However, that requires to ask for matching all locations in t1.location against all locations in t2.location and I do not know if that is possible. Does anyone know what would be the best way of matching these two models?

Thanks,
Steven
Re: [ECL] How to match hierarchical models? [message #1388375 is a reply to message #1387578] Thu, 26 June 2014 10:49 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi,

You could always write a cached operation that returns a template's location and use it in your condition e.g.

@cached
operation Location getTemplate() : Template {
return Template.all.selectOne(t|t.locations.includes(self));
}

If this is too inefficient, you could populate a map / add an extended property (.~template) to each Location object (see the respective section in the Epsilon book) upfront.

Cheers,
Dimitris
Re: [ECL] How to match hierarchical models? [message #1388449 is a reply to message #1388375] Thu, 26 June 2014 13:13 Go to previous message
Steven te Brinke is currently offline Steven te BrinkeFriend
Messages: 2
Registered: June 2014
Junior Member
Thanks. I was hoping there was a possibility to apply lazy rules selectively, but since that's not the case, an operation is indeed a good solution. I thought about that already, but the elegant cached operation you wrote convinced me this is a good idea, so now it all works.
Previous Topic:[ETL] Modifying referenced model
Next Topic:[EOL] Type not found when using registered EPackage
Goto Forum:
  


Current Time: Fri Apr 26 12:46:51 GMT 2024

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

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

Back to the top