Query/Views/Transformations © 2006 ATLAS Nantes - 1 - Query/Views/Transformations An introduction to the MOF 2.0 QVT standard with focus on the Operational.

Slides:



Advertisements
Similar presentations
Profiles Construction Eclipse ECESIS Project Construction of Complex UML Profiles UPM ETSI Telecomunicación Ciudad Universitaria s/n Madrid 28040,
Advertisements

June 9, 2006 Transforming models with ATL © 2006 ATLAS Nantes Transforming models with ATL The A TLAS Transformation Language Frédéric Jouault ATLAS.
OCL2 April A presentation of OCL 2 Object Constraint Language Christian Hein, Fraunhofer FOKUS April 2006.
Families to Persons © 2007 ATLAS Nantes "Families to Persons" A simple illustration of model-to-model transformation Freddy Allilaire Frédéric Jouault.
Inheritance Inheritance Reserved word protected Reserved word super
Formal Methods of Systems Specification Logical Specification of Hard- and Software Prof. Dr. Holger Schlingloff Institut für Informatik der.
OORPT Object-Oriented Reengineering Patterns and Techniques 13. Model-Driven Development Prof. O. Nierstrasz.
Object-Oriented Analysis and Design
 2006 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
UML CASE Tool. ABSTRACT Domain analysis enables identifying families of applications and capturing their terminology in order to assist and guide system.
Sheet 1© 2005 Lentedagen, 30 March-1 April 2005 IPA Lentedagen on Software Architecture Model Transformations in MDA Ivan Kurtev.
Describing Syntax and Semantics
Objectives Explain the purpose and objectives of object- oriented design Develop design class diagrams Develop interaction diagrams based on the principles.
MDE In A Sales Management System: A Case Study © 2008 INRIA, TUD & SAP MDE In A Sales Management System: A Case Study Mathias Fritzsche, Hugo Bruneliere,
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
MDD Tutorial for managers Eclipse ECESIS Project A presentation of MDD basics Model-driven development (MDD) tutorial for managers EUROPEAN SOFTWARE INSTITUTE,
XML Metadata Interchange (XMI)
Comparing M2T & M2M Complementary Approaches © 2008 INRIA, University of York & SINTEF Comparing M2T & M2M Complementary Approaches Hugo Bruneliere,
Object-Oriented Analysis and Design
Advanced Applications Of Model-to-Model Transformation © 2008 INRIA Advanced Applications Of Model-to-Model Transformation Hugo Bruneliere & Frédéric.
Composing Models: Principles & Techniques © Copyright TUBS & TUD Composing Models: Principles & Techniques Steven Völkel & Jendrik Johannes.
Systems Analysis and Design in a Changing World, Fifth Edition
An Approach and Tool for Synchronous Refactoring of UML Diagrams and Models Using Model-to-Model Transformations Hafsteinn Þór Einarsson Helmut Neukirchen.
Model Transformations
Faculty of Informatics and Information Technologies Slovak University of Technology Peter Kajsa and Ľubomír Majtás Design.
MDA and QVT  Tom Gullion, Director of Product Management, Together Products.
ATL The ATLAS Transformation Language. 2 ATL (ATLAS Transformation Language) ATL transformation pattern ATL metamodel Helpers – Operation helpers – Attribute.
Model transformation with a dedicated imperative language IRISA Rennes (France) - Triskell team Jean-Marc Jézéquel Didier Vojtisek Jean-Philippe Thibault.
Introduction to MDA (Model Driven Architecture) CYT.
Introduction to UML By: Prof. Aiman Hanna Department of Computer Science, Concordia University, Montreal, Canada.
Model Handling with EMF Eclipse ECESIS Project Model handling with EMF An introduction to the Eclipse Modeling Framework ATLAS group (INRIA & LINA),
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Alignment of ATL and QVT © 2006 ATLAS Nantes Alignment of ATL and QVT Ivan Kurtev ATLAS group, INRIA & University of Nantes, France
1 On to Object Design Chapter 14 Applying UML and Patterns.
What is MOF? The Meta Object Facility (MOF) specification provides a set of CORBA interfaces that can be used to define and manipulate a set of interoperable.
Programming in Java Unit 3. Learning outcome:  LO2:Be able to design Java solutions  LO3:Be able to implement Java solutions Assessment criteria: 
UML Profiles Eclipse ECESIS Project The UML Profile technology SOFTEAM 144 Ave des Champs Elysées Paris, France
Usage of OCL April Usage of OCL for design guidelines of models Christian Hein, Fraunhofer FOKUS April 2006.
WP 3.3 © Copyright Xactium, TUBS & TUD How to build a set of DSLs: from Theory to Practise Xactium, TUBS, Jendrik Johannes (TUD)
Systems Analysis and Design in a Changing World, 3rd Edition
1 5 Nov 2002 Risto Pohjonen, Juha-Pekka Tolvanen MetaCase Consulting AUTOMATED PRODUCTION OF FAMILY MEMBERS: LESSONS LEARNED.
Hybrid Transformation Modeling Integrating a Declarative with an Imperative Model Transformation Language Pieter Van Gorp
Introduction to Model-Driven Simulation © 2008 SAP, TU Dresden, XJ Technologies Introduction to Model-Driven Simulation Mathias Fritzsche 1, Jendrik.
An ATL Example © 2005 ATLAS Nantes An ATL Example The BibTeXML to DocBook Transformation ATLAS group (INRIA & LINA), University of Nantes, France.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Sheet 1 DocEng’03, Grenoble, November 2003 Model Driven Architecture based XML Processing Ivan Kurtev, Klaas van den Berg University of Twente, the Netherlands.
Relationships Relationships between objects and between classes.
1 Class Diagrams. 2 Overview Class diagrams are the most commonly used diagrams in UML. Class diagrams are for visualizing, specifying and documenting.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 9 Java Fundamentals Objects/ClassesMethods Mon.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
ModTransf A Simple Model to Model Transformation Engine Cédric Dumoulin.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
Introduction To Model-to-Model Transformation © 2008 INRIA Introduction To Model-to-Model Transformation Hugo Bruneliere & Frédéric Jouault INRIA.
Domain Model A representation of real-world conceptual classes in a problem domain. The core of object-oriented analysis They are NOT software objects.
Based on material developed in ATHENA (IST ), INTEROP (IST ) and MODELWARE (IST ) 6-1b. Atlas Transformation Language (ATL) with RSM.
Classes, Interfaces and Packages
UML Profile BY RAEF MOUSHEIMISH. Background Model is a description of system or part of a system using well- defined language. Model is a description.
An Introduction to Metamodelling Eclipse ECESIS Project An Introduction to Metamodelling Principles & Fundamentals Department of Computer Science,
Ontologies Reasoning Components Agents Simulations An Overview of Model-Driven Engineering and Architecture Jacques Robin.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Sheet 1MDAFA2004 Linköping, June 2004 A Language for Model Transformations in the MOF Architecture Ivan Kurtev, Klaas van den Berg University of Twente,
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
UNIT-IV Designing Classes – Access Layer ‐ Object Storage ‐ Object Interoperability.
Operational QVT Incremental Update
About the Presentations
Model-Driven Ontology Engineering
QVT Operational 1.0 Mini-deck
Software Architecture & Design
Presentation transcript:

Query/Views/Transformations © 2006 ATLAS Nantes Query/Views/Transformations An introduction to the MOF 2.0 QVT standard with focus on the Operational Mappings Ivan Kurtev ATLAS group, INRIA & University of Nantes, France

Query/Views/Transformations © 2006 ATLAS Nantes Context of this work The present courseware has been elaborated in the context of the MODELWARE European IST FP6 project ( Co-funded by the European Commission, the MODELWARE project involves 19 partners from 8 European countries. MODELWARE aims to improve software productivity by capitalizing on techniques known as Model-Driven Development (MDD). To achieve the goal of large-scale adoption of these MDD techniques, MODELWARE promotes the idea of a collaborative development of courseware dedicated to this domain. The MDD courseware provided here with the status of open source software is produced under the EPL 1.0 license.

Query/Views/Transformations © 2006 ATLAS Nantes Prerequisites To be able to understand this lecture, a reader should be familiar with the following concepts, languages, and standards: Model Driven Engineering (MDE) The role of model transformations in MDE UML OCL MOF Basic programming concepts

Query/Views/Transformations © 2006 ATLAS Nantes Outline Overview of QVT QVT Requirements QVT Languages: Relations Core Presentation of Operational Mappings Case Study: Flattening UML Inheritance Hierarchies Basic Language Constructs Conclusions

Query/Views/Transformations © 2006 ATLAS Nantes Overview QVT stands for Query/Views/Transformations OMG standard language for expressing queries, views, and transformations on MOF models OMG QVT Request for Proposals (QVT RFP, ad/ ) issued in 2002 Seven initial submissions that converged to a common proposal Current status (June, 2006): final adopted specification, OMG document ptc/

Query/Views/Transformations © 2006 ATLAS Nantes QVT Operational Context Abstract syntax of the language is defined as MOF 2.0 metamodel Transformations (Tab) are defined on the base of MOF 2.0 metamodels (MMa, MMb) Transformations are executed on instances of MOF 2.0 metamodels (Ma)

Query/Views/Transformations © 2006 ATLAS Nantes Requirements for QVT Language Some requirements formulated in the QVT RFP Mandatory requirements Query languageProposals shall define a language for querying models Transformation language Proposals shall define a language for transformation definitions Abstract syntax The abstract syntax of the QVT languages shall be described as MOF 2.0 metamodel ParadigmThe transformation definition language shall be declarative Input and output All the mechanisms defined by proposals shall operate on models instances of MOF 2.0 metamodels Optional requirements Directionality Proposals may support transformation definitions that can be executed in two directions Traceability Proposals may support traceability between source and target model elements Reusability Proposals may support mechanisms for reuse of transformation definitions Model update Proposals may support execution of transformations that update an existing model

Query/Views/Transformations © 2006 ATLAS Nantes QVT Architecture Layered architecture with three transformation languages: Relations Core Operational Mappings Black Box is a mechanism for calling external programs during transformation execution

Query/Views/Transformations © 2006 ATLAS Nantes Conformance Points for QVT Tools Interoperability Dimension Language Dimension Syntax Executable XMI Executable Syntax Exportable XMI Exportable Core Relations Operational Mappings Language dimension indicates the language a tool may execute Interoperability dimension indicates the syntax that a tool can read 12 possible conformance points ! Note: Conformance to QVT is defined for tools and not for languages. The term “QVT compliant language” is not defined in the specification.

Query/Views/Transformations © 2006 ATLAS Nantes QVT Languages Relations Declarative transformation language Specification of relations over model elements Core Declarative transformation language Simplification of Relations language Operational Mappings Imperative transformation language Extends Relations language with imperative constructs QVT is a set of three languages that collectively provide a hybrid “language”.

Query/Views/Transformations © 2006 ATLAS Nantes Overview of Relations Language Declarative language based on relations defined on model elements in metamodels Object patterns that may be matched and instantiated Automatic handling of traceability links Transformations are potentially multidirectional Supported execution scenarios: Check-only: verifies if given models are related in a certain way Unidirectional transformations Multidirectional transformations Incremental update of existing models

Query/Views/Transformations © 2006 ATLAS Nantes Overview of Core Language Declarative language based on relations defined on model elements in metamodels Simpler object patterns Manual handling of traceability links Equal expressivity compared to the Relations language More verbose than the Relations language Core and Relations support the same set of execution scenarios Usage options: Simple transformation language Reference point for defining the semantics of the Relations language

Query/Views/Transformations © 2006 ATLAS Nantes Outline Overview of QVT QVT Requirements QVT Languages: Relations Core Presentation of Operational Mappings Case Study: Flattening UML Inheritance Hierarchies Basic Language Constructs Conclusions

Query/Views/Transformations © 2006 ATLAS Nantes Operational Mappings Language This lecture presents Operational Mappings in details based on an example case study Case study: Flattening UML class hierarchies Overall transformation structure Mapping rules Querying source models Object resolution operations Creating target objects Flow of control Other features

Query/Views/Transformations © 2006 ATLAS Nantes Case Study Flattening UML class hierarchies: given a source UML model transform it to another UML model in which only the leaf classes (classes not extended by other classes) in inheritance hierarchies are kept. Rules: Transform only the leaf classes in the source model Include the inherited attributes and associations Attributes with the same name override the inherited attributes Copy the primitive types

Query/Views/Transformations © 2006 ATLAS Nantes Source and Target Metamodel: SimpleUML

Query/Views/Transformations © 2006 ATLAS Nantes Example Input Model

Query/Views/Transformations © 2006 ATLAS Nantes Example Output Model

Query/Views/Transformations © 2006 ATLAS Nantes Model Transformation expressed in Operational Mappings Language Overall structure of a transformation program: transformation SimpleUML2FlattenSimpleUML(in source : SimpleUML out target : SimpleUML); ………………………………………………………………… main() {} ………………………………………………………………… …helpers…………………………………………… …mapping operations……………… Signature: Declares the transformation name and the source and target metamodels. in and out keywords indicate source and target model variables. Entry point: The execution of the transformation starts here by executing the operations in the body of main Transformation elements: Transformation consists of mapping operations and helpers. They form the transformation logic.

Query/Views/Transformations © 2006 ATLAS Nantes Mapping Operations A mapping operation maps one or more source elements into one or more target elements Always unidirectional Selects source elements on the base of a type and a Boolean condition (guard) Executes operations in its body to create target elements May invoke other mapping operations and may be invoked Mapping operations may be related by inheritance

Query/Views/Transformations © 2006 ATLAS Nantes Mapping Operations: Example (1) Consider the rule that transforms only leaf classes Selects only classes without subclasses Collects all the inherited properties Creates new class in the target model mapping Class::leafClass2Class(in model : Model) : Class when {not model.allInstances(Generalization)->exists(g | g.general = self)} { name:= self.name; abstract:= self.abstract; attributes:= self.derivedAttributes()->map property2property(self)->asOrderedSet(); } Operation body Signature and guard

Query/Views/Transformations © 2006 ATLAS Nantes Mapping Operations: Example (2) mapping Class::leafClass2Class(in model : Model) : Class when {not model.allInstances(Generalization)->exists(g | g.general = self)} Operation Signature and Guard Operation name Source element type An optional sequence of input/output parameters Target element type Guard The Guard is an OCL expression used to filter source elements of a given type. The mapping operation is executed only on elements for which the guard expression is evaluated to true.

Query/Views/Transformations © 2006 ATLAS Nantes Mapping Operations: Example (3) name:= self.name; abstract:= self.abstract; attributes:= self.derivedAttributes()->map property2property(self)->asOrderedSet(); Operation Body The predefined variable self refers to the source element on which the operation is executed The left-hand side of the assignments denotes properties of the target element Invocation of helper derivedAttributes The keyword map is used to invoke another mapping operation named property2property over the elements returned by the helper derivedAttributes The mapping operation body contains initialization expressions for the properties of the target element. When an operation is executed over a source element the self variable is bound to it and an instance of the target type is created. Then the operation body is executed.

Query/Views/Transformations © 2006 ATLAS Nantes Helpers Helpers are operations associated to a type that return a result Both primitive and model types can be used Helpers may be used to perform complex navigations over source models Helpers have: List of input parameters An executable body Helper types: Side-effect free: Query helper; With side effect over input parameters: Helper

Query/Views/Transformations © 2006 ATLAS Nantes Helpers: Example query Class::derivedAttributes() : OrderedSet(Property){ if self.generalizations->isEmpty() then self.attributes else self.attributes->union( self.generalizations->collect(g | g.general.derivedAttributes()->select(attr | not self.attributes->exists(att | att.name = attr.name) ) )->flatten() )->asOrderedSet() endif } The query derivedAttributes is a side-effect free helper defined on classes. It returns an ordered set of properties that contains the attributes defined in a given class and the attributes derived from the its super classes. Derived attributes are overridden by the defined attributes with the same name. Note that this is a recursive helper. The variable self refers to the class on which the helper is executed The context type of the helper derivedAttributes Result type

Query/Views/Transformations © 2006 ATLAS Nantes Invoking Mapping Operations …………………………………………………… attributes:= self.derivedAttributes()->map property2property(self)->asOrderedSet(); …………………………………………………… mapping Property::property2property(in ownerClass : Class) : Property{ name:= self.name; type:= self.type; owner:= ownerClass; } Assume we have a mapping operation property2property that simply copies a property of a source class to a property of the target class. The target class is already created by the previously shown rule leafClass2Class. In order to invoke property2property on every attribute of the source class we use the notation “->map”. It implies an iteration over a list of source elements. The notation “object.map” invokes a mapping operation on object as a source element. Invocation of property2property on every member of the set returned by derivedAttributes query

Query/Views/Transformations © 2006 ATLAS Nantes Resolving Object References Assume that we write a mapping operation that transforms associations in the source model to associations in the target model. In the target model an association relates two classes derived from other two classes in the source model. To identify these two classes in the target model the transformation engine maintains links among source and target model elements. These links are used for resolving object references from source to target model elements and back. An example of a mapping operation that transforms associations and uses resolution of object references: mapping Association::copyAssociation(sourceClass : Class) : Association { name:=self.name; source:=sourceClass.resolveByRule('leafClass2Class', Class)->first(); target:= self.target.resolveByRule('leafClass2Class', Class)->first(); } resolveByRule is an operation that looks for model elements of a given type (Class) in the target model derived from a source element by applying a given rule (leafClass2Class).

Query/Views/Transformations © 2006 ATLAS Nantes General Structure of Mapping Operations mapping Type::operationName(((in|out|inout) pName : pType)* ) : (rName : rType)+ when {guardExpression} { init {} population {} end {} } init section contains code executed before the instantiation of the declared result elements population section contains code that sets the values or the result and the parameters declared as out or inout. The population keyword may be skipped. Population section is the default section in the operation body. end section contains code executed before exiting the operation. There exists an implicit instantiation section that creates all the output parameters not created in the init section. The trace links are created in the instantiation section.

Query/Views/Transformations © 2006 ATLAS Nantes Apart from the implicit creation of objects in the instantiation section there is an operation for creating and populating objects in mapping operations Operation object: Object Creation and Population object p : Property { name:= self.name; type:= self.type; owner:= ownerClass; } Variable name and result type Population or property values

Query/Views/Transformations © 2006 ATLAS Nantes Imperative Constructs for Managing the Flow of Control Operational Mappings is an imperative language. While many algorithms may be implemented just by a set of mapping operations that invoke each other and are supported by OCL expressions for navigation and iteration, there are cases where more sophisticated control flow is needed. The following imperative constructs are available: Compute While forEach Break Continue If-then-else

Query/Views/Transformations © 2006 ATLAS Nantes Features not Covered in the Lecture Packaging facilities: transformation libraries reuse of libraries Reuse facilities: rule inheritance and merging disjunctions of mapping operations Constructor operations Intermediate data Reusing and extending transformations Operation post condition: where clause For more details consult the QVT specification: OMG document ptc/

Query/Views/Transformations © 2006 ATLAS Nantes Conclusions (1) QVT: Query/Views/Transformations – the OMG standard language for model transformations in MDA/MDE; The issue of Views over models is not addressed; Query language based on OCL; A family of three transformation languages: Relations: declarative language Core: declarative language, simplification of Relations; Operational Mappings: imperative transformation language that extends relations; Collectively QVT languages form a hybrid language;

Query/Views/Transformations © 2006 ATLAS Nantes Conclusions (2) Tool support is still insufficient (at the time of preparing of this lecture – June 2006); QVT is not proved yet in non-trivial industrial like scenarios; Many issues need further exploration: Performance; Testing; Scalability of transformations; Ease of use; Handling change propagation; Incremental transformations; Adequacy of the reuse mechanisms;

Query/Views/Transformations © 2006 ATLAS Nantes Additional Materials This lecture is accompanied by an implementation of the presented case study. The code, the documentation, and the example models are available from the MODELWARE web site.