| -------------------------------------------------------------------------------- |
| -- Copyright (c) 2008 Tata Consultancy Services and others. |
| -- All rights reserved. This program and the accompanying materials |
| -- are made available under the terms of the Eclipse Public License v2.0 |
| -- which accompanies this distribution, and is available at |
| -- http://www.eclipse.org/legal/epl-v20.html |
| -- |
| -- Contributors: |
| -- S.Reddy - Section 10.3 of the OMG MOF-QVT 1.0 specification |
| -- E.D.Willink - contributions to drafts of the above |
| -- E.D.Willink - adaptation to comply with QVT specification |
| -- H. Hoyos - adaptation to comply with QVT 1.2 and bug fixes |
| -------------------------------------------------------------------------------- |
| import pivotocl : 'platform:/resource/org.eclipse.ocl.pivot/model/Pivot.ecore'::pivot; -- HHR Use Pivot metamodels |
| import qvtbase : 'platform:/resource/org.eclipse.qvtd.pivot.qvtbase/model/QVTbase.ecore'::qvtbase; -- HHR Use Pivot metamodels |
| import qvttemplate : 'platform:/resource/org.eclipse.qvtd.pivot.qvttemplate/model/QVTtemplate.ecore'::qvttemplate; -- HHR Use Pivot metamodels |
| import qvtrelation : 'platform:/resource/org.eclipse.qvtd.pivot.qvtrelation/model/QVTrelation.ecore'::qvtrelation; -- HHR Use Pivot metamodels |
| import qvtcore : 'platform:/resource/org.eclipse.qvtd.pivot.qvtcore/model/QVTcore.ecore'::qvtcore; -- HHR Use Pivot metamodels |
| |
| |
| |
| transformation org::eclipse::qvtd::xtext::qvtrelation2::tests::rel2core::relToCore(relations:{qvtrelation,qvttemplate,qvtbase,pivotocl}, core:{qvtcore,qvtbase,pivotocl}) -- HHR Use Pivot metamodels |
| { |
| -- Rule 1: Corresponding to each relation there exists a trace class in core. |
| -- The trace class contains a property corresponding to each object node in the |
| -- pattern of each domain of the relation. |
| -- |
| top relation ModelToTraceModel |
| { |
| modelName:String; |
| modelURI:String; |
| domain relations |
| relationsModel:RelationModel { |
| name = modelName, |
| externalURI = modelURI |
| }; |
| enforce domain core |
| traceModel:Model { |
| name = modelName, |
| externalURI = modelURI |
| }; |
| } |
| |
| top relation PackageToTracePackage |
| { |
| packageName:String; |
| packageURI:String; |
| domain relations |
| relationsPackage:Package { |
| name = packageName, |
| URI = packageURI |
| }; |
| enforce domain core |
| tracePackage:Package { |
| name = packageName, |
| URI = packageURI |
| }; |
| } |
| |
| top relation PackageToTraceModelOwnership |
| { |
| domain relations |
| relationsParent:RelationModel { |
| ownedPackages = relationsChild:Package {} |
| }; |
| enforce domain core |
| traceParent:Model { |
| ownedPackages = traceChild:Package {} |
| }; |
| when { |
| ModelToTraceModel(relationsParent, traceParent); |
| PackageToTracePackage(relationsChild, traceChild); |
| } |
| } |
| |
| top relation PackageToTracePackageOwnership |
| { |
| domain relations |
| relationsParent:Package { |
| ownedPackages = relationsChild:Package {} |
| }; |
| enforce domain core |
| traceParent:Package { |
| ownedPackages = traceChild:Package {} |
| }; |
| when { |
| PackageToTracePackage(relationsParent, traceParent); |
| PackageToTracePackage(relationsChild, traceChild); |
| } |
| } |
| |
| top relation TransformationToTracePackage |
| { |
| domain relations |
| rTransformation:RelationalTransformation { |
| name = transformationName:String{} |
| }; |
| enforce domain core |
| tracePackage:Package { |
| name = 'T'+transformationName |
| }; |
| } |
| |
| top relation TransformationToTracePackageOwnership |
| { |
| domain relations |
| relationsParent:Package { |
| ownedClasses = relationsChild:RelationalTransformation {} |
| }; |
| enforce domain core |
| traceParent:Package { |
| ownedPackages = traceChild:Package {} |
| }; |
| when { |
| PackageToTracePackage(relationsParent, traceParent); |
| TransformationToTracePackage(relationsChild, traceChild); |
| } |
| } |
| |
| top relation RelationToTraceClass |
| { |
| domain relations |
| rRelation: Relation { |
| name = relationName:String{}, |
| _'transformation' = rParent:RelationalTransformation{} |
| }; |
| enforce domain |
| core traceClass:Class { |
| name = 'T'+relationName, |
| owningPackage = traceParent:Package{} |
| }; |
| when { |
| TransformationToTracePackage(rParent, traceParent); |
| } |
| } |
| |
| top relation RootVariableToTraceClassProperty |
| { |
| domain relations |
| rRelation: Relation { |
| domain = relationDomain:RelationDomain { |
| pattern = relationDomainPattern:DomainPattern { |
| templateExpression = rootTemplateExp:TemplateExp { |
| bindsTo = rootVariable:Variable {} |
| } |
| } |
| } |
| }; |
| enforce domain core |
| traceClass:Class{ |
| ownedProperties = traceProperty:Property{} |
| }; |
| when { |
| RelationToTraceClass(rRelation, traceClass); |
| } |
| where { |
| VariableToTraceClassProperty(rootVariable, traceProperty); |
| -- CollectionTemplateToTraceClassProps(rootTemplateExp, traceClass); |
| ObjectTemplateToTraceClassProps(rootTemplateExp, traceClass); |
| } |
| } |
| |
| /* relation CollectionTemplateToTraceClassProps |
| { |
| variableName: String; |
| domain relations |
| collectionTemplateExp:CollectionTemplateExp { |
| member = members:Set(OCLExpression) { |
| templateExp:TemplateExp { |
| bindsTo = templateVariable:Variable { |
| name = variableName, |
| type = variableType:Class {} |
| } |
| } |
| ++ _ } |
| }; |
| enforce domain |
| core traceClass:Class { |
| ownedProperties = traceClassProperty:Property { |
| name=variableName, |
| type=variableType |
| } |
| }; |
| where { |
| CollectionTemplateToTraceClassProps(templateExp, traceClass); |
| ObjectTemplateToTraceClassProps(templateExp, traceClass); |
| } |
| } */ |
| |
| relation ObjectTemplateToTraceClassProps |
| { |
| domain relations |
| objectTemplateExp:ObjectTemplateExp { |
| part = propertyTemplateItem:PropertyTemplateItem { |
| value = templateExp:TemplateExp { |
| bindsTo = templateVariable:Variable {} |
| } |
| } |
| }; |
| enforce domain |
| core traceClass:Class { |
| ownedProperties = traceProperty:Property {} |
| }; |
| where { |
| VariableToTraceClassProperty(templateVariable, traceProperty); |
| -- CollectionTemplateToTraceClassProps(templateExp, traceClass); |
| -- ObjectTemplateToTraceClassProps(templateExp, traceClass); |
| } |
| } |
| |
| relation VariableToTraceClassProperty |
| { |
| domain relations |
| variable:Variable { |
| name = variableName : String{}, |
| type = variableType : Class{} |
| }; |
| enforce domain core |
| traceProperty:Property { |
| name = variableName, |
| type = variableType |
| }; |
| } |
| } |