1. Trang chủ
  2. » Công Nghệ Thông Tin

Modeltomodel transformation with ATL

59 238 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 59
Dung lượng 543,68 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Models transformation is the most important key in Model Driven Architecture (MDA). The first transformation in MDA is Computing Independent Model (CIM) to Platform Independent Model (PIM) transformation, the second is PIM to Platform Specific Model (PSM) transformation. This latter transformation deals the two less abstract levels, PIM and PSM, for that most researchers focused on this kind of transformation. Nevertheless, the top level of abstraction, CIM, and its transformation to PIM is rarely discussed in research topics. Our goal in this paper is to represent an approach that allows mastering transformation from CIM to PIM in accordance with MDA. Our method based on creating a good CIM level, using construction rules, to facilitate the transformation to PIM level. Next, our transformation rules, implemented with Atlas Transformation Language (ATL), ensure a semiautomatic transformation from CIM to PIM. Our approach conforms to MDA, because it allows considering the business dimension in the CIM level, and it allows modelling this latter level by using Business Process Model and Notation (BPMN), this latter is the OMG standard for modelling the business process. However, we founded on UML to model PIM level, because UML is advocated by MDA in PIM. Our proposal results a set of classes, organized according to the Model View Controller (MVC).

Trang 1

Model-to-model Transformation with ATL

Frédéric Jouault (INRIA) Brahim-Khalil LOUKIL (INRIA) William Piers (Obeo)

Trang 2

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Š Available resources: wiki, zoo, newsgroup, use cases, etc.

Š ATL language description

• First exercise: Ecore-To-UML2.1

• Architecture

Š Overview

Š The new virtual machine: EMF-VM

• Second exercise: GMF Diagram Refactoring

• Third exercise: Public-To-Private

Trang 3

Š Available resources: wiki, zoo, newsgroup, use cases, etc.

Š ATL language description

• First exercise: Ecore-To-UML2.1

• Architecture

Š Overview

Š The new virtual machine: EMF-VM

• Second exercise: GMF Diagram Refactoring

• Third exercise: Public-To-Private

Trang 4

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

ATL - Description

• ATL : ATLAS Transformation Language

• ATL is a language and a virtual machine dedicated to model transformation

• ATL is an Eclipse Model-to-Model (M2M) component, inside of the Eclipse Modeling Project (EMP)

Trang 5

M2

M1

Trang 6

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Operational context: small theory

ATL

Rule Class

MMa2MMb.atl

conformsTo

Trang 7

Operational context of ATL

metamodel

Trang 8

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

M2M vs M2T

• M2M: Model To Model transformation

Š Abstract syntax to abstract syntax

Š Languages: ATL, QVT Operational, QVT Relations

• M2T: Model To Text transformation

Š Abstract syntax to concrete syntax

Š Languages: JET, xPand

• TMF: Textual Modeling Framework

Š Abstract syntax to and from concrete syntax

Š Languages: TCS, xText

• This tutorial is focused on M2M

Trang 9

Š ATL language description

• First exercise: Ecore-To-UML2.1

• Architecture

Š Overview

Š The new virtual machine: EMF-VM

• Second exercise: GMF Diagram Refactoring

• Third exercise: Public-To-Private

Trang 10

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

ATL history

• 1990 : first works on model transformation

• 1998 : initial publication for a Ph.D thesis at the

University of Nantes

• 1998 - 2004 : Implementation

Š CARROLL/MOTOR project (CEA, Thales, INRIA)

Š Collaborative projects : ModelWare, ModelPlex, OpenEmbeDD

• 2004 : Eclipse GMT integration

• 2006 : Industrial solution inside of the Eclipse M2M

project

Trang 11

Š Use cases: http://www.eclipse.org/m2m/atl/usecases/

Š Transformations zoo (i.e., a library):

http://www.eclipse.org/m2m/atl/atlTransformations/

• Other links :

Š Project page: http://www.eclipse.org/m2m/atl/

Trang 12

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

ATL transformation zoo

Rule 'ComplexReference'

This rule generates two opposites references which will be the link

between the new Relationship and his adjoining Classes

rule ComplexReference {

from

r : DSL!Role (

r.relation.needTurnOnClass() )

upper <- if r.max=0

then 0-1 else 1 endif,isOrdered <- r.isOrdered,isContainer <- r.isEmbedding(),isUnique <- false

),rfInRelationship : KM3!Reference (

name <- oppositeRole.name,owner <- r.relation,

type <- r.source,opposite <- rfInOwner,lower <- oppositeRole.min,upper <- if oppositeRole.max=0 then 0-1 else 1 endif,isOrdered <- oppositeRole.isOrdered,

isContainer <- oppositeRole.isEmbedding(),isUnique <- false

) }

Trang 14

ATL overview

• Source models and target models are distinct:

Š Source models are read-only (they can only be navigated, not modified),

Š Target models are write-only (they cannot be navigated).

• The language is a declarative-imperative hybrid:

Š Declarative part:

ƒ Matched rules with automatic traceability support,

Trang 15

ATL overview (continued)

• A declarative rule specifies:

Š a target pattern to be created in the target models for each

• An imperative rule is basically a procedure:

Š It is called by its name,

Š It may take arguments,

Š It can contain:

ƒ A declarative target pattern,

ƒ An action block (i.e a sequence of statements),

ƒ Both.

Trang 16

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

ATL overview (continued)

• Applying a declarative rule means:

Š Creating the specified target elements,

Š Initializing the properties of the newly created elements.

• There are three types of declarative rules:

Š Standard rules that are applied once for each match,

ƒ A given set of elements may only be matched by one standard rule,

it is referred to from other rules (possibly never for some matches),

Š Unique lazy rules that are applied at most once for each

match and only if it is referred to from other rules.

Trang 17

Declarative rules: source pattern

• The source pattern is composed of:

Š A labeled set of types coming from the source metamodels,

• A match corresponds to a set of elements coming

from the source models that:

Š Are of the types specified in the source pattern (one element for each type),

Š Satisfy the guard.

Trang 18

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Declarative rules: target pattern

• The target pattern is composed of:

Š A labeled set of types coming from the target metamodels,

Š For each element of this set, a set of bindings.

Š A binding specifies the initialization of a property of a target

element using an expression.

• For each match, the target pattern is applied:

Š Elements are created in the target models (one for each type of the target pattern),

Š Target elements are initialized by executing the bindings:

ƒ First evaluating their value,

ƒ Then assigning this value to the corresponding property.

Trang 19

Execution order of declarative rules

• Declarative ATL frees the developer from specifying execution order:

Š The order in which rules are matched and applied is not specified.

ƒ Remark: the match of a lazy or unique lazy rules must be referred to before the rule is applied.

Š The order in which bindings are applied is not specified.

• The execution of declarative rules can however be kept deterministic :

Š The execution of a rule cannot change source models

Î It cannot change a match,

Š Target elements are not navigable

Î The execution of a binding cannot change the value of another.

Trang 20

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Example: Class to Relational - Overview

• The source metamodel Class is a simplification of

class diagrams.

• The target metamodel Relational is a simplification of

the relational model.

Î ATL declaration of the transformation:

module Class2Relational;

create Mout : Relational from Min : Class;

• The transformation excerpts used in this presentation come from:

http://www.eclipse.org/m2m/atl/atlTransformations/#Class2Relational

Trang 21

Example: Class to Relational - Source Metamodel

* {ordered } owner

Trang 22

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Example: Class to Relational – Target Metamodel

Named

+name:String

owner +

col +

* {ordered}

keyOf

Type

* + type

Trang 23

Example: Class to Relational, overview

• Informal description of rules

Š Class2Table:

ƒ A table is created from each class ,

attributes of the class,

owner class of the attribute,

Trang 24

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Example: Class to Relational - Rule

Trang 25

Example: Class to Relational - Rule

Trang 26

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Example: Class to Relational - Rule

Class2Table (3 Of 4)

• The columns of the table correspond to the single-valued

attributes of the class :

navigation

)

}

automatic traceability support.

Trang 27

Example: Class to Relational - Rule

key <- Set {key}

),

key : Relational!Column ( another target

Trang 28

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Example: Class to Relational - Rule

SingleValuedAttribute2Column

rule SingleValuedAttribute2Column {

from the guard is used for selection

to

c : Relational!Column (

name <- a.name )

}

Trang 29

Example: Class to Relational - Rule

}

Trang 30

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Object Constraint Language (OCL)

• Originally intended to express constraints over UML models, for instance:

context Person inv: self.age > 0

• Extended to query any model

• Used in several transformation languages (e.g., ATL, QVT) to compute values from the source models

• Specification:

Š The version on which ATL is based is available from:

http://www.omg.org/docs/ptc/03-10-14.pdf

Š Section 7: language overview

Š Section 11: standard library

ƒ Section 11.8: iterator expressions

Trang 31

ATL types hierarchy

Trang 32

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Other ATL features: rule inheritance

• Rule inheritance, to help structure transformations and reuse rules and patterns:

Š A child rule matches a subset of what its parent rule

matches,

Î All the bindings of the parent still make sense for the child,

Š A child rule specializes target elements of its parent rule:

ƒ Initialization of existing elements may be improved or changed,

ƒ New elements may be created,

Trang 33

Copy class inheritance without rule inheritance

Source metamodel: MMA

class A1 { attribute v1 : String ; }

class A2 extends A1 {

attribute v2 : String ;

}

Trang 34

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Copy class inheritance with rule inheritance

rule A2toB2 extends A1toB1 {

from

s : MMA!A2

to

t : MMB!B2 ( v2 <- s.v2 )

Source metamodel: MMA

class A1 { attribute v1 : String ; }

class A2 extends A1 {

attribute v2 : String ;

}

Trang 35

Other ATL features: refining mode

small part of a model:

Š Since source models are read-only target models must be created from scratch,

Š This can be done by writing copy rules for each elements that are not transformed,

Î This is not very elegant,

Š In refining mode, the ATL engine automatically copies unmatched elements.

Î An (optimized) engine may modify source models in-place but only commit the changes in the end.

module A2A; create OUT : MMA refining IN : MMA;

Trang 36

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

ATL editor

Trang 37

ATL content assist

• ADT (ATL Development Tools) has recently been improved with basic content assist

Š Type completion

Š Left-side bindings completion

Š Basic code templates

Trang 38

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Launching ATL using ANT

<project name="Families2Persons" default="main">

<property name="input" value="sample-Families.ecore"/>

<property name="output" value="sample-Persons.ecore"/>

<target name="main" depends="loadModels">

<am3.loadModel modelHandler="EMF"

name="myFamilies" metamodel="Families"

path="${input}"/>

<am3.atl path="Families2Persons.atl">

<inmodel name="Families" model="Families"/>

<inmodel name="IN" model="myFamilies"/>

<inmodel name="Persons" model="Persons"/>

<outmodel name="OUT" model="myPersons" metamodel="Persons"/>

Trang 39

Š ATL language description

• Architecture

Š Overview

Š The new virtual machine: EMF-VM

• Second exercise: GMF Diagram Refactoring

• Third exercise: Public-To-Private

Trang 40

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

First exercise: Ecore-To-UML2.1

Trang 41

First exercise: Quick overview

publicObject caseEAttribute(EAttribute eAttribute) {

EClass eContainingClass = eAttribute.getEContainingClass();

upper<-et.upperBound )

Trang 42

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Š ATL language description

• First exercise : Ecore-To-UML2.1

Š Overview

Š The new virtual machine: EMF-VM

• Second exercise: GMF Notation-To-Notation

• Third exercise: Public-To-Private

Trang 43

ATL main plugins organization

Eclipse ui integration

ATL core

ATL Regular VM (with drivers) New ATL VM EMF-dedicated

Trang 44

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Š Can be implemented on different

platforms (Java, Net)

Trang 45

ATL execution process

• 2 steps

Š Compilation

Š Execution

Trang 46

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Š Some missing features (decreasing in number quickly)

Š No UML profile support

• Non-regression evaluated with a new test plugin

Trang 47

Non regression wiki page

Trang 48

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

EMF-VM Benchmarks

Trang 49

Š ATL language description

• First exercise: Ecore-To-UML2.1

• Architecture

Š Overview

Š The new virtual machine: EMF-VM

• Third exercise: Public-To-Private

Trang 50

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Second Exercise: GMF Diagram Refactoring

• Context:

Š GMF (Graphical Modeling Framework) enables graphical

concrete syntaxes for models

Š Graphical properties (e.g., position, size, color) are stored in a

separate Notation model, for instance:

ƒ default.uml conforming to the UML metamodel

ƒ default.umlclass_diagram conforming the Notation metamodel

Trang 51

GMF Diagram Refactoring: Sample Source

Trang 52

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

GMF Diagram Refactoring: Sample Target

Trang 53

GMF Diagram Refactoring

• Possible extensions:

Š Bendpoints for edges

Š Styles (e.g., so that lines appear in the same shade of gray)

Š Other kinds of refactorings

Trang 54

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Š ATL language description

• First exercise: Ecore-To-UML2.1

• Architecture

Š Overview

Š The new virtual machine: EMF-VM

• Second exercise: GMF Diagram Refactoring

Trang 55

Third exercise : Public To Private

• Context

Š Simplified Java metamodel: classes, fields, methods

Š Sample Java model: PetriNet

Trang 56

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Input model (with public fields)

Trang 57

Output model (privatized)

Trang 58

Model-To-Model Transformation with ATL | © 2008 by INRIA, Obeo; made available under the EPL v1.0

Legal Notices

• Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc in the United States, other

countries, or both

• Other company, product, or service names may be

trademarks or service marks of others

Trang 59

• Questions or Comments?

Ngày đăng: 25/12/2016, 13:31

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm