View Javadoc
1   /*
2    * Copyright 2013 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.transform.requests.query;
17  
18  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLAdhocQueryRequest;
19  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindDocumentsByReferenceIdQuery;
20  
21  import static org.openehealth.ipf.commons.ihe.xds.core.transform.requests.QueryParameter.DOC_ENTRY_REFERENCE_IDS;
22  
23  /**
24   * Transforms between a {@link FindDocumentsByReferenceIdQuery} and {@link EbXMLAdhocQueryRequest}.
25   * @author Dmytro Rud
26   */
27  public class FindDocumentsByReferenceIdQueryTransformer extends FindDocumentsQueryTransformer<FindDocumentsByReferenceIdQuery> {
28  
29      @Override
30      public void toEbXML(FindDocumentsByReferenceIdQuery query, EbXMLAdhocQueryRequest ebXML) {
31          if (query == null || ebXML == null) {
32              return;
33          }
34  
35          super.toEbXML(query, ebXML);
36          QuerySlotHelper slots = new QuerySlotHelper(ebXML);
37          slots.fromStringList(DOC_ENTRY_REFERENCE_IDS, query.getReferenceIds());
38      }
39  
40  
41      public void fromEbXML(FindDocumentsByReferenceIdQuery query, EbXMLAdhocQueryRequest ebXML) {
42          if (query == null || ebXML == null) {
43              return;
44          }
45  
46          super.fromEbXML(query, ebXML);
47          QuerySlotHelper slots = new QuerySlotHelper(ebXML);
48          query.setReferenceIds(slots.toStringQueryList(DOC_ENTRY_REFERENCE_IDS));
49      }
50  }