A Semi-automatic Approach for Bridging DSLs with UML

20
1 © 2007 BIG Vienna University of Technology A Semi-automatic Approach for Bridging A Semi-automatic Approach for Bridging DSLs with UML DSLs with UML 7th OOPSLA Workshop on Domain-Specific Modeling 7th OOPSLA Workshop on Domain-Specific Modeling Montréal Canada Montréal Canada October 21-22, 2007 October 21-22, 2007 Manuel Wimmer Manuel Wimmer , Andrea Schauerhuber, , Andrea Schauerhuber, Michael Strommer, Gerti Kappel Michael Strommer, Gerti Kappel {wimmer, schauerhuber, strommer, {wimmer, schauerhuber, strommer, gerti}@big.tuwien.ac.at gerti}@big.tuwien.ac.at 22.10.2007 M odel CVS X Y Z U V W X Y Z U V W Vienna University of Technology Wieland Schwinger Wieland Schwinger [email protected] [email protected] IF IF S S Johannes Kepler University Linz

description

Johannes Kepler University Linz. Vienna University of Technology. A Semi-automatic Approach for Bridging DSLs with UML 7th OOPSLA Workshop on Domain-Specific Modeling Montréal Canada October 21-22, 2007. - PowerPoint PPT Presentation

Transcript of A Semi-automatic Approach for Bridging DSLs with UML

Page 1: A Semi-automatic Approach for Bridging DSLs with UML

1© 2007 BIG Vienna University of Technology

A Semi-automatic Approach for A Semi-automatic Approach for Bridging DSLs with UMLBridging DSLs with UML7th OOPSLA Workshop on Domain-Specific Modeling7th OOPSLA Workshop on Domain-Specific Modeling

Montréal CanadaMontréal CanadaOctober 21-22, 2007October 21-22, 2007

Manuel WimmerManuel Wimmer, Andrea Schauerhuber, , Andrea Schauerhuber, Michael Strommer, Gerti KappelMichael Strommer, Gerti Kappel

{wimmer, schauerhuber, strommer, gerti}@big.tuwien.ac.at{wimmer, schauerhuber, strommer, gerti}@big.tuwien.ac.at

22.10.2007ModelCVS

Class

ClassClass

Class

Class

Class

Class

Class

ClassClass

Class

ClassClass

Class

Class

Class

Class

Class

ClassClass

Class

Class Class Class

Class

Class Class

Class

Class

ClassClass

Class

Class

Class

Class

Class

ClassClass

Class

ClassClass

Class

Class

Class

Class

Class

ClassClass

Class

Class Class Class

Class

Class Class

Class

X

Y Z

U V

W

X

Y Z

U V

W

X

Y Z

U V

W

X

Y Z

U V

W

Vienna University of Technology

Wieland SchwingerWieland [email protected]@ifs.uni-linz.ac.at IFIF

SS

Johannes Kepler University Linz

Page 2: A Semi-automatic Approach for Bridging DSLs with UML

2© 2007 BIG Vienna University of Technology

Overview

Motivation Related Work State of the Art Methodology Semi-automatic Bridge Generation Case Study Summary

Page 3: A Semi-automatic Approach for Bridging DSLs with UML

3© 2007 BIG Vienna University of Technology

Motivation

In the modeling world, DSLs are defined externally with Metamodels or internally with UML Profiles

Problem: No interoperability between formalisms

Need to bridge both approaches1. Exit strategy for existing CASE tools

Further use of code generation functionalities of CASE tools No information of DSL models should be lost!

2. Building UML Profiles from scratch First step: define modeling concepts in a metamodel [1]

Page 4: A Semi-automatic Approach for Bridging DSLs with UML

4© 2007 BIG Vienna University of Technology

Related Work

Integration of DSLs and UML Profiles in Abouzahra et al. [2] Mappings between DSL metamodel and UML profile Model transformations from DSL models to UML models and

vice versa are automatically generated Prerequisite: UML Profile exists

Difference to our work We do not assume, that a UML Profile is already available Whole bridge is generated

UML profile Model transformations

Page 5: A Semi-automatic Approach for Bridging DSLs with UML

5© 2007 BIG Vienna University of Technology

DSL-MM

DSL2UML rule EntityType2Class from e : EntityType to c : Class { c.name = e.name; c.applyStereotype(EntityType); c.maxInstances = e.maxInstances;}

Transformations

rule Class2EntityType from c: Class to e: EntityType[ c.appliedStereotype(EntityType) ] { e.name = c.name; e.maxInstances = c.maxInstances;}

UML2DSL

UML-MM

C

C

UML-Profile«MetaClass»

Class

«Stereotype» EntityType

maxInstances : Integer

State of the ArtAd-hoc Bridge Implementation

Drawbacks of Ad-hoc Implementation1. Transformations and Profiles are highly coupled2. Bridging covers repetitive tasks3. No guidelines4. No explicit correspondences between DSL and UML

Page 6: A Semi-automatic Approach for Bridging DSLs with UML

6© 2007 BIG Vienna University of Technology

MappingModel

MethodologyStep 1: Mapping Creation

DSL-MM

DSL2UML rule EntityType2Class from e : EntityType to c : Class { c.name = e.name; c.applyStereotype(EntityType); c.maxInstances = e.maxInstances;}

Transformations

UML-Profile«MetaClass»

Class

«Stereotype» EntityType

maxInstances : Integer

rule Class2EntityType from c: Class to e: EntityType[ c.appliedStereotype(EntityType) ] { e.name = c.name; e.maxInstances = c.maxInstances;}

UML2DSL

UML-MM

C

C

Step 1: User has to define mappings between DSL and UML metamodel elements Manually in mapping editor Use a dedicated Metamodel Mapping Language

Page 7: A Semi-automatic Approach for Bridging DSLs with UML

7© 2007 BIG Vienna University of Technology

MappingModel

MethodologyStep 2: Bridge Generation

DSL-MM

DSL2UML rule EntityType2Class from e : EntityType to c : Class { c.name = e.name; c.applyStereotype(EntityType); c.maxInstances = e.maxInstances;}

Transformations

UML-Profile«MetaClass»

Class

«Stereotype» EntityType

maxInstances : Integer

rule Class2EntityType from c: Class to e: EntityType[ c.appliedStereotype(EntityType) ] { e.name = c.name; e.maxInstances = c.maxInstances;}

UML2DSL

UML-MM

C

C

Step 2: Bridge is automatically generated by BridgeGenerator Parses user-defined mappings Generates profile definitions Generates model transformations

Bridge Generator

Page 8: A Semi-automatic Approach for Bridging DSLs with UML

8© 2007 BIG Vienna University of Technology

Comparison of ApproachesDrawbacks of Ad-hoc Implementation and Solutions

Drawback 1: Transformations and profiles are highly coupledSolution: Mapping model is single source of information

Drawback 2: Bridging covers repetitive tasksSolution: Automation by model transformations

Drawback 3: No guidelinesSolution: Guidelines support systematic integration

Drawback 4: No explicit correspondences between DSL and UMLSolution: Explicit correspondences via mapping model

Page 9: A Semi-automatic Approach for Bridging DSLs with UML

9© 2007 BIG Vienna University of Technology

Step 1: Mapping Creation (1/3) Overview

General Idea: Map semantically corresponding DSL metamodel elements and UML metamodel elements

Metamodel element types Class Feature

Attribute Reference

User-defined Type Enumeration

» Enumeration Literal Data Type

Page 10: A Semi-automatic Approach for Bridging DSLs with UML

10© 2007 BIG Vienna University of Technology

mwcore

MappingLanguage

WModel ModelRef

ElementRef

WLinkEndWLink

WModel

Cl2Cl-Mapping 0..*Feat2Feat-Mapping

WLink

Att2Att-MappingRef2Ref-Mapping Enum2Enum-Mapping

Lit2Lit-MappingisAbstract : BOOL =

false

Invariantexp : OCLExpression

2

*

* 1

0..*

0..*

0..*

0..* 0..*rightInvleftInv

0..*

Step 1: Mapping Creation (2/3) Mapping Language

superMapping

0..*

MappingModel

0..*

Dat2Dat-Mapping

Type2Type-Mapping

Mapping Language is based on the ATLAS Model Weaver Core Language (mwcore) [3]

For each metamodel type, a mapping operator is defined(MappingLanguage)

Page 11: A Semi-automatic Approach for Bridging DSLs with UML

11© 2007 BIG Vienna University of Technology

Step 1: Mapping Creation (3/3)Mapping Tool: AMW

UML MMDSL

MM

Mapping Model

Properties of mappings

Page 12: A Semi-automatic Approach for Bridging DSLs with UML

12© 2007 BIG Vienna University of Technology

Step 2: UML Profile Generation (1/3) Stereotype Generation

UML Profile generation is driven by user-defined mappings

Stereotype Generation

for each cl2cl mappingModel.getCl2Cl-Mappings(){create Stereotype {

self.setName(cl2cl.getRightClass().getName());self.setExtension(cl2cl.getLeftClass());for each superMapping cl2cl.getSuperMappings() {

self.getSuperStereotype().add( resolveCreatedStereotypeFor(superMapping));

}}

}

Page 13: A Semi-automatic Approach for Bridging DSLs with UML

13© 2007 BIG Vienna University of Technology

Step 2: UML Profile Generation (2/3) Tagged Value Generation

General Idea of Tagged Value Generation: Distinction between mapped and unmapped features

UML:: Class_B

DSL::Class_A

Mapped features No tagged values are produced

Unmapped DSL features Generate Tagged Values

Unmapped UML features No tagged values are produced

features

features

Cl2Cl

Page 14: A Semi-automatic Approach for Bridging DSLs with UML

14© 2007 BIG Vienna University of Technology

Step 2: UML Profile Generation (3/3) Data Type and Enumeration Generation

Distinction between mapped and unmapped types

- Private- Public

DSL

«enumeration» Visibility

«enumeration» VisibilityKin

d

UMLMappingModel

E2E

0..*- Private- Public

L2L

L2L

DSL UML

- Restrict- SetNULL

n.a.

No additional elementsare necessary

Create EnumerationDeletionKind withLiterals Restrict and SetNULL

Mapping not

possible

Map

ped

Typ

es

Un

map

ped

Typ

es

Mapping Model BridgeGenerator

«enumeration»

DeletionKind

Page 15: A Semi-automatic Approach for Bridging DSLs with UML

15© 2007 BIG Vienna University of Technology

Step 2: Model Transformation Generation

Model Transformation Frameworks supporting UML Profiles are hard to find Work-around: Read in Profiles as additional input models

Model Transformation Generation Template (ATL Code)

rule cl2cl.getLeft.name() + _2_ + cl2cl.getRight().name extends getRulesfor(cl2cl.superMappings) {

from s : DSL!cl2cl.getLeft() [cl2cl.getLeftInv()]

to t : UML!cl2cl.getRight() (

//set attributes/references for mapped features

)

do{

if(cl2cl.isRoot()){ t.applyProfile(getLeftModel.name); }

t.assignStereotype(cl2cl.getLeft().name); //set tagged values for unmapped features

}

}

Page 16: A Semi-automatic Approach for Bridging DSLs with UML

16© 2007 BIG Vienna University of Technology

Case StudyAllFusion Gen 2 Rational Software Modeler

AllFusion Gen

Rational SoftwareModeler(RSM)

Eclipse

DataModelMM UML2MMDataModelProfile

DataModel ClassModel

Gen_2_UML2

UML2_2_Gen

ATL

ATL

Injector

ExtractorExtractor

Injector

Eclipse Modeling Framework UML2 Project

Goal of the ModelCVS project: Bridge AllFusion Gen with UML AllFusion Gen consists of several DSLs

Data Model, GUI Design, Dialog Flow, … Case Study 1: Bridge Data Model with UML Class Model

Architecture of the Integration Framework

ModelCVS

Class

ClassClass

Class

Class

Class

Class

Class

ClassClass

Class

ClassClass

Class

Class

Class

Class

Class

ClassClass

Class

Class Class Class

Class

Class Class

Class

Class

ClassClass

Class

Class

Class

Class

Class

ClassClass

Class

ClassClass

Class

Class

Class

Class

Class

ClassClass

Class

Class Class Class

Class

Class Class

Class

X

Y Z

U V

W

X

Y Z

U V

W

X

Y Z

U V

W

X

Y Z

U V

W

http://www.modelcvs.org

Page 17: A Semi-automatic Approach for Bridging DSLs with UML

17© 2007 BIG Vienna University of Technology

«profile»DataModel

«stereotype»

AnalysisEntityType«stereotype»

DesignEntityType

«metaclass»

NamedElement«stereotype»

DataDefinitionElement

«stereotype»

Relationship«metaclass»

Property«stereotype»

Attribute

«metaclass»

Package«stereotype»

SubjectArea

«metaclass»

Class«stereotype»

EntityType

C2C Mapping OverviewDataModel

SubjectArea

0..*

EntityType

DataDefinitionElement

Attribute

Relationship

name : String [1:1]

PackageableElement0..*

Package

NamedElement

Property

Class

name : String [1:1]

ClassModelMappingModel

0..*

0..*

AnalysisEntityType DesignEntityType

C2C

C2C

C2C

C2C

C2C

0..*

GEN

Page 18: A Semi-automatic Approach for Bridging DSLs with UML

18© 2007 BIG Vienna University of Technology

DataModel

EntityType

Attribute

Relationship

avgOccurrence:IntminOccurrence:IntmaxOccurence:IntpercentengeOfGrowth:Int

superEntity

0..1

Property

ClasssuperClass

0..*

UMLModelMappingModel

C2C

0..*

0..*

AnalysisEntityType DesignEntityType

isAbstract:Bool

0..*

R2R

R2R

«profile»

DataModel

«stereotype»

AnalysisEntityType«stereotype»

DesignEntityType

avgOccurrence:IntminOccurrence:IntmaxOccurrence:IntpercentengeOfGrowth:Int

«stereotype»

EntityType«metaclass»

Class

if(self.getAssignedStereotype() .oclIsKindOf(EntityType)){ self.superClass.upper = 1}

R2R

EntityType 2 Class Mapping Details

GEN

Page 19: A Semi-automatic Approach for Bridging DSLs with UML

19© 2007 BIG Vienna University of Technology

Summary

We presented how to derive a bridge between DSLs and UML semi-automatically

Mapping Creation: Define correspondences between DSL and UML metamodel elements

Generate UML Profile: Stereotypes, tagged values, data types, and constraints

Generate Model Transformations: Transformation Code also uses the generated UML profiles

Ongoing Work Mapping Language: n:m Mappings, Path-Exp, … Mapping Editor: validation support, … Adapt profile and model transformation generation Further case studies: GUI Design, Dialog Flow

Step 1

Step 2

Page 20: A Semi-automatic Approach for Bridging DSLs with UML

20© 2007 BIG Vienna University of Technology

References

[1] N. Moreno, P. Fraternali, and A. Vallecillo. WebML modeling in UML. IET Software Journal, 2007.

[2] A. Abouzahra, J. Bezivin, M. D. D. Fabro, and F. Jouault. A Practical Approach to Bridging Domain Specific Languages with UML profiles. In Proceedings of the Best Practices for Model Driven Software Development at OOPSLA’05, San Diego, California, USA, 2005.

[3] M. D. D. Fabro, J. Bzivin, F. Jouault, E. Breton, and G. Gueltas. AMW: a generic model weaver. In Proceedings of the 1re Journe sur l’Ingnierie Dirige par les Modles (IDM05), 2005.