// we provide here only the basic mapping, all mapping that concerns fine-grained properties of each TOSCA concept have been excluded from this file for the purpose of simplicity modeltype TOSCA uses "http://www.example.org/TOSCA"; modeltype compose uses "http://www.example.org/compose"; transformation TOSCAToComposeTransformation(in Source: TOSCA, out Target: compose); main() { var a :=Source.rootObjects()[ServiceTemplate]; a.map TOSCAToCompose(); } mapping ServiceTemplate::TOSCAToCompose(): Compose { // Mapping Service Temmplate to Compose Template' version :="3.00"; //the version don't need any mapping we use Default Docker compose version ' description:=self.description; services:=self.topologytemplate.entitytemplate->map NodeMaptoService(); // all nodes whose types =applications, databases, etc, will be mapped to services in docker compose networks:=self.topologytemplate.entitytemplate->map NodeMaptoNetwork();//all tosca nodes whose type networks will be mapped into network type into docker compose volumes:=self.topologytemplate.entitytemplate->map NodeMaptoVolume(); // all tosca nodes whose type blocstorage, abstractstorage, objectstorage will be mapped into volume type into docker compose } mapping EntityTemplate::NodeMaptoService() : Service when {self.oclIsTypeOf(NodeTemplate) and self.type.name.toString()!="tosca.nodes.Compute" and self.type.name.toString()!="tosca.nodes.Network" and self.type.name.toString()!="tosca.nodes.Storage"} { name:=self.name; dependon:=self.oclAsType(NodeTemplate).requirements.nodetemplate.late resolve(Service); properties:=self.properties->map ToProperties(); image:=self.oclAsType(NodeTemplate).artifacts-> map toImage(); } mapping Artifacts::toImage():Image { name:=self.name; registry:=self->map toRegistry(); } mapping Artifacts::toRegistry() : Registry{ name:=self.repository; url:=self.file; } mapping Properties::ToProperties() :Properties{ name:=self.element; value:=self.value; } mapping EntityTemplate::NodeMaptoNetwork() : Network when {self.oclIsTypeOf(NodeTemplate) and self.type.name.toString()="tosca.nodes.Network"} { name:=self.name; } mapping EntityTemplate::NodeMaptoVolume() : Volume when {self.oclIsTypeOf(NodeTemplate) and self.type.name.toString()="tosca.nodes.Storage"} { name:=self.name; }