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  
19  import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLAdhocQueryRequest;
20  import org.openehealth.ipf.commons.ihe.xds.core.requests.query.GetFoldersForDocumentQuery;
21  
22  import static org.openehealth.ipf.commons.ihe.xds.core.transform.requests.QueryParameter.*;
23  
24  /**
25   * Transforms between a {@link GetFoldersForDocumentQuery} and {@link EbXMLAdhocQueryRequest}.
26   * @author Jens Riemschneider
27   */
28  public class GetFoldersForDocumentQueryTransformer extends GetFromDocumentQueryTransformer<GetFoldersForDocumentQuery> {
29  
30      /**
31       *
32       * @param query
33       *          the query. Can be <code>null</code>.
34       * @param ebXML ebXML object
35       */
36      public void toEbXML(GetFoldersForDocumentQuery query, EbXMLAdhocQueryRequest ebXML) {
37          if (query == null || ebXML == null) {
38              return;
39          }
40  
41          super.toEbXML(query, ebXML);
42  
43          QuerySlotHelper slots = new QuerySlotHelper(ebXML);
44          slots.fromStatus(ASSOCIATION_STATUS, query.getAssociationStatuses());
45          slots.fromInteger(METADATA_LEVEL, query.getMetadataLevel());
46      }
47  
48      /**
49       *
50       * @param query
51       *          the query. Can be <code>null</code>.
52       * @param ebXML ebXML object
53       */
54      public void fromEbXML(GetFoldersForDocumentQuery query, EbXMLAdhocQueryRequest ebXML) {
55          if (query == null || ebXML == null) {
56              return;
57          }
58  
59          super.fromEbXML(query, ebXML);
60  
61          QuerySlotHelper slots = new QuerySlotHelper(ebXML);
62          query.setAssociationStatuses(slots.toStatus(ASSOCIATION_STATUS));
63          query.setMetadataLevel(slots.toInteger(METADATA_LEVEL));
64      }
65  }