The Art of Model Transformation with Operational QVT.ppt

上传人:文库蛋蛋多 文档编号:2801616 上传时间:2023-02-25 格式:PPT 页数:38 大小:1.55MB
返回 下载 相关 举报
The Art of Model Transformation with Operational QVT.ppt_第1页
第1页 / 共38页
The Art of Model Transformation with Operational QVT.ppt_第2页
第2页 / 共38页
The Art of Model Transformation with Operational QVT.ppt_第3页
第3页 / 共38页
The Art of Model Transformation with Operational QVT.ppt_第4页
第4页 / 共38页
The Art of Model Transformation with Operational QVT.ppt_第5页
第5页 / 共38页
点击查看更多>>
资源描述

《The Art of Model Transformation with Operational QVT.ppt》由会员分享,可在线阅读,更多相关《The Art of Model Transformation with Operational QVT.ppt(38页珍藏版)》请在三一办公上搜索。

1、23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-1-,The Art of Model Transformation with Operational QVT,Sergey BoykoRadomil DvorakAlexander IgdalovBorland Software Corporation,23 March,2009,The Art of Model Transformation with Operati

2、onal QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-2-,QVTO Key Concepts,Operational QVT(QVTO)operates with EMF modelsuses OCL for model navigationMain goal-model modification and transformationrequired an explicit and complete algorithm model-to-model mapping,23 March,2009,The Art of Model Tran

3、sformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-3-,QVTO structure,QVTOperational package general structuring elements and top-level constructionsImperativeOCL package extension to OCL expressions and type systemStandard Library,23 March,2009,The Art of Model Transforma

4、tion with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-4-,QVTOperational package,Transformation declarationImperative operations(mappings,helpers,queries,constructors)Intermediate dataObject creation and update mechanismTrace resolution expressions,23 March,2009,The Art of Model Tr

5、ansformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-5-,Operational Transformation 1,modeltype ECORE uses http:/www.eclipse.org/emf/2002/Ecore;modeltype UML uses http:/www.eclipse.org/uml2/2.0.0/UML;transformation Ecore2Uml(in inModel:ECORE,out outModel:UML);main()inModel

6、.rootObjects()EPackage-map ePackage2Model();mapping EPackage:ePackage2Model():Model name:=self.name;,A simple transformation example,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-6-,Operational Transformation 2,The content of the tr

7、ansformation definition may be placed within the transformation element:modeltype ECORE uses http:/www.eclipse.org/emf/2002/Ecore;modeltype UML uses http:/www.eclipse.org/uml2/2.0.0/UML;transformation Ecore2Uml(in inModel:ECORE,out outModel:UML)main()inModel.rootObjects()EPackage-map ePackage2Model(

8、);mapping EPackage:ePackage2Model():Model name:=self.name;,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-7-,Imperative Operations,define an imperative bodyenriched signatureTypes of QVTO imperative operationsEntry operationMappingsH

9、elpersQueriesConstructors,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-8-,Entry Operation,An entry operation is the entry point for the execution of a transformation.main()inModel.rootObjects()EPackage-map ePackage2Model();Typicall

10、y refers to model parameters and invokes top-level mappings.,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-9-,Helpers and Queries,A helper is an operation that performs a computation on one or more source objects and provides a resu

11、lt.It is illegal to create or update object instances except for pre-defined types like sets,tuples,and for intermediate properties.helper EPackage:someHelper1():Set(String)if(self.name=A)then return Set B;endif;return Set self.name;A query is a“read-only”helper which is not allowed to create or upd

12、ate any objects.query EPackage:getNameAtoB():String if(self.name=A)then return B;endif;return self.name;helper EPackage:someHelper2():Set(String)=Setself.name;query EPackage:getName():String=self.name;,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Ale

13、xander Igdalov,-10-,Constructors,A constructor is an operation that defines how to create and populate the properties of an instance of a given class.constructor EClass:EClass(s:String,op:EOperation)name:=s;eOperations+=op;Calling the constructor:new EClass(“AClass,new EOperation();,23 March,2009,Th

14、e Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-11-,Mappings,A mapping between one or more source model elements into one or more target model elements.:=*mapping?(:)?(?)(:param_list)?*?Most typical case:mapping:():mapping ECORE:EPackage:ePackage2Pac

15、kage():UML:Package name:=self.name;ePackage.map ePackage2Package();/calling a mapping for a single contextePackages-map ePackage2Package();/calling a mapping consequently for a collection of contexts,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexa

16、nder Igdalov,-12-,Mapping Parameters Direction Kind,mapping EPackage:someMapping(in a:EClass):Package name:=self.name;mapping EPackage:someMapping(in a:EClass,inout b:EAttribute):Model name:=self.name+a.name;b.name:=b.name+123;mapping inout EPackage:ePackage2Package():Package name:=self.name+123;sel

17、f.name:=result.name+456;Mapping parameter direction kind in object passed for read-only access,the default direction inout object passed for update,retains its value out parameter receives new value(not necessarily newly created object),23 March,2009,The Art of Model Transformation with Operational

18、QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-13-,Mappings when clause,mapping EPackage:ePackage2Package():Package when self.name null name:=self.name;,self.name=null(condition not satisfied)mapping not executed null returned mapping not executed exception thrown,WHEN-clause containsa Boolean c

19、ondition,Invocation:-in standard modewhen-clause acts as a guard which filters input parametersa.map ePackage2Package();-in strict modewhen-clause acts as a pre-condition which must always holda.xmap ePackage2Package();,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,

20、Radomil Dvorak,Alexander Igdalov,-14-,Mapping Body General Form,mapping EPackage:myMapping():Package init var tmp:=self.map otherMapping();if(self.name=AAA)then result:=object Package;endif;population object result:Package name:=self.name;end assert(result.name null);,init sectioncomputation prior t

21、o the instantiation of the outputs,population sectionpopulation of the outputs,end(termination)sectioncomputations before exiting the body,implicit instantiation section instantiation of out parameters(results)that still have a null value,Predefined variables in mappings:self refers to the context r

22、esult refers to the result,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-15-,Mapping Body Population Keyword Omitted,mapping EPackage:myMapping():Package init var tmp:=self.map otherMapping();if(self.name=AAA)then result:=object Pac

23、kage;endif;name:=self.name;end assert(result.name null);,Direct access to properties of the result within the population section without the population keyword!,Omitted population keyword is the most typical case!,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomi

24、l Dvorak,Alexander Igdalov,-16-,Overriding Mappings,Simple overriding:mapping ENamedElement:makeClass():EClass name:=NE:+self.name;mapping EClassifier:makeClass():EClass name:=CLASSIFIER:+self.name;mapping EClass:makeClass():EClass name:=CLASS:+self.name;mapping EDataType:makeClass():EClass name:=DT

25、:+self.name;,-overrides,overrides,overrides,overrides,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-17-,Mapping Extension-inherits,abstract mapping EClassifier:makeClassifier():EClassifier name:=self.name+1;mapping EClass:makeClass(

26、):EClass inherits EClassifier:makeClassifier init var tmp:=2;name:=name+tmp;Evaluation result:result.name=self.name+12,Execution flow:init section(of EClass:makeClass)instantiation section(of EClass:makeClass)inherited mapping(s)(EClassifier:makeClassifier)mapping population and termination sections

27、(of EClass:makeClass),implicit instantiation,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-18-,Mapping Extension-merges,abstract mapping EClassifier:makeClassifier():EClassifier name:=name+1;mapping EClass:makeClass():EClass merges

28、EClassifier:makeClassifier init var tmp:=2;name:=self.name+tmp;Evaluation result:result.name=self.name+21,Execution flow:merging mapping(EClass:makeClassifier)merged mapping(s)(EClassifier:makeClassifier),23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,

29、Alexander Igdalov,-19-,Mapping Extension-disjuncts,mapping EClass:makeAClass():EClass when self.name null and self.name.startsWith(A)name:=self.name+A;mapping EClass:makeBClass():EClass when self.name null and self.name.startsWith(B)name:=self.name+B;mapping EClass:makeClass():EClass disjuncts EClas

30、s:makeAClass,EClass:makeBClass Evaluation results:object EClass name:=CClass.map makeClass()=null;object EClass name:=AClass.map makeClass().name=AClassA;object EClass name:=BClass.map makeClass().name=BClassB;,Execution flow:when-clauses of the disjuncted mappings are evaluated(-of EClass:makeAClas

31、s-of EClass:makeBClass)2.If all when-clauses are not satisfied null is returned3.Otherwise,the first mapping with a true when-clause is executed,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-20-,Traceability Concept,Trace contains i

32、nformation about mapped objectsTrace consists of trace recordsA trace record is created when a mapping is executedTrace records keep reference to the executed mapping and the mapping parameter valuesA trace record is created after the implicit instantiation section of the mapping is finishedmapping

33、EPackage:myMapping():Package init population end Usage:Prohibit duplicate execution with the same parametersUsed in resolve expressionsMay be serialized after the transformation execution,implicit instantiation section,A trace record is created here!,Trace,23 March,2009,The Art of Model Transformati

34、on with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-21-,Resolve Expressions 1,A resolve expression is an expression that inspects trace records to retrieve source or target objects which participated in the previous mapping executions.resolve resolves target objects for a given so

35、urce object inv(invresolve)resolves source objects for a given target object One(resolveOne)finds the first matching object In(resolveIn)inspects trace records for a given mapping only late(late resolve)performs resolution and assignment to some model object property after the transformation executi

36、onmapping EPackage:myMapping():Package 24=16 combinations,e.g.invresolveOne or late invresolveOneIn,source objectstarget objects,ePackage.resolve(Package),23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-22-,Resolve Expressions 2,mappi

37、ng EClassifier:c2c():EClass name:=mapped+self.name;/somewhere in the codevar orig:=object EClass name:=original;var mapped:=orig.map c2c();/in some other placevar res1:=orig.resolve(EClass);var res2:=resolveoneIn(EClassifier:c2c,t:EClass|t.name.startsWith(mapped);var res3:=mapped.invresolveIn(EClass

38、ifier:c2c,EClass);Resolve expressions are a useful instrument of retrieving trace information!,Filtering condition type boolean expression,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-23-,Object Expression,An object expression is a

39、n inline instantiation facility.object x:X/An explicit variable here object Y/No referred variable hereobject x:/the type of x is skipped here when already known If x exists then it is updated,otherwise created and updatedobject EPackage name:=pack;nsURI:=http:/myuri.org;eClassifiers+=object EClass

40、name:=clazz;,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-24-,Model Extents,A model extent is a container for model objects.For each model parameter there is a model extent.modeltype ECORE uses http:/www.eclipse.org/emf/2002/Ecore;

41、transformation transf(in m:ECORE,out x:ECORE,out y:ECORE);main()var a:=object EPackagex name:=a;var b:=object EPackagey name:=b;mapping EClass:toClass():EClassy name:=self.name;Refer to model extents with model_parameter_name,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey

42、Boyko,Radomil Dvorak,Alexander Igdalov,-25-,Intermediate Properties,An intermediate property is a property defined as an extension of the type referred by the context.typically defined as class extensions of model metaclasses created temporarily by a transformation not a part of the output used for

43、intermediate calculations associated with the instances of the extended classintermediate property EClass:intermProp:String;main()object EClass name:=original;intermProp:=abc;,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-26-,Interm

44、ediate Classes,An intermediate class is a class created temporarily by a transformation to perform some needed calculation but which is not part of the expected output.intermediate class MyEPackage extends EPackage myName:String;mapping EClassifier:c2c():EClass object MyEPackage name:=name;myName:=s

45、omeThoughtfulName;,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-27-,ImperativeOCL package,AssignmentsVariablesLoops(while,forEach)Loop interrupt constructs(break,continue)Conditional execution workflowConvenient shorthand notationM

46、utable collections,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-28-,Assignments,Assignment to variablesAssignment to properties(including complex nested constructions)mapping EClassifier:c2c():EClass name:=self.name;mapping EPackag

47、e:p2p():EPackage name:=nsPrefix:=nsURI:=aaa;eClassifiers+=self.eClassifiers-map c2c();eClassifiers+=object EClass name:=A;eSuperPackage.eSuperPackage.eSubpackages-any(true).name:=A;,23 March,2009,The Art of Model Transformation with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-29-,

48、Variables in QVTO,OCL variables in let expression:let a:String=aa in/*some expression with a*/;QVTO extends OCL with variable initialization expressions and assignments to variables:var a:String:=A;/full notationvar b:=B;/type deduced from the initialization expressionvar c:String;/default value ass

49、ignedmapping EPackage:p2p():EPackage var tmp:=A+self.name;/variable declaration and initializationname:=tmp;/variable read accesstmp:=tmp+B/variable modificationeClassifiers+=self.eClassifiers-map c2c();eClassifiers+=object EClass name:=tmp;/another access,23 March,2009,The Art of Model Transformati

50、on with Operational QVT-Sergey Boyko,Radomil Dvorak,Alexander Igdalov,-30-,While Loop,OCL iterator expressions iterate through collections and cannot be interrupted by break,continue or return statements.They are rather specific,e.g.:collection-collect(v:Type|expression-with-v)While loop is a Java-l

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号