KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > projectmanagement > business > employee > EmployeeImpl


1 package projectmanagement.business.employee;
2
3 import projectmanagement.business.ProjectManagementBusinessException;
4 import projectmanagement.data.employee.*;
5 import com.lutris.appserver.server.sql.DatabaseManagerException;
6 import com.lutris.appserver.server.sql.ObjectIdException;
7 import com.lutris.dods.builder.generator.query.DataObjectException;
8
9 import projectmanagement.spec.employee.*;
10
11 import java.sql.Date JavaDoc;
12
13 /**
14  * Represents an employee.
15  *
16  * @author Sasa Bojanic
17  * @version 1.0
18  */

19 public class EmployeeImpl implements Employee,java.io.Serializable JavaDoc {
20    /**
21     * The DO of the Employee.
22     */

23    protected EmployeeDO myDO = null;
24
25    /**
26     * The public constructor.
27     */

28    public EmployeeImpl() throws ProjectManagementBusinessException {
29       try {
30          this.myDO = EmployeeDO.createVirgin();
31       } catch(DatabaseManagerException ex) {
32          throw new ProjectManagementBusinessException("Error creating empty employee", ex);
33       } catch(ObjectIdException ex) {
34          throw new ProjectManagementBusinessException("Error creating object ID for employee", ex);
35       }
36    }
37
38    /** The public constructor
39     *
40     * @param theEmployee. The data object of the employee.
41     */

42    public EmployeeImpl(EmployeeDO theEmployee) {
43       this.myDO = theEmployee;
44    }
45
46    /**
47     * Gets the DO object for the employee
48     *
49     * @return the DO object.
50     * @exception ProjectManagementBusinessException if an error occurs
51     * retrieving data.
52     */

53    public EmployeeDO getDO()
54          throws ProjectManagementBusinessException {
55       if (this.myDO!=null) {
56          return this.myDO;
57       } else {
58          throw new ProjectManagementBusinessException("Error getting DO object for employee");
59       }
60    }
61
62    /**
63     * Gets the object id for the employee
64     *
65     * @return the object id.
66     * @exception ProjectManagementBusinessException if an error occurs
67     * retrieving data (usually due to an underlying data layer
68     * error).
69     */

70    public String JavaDoc getHandle()
71       throws ProjectManagementBusinessException {
72       try {
73          return this.myDO.getHandle();
74       } catch(DatabaseManagerException ex) {
75          throw new ProjectManagementBusinessException("Error getting handle for employee", ex);
76       }
77    }
78
79    public int getAuthLevel () {
80       try {
81          boolean isAdmin=getIsAdmin();
82          if (isAdmin) {
83             return 2;
84          } else {
85             return 1;
86          }
87       } catch (Exception JavaDoc ex) {
88          return 0;
89       }
90    }
91
92    /**
93     * Sets the login name for the employee.
94     *
95     * @param the login name.
96     * @exception ProjectManagementBusinessException if an error occurs
97     * setting the data (usually due to an underlying data layer
98     * error).
99     */

100    public void setLogin(String JavaDoc login)
101       throws ProjectManagementBusinessException {
102       try {
103          myDO.setLogin(login);
104       } catch(DataObjectException ex) {
105          throw new ProjectManagementBusinessException("Error setting user's login name", ex);
106       }
107    }
108
109    /**
110     * Gets the login name for the employee
111     *
112     * @return the login name.
113     * @exception ProjectManagementBusinessException if an error occurs
114     * retrieving data (usually due to an underlying data layer
115     * error).
116     */

117    public String JavaDoc getLogin()
118       throws ProjectManagementBusinessException {
119       try {
120          return myDO.getLogin();
121       } catch(DataObjectException ex) {
122          throw new ProjectManagementBusinessException("Error getting user's login name", ex);
123       }
124    }
125
126    /**
127     * Sets the password for the employee.
128     *
129     * @param the password.
130     * @exception ProjectManagementBusinessException if an error occurs
131     * setting the data (usually due to an underlying data layer
132     * error).
133     */

134    public void setPassword(String JavaDoc password)
135       throws ProjectManagementBusinessException {
136       try {
137          myDO.setPassword(password);
138       } catch(DataObjectException ex) {
139          throw new ProjectManagementBusinessException("Error setting user's password", ex);
140       }
141    }
142
143    /**
144     * Gets the password for the employee
145     *
146     * @return the password.
147     * @exception ProjectManagementBusinessException if an error occurs
148     * retrieving data (usually due to an underlying data layer
149     * error).
150     */

151    public String JavaDoc getPassword()
152       throws ProjectManagementBusinessException {
153       try {
154          return myDO.getPassword();
155       } catch(DataObjectException ex) {
156          throw new ProjectManagementBusinessException("Error getting user's password", ex);
157       }
158    }
159
160    /**
161     * Sets the firstname for the employee.
162     *
163     * @param the firstname.
164     * @exception ProjectManagementBusinessException if an error occurs
165     * setting the data (usually due to an underlying data layer
166     * error).
167     */

168    public void setFirstName(String JavaDoc firstname)
169       throws ProjectManagementBusinessException {
170       try {
171          myDO.setFirstName(firstname);
172       } catch(DataObjectException ex) {
173          throw new ProjectManagementBusinessException("Error setting user's first name", ex);
174       }
175    }
176
177    /**
178     * Gets the firstname for the employee
179     *
180     * @return the firstname.
181     * @exception ProjectManagementBusinessException if an error occurs
182     * retrieving data (usually due to an underlying data layer
183     * error).
184     */

185    public String JavaDoc getFirstName()
186       throws ProjectManagementBusinessException {
187       try {
188          return myDO.getFirstName();
189       } catch(DataObjectException ex) {
190          throw new ProjectManagementBusinessException("Error getting user's first name", ex);
191       }
192    }
193
194    /**
195     * Sets the lastname for the employee.
196     *
197     * @param the lastname.
198     * @exception ProjectManagementBusinessException if an error occurs
199     * setting the data (usually due to an underlying data layer
200     * error).
201     */

202    public void setLastName(String JavaDoc lastname)
203       throws ProjectManagementBusinessException {
204       try {
205          myDO.setLastName(lastname);
206       } catch(DataObjectException ex) {
207          throw new ProjectManagementBusinessException("Error setting user's last name", ex);
208       }
209    }
210
211    /**
212     * Gets the lastname for the employee
213     *
214     * @return the lastname.
215     * @exception ProjectManagementBusinessException if an error occurs
216     * retrieving data (usually due to an underlying data layer
217     * error).
218     */

219    public String JavaDoc getLastName()
220       throws ProjectManagementBusinessException {
221       try {
222          return myDO.getLastName();
223       } catch(DataObjectException ex) {
224          throw new ProjectManagementBusinessException("Error getting user's last name", ex);
225       }
226    }
227
228    /**
229     * Sets the title for the employee.
230     *
231     * @param the title.
232     * @exception ProjectManagementBusinessException if an error occurs
233     * setting the data (usually due to an underlying data layer
234     * error).
235     */

236    public void setTitle(String JavaDoc title)
237       throws ProjectManagementBusinessException {
238       try {
239          myDO.setTitle(title);
240       } catch(DataObjectException ex) {
241          throw new ProjectManagementBusinessException("Error setting user's title", ex);
242       }
243    }
244
245    /**
246     * Gets the title for the employee
247     *
248     * @return the title.
249     * @exception ProjectManagementBusinessException if an error occurs
250     * retrieving data (usually due to an underlying data layer
251     * error).
252     */

253    public String JavaDoc getTitle()
254       throws ProjectManagementBusinessException {
255       try {
256          return myDO.getTitle();
257       } catch(DataObjectException ex) {
258          throw new ProjectManagementBusinessException("Error getting user's title", ex);
259       }
260    }
261
262    /**
263     * Sets the title of courtesy for the employee.
264     *
265     * @param the title of courtesy.
266     * @exception ProjectManagementBusinessException if an error occurs
267     * setting the data (usually due to an underlying data layer
268     * error).
269     */

270    public void setTitleOfCourtesy(String JavaDoc titleOfCourtesy)
271       throws ProjectManagementBusinessException {
272       try {
273          myDO.setTitleOfCourtesy(titleOfCourtesy);
274       } catch(DataObjectException ex) {
275          throw new ProjectManagementBusinessException("Error setting user's title of courtesy", ex);
276       }
277    }
278
279    /**
280     * Gets the title of courtesy for the employee
281     *
282     * @return the title of courtesy.
283     * @exception ProjectManagementBusinessException if an error occurs
284     * retrieving data (usually due to an underlying data layer
285     * error).
286     */

287    public String JavaDoc getTitleOfCourtesy()
288       throws ProjectManagementBusinessException {
289       try {
290          return myDO.getTitleOfCourtesy();
291       } catch(DataObjectException ex) {
292          throw new ProjectManagementBusinessException("Error getting user's title of courtesy", ex);
293       }
294    }
295
296    /**
297     * Sets the birth date for the employee.
298     *
299     * @param the birth date.
300     * @exception ProjectManagementBusinessException if an error occurs
301     * setting the data (usually due to an underlying data layer
302     * error).
303     */

304    public void setBirthDate(Date JavaDoc birthDate)
305       throws ProjectManagementBusinessException {
306       try {
307          myDO.setBirthDate(birthDate);
308       } catch(DataObjectException ex) {
309          throw new ProjectManagementBusinessException("Error setting user's birth date", ex);
310       }
311    }
312
313    /**
314     * Gets the birth date for the employee
315     *
316     * @return the birth date.
317     * @exception ProjectManagementBusinessException if an error occurs
318     * retrieving data (usually due to an underlying data layer
319     * error).
320     */

321    public Date JavaDoc getBirthDate()
322       throws ProjectManagementBusinessException {
323       try {
324          return myDO.getBirthDate();
325       } catch(DataObjectException ex) {
326          throw new ProjectManagementBusinessException("Error getting user's birth date", ex);
327       }
328    }
329
330    /**
331     * Sets the hire date for the employee.
332     *
333     * @param the hire date.
334     * @exception ProjectManagementBusinessException if an error occurs
335     * setting the data (usually due to an underlying data layer
336     * error).
337     */

338    public void setHireDate(Date JavaDoc hireDate)
339       throws ProjectManagementBusinessException {
340       try {
341          myDO.setHireDate(hireDate);
342       } catch(DataObjectException ex) {
343          throw new ProjectManagementBusinessException("Error setting user's hire date", ex);
344       }
345    }
346
347    /**
348     * Gets the hire date for the employee
349     *
350     * @return the hire date.
351     * @exception ProjectManagementBusinessException if an error occurs
352     * retrieving data (usually due to an underlying data layer
353     * error).
354     */

355    public Date JavaDoc getHireDate()
356       throws ProjectManagementBusinessException {
357       try {
358          return myDO.getHireDate();
359       } catch(DataObjectException ex) {
360          throw new ProjectManagementBusinessException("Error getting user's hire date", ex);
361       }
362    }
363
364    /**
365     * Sets the address for the customer.
366     *
367     * @param the address.
368     * @exception ProjectManagementBusinessException if an error occurs
369     * setting the data (usually due to an underlying data layer
370     * error).
371     */

372    public void setAddress(String JavaDoc address)
373       throws ProjectManagementBusinessException {
374       try {
375          myDO.setAddress(address);
376       } catch(DataObjectException ex) {
377          throw new ProjectManagementBusinessException("Error setting address", ex);
378       }
379    }
380
381    /**
382     * Gets the address.
383     *
384     * @return the address.
385     * @exception ProjectManagementBusinessException if an error occurs
386     * retrieving data (usually due to an underlying data layer
387     * error).
388     */

389    public String JavaDoc getAddress()
390       throws ProjectManagementBusinessException {
391       try {
392          return myDO.getAddress();
393       } catch(DataObjectException ex) {
394          throw new ProjectManagementBusinessException("Error getting address", ex);
395       }
396    }
397
398    /**
399     * Sets the employee's city.
400     *
401     * @param the employee's city.
402     * @exception ProjectManagementBusinessException if an error occurs
403     * setting the data (usually due to an underlying data layer
404     * error).
405     */

406    public void setCity(String JavaDoc city)
407       throws ProjectManagementBusinessException {
408       try {
409          myDO.setCity(city);
410       } catch(DataObjectException ex) {
411          throw new ProjectManagementBusinessException("Error setting city", ex);
412       }
413    }
414
415    /**
416     * Gets the employee city.
417     *
418     * @return the employee city.
419     * @exception ProjectManagementBusinessException if an error occurs
420     * retrieving data (usually due to an underlying data layer
421     * error).
422     */

423    public String JavaDoc getCity()
424       throws ProjectManagementBusinessException {
425       try {
426          return myDO.getCity();
427       } catch(DataObjectException ex) {
428          throw new ProjectManagementBusinessException("Error getting employee city", ex);
429       }
430    }
431
432    /**
433     * Sets the employee's region.
434     *
435     * @param the employee's region.
436     * @exception ProjectManagementBusinessException if an error occurs
437     * setting the data (usually due to an underlying data layer
438     * error).
439     */

440    public void setRegion(String JavaDoc region)
441       throws ProjectManagementBusinessException {
442       try {
443          myDO.setRegion(region);
444       } catch(DataObjectException ex) {
445          throw new ProjectManagementBusinessException("Error setting region", ex);
446       }
447    }
448
449    /**
450     * Gets the employee's region.
451     *
452     * @return the employee region.
453     * @exception ProjectManagementBusinessException if an error occurs
454     * retrieving data (usually due to an underlying data layer
455     * error).
456     */

457    public String JavaDoc getRegion()
458       throws ProjectManagementBusinessException {
459       try {
460          return myDO.getRegion();
461       } catch(DataObjectException ex) {
462          throw new ProjectManagementBusinessException("Error getting employee region", ex);
463       }
464    }
465
466    /**
467     * Sets the employee's postal code.
468     *
469     * @param the employee's postal code.
470     * @exception ProjectManagementBusinessException if an error occurs
471     * setting the data (usually due to an underlying data layer
472     * error).
473     */

474    public void setPostalCode(String JavaDoc postalCode)
475       throws ProjectManagementBusinessException {
476       try {
477          myDO.setPostalCode(postalCode);
478       } catch(DataObjectException ex) {
479          throw new ProjectManagementBusinessException("Error setting postal code", ex);
480       }
481    }
482
483    /**
484     * Gets the employee's postal code.
485     *
486     * @return the employee postal code.
487     * @exception ProjectManagementBusinessException if an error occurs
488     * retrieving data (usually due to an underlying data layer
489     * error).
490     */

491    public String JavaDoc getPostalCode()
492       throws ProjectManagementBusinessException {
493       try {
494          return myDO.getPostalCode();
495       } catch(DataObjectException ex) {
496          throw new ProjectManagementBusinessException("Error getting employee postal code", ex);
497       }
498    }
499
500    /**
501     * Sets the employee's country.
502     *
503     * @param the employee's country.
504     * @exception ProjectManagementBusinessException if an error occurs
505     * setting the data (usually due to an underlying data layer
506     * error).
507     */

508    public void setCountry(String JavaDoc country)
509       throws ProjectManagementBusinessException {
510       try {
511          myDO.setCountry(country);
512       } catch(DataObjectException ex) {
513          throw new ProjectManagementBusinessException("Error setting country", ex);
514       }
515    }
516
517    /**
518     * Gets the employee's country.
519     *
520     * @return the employee country.
521     * @exception ProjectManagementBusinessException if an error occurs
522     * retrieving data (usually due to an underlying data layer
523     * error).
524     */

525    public String JavaDoc getCountry()
526       throws ProjectManagementBusinessException {
527       try {
528          return myDO.getCountry();
529       } catch(DataObjectException ex) {
530          throw new ProjectManagementBusinessException("Error getting employee country", ex);
531       }
532    }
533
534    /**
535     * Sets the employee's home phone.
536     *
537     * @param the employee's home phone.
538     * @exception ProjectManagementBusinessException if an error occurs
539     * setting the data (usually due to an underlying data layer
540     * error).
541     */

542    public void setHomePhone(String JavaDoc homePhone)
543       throws ProjectManagementBusinessException {
544       try {
545          myDO.setHomePhone(homePhone);
546       } catch(DataObjectException ex) {
547          throw new ProjectManagementBusinessException("Error setting home phone", ex);
548       }
549    }
550
551    /**
552     * Gets the employee's home phone.
553     *
554     * @return the employee home phone.
555     * @exception ProjectManagementBusinessException if an error occurs
556     * retrieving data (usually due to an underlying data layer
557     * error).
558     */

559    public String JavaDoc getHomePhone()
560       throws ProjectManagementBusinessException {
561       try {
562          return myDO.getHomePhone();
563       } catch(DataObjectException ex) {
564          throw new ProjectManagementBusinessException("Error getting employee home phone", ex);
565       }
566    }
567
568    /**
569     * Sets the employee's mobile phone.
570     *
571     * @param the employee's mobile phone.
572     * @exception ProjectManagementBusinessException if an error occurs
573     * setting the data (usually due to an underlying data layer
574     * error).
575     */

576    public void setMobilePhone(String JavaDoc mobilePhone)
577       throws ProjectManagementBusinessException {
578       try {
579          myDO.setMobilePhone(mobilePhone);
580       } catch(DataObjectException ex) {
581          throw new ProjectManagementBusinessException("Error setting mobile phone", ex);
582       }
583    }
584
585    /**
586     * Gets the employee's mobile phone.
587     *
588     * @return the employee mobile phone.
589     * @exception ProjectManagementBusinessException if an error occurs
590     * retrieving data (usually due to an underlying data layer
591     * error).
592     */

593    public String JavaDoc getMobilePhone()
594       throws ProjectManagementBusinessException {
595       try {
596          return myDO.getMobilePhone();
597       } catch(DataObjectException ex) {
598          throw new ProjectManagementBusinessException("Error getting employee mobile phone", ex);
599       }
600    }
601
602    /**
603     * Sets the employee's email.
604     *
605     * @param the employee's email.
606     * @exception ProjectManagementBusinessException if an error occurs
607     * setting the data (usually due to an underlying data layer
608     * error).
609     */

610    public void setEmail(String JavaDoc email)
611       throws ProjectManagementBusinessException {
612       try {
613          myDO.setEmail(email);
614       } catch(DataObjectException ex) {
615          throw new ProjectManagementBusinessException("Error setting email", ex);
616       }
617    }
618
619    /**
620     * Gets the employee's email.
621     *
622     * @return the employee email.
623     * @exception ProjectManagementBusinessException if an error occurs
624     * retrieving data (usually due to an underlying data layer
625     * error).
626     */

627    public String JavaDoc getEmail()
628       throws ProjectManagementBusinessException {
629       try {
630          return myDO.getEmail();
631       } catch(DataObjectException ex) {
632          throw new ProjectManagementBusinessException("Error getting employee email", ex);
633       }
634    }
635
636    /**
637     * Sets the employee's notes.
638     *
639     * @param the employee's notes.
640     * @exception ProjectManagementBusinessException if an error occurs
641     * setting the data (usually due to an underlying data layer
642     * error).
643     */

644    public void setNotes(String JavaDoc notes)
645       throws ProjectManagementBusinessException {
646       try {
647          myDO.setNotes(notes);
648       } catch(DataObjectException ex) {
649          throw new ProjectManagementBusinessException("Error setting notes", ex);
650       }
651    }
652
653    /**
654     * Gets the employee's notes.
655     *
656     * @return the employee notes.
657     * @exception ProjectManagementBusinessException if an error occurs
658     * retrieving data (usually due to an underlying data layer
659     * error).
660     */

661    public String JavaDoc getNotes()
662       throws ProjectManagementBusinessException {
663       try {
664          return myDO.getNotes();
665       } catch(DataObjectException ex) {
666          throw new ProjectManagementBusinessException("Error getting employee notes", ex);
667       }
668    }
669
670    /**
671     * Sets the flag that indicates if employee is admin.
672     *
673     * @param isAdmin Indication if employee is admin.
674     * @exception ProjectManagementBusinessException if an error occurs
675     * setting the data (usually due to an underlying data layer
676     * error).
677     */

678    public void setIsAdmin(boolean isAdmin)
679       throws ProjectManagementBusinessException {
680       try {
681          myDO.setIsAdmin(isAdmin);
682       } catch(DataObjectException ex) {
683          throw new ProjectManagementBusinessException("Error setting administration flag", ex);
684       }
685    }
686
687    /**
688     * Returns true if the employee is admin.
689     *
690     * @return true if the employee is admin.
691     * @exception ProjectManagementBusinessException if an error occurs
692     * retrieving data (usually due to an underlying data layer
693     * error).
694     */

695    public boolean getIsAdmin()
696       throws ProjectManagementBusinessException {
697       try {
698          return myDO.getIsAdmin();
699       } catch(DataObjectException ex) {
700          throw new ProjectManagementBusinessException("Error getting indication if th user is admin", ex);
701       }
702    }
703
704    /**
705     * Commits all changes to the database.
706     *
707     * @exception ProjectManagementBusinessException if an error occurs
708     * retrieving data (usually due to an underlying data layer
709     * error).
710     */

711    public void save() throws ProjectManagementBusinessException {
712       try {
713          this.myDO.commit();
714       } catch(Exception JavaDoc ex) {
715          throw new ProjectManagementBusinessException("Error saving employee", ex);
716       }
717    }
718
719    /**
720     * Deletes the employee from database.
721     *
722     * @exception ProjectManagementBusinessException if an error occurs
723     * deleting data (usually due to an underlying data layer
724     * error).
725     */

726    public void delete() throws ProjectManagementBusinessException {
727       try {
728          this.myDO.delete();
729       } catch(Exception JavaDoc ex) {
730          throw new ProjectManagementBusinessException("Error deleting employee", ex);
731       }
732    }
733
734 }
735
Popular Tags