KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sellwin > domain > UserRole


1 package sellwin.domain;
2
3 import java.util.*;
4 import java.io.*;
5
6 // SellWin http://sourceforge.net/projects/sellwincrm
7
//Contact support@open-app.com for commercial help with SellWin
8
//This software is provided "AS IS", without a warranty of any kind.
9

10
11 /**
12  * This class represents an individual role defined in the system.
13  * This class holds column values in the 'user_role' database table
14  */

15 public class UserRole implements Serializable {
16
17     final public static String JavaDoc ROLE_SALES_REP="Sales Rep";
18     final public static String JavaDoc ROLE_SALES_MGR="Sales Mgr";
19     final public static String JavaDoc ROLE_SALES_SUPPORT="Sales Support";
20     final public static String JavaDoc ROLE_SYSTEM_ADMIN="System Admin";
21     final public static String JavaDoc ROLE_MKT_REP="Marketing Rep";
22
23     private long pk;
24     private String JavaDoc name;
25     private String JavaDoc modifiedBy;
26     private Date modifiedDate;
27     private ArrayList perms = new ArrayList();
28
29     public UserRole() {
30     }
31
32     public UserRole(String JavaDoc n) {
33         name = n;
34         modifiedBy="";
35         modifiedDate=new Date();
36     }
37
38     public final void setPK(long i) { pk = i; }
39     public final long getPK() { return pk; }
40
41     public final String JavaDoc getName() { return name; }
42     public final void setName(String JavaDoc n) { name = n; }
43
44     public final void addPermission(RolePermission p) { perms.add(p); }
45     public final ArrayList getPermissions() { return perms; }
46
47     public final String JavaDoc getModifiedBy() { return modifiedBy; }
48     public final Date getModifiedDate() { return modifiedDate; }
49     public final void setModifiedBy(String JavaDoc by) { modifiedBy = by; }
50     public final void setModifiedDate(Date dt) { modifiedDate = dt; }
51
52
53     public final void print() {
54         System.out.println("UserRole = "+getName() + " pk=" + pk);
55         RolePermission perm;
56         for (int i=0;i<perms.size();i++) {
57             perm = (RolePermission)perms.get(i);
58             perm.print();
59         }
60     }
61
62     public final UserRole copy() {
63         UserRole copy = new UserRole(new String JavaDoc(name));
64         copy.pk = pk;
65
66         for (int i=0;i<perms.size();i++) {
67             copy.perms.add(perms.get(i));
68         }
69
70         copy.setModifiedBy(new String JavaDoc(modifiedBy));
71         copy.setModifiedDate(new Date(modifiedDate.getTime()));
72
73         return copy;
74     }
75
76     final public boolean isSalesRep() {
77         if (name.equals(ROLE_SALES_REP))
78             return true;
79         return false;
80     }
81
82     final public boolean isSalesMgr() {
83         if (name.equals(ROLE_SALES_MGR)) return true;
84         return false;
85     }
86
87     final public boolean isSalesSupport() {
88         if (name.equals(ROLE_SALES_SUPPORT)) return true;
89         return false;
90     }
91
92     final public boolean isSystemAdmin() {
93         if (name.equals(ROLE_SYSTEM_ADMIN)) return true;
94         return false;
95     }
96
97     final public boolean isMarketingRep() {
98         if (name.equals(ROLE_MKT_REP)) return true;
99         return false;
100     }
101 }
102
Popular Tags