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.commons.ihe.xds.core.ebxml.ebxml30;
17  
18  import static org.apache.commons.lang3.Validate.notNull;
19  
20  import lombok.experimental.Delegate;
21  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLAdhocQueryRequest;
22  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.AdhocQueryRequest;
23  import org.openehealth.ipf.commons.ihe.xds.core.stub.ebrs30.query.ResponseOptionType;
24  
25  /**
26   * Encapsulation of {@link AdhocQueryRequest}.
27   * @author Jens Riemschneider
28   */
29  public class EbXMLAdhocQueryRequest30 implements EbXMLAdhocQueryRequest {
30      private final AdhocQueryRequest request;
31      
32      /**
33       * Constructs the wrapper using the real object.
34       * @param request
35       *          the ebXML 3.0 object.
36       */
37      public EbXMLAdhocQueryRequest30(AdhocQueryRequest request) {
38          notNull(request, "request cannot be null");
39          this.request = request;
40      }
41      
42      @Override
43      public String getSql() {
44          return null;    // not supported in 3.0
45      }
46  
47      @Override
48      public void setSql(String sql) {
49          // not supported in 3.0
50      }
51      
52      @Override
53      public String getReturnType() {
54          ResponseOptionType responseOption = request.getResponseOption();
55          return responseOption != null ? responseOption.getReturnType() : null;
56      }
57      
58      @Override
59      public void setReturnType(String returnType) {
60          request.getResponseOption().setReturnType(returnType);
61      }
62  
63      @Override
64      public String getId() {
65          return request.getAdhocQuery().getId();
66      }
67      
68      @Override
69      public void setId(String id) {
70          request.getAdhocQuery().setId(id);
71      }
72  
73      @Override
74      public String getHome() {
75          return request.getAdhocQuery().getHome();
76      }
77  
78      @Override
79      public void setHome(String homeCommunityID) {
80          request.getAdhocQuery().setHome(homeCommunityID);
81      }
82  
83      @Override
84      public AdhocQueryRequest getInternal() {
85          return request;
86      }
87  
88      /**
89       * Implements the {@link org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLSlotList} interface
90       * by delegating the calls to a "proper" slot list.
91       */
92      @Delegate
93      private EbXMLSlotList30 getSlotList() {
94          return new EbXMLSlotList30(request.getAdhocQuery().getSlot());
95      }
96  }