Storyboard TTC2011SimpleMigration
Source model:
Target model:
Migration extension:
Create example source graph:
did not find method simpleMigrationPerPattern(Graph,StoryPage) in class org.sdmlib.test.examples.helloworld.HelloWorldTTC2011
Result graph:
Number of migrated nodes: 8 Number of migrated Edges: 10
private Graph simpleMigrationInJava(Graph origGraph) { int noOfMatches = 0; Graph copyGraph = new Graph(); if (origGraph != null) { // migrate nodes for (Node origNode : origGraph.getNodes()) { Node copyNode = (Node) copyGraph.createGcsNode() .withText(origNode.getName()); copyNode.withOrig(origNode); noOfMatches++; } systemout = "Number of migrated nodes: " + noOfMatches; // migrate edges for (Edge origEdge : origGraph.getEdges()) { Edge copyEdge = (Edge) copyGraph.createGcsEdge() .withText(origEdge.getName()); Node origSrcNode = origEdge.getSrc(); if (origSrcNode != null) { copyEdge.setSrc(origSrcNode.getCopy()); } Node origTgtNode = origEdge.getTgt(); if (origTgtNode != null) { copyEdge.setTgt(origTgtNode.getCopy()); } } } return copyGraph; }
Result graph:
Number of migrated nodes: 8
private Graph simpleMigrationByCloning(Graph graph) { JsonArray jsonArray = GraphCreator.createIdMap("hg").toJsonArray(graph); Graph copyGraph = (Graph) GraphCreator.createIdMap("hg").decode(jsonArray); GraphComponentSet gcs = new GraphComponentSet(); gcs.addAll(copyGraph.getNodes()); gcs.addAll(copyGraph.getEdges()); for (GraphComponent comp : gcs) { comp.setParent(copyGraph); comp.setGraph(null); comp.setText(comp.getName()); comp.setName(null); } return copyGraph; }
Result graph:
private Graph simpleMigrationByJsonArray(Graph graph) { IdMap idMap = GraphCreator.createIdMap("hg"); JsonArray jsonArray = idMap.toJsonArray(graph); for (int i = 0; i < jsonArray.size(); i++) { JsonObject jsonObject = jsonArray.getJSONObject(i); String className = jsonObject.getString(IdMap.CLASS); if (Graph.class.getName().equals(className)) { JsonObject jsonProps = jsonObject.getJsonObject(JsonTokener.PROPS); // migrate nodes and edges to gcs JsonArray gcsArray = jsonProps.getJsonArray(Graph.PROPERTY_NODES); gcsArray.addAll(Arrays.asList(jsonProps.getJsonArray(Graph.PROPERTY_EDGES).toArray())); jsonProps.put(Graph.PROPERTY_GCS, gcsArray); jsonProps.remove(Graph.PROPERTY_NODES); jsonProps.remove(Graph.PROPERTY_EDGES); } else if (Node.class.getName().equals(className)) { JsonObject jsonProps = jsonObject.getJsonObject(JsonTokener.PROPS); // migrate name to text jsonProps.put(Node.PROPERTY_TEXT, jsonProps.get(Node.PROPERTY_NAME)); jsonProps.remove(Node.PROPERTY_NAME); // migrate graph to parent jsonProps.put(Node.PROPERTY_PARENT, jsonProps.get(Node.PROPERTY_GRAPH)); jsonProps.remove(Node.PROPERTY_GRAPH); } else if (Edge.class.getName().equals(className)) { JsonObject jsonProps = jsonObject.getJsonObject(JsonTokener.PROPS); // migrate name to text jsonProps.put(Node.PROPERTY_TEXT, jsonProps.get(Node.PROPERTY_NAME)); jsonProps.remove(Node.PROPERTY_NAME); // migrate graph to parent jsonProps.put(Node.PROPERTY_PARENT, jsonProps.get(Node.PROPERTY_GRAPH)); jsonProps.remove(Node.PROPERTY_GRAPH); } } Graph copyGraph = (Graph) GraphCreator.createIdMap("hg").decode(jsonArray); return copyGraph; }
Result graph:
did not find method simpleMigrationByGenericGraph(Graph,StoryPage) in class org.sdmlib.test.examples.helloworld.HelloWorldTTC2011
Result graph:
did not find method simpleMigrationToEvenMoreEvolvedGraphByGenericGraph(Graph,StoryPage) in class org.sdmlib.test.examples.helloworld.HelloWorldTTC2011
Result graph: