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.responses;
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.*;
23  
24  import javax.xml.bind.annotation.*;
25  import java.io.Serializable;
26  import java.util.ArrayList;
27  import java.util.List;
28  
29  /**
30   * Contains the response data for a query.
31   * Lists are pre-created and can therefore never be <code>null</code>.
32   * @author Jens Riemschneider
33   */
34  @XmlAccessorType(XmlAccessType.FIELD)
35  @XmlType(name = "QueryResponse", propOrder = {
36          "references", "submissionSets", "folders", "documentEntries", "associations", "documents"})
37  @XmlRootElement(name = "queryResponse")
38  @EqualsAndHashCode(callSuper = true, doNotUseGetters = true)
39  @ToString(callSuper = true, doNotUseGetters = true)
40  public class QueryResponse extends Response implements Serializable {
41      private static final long serialVersionUID = -435462523350768903L;
42      
43      @XmlElement(name = "reference")
44      @Getter @Setter private List<ObjectReference> references = new ArrayList<>();
45      @XmlElementRef
46      @Getter @Setter private List<DocumentEntry> documentEntries = new ArrayList<>();
47      @XmlElementRef
48      @Getter @Setter private List<Folder> folders = new ArrayList<>();
49      @XmlElementRef
50      @Getter @Setter private List<SubmissionSet> submissionSets = new ArrayList<>();
51      @XmlElementRef
52      @Getter @Setter private List<Association> associations = new ArrayList<>();
53      @XmlElementRef
54      @Getter @Setter private List<Document> documents = new ArrayList<>();
55      
56      /**
57       * Constructs the response.
58       */
59      public QueryResponse() {}
60      
61      /**
62       * Constructs the response.
63       * @param status
64       *          the status of the request execution.
65       */
66      public QueryResponse(Status status) {        
67          super(status);
68      }
69      
70      /**
71       * Constructs an error response object with the data from an exception.
72       * @param throwable
73       *          the exception that occurred.
74       * @param defaultMetaDataError
75       *          the default error code for {@link org.openehealth.ipf.commons.ihe.xds.core.validate.XDSMetaDataException}.
76       * @param defaultError
77       *          the default error code for any other exception.
78       * @param location
79       *          error location.
80       */
81      public QueryResponse(
82              Throwable throwable,
83              ErrorCode defaultMetaDataError,
84              ErrorCode defaultError,
85              String location)
86      {
87          super(throwable, defaultMetaDataError, defaultError, location);
88      }
89  
90  }