Package org.apache.camel.model

Examples of org.apache.camel.model.ChoiceDefinition


   * ChoiceDefinition does not return the children; but it returns the outputs
   * on the When?
   */
  protected List<ProcessorDefinition> getOutputs(ProcessorDefinition processor) { //
    if (processor instanceof ChoiceDefinition) {
      ChoiceDefinition choice = (ChoiceDefinition) processor;
      List<ProcessorDefinition> list = new ArrayList<ProcessorDefinition>();
      List<WhenDefinition> whenClauses = choice.getWhenClauses();
      if (whenClauses != null) {
        list.addAll(whenClauses);
      }
      OtherwiseDefinition otherwise = choice.getOtherwise();
      if (otherwise != null) {
        list.add(otherwise);
      }
      return list;
    } else {
View Full Code Here


   * does not work with When/Otherwise
   */
  protected void addCamelOutput(ProcessorDefinition processor, ProcessorDefinition toNode) {
    // special for choice
    if (processor instanceof ChoiceDefinition) {
      ChoiceDefinition choice = (ChoiceDefinition) processor;
      if (toNode instanceof WhenDefinition) {
        choice.getWhenClauses().add((WhenDefinition) toNode);
      } else if (toNode instanceof OtherwiseDefinition) {
        choice.setOtherwise((OtherwiseDefinition) toNode);
      } else {
        // there may be a nested choice so we need to add it on its parent
        ProcessorDefinition grandParent = choice.getParent();
        if (grandParent != null) {
          grandParent.addOutput(toNode);
        } else {
          Activator.getLogger().warning("No parent of " + choice + " so cannot add output " + toNode);
        }
View Full Code Here

    RouteDefinition routeDef = route.createRouteDefinition();
    System.out.println("Created: " + routeDef);

    assertSingleInput(routeDef, FromDefinition.class);
    assertSize(routeDef.getOutputs(), 2);
    ChoiceDefinition c1 = assertOutput(routeDef, 0, ChoiceDefinition.class);
    ToDefinition ed4 = assertOutput(routeDef, 1, ToDefinition.class);
    assertEquals("choice -> to", "seda:d", ed4.getUri());

    List<WhenDefinition> whenClauses = c1.getWhenClauses();
    assertSize(whenClauses, 1);
    WhenDefinition wd1 = whenClauses.get(0);
    ToDefinition ed2 = assertSingleOutput(wd1, ToDefinition.class);
    assertEquals("when -> to", "seda:b", ed2.getUri());
   
    OtherwiseDefinition od1 = c1.getOtherwise();
    assertNotNull("Should have Otherwise", od1);
    ToDefinition ed3 = assertSingleOutput(od1, ToDefinition.class);
    assertEquals("otherwise -> to", "seda:c", ed3.getUri());

    RouteContainer routeContainer = new RouteContainer();
View Full Code Here

        List<Exchange> camelExchanges = getMockEndpoint("mock:camel").getReceivedExchanges();

        RouteDefinition route = context.getRouteDefinitions().get(0);
        assertNotNull(route);

        ChoiceDefinition choice = (ChoiceDefinition) route.getOutputs().get(0);
        assertEquals("choice1", choice.getId());

        WhenDefinition when = (WhenDefinition) choice.getOutputs().get(0);
        assertEquals("when1", when.getId());

        LogDefinition log1 = (LogDefinition) when.getOutputs().get(0);
        assertEquals("log1", log1.getId());

        ToDefinition to1 = (ToDefinition) when.getOutputs().get(1);
        assertEquals("camel", to1.getId());

        OtherwiseDefinition other = (OtherwiseDefinition) choice.getOutputs().get(1);
        assertEquals("otherwise1", other.getId());

        LogDefinition log2 = (LogDefinition) other.getOutputs().get(0);
        assertEquals("log2", log2.getId());
View Full Code Here

            this.image = imagePrefix + "ContentBasedRouterIcon.png";
            this.nodeType = "Content Based Router";
            this.label = "Choice";
            this.edgeLabel = "";

            ChoiceDefinition choice = (ChoiceDefinition)node;
            List<ProcessorDefinition<?>> outputs = new ArrayList<ProcessorDefinition<?>>(choice.getWhenClauses());
            if (choice.getOtherwise() != null) {
                outputs.add(choice.getOtherwise());
            }
            this.outputs = outputs;
        } else if (node instanceof RecipientListDefinition) {
            this.image = imagePrefix + "RecipientListIcon.png";
            this.nodeType = "Recipient List";
View Full Code Here

        List<Exchange> camelExchanges = getMockEndpoint("mock:camel").getReceivedExchanges();

        RouteDefinition route = context.getRouteDefinitions().get(0);
        assertNotNull(route);

        ChoiceDefinition choice = (ChoiceDefinition) route.getOutputs().get(0);
        assertEquals("choice1", choice.getId());

        WhenDefinition when = (WhenDefinition) choice.getOutputs().get(0);
        assertEquals("when1", when.getId());

        LogDefinition log1 = (LogDefinition) when.getOutputs().get(0);
        assertEquals("log1", log1.getId());

        ToDefinition to1 = (ToDefinition) when.getOutputs().get(1);
        assertEquals("camel", to1.getId());

        OtherwiseDefinition other = (OtherwiseDefinition) choice.getOutputs().get(1);
        assertEquals("otherwise1", other.getId());

        LogDefinition log2 = (LogDefinition) other.getOutputs().get(0);
        assertEquals("log2", log2.getId());
View Full Code Here

            this.image = imagePrefix + "ContentBasedRouterIcon.png";
            this.nodeType = "Content Based Router";
            this.label = "Choice";
            this.edgeLabel = "";

            ChoiceDefinition choice = (ChoiceDefinition)node;
            List<ProcessorDefinition> outputs = new ArrayList<ProcessorDefinition>(choice.getWhenClauses());
            if (choice.getOtherwise() != null) {
                outputs.add(choice.getOtherwise());
            }
            this.outputs = outputs;
        } else if (node instanceof RecipientListDefinition) {
            this.image = imagePrefix + "RecipientListIcon.png";
            this.nodeType = "Recipient List";
View Full Code Here

TOP

Related Classes of org.apache.camel.model.ChoiceDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.