moscript a textual dsl for model manipulations
TRANSCRIPT
![Page 1: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/1.jpg)
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
![Page 2: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/2.jpg)
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
![Page 3: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/3.jpg)
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
![Page 4: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/4.jpg)
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
![Page 5: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/5.jpg)
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
![Page 6: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/6.jpg)
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
![Page 7: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/7.jpg)
MoScript and the Megamodel
Model Repositories
MoScript
011001
011001
011001
Megamodel
21/11/11 7 © AtlanMod -‐ atlanmod-‐contact@mines-‐nantes.fr
![Page 8: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/8.jpg)
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
* *
![Page 9: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/9.jpg)
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 }"
![Page 10: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/10.jpg)
Strategy
tx
(x)= y Synchronize
21/11/11 10 © AtlanMod -‐ atlanmod-‐contact@mines-‐nantes.fr
![Page 11: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/11.jpg)
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
![Page 12: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/12.jpg)
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 …"
![Page 13: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/13.jpg)
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())"
![Page 14: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/14.jpg)
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’);"
![Page 15: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/15.jpg)
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
![Page 16: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/16.jpg)
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
![Page 17: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/17.jpg)
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
![Page 18: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/18.jpg)
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
![Page 19: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/19.jpg)
Eclipse plugin
21/11/11 19 © AtlanMod -‐ atlanmod-‐contact@mines-‐nantes.fr
![Page 20: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/20.jpg)
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
![Page 21: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/21.jpg)
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
![Page 22: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/22.jpg)
END
21/11/11 22 © AtlanMod -‐ atlanmod-‐contact@mines-‐nantes.fr
Thank you for
attending
![Page 23: MoScript a textual DSL for model manipulations](https://reader038.vdocuments.us/reader038/viewer/2022103114/554fb771b4c9053d018b4573/html5/thumbnails/23.jpg)
ATL Transformations Zoo
21/11/11 23 © AtlanMod -‐ atlanmod-‐contact@mines-‐nantes.fr