View Javadoc
1   /*
2    * Copyright 2009 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  package org.openehealth.ipf.platform.camel.ihe.hl7v3.iti44;
17  
18  import org.openehealth.ipf.commons.ihe.hl7v3.audit.Hl7v3AuditDataset;
19  import org.openehealth.ipf.commons.ihe.hl7v3.Hl7v3WsTransactionConfiguration;
20  import org.openehealth.ipf.commons.ihe.hl7v3.iti44.GenericIti44PortType;
21  import org.openehealth.ipf.commons.ihe.ws.JaxWsClientFactory;
22  import org.openehealth.ipf.platform.camel.ihe.ws.AbstractWsEndpoint;
23  import org.openehealth.ipf.platform.camel.ihe.ws.AbstractWsProducer;
24  
25  import static org.openehealth.ipf.commons.xml.XmlUtils.rootElementName;
26  
27  /**
28   * Producer implementation for the ITI-44 component (PIX Feed v3).
29   */
30  public class Iti44Producer extends AbstractWsProducer<Hl7v3AuditDataset, Hl7v3WsTransactionConfiguration, String, String> {
31      /**
32       * Constructs the producer.
33       * @param endpoint
34       *          the endpoint creating this producer.
35       * @param clientFactory
36       *          the factory for clients to produce messages for the service.              
37       */
38      public Iti44Producer(AbstractWsEndpoint<Hl7v3AuditDataset, Hl7v3WsTransactionConfiguration> endpoint, JaxWsClientFactory<Hl7v3AuditDataset> clientFactory) {
39          super(endpoint, clientFactory, String.class, String.class);
40      }
41  
42      @Override
43      protected String callService(Object clientObject, String request) {
44          GenericIti44PortType client = (GenericIti44PortType) clientObject;
45          String rootElementName = rootElementName(request);
46          if ("PRPA_IN201301UV02".equals(rootElementName)) {
47              return client.recordAdded(request);
48          }
49          else if ("PRPA_IN201302UV02".equals(rootElementName)) {
50              return client.recordRevised(request);
51          }
52          else if ("PRPA_IN201304UV02".equals(rootElementName)) {
53              return client.duplicatesResolved(request);
54          }
55          throw new RuntimeException("Cannot dispatch message with root element " + rootElementName);
56      }
57  }