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.transform.requests.query;
17  
18  import static org.openehealth.ipf.commons.ihe.xds.core.transform.requests.QueryParameter.*;
19  
20  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLAdhocQueryRequest;
21  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetDocumentsQuery;
22  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetRelatedDocumentsQuery;
23  
24  /**
25   * Transforms between a {@link GetDocumentsQuery} and {@link EbXMLAdhocQueryRequest}.
26   * @author Jens Riemschneider
27   */
28  public class GetRelatedDocumentsQueryTransformer extends GetFromDocumentQueryTransformer<GetRelatedDocumentsQuery> {
29      @Override
30      public void toEbXML(GetRelatedDocumentsQuery query, EbXMLAdhocQueryRequest ebXML) {
31          if (query == null || ebXML == null) {
32              return;
33          }
34          
35          super.toEbXML(query, ebXML);
36          
37          QuerySlotHelper slots = new QuerySlotHelper(ebXML);
38          slots.fromAssociationType(ASSOCIATION_TYPE, query.getAssociationTypes());
39          slots.fromDocumentEntryType(DOC_ENTRY_TYPE, query.getDocumentEntryTypes());
40          slots.fromStatus(ASSOCIATION_STATUS, query.getAssociationStatuses());
41          slots.fromInteger(METADATA_LEVEL, query.getMetadataLevel());
42      }
43      
44      @Override
45      public void fromEbXML(GetRelatedDocumentsQuery query, EbXMLAdhocQueryRequest ebXML) {
46          if (query == null || ebXML == null) {
47              return;
48          }
49          
50          super.fromEbXML(query, ebXML);
51          
52          QuerySlotHelper slots = new QuerySlotHelper(ebXML);        
53          query.setAssociationTypes(slots.toAssociationType(ASSOCIATION_TYPE));
54          query.setDocumentEntryTypes(slots.toDocumentEntryType(DOC_ENTRY_TYPE));
55          query.setAssociationStatuses(slots.toStatus(ASSOCIATION_STATUS));
56          query.setMetadataLevel(slots.toInteger(METADATA_LEVEL));
57      }
58  }