moscript a textual dsl for model manipulations

Post on 11-May-2015

580 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Marco Brambilla

MoScript: A DSL for querying and manipulating model repositories

21/11/11 1 ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

Wolfgang Kling Frédéric Jouault

Jordi Cabot Dennis Wagelaar

Context

  Large numbers of modelling artefacts – E.g. MDD phases consume and produce

models

  Stored in model repositories   Strong interrelations

21/11/11   2  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

Transforma-ons  

Requirements Use Case

Class Diagram

Java Project

Context

  Not only models (source code, tools, libraries etc.)

  Heterogeneous   Distributed   Constant evolution of the

repository

21/11/11   3  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

0110010101010010100101010001

0110010101010010100101010001101  

01100101010100101001010100011010001  

Motivation

  Understand repository (updated view)

  Finding models –  By their content –  By a computed characteristic –  By their relation with other models

  Combining models information

  Perform common modelling tasks batch processing

010010101000101010

010010101000101010

010010101000101010

?

010010101000101010

21/11/11   4  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

MoScript

A textual DSL for querying and manipulating model repositories   Retrieve models

– by structure and content – by their relations with others – by behaviour (after a simulation)

  Manipulate models (transform, match, compare etc.) right after finding them

  Update repository view, persisting newly created artefacts or discarding existing ones

21/11/11   5  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

MoScript

  Based on the megamodel (repository view)   Uses OCL   Combines OCL with

– Operations without side effects – Statements (update view and repository)

21/11/11   6  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

MoScript  and  the  Megamodel  

Model Repositories

MoScript  

011001

011001

011001

Megamodel

21/11/11   7 ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

Megamodel’s Metamodel

21/11/11   8  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

Terminal Model

MetaMeta Model

Entity

Relationship Model

MetaModel

Weaving Model Transformation

Model Mega Model

1

Identified Element

* relatedTo

* sourceOf

* targetOf

* linked

* source * target

extends *

conformsTo 1

Reference Model

* elements

Transformation

* *

srcReferenceModel targetReferenceModel

Directed Relationship

targetModel srcModel

Transformation Record

* *

  Models conforming to the Java metamodel

  Transformations that transform models conforming to the Java metamodel

So far … (OCL and Megamodel)

21/11/11   9  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

Model::allInstances()−>select(m | m.conformsTo.kind = ’Java’)"

Transformation::allInstances()""−>select(t | t.srcReferenceModels.exists(rm | rm.kind = ’Java’))"

Collection{ Model1, Model2 …, Modeln }"

Collection{ Transformation1, Transformation2 …, Transformationn }"

Strategy

tx  

(x)=  y  Synchronize  

21/11/11   10  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

MoScript Abstract Syntax

21/11/11   11  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

OperationCallExp

PropertyCallExp

OclExpression

OCL

QueryOp

TransformOp

ProjectionOp

BindingStat

ForStat SaveStat RegisterStat

RemoveStat

ExpressionStat

Program Library Helper

Unit

MoScript MoScript

IfStat

Statement

StateCheckOp

MoScript Concrete Syntax

21/11/11   12  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

program program_name"

uses library1"uses …"

[ using {""variable1 : type = OclExpr;""variable2 …"

}]"

do {""variable <- OclExpr;"

"save(OclExpr, …);""remove(OclExpr, …);"

"register(…);"

"if …""for …"

}"

helper …"

  Query operations

  Model to Model transformations (M2M)

Brief Examples

21/11/11   13  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

Model::allInstances()−>any(m | m.indentifier = ’SimpsonFamily’) " −>allContents()−>collect(el | el.name))"

Collection {’Bart’, ’Homer’, ’Lisa’, ’Maggie’, ’Marge’} "

let j2dNet : Transformation = Transformation::allInstances()""−>any(t | t.identifier = ’j2dNet’)"

in"

Model::allInstances()""−>select(m | m.conformsTo.kind = ’Java’)) ""−>collect (jModel | j2dNet.applyTo(jModel))"

1"2"3"4"5"6"7"

TransformationRecord::allInstances()−>collect(tr | tr.run())"

  Projectors (inject & extract)

  The save statement

  The register statement"

Brief Examples

21/11/11   14  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

... for(dNetModel in dNetModels) {"" "save( dNetModel, dNetModel.getIdentifier(),"

dNetModel . location + ’.xmi’);" } "

helper context Model def: getIdentifier(): ... ;"

1"2"3"4"5"6"

Model::allInstances()−>select(m | m.conformsTo.kind = ’JavaGrammar’)) ""−>collect (jCode|jCode.inject())"

register(MetaMetaModel, ’Ecore’, ’http://www.eclipse.org/emf/2002/Ecore’);"

MoScript

Operations Without Side Effects Model :: allContents() : Collection(OclAny)"

Model :: allContentsRoots() : Collection(OclAny)"

Model :: allContentsInstancesOf(type_name : String) : Collection(OclAny)"

Model :: allContentsInstancesOf(type : OclAny) : Collection(OclAny)"

Transformation :: applyTo(inputModels : Sequence(Model)) : TransformationRecord"

Transformation :: applyTo(inputModels : Map(String, Model)) : TransformationRecord"

TransformationRecord :: run() : TransformationRecord"

Model :: inject() : Model"

Model :: extract() : Model"

Model :: available() : Boolean"

Model :: isDirty() : Boolean"

21/11/11   15  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

MoScript

Statements With Side Effects

save(m : Model, mgm : Megamodel, id : String, locator : String)"

remove(m : Model, mgm : Megamodel)"

register(elem : OclModelElement, id : String, locator : String)"

register(elem : OclModelElement, attrs : Map(String, OclAny))"

21/11/11   16  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

21/11/11   ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr   17

MoScript  

Metadata  Engine  

011001

011001

011001

TransformaIon  Tools  

Model Repositories

Megamodel

DSLs  Editors  

Discoverers   1

23

5

6

4

MoScript  Underlying  Architecture  

21/11/11   ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr   18

ImplementaIon  

011001

011001

011001

Model Repositories

GMM / AM3

AM3

ATL ATL VM

TCS ANTLR

ATL  VM  

MoScript  

WebML ATL Zoo

Eclipse plugin

21/11/11   19  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

Experimentation

  ATL Transformation Zoo model repository http://www.eclipse.org/m2m/atl/atlTransformations/

–  205 metamodels, 275 models, 219 transformations and 400 other artefacts

  Reverse engineering megamodel generation   Different kind of metrics   Execution of all the transformations and check results   Matching models

  WebML model repository –  WebModel metamodel –  WebModel xml (.wr) injection to ecore –  Transformation to WebML models –  Count user interface fields

21/11/11   20  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

Conclusions

DSL for querying and manipulating model repositories •  Uses OCL •  Based on the Megamodel •  Model dereferencing •  Applies transformation to model similarly as working

with functions. •  Allows the use of multiple transformation tools •  Makes types checking at run time to ensure

consistency. •  Hides a lot of the complexity of handling large

amounts of modelling artefacts and relationships, to the user

•  Keeps synchronized the megamodel with the repository to ensure integrity

21/11/11   21  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

END

21/11/11   22  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

Thank you for

attending

ATL Transformations Zoo

21/11/11   23  ©  AtlanMod    -­‐    atlanmod-­‐contact@mines-­‐nantes.fr  

top related