View Javadoc
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  package org.openehealth.ipf.platform.camel.ihe.mllp.core;
17  
18  import org.apache.camel.CamelContext;
19  import org.apache.camel.component.mina2.Mina2Endpoint;
20  import org.openehealth.ipf.commons.ihe.core.atna.AuditStrategy;
21  import org.openehealth.ipf.commons.ihe.hl7v2.Hl7v2InteractionId;
22  import org.openehealth.ipf.commons.ihe.hl7v2.audit.MllpAuditDataset;
23  import org.openehealth.ipf.platform.camel.ihe.atna.AuditableComponent;
24  
25  import java.util.Map;
26  
27  /**
28   * Camel component for MLLP-based eHealth transactions (like IHE PIX, PDQ, XAD-PID, etc.).
29   *
30   * @author Dmytro Rud
31   */
32  public abstract class MllpTransactionComponent<AuditDatasetType extends MllpAuditDataset>
33          extends MllpComponent<MllpTransactionEndpointConfiguration, AuditDatasetType> implements AuditableComponent<AuditDatasetType> {
34  
35      private final Hl7v2InteractionId<AuditDatasetType> interactionId;
36  
37      protected MllpTransactionComponent(Hl7v2InteractionId<AuditDatasetType> interactionId) {
38          super();
39          this.interactionId = interactionId;
40      }
41  
42      protected MllpTransactionComponent(CamelContext camelContext, Hl7v2InteractionId<AuditDatasetType> interactionId) {
43          super(camelContext);
44          this.interactionId = interactionId;
45      }
46  
47      @Override
48      protected MllpTransactionEndpointConfiguration createConfig(String uri, Map<String, Object> parameters) throws Exception {
49          return new MllpTransactionEndpointConfiguration(this, uri, parameters);
50      }
51  
52      @Override
53      protected MllpEndpoint<?, ?, ?> createEndpoint(Mina2Endpoint wrappedEndpoint, MllpTransactionEndpointConfiguration config) {
54          return new MllpTransactionEndpoint<>(this, wrappedEndpoint, config);
55      }
56  
57      @Override
58      public AuditStrategy<AuditDatasetType> getClientAuditStrategy() {
59          return interactionId.getHl7v2TransactionConfiguration().getClientAuditStrategy();
60      }
61  
62      @Override
63      public AuditStrategy<AuditDatasetType> getServerAuditStrategy() {
64          return interactionId.getHl7v2TransactionConfiguration().getServerAuditStrategy();
65      }
66  
67      @Override
68      public Hl7v2InteractionId<AuditDatasetType> getInteractionId() {
69          return interactionId;
70      }
71  }