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.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.ReferenceId;
23  import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query.QuerySlotHelper;
24  
25  import javax.xml.bind.annotation.*;
26  
27  /**
28   * Represents a stored query for FindDocumentsByReferenceIdQuery.
29   * @author Dmytro Rud
30   */
31  @XmlAccessorType(XmlAccessType.FIELD)
32  @XmlType(name = "FindDocumentsByReferenceIdQuery", propOrder = {"referenceIds"})
33  @XmlRootElement(name = "findDocumentsByReferenceIdQuery")
34  @EqualsAndHashCode(callSuper = true, doNotUseGetters = true)
35  @ToString(callSuper = true, doNotUseGetters = true)
36  public class FindDocumentsByReferenceIdQuery extends FindDocumentsQuery {
37      private static final long serialVersionUID = 8898792914033157098L;
38  
39      @XmlElement(name = "referenceId")
40      @Getter @Setter private QueryList<String> referenceIds;
41  
42  
43      /**
44       * Constructs the query.
45       */
46      public FindDocumentsByReferenceIdQuery() {
47          super(QueryType.FIND_DOCUMENTS_BY_REFERENCE_ID);
48      }
49  
50      @Override
51      public void accept(Visitor visitor) {
52          visitor.visit(this);
53      }
54  
55      /**
56       * Allows to use a collection of {@link ReferenceId} instead of a collection of {@link String}
57       * for specifying the query parameter "$XDSDocumentEntryReferenceIdList".
58       *
59       * @param referenceIds a collection of {@link ReferenceId} objects with AND/OR semantics.
60       */
61      public void setTypedReferenceIds(QueryList<ReferenceId> referenceIds) {
62          this.referenceIds = QuerySlotHelper.render(referenceIds);
63      }
64  
65      /**
66       * Tries to return the query parameter "$XDSDocumentEntryReferenceIdList"
67       * as a collection of {@link ReferenceId} instead of a collection of {@link String}.
68       * This may fail if SQL LIKE wildcards ("%", "_", etc.) are used in one or more elements.
69       *
70       * @return a collection of {@link ReferenceId} objects with AND/OR semantics.
71       */
72      public QueryList<ReferenceId> getTypedReferenceIds() {
73          return QuerySlotHelper.parse(this.referenceIds, ReferenceId.class);
74      }
75  
76  }