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.requests.query;
17  
18  import lombok.EqualsAndHashCode;
19  import lombok.Getter;
20  import lombok.Setter;
21  import lombok.ToString;
22  import org.openehealth.ipf.commons.ihe.xds.core.metadata.Code;
23  import org.openehealth.ipf.commons.ihe.xds.core.metadata.Person;
24  import org.openehealth.ipf.commons.ihe.xds.core.metadata.TimeRange;
25  import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query.QuerySlotHelper;
26  
27  import javax.xml.bind.annotation.*;
28  import java.util.List;
29  
30  /**
31   * Abstract stored query for documents.
32   * @author Jens Riemschneider
33   */
34  @XmlAccessorType(XmlAccessType.FIELD)
35  @XmlType(name = "DocumentsQuery", propOrder = {
36          "authorPersons", "creationTime", "serviceStartTime", "serviceStopTime",
37          "classCodes", "confidentialityCodes", "eventCodes", "formatCodes",
38          "healthcareFacilityTypeCodes", "practiceSettingCodes", "typeCodes"})
39  @XmlRootElement(name = "abstractDocumentsQuery")
40  @EqualsAndHashCode(callSuper = true, doNotUseGetters = true)
41  @ToString(callSuper = true, doNotUseGetters = true)
42  public abstract class DocumentsQuery extends StoredQuery  {
43      private static final long serialVersionUID = 1162423827844317922L;
44  
45      @XmlElement(name = "typeCode")
46      @Getter @Setter private List<Code> typeCodes;
47      @XmlElement(name = "classCode")
48      @Getter @Setter private List<Code> classCodes;
49      @XmlElement(name = "practiceSettingCode")
50      @Getter @Setter private List<Code> practiceSettingCodes;
51      @XmlElement(name = "healthcareFacilityTypeCode")
52      @Getter @Setter private List<Code> healthcareFacilityTypeCodes;
53      @XmlElement(name = "eventCode")
54      @Getter @Setter private QueryList<Code> eventCodes;
55      @XmlElement(name = "confidentialityCode")
56      @Getter @Setter private QueryList<Code> confidentialityCodes;
57      @XmlElement(name = "formatCode")
58      @Getter @Setter private List<Code> formatCodes;
59      @XmlElement(name = "authorPerson")
60      @Getter @Setter private List<String> authorPersons;
61  
62      @Getter private final TimeRange creationTime = new TimeRange();
63      @Getter private final TimeRange serviceStartTime = new TimeRange();
64      @Getter private final TimeRange serviceStopTime = new TimeRange();
65  
66      /**
67       * For JAXB only.
68       */
69      protected DocumentsQuery() {
70      }
71  
72  
73      protected DocumentsQuery(QueryType type) {
74          super(type);
75      }
76  
77      /**
78       * Allows to use a collection of {@link Person} instead of a collection of {@link String}
79       * for specifying the query parameter "$XDSDocumentEntryAuthorPerson".
80       *
81       * @param authorPersons a collection of {@link Person} objects.
82       */
83      public void setTypedAuthorPersons(List<Person> authorPersons) {
84          this.authorPersons = QuerySlotHelper.render(authorPersons);
85      }
86  
87      /**
88       * Tries to return the query parameter "$XDSDocumentEntryAuthorPerson"
89       * as a collection of {@link Person} instead of a collection of {@link String}.
90       * This may fail if SQL LIKE wildcards ("%", "_", etc.) are used in one or more elements.
91       *
92       * @return a collection of {@link Person} objects.
93       */
94      public List<Person> getTypedAuthorPersons() {
95          return QuerySlotHelper.parse(this.authorPersons, Person.class);
96      }
97  
98  }