Package org.apache.camel.model

Examples of org.apache.camel.model.ChoiceDefinition


            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


            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

        FromDefinition from = route.getInputs().get(0);
        assertEquals("fromFile", from.getId());
        assertTrue(from.hasCustomIdAssigned());

        ChoiceDefinition choice = (ChoiceDefinition) route.getOutputs().get(0);
        assertEquals("myChoice", choice.getId());
        assertTrue(choice.hasCustomIdAssigned());

        WhenDefinition when = choice.getWhenClauses().get(0);
        assertTrue(when.hasCustomIdAssigned());
        assertEquals("UK", when.getId());

        LogDefinition log = (LogDefinition) choice.getOtherwise().getOutputs().get(0);
        assertFalse(log.hasCustomIdAssigned());
    }
View Full Code Here

        FromDefinition from = route.getInputs().get(0);
        assertEquals("fromFile", from.getId());
        assertTrue(from.hasCustomIdAssigned());

        ChoiceDefinition choice = (ChoiceDefinition) route.getOutputs().get(0);
        assertEquals("myChoice", choice.getId());
        assertTrue(choice.hasCustomIdAssigned());

        WhenDefinition when = choice.getWhenClauses().get(0);
        assertTrue(when.hasCustomIdAssigned());
        assertEquals("UK", when.getId());

        LogDefinition log = (LogDefinition) choice.getOtherwise().getOutputs().get(0);
        assertFalse(log.hasCustomIdAssigned());
    }
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

                doFindType(children, type, found);
            }

            // special for choice
            if (out instanceof ChoiceDefinition) {
                ChoiceDefinition choice = (ChoiceDefinition) out;
                for (WhenDefinition when : choice.getWhenClauses()) {
                    List<ProcessorDefinition> children = when.getOutputs();
                    doFindType(children, type, found);
                }

                // otherwise is optional
                if (choice.getOtherwise() != null) {
                    List<ProcessorDefinition> children = choice.getOtherwise().getOutputs();
                    doFindType(children, type, found);
                }
            }

            // try children as well
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

                return type.cast(out);
            }

            // special for choice
            if (out instanceof ChoiceDefinition) {
                ChoiceDefinition choice = (ChoiceDefinition) out;
                for (WhenDefinition when : choice.getWhenClauses()) {
                    List<ProcessorDefinition> children = when.getOutputs();
                    T child = findFirstTypeInOutputs(children, type);
                    if (child != null) {
                        return child;
                    }
                }

                List<ProcessorDefinition> children = choice.getOtherwise().getOutputs();
                T child = findFirstTypeInOutputs(children, type);
                if (child != null) {
                    return child;
                }
            }
View Full Code Here

    }

    @SuppressWarnings("rawtypes")
    @Override
    public ProcessorDefinition createCamelDefinition() {
        ChoiceDefinition answer = new ChoiceDefinition();

        answer.setInheritErrorHandler(toXmlPropertyValue(PROPERTY_INHERITERRORHANDLER, Objects.<Boolean>getField(this, "inheritErrorHandler")));

        super.savePropertiesToCamelDefinition(answer);
        return answer;
    }
View Full Code Here

    @Override
    protected void loadPropertiesFromCamelDefinition(ProcessorDefinition processor) {
        super.loadPropertiesFromCamelDefinition(processor);

        if (processor instanceof ChoiceDefinition) {
            ChoiceDefinition node = (ChoiceDefinition) processor;

            this.setInheritErrorHandler(Objects.<Boolean>getField(node, "inheritErrorHandler"));
        } else {
            throw new IllegalArgumentException("ProcessorDefinition not an instanceof ChoiceDefinition. Was " + processor.getClass().getName());
        }
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.