[ECL] How to match hierarchical models? [message #1387578] |
Wed, 25 June 2014 09:29 |
Steven te Brinke 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 |
|
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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03260 seconds