1 24 package org.objectweb.speedo.j2eedo.database; 25 26 import java.util.Collection ; 27 import java.util.Date ; 28 import java.util.Iterator ; 29 30 35 public class Employee implements DatabaseObjectInterface { 36 private long empid; 37 private String firstname; 38 private String lastname; 39 private Address address; 40 private Date birthdate; 41 private Date hiredate; 42 private float salary; 43 private Department department; 44 private Employee manager; 45 private Collection slaves; 46 private Collection projects; 48 49 55 public Employee( 56 String firstname, 57 String lastname, 58 Date 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 (); 66 } 67 78 public Employee( 79 String firstname, 80 String lastname, 81 Address address, 82 Date birthdate, 83 Date hiredate, 84 float salary, 85 Department department, 86 Employee manager, 87 Collection 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 102 public Employee() { 103 super(); 104 } 105 public String getAsString() { 106 StringBuffer sb = new StringBuffer (); 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 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 134 public long getId() { 135 return this.empid; 136 } 137 138 141 public long getEmpid() { 142 return empid; 143 } 144 145 148 public Date getHiredate() { 149 return hiredate; 150 } 151 152 156 public void setHiredate(Date hiredate) { 157 this.hiredate = hiredate; 158 } 159 160 163 public String getLastname() { 164 return lastname; 165 } 166 167 171 public void setLastname(String lastname) { 172 this.lastname = lastname; 173 } 174 175 178 public Employee getManager() { 179 return manager; 180 } 181 182 186 public void setManager(Employee manager) { 187 this.manager = manager; 188 } 189 190 193 public Collection getProjects() { 194 return projects; 195 } 196 197 201 public void setProjects(Collection projects) { 202 this.projects.addAll(projects); 203 } 204 205 208 public float getSalary() { 209 return salary; 210 } 211 212 216 public void setSalary(float salary) { 217 this.salary = salary; 218 } 219 222 public Address getAddress() { 223 return address; 224 } 225 226 230 public void setAddress(Address address) { 231 this.address = address; 232 } 233 234 237 public Date getBirthdate() { 238 return birthdate; 239 } 240 241 245 public void setBirthdate(Date birthdate) { 246 this.birthdate = birthdate; 247 } 248 249 252 public Department getDepartment() { 253 return department; 254 } 255 256 260 public void setDepartment(Department department) { 261 this.department = department; 262 } 263 264 267 public String getFirstname() { 268 return firstname; 269 } 270 271 275 public void setFirstname(String firstname) { 276 this.firstname = firstname; 277 } 278 } | Popular Tags |