This article is the counterpart of the article “From Microsoft Visio to MetaEdit+ via Eclipse EMF” and should show the export of MetaEdit+ models into Microsoft Visio. Our solution components are the same as in the first article. We use the MetaEdit-EMF-Bridge and the Visio-EMF-Bridge in order to transform the two language definitions into Ecore models (metaedit_epc.ecore and visio_epc.ecore). Based on these Ecore models, we can define a migration that transforms metaedit_epc.ecore into visio_epc.ecore. Afterwards, we can import with the MetaEdit-EMF-Bridge a MetaEdit model (metaedit_epc_model.xmi). This MetaEdit-EMF model is the input of the migration that creates a Visio-EMF model (visio_epc_model.xmi). Finally, we can import this Visio-EMF model with the Visio-EMF-Bridge into Visio (see screencast: From MetaEdit+ to Visio).
Language Migration
We use ETL/EOL from Epsilon as transformation language. The script can also be divided into two parts. The first part contains language-independent rules that transform a MetaEdit project into a Visio document and a MetaEdit graph into a Visio page. The operation sets the position of a Visio shape and the post processing step transforms the different coordinate systems.
rule Project2Document transform project : MetaEdit!Me_Project to document : Visio!EVisioDocument { document.visioPages := project.me_containGraphs.equivalent(); } @abstract rule Graph2Page transform graph : MetaEdit!Me_Graph to page : Visio!EVisioPage { page.visioContainedShapes := graph.me_referenceObjects.equivalent(); page.visioContainedShapes.addAll(graph.me_referenceRelationships.equivalent()); } @abstract rule Shape transform object : MetaEdit!Me_Object to shape : Visio!EVisioShape { var position := MetaEdit!Me_Symbol.allInstances() .select(e | e.me_refObject = object).first().me_position; shape.setPosition(position); } operation Visio!EVisioShape setPosition(position : String) : Integer { var x := position.split(",").first(); var y := position.split(",").last(); var shapeSheet := new Visio!EVisioShapeSheet; var section := new Visio!EVisioSection; section.visioName := 'visSectionObject'; var row := new Visio!EVisioRow; row.visioName := '1'; var xCell := new Visio!EVisioCell; xCell.visioName := 'PinX'; xCell.visioValue := x; var yCell := new Visio!EVisioCell; yCell.visioName := 'PinY'; yCell.visioValue := y; self.visioShapeSheet := shapeSheet; shapeSheet.visioSections.add(section); section.visioRows.add(row); row.visioCells.add(xCell); row.visioCells.add(yCell); } post CoordinateTransformation { for (pinY : Visio!EVisioCell in Visio!EVisioCell.allInstances.select(e | e.visioName = 'PinY')) { var y : Real := pinY.visioValue.asReal(); y := (1150-y)/100; pinY.visioValue := y+''; } for (pinX : Visio!EVisioCell in Visio!EVisioCell.allInstances.select(e | e.visioName = 'PinX')) { var x : Real := pinX.visioValue.asReal(); x := x/100; pinX.visioValue := x+''; } }
The second part of the script is the language-dependent part that maps the different language types. For instance, we map MetaEditEvent to VisioEvent, MetaEditFunction to VisioFunction and so on.
--------------------- -- EPC-Transformation --------------------- rule MetaEditEpc2VisioEpc transform graph : MetaEdit!Event_Driven_Process_Chain_3395083925 to page : Visio!EVisioPage extends Graph2Page { page.visioName := graph.Name; } rule EditEvent2VisioEvent transform object : MetaEdit!Event_3395083771 to shape : Visio!Ereignis extends Shape { shape.visioText := object.Name; } rule EditFunction2VisioFunction transform object : MetaEdit!Function_3395083784 to shape : Visio!Funktion extends Shape { shape.visioText := object.Name; } rule EditXOR2VisioXOR transform object : MetaEdit!XOR_3395083733 to shape : Visio!XOR extends Shape { } rule EditOR2VisioOR transform object : MetaEdit!OR_3395083742 to shape : Visio!OR extends Shape { } rule EditAND2VisioAND transform object : MetaEdit!AND_3395083748 to shape : Visio!AND extends Shape { } rule MetaEditArc2VisioConnection transform relation : MetaEdit!Arc_3395083800 to shape : Visio!Dynamischer_Verbinder { for(role : MetaEdit!Me_Role in relation.me_role) { if(role.isTypeOf(MetaEdit!To_3395083810)) shape.visioTargetShape := role.me_object.equivalent(); if(role.isTypeOf(MetaEdit!From_3395083804)) shape.visioSourceShape := role.me_object.equivalent(); } }
Download
- Screencast: From MetaEdit+ to Visio
- MetaEdit-EMF-Bridge (new version 1.1.0)
- Visio-EMF-Bridge
- MetaEdit-Visio-EPC-Transformation
- Eclipse Modeling Tools and Epsilon (version 0.8.8)

