Salome HOME
- Code refactoring and simplification
[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.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;
27
28 /**
29  *
30  * @author F62173
31  */
32 @Entity(name = "Study")
33 @Table(name = "study")
34 @XmlRootElement
35 @NamedQueries({
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")
44 })
45 public class Study implements Serializable {
46     private static final long serialVersionUID = 1L;
47     @Id
48     @Basic(optional = false)
49     @NotNull
50     @Column(name = "id")
51     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
52     @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
53     private long id;
54     @Size(max = 255)
55     @Column(name = "name")
56     private String 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;
74
75     public Study() {
76     }
77
78     public Study(long id) {
79         this.id = id;
80     }
81
82     public long getId() {
83         return id;
84     }
85
86     public void setId(long id) {
87         this.id = id;
88     }
89
90     public String getName() {
91         return name;
92     }
93
94     public void setName(String name) {
95         this.name = name;
96     }
97
98     public Date getCreationDate() {
99         return creationDate;
100     }
101
102     public void setCreationDate(Date creationDate) {
103         this.creationDate = creationDate;
104     }
105
106     public Date getUpdateDate() {
107         return updateDate;
108     }
109
110     public void setUpdateDate(Date updateDate) {
111         this.updateDate = updateDate;
112     }
113
114     public Boolean getValid() {
115         return valid;
116     }
117
118     public void setValid(Boolean valid) {
119         this.valid = valid;
120     }
121
122     public Boolean getDeleted() {
123         return deleted;
124     }
125
126     public void setDeleted(Boolean deleted) {
127         this.deleted = deleted;
128     }
129
130     public Date getDeletionDate() {
131         return deletionDate;
132     }
133
134     public void setDeletionDate(Date deletionDate) {
135         this.deletionDate = deletionDate;
136     }
137
138     public long getAttributeGroupId() {
139         return attributeGroupId;
140     }
141
142     public void setAttributeGroupId(long attributeGroupId) {
143         this.attributeGroupId = attributeGroupId;
144     }
145
146     public long getProfileId() {
147         return profileId;
148     }
149
150     public void setProfileId(long profileId) {
151         this.profileId = profileId;
152     }
153
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();
160         s.id = sto.getId();
161         s.name = sto.getName();
162         s.updateDate = sto.getUpdateDate();
163         s.valid = sto.getValid();
164         s.profileId = sto.getProfileId();
165         return s;
166     }
167
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);
174         sto.setId(this.id);
175         sto.setName(this.name);
176         sto.setUpdateDate(this.updateDate);
177         sto.setValid(this.valid);
178         sto.setProfileId(this.profileId);
179         return sto;
180     }
181
182     @Override
183     public String toString() {
184         return "com.edf.gde.entities.Study[ id=" + id + " ]";
185     }
186
187     @Override
188     public int hashCode() {
189         int hash = 7;
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));
199         return hash;
200     }
201
202     @Override
203     public boolean equals(Object obj) {
204         if (obj == null) {
205             return false;
206         }
207         if (getClass() != obj.getClass()) {
208             return false;
209         }
210         final Study other = (Study) obj;
211         if (this.id != other.id) {
212             return false;
213         }
214         return true;
215     }
216
217 }