001: package projectmanagement.business.employee;
002:
003: import projectmanagement.business.ProjectManagementBusinessException;
004: import projectmanagement.data.employee.*;
005: import com.lutris.appserver.server.sql.DatabaseManagerException;
006: import com.lutris.appserver.server.sql.ObjectIdException;
007: import com.lutris.dods.builder.generator.query.DataObjectException;
008:
009: import projectmanagement.spec.employee.*;
010:
011: import java.sql.Date;
012:
013: /**
014: * Represents an employee.
015: *
016: * @author Sasa Bojanic
017: * @version 1.0
018: */
019: public class EmployeeImpl implements Employee, java.io.Serializable {
020: /**
021: * The DO of the Employee.
022: */
023: protected EmployeeDO myDO = null;
024:
025: /**
026: * The public constructor.
027: */
028: public EmployeeImpl() throws ProjectManagementBusinessException {
029: try {
030: this .myDO = EmployeeDO.createVirgin();
031: } catch (DatabaseManagerException ex) {
032: throw new ProjectManagementBusinessException(
033: "Error creating empty employee", ex);
034: } catch (ObjectIdException ex) {
035: throw new ProjectManagementBusinessException(
036: "Error creating object ID for employee", ex);
037: }
038: }
039:
040: /** The public constructor
041: *
042: * @param theEmployee. The data object of the employee.
043: */
044: public EmployeeImpl(EmployeeDO theEmployee) {
045: this .myDO = theEmployee;
046: }
047:
048: /**
049: * Gets the DO object for the employee
050: *
051: * @return the DO object.
052: * @exception ProjectManagementBusinessException if an error occurs
053: * retrieving data.
054: */
055: public EmployeeDO getDO() throws ProjectManagementBusinessException {
056: if (this .myDO != null) {
057: return this .myDO;
058: } else {
059: throw new ProjectManagementBusinessException(
060: "Error getting DO object for employee");
061: }
062: }
063:
064: /**
065: * Gets the object id for the employee
066: *
067: * @return the object id.
068: * @exception ProjectManagementBusinessException if an error occurs
069: * retrieving data (usually due to an underlying data layer
070: * error).
071: */
072: public String getHandle() throws ProjectManagementBusinessException {
073: try {
074: return this .myDO.getHandle();
075: } catch (DatabaseManagerException ex) {
076: throw new ProjectManagementBusinessException(
077: "Error getting handle for employee", ex);
078: }
079: }
080:
081: public int getAuthLevel() {
082: try {
083: boolean isAdmin = getIsAdmin();
084: if (isAdmin) {
085: return 2;
086: } else {
087: return 1;
088: }
089: } catch (Exception ex) {
090: return 0;
091: }
092: }
093:
094: /**
095: * Sets the login name for the employee.
096: *
097: * @param the login name.
098: * @exception ProjectManagementBusinessException if an error occurs
099: * setting the data (usually due to an underlying data layer
100: * error).
101: */
102: public void setLogin(String login)
103: throws ProjectManagementBusinessException {
104: try {
105: myDO.setLogin(login);
106: } catch (DataObjectException ex) {
107: throw new ProjectManagementBusinessException(
108: "Error setting user's login name", ex);
109: }
110: }
111:
112: /**
113: * Gets the login name for the employee
114: *
115: * @return the login name.
116: * @exception ProjectManagementBusinessException if an error occurs
117: * retrieving data (usually due to an underlying data layer
118: * error).
119: */
120: public String getLogin() throws ProjectManagementBusinessException {
121: try {
122: return myDO.getLogin();
123: } catch (DataObjectException ex) {
124: throw new ProjectManagementBusinessException(
125: "Error getting user's login name", ex);
126: }
127: }
128:
129: /**
130: * Sets the password for the employee.
131: *
132: * @param the password.
133: * @exception ProjectManagementBusinessException if an error occurs
134: * setting the data (usually due to an underlying data layer
135: * error).
136: */
137: public void setPassword(String password)
138: throws ProjectManagementBusinessException {
139: try {
140: myDO.setPassword(password);
141: } catch (DataObjectException ex) {
142: throw new ProjectManagementBusinessException(
143: "Error setting user's password", ex);
144: }
145: }
146:
147: /**
148: * Gets the password for the employee
149: *
150: * @return the password.
151: * @exception ProjectManagementBusinessException if an error occurs
152: * retrieving data (usually due to an underlying data layer
153: * error).
154: */
155: public String getPassword()
156: throws ProjectManagementBusinessException {
157: try {
158: return myDO.getPassword();
159: } catch (DataObjectException ex) {
160: throw new ProjectManagementBusinessException(
161: "Error getting user's password", ex);
162: }
163: }
164:
165: /**
166: * Sets the firstname for the employee.
167: *
168: * @param the firstname.
169: * @exception ProjectManagementBusinessException if an error occurs
170: * setting the data (usually due to an underlying data layer
171: * error).
172: */
173: public void setFirstName(String firstname)
174: throws ProjectManagementBusinessException {
175: try {
176: myDO.setFirstName(firstname);
177: } catch (DataObjectException ex) {
178: throw new ProjectManagementBusinessException(
179: "Error setting user's first name", ex);
180: }
181: }
182:
183: /**
184: * Gets the firstname for the employee
185: *
186: * @return the firstname.
187: * @exception ProjectManagementBusinessException if an error occurs
188: * retrieving data (usually due to an underlying data layer
189: * error).
190: */
191: public String getFirstName()
192: throws ProjectManagementBusinessException {
193: try {
194: return myDO.getFirstName();
195: } catch (DataObjectException ex) {
196: throw new ProjectManagementBusinessException(
197: "Error getting user's first name", ex);
198: }
199: }
200:
201: /**
202: * Sets the lastname for the employee.
203: *
204: * @param the lastname.
205: * @exception ProjectManagementBusinessException if an error occurs
206: * setting the data (usually due to an underlying data layer
207: * error).
208: */
209: public void setLastName(String lastname)
210: throws ProjectManagementBusinessException {
211: try {
212: myDO.setLastName(lastname);
213: } catch (DataObjectException ex) {
214: throw new ProjectManagementBusinessException(
215: "Error setting user's last name", ex);
216: }
217: }
218:
219: /**
220: * Gets the lastname for the employee
221: *
222: * @return the lastname.
223: * @exception ProjectManagementBusinessException if an error occurs
224: * retrieving data (usually due to an underlying data layer
225: * error).
226: */
227: public String getLastName()
228: throws ProjectManagementBusinessException {
229: try {
230: return myDO.getLastName();
231: } catch (DataObjectException ex) {
232: throw new ProjectManagementBusinessException(
233: "Error getting user's last name", ex);
234: }
235: }
236:
237: /**
238: * Sets the title for the employee.
239: *
240: * @param the title.
241: * @exception ProjectManagementBusinessException if an error occurs
242: * setting the data (usually due to an underlying data layer
243: * error).
244: */
245: public void setTitle(String title)
246: throws ProjectManagementBusinessException {
247: try {
248: myDO.setTitle(title);
249: } catch (DataObjectException ex) {
250: throw new ProjectManagementBusinessException(
251: "Error setting user's title", ex);
252: }
253: }
254:
255: /**
256: * Gets the title for the employee
257: *
258: * @return the title.
259: * @exception ProjectManagementBusinessException if an error occurs
260: * retrieving data (usually due to an underlying data layer
261: * error).
262: */
263: public String getTitle() throws ProjectManagementBusinessException {
264: try {
265: return myDO.getTitle();
266: } catch (DataObjectException ex) {
267: throw new ProjectManagementBusinessException(
268: "Error getting user's title", ex);
269: }
270: }
271:
272: /**
273: * Sets the title of courtesy for the employee.
274: *
275: * @param the title of courtesy.
276: * @exception ProjectManagementBusinessException if an error occurs
277: * setting the data (usually due to an underlying data layer
278: * error).
279: */
280: public void setTitleOfCourtesy(String titleOfCourtesy)
281: throws ProjectManagementBusinessException {
282: try {
283: myDO.setTitleOfCourtesy(titleOfCourtesy);
284: } catch (DataObjectException ex) {
285: throw new ProjectManagementBusinessException(
286: "Error setting user's title of courtesy", ex);
287: }
288: }
289:
290: /**
291: * Gets the title of courtesy for the employee
292: *
293: * @return the title of courtesy.
294: * @exception ProjectManagementBusinessException if an error occurs
295: * retrieving data (usually due to an underlying data layer
296: * error).
297: */
298: public String getTitleOfCourtesy()
299: throws ProjectManagementBusinessException {
300: try {
301: return myDO.getTitleOfCourtesy();
302: } catch (DataObjectException ex) {
303: throw new ProjectManagementBusinessException(
304: "Error getting user's title of courtesy", ex);
305: }
306: }
307:
308: /**
309: * Sets the birth date for the employee.
310: *
311: * @param the birth date.
312: * @exception ProjectManagementBusinessException if an error occurs
313: * setting the data (usually due to an underlying data layer
314: * error).
315: */
316: public void setBirthDate(Date birthDate)
317: throws ProjectManagementBusinessException {
318: try {
319: myDO.setBirthDate(birthDate);
320: } catch (DataObjectException ex) {
321: throw new ProjectManagementBusinessException(
322: "Error setting user's birth date", ex);
323: }
324: }
325:
326: /**
327: * Gets the birth date for the employee
328: *
329: * @return the birth date.
330: * @exception ProjectManagementBusinessException if an error occurs
331: * retrieving data (usually due to an underlying data layer
332: * error).
333: */
334: public Date getBirthDate()
335: throws ProjectManagementBusinessException {
336: try {
337: return myDO.getBirthDate();
338: } catch (DataObjectException ex) {
339: throw new ProjectManagementBusinessException(
340: "Error getting user's birth date", ex);
341: }
342: }
343:
344: /**
345: * Sets the hire date for the employee.
346: *
347: * @param the hire date.
348: * @exception ProjectManagementBusinessException if an error occurs
349: * setting the data (usually due to an underlying data layer
350: * error).
351: */
352: public void setHireDate(Date hireDate)
353: throws ProjectManagementBusinessException {
354: try {
355: myDO.setHireDate(hireDate);
356: } catch (DataObjectException ex) {
357: throw new ProjectManagementBusinessException(
358: "Error setting user's hire date", ex);
359: }
360: }
361:
362: /**
363: * Gets the hire date for the employee
364: *
365: * @return the hire date.
366: * @exception ProjectManagementBusinessException if an error occurs
367: * retrieving data (usually due to an underlying data layer
368: * error).
369: */
370: public Date getHireDate() throws ProjectManagementBusinessException {
371: try {
372: return myDO.getHireDate();
373: } catch (DataObjectException ex) {
374: throw new ProjectManagementBusinessException(
375: "Error getting user's hire date", ex);
376: }
377: }
378:
379: /**
380: * Sets the address for the customer.
381: *
382: * @param the address.
383: * @exception ProjectManagementBusinessException if an error occurs
384: * setting the data (usually due to an underlying data layer
385: * error).
386: */
387: public void setAddress(String address)
388: throws ProjectManagementBusinessException {
389: try {
390: myDO.setAddress(address);
391: } catch (DataObjectException ex) {
392: throw new ProjectManagementBusinessException(
393: "Error setting address", ex);
394: }
395: }
396:
397: /**
398: * Gets the address.
399: *
400: * @return the address.
401: * @exception ProjectManagementBusinessException if an error occurs
402: * retrieving data (usually due to an underlying data layer
403: * error).
404: */
405: public String getAddress()
406: throws ProjectManagementBusinessException {
407: try {
408: return myDO.getAddress();
409: } catch (DataObjectException ex) {
410: throw new ProjectManagementBusinessException(
411: "Error getting address", ex);
412: }
413: }
414:
415: /**
416: * Sets the employee's city.
417: *
418: * @param the employee's city.
419: * @exception ProjectManagementBusinessException if an error occurs
420: * setting the data (usually due to an underlying data layer
421: * error).
422: */
423: public void setCity(String city)
424: throws ProjectManagementBusinessException {
425: try {
426: myDO.setCity(city);
427: } catch (DataObjectException ex) {
428: throw new ProjectManagementBusinessException(
429: "Error setting city", ex);
430: }
431: }
432:
433: /**
434: * Gets the employee city.
435: *
436: * @return the employee city.
437: * @exception ProjectManagementBusinessException if an error occurs
438: * retrieving data (usually due to an underlying data layer
439: * error).
440: */
441: public String getCity() throws ProjectManagementBusinessException {
442: try {
443: return myDO.getCity();
444: } catch (DataObjectException ex) {
445: throw new ProjectManagementBusinessException(
446: "Error getting employee city", ex);
447: }
448: }
449:
450: /**
451: * Sets the employee's region.
452: *
453: * @param the employee's region.
454: * @exception ProjectManagementBusinessException if an error occurs
455: * setting the data (usually due to an underlying data layer
456: * error).
457: */
458: public void setRegion(String region)
459: throws ProjectManagementBusinessException {
460: try {
461: myDO.setRegion(region);
462: } catch (DataObjectException ex) {
463: throw new ProjectManagementBusinessException(
464: "Error setting region", ex);
465: }
466: }
467:
468: /**
469: * Gets the employee's region.
470: *
471: * @return the employee region.
472: * @exception ProjectManagementBusinessException if an error occurs
473: * retrieving data (usually due to an underlying data layer
474: * error).
475: */
476: public String getRegion() throws ProjectManagementBusinessException {
477: try {
478: return myDO.getRegion();
479: } catch (DataObjectException ex) {
480: throw new ProjectManagementBusinessException(
481: "Error getting employee region", ex);
482: }
483: }
484:
485: /**
486: * Sets the employee's postal code.
487: *
488: * @param the employee's postal code.
489: * @exception ProjectManagementBusinessException if an error occurs
490: * setting the data (usually due to an underlying data layer
491: * error).
492: */
493: public void setPostalCode(String postalCode)
494: throws ProjectManagementBusinessException {
495: try {
496: myDO.setPostalCode(postalCode);
497: } catch (DataObjectException ex) {
498: throw new ProjectManagementBusinessException(
499: "Error setting postal code", ex);
500: }
501: }
502:
503: /**
504: * Gets the employee's postal code.
505: *
506: * @return the employee postal code.
507: * @exception ProjectManagementBusinessException if an error occurs
508: * retrieving data (usually due to an underlying data layer
509: * error).
510: */
511: public String getPostalCode()
512: throws ProjectManagementBusinessException {
513: try {
514: return myDO.getPostalCode();
515: } catch (DataObjectException ex) {
516: throw new ProjectManagementBusinessException(
517: "Error getting employee postal code", ex);
518: }
519: }
520:
521: /**
522: * Sets the employee's country.
523: *
524: * @param the employee's country.
525: * @exception ProjectManagementBusinessException if an error occurs
526: * setting the data (usually due to an underlying data layer
527: * error).
528: */
529: public void setCountry(String country)
530: throws ProjectManagementBusinessException {
531: try {
532: myDO.setCountry(country);
533: } catch (DataObjectException ex) {
534: throw new ProjectManagementBusinessException(
535: "Error setting country", ex);
536: }
537: }
538:
539: /**
540: * Gets the employee's country.
541: *
542: * @return the employee country.
543: * @exception ProjectManagementBusinessException if an error occurs
544: * retrieving data (usually due to an underlying data layer
545: * error).
546: */
547: public String getCountry()
548: throws ProjectManagementBusinessException {
549: try {
550: return myDO.getCountry();
551: } catch (DataObjectException ex) {
552: throw new ProjectManagementBusinessException(
553: "Error getting employee country", ex);
554: }
555: }
556:
557: /**
558: * Sets the employee's home phone.
559: *
560: * @param the employee's home phone.
561: * @exception ProjectManagementBusinessException if an error occurs
562: * setting the data (usually due to an underlying data layer
563: * error).
564: */
565: public void setHomePhone(String homePhone)
566: throws ProjectManagementBusinessException {
567: try {
568: myDO.setHomePhone(homePhone);
569: } catch (DataObjectException ex) {
570: throw new ProjectManagementBusinessException(
571: "Error setting home phone", ex);
572: }
573: }
574:
575: /**
576: * Gets the employee's home phone.
577: *
578: * @return the employee home phone.
579: * @exception ProjectManagementBusinessException if an error occurs
580: * retrieving data (usually due to an underlying data layer
581: * error).
582: */
583: public String getHomePhone()
584: throws ProjectManagementBusinessException {
585: try {
586: return myDO.getHomePhone();
587: } catch (DataObjectException ex) {
588: throw new ProjectManagementBusinessException(
589: "Error getting employee home phone", ex);
590: }
591: }
592:
593: /**
594: * Sets the employee's mobile phone.
595: *
596: * @param the employee's mobile phone.
597: * @exception ProjectManagementBusinessException if an error occurs
598: * setting the data (usually due to an underlying data layer
599: * error).
600: */
601: public void setMobilePhone(String mobilePhone)
602: throws ProjectManagementBusinessException {
603: try {
604: myDO.setMobilePhone(mobilePhone);
605: } catch (DataObjectException ex) {
606: throw new ProjectManagementBusinessException(
607: "Error setting mobile phone", ex);
608: }
609: }
610:
611: /**
612: * Gets the employee's mobile phone.
613: *
614: * @return the employee mobile phone.
615: * @exception ProjectManagementBusinessException if an error occurs
616: * retrieving data (usually due to an underlying data layer
617: * error).
618: */
619: public String getMobilePhone()
620: throws ProjectManagementBusinessException {
621: try {
622: return myDO.getMobilePhone();
623: } catch (DataObjectException ex) {
624: throw new ProjectManagementBusinessException(
625: "Error getting employee mobile phone", ex);
626: }
627: }
628:
629: /**
630: * Sets the employee's email.
631: *
632: * @param the employee's email.
633: * @exception ProjectManagementBusinessException if an error occurs
634: * setting the data (usually due to an underlying data layer
635: * error).
636: */
637: public void setEmail(String email)
638: throws ProjectManagementBusinessException {
639: try {
640: myDO.setEmail(email);
641: } catch (DataObjectException ex) {
642: throw new ProjectManagementBusinessException(
643: "Error setting email", ex);
644: }
645: }
646:
647: /**
648: * Gets the employee's email.
649: *
650: * @return the employee email.
651: * @exception ProjectManagementBusinessException if an error occurs
652: * retrieving data (usually due to an underlying data layer
653: * error).
654: */
655: public String getEmail() throws ProjectManagementBusinessException {
656: try {
657: return myDO.getEmail();
658: } catch (DataObjectException ex) {
659: throw new ProjectManagementBusinessException(
660: "Error getting employee email", ex);
661: }
662: }
663:
664: /**
665: * Sets the employee's notes.
666: *
667: * @param the employee's notes.
668: * @exception ProjectManagementBusinessException if an error occurs
669: * setting the data (usually due to an underlying data layer
670: * error).
671: */
672: public void setNotes(String notes)
673: throws ProjectManagementBusinessException {
674: try {
675: myDO.setNotes(notes);
676: } catch (DataObjectException ex) {
677: throw new ProjectManagementBusinessException(
678: "Error setting notes", ex);
679: }
680: }
681:
682: /**
683: * Gets the employee's notes.
684: *
685: * @return the employee notes.
686: * @exception ProjectManagementBusinessException if an error occurs
687: * retrieving data (usually due to an underlying data layer
688: * error).
689: */
690: public String getNotes() throws ProjectManagementBusinessException {
691: try {
692: return myDO.getNotes();
693: } catch (DataObjectException ex) {
694: throw new ProjectManagementBusinessException(
695: "Error getting employee notes", ex);
696: }
697: }
698:
699: /**
700: * Sets the flag that indicates if employee is admin.
701: *
702: * @param isAdmin Indication if employee is admin.
703: * @exception ProjectManagementBusinessException if an error occurs
704: * setting the data (usually due to an underlying data layer
705: * error).
706: */
707: public void setIsAdmin(boolean isAdmin)
708: throws ProjectManagementBusinessException {
709: try {
710: myDO.setIsAdmin(isAdmin);
711: } catch (DataObjectException ex) {
712: throw new ProjectManagementBusinessException(
713: "Error setting administration flag", ex);
714: }
715: }
716:
717: /**
718: * Returns true if the employee is admin.
719: *
720: * @return true if the employee is admin.
721: * @exception ProjectManagementBusinessException if an error occurs
722: * retrieving data (usually due to an underlying data layer
723: * error).
724: */
725: public boolean getIsAdmin()
726: throws ProjectManagementBusinessException {
727: try {
728: return myDO.getIsAdmin();
729: } catch (DataObjectException ex) {
730: throw new ProjectManagementBusinessException(
731: "Error getting indication if th user is admin", ex);
732: }
733: }
734:
735: /**
736: * Commits all changes to the database.
737: *
738: * @exception ProjectManagementBusinessException if an error occurs
739: * retrieving data (usually due to an underlying data layer
740: * error).
741: */
742: public void save() throws ProjectManagementBusinessException {
743: try {
744: this .myDO.commit();
745: } catch (Exception ex) {
746: throw new ProjectManagementBusinessException(
747: "Error saving employee", ex);
748: }
749: }
750:
751: /**
752: * Deletes the employee from database.
753: *
754: * @exception ProjectManagementBusinessException if an error occurs
755: * deleting data (usually due to an underlying data layer
756: * error).
757: */
758: public void delete() throws ProjectManagementBusinessException {
759: try {
760: this .myDO.delete();
761: } catch (Exception ex) {
762: throw new ProjectManagementBusinessException(
763: "Error deleting employee", ex);
764: }
765: }
766:
767: }
|