]> SALOME platform Git repositories - modules/gde.git/blob - projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Study.java
Salome HOME
Working on tests for Study
[modules/gde.git] / projects / GDE_App / GDE-ejb / src / java / com / edf / gde / entities / Study.java
1 /*
2  * (C) 2015 EDF
3  */
4 package com.edf.gde.entities;
5
6 import com.edf.gde.transferables.StudyTO;
7 import java.io.Serializable;
8 import java.util.Date;
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;
25
26 /**
27  *
28  * @author F62173
29  */
30 @Entity(name = "Study")
31 @Table(name = "study")
32 @XmlRootElement
33 @NamedQueries({
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")
40 })
41 public class Study implements Serializable {
42     private static final long serialVersionUID = 1L;
43     @Id
44     @Basic(optional = false)
45     @NotNull
46     @Column(name = "id")
47     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
48     @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
49     private long id;
50     @Size(max = 255)
51     @Column(name = "name")
52     private String 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;
72     public Study() {
73     }
74
75     public Study(long id) {
76         this.id = id;
77     }
78
79     public long getId() {
80         return id;
81     }
82
83     public void setId(long id) {
84         this.id = id;
85     }
86
87     public String getName() {
88         return name;
89     }
90
91     public void setName(String name) {
92         this.name = name;
93     }
94
95     public Date getCreationDate() {
96         return creationDate;
97     }
98
99     public void setCreationDate(Date creationDate) {
100         this.creationDate = creationDate;
101     }
102
103     public Date getUpdateDate() {
104         return updateDate;
105     }
106
107     public void setUpdateDate(Date updateDate) {
108         this.updateDate = updateDate;
109     }
110
111     public boolean getValid() {
112         return valid;
113     }
114
115     public void setValid(boolean valid) {
116         this.valid = valid;
117     }
118
119     public boolean getDeleted() {
120         return deleted;
121     }
122
123     public void setDeleted(boolean deleted) {
124         this.deleted = deleted;
125     }
126
127     public Date getDeletionDate() {
128         return deletionDate;
129     }
130
131     public void setDeletionDate(Date deletionDate) {
132         this.deletionDate = deletionDate;
133     }
134
135     public long getAttributeGroupId() {
136         return attributeGroupId;
137     }
138
139     public void setAttributeGroupId(long attributeGroupId) {
140         this.attributeGroupId = attributeGroupId;
141     }
142
143     public long getProfileId() {
144         return profileId;
145     }
146
147     public void setProfileId(long profileId) {
148         this.profileId = profileId;
149     }
150
151     public boolean isLocked() {
152         return locked;
153     }
154
155     public void setLocked(boolean locked) {
156         this.locked = locked;
157     }
158
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();
165         s.id = sto.getId();
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();
171         return s;
172     }
173
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);
180         sto.setId(this.id);
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);
186         return sto;
187     }
188
189     @Override
190     public String toString() {
191         return "com.edf.gde.entities.Study[ id=" + id + " ]";
192     }
193
194     @Override
195     public int hashCode() {
196         int hash = 5;
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);
207         return hash;
208     }
209
210     @Override
211     public boolean equals(Object obj) {
212         if (obj == null) {
213             return false;
214         }
215         if (getClass() != obj.getClass()) {
216             return false;
217         }
218         final Study other = (Study) obj;
219         if (this.id != other.id) {
220             return false;
221         }
222         return true;
223     }
224
225
226 }