View Javadoc

1   /*
2    * Copyright 2007 The International Moth Class Association (IMCA)
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.imca.model.entities;
17  
18  import javax.persistence.Entity;
19  import javax.persistence.GeneratedValue;
20  import javax.persistence.GenerationType;
21  import javax.persistence.Id;
22  import javax.persistence.NamedQueries;
23  import javax.persistence.NamedQuery;
24  import javax.persistence.OneToOne;
25  
26  /**
27   * An persistence entity description. There is no logic just getter and setters,
28   * for the properties. This Object represents a table in the database and the
29   * properties are fields.
30   *
31   * @author dougculnane
32   */
33  @Entity
34  @NamedQueries( {
35          @NamedQuery(name = "findPersonByXmlId", 
36                  query = "SELECT p FROM PersonEntity p WHERE p.xmlId= :xmlId"),
37          @NamedQuery(name = "findPersonByEmail", 
38                  query = "SELECT p FROM PersonEntity p WHERE p.email= :email"),
39          @NamedQuery(name = "PersonBasicSearch", 
40                  query = "SELECT p FROM PersonEntity p WHERE " +
41                  		"p.firstName LIKE :search OR p.lastName LIKE :search")
42  })
43  public class PersonEntity {
44  
45      /**
46       * Object Identifier.
47       */
48      @Id
49      @GeneratedValue(strategy=GenerationType.TABLE)
50      private long id;
51  
52      private String sex = "";
53  
54      private String firstName = "";
55  
56      private String lastName = "";
57  
58      private String tel = "";
59  
60      private String mobile = "";
61  
62      private String email = "";
63  
64      private String xmlId = "";
65  
66      private String languageCode = java.util.Locale.ENGLISH.getLanguage();
67  
68      private String password = "";
69  
70      private String resetPassword = "";
71      
72      private String club = "";
73      
74      private boolean systemAdmin = false;
75  
76      @OneToOne
77      private AddressEntity address;;
78  
79      private String url = "";
80  
81      public String getFirstName() {
82          return firstName;
83      }
84  
85      public void setFirstName(String firstName) {
86          this.firstName = firstName;
87      }
88  
89      public String getLastName() {
90          return lastName;
91      }
92  
93      public void setLastName(String lastName) {
94          this.lastName = lastName;
95      }
96  
97      public String getSex() {
98          return sex;
99      }
100 
101     public void setSex(String sex) {
102         this.sex = sex;
103     }
104 
105     public AddressEntity getAddress() {
106         return address;
107     }
108 
109     public void setAddress(AddressEntity address) {
110         this.address = address;
111     }
112 
113     public String getEmail() {
114         return email;
115     }
116 
117     public void setEmail(String email) {
118         this.email = email;
119     }
120 
121     public long getId() {
122         return id;
123     }
124 
125     public void setId(long id) {
126         this.id = id;
127     }
128 
129     public String getTel() {
130         return tel;
131     }
132 
133     public void setTel(String tel) {
134         this.tel = tel;
135     }
136 
137     public String getUrl() {
138         return url;
139     }
140 
141     public void setUrl(String url) {
142         this.url = url;
143     }
144 
145     public String getXmlId() {
146         return xmlId;
147     }
148 
149     public void setXmlId(String xmlId) {
150         this.xmlId = xmlId;
151     }
152 
153     public String getMobile() {
154         return mobile;
155     }
156 
157     public void setMobile(String mobile) {
158         this.mobile = mobile;
159     }
160 
161     public String getPassword() {
162         return password;
163     }
164 
165     public void setPassword(String password) {
166         this.password = password;
167     }
168 
169     public String getResetPassword() {
170         return resetPassword;
171     }
172 
173     public void setResetPassword(String resetPassword) {
174         this.resetPassword = resetPassword;
175     }
176 
177     public String getLanguageCode() {
178         return languageCode;
179     }
180 
181     public void setLanguageCode(String languageCode) {
182         this.languageCode = languageCode;
183     }
184 
185     /**
186      * Override the Object method to give a usable human readable 
187      * representation of the Object.
188      */
189     public String toString(){
190         return (firstName + " " + lastName).trim();
191     }
192 
193     public boolean getSystemAdmin() {
194         return systemAdmin;
195     }
196 
197     public void setSystemAdmin(boolean systemAdmin) {
198         this.systemAdmin = systemAdmin;
199     }
200 
201     public String getClub() {
202         return club;
203     }
204 
205     public void setClub(String club) {
206         this.club = club;
207     }
208     
209 }