Slides from my 10-year most influential paper award presentation at ACM/IEEE MoDELS 2016 at St Malo, France. Original paper: http://link.springer.com/chapter/10.1007%2F11880240_16
Merging Models with the Epsilon Merging Language - A Decade Later
1. Merging Models with the
Epsilon Merging Language
– A Decade Later
Dimitris Kolovos, Richard Paige, and Fiona Polack
Department of Computer Science
University of York
firstname.lastname@york.ac.uk
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 1/23
2. Ambition (in 2004)
Develop a hybrid textual language for model merging
In the same way that ATL targeted M2M, OCL targeted model
validation etc.
Desirable features
Expressiveness
Metamodel and modelling-technology independence
Support for merging heterogeneous models
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 2/23
3. First Steps (2004–2005)
Started with a version of the OCL grammar (ANTLR) and
extended it with merging-specific syntax
Wrote an interpreter for the AST
Introduced an abstraction layer for modelling technologies
Implemented the abstraction layer for the NetBeans MetaData
Repository (MDR) – MOF 1.4
Implemented the first version of EML’s Eclipse-based
development tools
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 3/23
8. Merging Process
Focused on 2-way merging
Steps
1 Establish correspondences between elements in the two models
2 Merge matching elements (optional)
3 Transform non-matching elements (optional)
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 7/23
9. Matching Elements
Notes
We establish correspondences based on national insurance
number matching
List!Person means: type “Person” from model “List”
Inspired by ATL
rule MatchPersonWithTaxPayer
match p : List!Person
with tp : HMRC!TaxPayer {
compare: (p.country = "UK") and (p.taxId = tp.nin)
}
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 8/23
10. Merging Elements
Notes
We merge matched Persons with their corresponding
TaxPayers and produce (notification) Letters as output
We don’t want to bother those whose incomes match
rule DiscrepancyLetter
merge p : List!Person
with tp : HMRC!TaxPayer
into l : Outbox!Letter {
guard: tp.declaredIncome <> p.income
l.address = tp.address;
l.text = "Dear " + p.name + ", ";
if (p.income > tp.declaredIncome) {
l.text += "you are doomed.";
}
else { l.text += "we love you."; }
}
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 9/23
11. Transforming Unmatched Elements
Notes
Unmatched Person elements from the UK means non-existing
national insurance numbers (i.e. fraud!)
rule FraudLetter
transform p : List!Person
into l : Outbox!Letter {
guard: p.country == "UK"
l.address = p.address;
l.text = "You are doomed beyond imagination.";
}
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 10/23
12. Modularisation
An EML program consists of
Matching rules
Merging rules
Transformation rules
These are three different languages!
. . . which share a common OCL-based imperative expression
language, model connectivity facilities etc.
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 11/23
13. Modularisation
An EML program consists of
Matching rules
Merging rules
Transformation rules
These are three four different languages!
. . . which share model connectivity facilities etc.
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 11/23
16. Eclipse Modeling Project
Epsilon joined the Eclipse Modeling GMT incubator in 2006
Graduated (v1.0) in 2012
Currently in v1.3 (v1.4 approved yesterday)
Substantial boost to adoption
≈ 8,000 forum posts since 2008
In open-source projects and in industry
To teach modelling and MDE courses
http://eclipse.org/epsilon/users
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 13/23
18. Epsilon Validation Language (EVL)
context List!Person {
constraint MatchingIncome {
// Won’t be evaluated if ValidNin is not satisfied
guard : self.satisfies("ValidNin")
check {
var taxPayer = HMRC!TaxPayer.all.
selectOne(tp|self.taxId = tp.nin);
return taxPayer.declaredIncome = self.income;
}
message : "Mismatching income: " + self.income
+ "<>" + taxPayer.declaredIncome
}
}
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 16/23
19. Epsilon Generation Language (EGL)
Key capabilities
Template-based M2T language
Separate sub-language for rule-based template coordination
Support for hand-written code in generated files
rule EClass2DBClass
transform c : EClass {
guard : c.isAnnotatedAs("db")
template : "eclass2dbclass.egl"
target : c.name + ".java"
}
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 17/23
20. Epsilon Generation Language (EGL)
[%for (f in c.eStructuralFeatures.select(f|f.isMany)) { %]
protected List<[%=f.eType.getJavaBoxedName()%]>
[%=sf.name%] = null;
[%}%]
[%for (r in c.eReferences.select(r|not r.isMany)) { %]
protected [%=r.eType.getJavaName()%] [%=r.name%] = null;
[%}%]
[%if (c.isAnnotatedAs("customize")){%]
[% out.setContentType("Java"); %]
// protected region custom-fields-and-methods on begin
// protected region custom-fields-and-methods end
[%}%]
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 18/23
21. Epsilon Pattern Language (EPL)
Key capabilities
Textual language for model pattern matching
In-place transformation capabilities
Matches exposed as a “virtual” model
patterns → types, matches → elements, roles → properties
pattern PublicField
class : ClassDeclaration,
field : FieldDeclaration from: class.bodyDeclarations,
setter : MethodDeclaration from: class.bodyDeclarations
guard: setter.name = "set" + field.getName(),
getter : MethodDeclaration from: class.bodyDeclarations
guard : (getter.name = "get" + field.getName()
or getter.name = "is" + field.getName()) { }
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 19/23
22. Epsilon Pattern Language (EPL)
context Patterns!PublicField {
constraint GetterAndFieldSameType {
check : self.getter.returnType.type =
self.field.type.type
message : "The getter of " + self.class.name +
"." + self.field.fragments.at(0).name +
" does not have the same type as" +
" the field itself"
}
}
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 20/23
23. Epsilon (2004 - 2016)
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 21/23
24. Epsilon (2004 - 2016)
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 21/23
25. Epsilon (2004 - 2016)
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 21/23
26. Reflection
EML was the first language tailored for model merging
The 2006 MoDELS paper made the case for non-trivial
merging of heterogeneous models
EML was the seed from which Epsilon eventually grew
EML is too verbose for merging homogeneous models
. . . although homogeneous merging strategies can be trivially
generated using HOTs
EML turned out to be one of the least popular languages in
Epsilon
Little practical need for complex model merging?
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 22/23
27. Looking Ahead
Incrementality
Prototype for EGL → Robust implementation across Epsilon
User experience
Code completion, refactoring etc.
Integration
Enterprise Architect, MagicDraw etc.
Optimisation
e.g. technology-specific implementations of select() to avoid
naive iteration and use indexes instead
D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 23/23