2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
6 package com.edf.gde.entities;
8 import com.edf.gde.transferables.StudyTO;
9 import java.io.Serializable;
10 import java.util.Date;
11 import java.util.Objects;
12 import javax.persistence.Basic;
13 import javax.persistence.Column;
14 import javax.persistence.Entity;
15 import javax.persistence.GeneratedValue;
16 import javax.persistence.GenerationType;
17 import javax.persistence.Id;
18 import javax.persistence.NamedQueries;
19 import javax.persistence.NamedQuery;
20 import javax.persistence.SequenceGenerator;
21 import javax.persistence.Table;
22 import javax.persistence.Temporal;
23 import javax.persistence.TemporalType;
24 import javax.validation.constraints.NotNull;
25 import javax.validation.constraints.Size;
26 import javax.xml.bind.annotation.XmlRootElement;
32 @Entity(name = "Study")
33 @Table(name = "study")
36 @NamedQuery(name = "Study.findAll", query = "SELECT s FROM Study s"),
37 @NamedQuery(name = "Study.findById", query = "SELECT s FROM Study s WHERE s.id = :id"),
38 @NamedQuery(name = "Study.findByName", query = "SELECT s FROM Study s WHERE s.name = :name"),
39 @NamedQuery(name = "Study.findByCreationDate", query = "SELECT s FROM Study s WHERE s.creationDate = :creationDate"),
40 @NamedQuery(name = "Study.findByUpdateDate", query = "SELECT s FROM Study s WHERE s.updateDate = :updateDate"),
41 //@NamedQuery(name = "Study.findByValid", query = "SELECT s FROM Study s WHERE s.valid = :valid"),
42 //@NamedQuery(name = "Study.findByDeleted", query = "SELECT s FROM Study s WHERE s.deleted = :deleted"),
43 @NamedQuery(name = "Study.findByDeletionDate", query = "SELECT s FROM Study s WHERE s.deletionDate = :deletionDate")
45 public class Study implements Serializable {
46 private static final long serialVersionUID = 1L;
48 @Basic(optional = false)
51 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
52 @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
55 @Column(name = "name")
57 @Column(name = "creation_date")
58 @Temporal(TemporalType.TIMESTAMP)
59 private Date creationDate;
60 @Column(name = "update_date")
61 @Temporal(TemporalType.TIMESTAMP)
62 private Date updateDate;
63 @Column(name = "valid")
64 private Boolean valid;
65 @Column(name = "deleted")
66 private Boolean deleted;
67 @Column(name = "deletion_date")
68 @Temporal(TemporalType.TIMESTAMP)
69 private Date deletionDate;
70 @Column(name = "attribute_group_id")
71 private long attributeGroupId;
72 @Column(name = "profile_id")
73 private long profileId;
78 public Study(long id) {
86 public void setId(long id) {
90 public String getName() {
94 public void setName(String name) {
98 public Date getCreationDate() {
102 public void setCreationDate(Date creationDate) {
103 this.creationDate = creationDate;
106 public Date getUpdateDate() {
110 public void setUpdateDate(Date updateDate) {
111 this.updateDate = updateDate;
114 public Boolean getValid() {
118 public void setValid(Boolean valid) {
122 public Boolean getDeleted() {
126 public void setDeleted(Boolean deleted) {
127 this.deleted = deleted;
130 public Date getDeletionDate() {
134 public void setDeletionDate(Date deletionDate) {
135 this.deletionDate = deletionDate;
138 public long getAttributeGroupId() {
139 return attributeGroupId;
142 public void setAttributeGroupId(long attributeGroupId) {
143 this.attributeGroupId = attributeGroupId;
146 public long getProfileId() {
150 public void setProfileId(long profileId) {
151 this.profileId = profileId;
154 public static Study fromStudyTO(StudyTO sto) {
155 Study s = new Study();
156 s.creationDate = sto.getCreationDate();
157 s.deleted = sto.getDeleted();
158 s.deletionDate = sto.getDeletionDate();
159 s.attributeGroupId = sto.getAttributeGroupId();
161 s.name = sto.getName();
162 s.updateDate = sto.getUpdateDate();
163 s.valid = sto.getValid();
164 s.profileId = sto.getProfileId();
168 public StudyTO toStudyTO() {
169 StudyTO sto = new StudyTO();
170 sto.setCreationDate(this.creationDate);
171 sto.setDeleted(this.deleted);
172 sto.setDeletionDate(this.deletionDate);
173 sto.setAttributeGroupId(this.attributeGroupId);
175 sto.setName(this.name);
176 sto.setUpdateDate(this.updateDate);
177 sto.setValid(this.valid);
178 sto.setProfileId(this.profileId);
183 public String toString() {
184 return "com.edf.gde.entities.Study[ id=" + id + " ]";
188 public int hashCode() {
190 hash = 11 * hash + (int) (this.id ^ (this.id >>> 32));
191 hash = 11 * hash + Objects.hashCode(this.name);
192 hash = 11 * hash + Objects.hashCode(this.creationDate);
193 hash = 11 * hash + Objects.hashCode(this.updateDate);
194 hash = 11 * hash + Objects.hashCode(this.valid);
195 hash = 11 * hash + Objects.hashCode(this.deleted);
196 hash = 11 * hash + Objects.hashCode(this.deletionDate);
197 hash = 11 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32));
198 hash = 11 * hash + (int) (this.profileId ^ (this.profileId >>> 32));
203 public boolean equals(Object obj) {
207 if (getClass() != obj.getClass()) {
210 final Study other = (Study) obj;
211 if (this.id != other.id) {