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.metadata;
17  
18  import lombok.EqualsAndHashCode;
19  import lombok.Getter;
20  import lombok.Setter;
21  import lombok.ToString;
22  
23  import javax.xml.bind.annotation.*;
24  import java.io.Serializable;
25  import java.util.ArrayList;
26  import java.util.List;
27  
28  /**
29   * Represents an XDS submission set according to the IHE XDS specification.
30   * <p>
31   * All non-list members of this class are allowed to be <code>null</code>.
32   * The lists are pre-created and can therefore never be <code>null</code>.
33   * 
34   * @author Jens Riemschneider
35   */
36  @XmlAccessorType(XmlAccessType.FIELD)
37  @XmlType(name = "SubmissionSet", propOrder = {
38          "sourceId", "submissionTime", "authors", "intendedRecipients", "contentTypeCode"})
39  @XmlRootElement(name = "submissionSet")
40  @EqualsAndHashCode(callSuper = true, doNotUseGetters = true)
41  @ToString(callSuper = true, doNotUseGetters = true)
42  public class SubmissionSet extends XDSMetaClass implements Serializable {
43      private static final long serialVersionUID = 5961980266312684583L;
44      
45      @XmlElement(name = "author")
46      @Getter private final List<Author> authors = new ArrayList<>();
47      @Getter @Setter private Code contentTypeCode;
48      @XmlElement(name = "intendedRecipient")
49      @Getter private final List<Recipient> intendedRecipients = new ArrayList<>();
50      @Getter @Setter private String sourceId;
51      @Getter private Timestamp submissionTime;
52      @XmlAttribute
53      @Getter @Setter private String targetHomeCommunityId;
54  
55      /**
56       * @param author
57       *          the author of the submission.
58       */
59      public void setAuthor(Author author) {
60          authors.clear();
61          authors.add(author);
62      }
63  
64      /**
65       * @return the author of the submission. If the submission has multiple authors
66       *          this method returns only the first in the list. If the submission
67       *          has no authors, this method returns {@code null}.
68       * @deprecated please iterate over {@link #getAuthors()}.
69       */
70      @Deprecated
71      public Author getAuthor() {
72          return authors.isEmpty() ? null : authors.get(0);
73      }
74  
75      public void setSubmissionTime(Timestamp submissionTime) {
76          this.submissionTime = submissionTime;
77      }
78  
79      public void setSubmissionTime(String submissionTime) {
80          this.submissionTime = Timestamp.fromHL7(submissionTime);
81      }
82  
83  }