01: package projectmanagement.presentation;
02:
03: import projectmanagement.spec.employee.Employee;
04:
05: /**
06: * Object that will be held in session data. This should
07: * be the only object held there. Methods should be called
08: * on this object to set and get data.
09: *
10: * @author Sasa Bojanic
11: * @version 1.0
12: */
13: public class ProjectManagementSessionData implements
14: java.io.Serializable {
15:
16: /**
17: * Hash key to save session data for the ProjectManagement app in the Session
18: */
19: public static final String SESSION_KEY = "ProjectManagementSessionData";
20:
21: protected Employee myUser = null;
22: protected String userMessage = null;
23: protected boolean isAdmin = false;
24:
25: /**
26: * Sets the employee object
27: *
28: * @param theEmployee the employee object
29: */
30: public void setUser(Employee theEmployee) {
31: this .myUser = theEmployee;
32: }
33:
34: /**
35: * Gets the employee object
36: *
37: * @return employee
38: */
39: public Employee getUser() {
40: return this .myUser;
41: }
42:
43: /**
44: * Method to remove the current user from the session
45: */
46: public void removeUser() {
47: this .myUser = null;
48: }
49:
50: /**
51: * Sets the message
52: *
53: * @param msg the message to be set
54: */
55: public void setUserMessage(String msg) {
56: this .userMessage = msg;
57: }
58:
59: public void setAdmin(boolean isAdmin) {
60: this .isAdmin = isAdmin;
61: }
62:
63: public int getAuthLevel() {
64: if (isAdmin) {
65: return 2;
66: } else if (myUser != null) {
67: return myUser.getAuthLevel();
68: } else {
69: return 0;
70: }
71: }
72:
73: /**
74: * Retrieve the most recent user message and then clear it so no
75: * other app tries to use it.
76: */
77: public String getAndClearUserMessage() {
78: String msg = this.userMessage;
79: this.userMessage = null;
80: return msg;
81: }
82: }
|