Coverage Report - org.mule.tools.visualizer.processor.InboundFilterProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
InboundFilterProcessor
35%
11/31
38%
3/8
2
 
 1  
 /*
 2  
  * $Id: InboundFilterProcessor.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 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  8
         super(environment);
 30  8
         this.endpointNode = endpointNode;
 31  8
     }
 32  
 
 33  
     public void process(Graph graph, Element currentElement, GraphNode parent)
 34  
     {
 35  0
         processInboundFilter(graph, currentElement, endpointNode, parent);
 36  0
     }
 37  
 
 38  
     public void processInboundFilter(Graph graph, Element endpoint, GraphNode endpointNode, GraphNode parent)
 39  
     {
 40  8
         Element filter = endpoint.getChild(MuleTag.ELEMENT_FILTER);
 41  8
         boolean conditional = false;
 42  
 
 43  8
         if (filter == null)
 44  
         {
 45  8
             filter = endpoint.getChild(MuleTag.ELEMENT_LEFT_FILTER);
 46  8
             conditional = filter != null;
 47  
         }
 48  
 
 49  8
         if (filter != null)
 50  
         {
 51  
 
 52  0
             GraphNode filterNode = graph.addNode();
 53  0
             filterNode.getInfo().setHeader(filter.getAttributeValue(MuleTag.ATTRIBUTE_CLASS_NAME));
 54  0
             filterNode.getInfo().setFillColor(ColorRegistry.COLOR_FILTER);
 55  0
             StringBuffer caption = new StringBuffer();
 56  0
             appendProperties(filter, caption);
 57  0
             filterNode.getInfo().setCaption(caption.toString());
 58  
             // this is a hack to pick up and/or filter conditions
 59  
             // really we need a nice recursive way of doing this
 60  0
             if (conditional)
 61  
             {
 62  0
                 filter = endpoint.getChild(MuleTag.ELEMENT_RIGHT_FILTER);
 63  0
                 GraphNode filterNode2 = graph.addNode();
 64  0
                 filterNode2.getInfo().setHeader(filter.getAttributeValue(MuleTag.ATTRIBUTE_CLASS_NAME));
 65  0
                 filterNode2.getInfo().setFillColor(ColorRegistry.COLOR_FILTER);
 66  0
                 StringBuffer caption2 = new StringBuffer();
 67  0
                 appendProperties(filter, caption2);
 68  0
                 filterNode2.getInfo().setCaption(caption2.toString());
 69  0
                 addEdge(graph, endpointNode, filterNode2, "filters on", isTwoWay(endpoint));
 70  
             }
 71  0
             processInboundFilter(graph, filter, filterNode, parent);
 72  
 
 73  0
             addEdge(graph, endpointNode, filterNode, "filters on", isTwoWay(endpoint));
 74  0
         }
 75  
         else
 76  
         {
 77  8
             addEdge(graph, endpointNode, parent, "in", isTwoWay(endpoint));
 78  
         }
 79  8
     }
 80  
 
 81  
 }