1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.roles;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.kuali.hr.time.util.TKContext;
22 import org.kuali.hr.time.util.TkConstants;
23 import org.kuali.rice.core.api.util.ConcreteKeyValue;
24 import org.kuali.rice.core.api.util.KeyValue;
25 import org.kuali.rice.kns.web.struts.form.KualiMaintenanceForm;
26 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
27
28 public class TkRoleValuesFinder extends KeyValuesBase {
29
30 private KualiMaintenanceForm kualiForm = null;
31
32 public KualiMaintenanceForm getKualiForm() {
33 return kualiForm;
34 }
35
36 public void setKualiForm(KualiMaintenanceForm kualiForm) {
37 this.kualiForm = kualiForm;
38 }
39
40 @Override
41 public List<KeyValue> getKeyValues() {
42
43 List<KeyValue> filteredLabels = new ArrayList<KeyValue>();
44 KualiMaintenanceForm kualiForm = null;
45 if (TKContext.getHttpServletRequest() != null) {
46 if(TKContext.getHttpServletRequest().getAttribute("KualiForm") instanceof KualiMaintenanceForm){
47 kualiForm = (KualiMaintenanceForm)TKContext.getHttpServletRequest().getAttribute("KualiForm");
48 setKualiForm(kualiForm);
49 }
50 }
51
52 if(kualiForm == null || kualiForm.getDocTypeName().equals("RoleGroupMaintenanceDocumentType")){
53 if(TKContext.getUser().isSystemAdmin()){
54 filteredLabels.add(new ConcreteKeyValue(TkConstants.ROLE_TK_SYS_ADMIN, TkConstants.ALL_ROLES_MAP.get(TkConstants.ROLE_TK_SYS_ADMIN)));
55 filteredLabels.add(new ConcreteKeyValue(TkConstants.ROLE_TK_GLOBAL_VO, TkConstants.ALL_ROLES_MAP.get(TkConstants.ROLE_TK_GLOBAL_VO)));
56 }
57
58 if(TKContext.getUser().isSystemAdmin() || TKContext.getUser().isLocationAdmin()){
59 filteredLabels.add(new ConcreteKeyValue(TkConstants.ROLE_TK_LOCATION_ADMIN, TkConstants.ALL_ROLES_MAP.get(TkConstants.ROLE_TK_LOCATION_ADMIN)));
60 filteredLabels.add(new ConcreteKeyValue(TkConstants.ROLE_TK_LOCATION_VO, TkConstants.ALL_ROLES_MAP.get(TkConstants.ROLE_TK_LOCATION_VO)));
61 }
62 }
63
64 if(kualiForm == null || kualiForm.getDocTypeName().equals("DepartmentMaintenanceDocumentType")){
65 if(TKContext.getUser().isSystemAdmin() || TKContext.getUser().isLocationAdmin()){
66 filteredLabels.add(new ConcreteKeyValue(TkConstants.ROLE_TK_DEPT_ADMIN, TkConstants.ALL_ROLES_MAP.get(TkConstants.ROLE_TK_DEPT_ADMIN)));
67 filteredLabels.add(new ConcreteKeyValue(TkConstants.ROLE_TK_DEPT_VO, TkConstants.ALL_ROLES_MAP.get(TkConstants.ROLE_TK_DEPT_VO)));
68
69 filteredLabels.add(new ConcreteKeyValue(TkConstants.ROLE_LV_DEPT_ADMIN, TkConstants.ALL_ROLES_MAP.get(TkConstants.ROLE_LV_DEPT_ADMIN)));
70 filteredLabels.add(new ConcreteKeyValue(TkConstants.ROLE_LV_DEPT_VO, TkConstants.ALL_ROLES_MAP.get(TkConstants.ROLE_LV_DEPT_VO)));
71 }
72 }
73
74 if(kualiForm == null || kualiForm.getDocTypeName().equals("WorkAreaMaintenanceDocumentType")){
75 if(TKContext.getUser().isSystemAdmin() || TKContext.getUser().isLocationAdmin() || TKContext.getUser().isDepartmentAdmin()){
76 filteredLabels.add(new ConcreteKeyValue(TkConstants.ROLE_TK_APPROVER, TkConstants.ALL_ROLES_MAP.get(TkConstants.ROLE_TK_APPROVER)));
77 filteredLabels.add(new ConcreteKeyValue(TkConstants.ROLE_TK_APPROVER_DELEGATE, TkConstants.ALL_ROLES_MAP.get(TkConstants.ROLE_TK_APPROVER_DELEGATE)));
78 filteredLabels.add(new ConcreteKeyValue(TkConstants.ROLE_TK_REVIEWER, TkConstants.ALL_ROLES_MAP.get(TkConstants.ROLE_TK_REVIEWER)));
79 }
80 }
81
82
83
84 return filteredLabels;
85 }
86 }