© 2005-2006 The ATHENA Consortium. 5-3. UML Profiles and Domain-Specific Languages (DSLs),
A Semi-automatic Approach for Bridging DSLs with UML
description
Transcript of 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
2© 2007 BIG Vienna University of Technology
Overview
Motivation Related Work State of the Art Methodology Semi-automatic Bridge Generation Case Study Summary
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]
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
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
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
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
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
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
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)
11© 2007 BIG Vienna University of Technology
Step 1: Mapping Creation (3/3)Mapping Tool: AMW
UML MMDSL
MM
Mapping Model
Properties of mappings
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));
}}
}
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
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
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
}
}
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
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
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
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
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.