| import SimpleGraph : '../Graph2GraphMinimal/SimpleGraph.ecore'::simplegraph; |
| import SimpleGraph2Graph : '../Graph2GraphMinimal/SimpleGraph2Graph.ecore'::simplegraph2graph; |
| |
| transformation CopyGraph { |
| check upperGraph imports SimpleGraph; |
| enforce lowerGraph imports SimpleGraph; |
| middle imports SimpleGraph2Graph; |
| } |
| |
| map __root__ in CopyGraph { |
| |
| for g1 : SimpleGraph::Graph in SimpleGraph::Graph.allInstances() { |
| call Graph2Middle { |
| g1 iterates g1; |
| } |
| } |
| } |
| |
| map Graph2Middle in CopyGraph { -- L to M for G |
| guard:upperGraph g1:Graph; |
| new:middle middleG2G:Graph2Graph; |
| set middleG2G.graph1 := g1; |
| set middleG2G.name := g1.name.toLowerCase(); |
| for child in g1.element->select(e | e.oclIsTypeOf(simplegraph::Node)) { |
| call Node2Middle { |
| n1 iterates child; |
| middleParent uses middleG2G; |
| } |
| } |
| call Middle2Graph { |
| g2Gmiddle uses middleG2G; |
| } |
| } |
| |
| map Node2Middle in CopyGraph { -- L to M for N |
| guard:upperGraph n1:Node; |
| in:middle middleParent:Graph2Graph; |
| new:middle n2n:Node2Node; |
| set n2n.owner := middleParent; |
| set n2n.node1 := n1; |
| set n2n.label := n1.label.toLowerCase(); |
| } |
| |
| map Middle2Graph in CopyGraph { -- M to R for G |
| in:middle g2Gmiddle:Graph2Graph; |
| new:lowerGraph g2:Graph; |
| set g2Gmiddle.graph2 := g2; |
| set g2.name := g2Gmiddle.name; |
| for child in g2Gmiddle.element2Element->select(e2e | e2e.oclIsTypeOf(simplegraph2graph::Node2Node)) { |
| call Middle2Node { |
| n2n iterates child; |
| } |
| } |
| } |
| |
| map Middle2Node in CopyGraph { -- M to R for N |
| guard:middle n2n:Node2Node; |
| new:lowerGraph n2:Node; |
| set n2n.node2 := n2; |
| set n2.graph := n2n.owner.graph2; |
| set n2.label := n2n.label; |
| } |