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.requests.query;
17  
18  import lombok.EqualsAndHashCode;
19  import lombok.Getter;
20  import lombok.ToString;
21  
22  import static org.apache.commons.lang3.Validate.notNull;
23  
24  import javax.xml.bind.annotation.*;
25  import java.io.Serializable;
26  
27  /**
28   * Base class for all query requests.
29   * @author Jens Riemschneider
30   */
31  @XmlAccessorType(XmlAccessType.FIELD)
32  @XmlType(name = "Query")
33  @EqualsAndHashCode(doNotUseGetters = true)
34  @ToString(doNotUseGetters = true)
35  public abstract class Query implements Serializable {
36      private static final long serialVersionUID = 7597105342752455732L;
37  
38      @XmlAttribute
39      @Getter private QueryType type;
40  
41      /**
42       * For JAXB serialization only.
43       */
44      public Query() {
45      }
46  
47      /**
48       * Constructs the query.
49       * @param type
50       *          the type of the query.
51       */
52      protected Query(QueryType type) {
53          notNull(type, "type cannot be null");
54          this.type = type;
55      }
56  
57      /**
58       * Visitor interface used for this class to implement the visitor pattern.
59       */
60      public interface Visitor {
61          void visit(FindDocumentsQuery query);
62          void visit(FindDocumentsForMultiplePatientsQuery query);
63          void visit(FindFoldersQuery query);
64          void visit(FindFoldersForMultiplePatientsQuery query);
65          void visit(GetSubmissionSetsQuery query);
66          void visit(GetSubmissionSetAndContentsQuery query);
67          void visit(GetRelatedDocumentsQuery query);
68          void visit(GetFoldersQuery query);
69          void visit(GetFoldersForDocumentQuery query);
70          void visit(GetFolderAndContentsQuery query);
71          void visit(GetDocumentsQuery query);
72          void visit(GetDocumentsAndAssociationsQuery query);
73          void visit(GetAssociationsQuery query);
74          void visit(GetAllQuery query);
75          void visit(FindSubmissionSetsQuery query);
76          void visit(FetchQuery query);
77          void visit(FindDocumentsByReferenceIdQuery query);
78      }
79      
80      /**
81       * Accept a visitor to process an instance of this class.
82       * @param visitor
83       *          the visitor implementation.
84       */
85      public abstract void accept(Visitor visitor);
86  }