View Javadoc
1   /*
2    * Copyright 2012 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.commons.ihe.xds.core.audit;
17  
18  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.EbXMLAdhocQueryRequest30;
19  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryRequest;
20  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.rim.AdhocQueryType;
21  import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.QueryParameter;
22  import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query.QuerySlotHelper;
23  
24  import java.util.List;
25  import java.util.Map;
26  
27  /**
28   * Basis for Strategy pattern implementation for ATNA Auditing
29   * in ebXML 3.0-based query-related XDS transactions.
30   *
31   * @author Dmytro Rud
32   */
33  public abstract class XdsQueryAuditStrategy30 extends XdsAuditStrategy<XdsQueryAuditDataset> {
34  
35  
36  
37      /**
38       * Constructs an XDS query audit strategy.
39       *
40       * @param serverSide whether this is a server-side or a client-side strategy.
41       */
42      public XdsQueryAuditStrategy30(boolean serverSide) {
43          super(serverSide);
44      }
45  
46  
47      @Override
48      public XdsQueryAuditDataset enrichAuditDatasetFromRequest(XdsQueryAuditDataset auditDataset, Object pojo, Map<String, Object> parameters) {
49          AdhocQueryRequest request = (AdhocQueryRequest) pojo;
50          AdhocQueryType adHocQuery = request.getAdhocQuery();
51          if (adHocQuery != null) {
52              auditDataset.setQueryUuid(adHocQuery.getId());
53              auditDataset.setHomeCommunityId(adHocQuery.getHome());
54          }
55  
56          QuerySlotHelper slotHelper = new QuerySlotHelper(new EbXMLAdhocQueryRequest30(request));
57          List<String> patientIdList = slotHelper.toStringList(QueryParameter.DOC_ENTRY_PATIENT_ID);
58          if (patientIdList != null) {
59              auditDataset.getPatientIds().addAll(patientIdList);
60          }
61          return auditDataset;
62      }
63  
64      @Override
65      public XdsQueryAuditDataset createAuditDataset() {
66          return new XdsQueryAuditDataset(isServerSide());
67      }
68  
69  
70  }