You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by js...@apache.org on 2007/09/21 11:21:31 UTC

svn commit: r578030 - /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/XmlGraphGenerator.java

Author: jstrachan
Date: Fri Sep 21 02:21:31 2007
New Revision: 578030

URL: http://svn.apache.org/viewvc?rev=578030&view=rev
Log:
tidied up the XML graph generation so that a parent node is written which links to each route group

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/XmlGraphGenerator.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/XmlGraphGenerator.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/XmlGraphGenerator.java?rev=578030&r1=578029&r2=578030&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/XmlGraphGenerator.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/view/XmlGraphGenerator.java Fri Sep 21 02:21:31 2007
@@ -43,6 +43,9 @@
         writer.println("<Graph>");
         writer.println();
 
+        if (map.size() > 0) {
+            writer.println("<Node id='root' name='Camel Routes' description='Collection of Camel Routes' nodeType='root'/>");
+        }
         printRoutes(writer, map);
 
         writer.println();
@@ -58,21 +61,34 @@
     }
 
     protected void printRoutes(PrintWriter writer, String group, List<RouteType> routes) {
+        group = encode(group);
         if (group != null) {
-            // TODO
+            int idx = group.lastIndexOf('.');
+            String name =group;
+            if (idx > 0 && idx < group.length() -1 ) {
+                name = group.substring(idx + 1);
+            }
+            writer.println("<Node id='" + group + "' name='" + name + "' description='" + group + "' nodeType='group'/>");
+            writer.println("<Edge fromID='root' toID='" + group + "'/>");
         }
         for (RouteType route : routes) {
             List<FromType> inputs = route.getInputs();
+            boolean first = true;
             for (FromType input : inputs) {
-                printRoute(writer, route, input);
+                NodeData nodeData = getNodeData(input);
+                if (first) {
+                    first = false;
+                    if (group != null) {
+                        writer.println("<Edge fromID='" + group + "' toID='" + encode(nodeData.id) + "'/>");
+                    }
+                }
+                printRoute(writer, route, nodeData);
             }
             writer.println();
         }
     }
 
-    protected void printRoute(PrintWriter writer, final RouteType route, FromType input) {
-        NodeData nodeData = getNodeData(input);
-
+    protected void printRoute(PrintWriter writer, final RouteType route, NodeData nodeData) {
         printNode(writer, nodeData);
 
         // TODO we should add a transactional client / event driven consumer / polling client
@@ -142,7 +158,7 @@
             if (isNullOrBlank(nodeType)) {
                 nodeType = data.shape;
                 if (isNullOrBlank(nodeType)) {
-                    nodeType = "PrimitiveReverseBurst";
+                    nodeType = "node";
                 }
             }
             writer.print(encode(nodeType));