001: /*
002: * Speedo: an implementation of JDO compliant personality on top of JORM
003: * generic I/O sub-system. Copyright (C) 2001-2004 France Telecom R&D
004: *
005: * This library is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU Lesser General Public License as published by the
007: * Free Software Foundation; either version 2 of the License, or (at your
008: * option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful, but WITHOUT
011: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
013: * for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public License
016: * along with this library; if not, write to the Free Software Foundation,
017: * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018: *
019: * Release: 1.0
020: *
021: * Created on 27 feb. 2004 @author franck.milleville@cgey.com
022: *
023: */
024: package org.objectweb.speedo.j2eedo.database;
025:
026: import java.util.Collection;
027: import java.util.Date;
028: import java.util.Iterator;
029:
030: /**
031: * This class define the Java class to access to the employee's data
032: * @author franck.milleville @cgey.com
033: *
034: */
035: public class Employee implements DatabaseObjectInterface {
036: private long empid;
037: private String firstname;
038: private String lastname;
039: private Address address;
040: private Date birthdate;
041: private Date hiredate;
042: private float salary;
043: private Department department;
044: private Employee manager;
045: private Collection slaves;
046: private Collection projects; //element:Project
047:
048: /**
049: * @param firstname
050: * @param lastname
051: * @param birthdate
052: * @param department
053: */
054: public Employee(String firstname, String lastname, Date birthdate,
055: Department department) {
056: super ();
057: this .firstname = firstname;
058: this .lastname = lastname;
059: this .birthdate = birthdate;
060: this .department = department;
061: this .hiredate = new Date();
062: }
063:
064: /**
065: * @param firstname
066: * @param lastname
067: * @param address
068: * @param birthdate
069: * @param hiredate
070: * @param salary
071: * @param department
072: * @param manager
073: * @param projects
074: */
075: public Employee(String firstname, String lastname, Address address,
076: Date birthdate, Date hiredate, float salary,
077: Department department, Employee manager, Collection projects) {
078: super ();
079: this .firstname = firstname;
080: this .lastname = lastname;
081: this .address = address;
082: this .birthdate = birthdate;
083: this .hiredate = hiredate;
084: this .salary = salary;
085: this .department = department;
086: this .manager = manager;
087: this .projects = projects;
088: }
089:
090: /**
091: * Empty constructor
092: */
093: public Employee() {
094: super ();
095: }
096:
097: public String getAsString() {
098: StringBuffer sb = new StringBuffer();
099: sb.append("\nEmployee\t(empid:").append(this .empid);
100: sb.append(" department:").append(this .department.getName());
101: sb.append(")\n\tFirst name:").append(this .firstname);
102: sb.append("\tlast name:").append(this .lastname);
103: sb.append("\tbirthdate:").append(this .birthdate);
104: sb.append("\tmanager:");
105: if (null != this .manager)
106: sb.append(this .manager.getLastname());
107: else
108: sb.append("No manager");
109: sb.append("\tsalary:").append(this .salary);
110: sb.append("\thire date:").append(this .hiredate);
111: sb.append("\n\tadsress:").append(this .address.getAsString());
112: if (this .projects != null) {
113: Iterator i = projects.iterator();
114: if (i.hasNext()) {
115: sb.append("\tMember of projects:");
116: }
117: while (i.hasNext()) {
118: sb.append(((Project) i.next()).getName()).append(" ");
119: }
120: }
121: return sb.toString();
122: }
123:
124: /**
125: * @see org.objectweb.speedo.j2eedo.database.DatabaseObjectInterface#getId()
126: */
127: public long getId() {
128: return this .empid;
129: }
130:
131: /**
132: * @return Returns the empid.
133: */
134: public long getEmpid() {
135: return empid;
136: }
137:
138: /**
139: * @return Returns the hiredate.
140: */
141: public Date getHiredate() {
142: return hiredate;
143: }
144:
145: /**
146: * @param hiredate
147: * The hiredate to set.
148: */
149: public void setHiredate(Date hiredate) {
150: this .hiredate = hiredate;
151: }
152:
153: /**
154: * @return Returns the lastname.
155: */
156: public String getLastname() {
157: return lastname;
158: }
159:
160: /**
161: * @param lastname
162: * The lastname to set.
163: */
164: public void setLastname(String lastname) {
165: this .lastname = lastname;
166: }
167:
168: /**
169: * @return Returns the manager.
170: */
171: public Employee getManager() {
172: return manager;
173: }
174:
175: /**
176: * @param manager
177: * The manager to set.
178: */
179: public void setManager(Employee manager) {
180: this .manager = manager;
181: }
182:
183: /**
184: * @return Returns the projects.
185: */
186: public Collection getProjects() {
187: return projects;
188: }
189:
190: /**
191: * @param projects
192: * The projects to set.
193: */
194: public void setProjects(Collection projects) {
195: this .projects.addAll(projects);
196: }
197:
198: /**
199: * @return Returns the salary.
200: */
201: public float getSalary() {
202: return salary;
203: }
204:
205: /**
206: * @param salary
207: * The salary to set.
208: */
209: public void setSalary(float salary) {
210: this .salary = salary;
211: }
212:
213: /**
214: * @return Returns the address.
215: */
216: public Address getAddress() {
217: return address;
218: }
219:
220: /**
221: * @param address
222: * The address to set.
223: */
224: public void setAddress(Address address) {
225: this .address = address;
226: }
227:
228: /**
229: * @return Returns the birthdate.
230: */
231: public Date getBirthdate() {
232: return birthdate;
233: }
234:
235: /**
236: * @param birthdate
237: * The birthdate to set.
238: */
239: public void setBirthdate(Date birthdate) {
240: this .birthdate = birthdate;
241: }
242:
243: /**
244: * @return Returns the department.
245: */
246: public Department getDepartment() {
247: return department;
248: }
249:
250: /**
251: * @param department
252: * The department to set.
253: */
254: public void setDepartment(Department department) {
255: this .department = department;
256: }
257:
258: /**
259: * @return Returns the firstname.
260: */
261: public String getFirstname() {
262: return firstname;
263: }
264:
265: /**
266: * @param firstname
267: * The firstname to set.
268: */
269: public void setFirstname(String firstname) {
270: this.firstname = firstname;
271: }
272: }
|