1 /* 2 * Copyright 2014 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.openehealth.ipf.platform.camel.hl7; 18 19 import org.apache.camel.spring.SpringRouteBuilder; 20 21 import static org.openehealth.ipf.platform.camel.hl7.HL7v2.*; 22 23 /** 24 * This route is the Java version of {@link org.openehealth.ipf.platform.camel.hl7.extend.SampleRouteBuilder} 25 * using expressions and predicates defined by {@link org.openehealth.ipf.platform.camel.hl7.HL7v2}. 26 */ 27 public class SampleRouteBuilder2 extends SpringRouteBuilder { 28 29 @Override 30 public void configure() throws Exception { 31 32 from("direct:input1") 33 // create a message adapter from an HL7 string 34 .unmarshal().hl7() 35 .transform(set("MSH-5", header("foo"))) 36 .choice() 37 .when(get("MSH-5").isEqualTo("blah")) 38 .convertBodyTo(String.class) // adapter -> string 39 .to("mock:output1") 40 .when(get("MSH-5").isEqualTo("blub")) 41 .convertBodyTo(String.class) // adapter -> string 42 .to("mock:output2"); 43 } 44 45 }