SlideShare a Scribd company logo
1 of 117
Download to read offline
Model Refactoring and other Advanced
                      ATL Techniques


                Frédéric Jouault (INRIA)
                William Piers (Obeo)




© 2009 by INRIA, Obeo; made available under the EPL v1.0 | 23 March 2009
What You Will Learn in This Tutorial
    • Refactoring models efficiently
    • Compiling a DSL for SWTBot
    • Visualizing models




2        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Discussion Topics
    • About ATL
        ATL versions (2004 vs. 2006), notably refining mode
        Best Practices
        Model Transformation Virtual Machines
        ATL vs. QVT

    • Around ATL
        M2M vs. M2T
        Where do models come from?
        Modeling platforms – AmmA
        Domain-Specific Languages and Modeling

     You can vote for the topics you are most interested in (2 or 3)
     You may suggest additional topics

3          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Agenda
    • Introduction
       Model-To-Model transformation in the MDE field
       M2M vs. M2T
    • ATL Overview
    • First exercise: Model Visualization
    • Advanced Usage of ATL
    • Second exercise: Model Refactoring
    • Architecture
    • Third exercise: A DSL Compiler for SWTBot
    • ATL Industrialization
    • Discussions



4        Model Refactoring and other Advanced ATL Techniques | © 2009 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)




5         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Definitions
    • A model transformation is the automatic creation of target
      models from source models.

    • Applications*:
           Interoperability of Telephony Languages
           Modeling Web applications
           Converting graphics (e.g., Rational Rose to UML2 Tools)
           Measuring and verifying UML models
           etc.

    Whatever your problem, you can write a lot of Java code or a
     (generally) much simpler ATL transformation.

             * Use cases available at: http://www.eclipse.org/m2m/atl/usecases/

6           Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Operational context: small theory
                       conformsTo          Metametamodel
                                                      Class
                                                      Class
                   conformsTo                                                  conformsTo


        MMa                                ATL                                   MMb
                       Class                              Class                                 Class
                      Green                                Rule                                  Blue


                       Class                                                                     Class

                       Red                 MMa2MMb.atl                                           Pink
                                                 Rule         Rule
       conformsTo                                 R2B         G2P                               conformsTo


        Ma                                                                       Mb



7       Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Operational context of ATL
                                                  MOF
    MMa is the                                                                                        MMB is the
    source                                                                                            target
    metamodel
                    MMa                            ATL                           MMb                  metamodel




                                            MMa2MMb.atl
                       Ma                                                           Mb
         Ma is the source model                                   Mb is the target model

8           Model Refactoring and other Advanced ATL Techniques | © 2009 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




9         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Agenda
     • Introduction
     • ATL Overview
        Available resources: wiki, zoo, newsgroup, use cases,
         etc.
        ATL language description
     • First exercise: Model Visualization
     • Advanced Usage of ATL
     • Second exercise: Model Refactoring
     • Architecture
     • Third exercise: A DSL Compiler for SWTBot
     • ATL Industrialization
     • Discussions


10        Model Refactoring and other Advanced ATL Techniques | © 2009 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




11         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL community
     • Active community
         Newsgroup: news://news.eclipse.org/eclipse.modeling.m2m
         Wiki: http://wiki.eclipse.org/ATL
         Bugzilla
         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/




12          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL documentation
     • For a long time, ATL doc was dispatched over several
       places
        ATL User Manual, out of date
        ATL wiki, disorganized
        Some information in newsgroup, mailing lists...




     • Now merged into ATL wiki
             http://wiki.eclipse.org/ATL/User_Guide
     • Use of Mylyn Wikitext tool to generate Eclipse Help
     • Eclipse Help produces a portable, printable,
       searchable documentation support

13        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL documentation




                                                                                                 Mylyn WikiText
     Eclipse Wiki                                                                                extraction to
     collaborative                                                                               Eclipse Help
     edition

14           Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
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,
             Side-effect free navigation (and query) language: OCL 2.0
         Imperative part:
             Called rules,
             Action blocks.
     • Recommended programming style: declarative


15        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL overview (continued)
     • A declarative rule specifies:
         a source pattern to be matched in the source models,
         a target pattern to be created in the target models for each
          match during rule application.
     • 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.




16        Model Refactoring and other Advanced ATL Techniques | © 2009 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,
         Lazy rules that are applied as many times for each match as
          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.



17        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Declarative rules: source pattern
     • The source pattern is composed of:
         A labeled set of types coming from the source metamodels,
         A guard (Boolean expression) used to filter matches .
     • 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.




18        Model Refactoring and other Advanced ATL Techniques | © 2009 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.




19         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
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.

20        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Example: ClassDiagram to Relational – Overview
     • The source metamodel ClassDiagram is a
       simplification of class diagrams.
     • The target metamodel Relational is a simplification of
       the relational model.
      ATL declaration of the transformation:
     module ClassDiagram2Relational;
     create Mout : Relational from Min : ClassDiagram;

     • The transformation excerpts used in this presentation
       come from:
     http://www.eclipse.org/m2m/atl/atlTransformations/#Class2Relational


21          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Source Metamodel: ClassDiagram
                       NamedElement

                     +name : String




                           Classifier


                                                   +type




      DataType                                       Class                          +attr           Attribute

                                                                                            +multivalued : Boolean
                                                                        owner     *
                                                                           {ordered }
22         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Target Metamodel: Relational

                                                      Named
                                               +name:String




        Table                       + col            Column                 *     + type                Type

                         + owner     *
                             { ordered }

       + keyOf    0..1                            + key      *




23        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Sample Source and Target Models




     Class2Table
     SingleValuedAttribute2Column
     MultiValuedAttribute2Column
24        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ClassDiagram2Relational.atl – overview
            NamedElement

           +name : String
                                                                                       Class2Table
                                                                                       SingleValuedAttribute2Column
                                                                                       MultiValuedAttribute2Column
               Classifier


                              +type


                                                                                                                        Named

DataType                       Class                             Attribute
                                                                                                                    +name:String
                                                   +attr
                                                           +multivalued : Boolean
                                          owner      *
                                             { ordered }




                                                                                    Table                 + col         Column     *   + type   Type

                                                                                                   + owner    *
                                                                                                       {ordered }

                                                                               + keyOf      0..1                      + key   *




25                      Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ClassDiagram2Relational.atl – overview
     • Informal description of rules
         Class2Table:
             A table is created from each class,
             The columns of the table correspond to the single-valued
              attributes of the class,
             A column corresponding to the key of the table is created.
         SingleValuedAttribute2Column:
             A column is created from each single-valued attribute.
         MultiValuedAttribute2Column:
             A table with two columns is created from each multi-valued
              attribute,
             One column refers to the key of the table created from the
              owner class of the attribute,
             The second column contains the value of the attribute.


26        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Rule Class2Table (1 Of 4)
     • For each Class, create a Table :

     rule Class2Table {
        from                     -- source pattern
            c : ClassDiagram!Class
        to                       -- target pattern
            t : Relational!Table
     }




27          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Rule Class2Table (2 Of 4)
     • The name of the Table is the name of the Class:

     rule Class2Table {
        from
            c : ClassDiagram!Class
        to
            t : Relational!Table (
                 name <- c.name    -- a simple binding
            )
     }




28         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Rule Class2Table (3 Of 4)
     • The columns of the table correspond to the single-valued
        attributes of the class:
     rule Class2Table {
        from
             c : ClassDiagram!Class
        to
             t : Relational!Table (
                  name <- c.name,
                  col <- c.attr->select(e |    -- a binding
                           not e.multiValued   -- using complex
                         )                     -- navigation
         )
     }
     • Remark: attributes are automatically resolved into columns by
        automatic traceability support.
29         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Rule Class2Table (4 Of 4)
     • Each Table owns a key containing a unique identifier:
     rule Class2Table {
        from
            c : ClassDiagram!Class
        to
            t : Relational!Table (
                 name <- c.name,
                     col <- c.attr->select(e | not e.multiValued
                 )->union(Sequence {key}),
                 key <- Set {key}
            ),
            key : Relational!Column ( -- another target
                 name <- ‘Id’              -- pattern element
            )                              -- for the key
30   }
            Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Rule SingleValuedAttribute2Column
     • For each single-valued Attribute create a Column:

     rule SingleValuedAttribute2Column {
        from -- the guard is used for selection
            a : ClassDiagram!Attribute (not a.multiValued)
        to
            c : Relational!Column (
                 name <- a.name
            )
     }




31         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Rule MultiValuedAttribute2Column
      • For each multi-valued Attribute create a Table, which contains
        two columns:
          The identifier of the table created from the class owner of the
           Attribute
          The value.
rule MultiValuedAttribute2Column {
                                                                                   id : Relational!Column (
  from
     a : ClassDiagram!Attribute (a.multiValued)                                            name <- ‘Id’
  to                                                                                   ),
      t : Relational!Table (                                                           value : Relational!Column (
           name <- a.owner.name + ‘_’ + a.name,                                            name <- a.name
           col <- Sequence {id, value}                                                 )
      ),                                                                       }


 32          Model Refactoring and other Advanced ATL Techniques | © 2009 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


33        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL/OCL types hierarchy




34       Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Running ATL/OCL Queries Within Eclipse
     • Considering a given OCL expression, such as:
        5 mod 2
     • Place it in an ATL query, for instance in file TestQuery.atl:
        query TestQuery = (5 mod 2).debug('Result');
     • Where the call to OclAny.debug(String) : OclAny:
         Does not change the result (it returns the value on which it is called)
         Prints the result on the console
         This operation may be called anywhere (e.g., to print intermediate
          values)
     • Advantages:
         May query any model
         May use debugger
     • Drawbacks:
         Cannot specify a context




35          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Iterator Expressions Returning Collections
     • collect
        Query: Sequence {1, 2, 3, 4}->collect(e | e + 2)
        Result: Sequence {3, 4, 5, 6}
     • reject
        Query: Sequence {1, 2, 3, 4}->reject(e | e > 2)
        Result: Sequence {1, 2}
     • select
        Query: Sequence {1, 2, 3, 4}->select(e | e > 2)
        Result: Sequence {3, 4}
     • sortedBy
        Query: Sequence {3, 4, 1, 2}->sortedBy(e | e)
        Result: Sequence {1, 2, 3, 4}




36         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Predicate Iterator Expressions Admitting Multiple Iterators

     • exists

         Sequence {1, 2, 3, 4}->exists(e | true
         e > 2)
         Sequence
     • forAll        {1, 2, 3, 4}->exists(e | fals
         e < 1)                               e
         Sequence {1, 2, 3, 4}->exists(e, | true
         Sequence {1, 2, 3, 4}->forAll(e false
         f |> 2) f + 3)
         e e=
         Sequence {1, 2, 3, 4}->forAll(e | true
         e > 0)
37        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Other Iterator Expressions with One Iterator
     • any
        Query:        Set{1, 2, 3, 4}->any(e | e > 2)
        Result:       3
        Query:        Set{1, 2, 3, 4}->any(e | e > 2)
        Result:       4
     • isUnique
        Query:        Sequence {1, 2, 3, 4}->isUnique(e | e mod 2 = 1)
        Result:       false (Sequence {1, 0, 1, 0} contains duplicates)
        Query:        Sequence {1, 2, 3, 4}->isUnique(e | e)
        Result:       true
     • one
        Query: Set{1, 2, 3, 4}->one(e | e > 2)
        Result: false
38           Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Iterate Expression
     • Enables computation of any value from a collection
     • Example:
        Sequence {'one', 'two', 'three'}->iterate(e; acc : String = '(' |
          acc + if acc = '(' then '' else ', 'endif + e
        ) + ')'
        Result: '(one, two, three)'
     • Description:
         The accumulator is initialized
         For each element in the source:
            The iterator gets the value of this element
            The body is evaluated
            The accumulator receives the resulting value
         The result is the value of the accumulator at the end of the
          iteration
39         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL editor




40        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL content assist
     • ADT (ATL Development Tools) has recently been
       improved with basic content assist
        Type completion
        Left-side bindings completion
        Basic code templates




41         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL Launch Configuration




42   Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Launching ATL using ANT
     • Historically provided by GMT/AM3

     • A new set of tasks is directly available into ATL 3.0
        Very close to the old AM3 tasks
           am3.saveModel => atl.saveModel
           am3.loadModel => atl.loadModel
           am3.atl => atl.launch
        Allows to specify transformation launching with more
         parameters
           Specific Injector/Extractor


     • Provide a way to chain transformations

43        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Launching ATL using ANT
       <project name="ClassDiagram2Relational" default="main">
             <property name="source" value="ClassDiagram/Sample-ClassDiagram.xmi"/>
             <property name="target" value="Relational/Sample-Relational.xmi"/>

             <target name="main" depends="loadMetamodels">
                   <atl.loadModel modelHandler="EMF"
                          name="myClassDiagram" metamodel="ClassDiagram"
                          path="${source}"/>

                    <atl.launch path="ATLFiles/ClassDiagram2Relational.atl">
                           <inModel name="ClassDiagram" model="ClassDiagram"/>
                           <inModel name="IN" model="myClassDiagram"/>
                           <inModel name="Relational" model="Relational"/>
                           <outModel name="OUT" model="myRelational" metamodel="Relational"/>
                    </atl.launch>

                   <atl.saveModel model="myRelational" path="${target}"/>
             </target>

             <target name="loadMetamodels">
                   <atl.loadModel modelHandler="EMF"
                          name="ClassDiagram" metamodel="%EMF"
                          path="ClassDiagram/ClassDiagram.ecore"/>
                   <atl.loadModel modelHandler="EMF"
                          name="Relational" metamodel="%EMF"
                          path="Relational/Relational.ecore" />
             </target>
       </project>

44          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Agenda
     • Introduction
     • ATL Overview
     • First exercise: Model Visualization
     • Advanced Usage of ATL
     • Second exercise: Model Refactoring
     • Architecture
     • Third exercise: A DSL Compiler for SWTBot
     • ATL Industrialization
     • Discussions




45        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
First exercise: Model Visualization
     • Context
         UML models (but general approach)

     • Objective
         provide a different way to visualize models
         applications in reverse engineering cartography

     • A visualization tool: prefuse (http://prefuse.org/)
         Advanced / dynamic visualizations
         BSD license
         Accepts many data formats as input
            GraphML
            TreeML


46         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
First exercise: Model Visualization
     • Overview:
        UML Model                                                            Prefuse visualization




47        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Agenda
     • Introduction
     • ATL Overview
     • First exercise: Model Visualization
     • Advanced Usage of ATL
       • Simple and Efficient Refactoring Transformations
       • Model Enrichment
     • Second exercise: Model Refactoring
     • Architecture
     • Third exercise: A DSL Compiler for SWTBot
     • ATL Industrialization
     • Discussions


48        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Writing Interpreters in ATL
     • An ATL interpreter typically evaluates a model into a
       value.
         Example: simple expressions.

     • Evaluation may involve input data that is not part of the
       model:
         Example: XPath expressions evaluates over an XML model.

     • The interpreter may be part of a larger transformation.

     • How to write an evaluator:
         Define an evaluation helper on each metamodel class to
          evaluate.


49         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Example: Metamodel for Simple Expressions
                                         Expression

                                                                        +right

                                                                       +left




               IntegerExp                                       OperatorExp
           +value : Integer                                  +operator : String




50       Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL Interpreter for Simple Expressions
     query CalcEval =
      let root : Calc!Expression.allInstances()->any(e | -- select root
         e.refImmediateComposite().oclIsUndefined()) in
      root.eval().debug('Result'); -- evaluate

     helper context Calc!IntegerExp def: eval() : Integer =
      self.value;

     helper context Calc!OperatorExp def: eval() : Integer =
      if self.operator = '+' then
          self.left.eval() + self.right.eval()
      else if self.operator = '*' then
          self.left.eval() * self.right.eval()
      else
          self.operator.debug('UnsupportedOperator')
      endif endif;
51          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Simple Expressions in Java (1 Of 3)
     abstract class Expression {
       public abstract int eval();
     }

     class IntegerExp extends Expression {
       int value;
       public IntegerExp(int value) {
          this.value = value;
       }
       public int eval() {
          return value;
       }
     }

52         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Simple Expressions in Java (2 Of 3)
     class OperatorExp extends Expression {
       Expression left;          String operator; Expression right;
       public OperatorExp(Expression left, String operator, Expression right) {
          this.left = left;
          this.operator = operator;
          this.right = right;
       }
       public int eval() {
          int ret = 0;
             if("+".equals(operator)) {
                    ret = left.eval() + right.eval();
             } else if("*".equals(operator)) {
                    ret = left.eval() * right.eval();
             } else {
                    System.err.println("Unsupported operator: " + operator);
                    System.exit(1);
             }
             return ret;
         }
     }

53               Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Simple Expressions in Java (3 Of 3)
     public class TestExpression {
       public static void main(String args[]) {
         System.out.println( // evaluating 1 + 4 * 3
             new OperatorExp(
                 new IntegerExp(1),
                 "+",
                 new OperatorExp(
                      new IntegerExp(4),
                      "*",
                      new IntegerExp(3)
                 )
             ).eval()
         );
       }
     }
54          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Writing Serializers in ATL
     • A serializer transforms a source model into a String.

     • It is a special kind of interpreter that evaluates into a
       String representing the evaluated model.

     • Pros:
         Any string may be computed (e.g., XML, HTML).
         Easily usable from within a transformation (e.g., when parts of
          the source model correspond to strings in the target model).

     • Cons:
         A TCS syntax specification can already be used for
          serialization.
         Some complex syntactic rules (e.g., proper parenthesizing of
          expressions) are hard to represent (but TCS does it
55
          automatically).
           Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Example: ATL Serializer for Simple Expressions
     query CalcEval =
      let root : Calc!Expression.allInstances()->any(e | -- select root
         e.refImmediateComposite().oclIsUndefined()) in
      root.serialize().debug('Result');   -- serialize

     helper context Calc!IntegerExp def: serialize() : String =
      self.value.toString();

     helper context Calc!OperatorExp def: serialize() : String =
      '(' +
           self.left.serialize() + ' ' +
           self.operator + ' ' +
           self.right.serialize() +
      ')';
56         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Simple copy
-- Source metamodel: MMA                                               -- Target metamodel: MMB
class A1 {                                                             class B1 {
    attribute v1 : String;                                                 attribute v1 : String;
   attribute v2 : String;                                                 attribute v2 : String;
}                                                                      }
module MMAtoMMB;
create OUT : MMB from IN : MMA;
rule A1toB1 {
  from
    s : MMA!A1
  to
    t : MMB!B1 (
       v1 <- s.v1,
       v2 <- s.v2
    )
}
57           Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Structure creation
-- Source metamodel: MMA                                               -- Target metamodel: MMB
class A1 {                                                             class B1 { reference b2 : B2;
    attribute v1 : String;                                                       reference b3 : B3; }
   attribute v2 : String;                                              class B2 { attribute v1 : String; }
}                                                                      class B3 { attribute v2 : String; }
module MMAtoMMB;                                                             t2 : MMB!B2 (
create OUT : MMB from IN : MMA;                                                 v1 <- s.v1
rule A1toB1andB2andB3 {                                                      ),
  from                                                                       t3 : MMB!B3 (
    s : MMA!A1                                                                  v2 <- s.v2
  to                                                                         )
    t1 : MMB!B1 (                                                      }
       b2 <- t2,
       b3 <- t3
    ),
58           Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Structure simplification
-- Source metamodel: MMA                                                -- Target metamodel: MMB
class A1 { reference a2 : A2;                                           class B1 {
       reference a3 : A3; }                                                attribute v1 : String;
class A2 { attribute v1 : String; }                                        attribute v2 : String;
class A3 { attribute v2 : String; }                                     }
module MMAtoMMB;
create OUT : MMB from IN : MMA;
rule A1toB1 {
  from
    s : MMA!A1
  to
    t : MMB!B1 (
       v1 <- s.a2.v1,
       v2 <- s.a3.v2
    )
}
59            Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Structure simplification (needlessly more complex)
-- Source metamodel: MMA                                                -- Target metamodel: MMB
class A1 { reference a2 : A2;                                           class B1 {
       reference a3 : A3; }                                                attribute v1 : String;
class A2 { attribute v1 : String; }                                        attribute v2 : String;
class A3 { attribute v2 : String; }                                     }
module MMAtoMMB;
create OUT : MMB from IN : MMA;
rule A1toB1 {
  from s1 : MMA!A1, s2 : MMA!A2,
    s3 : MMA!A3 (s1.a2 = s2 and s1.a3 = s3)
  to
    t : MMB!B1 (
       v1 <- s.a2.v1,
       v2 <- s.a3.v2
    )
}
60            Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Traceability: implicit resolution of default elements
-- Source metamodel: MMA                                                -- Target metamodel: MMB
class A1 { reference a2 : A2;                                           class B1 { reference b2 : B2;
       reference a3 : A3; }                                                       reference b3 : B3; }
class A2 { attribute v1 : String; }                                     class B2 { attribute v1 : String; }
class A3 { attribute v2 : String; }                                     class B3 { attribute v2 : String; }
module MMAtoMMB;                                                        rule A2toB2 {
create OUT : MMB from IN : MMA;                                           from s : MMA!A2
rule A1toB1 {                                                             to    t : MMB!B2 (
  from                                                                      v1 <- s.v1    )
    s : MMA!A1                                                          }
  to                                                                    rule A3toB3 {
    t : MMB!B1 (                                                          from s : MMA!A3
       b2 <- s.a2, -- HERE                                                to    t : MMB!B3 (
       b3 <- s.a3 -- HERE                                                   v2 <- s.v2   )
    )                                                                   }
}
61            Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Remark: same result, less modular
-- Source metamodel: MMA                                                -- Target metamodel: MMB
class A1 { reference a2 : A2;                                           class B1 { reference b2 : B2;
       reference a3 : A3; }                                                       reference b3 : B3; }
class A2 { attribute v1 : String; }                                     class B2 { attribute v1 : String; }
class A3 { attribute v2 : String; }                                     class B3 { attribute v2 : String; }
module MMAtoMMB;                                                              t2 : MMB!B2 (
create OUT : MMB from IN : MMA;                                                  v1 <- s.a2.v1
rule A1toB1 {                                                                 ),
  from                                                                        t3 : MMB!B3 (
    s : MMA!A1                                                                   v2 <- s.a3.v2
  to                                                                          )
    t1 : MMB!B1 (                                                       }
       b2 <- t2,
       b3 <- t3
    ),
62            Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Traceability: resolveTemp for additional elements
-- Source metamodel: MMA                                                -- Target metamodel: MMB
class A1 { reference a2 : A2; }                                         class B1 { reference b2 : B2;
class A2 { attribute v1 : String;                                                 reference b3 : B3; }
          attribute v2 : String; }                                      class B2 { attribute v1 : String; }
                                                                        class B3 { attribute v2 : String; }
module MMAtoMMB;                                                        rule A2toB2andB3 {
create OUT : MMB from IN : MMA;                                           from
rule A1toB1 {                                                               s : MMA!A2
  from      s : MMA!A1                                                    to
  to                                                                        t1 : MMB!B2 (
    t : MMB!B1 (                                                               v1 <- s.v1
       b2 <- s.a2,                                                          ),
       b3 <-                                                                t2 : MMB!B3 (
         thisModule.resolveTemp(s.a2, 't2')                                    v2 <- s.v2
    )                                                                       )
}
63                                                                      }
              Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Traceability: resolveTemp even for first element
-- Source metamodel: MMA                                                 -- Target metamodel: MMB
class A1 { reference a2 : A2; }                                          class B1 { reference b2 : B2;
class A2 { attribute v1 : String;                                                  reference b3 : B3; }
          attribute v2 : String; }                                       class B2 { attribute v1 : String; }
                                                                         class B3 { attribute v2 : String; }
module MMAtoMMB;                                                         rule A2toB2andB3 {
create OUT : MMB from IN : MMA;                                            from
rule A1toB1 {                                                                s : MMA!A2
  from s : MMA!A1                                                          to
  to t : MMB!B1 (                                                            t1 : MMB!B2 (
       b2 <- -- possible but complex                                            v1 <- s.v1
         thisModule.resolveTemp(s.a2, 't1'),                                 ),
       b3 <-                                                                 t2 : MMB!B3 (
         thisModule.resolveTemp(s.a2, 't2')                                     v2 <- s.v2
    )                                                                        )
}
64                                                                       }
               Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Structure creation revisited with resolveTemp
-- Source metamodel: MMA                                                 -- Target metamodel: MMB
class A1 {                                                               class B1 { reference b2 : B2;
    attribute v1 : String;                                                         reference b3 : B3; }
   attribute v2 : String;                                                class B2 { attribute v1 : String; }
}                                                                        class B3 { attribute v2 : String; }
module MMAtoMMB;                                                               t2 : MMB!B2 (
create OUT : MMB from IN : MMA;                                                   v1 <- s.v1
rule A1toB1andB2andB3 {                                                        ),
  from                                                                         t3 : MMB!B3 (
   s : MMA!A1                                                                     v2 <- s.v2
  to                                                                           )
   t1 : MMB!B1 (-- possible but complex                                  }
      b2 <- thisModule.resolveTemp(s, 't2'),
      b3 <- thisModule.resolveTemp(s, 't3')
   ),
65             Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Kinds of matched (declarative) rules
     • We have only seen standard rules in default mode so far.
 Kind of             Number of                        Number of                                  Kind of
 rule                references                       times the                                  traceability
                     to source                        target pattern                             link
                     pattern                          gets created                               created
 standard                              0                                                   1 default or
                                       1                                                   1 not (using
                                                                                             keyword
                                     n>1                                                   1
                                                                                             nodefault)
 unique
66
                                                0                                          0 Not default
           Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Syntax of the different kinds of matched rules
     Kind of rule                      Definition                                   Reference
     standard                          rule R1 {                                    <value of type
     default                            from s :                                    MMA!A1>
                                       MMA!A1                                       or
                                        to t : MMB!                                 <collection of
                                       B1 }                                         MMA!A1>
     standard              nodefault rule not currently
     nodefault             R1 {                   possible
     (1) For collections: aCollection->collect(e | thisModule.R1(e))
                            from s :
67
                           MMA!A1
            Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
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,
         Syntax:
            abstract rule R1 {
              -- ...
            }
            rule R2 extends R1 {
              -- ...
            }
68        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Copy class inheritance without rule inheritance
     -- Source metamodel: MMA                                         -- Target metamodel: MMB
     class A1 { attribute v1 : String; }                              class B1 { attribute v1 : String; }
     class A2 extends A1 {                                            class B2 extends B1 {
        attribute v2 : String;                                           attribute v2 : String;
     }                                                                }
     module MMAtoMMB;                                                 rule A2toB2 {
     create OUT : MMB from IN : MMA;                                    from
     rule A1toB1 {                                                        s : MMA!A2
       from                                                             to
         s : MMA!A1                                                       t : MMB!B2 (
       to                                                                    v1 <- s.v1,
         t : MMB!B1 (                                                        v2 <- s.v2
            v1 <- s.v1                                                    )
         )                                                            }
     }
69          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Copy class inheritance with rule inheritance
     -- Source metamodel: MMA                                         -- Target metamodel: MMB
     class A1 { attribute v1 : String; }                              class B1 { attribute v1 : String; }
     class A2 extends A1 {                                            class B2 extends B1 {
        attribute v2 : String;                                           attribute v2 : String;
     }                                                                }
     module MMAtoMMB;                                                 rule A2toB2 extends A1toB1 {
     create OUT : MMB from IN : MMA;                                    from
     rule A1toB1 {                                                        s : MMA!A2
       from                                                             to
         s : MMA!A1                                                       t : MMB!B2 (
       to                                                                    -- v1 <- s.v1,
         t : MMB!B1 (                                                        v2 <- s.v2
            v1 <- s.v1                                                    )
         )                                                            }
     }
70          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Guidelines
     Make your transformation as complex as necessary but
      as simple as possible.

     • Prefer declarative over imperative: only use imperative
       for the part of a transformation that needs it if it even
       does.

     • Prefer simpler constructs over more complex ones:
         Use standard rules when possible, otherwise use unique lazy
          rules, and use lazy rules only if necessary.
         Only use resolveTemp if necessary.
         Prefer iterators (e.g., select, collect) over iterate.



71         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Refactoring Transformations – Example




     • Public2Private:
         Making every public Property private
         Leaving the rest of the model unchanged



     • Note: although this example uses UML, the approach
       presented here is metamodel-independent.

72         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Operational context of ATL (Reminder)
                                                 MOF
 MMa is the                                                                                          MMB is the
 source                                                                                              target
 metamodel
                   MMa                            ATL                            MMb                 metamodel




                                            MMa2MMb.atl
                      Ma                                                            Mb
       Ma is the source model                                    Mb is the target model
              (read-only)                                             (write-only)
73        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Refactoring transformations – Overview
     • General characteristics:
         Operate on a single metamodel (i.e., MMa = MMb)
         Most of the model remains unchanged (i.e., Ma ≈ Mb)

     • Optional characteristics:
         May apply to only a given part of the model (i.e., a selection)
         Identity of elements may need to be preserved (e.g., in an
          editor, although usually not necessary if XMI-to-XMI)

     • Challenges:
         Modification of an existing model (i.e., different from the
          general scheme)
         Possible interactive usage (requires a certain performance
          level)


74         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Implementation of Refactoring Transformations
     • Writing every rule
         Simple, but not scalable: typically about one rule per metamodel
          element (e.g., 4153 lines of code for UML)
     • Modifying a generated copy transformation
         Scales easily to a large number of metamodel elements, but
          important information is hidden
     • Superimposing a few rules on a copy transformation
         Relatively elegant: the generated copy transformation is left
          untouched, refactoring rules are grouped into a separate module

     • Common issue of these approaches: they copy the source model
       elements into a different target model
         Performance is not especially good, they do not scale to large
          models
         Identity of elements is not preserved for use within an editor



75          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
UML Public2Private – Superimposition
module Public2Private;
                                         Technique
create OUT : UML2 from IN : UML2;

rule Property {
  from                                                                             rule Property {
                                                                                      from
      s : UML2!Property (
            s.visibility = #public

  to
      )
                                                                                         s : UML2!Property (
      t : UML2!Property (
            visibility <- #private,
                                                                                            s.visibility = #public
            name <- s.name,                                                              )
                                                                                      to
            isLeaf <- s.isLeaf,
            isStatic <- s.isStatic,
            isOrdered <- s.isOrdered,
            isUnique <- s.isUnique,                                                      t : UML2!Property (
            isReadOnly <- s.isReadOnly,
            isDerived <- s.isDerived,
                                                                                            visibility <- #private,
            isDerivedUnion <- s.isDerivedUnion,
            aggregation <- s.aggregation,
                                                                                            name <- s.name,
            eAnnotations <- s.eAnnotations,                                                 isLeaf <- s.isLeaf,
                                                                                   …
            ownedComment <- s.ownedComment,
            clientDependency <- s.clientDependency,
            nameExpression <- s.nameExpression,
            type <- s.type,
            upperValue <- s.upperValue,
            lowerValue <- s.lowerValue,
            templateParameter <- s.templateParameter,
            end <- s.end,
            deployment <- s.deployment,
            templateBinding <- s.templateBinding,                                          Superimposed on
            ownedTemplateSignature <- s.ownedTemplateSignature,
            redefinedProperty <- s.redefinedProperty,                                      UML2Copy.atl
            defaultValue <- s.defaultValue,
            subsettedProperty <- s.subsettedProperty,                                      (4153 generated lines)
            association <- s.association,
            qualifier <- s.qualifier

}
  76  )
                   Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL Refining Mode
     • Challenges:
        Keeping as much as possible of ATL semantics
        Performance suitable for interactive usage
        Preservation of elements identity

     • ATL 2004 refining mode:
        Works as the approaches presented earlier: by copying
         source model elements to target model
        Only rules that do not perform simple copy need to be
         specified, with all bindings (similar to superimposition but with
         an implicit copy transformation)
        Keeps ATL semantics, but neither very performant, nor
         identity preserving



77        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL 2006 Refining Mode


     • Works by performing in-place transformation
       Still keeps ATL semantics
          (i.e., write-only target model during rule execution)
        Performs well-enough for interactive usage (see
        demo)
        Preserves elements identity

     • Only rules and bindings that do perform
       changes need to be specified
        Less verbose than previous techniques (including
        ATL 2004)

78       Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Public2Private in ATL 2006 Refining Mode




     module Public2Private;
     create OUT : UML refining IN : UML;
     rule Property {
       from
          s : UML!Property (s.visibility = #public)
       to
          t : UML!Property (
               visibility <- #private
          )
     }
79           Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
What would happen in Standard Mode?




     module Public2Private;
     create OUT : UML from IN : UML;
     rule Property {
       from
          s : UML!Property (s.visibility = #public)
       to
          t : UML!Property (
               visibility <- #private
          )
     }
80           Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Public2Private.atl on j2se-1_2-api.uml (6.17MiB)

                              Time (s)
                                           Bytecod Lines of
                          Transformat Tota   es     code
                              ion      l
 Superimposi
    tion                                                            2467779
                                      209                       216                                                41
                                                                       7

     Refining                        3.20                         11             354364                           15
                                                                                                                  2.7
81    Ratio                          65.3                      19.6                  69.6
         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Public2Private.atl on j2se-1_6-api.uml (13.14MiB)

                              Time (s)
                                           Bytecod Lines of
                          Transformat Tota   es     code
                              ion      l
 Superimposi
    tion                                                            5247898
                                      496                       515                                                41
                                                                       4

     Refining                        5.75                         25             674874                           15
                                                                                                                  2.7
82    Ratio                          86.3                      20.6                  77.8
         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Public2Private plus Accessors



rule Property {
 from
    s : UML!Property (
       s.visibility = #public)
 to
    t : UML!Property (
       visibility <- #private ),
    getter : UML!Operation (
       namespace <- s.namespace, -- ! see later
       name <- 'get' + s.name.firstToUpper,
       ownedParameter <- getterReturnParam   ),
    getterReturnParam : UML!Parameter (
       name <- 'return',
       direction <- #return,
       type <- s.type                        )
} …
83      Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL 2006 Refining Mode – Implementation
     Overview
     • Computing changes
         No change to the source model during rule execution, which
          happens as with a read-only source model
         All changes are stored in a RefiningTrace model

     • Applying changes
         After the execution of all rules

     • The trace:
         may be serialized
         could be serialized and not applied (e.g., to use a different
          application engine)



84         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Public2Private plus Accessors –
                             Changeability Issue



rule Property {
 from
    s : UML!Property (
       s.visibility = #public)
 to
    t : UML!Property (
       visibility <- #private ),
    getter : UML!Operation (
       namespace <- s.namespace,
       name <- 'get' + s.name.firstToUpper,
       ownedParameter <- getterReturnParam                                              ),
    getterReturnParam : UML!Parameter (
       name <- 'return',
       direction <- #return,
       type <- s.type                                                                   )
} …
85      Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Public2Private plus Accessors –
                             Introducing Reverse Bindings



rule Property {
 from
    s : UML!Property (
       s.visibility = #public)
 to
    t : UML!Property (
       visibility <- #private ),
    getter : UML!Operation ->
           (s.namespace.ownedOperation) (
       name <- 'get' + s.name.firstToUpper,
       ownedParameter <- getterReturnParam                                              ),
    getterReturnParam : UML!Parameter (
       name <- 'return',
       direction <- #return,
       type <- s.type                                                                   )
} …
86      Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Launching ATL 2006 Refining Transformations
• Adding inout models to the ATL Ant Task
<atl.launch path="${base.path}/Public2Private.atl">
 <inoutModel name="IN" model="source"/>
 <outModel name="refiningTrace"
   metamodel="RefiningTrace" model="refiningTrace"/>
</atl.launch>

• The user still sees different source and target models, but there
  are effectively the same

• There are two other ways to launch a refining transformation:
       Using the launch configuration (see next slide)
       Programmatically (e.g., from Eclipse plugins as shown in next exercise)


 87            Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL 2006 Refining Launch Configuration




88       Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Model Enrichment
     • Problem
        Adding information from model mB into model mA in order to obtain
         enriched model mA’

     • Approach
        Write a transformation refining mA and taking mB as additional
         source model
           create mA’ : MMA refining mA : MMA, mB : MMB;


     • Example:
        Annotating EDataTypes from an Ecore metamodel with
         instanceClassNames
         module ApplyAnnotations2Ecore;
         create OUT : Ecore refining IN : Ecore, annotations : Annotation;

89        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Model Enrichment Example
     -- @atlcompiler atlworkspace
     -- @nsURI Ecore=http://www.eclipse.org/emf/2002/Ecore
     module ApplyAnnotations2Ecore;
     create OUT : Ecore refining IN : Ecore, annotations : Annotation;
     rule DataTypeAnnotations {
       from
          s : Ecore!EDataType
       to
          t : Ecore!EDataType (
               instanceClassName <-
                    let a : String = s.getAnnotation('instanceClassName') in
                    if a.oclIsUndefined() then
                         s.instanceClassName
                    else
                         a
                    endif
          )
     }
     -- getAnnotation helper not shown here
     -- […]

90          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Agenda
     • Introduction
     • ATL Overview
     • First exercise: Model Visualization
     • Advanced Usage of ATL
     • Second exercise: Model Refactoring
     • Architecture
     • Third exercise: A DSL Compiler for SWTBot
     • ATL Industrialization
     • Discussions




91        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Second exercise: Model Refactoring
     • Intent
         Provide in-place refactoring actions on models
         Big models support
         Reversible actions




     • Realization: a refactoring pop-up menu
         Based on ATL refining mode
         Available on UML2 models (both with the tree editor and
          UML2Tools)
         Set public fields to private
         Optionally adds getters and setters

     Use-case: privatization of public attributes
92         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Second exercise: Model Refactoring
     • Example: refactoring on UML2Tools




93        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Agenda
     • Introduction
     • ATL Overview
     • First exercise: Model Visualization
     • Advanced Usage of ATL
     • Second exercise: Model Refactoring
     • Architecture
          Overview
          The new virtual machine: EMF-VM
     • Third exercise: A DSL Compiler for SWTBot
     • ATL Industrialization
     • Discussions


94        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL main plugins organization


                                                                             Eclipse ui integration

                                                                               Parser and Compiler
                                                                               utilities
                                                                                ATL Core API

                                                                               ATL EMF–specific VM
                                                                               ATL Regular VM


95        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL Core API
     • Problem
         ATL initial architecture changed many times, without strict
          conventions
         Integration of several contributions
         Two Vms, two compilers
     • Intent
         Need to reorganize ATL core to resolve maintenance and
          accessibility issues
         Provide an unique and simple way to use ATL
          programmatically
     • Realization
         A Core API which manages models loading/saving and ATL
          launching
         Provides extensibility at several levels


96          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL Core API




97       Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL architecture
     • Intermediate file format : ASM
     • Modular VM dedicated to M2M
       support
        A complete specification
         describes the VM
         (http://www.eclipse.org/m2m/atl/doc/)
        Can be implemented on different
         platforms (Java, .Net)




98         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL execution process
     • 2 steps
         Compilation
         Execution




99         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL Virtual Machine
      • ATL core engine
      • Byte code interpreter (ASM)
         Granular model management instruction
         Uses OCL/ATL type hierarchy
         Uses an abstract model handler layer
      • ATL VM defined by a concrete specification
         Allows other language implementation
      • ASM code
                                          ...
                                          <operation name="122">
                                                 <context type="8"/>
                                                 <parameters>
                                                 </parameters>
                                                 <code>
                                                    <push arg="77"/>
                                                    <push arg="25"/>
                                                    <findme/>
                                                    <push arg="23"/>
                                                    ...

100         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
EMF-VM
      • A new ATL Virtual Machine is now available
          Increased performance
          EMF-only (no wrapping of EObjects)
      • At this time...
          Some missing features (decreasing in number quickly):
             •UML profile support
             •Debugger interactions
      • Non-regression evaluated with a new test plugin




101          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Non-regression tests
      • Non-regression engine uses EMF Compare to check
        output models conformance

      • Non-regression tests also allows to check
       
           ATL Regular VM
       
           ATL Compiler
       
           ATL Parser

      • Provides a way for users to safely work on base
        components: bug corrections, new features




102           Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Non regression wiki page




103       Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
EMF-VM Benchmarks




104      Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Agenda
      • Introduction
      • ATL Overview
      • First exercise: Model Visualization
      • Advanced Usage of ATL
      • Second exercise: Model Refactoring
      • Architecture
      • Third exercise: A DSL Compiler for SWTBot
      • ATL Industrialization
      • Discussions




105        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Third Exercise: A DSL Compiler for SWTBot
      Intent
          Provide a simpler syntax for SWTBot (i.e., a
           Domain-Specific Language or DSL)
          Generate Java code from simpler syntax

      Prerequisites
         SWTBot DSL implementation (metamodel, syntax)
         SimpleJava metamodel (only what is necessary for
          generation of SWTBot code)

      Realization
         An ATL transformation from SWTBot to SimpleJava


106        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Third Exercise: A DSL Compiler for SWTBot




107       Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Agenda
      • Introduction
      • ATL Overview
      • First exercise: Model Visualization
      • Advanced Usage of ATL
      • Second exercise: Model Refactoring
      • Architecture
      • Third exercise: A DSL Compiler for SWTBot
      • ATL Industrialization
      • Discussions




108        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL Industrialization process
                                                       idea

                                                     Labo

           experimentation                                                                 industrialization




                  Users                                                               PME
         validation                                                                          commercialization
                                                    partnership

109        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Roadmap
      • Roadmap overview:
         Industrialization
            EMF-VM improvements
            Stabilization
            Internationalization
            Improve Eclipse integration
         New features
            Packaging
            Incremental transformation support
      • Means:
         Existing features amelioration (IDE)
         Complex features research (incremental)



110         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
ATL Releng module




111       Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Done
      • API refactoring
          Correction of current issues
          Provide a “clean” Java access to ATL for developers
      • ATL ant tasks
      • Documentation
          Merging wiki / pdf
          doc plugin synchronization
      • Many bugs corrections & feature improvements
          Loading an UML2 profile from a plugin
          Stable EMF ResourceSet management strategy
      • Examples: public2private
          Provide launch configuration, ant file and java popup samples



112          Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
What’s next?
      • IDE improvements
         Content assist
         Syntax colors
         File wizard
         Launch configurations
         Integration of a CS contribution: ATL profiler
      • Debugger
         Reimplemented for at least EMFVM
      • Documentation improvement




113         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Agenda
      • Introduction
      • ATL Overview
      • First exercise: Model Visualization
      • Advanced Usage of ATL
      • Second exercise: Model Refactoring
      • Architecture
      • Third exercise: A DSL Compiler for SWTBot
      • ATL Industrialization
      • Discussions




114        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
Discussion Topics
      • About ATL
          ATL versions (2004 vs. 2006), notably refining mode
          Best Practices
          Model Transformation Virtual Machines
          ATL vs. QVT

      • Around ATL
          M2M vs. M2T
          Where do models come from?
          Modeling platforms – AmmA
          Domain-Specific Languages and Modeling

       You can vote for the topics you are most interested in (2 or 3)
       You may suggest additional topics

115          Model Refactoring and other Advanced ATL Techniques | © 2009 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




116        Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
END
      • Questions or Comments?




117         Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0

More Related Content

What's hot

Model-Driven Software Engineering in Practice - Chapter 4 - Model-Driven Arch...
Model-Driven Software Engineering in Practice - Chapter 4 - Model-Driven Arch...Model-Driven Software Engineering in Practice - Chapter 4 - Model-Driven Arch...
Model-Driven Software Engineering in Practice - Chapter 4 - Model-Driven Arch...Jordi Cabot
 
Productionzing ML Model Using MLflow Model Serving
Productionzing ML Model Using MLflow Model ServingProductionzing ML Model Using MLflow Model Serving
Productionzing ML Model Using MLflow Model ServingDatabricks
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
Distributed Locking in Mule
Distributed Locking in MuleDistributed Locking in Mule
Distributed Locking in MuleSunil Kumar
 
Mockito a simple, intuitive mocking framework
Mockito   a simple, intuitive mocking frameworkMockito   a simple, intuitive mocking framework
Mockito a simple, intuitive mocking frameworkPhat VU
 
Drools 6.0 (Red Hat Summit)
Drools 6.0 (Red Hat Summit)Drools 6.0 (Red Hat Summit)
Drools 6.0 (Red Hat Summit)Mark Proctor
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Steve Pember
 
Qt multi threads
Qt multi threadsQt multi threads
Qt multi threadsYnon Perek
 
Circuit Breaker Pattern
Circuit Breaker PatternCircuit Breaker Pattern
Circuit Breaker PatternTung Nguyen
 
Model-Driven Software Engineering in Practice - Chapter 1 - Introduction
Model-Driven Software Engineering in Practice - Chapter 1 - IntroductionModel-Driven Software Engineering in Practice - Chapter 1 - Introduction
Model-Driven Software Engineering in Practice - Chapter 1 - IntroductionMarco Brambilla
 
Reliable Event Delivery in Apache Kafka Based on Retry Policy and Dead Letter...
Reliable Event Delivery in Apache Kafka Based on Retry Policy and Dead Letter...Reliable Event Delivery in Apache Kafka Based on Retry Policy and Dead Letter...
Reliable Event Delivery in Apache Kafka Based on Retry Policy and Dead Letter...HostedbyConfluent
 
KFServing and Kubeflow Pipelines
KFServing and Kubeflow PipelinesKFServing and Kubeflow Pipelines
KFServing and Kubeflow PipelinesAnimesh Singh
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in javakim.mens
 
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...Edureka!
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action Alex Movila
 
Jim Dowling - Multi-tenant Flink-as-a-Service on YARN
Jim Dowling - Multi-tenant Flink-as-a-Service on YARN Jim Dowling - Multi-tenant Flink-as-a-Service on YARN
Jim Dowling - Multi-tenant Flink-as-a-Service on YARN Flink Forward
 
Model-Driven Software Engineering in Practice - Chapter 2 - MDSE Principles
Model-Driven Software Engineering in Practice - Chapter 2 - MDSE PrinciplesModel-Driven Software Engineering in Practice - Chapter 2 - MDSE Principles
Model-Driven Software Engineering in Practice - Chapter 2 - MDSE PrinciplesMarco Brambilla
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1Shahzad
 

What's hot (20)

Model-Driven Software Engineering in Practice - Chapter 4 - Model-Driven Arch...
Model-Driven Software Engineering in Practice - Chapter 4 - Model-Driven Arch...Model-Driven Software Engineering in Practice - Chapter 4 - Model-Driven Arch...
Model-Driven Software Engineering in Practice - Chapter 4 - Model-Driven Arch...
 
Productionzing ML Model Using MLflow Model Serving
Productionzing ML Model Using MLflow Model ServingProductionzing ML Model Using MLflow Model Serving
Productionzing ML Model Using MLflow Model Serving
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Introduction to MDA
Introduction to MDAIntroduction to MDA
Introduction to MDA
 
Distributed Locking in Mule
Distributed Locking in MuleDistributed Locking in Mule
Distributed Locking in Mule
 
Mockito a simple, intuitive mocking framework
Mockito   a simple, intuitive mocking frameworkMockito   a simple, intuitive mocking framework
Mockito a simple, intuitive mocking framework
 
Drools 6.0 (Red Hat Summit)
Drools 6.0 (Red Hat Summit)Drools 6.0 (Red Hat Summit)
Drools 6.0 (Red Hat Summit)
 
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
Anatomy of a Spring Boot App with Clean Architecture - Spring I/O 2023
 
Qt multi threads
Qt multi threadsQt multi threads
Qt multi threads
 
Circuit Breaker Pattern
Circuit Breaker PatternCircuit Breaker Pattern
Circuit Breaker Pattern
 
Model-Driven Software Engineering in Practice - Chapter 1 - Introduction
Model-Driven Software Engineering in Practice - Chapter 1 - IntroductionModel-Driven Software Engineering in Practice - Chapter 1 - Introduction
Model-Driven Software Engineering in Practice - Chapter 1 - Introduction
 
Completable future
Completable futureCompletable future
Completable future
 
Reliable Event Delivery in Apache Kafka Based on Retry Policy and Dead Letter...
Reliable Event Delivery in Apache Kafka Based on Retry Policy and Dead Letter...Reliable Event Delivery in Apache Kafka Based on Retry Policy and Dead Letter...
Reliable Event Delivery in Apache Kafka Based on Retry Policy and Dead Letter...
 
KFServing and Kubeflow Pipelines
KFServing and Kubeflow PipelinesKFServing and Kubeflow Pipelines
KFServing and Kubeflow Pipelines
 
Basics of reflection in java
Basics of reflection in javaBasics of reflection in java
Basics of reflection in java
 
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Jim Dowling - Multi-tenant Flink-as-a-Service on YARN
Jim Dowling - Multi-tenant Flink-as-a-Service on YARN Jim Dowling - Multi-tenant Flink-as-a-Service on YARN
Jim Dowling - Multi-tenant Flink-as-a-Service on YARN
 
Model-Driven Software Engineering in Practice - Chapter 2 - MDSE Principles
Model-Driven Software Engineering in Practice - Chapter 2 - MDSE PrinciplesModel-Driven Software Engineering in Practice - Chapter 2 - MDSE Principles
Model-Driven Software Engineering in Practice - Chapter 2 - MDSE Principles
 
Design Pattern For C# Part 1
Design Pattern For C# Part 1Design Pattern For C# Part 1
Design Pattern For C# Part 1
 

Viewers also liked

ATL tutorial - EclipseCon 2008
ATL tutorial - EclipseCon 2008ATL tutorial - EclipseCon 2008
ATL tutorial - EclipseCon 2008William Piers
 
Transformation M2M avec ATL
Transformation M2M avec ATL Transformation M2M avec ATL
Transformation M2M avec ATL Halima Bouabdelli
 
ATL Industrialization
ATL IndustrializationATL Industrialization
ATL IndustrializationWilliam Piers
 
Transformation de carrés en cercles avec Atlas Transformation Language(ATL)
Transformation de carrés en cercles avec Atlas Transformation Language(ATL)Transformation de carrés en cercles avec Atlas Transformation Language(ATL)
Transformation de carrés en cercles avec Atlas Transformation Language(ATL)Amira Hakim
 
Optimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc resultsOptimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc resultsEdward Willink
 
OCCIware Contribution to the EU consultation on Cloud Computing Research Inno...
OCCIware Contribution to the EU consultation on Cloud Computing Research Inno...OCCIware Contribution to the EU consultation on Cloud Computing Research Inno...
OCCIware Contribution to the EU consultation on Cloud Computing Research Inno...OCCIware
 
Ressource numérique Circuit électrique au primaire
Ressource numérique Circuit électrique au primaire Ressource numérique Circuit électrique au primaire
Ressource numérique Circuit électrique au primaire Erradi Mohamed
 
Model Transformation: A survey of the state of the art
Model Transformation: A survey of the state of the artModel Transformation: A survey of the state of the art
Model Transformation: A survey of the state of the artTom Mens
 
OCCIware: extensible and standard-based XaaS platform to manage everything in...
OCCIware: extensible and standard-based XaaS platform to manage everything in...OCCIware: extensible and standard-based XaaS platform to manage everything in...
OCCIware: extensible and standard-based XaaS platform to manage everything in...OCCIware
 
Timing verification of automotive communication architecture using quantile ...
Timing verification of automotive communication  architecture using quantile ...Timing verification of automotive communication  architecture using quantile ...
Timing verification of automotive communication architecture using quantile ...RealTime-at-Work (RTaW)
 
Vbisigk
VbisigkVbisigk
VbisigkISIG
 
النشاط العلمي - الكهرباء
النشاط العلمي  -   الكهرباءالنشاط العلمي  -   الكهرباء
النشاط العلمي - الكهرباءErradi Mohamed
 
mis
mismis
misISIG
 
Yet Another Three QVT Languages
Yet Another Three QVT LanguagesYet Another Three QVT Languages
Yet Another Three QVT LanguagesEdward Willink
 

Viewers also liked (20)

ATL tutorial - EclipseCon 2008
ATL tutorial - EclipseCon 2008ATL tutorial - EclipseCon 2008
ATL tutorial - EclipseCon 2008
 
Transformation M2M avec ATL
Transformation M2M avec ATL Transformation M2M avec ATL
Transformation M2M avec ATL
 
ATL Industrialization
ATL IndustrializationATL Industrialization
ATL Industrialization
 
Model evolution and versioning
Model evolution and versioningModel evolution and versioning
Model evolution and versioning
 
Transformation de carrés en cercles avec Atlas Transformation Language(ATL)
Transformation de carrés en cercles avec Atlas Transformation Language(ATL)Transformation de carrés en cercles avec Atlas Transformation Language(ATL)
Transformation de carrés en cercles avec Atlas Transformation Language(ATL)
 
ATL
ATLATL
ATL
 
Optimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc resultsOptimized declarative transformation First Eclipse QVTc results
Optimized declarative transformation First Eclipse QVTc results
 
OCCIware
OCCIwareOCCIware
OCCIware
 
OCCIware Contribution to the EU consultation on Cloud Computing Research Inno...
OCCIware Contribution to the EU consultation on Cloud Computing Research Inno...OCCIware Contribution to the EU consultation on Cloud Computing Research Inno...
OCCIware Contribution to the EU consultation on Cloud Computing Research Inno...
 
Aligning OCL and UML
Aligning OCL and UMLAligning OCL and UML
Aligning OCL and UML
 
Ressource numérique Circuit électrique au primaire
Ressource numérique Circuit électrique au primaire Ressource numérique Circuit électrique au primaire
Ressource numérique Circuit électrique au primaire
 
Model Transformation: A survey of the state of the art
Model Transformation: A survey of the state of the artModel Transformation: A survey of the state of the art
Model Transformation: A survey of the state of the art
 
What fUML can bring to MBSE?
What fUML can bring to MBSE?What fUML can bring to MBSE?
What fUML can bring to MBSE?
 
OCCIware: extensible and standard-based XaaS platform to manage everything in...
OCCIware: extensible and standard-based XaaS platform to manage everything in...OCCIware: extensible and standard-based XaaS platform to manage everything in...
OCCIware: extensible and standard-based XaaS platform to manage everything in...
 
Timing verification of automotive communication architecture using quantile ...
Timing verification of automotive communication  architecture using quantile ...Timing verification of automotive communication  architecture using quantile ...
Timing verification of automotive communication architecture using quantile ...
 
Java vs .Net
Java vs .NetJava vs .Net
Java vs .Net
 
Vbisigk
VbisigkVbisigk
Vbisigk
 
النشاط العلمي - الكهرباء
النشاط العلمي  -   الكهرباءالنشاط العلمي  -   الكهرباء
النشاط العلمي - الكهرباء
 
mis
mismis
mis
 
Yet Another Three QVT Languages
Yet Another Three QVT LanguagesYet Another Three QVT Languages
Yet Another Three QVT Languages
 

Similar to Model Refactoring and ATL Techniques

What's New in MDT?
What's New in MDT?What's New in MDT?
What's New in MDT?Kenn Hussey
 
Acceleo MTL Code Generation
Acceleo MTL Code GenerationAcceleo MTL Code Generation
Acceleo MTL Code GenerationJonathan Musset
 
Team Work With Models Web
Team Work With Models WebTeam Work With Models Web
Team Work With Models WebCédric Brun
 
Software Technologies for the Interoperability, Reusability and Adaptability...
Software Technologies for the Interoperability,  Reusability and Adaptability...Software Technologies for the Interoperability,  Reusability and Adaptability...
Software Technologies for the Interoperability, Reusability and Adaptability...Daniele Gianni
 
AIXM, WXXM, FIXM a unified approach to Modelling
AIXM, WXXM, FIXM a unified approach to ModellingAIXM, WXXM, FIXM a unified approach to Modelling
AIXM, WXXM, FIXM a unified approach to ModellingSnowflake Software
 
Open Source Meets Open Specifications
Open Source Meets Open SpecificationsOpen Source Meets Open Specifications
Open Source Meets Open SpecificationsKenn Hussey
 
Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013Noopur Gupta
 
Acceleo Day - Acceleo Mtl Code Generation
Acceleo Day - Acceleo Mtl Code GenerationAcceleo Day - Acceleo Mtl Code Generation
Acceleo Day - Acceleo Mtl Code GenerationCédric Brun
 
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)mfrancis
 
RuCORD: Rule-based Composite Operation Recovering and Detection to Support Co...
RuCORD: Rule-based Composite Operation Recovering and Detection to Support Co...RuCORD: Rule-based Composite Operation Recovering and Detection to Support Co...
RuCORD: Rule-based Composite Operation Recovering and Detection to Support Co...Amanuel Alemayehu
 
Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...
Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...
Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...Sameh El-Ashry
 
Spark Summit EU talk by Mikhail Semeniuk Hollin Wilkins
Spark Summit EU talk by Mikhail Semeniuk Hollin WilkinsSpark Summit EU talk by Mikhail Semeniuk Hollin Wilkins
Spark Summit EU talk by Mikhail Semeniuk Hollin WilkinsSpark Summit
 
Model Execution: Past, Present and Future
Model Execution: Past, Present and FutureModel Execution: Past, Present and Future
Model Execution: Past, Present and FutureBenoit Combemale
 
Modal Driven Architecture In Software Engineering By NADEEM AHMED
Modal Driven Architecture In Software Engineering By NADEEM AHMED Modal Driven Architecture In Software Engineering By NADEEM AHMED
Modal Driven Architecture In Software Engineering By NADEEM AHMED NA000000
 
20230419-LLaMA-Adapter_ Efficient Fine-tuning of Language Models with Zero-in...
20230419-LLaMA-Adapter_ Efficient Fine-tuning of Language Models with Zero-in...20230419-LLaMA-Adapter_ Efficient Fine-tuning of Language Models with Zero-in...
20230419-LLaMA-Adapter_ Efficient Fine-tuning of Language Models with Zero-in...San Kim
 
Telecommunications Service Creation: Towards Extensions for Enterprise Archit...
Telecommunications Service Creation: Towards Extensions for Enterprise Archit...Telecommunications Service Creation: Towards Extensions for Enterprise Archit...
Telecommunications Service Creation: Towards Extensions for Enterprise Archit...Vanea Chiprianov
 

Similar to Model Refactoring and ATL Techniques (20)

QVT & MTL In Eclipse
QVT & MTL In EclipseQVT & MTL In Eclipse
QVT & MTL In Eclipse
 
What's New in MDT?
What's New in MDT?What's New in MDT?
What's New in MDT?
 
Acceleo MTL Code Generation
Acceleo MTL Code GenerationAcceleo MTL Code Generation
Acceleo MTL Code Generation
 
Team Work With Models Web
Team Work With Models WebTeam Work With Models Web
Team Work With Models Web
 
Software Technologies for the Interoperability, Reusability and Adaptability...
Software Technologies for the Interoperability,  Reusability and Adaptability...Software Technologies for the Interoperability,  Reusability and Adaptability...
Software Technologies for the Interoperability, Reusability and Adaptability...
 
AIXM, WXXM, FIXM a unified approach to Modelling
AIXM, WXXM, FIXM a unified approach to ModellingAIXM, WXXM, FIXM a unified approach to Modelling
AIXM, WXXM, FIXM a unified approach to Modelling
 
Open Source Meets Open Specifications
Open Source Meets Open SpecificationsOpen Source Meets Open Specifications
Open Source Meets Open Specifications
 
Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013Eclipse and Java 8 - Eclipse Day India 2013
Eclipse and Java 8 - Eclipse Day India 2013
 
Acceleo Day - Acceleo Mtl Code Generation
Acceleo Day - Acceleo Mtl Code GenerationAcceleo Day - Acceleo Mtl Code Generation
Acceleo Day - Acceleo Mtl Code Generation
 
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)Software AG Application Modularity - OSGi and JPMS (Jigsaw)
Software AG Application Modularity - OSGi and JPMS (Jigsaw)
 
2010 06 22 omg - obeo
2010 06 22   omg - obeo2010 06 22   omg - obeo
2010 06 22 omg - obeo
 
RuCORD: Rule-based Composite Operation Recovering and Detection to Support Co...
RuCORD: Rule-based Composite Operation Recovering and Detection to Support Co...RuCORD: Rule-based Composite Operation Recovering and Detection to Support Co...
RuCORD: Rule-based Composite Operation Recovering and Detection to Support Co...
 
Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...
Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...
Efficient Methodology of Sampling UVM RAL During Simulation for SoC Functiona...
 
Spark Summit EU talk by Mikhail Semeniuk Hollin Wilkins
Spark Summit EU talk by Mikhail Semeniuk Hollin WilkinsSpark Summit EU talk by Mikhail Semeniuk Hollin Wilkins
Spark Summit EU talk by Mikhail Semeniuk Hollin Wilkins
 
Model Execution: Past, Present and Future
Model Execution: Past, Present and FutureModel Execution: Past, Present and Future
Model Execution: Past, Present and Future
 
Modal Driven Architecture In Software Engineering By NADEEM AHMED
Modal Driven Architecture In Software Engineering By NADEEM AHMED Modal Driven Architecture In Software Engineering By NADEEM AHMED
Modal Driven Architecture In Software Engineering By NADEEM AHMED
 
20230419-LLaMA-Adapter_ Efficient Fine-tuning of Language Models with Zero-in...
20230419-LLaMA-Adapter_ Efficient Fine-tuning of Language Models with Zero-in...20230419-LLaMA-Adapter_ Efficient Fine-tuning of Language Models with Zero-in...
20230419-LLaMA-Adapter_ Efficient Fine-tuning of Language Models with Zero-in...
 
Telecommunications Service Creation: Towards Extensions for Enterprise Archit...
Telecommunications Service Creation: Towards Extensions for Enterprise Archit...Telecommunications Service Creation: Towards Extensions for Enterprise Archit...
Telecommunications Service Creation: Towards Extensions for Enterprise Archit...
 
Whats new in Java 7
Whats new in Java 7Whats new in Java 7
Whats new in Java 7
 
Whats new in Java 7
Whats new in Java 7Whats new in Java 7
Whats new in Java 7
 

Recently uploaded

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dashnarutouzumaki53779
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate AgentsRyan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
Ryan Mahoney - Will Artificial Intelligence Replace Real Estate Agents
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Visualising and forecasting stocks using Dash
Visualising and forecasting stocks using DashVisualising and forecasting stocks using Dash
Visualising and forecasting stocks using Dash
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

Model Refactoring and ATL Techniques

  • 1. Model Refactoring and other Advanced ATL Techniques Frédéric Jouault (INRIA) William Piers (Obeo) © 2009 by INRIA, Obeo; made available under the EPL v1.0 | 23 March 2009
  • 2. What You Will Learn in This Tutorial • Refactoring models efficiently • Compiling a DSL for SWTBot • Visualizing models 2 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 3. Discussion Topics • About ATL  ATL versions (2004 vs. 2006), notably refining mode  Best Practices  Model Transformation Virtual Machines  ATL vs. QVT • Around ATL  M2M vs. M2T  Where do models come from?  Modeling platforms – AmmA  Domain-Specific Languages and Modeling  You can vote for the topics you are most interested in (2 or 3)  You may suggest additional topics 3 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 4. Agenda • Introduction  Model-To-Model transformation in the MDE field  M2M vs. M2T • ATL Overview • First exercise: Model Visualization • Advanced Usage of ATL • Second exercise: Model Refactoring • Architecture • Third exercise: A DSL Compiler for SWTBot • ATL Industrialization • Discussions 4 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 5. 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) 5 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 6. Definitions • A model transformation is the automatic creation of target models from source models. • Applications*:  Interoperability of Telephony Languages  Modeling Web applications  Converting graphics (e.g., Rational Rose to UML2 Tools)  Measuring and verifying UML models  etc. Whatever your problem, you can write a lot of Java code or a (generally) much simpler ATL transformation. * Use cases available at: http://www.eclipse.org/m2m/atl/usecases/ 6 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 7. Operational context: small theory conformsTo Metametamodel Class Class conformsTo conformsTo MMa ATL MMb Class Class Class Green Rule Blue Class Class Red MMa2MMb.atl Pink Rule Rule conformsTo R2B G2P conformsTo Ma Mb 7 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 8. Operational context of ATL MOF MMa is the MMB is the source target metamodel MMa ATL MMb metamodel MMa2MMb.atl Ma Mb Ma is the source model Mb is the target model 8 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 9. 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 9 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 10. Agenda • Introduction • ATL Overview  Available resources: wiki, zoo, newsgroup, use cases, etc.  ATL language description • First exercise: Model Visualization • Advanced Usage of ATL • Second exercise: Model Refactoring • Architecture • Third exercise: A DSL Compiler for SWTBot • ATL Industrialization • Discussions 10 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 11. 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 11 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 12. ATL community • Active community  Newsgroup: news://news.eclipse.org/eclipse.modeling.m2m  Wiki: http://wiki.eclipse.org/ATL  Bugzilla  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/ 12 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 13. ATL documentation • For a long time, ATL doc was dispatched over several places  ATL User Manual, out of date  ATL wiki, disorganized  Some information in newsgroup, mailing lists... • Now merged into ATL wiki http://wiki.eclipse.org/ATL/User_Guide • Use of Mylyn Wikitext tool to generate Eclipse Help • Eclipse Help produces a portable, printable, searchable documentation support 13 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 14. ATL documentation Mylyn WikiText Eclipse Wiki extraction to collaborative Eclipse Help edition 14 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 15. 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,  Side-effect free navigation (and query) language: OCL 2.0  Imperative part:  Called rules,  Action blocks. • Recommended programming style: declarative 15 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 16. ATL overview (continued) • A declarative rule specifies:  a source pattern to be matched in the source models,  a target pattern to be created in the target models for each match during rule application. • 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. 16 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 17. 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,  Lazy rules that are applied as many times for each match as 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. 17 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 18. Declarative rules: source pattern • The source pattern is composed of:  A labeled set of types coming from the source metamodels,  A guard (Boolean expression) used to filter matches . • 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. 18 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 19. 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. 19 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 20. 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. 20 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 21. Example: ClassDiagram to Relational – Overview • The source metamodel ClassDiagram is a simplification of class diagrams. • The target metamodel Relational is a simplification of the relational model.  ATL declaration of the transformation: module ClassDiagram2Relational; create Mout : Relational from Min : ClassDiagram; • The transformation excerpts used in this presentation come from: http://www.eclipse.org/m2m/atl/atlTransformations/#Class2Relational 21 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 22. Source Metamodel: ClassDiagram NamedElement +name : String Classifier +type DataType Class +attr Attribute +multivalued : Boolean owner * {ordered } 22 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 23. Target Metamodel: Relational Named +name:String Table + col Column * + type Type + owner * { ordered } + keyOf 0..1 + key * 23 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 24. Sample Source and Target Models Class2Table SingleValuedAttribute2Column MultiValuedAttribute2Column 24 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 25. ClassDiagram2Relational.atl – overview NamedElement +name : String Class2Table SingleValuedAttribute2Column MultiValuedAttribute2Column Classifier +type Named DataType Class Attribute +name:String +attr +multivalued : Boolean owner * { ordered } Table + col Column * + type Type + owner * {ordered } + keyOf 0..1 + key * 25 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 26. ClassDiagram2Relational.atl – overview • Informal description of rules  Class2Table:  A table is created from each class,  The columns of the table correspond to the single-valued attributes of the class,  A column corresponding to the key of the table is created.  SingleValuedAttribute2Column:  A column is created from each single-valued attribute.  MultiValuedAttribute2Column:  A table with two columns is created from each multi-valued attribute,  One column refers to the key of the table created from the owner class of the attribute,  The second column contains the value of the attribute. 26 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 27. Rule Class2Table (1 Of 4) • For each Class, create a Table : rule Class2Table { from -- source pattern c : ClassDiagram!Class to -- target pattern t : Relational!Table } 27 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 28. Rule Class2Table (2 Of 4) • The name of the Table is the name of the Class: rule Class2Table { from c : ClassDiagram!Class to t : Relational!Table ( name <- c.name -- a simple binding ) } 28 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 29. Rule Class2Table (3 Of 4) • The columns of the table correspond to the single-valued attributes of the class: rule Class2Table { from c : ClassDiagram!Class to t : Relational!Table ( name <- c.name, col <- c.attr->select(e | -- a binding not e.multiValued -- using complex ) -- navigation ) } • Remark: attributes are automatically resolved into columns by automatic traceability support. 29 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 30. Rule Class2Table (4 Of 4) • Each Table owns a key containing a unique identifier: rule Class2Table { from c : ClassDiagram!Class to t : Relational!Table ( name <- c.name, col <- c.attr->select(e | not e.multiValued )->union(Sequence {key}), key <- Set {key} ), key : Relational!Column ( -- another target name <- ‘Id’ -- pattern element ) -- for the key 30 } Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 31. Rule SingleValuedAttribute2Column • For each single-valued Attribute create a Column: rule SingleValuedAttribute2Column { from -- the guard is used for selection a : ClassDiagram!Attribute (not a.multiValued) to c : Relational!Column ( name <- a.name ) } 31 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 32. Rule MultiValuedAttribute2Column • For each multi-valued Attribute create a Table, which contains two columns:  The identifier of the table created from the class owner of the Attribute  The value. rule MultiValuedAttribute2Column { id : Relational!Column ( from a : ClassDiagram!Attribute (a.multiValued) name <- ‘Id’ to ), t : Relational!Table ( value : Relational!Column ( name <- a.owner.name + ‘_’ + a.name, name <- a.name col <- Sequence {id, value} ) ), } 32 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 33. 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 33 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 34. ATL/OCL types hierarchy 34 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 35. Running ATL/OCL Queries Within Eclipse • Considering a given OCL expression, such as: 5 mod 2 • Place it in an ATL query, for instance in file TestQuery.atl: query TestQuery = (5 mod 2).debug('Result'); • Where the call to OclAny.debug(String) : OclAny:  Does not change the result (it returns the value on which it is called)  Prints the result on the console  This operation may be called anywhere (e.g., to print intermediate values) • Advantages:  May query any model  May use debugger • Drawbacks:  Cannot specify a context 35 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 36. Iterator Expressions Returning Collections • collect Query: Sequence {1, 2, 3, 4}->collect(e | e + 2) Result: Sequence {3, 4, 5, 6} • reject Query: Sequence {1, 2, 3, 4}->reject(e | e > 2) Result: Sequence {1, 2} • select Query: Sequence {1, 2, 3, 4}->select(e | e > 2) Result: Sequence {3, 4} • sortedBy Query: Sequence {3, 4, 1, 2}->sortedBy(e | e) Result: Sequence {1, 2, 3, 4} 36 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 37. Predicate Iterator Expressions Admitting Multiple Iterators • exists Sequence {1, 2, 3, 4}->exists(e | true e > 2) Sequence • forAll {1, 2, 3, 4}->exists(e | fals e < 1) e Sequence {1, 2, 3, 4}->exists(e, | true Sequence {1, 2, 3, 4}->forAll(e false f |> 2) f + 3) e e= Sequence {1, 2, 3, 4}->forAll(e | true e > 0) 37 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 38. Other Iterator Expressions with One Iterator • any Query: Set{1, 2, 3, 4}->any(e | e > 2) Result: 3 Query: Set{1, 2, 3, 4}->any(e | e > 2) Result: 4 • isUnique Query: Sequence {1, 2, 3, 4}->isUnique(e | e mod 2 = 1) Result: false (Sequence {1, 0, 1, 0} contains duplicates) Query: Sequence {1, 2, 3, 4}->isUnique(e | e) Result: true • one Query: Set{1, 2, 3, 4}->one(e | e > 2) Result: false 38 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 39. Iterate Expression • Enables computation of any value from a collection • Example: Sequence {'one', 'two', 'three'}->iterate(e; acc : String = '(' | acc + if acc = '(' then '' else ', 'endif + e ) + ')' Result: '(one, two, three)' • Description:  The accumulator is initialized  For each element in the source:  The iterator gets the value of this element  The body is evaluated  The accumulator receives the resulting value  The result is the value of the accumulator at the end of the iteration 39 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 40. ATL editor 40 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 41. ATL content assist • ADT (ATL Development Tools) has recently been improved with basic content assist  Type completion  Left-side bindings completion  Basic code templates 41 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 42. ATL Launch Configuration 42 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 43. Launching ATL using ANT • Historically provided by GMT/AM3 • A new set of tasks is directly available into ATL 3.0  Very close to the old AM3 tasks  am3.saveModel => atl.saveModel  am3.loadModel => atl.loadModel  am3.atl => atl.launch  Allows to specify transformation launching with more parameters  Specific Injector/Extractor • Provide a way to chain transformations 43 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 44. Launching ATL using ANT <project name="ClassDiagram2Relational" default="main"> <property name="source" value="ClassDiagram/Sample-ClassDiagram.xmi"/> <property name="target" value="Relational/Sample-Relational.xmi"/> <target name="main" depends="loadMetamodels"> <atl.loadModel modelHandler="EMF" name="myClassDiagram" metamodel="ClassDiagram" path="${source}"/> <atl.launch path="ATLFiles/ClassDiagram2Relational.atl"> <inModel name="ClassDiagram" model="ClassDiagram"/> <inModel name="IN" model="myClassDiagram"/> <inModel name="Relational" model="Relational"/> <outModel name="OUT" model="myRelational" metamodel="Relational"/> </atl.launch> <atl.saveModel model="myRelational" path="${target}"/> </target> <target name="loadMetamodels"> <atl.loadModel modelHandler="EMF" name="ClassDiagram" metamodel="%EMF" path="ClassDiagram/ClassDiagram.ecore"/> <atl.loadModel modelHandler="EMF" name="Relational" metamodel="%EMF" path="Relational/Relational.ecore" /> </target> </project> 44 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 45. Agenda • Introduction • ATL Overview • First exercise: Model Visualization • Advanced Usage of ATL • Second exercise: Model Refactoring • Architecture • Third exercise: A DSL Compiler for SWTBot • ATL Industrialization • Discussions 45 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 46. First exercise: Model Visualization • Context  UML models (but general approach) • Objective  provide a different way to visualize models  applications in reverse engineering cartography • A visualization tool: prefuse (http://prefuse.org/)  Advanced / dynamic visualizations  BSD license  Accepts many data formats as input  GraphML  TreeML 46 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 47. First exercise: Model Visualization • Overview: UML Model Prefuse visualization 47 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 48. Agenda • Introduction • ATL Overview • First exercise: Model Visualization • Advanced Usage of ATL • Simple and Efficient Refactoring Transformations • Model Enrichment • Second exercise: Model Refactoring • Architecture • Third exercise: A DSL Compiler for SWTBot • ATL Industrialization • Discussions 48 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 49. Writing Interpreters in ATL • An ATL interpreter typically evaluates a model into a value.  Example: simple expressions. • Evaluation may involve input data that is not part of the model:  Example: XPath expressions evaluates over an XML model. • The interpreter may be part of a larger transformation. • How to write an evaluator:  Define an evaluation helper on each metamodel class to evaluate. 49 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 50. Example: Metamodel for Simple Expressions Expression +right +left IntegerExp OperatorExp +value : Integer +operator : String 50 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 51. ATL Interpreter for Simple Expressions query CalcEval = let root : Calc!Expression.allInstances()->any(e | -- select root e.refImmediateComposite().oclIsUndefined()) in root.eval().debug('Result'); -- evaluate helper context Calc!IntegerExp def: eval() : Integer = self.value; helper context Calc!OperatorExp def: eval() : Integer = if self.operator = '+' then self.left.eval() + self.right.eval() else if self.operator = '*' then self.left.eval() * self.right.eval() else self.operator.debug('UnsupportedOperator') endif endif; 51 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 52. Simple Expressions in Java (1 Of 3) abstract class Expression { public abstract int eval(); } class IntegerExp extends Expression { int value; public IntegerExp(int value) { this.value = value; } public int eval() { return value; } } 52 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 53. Simple Expressions in Java (2 Of 3) class OperatorExp extends Expression { Expression left; String operator; Expression right; public OperatorExp(Expression left, String operator, Expression right) { this.left = left; this.operator = operator; this.right = right; } public int eval() { int ret = 0; if("+".equals(operator)) { ret = left.eval() + right.eval(); } else if("*".equals(operator)) { ret = left.eval() * right.eval(); } else { System.err.println("Unsupported operator: " + operator); System.exit(1); } return ret; } } 53 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 54. Simple Expressions in Java (3 Of 3) public class TestExpression { public static void main(String args[]) { System.out.println( // evaluating 1 + 4 * 3 new OperatorExp( new IntegerExp(1), "+", new OperatorExp( new IntegerExp(4), "*", new IntegerExp(3) ) ).eval() ); } } 54 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 55. Writing Serializers in ATL • A serializer transforms a source model into a String. • It is a special kind of interpreter that evaluates into a String representing the evaluated model. • Pros:  Any string may be computed (e.g., XML, HTML).  Easily usable from within a transformation (e.g., when parts of the source model correspond to strings in the target model). • Cons:  A TCS syntax specification can already be used for serialization.  Some complex syntactic rules (e.g., proper parenthesizing of expressions) are hard to represent (but TCS does it 55 automatically). Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 56. Example: ATL Serializer for Simple Expressions query CalcEval = let root : Calc!Expression.allInstances()->any(e | -- select root e.refImmediateComposite().oclIsUndefined()) in root.serialize().debug('Result'); -- serialize helper context Calc!IntegerExp def: serialize() : String = self.value.toString(); helper context Calc!OperatorExp def: serialize() : String = '(' + self.left.serialize() + ' ' + self.operator + ' ' + self.right.serialize() + ')'; 56 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 57. Simple copy -- Source metamodel: MMA -- Target metamodel: MMB class A1 { class B1 { attribute v1 : String; attribute v1 : String; attribute v2 : String; attribute v2 : String; } } module MMAtoMMB; create OUT : MMB from IN : MMA; rule A1toB1 { from s : MMA!A1 to t : MMB!B1 ( v1 <- s.v1, v2 <- s.v2 ) } 57 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 58. Structure creation -- Source metamodel: MMA -- Target metamodel: MMB class A1 { class B1 { reference b2 : B2; attribute v1 : String; reference b3 : B3; } attribute v2 : String; class B2 { attribute v1 : String; } } class B3 { attribute v2 : String; } module MMAtoMMB; t2 : MMB!B2 ( create OUT : MMB from IN : MMA; v1 <- s.v1 rule A1toB1andB2andB3 { ), from t3 : MMB!B3 ( s : MMA!A1 v2 <- s.v2 to ) t1 : MMB!B1 ( } b2 <- t2, b3 <- t3 ), 58 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 59. Structure simplification -- Source metamodel: MMA -- Target metamodel: MMB class A1 { reference a2 : A2; class B1 { reference a3 : A3; } attribute v1 : String; class A2 { attribute v1 : String; } attribute v2 : String; class A3 { attribute v2 : String; } } module MMAtoMMB; create OUT : MMB from IN : MMA; rule A1toB1 { from s : MMA!A1 to t : MMB!B1 ( v1 <- s.a2.v1, v2 <- s.a3.v2 ) } 59 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 60. Structure simplification (needlessly more complex) -- Source metamodel: MMA -- Target metamodel: MMB class A1 { reference a2 : A2; class B1 { reference a3 : A3; } attribute v1 : String; class A2 { attribute v1 : String; } attribute v2 : String; class A3 { attribute v2 : String; } } module MMAtoMMB; create OUT : MMB from IN : MMA; rule A1toB1 { from s1 : MMA!A1, s2 : MMA!A2, s3 : MMA!A3 (s1.a2 = s2 and s1.a3 = s3) to t : MMB!B1 ( v1 <- s.a2.v1, v2 <- s.a3.v2 ) } 60 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 61. Traceability: implicit resolution of default elements -- Source metamodel: MMA -- Target metamodel: MMB class A1 { reference a2 : A2; class B1 { reference b2 : B2; reference a3 : A3; } reference b3 : B3; } class A2 { attribute v1 : String; } class B2 { attribute v1 : String; } class A3 { attribute v2 : String; } class B3 { attribute v2 : String; } module MMAtoMMB; rule A2toB2 { create OUT : MMB from IN : MMA; from s : MMA!A2 rule A1toB1 { to t : MMB!B2 ( from v1 <- s.v1 ) s : MMA!A1 } to rule A3toB3 { t : MMB!B1 ( from s : MMA!A3 b2 <- s.a2, -- HERE to t : MMB!B3 ( b3 <- s.a3 -- HERE v2 <- s.v2 ) ) } } 61 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 62. Remark: same result, less modular -- Source metamodel: MMA -- Target metamodel: MMB class A1 { reference a2 : A2; class B1 { reference b2 : B2; reference a3 : A3; } reference b3 : B3; } class A2 { attribute v1 : String; } class B2 { attribute v1 : String; } class A3 { attribute v2 : String; } class B3 { attribute v2 : String; } module MMAtoMMB; t2 : MMB!B2 ( create OUT : MMB from IN : MMA; v1 <- s.a2.v1 rule A1toB1 { ), from t3 : MMB!B3 ( s : MMA!A1 v2 <- s.a3.v2 to ) t1 : MMB!B1 ( } b2 <- t2, b3 <- t3 ), 62 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 63. Traceability: resolveTemp for additional elements -- Source metamodel: MMA -- Target metamodel: MMB class A1 { reference a2 : A2; } class B1 { reference b2 : B2; class A2 { attribute v1 : String; reference b3 : B3; } attribute v2 : String; } class B2 { attribute v1 : String; } class B3 { attribute v2 : String; } module MMAtoMMB; rule A2toB2andB3 { create OUT : MMB from IN : MMA; from rule A1toB1 { s : MMA!A2 from s : MMA!A1 to to t1 : MMB!B2 ( t : MMB!B1 ( v1 <- s.v1 b2 <- s.a2, ), b3 <- t2 : MMB!B3 ( thisModule.resolveTemp(s.a2, 't2') v2 <- s.v2 ) ) } 63 } Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 64. Traceability: resolveTemp even for first element -- Source metamodel: MMA -- Target metamodel: MMB class A1 { reference a2 : A2; } class B1 { reference b2 : B2; class A2 { attribute v1 : String; reference b3 : B3; } attribute v2 : String; } class B2 { attribute v1 : String; } class B3 { attribute v2 : String; } module MMAtoMMB; rule A2toB2andB3 { create OUT : MMB from IN : MMA; from rule A1toB1 { s : MMA!A2 from s : MMA!A1 to to t : MMB!B1 ( t1 : MMB!B2 ( b2 <- -- possible but complex v1 <- s.v1 thisModule.resolveTemp(s.a2, 't1'), ), b3 <- t2 : MMB!B3 ( thisModule.resolveTemp(s.a2, 't2') v2 <- s.v2 ) ) } 64 } Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 65. Structure creation revisited with resolveTemp -- Source metamodel: MMA -- Target metamodel: MMB class A1 { class B1 { reference b2 : B2; attribute v1 : String; reference b3 : B3; } attribute v2 : String; class B2 { attribute v1 : String; } } class B3 { attribute v2 : String; } module MMAtoMMB; t2 : MMB!B2 ( create OUT : MMB from IN : MMA; v1 <- s.v1 rule A1toB1andB2andB3 { ), from t3 : MMB!B3 ( s : MMA!A1 v2 <- s.v2 to ) t1 : MMB!B1 (-- possible but complex } b2 <- thisModule.resolveTemp(s, 't2'), b3 <- thisModule.resolveTemp(s, 't3') ), 65 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 66. Kinds of matched (declarative) rules • We have only seen standard rules in default mode so far. Kind of Number of Number of Kind of rule references times the traceability to source target pattern link pattern gets created created standard 0 1 default or 1 1 not (using keyword n>1 1 nodefault) unique 66 0 0 Not default Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 67. Syntax of the different kinds of matched rules Kind of rule Definition Reference standard rule R1 { <value of type default from s : MMA!A1> MMA!A1 or to t : MMB! <collection of B1 } MMA!A1> standard nodefault rule not currently nodefault R1 { possible (1) For collections: aCollection->collect(e | thisModule.R1(e)) from s : 67 MMA!A1 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 68. 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,  Syntax: abstract rule R1 { -- ... } rule R2 extends R1 { -- ... } 68 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 69. Copy class inheritance without rule inheritance -- Source metamodel: MMA -- Target metamodel: MMB class A1 { attribute v1 : String; } class B1 { attribute v1 : String; } class A2 extends A1 { class B2 extends B1 { attribute v2 : String; attribute v2 : String; } } module MMAtoMMB; rule A2toB2 { create OUT : MMB from IN : MMA; from rule A1toB1 { s : MMA!A2 from to s : MMA!A1 t : MMB!B2 ( to v1 <- s.v1, t : MMB!B1 ( v2 <- s.v2 v1 <- s.v1 ) ) } } 69 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 70. Copy class inheritance with rule inheritance -- Source metamodel: MMA -- Target metamodel: MMB class A1 { attribute v1 : String; } class B1 { attribute v1 : String; } class A2 extends A1 { class B2 extends B1 { attribute v2 : String; attribute v2 : String; } } module MMAtoMMB; rule A2toB2 extends A1toB1 { create OUT : MMB from IN : MMA; from rule A1toB1 { s : MMA!A2 from to s : MMA!A1 t : MMB!B2 ( to -- v1 <- s.v1, t : MMB!B1 ( v2 <- s.v2 v1 <- s.v1 ) ) } } 70 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 71. Guidelines Make your transformation as complex as necessary but as simple as possible. • Prefer declarative over imperative: only use imperative for the part of a transformation that needs it if it even does. • Prefer simpler constructs over more complex ones:  Use standard rules when possible, otherwise use unique lazy rules, and use lazy rules only if necessary.  Only use resolveTemp if necessary.  Prefer iterators (e.g., select, collect) over iterate. 71 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 72. Refactoring Transformations – Example • Public2Private:  Making every public Property private  Leaving the rest of the model unchanged • Note: although this example uses UML, the approach presented here is metamodel-independent. 72 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 73. Operational context of ATL (Reminder) MOF MMa is the MMB is the source target metamodel MMa ATL MMb metamodel MMa2MMb.atl Ma Mb Ma is the source model Mb is the target model (read-only) (write-only) 73 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 74. Refactoring transformations – Overview • General characteristics:  Operate on a single metamodel (i.e., MMa = MMb)  Most of the model remains unchanged (i.e., Ma ≈ Mb) • Optional characteristics:  May apply to only a given part of the model (i.e., a selection)  Identity of elements may need to be preserved (e.g., in an editor, although usually not necessary if XMI-to-XMI) • Challenges:  Modification of an existing model (i.e., different from the general scheme)  Possible interactive usage (requires a certain performance level) 74 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 75. Implementation of Refactoring Transformations • Writing every rule  Simple, but not scalable: typically about one rule per metamodel element (e.g., 4153 lines of code for UML) • Modifying a generated copy transformation  Scales easily to a large number of metamodel elements, but important information is hidden • Superimposing a few rules on a copy transformation  Relatively elegant: the generated copy transformation is left untouched, refactoring rules are grouped into a separate module • Common issue of these approaches: they copy the source model elements into a different target model  Performance is not especially good, they do not scale to large models  Identity of elements is not preserved for use within an editor 75 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 76. UML Public2Private – Superimposition module Public2Private; Technique create OUT : UML2 from IN : UML2; rule Property { from rule Property { from s : UML2!Property ( s.visibility = #public to ) s : UML2!Property ( t : UML2!Property ( visibility <- #private, s.visibility = #public name <- s.name, ) to isLeaf <- s.isLeaf, isStatic <- s.isStatic, isOrdered <- s.isOrdered, isUnique <- s.isUnique, t : UML2!Property ( isReadOnly <- s.isReadOnly, isDerived <- s.isDerived, visibility <- #private, isDerivedUnion <- s.isDerivedUnion, aggregation <- s.aggregation, name <- s.name, eAnnotations <- s.eAnnotations, isLeaf <- s.isLeaf, … ownedComment <- s.ownedComment, clientDependency <- s.clientDependency, nameExpression <- s.nameExpression, type <- s.type, upperValue <- s.upperValue, lowerValue <- s.lowerValue, templateParameter <- s.templateParameter, end <- s.end, deployment <- s.deployment, templateBinding <- s.templateBinding, Superimposed on ownedTemplateSignature <- s.ownedTemplateSignature, redefinedProperty <- s.redefinedProperty, UML2Copy.atl defaultValue <- s.defaultValue, subsettedProperty <- s.subsettedProperty, (4153 generated lines) association <- s.association, qualifier <- s.qualifier } 76 ) Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 77. ATL Refining Mode • Challenges:  Keeping as much as possible of ATL semantics  Performance suitable for interactive usage  Preservation of elements identity • ATL 2004 refining mode:  Works as the approaches presented earlier: by copying source model elements to target model  Only rules that do not perform simple copy need to be specified, with all bindings (similar to superimposition but with an implicit copy transformation)  Keeps ATL semantics, but neither very performant, nor identity preserving 77 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 78. ATL 2006 Refining Mode • Works by performing in-place transformation Still keeps ATL semantics (i.e., write-only target model during rule execution)  Performs well-enough for interactive usage (see demo)  Preserves elements identity • Only rules and bindings that do perform changes need to be specified  Less verbose than previous techniques (including ATL 2004) 78 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 79. Public2Private in ATL 2006 Refining Mode module Public2Private; create OUT : UML refining IN : UML; rule Property { from s : UML!Property (s.visibility = #public) to t : UML!Property ( visibility <- #private ) } 79 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 80. What would happen in Standard Mode? module Public2Private; create OUT : UML from IN : UML; rule Property { from s : UML!Property (s.visibility = #public) to t : UML!Property ( visibility <- #private ) } 80 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 81. Public2Private.atl on j2se-1_2-api.uml (6.17MiB) Time (s) Bytecod Lines of Transformat Tota es code ion l Superimposi tion 2467779 209 216 41 7 Refining 3.20 11 354364 15 2.7 81 Ratio 65.3 19.6 69.6 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 82. Public2Private.atl on j2se-1_6-api.uml (13.14MiB) Time (s) Bytecod Lines of Transformat Tota es code ion l Superimposi tion 5247898 496 515 41 4 Refining 5.75 25 674874 15 2.7 82 Ratio 86.3 20.6 77.8 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 83. Public2Private plus Accessors rule Property { from s : UML!Property ( s.visibility = #public) to t : UML!Property ( visibility <- #private ), getter : UML!Operation ( namespace <- s.namespace, -- ! see later name <- 'get' + s.name.firstToUpper, ownedParameter <- getterReturnParam ), getterReturnParam : UML!Parameter ( name <- 'return', direction <- #return, type <- s.type ) } … 83 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 84. ATL 2006 Refining Mode – Implementation Overview • Computing changes  No change to the source model during rule execution, which happens as with a read-only source model  All changes are stored in a RefiningTrace model • Applying changes  After the execution of all rules • The trace:  may be serialized  could be serialized and not applied (e.g., to use a different application engine) 84 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 85. Public2Private plus Accessors – Changeability Issue rule Property { from s : UML!Property ( s.visibility = #public) to t : UML!Property ( visibility <- #private ), getter : UML!Operation ( namespace <- s.namespace, name <- 'get' + s.name.firstToUpper, ownedParameter <- getterReturnParam ), getterReturnParam : UML!Parameter ( name <- 'return', direction <- #return, type <- s.type ) } … 85 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 86. Public2Private plus Accessors – Introducing Reverse Bindings rule Property { from s : UML!Property ( s.visibility = #public) to t : UML!Property ( visibility <- #private ), getter : UML!Operation -> (s.namespace.ownedOperation) ( name <- 'get' + s.name.firstToUpper, ownedParameter <- getterReturnParam ), getterReturnParam : UML!Parameter ( name <- 'return', direction <- #return, type <- s.type ) } … 86 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 87. Launching ATL 2006 Refining Transformations • Adding inout models to the ATL Ant Task <atl.launch path="${base.path}/Public2Private.atl"> <inoutModel name="IN" model="source"/> <outModel name="refiningTrace" metamodel="RefiningTrace" model="refiningTrace"/> </atl.launch> • The user still sees different source and target models, but there are effectively the same • There are two other ways to launch a refining transformation:  Using the launch configuration (see next slide)  Programmatically (e.g., from Eclipse plugins as shown in next exercise) 87 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 88. ATL 2006 Refining Launch Configuration 88 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 89. Model Enrichment • Problem  Adding information from model mB into model mA in order to obtain enriched model mA’ • Approach  Write a transformation refining mA and taking mB as additional source model create mA’ : MMA refining mA : MMA, mB : MMB; • Example:  Annotating EDataTypes from an Ecore metamodel with instanceClassNames module ApplyAnnotations2Ecore; create OUT : Ecore refining IN : Ecore, annotations : Annotation; 89 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 90. Model Enrichment Example -- @atlcompiler atlworkspace -- @nsURI Ecore=http://www.eclipse.org/emf/2002/Ecore module ApplyAnnotations2Ecore; create OUT : Ecore refining IN : Ecore, annotations : Annotation; rule DataTypeAnnotations { from s : Ecore!EDataType to t : Ecore!EDataType ( instanceClassName <- let a : String = s.getAnnotation('instanceClassName') in if a.oclIsUndefined() then s.instanceClassName else a endif ) } -- getAnnotation helper not shown here -- […] 90 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 91. Agenda • Introduction • ATL Overview • First exercise: Model Visualization • Advanced Usage of ATL • Second exercise: Model Refactoring • Architecture • Third exercise: A DSL Compiler for SWTBot • ATL Industrialization • Discussions 91 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 92. Second exercise: Model Refactoring • Intent  Provide in-place refactoring actions on models  Big models support  Reversible actions • Realization: a refactoring pop-up menu  Based on ATL refining mode  Available on UML2 models (both with the tree editor and UML2Tools)  Set public fields to private  Optionally adds getters and setters Use-case: privatization of public attributes 92 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 93. Second exercise: Model Refactoring • Example: refactoring on UML2Tools 93 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 94. Agenda • Introduction • ATL Overview • First exercise: Model Visualization • Advanced Usage of ATL • Second exercise: Model Refactoring • Architecture  Overview  The new virtual machine: EMF-VM • Third exercise: A DSL Compiler for SWTBot • ATL Industrialization • Discussions 94 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 95. ATL main plugins organization Eclipse ui integration Parser and Compiler utilities ATL Core API ATL EMF–specific VM ATL Regular VM 95 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 96. ATL Core API • Problem  ATL initial architecture changed many times, without strict conventions  Integration of several contributions  Two Vms, two compilers • Intent  Need to reorganize ATL core to resolve maintenance and accessibility issues  Provide an unique and simple way to use ATL programmatically • Realization  A Core API which manages models loading/saving and ATL launching  Provides extensibility at several levels 96 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 97. ATL Core API 97 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 98. ATL architecture • Intermediate file format : ASM • Modular VM dedicated to M2M support  A complete specification describes the VM (http://www.eclipse.org/m2m/atl/doc/)  Can be implemented on different platforms (Java, .Net) 98 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 99. ATL execution process • 2 steps  Compilation  Execution 99 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 100. ATL Virtual Machine • ATL core engine • Byte code interpreter (ASM)  Granular model management instruction  Uses OCL/ATL type hierarchy  Uses an abstract model handler layer • ATL VM defined by a concrete specification  Allows other language implementation • ASM code ... <operation name="122"> <context type="8"/> <parameters> </parameters> <code> <push arg="77"/> <push arg="25"/> <findme/> <push arg="23"/> ... 100 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 101. EMF-VM • A new ATL Virtual Machine is now available  Increased performance  EMF-only (no wrapping of EObjects) • At this time...  Some missing features (decreasing in number quickly): •UML profile support •Debugger interactions • Non-regression evaluated with a new test plugin 101 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 102. Non-regression tests • Non-regression engine uses EMF Compare to check output models conformance • Non-regression tests also allows to check  ATL Regular VM  ATL Compiler  ATL Parser • Provides a way for users to safely work on base components: bug corrections, new features 102 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 103. Non regression wiki page 103 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 104. EMF-VM Benchmarks 104 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 105. Agenda • Introduction • ATL Overview • First exercise: Model Visualization • Advanced Usage of ATL • Second exercise: Model Refactoring • Architecture • Third exercise: A DSL Compiler for SWTBot • ATL Industrialization • Discussions 105 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 106. Third Exercise: A DSL Compiler for SWTBot Intent  Provide a simpler syntax for SWTBot (i.e., a Domain-Specific Language or DSL)  Generate Java code from simpler syntax Prerequisites  SWTBot DSL implementation (metamodel, syntax)  SimpleJava metamodel (only what is necessary for generation of SWTBot code) Realization  An ATL transformation from SWTBot to SimpleJava 106 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 107. Third Exercise: A DSL Compiler for SWTBot 107 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 108. Agenda • Introduction • ATL Overview • First exercise: Model Visualization • Advanced Usage of ATL • Second exercise: Model Refactoring • Architecture • Third exercise: A DSL Compiler for SWTBot • ATL Industrialization • Discussions 108 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 109. ATL Industrialization process idea Labo experimentation industrialization Users PME validation commercialization partnership 109 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 110. Roadmap • Roadmap overview:  Industrialization  EMF-VM improvements  Stabilization  Internationalization  Improve Eclipse integration  New features  Packaging  Incremental transformation support • Means:  Existing features amelioration (IDE)  Complex features research (incremental) 110 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 111. ATL Releng module 111 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 112. Done • API refactoring  Correction of current issues  Provide a “clean” Java access to ATL for developers • ATL ant tasks • Documentation  Merging wiki / pdf  doc plugin synchronization • Many bugs corrections & feature improvements  Loading an UML2 profile from a plugin  Stable EMF ResourceSet management strategy • Examples: public2private  Provide launch configuration, ant file and java popup samples 112 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 113. What’s next? • IDE improvements  Content assist  Syntax colors  File wizard  Launch configurations  Integration of a CS contribution: ATL profiler • Debugger  Reimplemented for at least EMFVM • Documentation improvement 113 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 114. Agenda • Introduction • ATL Overview • First exercise: Model Visualization • Advanced Usage of ATL • Second exercise: Model Refactoring • Architecture • Third exercise: A DSL Compiler for SWTBot • ATL Industrialization • Discussions 114 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 115. Discussion Topics • About ATL  ATL versions (2004 vs. 2006), notably refining mode  Best Practices  Model Transformation Virtual Machines  ATL vs. QVT • Around ATL  M2M vs. M2T  Where do models come from?  Modeling platforms – AmmA  Domain-Specific Languages and Modeling  You can vote for the topics you are most interested in (2 or 3)  You may suggest additional topics 115 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 116. 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 116 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0
  • 117. END • Questions or Comments? 117 Model Refactoring and other Advanced ATL Techniques | © 2009 by INRIA, Obeo; made available under the EPL v1.0