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.RetrieveDocumentSetRequestType;
19  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.RetrieveImagingDocumentSetRequestType;
20  import org.openehealth.ipf.commons.ihe.xds.core.audit.XdsNonconstructiveDocumentSetRequestAuditDataset.Document;
21  
22  import java.util.List;
23  import java.util.Map;
24  
25  /**
26   * Basis for Strategy pattern implementation for ATNA Auditing
27   * in ebXML 3.0-based retrieval-related XDS-I transactions.
28   *
29   * @author Clay Sebourn
30   */
31  abstract public class XdsIRetrieveAuditStrategy30 extends XdsRetrieveAuditStrategy30 {
32  
33      public XdsIRetrieveAuditStrategy30(boolean serverSide) {
34          super(serverSide);
35      }
36  
37      @Override
38      public XdsNonconstructiveDocumentSetRequestAuditDataset enrichAuditDatasetFromRequest(XdsNonconstructiveDocumentSetRequestAuditDataset auditDataset, Object pojo, Map<String, Object> parameters) {
39          RetrieveImagingDocumentSetRequestType request = (RetrieveImagingDocumentSetRequestType) pojo;
40          List<RetrieveImagingDocumentSetRequestType.StudyRequest> requestedStudies = request.getStudyRequest();
41          if (requestedStudies != null) {
42              for (RetrieveImagingDocumentSetRequestType.StudyRequest studyRequest : requestedStudies) {
43                  List<RetrieveImagingDocumentSetRequestType.SeriesRequest> requestedSeries = studyRequest.getSeriesRequest();
44                  if (requestedSeries != null) {
45                      for (RetrieveImagingDocumentSetRequestType.SeriesRequest seriesRequest : requestedSeries) {
46                          List<RetrieveDocumentSetRequestType.DocumentRequest> requestedDocuments = seriesRequest.getDocumentRequests();
47                          if (requestedDocuments != null) {
48                              for (RetrieveDocumentSetRequestType.DocumentRequest document : requestedDocuments) {
49                                  auditDataset.getDocuments().add(new Document(
50                                          document.getDocumentUniqueId(),
51                                          document.getRepositoryUniqueId(),
52                                          document.getHomeCommunityId(),
53                                          studyRequest.getStudyInstanceUID(),
54                                          seriesRequest.getSeriesInstanceUID(),
55                                          getDefaultDocumentStatus()));
56                              }
57                          }
58                      }
59                  }
60              }
61          }
62          return auditDataset;
63      }
64  
65  }