CHAPTER 11: MODEL TRANSFORMATION Transformation Definition - - PowerPoint PPT Presentation

chapter 11 model transformation
SMART_READER_LITE
LIVE PREVIEW

CHAPTER 11: MODEL TRANSFORMATION Transformation Definition - - PowerPoint PPT Presentation

Architecture and Modelling of Information Systems (D0I71A) Prof. dr. Monique Snoeck CHAPTER 11: MODEL TRANSFORMATION Transformation Definition Transformation Tool 2 Agenda Model Transformations General approach Transformation


slide-1
SLIDE 1

Transformation Tool

Transformation Definition

CHAPTER 11: MODEL TRANSFORMATION

Architecture and Modelling

  • f Information Systems (D0I71A)
  • Prof. dr. Monique Snoeck
slide-2
SLIDE 2

Transformation Tool

Transformation Definition

Agenda

  • Model Transformations
  • General approach
  • Transformation Rule Examples
  • General Architecture
  • The Enterprise Layer
  • The Event Handling Layer
  • Transformation Technology Example

18:12

2

slide-3
SLIDE 3

Transformation Tool

Transformation Definition

General Approach

18:12

3

models models

  • r

code transformation engine transformation definition

slide-4
SLIDE 4

Transformation Tool

Transformation Definition

General approach to transformations

  • Develop software manually
  • Look for patterns that are best practices
  • Define Transformations based on patterns
  • = Pushing patterns "below the water line"

18:12

4

slide-5
SLIDE 5

Transformation Tool

Transformation Definition

Pushing Best Practices “below the line”

  • FLAT FILE (198x)
  • Application
  • record insertion
  • record deletion
  • record search
  • sorting
  • indexing
  • storage

18:12

5

  • DATABASE MGT SYSTEM (20xx)
  • Application
  • Record insertion
  • record deletion
  • record search
  • sorting
  • indexing
  • storage
slide-6
SLIDE 6

Transformation Tool

Transformation Definition

Specifications

Pushing Best Practices “below the line”

  • Traditional
  • MDA

18:12

6

Code

Specifications Object Interaction Pattern OO –relational Storage Pattern

Code

Object Interaction Pattern OO –relational Storage Pattern Other Architectural Pattern Other Architectural Pattern

slide-7
SLIDE 7

Transformation Tool

Transformation Definition

Agenda

  • Model Transformations
  • General approach
  • Transformation Rule Examples
  • General Architecture
  • The Enterprise Layer
  • The Event Handling Layer
  • Transformation Technology Example

18:12

7

slide-8
SLIDE 8

Transformation Tool

Transformation Definition

General Transformation Architecture

18:12

8

Domain Model Information System Services Enterprise Layer Persistence + Business Logic Event Handling Layer User Interface Transactions Queries Business Process Models Business Process Engine

slide-9
SLIDE 9

Transformation Tool

Transformation Definition

Agenda

  • Model Transformations
  • General approach
  • Transformation Rule Examples
  • General Architecture
  • The Enterprise Layer
  • The Event Handling Layer
  • Transformation Technology Example

18:12

9

slide-10
SLIDE 10

Transformation Tool

Transformation Definition

The Enterprise Layer

  • The Database Schema
  • Associations
  • Navigability: one way or both ways ?
  • Cardinality of ‘one’  transform to ‘many’ ?
  • Optimisations

 Merge classes for ‘mandatory-one’ dependencies ?  Merge classes for ‘optional-one’ dependencies ?

18:12

10

Domain Model Enterprise Layer Persistence + Business Logic

slide-11
SLIDE 11

Transformation Tool

Transformation Definition

The Enterprise Layer

  • The Database Schema = PSM for the EDG (=PIM)

Class Project private Department owningDept Class Department private SET(Project) projects Class Employee private SET(DeptAssignment) assmtHistory Class Employee private Department mydepartement

  • Foreign Key from Dependent to Master
  • Navigation from master to dependent too ?
  • Transform cardinality of ‘one’ to ‘many ‘?
  • Merge Employee and DeptAssignment into
  • ne database class ?

18:12

11

slide-12
SLIDE 12

Transformation Tool

Transformation Definition

The Enterprise Layer

  • The Business Logic

18:12

12

Domain Model Enterprise Layer Persistence + Business Logic

slide-13
SLIDE 13

Transformation Tool

Transformation Definition

The Enterprise Layer (Business Logic)

18:12

13

Attribute of Object Type Association Object Type participates in Attribute in Implementation Class Association Attribute in Implementation Class Object Type Implementation Class Factory 1 method per event type the object type participates in + 1 method for checking the corresponding preconditions Abstract Class

Database Layer Business Logic

slide-14
SLIDE 14

Transformation Tool

Transformation Definition

The Enterprise Layer (Business Logic)

18:12

14

Object Type's FSM Abstract state class (associated with mapped class) For each State of the FSM, a State subclass of the mapped Abstract state class Per mapped State subclass, methods for checking state con- ditions for each event in of the mapped Abstract state class Database Layer Business Logic

slide-15
SLIDE 15

Transformation Tool

Transformation Definition

The Enterprise Layer (Business Logic)

  • Preconditions
  • Code can be injected in different places
  • In a check-event method in business layer or in the event handling layer
  • Example:
  • checking a precondition for a returnDate to be later than today

Public boolean isValidReturnDate (Date d){ return d.compareTo(today) > 0 } … if isValidReturnDate(input_returnDate) { this.returnDate = input_returnDate; } else { throw new RuntimeException("return date is not valid.");}

18:12

15

slide-16
SLIDE 16

Transformation Tool

Transformation Definition

Agenda

  • Model Transformations
  • General approach
  • Transformation Rule Examples
  • General Architecture
  • The Enterprise Layer
  • The Event Handling Layer
  • Transformation Technology Example

18:12

16

Domain Model Event Handling Layer

slide-17
SLIDE 17

Transformation Tool

Transformation Definition

(Recap) A Business Event is ...

  • A request to perform an activity to register something that happens or that you would

like to happen in the real world.

18:12

17

slide-18
SLIDE 18

Transformation Tool

Transformation Definition

(Recap)The Object Event Table

  • identifies Business Event Types
  • identifies Object Types
  • models participation of Object

Types to Business Event Types with an Object-Event-table

  • (Decide on notification & coordination pattern later at implementation time)

18:12

18

slide-19
SLIDE 19

Transformation Tool

Transformation Definition

(Recap)The Object Event Table

  • In Merode, a business event is a request + an activity
  • request can be refused
  •  When filled, a cell specifies what preconditions are

imposed on a business event by a business object type

  • Activity is distributed across participants
  • (assuming that the request has been accepted)
  •  when filled, cell specifies what the effect is of that

business event on the participating business object type (modified attributes, operation to call),

18:12

19

slide-20
SLIDE 20

Transformation Tool

Transformation Definition

Transforming the OET to code

  • OET-table (PIM)
  • No immediate transformation to code ...
  • Transform to UML-PSM
  • Define collaboration diagram
  • Transform Collaboration Diagram to code
  •  1 pattern, applicable to all event types !
  • Transparent
  • Maintenance easier
  • Transformation tot non-OO platforms possible as well

18:12

20

MERODE OET UML Collaboration Diagram PSM/ Code

Messaging Pattern ?

slide-21
SLIDE 21

Transformation Tool

Transformation Definition

Business Event Handling

1. Tasks Event Dispatcher

  • Check Preconditions of all participants
  • By Event Dispatcher
  • By rule engine
  • By Objects/Components
  • Notify Event (broadcast) to participants
  • Co-ordinate answers
  • Check first – do then
  • Do & compensate

2. How many Event Dispatchers ?

  • Centralised versus Distributed
  • ne event handler for all events (maximally centralised)
  • ne event handler per event (maximally distributed)

18:12

21

slide-22
SLIDE 22

Transformation Tool

Transformation Definition

Mapping

18:12

22

Platform Independent Model

Business Event Object

Object/Event Involvement

Mapping

Mapping Rules for

  • Event Triggering
  • Precondition verification
  • Event Notification
  • Coordination of Event

Execution

Platform Specific Model Platform Choice

  • Programming Languages
  • EAI Middleware
  • Web Service Technology
  • - ...
slide-23
SLIDE 23

Transformation Tool

Transformation Definition

Sample Event Handling Patterns

  • Messaging Pattern should take care of:
  • Event Notification to participants, precondition checking, Coordination of Event Execution
  • Scheme 1: Forwarding
  • Not standardised ⇒ Must be designed for each event type separately
  • More difficult to maintain
  • E.g. take inspiration from OO-SSADM (UK)
  • co-ordination of method invocation starts at home-entity
  • Merode
  • Forwarding can start in event owner
  • Scheme 2: Broadcasting
  • one event handler per event (event class)
  • (option chosen in code-generator)
  • one event handler for all events of one type (C/M/E event dispatchers)
  • (option chosen in JMermaid)

18:12

23

1 2

slide-24
SLIDE 24

Transformation Tool

Transformation Definition

Event Forwarding

  • In MERODE all receiving objects are connected with ED-relationship

 Initiate forwarding in Owner of Event  Forward to Masters

Questions

  • How to ensure atomicity ?
  • What if more than one Owner for an Event ?
  • What with Event-preconditions ?

(= preconditions for event in general, not for a method in a class)

18:12

24

slide-25
SLIDE 25

Transformation Tool

Transformation Definition

Event Forwarding: example scheme

  • General outline:

Check first Do then

18:12

25

PRODUCT TYPE PRODUCT ORDER ORDER LINE

(2) Check modify_quantity (3) Check modify_quantity (4) Checkmodify_quantity (1) modify_quantity OK OK OK Done Done Done Done (1) Check modify_quantity (2) modify_quantity (3) modify_quantity (4) modify_quantity

slide-26
SLIDE 26

Transformation Tool

Transformation Definition

Event forwarding

Questions

  • How to ensure atomicity ?
  • What if more than one Owner for an Event ?
  • What with Event-preconditions ?

(= preconditions for event in general, not for a method in a class)

18:12

26

BOOK MEMBER LOAN RESERVATION fetch loan.member = reservation.member loan.book = reservation.book

slide-27
SLIDE 27

Transformation Tool

Transformation Definition

Event Broadcasting: example scheme 2

  • One class per 1-many Event(s)

18:12

27

Event

PRODUCT TYPE PRODUCT ORDER ORDER LINE

modify_quantity

Modify Quantity

Check modify quantity

Done Done Done Done

modify quantity

Done Ok Ok Ok Ok

slide-28
SLIDE 28

Transformation Tool

Transformation Definition

e:Event Handler

  • 1

:Object Type s :StateClass checkEvent() OK_prec = checkEvent() getCurrentState() s = getCurrentState() checkEvent() IS1 :InputService handleEvent(o1) OK_state = checkEvent() Result = handleEvent() event() 1 2 event() 3 4

Event broadcasting pattern in Prototype

18:12

28

slide-29
SLIDE 29

Transformation Tool

Transformation Definition

Event broadcasting pattern in Prototype

18:12

29

1 1 2 2 3 4 3 4

slide-30
SLIDE 30

Transformation Tool

Transformation Definition

Event Broadcasting: example scheme 2bis

  • One class per 1-many Event(s)

18:12

30

Event

PRODUCT TYPE PRODUCT ORDER ORDER LINE

modify_quantity

Modify Quantity

Check modify quantity

Done Done Done Done

modify quantity

Done

Check done by Event Handler

slide-31
SLIDE 31

Transformation Tool

Transformation Definition

Event Broadcasting: example scheme 2ter

  • One class per 1-many Event(s)

18:12

31

Event

PRODUCT TYPE PRODUCT ORDER ORDER LINE

modify_quantity

Modify Quantity

Check modify quantity

Done Done Done Done

modify quantity

Done

Check done by Rules Engine Rules Engine OK

slide-32
SLIDE 32

Transformation Tool

Transformation Definition

Event Broadcasting: example scheme 2

  • 2 main Options:
  • hard coded
  • for example one method per event
  • Using OET as look-up table
  • allows for dynamic subscription

18:12

32

slide-33
SLIDE 33

Transformation Tool

Transformation Definition

Hard coded EventDispatcher

Member Book Loan Borrow A/M A/M O/C

18:12

33

Class Eventhandler borrow (m:member, b: book) is local new_loan : LOAN require do lock m lock b check Preconditions loan check preconditions member check preconditions book if OK then create new_loan.borrow(db.loans.new_id, book, member) db.loans.extend(new_loan) – stores new loan in database b.borrow(new_loan) m.borrow(new_loan) unlock member unlock copy end

slide-34
SLIDE 34

Transformation Tool

Transformation Definition

Event Dispatcher with look-up table

Member Book Loan Borrow A/M A/M O/C

18:12

34

MEMBER LOAN BOOK

borrow

borrow

Done Done Done

Borrow

Done

slide-35
SLIDE 35

Transformation Tool

Transformation Definition

Patterns for Event Handling

  • Choice of transformation depends on aspects not yet captured in EL, ISL, BL
  • Non-functional Requirements (Qualities)
  • single platform vs multi-platform
  • confidentiality of rules
  • variability of participating services
  • technical capabilities of participating services
  • performance
  • Technical Design Choices
  • hard-coded or with subscription manager
  • coordination protocol
  • two-phase commit
  • compensation-based
  • rules private and checked decentrally
  • rules shared and checked centrally

18:12

35

slide-36
SLIDE 36

Transformation Tool

Transformation Definition

Agenda

  • Model Transformations
  • General approach
  • Transformation Rule Examples
  • General Architecture
  • The Enterprise Layer
  • The Event Handling Layer
  • Transformation Technology Example

18:12

37

slide-37
SLIDE 37

Transformation Tool

Transformation Definition

Generator Engine

Template-based transformation

18:12

38 Data structure Templates

slide-38
SLIDE 38

Transformation Tool

Transformation Definition

MXP to Java via Apache Velocity

  • Apache Generator engine

1.

Defines a data structure consisting of Java meta-object classes as structured data collections

2.

Uses an XML parser to extract data from MXP file and populate the Java meta-object classes

3.

Distributes properties collected from XML into velocity template contexts

18:12

39

slide-39
SLIDE 39

Transformation Tool

Transformation Definition

Starting point = Merode MXP

18:12

40

  • Merode model = XML file
  • XML = Extensible Markup Language
  • was created to structure, store, and transport information
  • most common tool for data transmissions between all sorts of

applications

  • uses tags which are not predefined => user can define any tag
  • Information is stored between opening and closing tags, e.g.

<note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>

slide-40
SLIDE 40

Transformation Tool

Transformation Definition

Merode MXP

  • Object types, attributes, events, methods

18:12

41

String name String nr

<mxp:metamodel lastid="13"> <mxp:datatypes /> <mxp:metaobjects> <mxp:metaobject id="1" name="a" abstract="false"> <mxp:metadescription /> <mxp:metaconstraints /> <mxp:metamultiplepropagationconstraints /> <mxp:metaattributes> <mxp:metaattribute id="12" name="name" type="String" type-id="1"> <mxp:description /> <mxp:validation /> <mxp:implementation /> </mxp:metaattribute> <mxp:metaattribute id="13" name="nr" type="String" type-id="1"> <mxp:description /> <mxp:validation /> <mxp:implementation /> </mxp:metaattribute> / t tt ib t

slide-41
SLIDE 41

Transformation Tool

Transformation Definition

Merode MXP

  • Object types, attributes, events, methods

18:12

42

<mxp:metaevents> <mxp:metaevent id="2" name="cr_a"> <mxp:metadescription /> <mxp:metaattributes /> </mxp:metaevent> <mxp:metaevent id="3" name="end_a"> <mxp:metadescription /> <mxp:metaattributes /> </mxp:metaevent> </mxp:metaevents>

slide-42
SLIDE 42

Transformation Tool

Transformation Definition

Merode MXP

  • Object types, attributes, events, methods

18:12

43

<mxp:metamethods> <mxp:metamethod id="4" name="cr_a" provenance="OWNED" type="CREATE" ownerobjectid="1" ownereventid="2"> <mxp:metaprecondition /> <mxp:metaimplementation /> <mxp:metapostcondition /> <mxp:metaattributes /> </mxp:metamethod> <mxp:metamethod id="5" name="end_a" provenance="OWNED" type="END" ownerobjectid="1" ownereventid="3"> <mxp:metaprecondition /> <mxp:metaimplementation /> <mxp:metapostcondition /> <mxp:metaattributes /> </mxp:metamethod> </mxp:metamethods>

slide-43
SLIDE 43

Transformation Tool

Transformation Definition

Generation of Java-Code

  • Template for mapping a business object type defined in the

MERODE-model into a Java class

public abstract class $object.objName { // ---------------- attributes -------------------- #foreach ($attribute in $object.attributes.entrySet()) private $attribute.attributeType $attribute.attributeName; #end // ---------------- dependencies -------------------- #foreach ($master in $object.masters.entrySet()) private $master.masterName $master.masterName.toLowerCase(); #end ... }

18:12

44

slide-44
SLIDE 44

Transformation Tool

Transformation Definition

Generation of Java-Code

  • Template applied to LOAN

public abstract class Loan { // ---------------- attributes -------------------- private int loanID; private Date loanDate; private Date returnDate; // ---------------- dependencies -------------------- private Member member; private Copy copy;

18:12

45

slide-45
SLIDE 45

Transformation Tool

Transformation Definition

Generation of Java Code

  • Template for checking referential integrity precondition

#foreach ( $method in $object.ownedMethods ) .... #if ($method.isEndingMethod) if(hasLivingDependents()) throw new MerodeException ("Precondition violation in ending method \"${method.methodName}\" in class ${object.objectName}:\nObject has living dependents"); .... #end

18:12

46

slide-46
SLIDE 46

Transformation Tool

Transformation Definition

Generation of Java code

  • Result after applying to class A:

public class Aimpl extends A { ... public void check_end_a() throws MerodeException { if(hasLivingDependents()) throw new MerodeException ("Precondition violation in ending method \"end_a\" in class A:\nObject has living dependents"); } .... }

18:12

47

slide-47
SLIDE 47

Transformation Tool

Transformation Definition

Other examples of MDE

  • Previous JMermaid code generator (Raf Haesen)
  • Extension to UI generation (Jenny Ruiz)
  • Event-based Distributed Business Processes (Pieter Hens)
  • Service composition (Geert Monsieur)
  • Current JMermaid code generator (Gayane Sedrakyan)

18:12

48

slide-48
SLIDE 48

Transformation Tool

Transformation Definition

Case: Previous JMermaid code generator

18:12

49

  • Used XMI-based generator “Andro MDA”
slide-49
SLIDE 49

Transformation Tool

Transformation Definition

UML: MXP to XMI via XSLT

18:12

50

XMI: <UML:Class visibility="public" isSpecification="false" isRoot="false" isLeaf="false" isAbstract="false" isActive="false" stereotype="sentity" xmi.id="484" name="A"> <UML:Classifier.feature> <UML:Attribute visibility="private" isSpecification="false" ownerScope="instance" xmi.id="485" name="naam" type="987654321"/> <UML:Attribute visibility="private" isSpecification="false" ownerScope="instance" xmi.id="487" name="nr" type="987654321"/> <UML:Operation visibility="public" isSpecification="false" ownerScope="instance" isQuery="false" concurrency="sequential" isRoot="false" isLeaf="false" isAbstract="false" xmi.id="490" name="cr_a" stereotype="soc"> <UML:BehavioralFeature.parameter> <UML:Parameter kind="return" type="dvoid" xmi.id="mp490"/> </UML:BehavioralFeature.parameter> </UML:Operation> <UML:Operation visibility="public" isSpecification="false" ownerScope="instance" isQuery="false" concurrency="sequential" isRoot="false" isLeaf="false" isAbstract="false" xmi.id="491" name="end_a" stereotype="soe"> <UML:BehavioralFeature.parameter> <UML:Parameter kind="return" type="dvoid" xmi.id="mp491"/> </UML:BehavioralFeature.parameter> </UML:Operation> </UML:Classifier.feature> </UML:Class>

slide-50
SLIDE 50

Transformation Tool

Transformation Definition

Case: Extension with UI design

18:12

51

slide-51
SLIDE 51

Transformation Tool

Transformation Definition

Presentation model

18:12

52

slide-52
SLIDE 52

Transformation Tool

Transformation Definition

Case: Extension with UI design

  • UI generated according to UI design choices recorded in presentation model.

18:12

53

slide-53
SLIDE 53

Transformation Tool

Transformation Definition

Case: Using MDA to improve load balancing in business process execution

  • Model2Model transformation to split a global process into multiple smaller –lightweight-

processes

  • Takes advantage of existing event-based architectures (publish –subscribe)

18:12

54 BPMN Model

PIM

Split BPMN Model Split BPMN Model Split BPMN Model

Decentralization Algorithm

PSM PSM PSM

Business Process Modeler Deploy and distribute

Process Engine

Code Code Code

Process Engine Process Engine

slide-54
SLIDE 54

Transformation Tool

Transformation Definition

PIM2PSM Transformation (1)

18:12

55

  • Each task in the original process

becomes a process on its own

  • For each new process, start rules are

calculated

  • A start rules depicts when a split

process can start its execution

  • The split processes are also in BPMN-

notation

  • The start rules are transcribed with

the use of bpmn-start-events

slide-55
SLIDE 55

Transformation Tool

Transformation Definition

PIM2PSM Transformation (2)

18:12

56

  • Realized with the Atlas Transformation Language
  • Declarative language to define transformation rules from objects in the source meta-model to objects in the

target meta-model

  • Available as an Eclipse Plugin

rule Task2Process { from s: BPMN20!Task to newTask: BPMN20!Task ( id <- s.id, name <- s.name ), endev: BPMN20!EndEvent ( id <- 'EndEvent' + s.id, eventDefinitions <- outputDef ),

  • utputDef: BPMN20!SignalEventDefinition (

id <- 'outputDef' + s.id, signalRef <- outputSignal ),

  • utputSignal: BPMN20!Signal (

id <- 'Signal' + s.id), ), process: BPMN20!Process ( id <- 'sid-Process' + s.id, flowElements <- Sequence{newTask}, flowElements <- Sequence{outputSeqFlow}, flowElements <- Sequence{endev}, flowElements <- s.getEventRule()

  • > collect(e | thisModule.createStartEvents(e))

)

Ecore MetaMetaModel ATL BPMN2.0 BPMN2.0 BPMN2EventBPMN Source Model Target Model

Conforms to Conforms to Conforms to Conforms to Transformation Conforms to

slide-56
SLIDE 56

Transformation Tool

Transformation Definition

Coordination in service compositions

18:12

57

Business Process as blueprint Coordination = Control Flow + Data Flow

slide-57
SLIDE 57

Transformation Tool

Transformation Definition

Using MDA to automate the design of service interactions

18:12

58

BPMN Model

PIM

BPEL + WSDL File BPEL + WSDL File BPEL + WSDL File

Pattern-based coordination

PSM PSM PSM

Business Process Modeler Deploy and distribute

BPEL Engine

Code Code Code

BPEL Engine BPEL Engine

Configurable transformation ! Choose a pattern, then transform

slide-58
SLIDE 58

Transformation Tool

Transformation Definition

PIM2PSM transformation

  • Transformation rules implemented in Java
  • PIM (input):
  • BPMN 2.0 (XML)
  • Service and Data Providers (WSDL files)
  • Transformation configuration:
  • Coordination Model (XML)

= selection of patterns

  • PSM (output):
  • BPEL (and WSDL) files for each participating

service in the service composition

18:12

59

Arrange
  • nline
payment Book flight Send tickets to customer Book car Book hotel Register payment Process customer’s request Notify Customer Overview
  • n unpaid
invoices Processed customer request Customer’s address The ‘overview on unpaid invoices’ data
  • bject can be retrieved from the
Finance Data Service and is required to make the decision that is modeld in this data-based gateway The ‘processed customer request’ data
  • bject which is a result from the
‘process customer’s request’ task is required to make the decision that is modeled in this data-based gateway Customer wants a hotel Customer wants a flight Customer wants a car The ‘customer’s address’ data
  • bject is available at the
Customer Data Service One or more unpaid invoices No unpaid invoices

Java

slide-59
SLIDE 59

Transformation Tool

Transformation Definition

Lessons Learned about MDE

  • Productivity ?
  • Development of code generation transformation: approximately 6-8 PM work
  • Intensive testing required
  • bug-free after +/- 1 year of use
  • Yearly used to generate hundred’s of applications
  • Template-based approach + JAVA are easy-to-use technologies for transformations
  • Documentation
  • PIM requires its own documentation
  • Documentation of transformation is essential

Maintenance of transformation is harder than maintenance of “normal” code

  •  the need for documentation does not disappear
  • Portability & Interoperability
  • Yes, but new transformations need to be defined

18:12

60