]> SALOME platform Git repositories - modules/gde.git/blob - projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Study.java
Salome HOME
Add study
[modules/gde.git] / projects / GDE_App / GDE-ejb / src / java / com / edf / gde / entities / Study.java
1 /*
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.
5  */
6 package com.edf.gde.entities;
7
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;
26
27 /**
28  *
29  * @author F62173
30  */
31 @Entity(name = "Study")
32 @Table(name = "study")
33 @XmlRootElement
34 @NamedQueries({
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")
43 })
44 public class Study implements Serializable {
45     private static final long serialVersionUID = 1L;
46     @Id
47     @Basic(optional = false)
48     @NotNull
49     @Column(name = "id")
50     private long id;
51     @Size(max = 255)
52     @Column(name = "name")
53     private String 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;
69
70     public Study() {
71     }
72
73     public Study(long id) {
74         this.id = id;
75     }
76
77     public long getId() {
78         return id;
79     }
80
81     public void setId(long id) {
82         this.id = id;
83     }
84
85     public String getName() {
86         return name;
87     }
88
89     public void setName(String name) {
90         this.name = name;
91     }
92
93     public Date getCreationDate() {
94         return creationDate;
95     }
96
97     public void setCreationDate(Date creationDate) {
98         this.creationDate = creationDate;
99     }
100
101     public Date getUpdateDate() {
102         return updateDate;
103     }
104
105     public void setUpdateDate(Date updateDate) {
106         this.updateDate = updateDate;
107     }
108
109     public Boolean getValid() {
110         return valid;
111     }
112
113     public void setValid(Boolean valid) {
114         this.valid = valid;
115     }
116
117     public Boolean getDeleted() {
118         return deleted;
119     }
120
121     public void setDeleted(Boolean deleted) {
122         this.deleted = deleted;
123     }
124
125     public Date getDeletionDate() {
126         return deletionDate;
127     }
128
129     public void setDeletionDate(Date deletionDate) {
130         this.deletionDate = deletionDate;
131     }
132
133     public long getAttributeGroupId() {
134         return attributeGroupId;
135     }
136
137     public void setAttributeGroupId(long attributeGroupId) {
138         this.attributeGroupId = attributeGroupId;
139     }
140
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();
147         s.id = sto.getId();
148         s.name = sto.getName();
149         s.updateDate = sto.getUpdateDate();
150         s.valid = sto.getValid();
151         return s;
152     }
153
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);
160         sto.setId(this.id);
161         sto.setName(this.name);
162         sto.setUpdateDate(this.updateDate);
163         sto.setValid(this.valid);
164         return sto;
165     }
166
167     @Override
168     public String toString() {
169         return "com.edf.gde.entities.Study[ id=" + id + " ]";
170     }
171
172     @Override
173     public int hashCode() {
174         int hash = 7;
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);
183         return hash;
184     }
185
186     @Override
187     public boolean equals(Object obj) {
188         if (obj == null) {
189             return false;
190         }
191         if (getClass() != obj.getClass()) {
192             return false;
193         }
194         final Study other = (Study) obj;
195         if (this.id != other.id) {
196             return false;
197         }
198         return true;
199     }
200     
201 }