| /******************************************************************************* |
| * Copyright (c) 2017 Willink Transformations 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: |
| * E.D.Willink - initial implementation |
| *******************************************************************************/ |
| import ecoreMM : 'http://www.eclipse.org/emf/2002/Ecore'; |
| import pivotMM : 'http://www.eclipse.org/ocl/2015/Pivot'; |
| --import pivotMM : 'platform:/resource/org.eclipse.ocl.pivot/model/Pivot.ecore'::pivot; |
| |
| package org::eclipse::ocl::pivot2::ecore2pivot { |
| /** |
| * Transform an Ecore metamodel to a Pivot metamodel |
| */ |
| transformation Ecore2Pivot(ecore:ecoreMM, as:pivotMM) |
| { |
| query getRootEPackages(ePackage : ecoreMM::EPackage[1]) : Set(ecoreMM::EPackage)[1] implementedby 'org.eclipse.qvtd.xtext.qvtrelation.tests.helpers.GetRootEPackages'; |
| |
| /** |
| * ecore::EPackage <=> pivot::Package |
| */ |
| top relation mapEPackage_root { |
| name : String; |
| -- nsPrefix : String; |
| -- nsURI : String; |
| ePackages : Set(ecore::EPackage) = getRootEPackages(ePackage); |
| asModel : pivotMM::Model; |
| /*enforce*/ domain ecore ePackage : EPackage { |
| eSuperPackage = null, |
| name = name |
| -- nsPrefix = nsPrefix, |
| -- nsURI = nsURI |
| }; |
| enforce domain as asPackage : Package { |
| name = name, |
| -- nsPrefix = nsPrefix, |
| -- URI = nsURI, |
| Model = asModel |
| }; |
| when { |
| mapEPackages(ePackages, asModel); |
| } |
| } |
| |
| relation mapEPackages { |
| /*enforce*/ domain ecore ePackages : Set(ecoreMM::EPackage) {}; |
| enforce domain as asModel : Model {}; |
| } |
| } |
| } |