SlideShare a Scribd company logo
Model Manipulation
Using Embedded DSLs
in Scala
Filip Křikava
I3S laboratory, Université Nice Sophia-Antipolis
Scala Workshop 2013, Montpellier, 2.7.2013
Context
Model Manipulation
• Essential in Model-Driven Engineering (MDE)
• Automating operations such as
• model consistency checking
• model-to-model transformation (M2M)
• model-to-text transformation (M2T)
Approaches in
http://eclipse.org/modeling/
GPL external DSL
M2M
transformation
QVT
ETL
Kermeta
ATL
Model consistency
checking
OCL
EVL
Kermeta
M2T
transformation
MOFM2T
EGL
Kermeta
Xpand
Issues
✓ Versatility
✓ Tool support
✓ Performance
✓ Integration
✗ Limited tool support
✗ Limited performance
✗ Limited versatility (fall back to Java)
✗ Limited interoperability
✓ High level of abstraction
✓ Expressiveness and ease of use
✓ Domain-specific error checking and
optimizations
✗ Low level of abstraction
✗ Limited expressiveness (lack of
functional aspects in the language)
✗ Limited domain-specific error
checking and optimizations
= giving raise to accidental complexities, albeit of a different nature.
QVT
ETL
ATL
OCL
EVL
Kermeta
MOFM2T
EGL
Xpand
Towards Embedded DSLs
• External model manipulation DSLs
• embed general-purpose programming constructs into a specific
model-manipulation DSL
Towards Embedded DSLs
• External model manipulation DSLs
• embed general-purpose programming constructs into a specific
model-manipulation DSL
• We explore Internal / embedded model manipulation DSLs, that
• embed domain-specific model manipulation constructs into a
GPL
• aiming at
• similar features and expressiveness
• increased versatility
• improved tool support
• with significantly reduced engineering effort
Quick Example
Model Consistency Checking
Checking Library books’ ISBN codes.
context Book:
invariant UniqueISBN:
self.library.books->forAll(book |
book <> self implies book.isbn <> self.isbn);
OCL
Quick Example
Model Consistency Checking
Checking Library books’ ISBN codes.
✓ Tool support (rich editor, debugger)
✓ Unit testing
✓ Invariant inheritance
✓ Integration (build tools, workflows)
context Book:
invariant UniqueISBN:
self.library.books->forAll(book |
book <> self implies book.isbn <> self.isbn);
OCL
class BookContext extends ValidationContext
with BookPackageScalaSupport {
type Self = Class
def invUniqueISBN =
self.library.books forall { book =>
book != self implies book.isbn != self.isbn
}
}
Scala
Common Infrastructure Support
• Navigation
• Modification
self.getLibrary().getIsbn() self.library.isbn
self.library.books collect {
case Book(title, Author(author),_,_,_,_) => (title, author)
}
val sicp = Book(name = "SICP", copies = 2)
sicp.author = library.authors find (_.name == "H. Abelson")
with LibraryPackageScalaSupport
• Generate a Scala support trait for each EMF package
• Improving null handling
• Multiplicity 0..1 is wrapped into Option[T]
Model Consistency Checking
def invHasCapitalizedName =
// guards
guardedBy {
// invariant dependency
self satisfies invHasNonEmptyName
} check {
if (self.name.split(" ") forall (_(0).isUpper)) {
Passed
} else {
// detailed error messages
Error(s"Book ${self.name} does not have capitalized name")
// with quick fixes
.quickFix("Capitalize book name") {
self.name = self.name.split(" ") map (_.capitalize) mkString (" ")
}
}
}
✓ Context and invariant guards
✓ User feedback including quick fixes
✓ Invariant inheritance, modularity
✓ Different levels of severity
M2M Transformation
class OO2DB extends M2M with OOPackageScalaSupport with DBPackageScalaSupport {
def ruleClass2Table(cls: Class, tab: Table, pkey: Column) {
tab.name = cls.name;
tab.columns += pkey
tab.columns ++= ~cls.properties
pkey.name = "Id"
pkey.dataType = "Int"
}
@Lazy
def ruleProperty2Column(prop: Property, col: Column) = guardedBy {
!prop.multi
} transform {
col.name = prop.name
col.dataType = prop.type_.name
}
}
Simple object-oriented model into relational model
✓ Hybrid M2M transformation
✓ Rule inheritance, modularity
✓ Matched rules, lazy rules, partial rules
✓ Unit testing
M2M Transformation
class OO2DB extends M2M with OOPackageScalaSupport with DBPackageScalaSupport {
def ruleClass2Table(cls: Class, tab: Table, pkey: Column) {
tab.name = cls.name;
tab.columns += pkey
tab.columns ++= ~cls.properties
pkey.name = "Id"
pkey.dataType = "Int"
}
@Lazy
def ruleProperty2Column(prop: Property, col: Column) = guardedBy {
!prop.multi
} transform {
col.name = prop.name
col.dataType = prop.type_.name
}
}
Simple object-oriented model into relational model
✓ Hybrid M2M transformation
✓ Rule inheritance, modularity
✓ Matched rules, lazy rules, partial rules
✓ Unit testing
M2M Transformation
class OO2DB extends M2M with OOPackageScalaSupport with DBPackageScalaSupport {
def ruleClass2Table(cls: Class, tab: Table, pkey: Column) {
tab.name = cls.name;
tab.columns += pkey
tab.columns ++= ~cls.properties
pkey.name = "Id"
pkey.dataType = "Int"
}
@Lazy
def ruleProperty2Column(prop: Property, col: Column) = guardedBy {
!prop.multi
} transform {
col.name = prop.name
col.dataType = prop.type_.name
}
}
Executes
Simple object-oriented model into relational model
✓ Hybrid M2M transformation
✓ Rule inheritance, modularity
✓ Matched rules, lazy rules, partial rules
✓ Unit testing
M2T Transformation
class OO2Java extends M2T with OOPackageScalaSupport {
type Root = Class // input type for this transformation
def main =
!s"public class ${root.name}" curlyIndent {
!endl // extra new line
for (o <- root.operations) {
genOperation(o)
!endl // extra new line
}
}
def genOperation(o: Operation) =
!s"public ${o.returnType.name} ${o.name}()" curlyIndent {
!s"""
// TODO: should be implemented
throw new UnsupportedOperationException("${o.name}");
"""
}
}
Simple object-oriented model into Java code
✓ Template based, code-centric M2T
✓ Template inheritance, modularity
✓ Smart white space handling
✓ Unit testing
Further Work
Beyond Shallow Embedding
• Using Scala facilities for deep embedding
• scala-virtualized https://github.com/TiarkRompf/scala-virtualized
• lightweight modular staging http://scala-lms.github.io/
• For
• formal analysis
• domain-specific error checking
• domain-specific optimization
Further Work
Formal Reasoning
• Translating invariant expression into first-order logic
• To check invariant unsatisfiability1
library.books exists { book => book.pages > 300 }
library.books forall { book => book.pages < 300 }
1Clavel, M., Egea, M., Garcia de Dios, M.A. (2009) Checking unsatisfiability for OCL constraints. OCL Workshop,
MODELS 2009
• Automatic verification using SMT solvers
Further Work
Domain-Specific error checking
• Using ~ without corresponding rule yields compile time error
@implicitNotFound("No conversion rule between ${Source} and ${Target}.")
trait Rule[S <: EObject, T <: EObject]
implicit class EListM2MSupport[A <: EObject: ClassTag](that: EList[A]) {
def unary_~[B <: EObject](implicit rule: Rule[A, B]) = // ...
}
implicit val _ruleClass2Table = rule(ruleClass2Table _)
Further Work
Faster M2M Transformations
Translate declarative rules into imperative code
source.eAllContents collect {
case x: Class ⇒
ruleClass2Table(x, create[Table], create[Column])
case x: Property ⇒
ruleProperty2Column4(x, create[Column])
case x =>
logger warn (s"No rule to transform ${x}.")
}
class OO2DB extends M2M with OOPackageScalaSupport with DBPackageScalaSupport {
def ruleClass2Table(cls: Class, tab: Table, pkey: Column)
def ruleProperty2Column(prop: Property, col: Column)
}
Further Work
Even Faster M2M Transformations
Translate declarative rules into imperative code
class OO2DB extends M2M with OOPackageScalaSupport with DBPackageScalaSupport {
def ruleClass2Table(cls: Class, tab: Table, pkey: Column)
def ruleProperty2Column(prop: Property, col: Column)
}
val it = source.eAllContents
while (it.hasNext) {
val x = it.next
if (x.isInstanceOf[Class])
ruleClass2Table(x.asInstanceOf[Class], create[Table], create[Column])
else if (x.isInstanceOf[Property])
ruleProperty2Column4(x.asInstanceOf[Property], create[Column])
else
logger warn (s"No rule to transfrom ${x}.")
}
ThankYou
Filip Křikava
filip.krikava@i3s.unice.fr
https://fikovnik.github.io/Sigma
The work is partly funded by the ANR SALTY project under contract ANR-09-SEGI-012.
https://salty.unice.fr

More Related Content

PDF
You need to extend your models? EMF Facet vs. EMF Profiles
PPTX
OCL in EMF
ODP
Enrich Your Models With OCL
PDF
Clojure - An Introduction for Java Programmers
PDF
PDF
A Brief, but Dense, Intro to Scala
PDF
Clojure talk at Münster JUG
ODP
Refactoring to Scala DSLs and LiftOff 2009 Recap
You need to extend your models? EMF Facet vs. EMF Profiles
OCL in EMF
Enrich Your Models With OCL
Clojure - An Introduction for Java Programmers
A Brief, but Dense, Intro to Scala
Clojure talk at Münster JUG
Refactoring to Scala DSLs and LiftOff 2009 Recap

What's hot (18)

PDF
The Evolution of Scala / Scala進化論
PPT
Oscon keynote: Working hard to keep it simple
PDF
Scala eXchange opening
PDF
Clojure A Dynamic Programming Language for the JVM
PDF
Build Cloud Applications with Akka and Heroku
PPTX
Scala, Play 2.0 & Cloud Foundry
PPTX
Core java
PDF
Clojure - An Introduction for Lisp Programmers
PPT
Core java
PDF
scalaliftoff2009.pdf
PPT
Java Tutorial
PPTX
Introduction to java 101
PDF
camel-scala.pdf
PPT
Scala Talk at FOSDEM 2009
PDF
Java Course 7: Text processing, Charsets & Encodings
PDF
Scala, Akka, and Play: An Introduction on Heroku
PDF
Ppl for students unit 4 and 5
PPT
Presentation on java
The Evolution of Scala / Scala進化論
Oscon keynote: Working hard to keep it simple
Scala eXchange opening
Clojure A Dynamic Programming Language for the JVM
Build Cloud Applications with Akka and Heroku
Scala, Play 2.0 & Cloud Foundry
Core java
Clojure - An Introduction for Lisp Programmers
Core java
scalaliftoff2009.pdf
Java Tutorial
Introduction to java 101
camel-scala.pdf
Scala Talk at FOSDEM 2009
Java Course 7: Text processing, Charsets & Encodings
Scala, Akka, and Play: An Introduction on Heroku
Ppl for students unit 4 and 5
Presentation on java
Ad

Viewers also liked (14)

PDF
A Self-Adaptive Evolutionary Negative Selection Approach for Anom
PDF
Unisys Service Oriented Self Adaptive Systems
PDF
Self-Adaptive Federated Authorisation Infrastructures
PDF
ACTRESS: Domain-Specific Modeling of Self-Adaptive Software Architectures
PDF
Intensive Surrogate Model Exploitation in Self-adaptive Surrogate-assisted CM...
PDF
PhD Thesis Defense
PDF
Domain specific languages and Scala
PPT
Hausi Müller - Towards Self-Adaptive Software-Intensive Systems
PDF
A Self-Adaptive Deployment Framework for Service-Oriented Systems
PDF
Do Search-Based Approaches Improve the Design of Self-Adaptive Systems ? A Co...
PDF
Architectural Design Spaces for Feedback Control in Self-Adaptive Systems Con...
PPTX
Self-Adaptive SLA-Driven Capacity Management for Internet Services
PDF
201209 An Introduction to Building Affective-Driven Self-Adaptive Software
PDF
Self-adaptive Systems : An Introduction
A Self-Adaptive Evolutionary Negative Selection Approach for Anom
Unisys Service Oriented Self Adaptive Systems
Self-Adaptive Federated Authorisation Infrastructures
ACTRESS: Domain-Specific Modeling of Self-Adaptive Software Architectures
Intensive Surrogate Model Exploitation in Self-adaptive Surrogate-assisted CM...
PhD Thesis Defense
Domain specific languages and Scala
Hausi Müller - Towards Self-Adaptive Software-Intensive Systems
A Self-Adaptive Deployment Framework for Service-Oriented Systems
Do Search-Based Approaches Improve the Design of Self-Adaptive Systems ? A Co...
Architectural Design Spaces for Feedback Control in Self-Adaptive Systems Con...
Self-Adaptive SLA-Driven Capacity Management for Internet Services
201209 An Introduction to Building Affective-Driven Self-Adaptive Software
Self-adaptive Systems : An Introduction
Ad

Similar to Model Manipulation Using Embedded DSLs in Scala (20)

PPTX
Taxonomy of Scala
PDF
Introducing BoxLang : A new JVM language for productivity and modularity!
PPTX
Distributed Model Validation with Epsilon
PPTX
How Scala promotes TDD
PDF
scalaliftoff2009.pdf
PDF
scalaliftoff2009.pdf
PDF
scalaliftoff2009.pdf
PDF
JRuby e DSL
PDF
Scala for Java Programmers
PDF
BoxLang JVM Language : The Future is Dynamic
PDF
Groovy concurrency
KEY
The Why and How of Scala at Twitter
PPTX
Testing in Scala. Adform Research
PPTX
Testing in Scala by Adform research
PDF
MT_LinqXml _Introduce Linq to XML and Application.pdf
PDF
Beyond Map/Reduce: Getting Creative With Parallel Processing
PPTX
Scala Up North: "Analysing Scala Puzzlers: Essential and Accidental Complexit...
PPTX
BASE Meetup: "Analysing Scala Puzzlers: Essential and Accidental Complexity i...
PPT
Scala Days San Francisco
Taxonomy of Scala
Introducing BoxLang : A new JVM language for productivity and modularity!
Distributed Model Validation with Epsilon
How Scala promotes TDD
scalaliftoff2009.pdf
scalaliftoff2009.pdf
scalaliftoff2009.pdf
JRuby e DSL
Scala for Java Programmers
BoxLang JVM Language : The Future is Dynamic
Groovy concurrency
The Why and How of Scala at Twitter
Testing in Scala. Adform Research
Testing in Scala by Adform research
MT_LinqXml _Introduce Linq to XML and Application.pdf
Beyond Map/Reduce: Getting Creative With Parallel Processing
Scala Up North: "Analysing Scala Puzzlers: Essential and Accidental Complexit...
BASE Meetup: "Analysing Scala Puzzlers: Essential and Accidental Complexity i...
Scala Days San Francisco

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Empathic Computing: Creating Shared Understanding
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Encapsulation theory and applications.pdf
PPT
Teaching material agriculture food technology
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Machine learning based COVID-19 study performance prediction
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation_ Review paper, used for researhc scholars
Per capita expenditure prediction using model stacking based on satellite ima...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Chapter 3 Spatial Domain Image Processing.pdf
Spectroscopy.pptx food analysis technology
MYSQL Presentation for SQL database connectivity
Encapsulation theory and applications.pdf
Teaching material agriculture food technology
Review of recent advances in non-invasive hemoglobin estimation
Mobile App Security Testing_ A Comprehensive Guide.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
20250228 LYD VKU AI Blended-Learning.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Model Manipulation Using Embedded DSLs in Scala

  • 1. Model Manipulation Using Embedded DSLs in Scala Filip Křikava I3S laboratory, Université Nice Sophia-Antipolis Scala Workshop 2013, Montpellier, 2.7.2013
  • 2. Context Model Manipulation • Essential in Model-Driven Engineering (MDE) • Automating operations such as • model consistency checking • model-to-model transformation (M2M) • model-to-text transformation (M2T)
  • 3. Approaches in http://eclipse.org/modeling/ GPL external DSL M2M transformation QVT ETL Kermeta ATL Model consistency checking OCL EVL Kermeta M2T transformation MOFM2T EGL Kermeta Xpand
  • 4. Issues ✓ Versatility ✓ Tool support ✓ Performance ✓ Integration ✗ Limited tool support ✗ Limited performance ✗ Limited versatility (fall back to Java) ✗ Limited interoperability ✓ High level of abstraction ✓ Expressiveness and ease of use ✓ Domain-specific error checking and optimizations ✗ Low level of abstraction ✗ Limited expressiveness (lack of functional aspects in the language) ✗ Limited domain-specific error checking and optimizations = giving raise to accidental complexities, albeit of a different nature. QVT ETL ATL OCL EVL Kermeta MOFM2T EGL Xpand
  • 5. Towards Embedded DSLs • External model manipulation DSLs • embed general-purpose programming constructs into a specific model-manipulation DSL
  • 6. Towards Embedded DSLs • External model manipulation DSLs • embed general-purpose programming constructs into a specific model-manipulation DSL • We explore Internal / embedded model manipulation DSLs, that • embed domain-specific model manipulation constructs into a GPL • aiming at • similar features and expressiveness • increased versatility • improved tool support • with significantly reduced engineering effort
  • 7. Quick Example Model Consistency Checking Checking Library books’ ISBN codes. context Book: invariant UniqueISBN: self.library.books->forAll(book | book <> self implies book.isbn <> self.isbn); OCL
  • 8. Quick Example Model Consistency Checking Checking Library books’ ISBN codes. ✓ Tool support (rich editor, debugger) ✓ Unit testing ✓ Invariant inheritance ✓ Integration (build tools, workflows) context Book: invariant UniqueISBN: self.library.books->forAll(book | book <> self implies book.isbn <> self.isbn); OCL class BookContext extends ValidationContext with BookPackageScalaSupport { type Self = Class def invUniqueISBN = self.library.books forall { book => book != self implies book.isbn != self.isbn } } Scala
  • 9. Common Infrastructure Support • Navigation • Modification self.getLibrary().getIsbn() self.library.isbn self.library.books collect { case Book(title, Author(author),_,_,_,_) => (title, author) } val sicp = Book(name = "SICP", copies = 2) sicp.author = library.authors find (_.name == "H. Abelson") with LibraryPackageScalaSupport • Generate a Scala support trait for each EMF package • Improving null handling • Multiplicity 0..1 is wrapped into Option[T]
  • 10. Model Consistency Checking def invHasCapitalizedName = // guards guardedBy { // invariant dependency self satisfies invHasNonEmptyName } check { if (self.name.split(" ") forall (_(0).isUpper)) { Passed } else { // detailed error messages Error(s"Book ${self.name} does not have capitalized name") // with quick fixes .quickFix("Capitalize book name") { self.name = self.name.split(" ") map (_.capitalize) mkString (" ") } } } ✓ Context and invariant guards ✓ User feedback including quick fixes ✓ Invariant inheritance, modularity ✓ Different levels of severity
  • 11. M2M Transformation class OO2DB extends M2M with OOPackageScalaSupport with DBPackageScalaSupport { def ruleClass2Table(cls: Class, tab: Table, pkey: Column) { tab.name = cls.name; tab.columns += pkey tab.columns ++= ~cls.properties pkey.name = "Id" pkey.dataType = "Int" } @Lazy def ruleProperty2Column(prop: Property, col: Column) = guardedBy { !prop.multi } transform { col.name = prop.name col.dataType = prop.type_.name } } Simple object-oriented model into relational model ✓ Hybrid M2M transformation ✓ Rule inheritance, modularity ✓ Matched rules, lazy rules, partial rules ✓ Unit testing
  • 12. M2M Transformation class OO2DB extends M2M with OOPackageScalaSupport with DBPackageScalaSupport { def ruleClass2Table(cls: Class, tab: Table, pkey: Column) { tab.name = cls.name; tab.columns += pkey tab.columns ++= ~cls.properties pkey.name = "Id" pkey.dataType = "Int" } @Lazy def ruleProperty2Column(prop: Property, col: Column) = guardedBy { !prop.multi } transform { col.name = prop.name col.dataType = prop.type_.name } } Simple object-oriented model into relational model ✓ Hybrid M2M transformation ✓ Rule inheritance, modularity ✓ Matched rules, lazy rules, partial rules ✓ Unit testing
  • 13. M2M Transformation class OO2DB extends M2M with OOPackageScalaSupport with DBPackageScalaSupport { def ruleClass2Table(cls: Class, tab: Table, pkey: Column) { tab.name = cls.name; tab.columns += pkey tab.columns ++= ~cls.properties pkey.name = "Id" pkey.dataType = "Int" } @Lazy def ruleProperty2Column(prop: Property, col: Column) = guardedBy { !prop.multi } transform { col.name = prop.name col.dataType = prop.type_.name } } Executes Simple object-oriented model into relational model ✓ Hybrid M2M transformation ✓ Rule inheritance, modularity ✓ Matched rules, lazy rules, partial rules ✓ Unit testing
  • 14. M2T Transformation class OO2Java extends M2T with OOPackageScalaSupport { type Root = Class // input type for this transformation def main = !s"public class ${root.name}" curlyIndent { !endl // extra new line for (o <- root.operations) { genOperation(o) !endl // extra new line } } def genOperation(o: Operation) = !s"public ${o.returnType.name} ${o.name}()" curlyIndent { !s""" // TODO: should be implemented throw new UnsupportedOperationException("${o.name}"); """ } } Simple object-oriented model into Java code ✓ Template based, code-centric M2T ✓ Template inheritance, modularity ✓ Smart white space handling ✓ Unit testing
  • 15. Further Work Beyond Shallow Embedding • Using Scala facilities for deep embedding • scala-virtualized https://github.com/TiarkRompf/scala-virtualized • lightweight modular staging http://scala-lms.github.io/ • For • formal analysis • domain-specific error checking • domain-specific optimization
  • 16. Further Work Formal Reasoning • Translating invariant expression into first-order logic • To check invariant unsatisfiability1 library.books exists { book => book.pages > 300 } library.books forall { book => book.pages < 300 } 1Clavel, M., Egea, M., Garcia de Dios, M.A. (2009) Checking unsatisfiability for OCL constraints. OCL Workshop, MODELS 2009 • Automatic verification using SMT solvers
  • 17. Further Work Domain-Specific error checking • Using ~ without corresponding rule yields compile time error @implicitNotFound("No conversion rule between ${Source} and ${Target}.") trait Rule[S <: EObject, T <: EObject] implicit class EListM2MSupport[A <: EObject: ClassTag](that: EList[A]) { def unary_~[B <: EObject](implicit rule: Rule[A, B]) = // ... } implicit val _ruleClass2Table = rule(ruleClass2Table _)
  • 18. Further Work Faster M2M Transformations Translate declarative rules into imperative code source.eAllContents collect { case x: Class ⇒ ruleClass2Table(x, create[Table], create[Column]) case x: Property ⇒ ruleProperty2Column4(x, create[Column]) case x => logger warn (s"No rule to transform ${x}.") } class OO2DB extends M2M with OOPackageScalaSupport with DBPackageScalaSupport { def ruleClass2Table(cls: Class, tab: Table, pkey: Column) def ruleProperty2Column(prop: Property, col: Column) }
  • 19. Further Work Even Faster M2M Transformations Translate declarative rules into imperative code class OO2DB extends M2M with OOPackageScalaSupport with DBPackageScalaSupport { def ruleClass2Table(cls: Class, tab: Table, pkey: Column) def ruleProperty2Column(prop: Property, col: Column) } val it = source.eAllContents while (it.hasNext) { val x = it.next if (x.isInstanceOf[Class]) ruleClass2Table(x.asInstanceOf[Class], create[Table], create[Column]) else if (x.isInstanceOf[Property]) ruleProperty2Column4(x.asInstanceOf[Property], create[Column]) else logger warn (s"No rule to transfrom ${x}.") }
  • 20. ThankYou Filip Křikava filip.krikava@i3s.unice.fr https://fikovnik.github.io/Sigma The work is partly funded by the ANR SALTY project under contract ANR-09-SEGI-012. https://salty.unice.fr