KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > speedo > j2eedo > database > Employee


1 /*
2  * Speedo: an implementation of JDO compliant personality on top of JORM
3  * generic I/O sub-system. Copyright (C) 2001-2004 France Telecom R&D
4  *
5  * This library is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13  * for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Release: 1.0
20  *
21  * Created on 27 f�vr. 2004 @author franck.milleville@cgey.com
22  *
23  */

24 package org.objectweb.speedo.j2eedo.database;
25
26 import java.util.Collection JavaDoc;
27 import java.util.Date JavaDoc;
28 import java.util.Iterator JavaDoc;
29
30 /**
31  * This class define the Java class to access to the employee's data
32  * @author franck.milleville @cgey.com
33  *
34  */

35 public class Employee implements DatabaseObjectInterface {
36     private long empid;
37     private String JavaDoc firstname;
38     private String JavaDoc lastname;
39     private Address address;
40     private Date JavaDoc birthdate;
41     private Date JavaDoc hiredate;
42     private float salary;
43     private Department department;
44     private Employee manager;
45     private Collection JavaDoc slaves;
46     private Collection JavaDoc projects; //element:Project
47

48
49     /**
50      * @param firstname
51      * @param lastname
52      * @param birthdate
53      * @param department
54      */

55     public Employee(
56         String JavaDoc firstname,
57         String JavaDoc lastname,
58         Date JavaDoc birthdate,
59         Department department) {
60         super();
61         this.firstname = firstname;
62         this.lastname = lastname;
63         this.birthdate = birthdate;
64         this.department = department;
65         this.hiredate = new Date JavaDoc();
66     }
67     /**
68      * @param firstname
69      * @param lastname
70      * @param address
71      * @param birthdate
72      * @param hiredate
73      * @param salary
74      * @param department
75      * @param manager
76      * @param projects
77      */

78     public Employee(
79         String JavaDoc firstname,
80         String JavaDoc lastname,
81         Address address,
82         Date JavaDoc birthdate,
83         Date JavaDoc hiredate,
84         float salary,
85         Department department,
86         Employee manager,
87         Collection JavaDoc projects) {
88         super();
89         this.firstname = firstname;
90         this.lastname = lastname;
91         this.address = address;
92         this.birthdate = birthdate;
93         this.hiredate = hiredate;
94         this.salary = salary;
95         this.department = department;
96         this.manager = manager;
97         this.projects = projects;
98     }
99     /**
100      * Empty constructor
101      */

102     public Employee() {
103         super();
104     }
105     public String JavaDoc getAsString() {
106         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
107         sb.append("\nEmployee\t(empid:").append(this.empid);
108         sb.append(" department:").append(this.department.getName());
109         sb.append(")\n\tFirst name:").append(this.firstname);
110         sb.append("\tlast name:").append(this.lastname);
111         sb.append("\tbirthdate:").append(this.birthdate);
112         sb.append("\tmanager:");
113         if (null != this.manager)
114             sb.append(this.manager.getLastname());
115         else
116             sb.append("No manager");
117         sb.append("\tsalary:").append(this.salary);
118         sb.append("\thire date:").append(this.hiredate);
119         sb.append("\n\tadsress:").append(this.address.getAsString());
120         if (this.projects != null) {
121             Iterator JavaDoc i = projects.iterator();
122             if (i.hasNext()) {
123                 sb.append("\tMember of projects:");
124             }
125             while (i.hasNext()) {
126                 sb.append(((Project) i.next()).getName()).append(" ");
127             }
128         }
129         return sb.toString();
130     }
131     /**
132      * @see org.objectweb.speedo.j2eedo.database.DatabaseObjectInterface#getId()
133      */

134     public long getId() {
135         return this.empid;
136     }
137
138     /**
139      * @return Returns the empid.
140      */

141     public long getEmpid() {
142         return empid;
143     }
144
145     /**
146      * @return Returns the hiredate.
147      */

148     public Date JavaDoc getHiredate() {
149         return hiredate;
150     }
151
152     /**
153      * @param hiredate
154      * The hiredate to set.
155      */

156     public void setHiredate(Date JavaDoc hiredate) {
157         this.hiredate = hiredate;
158     }
159
160     /**
161      * @return Returns the lastname.
162      */

163     public String JavaDoc getLastname() {
164         return lastname;
165     }
166
167     /**
168      * @param lastname
169      * The lastname to set.
170      */

171     public void setLastname(String JavaDoc lastname) {
172         this.lastname = lastname;
173     }
174
175     /**
176      * @return Returns the manager.
177      */

178     public Employee getManager() {
179         return manager;
180     }
181
182     /**
183      * @param manager
184      * The manager to set.
185      */

186     public void setManager(Employee manager) {
187         this.manager = manager;
188     }
189
190     /**
191      * @return Returns the projects.
192      */

193     public Collection JavaDoc getProjects() {
194         return projects;
195     }
196
197     /**
198      * @param projects
199      * The projects to set.
200      */

201     public void setProjects(Collection JavaDoc projects) {
202         this.projects.addAll(projects);
203     }
204
205     /**
206      * @return Returns the salary.
207      */

208     public float getSalary() {
209         return salary;
210     }
211
212     /**
213      * @param salary
214      * The salary to set.
215      */

216     public void setSalary(float salary) {
217         this.salary = salary;
218     }
219     /**
220      * @return Returns the address.
221      */

222     public Address getAddress() {
223         return address;
224     }
225
226     /**
227      * @param address
228      * The address to set.
229      */

230     public void setAddress(Address address) {
231         this.address = address;
232     }
233
234     /**
235      * @return Returns the birthdate.
236      */

237     public Date JavaDoc getBirthdate() {
238         return birthdate;
239     }
240
241     /**
242      * @param birthdate
243      * The birthdate to set.
244      */

245     public void setBirthdate(Date JavaDoc birthdate) {
246         this.birthdate = birthdate;
247     }
248
249     /**
250      * @return Returns the department.
251      */

252     public Department getDepartment() {
253         return department;
254     }
255
256     /**
257      * @param department
258      * The department to set.
259      */

260     public void setDepartment(Department department) {
261         this.department = department;
262     }
263
264     /**
265      * @return Returns the firstname.
266      */

267     public String JavaDoc getFirstname() {
268         return firstname;
269     }
270
271     /**
272      * @param firstname
273      * The firstname to set.
274      */

275     public void setFirstname(String JavaDoc firstname) {
276         this.firstname = firstname;
277     }
278 }
Popular Tags