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 java.util.Iterator; |
21 | |
import java.util.List; |
22 | |
|
23 | |
import org.jdom.Element; |
24 | |
|
25 | |
public class MuleModelProcessor extends TagProcessor |
26 | |
{ |
27 | |
|
28 | |
private DescriptorProcessor descriptorProcessor; |
29 | |
|
30 | |
public MuleModelProcessor(GraphEnvironment environment) |
31 | |
{ |
32 | 4 | super(environment); |
33 | 4 | descriptorProcessor = new DescriptorProcessor(environment); |
34 | |
|
35 | 4 | } |
36 | |
|
37 | |
public void process(Graph graph, Element currentElement, GraphNode parent) |
38 | |
{ |
39 | |
|
40 | 4 | List models = currentElement.getChildren(MuleTag.ELEMENT_MODEL); |
41 | 4 | for (Iterator iter = models.iterator(); iter.hasNext();) |
42 | |
{ |
43 | 4 | Element modelElement = (Element) iter.next(); |
44 | 4 | if (getEnvironment().getConfig().isShowModels()) |
45 | |
{ |
46 | 0 | String name = modelElement.getAttributeValue(MuleTag.ATTRIBUTE_NAME); |
47 | 0 | String type = modelElement.getAttributeValue(MuleTag.ATTRIBUTE_TYPE); |
48 | 0 | String className = modelElement.getAttributeValue(MuleTag.ATTRIBUTE_CLASS_NAME); |
49 | 0 | if (type != null) |
50 | |
{ |
51 | 0 | if (type.equals("custom")) |
52 | |
{ |
53 | 0 | name += " (custom: " + className + ")"; |
54 | |
} |
55 | |
else |
56 | |
{ |
57 | 0 | name += " (" + type + ")"; |
58 | |
} |
59 | |
} |
60 | 0 | GraphNode node = graph.addNode(); |
61 | 0 | node.getInfo().setHeader(name); |
62 | 0 | node.getInfo().setFillColor(ColorRegistry.COLOR_MODEL); |
63 | |
|
64 | 0 | StringBuffer caption = new StringBuffer(); |
65 | 0 | appendProperties(modelElement, caption); |
66 | 0 | appendDescription(modelElement, caption); |
67 | 0 | node.getInfo().setCaption(caption.toString()); |
68 | |
|
69 | 0 | ExceptionStrategyProcessor processor = new ExceptionStrategyProcessor(getEnvironment()); |
70 | 0 | processor.process(graph, modelElement, node); |
71 | |
|
72 | |
} |
73 | 4 | descriptorProcessor.process(graph, modelElement, parent); |
74 | 4 | } |
75 | 4 | if (models.size() == 0) |
76 | |
{ |
77 | 0 | descriptorProcessor.process(graph, currentElement, parent); |
78 | |
} |
79 | 4 | } |
80 | |
} |