4 package com.edf.gde.entities;
6 import com.edf.gde.transferables.StudyTO;
7 import java.io.Serializable;
9 import java.util.Objects;
10 import javax.persistence.Basic;
11 import javax.persistence.Column;
12 import javax.persistence.Entity;
13 import javax.persistence.GeneratedValue;
14 import javax.persistence.GenerationType;
15 import javax.persistence.Id;
16 import javax.persistence.NamedQueries;
17 import javax.persistence.NamedQuery;
18 import javax.persistence.SequenceGenerator;
19 import javax.persistence.Table;
20 import javax.persistence.Temporal;
21 import javax.persistence.TemporalType;
22 import javax.validation.constraints.NotNull;
23 import javax.validation.constraints.Size;
24 import javax.xml.bind.annotation.XmlRootElement;
30 @Entity(name = "Study")
31 @Table(name = "study")
34 @NamedQuery(name = "Study.findAll", query = "SELECT s FROM Study s"),
35 @NamedQuery(name = "Study.findById", query = "SELECT s FROM Study s WHERE s.id = :id"),
36 @NamedQuery(name = "Study.findByName", query = "SELECT s FROM Study s WHERE s.name = :name"),
37 @NamedQuery(name = "Study.findByCreationDate", query = "SELECT s FROM Study s WHERE s.creationDate = :creationDate"),
38 @NamedQuery(name = "Study.findByUpdateDate", query = "SELECT s FROM Study s WHERE s.updateDate = :updateDate"),
39 @NamedQuery(name = "Study.findByDeletionDate", query = "SELECT s FROM Study s WHERE s.deletionDate = :deletionDate")
41 public class Study implements Serializable {
42 private static final long serialVersionUID = 1L;
44 @Basic(optional = false)
47 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
48 @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
51 @Column(name = "name")
53 @Column(name = "creation_date")
54 @Temporal(TemporalType.TIMESTAMP)
55 private Date creationDate;
56 @Column(name = "update_date")
57 @Temporal(TemporalType.TIMESTAMP)
58 private Date updateDate;
59 @Column(name = "valid")
60 private boolean valid;
61 @Column(name = "deleted")
62 private boolean deleted;
63 @Column(name = "deletion_date")
64 @Temporal(TemporalType.TIMESTAMP)
65 private Date deletionDate;
66 @Column(name = "attribute_group_id", nullable = true)
67 private Long attributeGroupId;
68 @Column(name = "profile_id", nullable = true)
69 private Long profileId;
70 @Column(name ="locked")
71 private boolean locked;
75 public Study(long id) {
83 public void setId(long id) {
87 public String getName() {
91 public void setName(String name) {
95 public Date getCreationDate() {
99 public void setCreationDate(Date creationDate) {
100 this.creationDate = creationDate;
103 public Date getUpdateDate() {
107 public void setUpdateDate(Date updateDate) {
108 this.updateDate = updateDate;
111 public boolean getValid() {
115 public void setValid(boolean valid) {
119 public boolean getDeleted() {
123 public void setDeleted(boolean deleted) {
124 this.deleted = deleted;
127 public Date getDeletionDate() {
131 public void setDeletionDate(Date deletionDate) {
132 this.deletionDate = deletionDate;
135 public long getAttributeGroupId() {
136 return attributeGroupId;
139 public void setAttributeGroupId(long attributeGroupId) {
140 this.attributeGroupId = attributeGroupId;
143 public long getProfileId() {
147 public void setProfileId(long profileId) {
148 this.profileId = profileId;
151 public boolean isLocked() {
155 public void setLocked(boolean locked) {
156 this.locked = locked;
159 public static Study fromStudyTO(StudyTO sto) {
160 Study s = new Study();
161 s.creationDate = sto.getCreationDate();
162 s.deleted = sto.getDeleted();
163 s.deletionDate = sto.getDeletionDate();
164 s.attributeGroupId = sto.getAttributeGroupId()==0?null:sto.getAttributeGroupId();
166 s.name = sto.getName();
167 s.updateDate = sto.getUpdateDate();
168 s.valid = sto.getValid();
169 s.profileId = sto.getProfileId()==0?null:sto.getProfileId();
170 s.locked = sto.isLocked();
174 public StudyTO toStudyTO() {
175 StudyTO sto = new StudyTO();
176 sto.setCreationDate(this.creationDate);
177 sto.setDeleted(this.deleted);
178 sto.setDeletionDate(this.deletionDate);
179 sto.setAttributeGroupId(this.attributeGroupId==null?0:this.attributeGroupId);
181 sto.setName(this.name);
182 sto.setUpdateDate(this.updateDate);
183 sto.setValid(this.valid);
184 sto.setProfileId(this.profileId==null?0:this.profileId);
185 sto.setLocked(this.locked);
190 public String toString() {
191 return "com.edf.gde.entities.Study[ id=" + id + " ]";
195 public int hashCode() {
197 hash = 67 * hash + (int) (this.id ^ (this.id >>> 32));
198 hash = 67 * hash + Objects.hashCode(this.name);
199 hash = 67 * hash + Objects.hashCode(this.creationDate);
200 hash = 67 * hash + Objects.hashCode(this.updateDate);
201 hash = 67 * hash + (this.valid ? 1 : 0);
202 hash = 67 * hash + (this.deleted ? 1 : 0);
203 hash = 67 * hash + Objects.hashCode(this.deletionDate);
204 hash = 67 * hash + Objects.hashCode(this.attributeGroupId);
205 hash = 67 * hash + Objects.hashCode(this.profileId);
206 hash = 67 * hash + (this.locked ? 1 : 0);
211 public boolean equals(Object obj) {
215 if (getClass() != obj.getClass()) {
218 final Study other = (Study) obj;
219 if (this.id != other.id) {