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.Id;
16 import javax.persistence.JoinColumn;
17 import javax.persistence.ManyToOne;
18 import javax.persistence.NamedQueries;
19 import javax.persistence.NamedQuery;
20 import javax.persistence.Table;
21 import javax.persistence.Temporal;
22 import javax.persistence.TemporalType;
23 import javax.validation.constraints.NotNull;
24 import javax.validation.constraints.Size;
25 import javax.xml.bind.annotation.XmlRootElement;
31 @Entity(name = "Study")
32 @Table(name = "study")
35 @NamedQuery(name = "Study.findAll", query = "SELECT s FROM Study s"),
36 @NamedQuery(name = "Study.findById", query = "SELECT s FROM Study s WHERE s.id = :id"),
37 @NamedQuery(name = "Study.findByName", query = "SELECT s FROM Study s WHERE s.name = :name"),
38 @NamedQuery(name = "Study.findByCreationDate", query = "SELECT s FROM Study s WHERE s.creationDate = :creationDate"),
39 @NamedQuery(name = "Study.findByUpdateDate", query = "SELECT s FROM Study s WHERE s.updateDate = :updateDate"),
40 //@NamedQuery(name = "Study.findByValid", query = "SELECT s FROM Study s WHERE s.valid = :valid"),
41 //@NamedQuery(name = "Study.findByDeleted", query = "SELECT s FROM Study s WHERE s.deleted = :deleted"),
42 @NamedQuery(name = "Study.findByDeletionDate", query = "SELECT s FROM Study s WHERE s.deletionDate = :deletionDate")
44 public class Study implements Serializable {
45 private static final long serialVersionUID = 1L;
47 @Basic(optional = false)
52 @Column(name = "name")
54 @Column(name = "creation_date")
55 @Temporal(TemporalType.TIMESTAMP)
56 private Date creationDate;
57 @Column(name = "update_date")
58 @Temporal(TemporalType.TIMESTAMP)
59 private Date updateDate;
60 @Column(name = "valid")
61 private Boolean valid;
62 @Column(name = "deleted")
63 private Boolean deleted;
64 @Column(name = "deletion_date")
65 @Temporal(TemporalType.TIMESTAMP)
66 private Date deletionDate;
67 @Column(name = "attribute_group_id")
68 private long attributeGroupId;
73 public Study(long id) {
81 public void setId(long id) {
85 public String getName() {
89 public void setName(String name) {
93 public Date getCreationDate() {
97 public void setCreationDate(Date creationDate) {
98 this.creationDate = creationDate;
101 public Date getUpdateDate() {
105 public void setUpdateDate(Date updateDate) {
106 this.updateDate = updateDate;
109 public Boolean getValid() {
113 public void setValid(Boolean valid) {
117 public Boolean getDeleted() {
121 public void setDeleted(Boolean deleted) {
122 this.deleted = deleted;
125 public Date getDeletionDate() {
129 public void setDeletionDate(Date deletionDate) {
130 this.deletionDate = deletionDate;
133 public long getAttributeGroupId() {
134 return attributeGroupId;
137 public void setAttributeGroupId(long attributeGroupId) {
138 this.attributeGroupId = attributeGroupId;
141 public static Study fromStudyTO(StudyTO sto) {
142 Study s = new Study();
143 s.creationDate = sto.getCreationDate();
144 s.deleted = sto.getDeleted();
145 s.deletionDate = sto.getDeletionDate();
146 s.attributeGroupId = sto.getAttributeGroupId();
148 s.name = sto.getName();
149 s.updateDate = sto.getUpdateDate();
150 s.valid = sto.getValid();
154 public StudyTO toStudyTO() {
155 StudyTO sto = new StudyTO();
156 sto.setCreationDate(this.creationDate);
157 sto.setDeleted(this.deleted);
158 sto.setDeletionDate(this.deletionDate);
159 sto.setAttributeGroupId(this.attributeGroupId);
161 sto.setName(this.name);
162 sto.setUpdateDate(this.updateDate);
163 sto.setValid(this.valid);
168 public String toString() {
169 return "com.edf.gde.entities.Study[ id=" + id + " ]";
173 public int hashCode() {
175 hash = 17 * hash + (int) (this.id ^ (this.id >>> 32));
176 hash = 17 * hash + Objects.hashCode(this.name);
177 hash = 17 * hash + Objects.hashCode(this.creationDate);
178 hash = 17 * hash + Objects.hashCode(this.updateDate);
179 hash = 17 * hash + Objects.hashCode(this.valid);
180 hash = 17 * hash + Objects.hashCode(this.deleted);
181 hash = 17 * hash + Objects.hashCode(this.deletionDate);
182 hash = 17 * hash + Objects.hashCode(this.attributeGroupId);
187 public boolean equals(Object obj) {
191 if (getClass() != obj.getClass()) {
194 final Study other = (Study) obj;
195 if (this.id != other.id) {