27
Merging Models with the Epsilon Merging Language – A Decade Later Dimitris Kolovos, Richard Paige, and Fiona Polack Department of Computer Science University of York [email protected] D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 1/23

Merging Models with the Epsilon Merging Language - A Decade Later

Embed Size (px)

Citation preview

Page 1: Merging Models with the Epsilon Merging Language - A Decade Later

Merging Models with theEpsilon Merging Language

– A Decade Later

Dimitris Kolovos, Richard Paige, and Fiona Polack

Department of Computer ScienceUniversity of York

[email protected]

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 1/23

Page 2: Merging Models with the Epsilon Merging Language - A Decade Later

Ambition (in 2004)

Develop a hybrid textual language for model mergingIn the same way that ATL targeted M2M, OCL targeted modelvalidation etc.

Desirable featuresExpressivenessMetamodel and modelling-technology independenceSupport for merging heterogeneous models

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 2/23

Page 3: Merging Models with the Epsilon Merging Language - A Decade Later

First Steps (2004–2005)

Started with a version of the OCL grammar (ANTLR) andextended it with merging-specific syntaxWrote an interpreter for the ASTIntroduced an abstraction layer for modelling technologies

Implemented the abstraction layer for the NetBeans MetaDataRepository (MDR) – MOF 1.4

Implemented the first version of EML’s Eclipse-baseddevelopment tools

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 3/23

Page 4: Merging Models with the Epsilon Merging Language - A Decade Later
Page 5: Merging Models with the Epsilon Merging Language - A Decade Later

Heterogeneous Model Merging?

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 5/23

Page 6: Merging Models with the Epsilon Merging Language - A Decade Later

Heterogeneous Model Merging?

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 6/23

Page 7: Merging Models with the Epsilon Merging Language - A Decade Later

Heterogeneous Model Merging?

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 6/23

Page 8: Merging Models with the Epsilon Merging Language - A Decade Later

Merging Process

Focused on 2-way mergingSteps

1 Establish correspondences between elements in the two models2 Merge matching elements (optional)3 Transform non-matching elements (optional)

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 7/23

Page 9: Merging Models with the Epsilon Merging Language - A Decade Later

Matching Elements

NotesWe establish correspondences based on national insurancenumber matchingList!Person means: type “Person” from model “List”

Inspired by ATL

rule MatchPersonWithTaxPayermatch p : List!Personwith 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

Page 10: Merging Models with the Epsilon Merging Language - A Decade Later

Merging Elements

NotesWe merge matched Persons with their correspondingTaxPayers and produce (notification) Letters as outputWe don’t want to bother those whose incomes match

rule DiscrepancyLettermerge p : List!Personwith tp : HMRC!TaxPayerinto 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

Page 11: Merging Models with the Epsilon Merging Language - A Decade Later

Transforming Unmatched Elements

NotesUnmatched Person elements from the UK means non-existingnational insurance numbers (i.e. fraud!)

rule FraudLettertransform p : List!Personinto 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

Page 12: Merging Models with the Epsilon Merging Language - A Decade Later

Modularisation

An EML program consists ofMatching rulesMerging rulesTransformation rules

These are three different languages!. . . which share a common OCL-based imperative expressionlanguage, model connectivity facilities etc.

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 11/23

Page 13: Merging Models with the Epsilon Merging Language - A Decade Later

Modularisation

An EML program consists ofMatching rulesMerging rulesTransformation 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

Page 14: Merging Models with the Epsilon Merging Language - A Decade Later

Modularisation (2006)

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 12/23

Page 15: Merging Models with the Epsilon Merging Language - A Decade Later

Modularisation (2006)

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 12/23

Page 16: Merging Models with the Epsilon Merging Language - A Decade Later

Eclipse Modeling Project

Epsilon joined the Eclipse Modeling GMT incubator in 2006Graduated (v1.0) in 2012

Currently in v1.3 (v1.4 approved yesterday)Substantial boost to adoption

≈ 8,000 forum posts since 2008In open-source projects and in industryTo teach modelling and MDE courseshttp://eclipse.org/epsilon/users

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 13/23

Page 17: Merging Models with the Epsilon Merging Language - A Decade Later

Epsilon Validation Language (EVL)

Key capabilitiesHuman-readable messagesConstraint dependenciesQuick fixes

context List!Person {

constraint ValidNin {

guard : self.country = "UK"

check : HMRC!TaxPayer.all.exists(tp|self.taxId = tp.nin)

message : "Unknown National Insurance Number: " +self.taxId

}}

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 15/23

Page 18: Merging Models with the Epsilon Merging Language - A Decade Later

Epsilon Validation Language (EVL)

context List!Person {

constraint MatchingIncome {

// Won’t be evaluated if ValidNin is not satisfiedguard : 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

Page 19: Merging Models with the Epsilon Merging Language - A Decade Later

Epsilon Generation Language (EGL)

Key capabilitiesTemplate-based M2T languageSeparate sub-language for rule-based template coordinationSupport for hand-written code in generated files

rule EClass2DBClasstransform 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

Page 20: Merging Models with the Epsilon Merging Language - A Decade Later

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

Page 21: Merging Models with the Epsilon Merging Language - A Decade Later

Epsilon Pattern Language (EPL)

Key capabilitiesTextual language for model pattern matchingIn-place transformation capabilitiesMatches exposed as a “virtual” model

patterns → types, matches → elements, roles → properties

pattern PublicFieldclass : ClassDeclaration,

field : FieldDeclaration from: class.bodyDeclarations,

setter : MethodDeclaration from: class.bodyDeclarationsguard: setter.name = "set" + field.getName(),

getter : MethodDeclaration from: class.bodyDeclarationsguard : (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

Page 22: Merging Models with the Epsilon Merging Language - A Decade Later

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

Page 23: Merging Models with the Epsilon Merging Language - A Decade Later

Epsilon (2004 - 2016)

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 21/23

Page 24: Merging Models with the Epsilon Merging Language - A Decade Later

Epsilon (2004 - 2016)

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 21/23

Page 25: Merging Models with the Epsilon Merging Language - A Decade Later

Epsilon (2004 - 2016)

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 21/23

Page 26: Merging Models with the Epsilon Merging Language - A Decade Later

Reflection

EML was the first language tailored for model mergingThe 2006 MoDELS paper made the case for non-trivialmerging of heterogeneous modelsEML was the seed from which Epsilon eventually grew

EML is too verbose for merging homogeneous models. . . although homogeneous merging strategies can be triviallygenerated using HOTs

EML turned out to be one of the least popular languages inEpsilon

Little practical need for complex model merging?

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 22/23

Page 27: Merging Models with the Epsilon Merging Language - A Decade Later

Looking Ahead

IncrementalityPrototype for EGL → Robust implementation across Epsilon

User experienceCode completion, refactoring etc.

IntegrationEnterprise Architect, MagicDraw etc.

Optimisatione.g. technology-specific implementations of select() to avoidnaive iteration and use indexes instead

D. Kolovos et. al. – ACM/IEEE MoDELS 2016 October 6, 2016 – Slide 23/23