gICS_2.8.6
ConsentKeyDTO.java
1 package org.emau.icmvc.ganimed.ttp.cm2.dto;
2 
3 /*
4  * ###license-information-start###
5  * gICS - a Generic Informed Consent Service
6  * __
7  * Copyright (C) 2014 - 2018 The MOSAIC Project - Institut fuer Community
8  * Medicine of the University Medicine Greifswald -
9  * mosaic-projekt@uni-greifswald.de
10  *
11  * concept and implementation
12  * l.geidel
13  * web client
14  * a.blumentritt, m.bialke
15  *
16  * Selected functionalities of gICS were developed as part of the MAGIC Project (funded by the DFG HO 1937/5-1).
17  *
18  * please cite our publications
19  * http://dx.doi.org/10.3414/ME14-01-0133
20  * http://dx.doi.org/10.1186/s12967-015-0545-6
21  * http://dx.doi.org/10.3205/17gmds146
22  * __
23  * This program is free software: you can redistribute it and/or modify
24  * it under the terms of the GNU Affero General Public License as published by
25  * the Free Software Foundation, either version 3 of the License, or
26  * (at your option) any later version.
27  *
28  * This program is distributed in the hope that it will be useful,
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31  * GNU General Public License for more details.
32  *
33  * You should have received a copy of the GNU Affero General Public License
34  * along with this program. If not, see <http://www.gnu.org/licenses/>.
35  * ###license-information-end###
36  */
37 
38 import java.io.Serializable;
39 import java.util.Date;
40 import java.util.HashSet;
41 import java.util.Set;
42 
49 public class ConsentKeyDTO implements Serializable {
50 
51  private static final long serialVersionUID = 3488915902092845220L;
52  private ConsentTemplateKeyDTO consentTemplateKey;
53  private Set<SignerIdDTO> signerIds = new HashSet<SignerIdDTO>();
54  private Date consentDate;
55 
56  public ConsentKeyDTO() {
57  }
58 
59  public ConsentKeyDTO(ConsentTemplateKeyDTO consentTemplateKey, Set<SignerIdDTO> signerIds, Date consentDate) {
60  super();
61  this.consentTemplateKey = consentTemplateKey;
62  if (signerIds != null) {
63  this.signerIds = signerIds;
64  }
65  this.consentDate = consentDate;
66  }
67 
68  public ConsentTemplateKeyDTO getConsentTemplateKey() {
69  return consentTemplateKey;
70  }
71 
72  public void setConsentTemplateKey(ConsentTemplateKeyDTO consentTemplateKey) {
73  this.consentTemplateKey = consentTemplateKey;
74  }
75 
76  public Set<SignerIdDTO> getSignerIds() {
77  return signerIds;
78  }
79 
80  public void setSignerIds(Set<SignerIdDTO> signerIds) {
81  if (signerIds != null) {
82  this.signerIds = signerIds;
83  }
84  }
85 
86  public Date getConsentDate() {
87  return consentDate;
88  }
89 
90  public void setConsentDate(Date consentDate) {
91  this.consentDate = consentDate;
92  }
93 
94  @Override
95  public int hashCode() {
96  final int prime = 31;
97  int result = 1;
98  result = prime * result + ((consentDate == null) ? 0 : consentDate.hashCode());
99  result = prime * result + ((consentTemplateKey == null) ? 0 : consentTemplateKey.hashCode());
100  result = prime * result + ((signerIds == null) ? 0 : signerIds.hashCode());
101  return result;
102  }
103 
104  @Override
105  public boolean equals(Object obj) {
106  if (this == obj)
107  return true;
108  if (obj == null)
109  return false;
110  if (getClass() != obj.getClass())
111  return false;
112  ConsentKeyDTO other = (ConsentKeyDTO) obj;
113  if (consentDate == null) {
114  if (other.consentDate != null)
115  return false;
116  } else if (!consentDate.equals(other.consentDate))
117  return false;
118  if (consentTemplateKey == null) {
119  if (other.consentTemplateKey != null)
120  return false;
121  } else if (!consentTemplateKey.equals(other.consentTemplateKey))
122  return false;
123  if (signerIds == null) {
124  if (other.signerIds != null)
125  return false;
126  } else if (!signerIds.equals(other.signerIds))
127  return false;
128  return true;
129  }
130 
131  @Override
132  public String toString() {
133  StringBuilder sb = new StringBuilder();
134  sb.append("signed consent for ");
135  sb.append(consentTemplateKey);
136  sb.append(" signed by [");
137  for (SignerIdDTO signerId : signerIds) {
138  sb.append(signerId.toString() + " ");
139  }
140  sb.append("] at ");
141  sb.append(consentDate);
142  return sb.toString();
143  }
144 }
signer id - combination of id and id type