1
2
3
4
5
6
7
8
9
10
11 package org.mule.tools.visualizer.processor;
12
13 import org.mule.tools.visualizer.config.ColorRegistry;
14 import org.mule.tools.visualizer.config.GraphEnvironment;
15 import org.mule.tools.visualizer.util.MuleTag;
16
17 import com.oy.shared.lm.graph.Graph;
18 import com.oy.shared.lm.graph.GraphNode;
19
20 import org.jdom.Element;
21
22 public class InboundFilterProcessor extends TagProcessor
23 {
24
25 private GraphNode endpointNode;
26
27 public InboundFilterProcessor(GraphEnvironment environment, GraphNode endpointNode)
28 {
29 super(environment);
30 this.endpointNode = endpointNode;
31 }
32
33 public void process(Graph graph, Element currentElement, GraphNode parent)
34 {
35 processInboundFilter(graph, currentElement, endpointNode, parent);
36 }
37
38 public void processInboundFilter(Graph graph, Element endpoint, GraphNode endpointNode, GraphNode parent)
39 {
40 Element filter = endpoint.getChild(MuleTag.ELEMENT_FILTER);
41 boolean conditional = false;
42
43 if (filter == null)
44 {
45 filter = endpoint.getChild(MuleTag.ELEMENT_LEFT_FILTER);
46 conditional = filter != null;
47 }
48
49 if (filter != null)
50 {
51
52 GraphNode filterNode = graph.addNode();
53 filterNode.getInfo().setHeader(filter.getAttributeValue(MuleTag.ATTRIBUTE_CLASS_NAME));
54 filterNode.getInfo().setFillColor(ColorRegistry.COLOR_FILTER);
55 StringBuffer caption = new StringBuffer();
56 appendProperties(filter, caption);
57 filterNode.getInfo().setCaption(caption.toString());
58
59
60 if (conditional)
61 {
62 filter = endpoint.getChild(MuleTag.ELEMENT_RIGHT_FILTER);
63 GraphNode filterNode2 = graph.addNode();
64 filterNode2.getInfo().setHeader(filter.getAttributeValue(MuleTag.ATTRIBUTE_CLASS_NAME));
65 filterNode2.getInfo().setFillColor(ColorRegistry.COLOR_FILTER);
66 StringBuffer caption2 = new StringBuffer();
67 appendProperties(filter, caption2);
68 filterNode2.getInfo().setCaption(caption2.toString());
69 addEdge(graph, endpointNode, filterNode2, "filters on", isTwoWay(endpoint));
70 }
71 processInboundFilter(graph, filter, filterNode, parent);
72
73 addEdge(graph, endpointNode, filterNode, "filters on", isTwoWay(endpoint));
74 }
75 else
76 {
77 addEdge(graph, endpointNode, parent, "in", isTwoWay(endpoint));
78 }
79 }
80
81 }