1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.api.util;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 import org.kuali.rice.kew.api.KewApiConstants;
22 import org.kuali.rice.kew.api.action.ActionRequestPolicy;
23 import org.kuali.rice.kew.api.action.ActionRequestStatus;
24 import org.kuali.rice.kew.api.action.ActionType;
25
26
27
28
29
30
31 public class CodeTranslator {
32 public static final Map<String, String> arLabels = getArLabels();
33 public static final Map<String, String> atLabels = getAtLabels();
34 public static final Map<String, String> arStatusLabels = getArStatusLabels();
35 public static final Map<String, String> routeStatusLabels = getRouteStatusLabels();
36 public static final Map<Boolean, String> activeIndicatorLabels = getActiveIndicatorLabels();
37 public static final Map<String, String> activationPolicyLabels = getActivationPolicyLabels();
38 public static final Map<String, String> policyLabels = getPolicyLabels();
39 public static final Map<String, String> approvePolicyLabels = getApprovePolicyLabels();
40
41 private static Map<String, String> getAtLabels() {
42 Map<String, String> newAtLabels = new HashMap<String, String>();
43 newAtLabels.put(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD, KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED);
44 newAtLabels.put(KewApiConstants.ACTION_TAKEN_ADHOC_CD, KewApiConstants.ACTION_TAKEN_ADHOC);
45 newAtLabels.put(KewApiConstants.ACTION_TAKEN_ADHOC_REVOKED_CD, KewApiConstants.ACTION_TAKEN_ADHOC_REVOKED);
46 newAtLabels.put(KewApiConstants.ACTION_TAKEN_APPROVED_CD, KewApiConstants.ACTION_TAKEN_APPROVED);
47 newAtLabels.put(KewApiConstants.ACTION_TAKEN_BLANKET_APPROVE_CD, KewApiConstants.ACTION_TAKEN_BLANKET_APPROVE);
48 newAtLabels.put(KewApiConstants.ACTION_TAKEN_CANCELED_CD, KewApiConstants.ACTION_TAKEN_CANCELED);
49 newAtLabels.put(ActionType.RECALL.getCode(), ActionType.RECALL.getLabel());
50 newAtLabels.put(KewApiConstants.ACTION_TAKEN_COMPLETED_CD, KewApiConstants.ACTION_TAKEN_COMPLETED);
51 newAtLabels.put(KewApiConstants.ACTION_TAKEN_ROUTED_CD, KewApiConstants.ACTION_TAKEN_ROUTED);
52 newAtLabels.put(KewApiConstants.ACTION_TAKEN_DENIED_CD, KewApiConstants.ACTION_TAKEN_DENIED);
53 newAtLabels.put(KewApiConstants.ACTION_TAKEN_FYI_CD, KewApiConstants.ACTION_TAKEN_FYI);
54 newAtLabels.put(KewApiConstants.ACTION_TAKEN_SAVED_CD, KewApiConstants.ACTION_TAKEN_SAVED);
55 newAtLabels.put(KewApiConstants.ACTION_TAKEN_RETURNED_TO_PREVIOUS_CD, KewApiConstants.ACTION_TAKEN_RETURNED_TO_PREVIOUS);
56 newAtLabels.put(KewApiConstants.ACTION_TAKEN_LOG_DOCUMENT_ACTION_CD, KewApiConstants.ACTION_TAKEN_LOG_DOCUMENT_ACTION);
57 newAtLabels.put(KewApiConstants.ACTION_TAKEN_MOVE_CD, KewApiConstants.ACTION_TAKEN_MOVE);
58 newAtLabels.put(KewApiConstants.ACTION_TAKEN_SU_APPROVED_CD, KewApiConstants.ACTION_TAKEN_SU_APPROVED);
59 newAtLabels.put(KewApiConstants.ACTION_TAKEN_SU_CANCELED_CD, KewApiConstants.ACTION_TAKEN_SU_CANCELED);
60 newAtLabels.put(KewApiConstants.ACTION_TAKEN_SU_DISAPPROVED_CD, KewApiConstants.ACTION_TAKEN_SU_DISAPPROVED);
61 newAtLabels.put(KewApiConstants.ACTION_TAKEN_SU_ROUTE_LEVEL_APPROVED_CD, KewApiConstants.ACTION_TAKEN_SU_ROUTE_LEVEL_APPROVED);
62 newAtLabels.put(KewApiConstants.ACTION_TAKEN_SU_ACTION_REQUEST_APPROVED_CD, KewApiConstants.ACTION_TAKEN_SU_ACTION_REQUEST_APPROVED);
63 newAtLabels.put(KewApiConstants.ACTION_TAKEN_SU_RETURNED_TO_PREVIOUS_CD, KewApiConstants.ACTION_TAKEN_SU_RETURNED_TO_PREVIOUS);
64 newAtLabels.put(KewApiConstants.ACTION_TAKEN_SU_ACTION_REQUEST_ACKNOWLEDGED_CD, KewApiConstants.ACTION_TAKEN_SU_ACTION_REQUEST_ACKNOWLEDGED);
65 newAtLabels.put(KewApiConstants.ACTION_TAKEN_SU_ACTION_REQUEST_FYI_CD, KewApiConstants.ACTION_TAKEN_SU_ACTION_REQUEST_FYI);
66 newAtLabels.put(KewApiConstants.ACTION_TAKEN_SU_ACTION_REQUEST_COMPLETED_CD, KewApiConstants.ACTION_TAKEN_SU_ACTION_REQUEST_COMPLETED);
67 newAtLabels.put(KewApiConstants.ACTION_TAKEN_TAKE_WORKGROUP_AUTHORITY_CD, KewApiConstants.ACTION_TAKEN_TAKE_WORKGROUP_AUTHORITY);
68 newAtLabels.put(KewApiConstants.ACTION_TAKEN_RELEASE_WORKGROUP_AUTHORITY_CD, KewApiConstants.ACTION_TAKEN_RELEASE_WORKGROUP_AUTHORITY);
69 return newAtLabels;
70 }
71
72 private static Map<String, String> getArLabels() {
73 Map<String, String> newArLabels = new HashMap<String, String>();
74 newArLabels.put(KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL);
75 newArLabels.put(KewApiConstants.ACTION_REQUEST_APPROVE_REQ, KewApiConstants.ACTION_REQUEST_APPROVE_REQ_LABEL);
76 newArLabels.put(KewApiConstants.ACTION_REQUEST_COMPLETE_REQ, KewApiConstants.ACTION_REQUEST_COMPLETE_REQ_LABEL);
77 newArLabels.put(KewApiConstants.ACTION_REQUEST_FYI_REQ, KewApiConstants.ACTION_REQUEST_FYI_REQ_LABEL);
78 return newArLabels;
79 }
80
81 private static Map<String, String> getArStatusLabels() {
82 Map<String, String> newArStatusLabels = new HashMap<String, String>();
83 newArStatusLabels.put(ActionRequestStatus.ACTIVATED.getCode(), KewApiConstants.ACTIVE_LABEL);
84 newArStatusLabels.put(ActionRequestStatus.INITIALIZED.getCode(), ActionRequestStatus.INITIALIZED.getLabel());
85 newArStatusLabels.put(ActionRequestStatus.DONE.getCode(), ActionRequestStatus.DONE.getLabel());
86 return newArStatusLabels;
87 }
88
89 private static Map<String, String> getRouteStatusLabels() {
90 Map<String, String> newRouteStatusLabels = new HashMap<String, String>();
91 newRouteStatusLabels.put(KewApiConstants.ROUTE_HEADER_CANCEL_CD, KewApiConstants.ROUTE_HEADER_CANCEL_LABEL);
92 newRouteStatusLabels.put(KewApiConstants.ROUTE_HEADER_DISAPPROVED_CD, KewApiConstants.ROUTE_HEADER_DISAPPROVED_LABEL);
93 newRouteStatusLabels.put(KewApiConstants.ROUTE_HEADER_ENROUTE_CD, KewApiConstants.ROUTE_HEADER_ENROUTE_LABEL);
94 newRouteStatusLabels.put(KewApiConstants.ROUTE_HEADER_EXCEPTION_CD, KewApiConstants.ROUTE_HEADER_EXCEPTION_LABEL);
95 newRouteStatusLabels.put(KewApiConstants.ROUTE_HEADER_FINAL_CD, KewApiConstants.ROUTE_HEADER_FINAL_LABEL);
96 newRouteStatusLabels.put(KewApiConstants.ROUTE_HEADER_INITIATED_CD, KewApiConstants.ROUTE_HEADER_INITIATED_LABEL);
97 newRouteStatusLabels.put(KewApiConstants.ROUTE_HEADER_PROCESSED_CD, KewApiConstants.ROUTE_HEADER_PROCESSED_LABEL);
98 newRouteStatusLabels.put(KewApiConstants.ROUTE_HEADER_SAVED_CD, KewApiConstants.ROUTE_HEADER_SAVED_LABEL);
99 return newRouteStatusLabels;
100 }
101
102 private static Map<Boolean, String> getActiveIndicatorLabels() {
103 Map<Boolean, String> newActiveIndicatorLabels = new HashMap<Boolean, String>();
104 newActiveIndicatorLabels.put(Boolean.TRUE, KewApiConstants.ACTIVE_LABEL_LOWER);
105 newActiveIndicatorLabels.put(Boolean.FALSE, KewApiConstants.INACTIVE_LABEL_LOWER);
106 return newActiveIndicatorLabels;
107 }
108
109 private static Map<String, String> getPolicyLabels() {
110 Map<String, String> newDocTypeActiveIndicatorLabels = new HashMap<String, String>();
111 newDocTypeActiveIndicatorLabels.put(KewApiConstants.TRUE_CD, KewApiConstants.YES_LABEL);
112 newDocTypeActiveIndicatorLabels.put(KewApiConstants.FALSE_CD, KewApiConstants.NO_LABEL);
113 newDocTypeActiveIndicatorLabels.put(KewApiConstants.INHERITED_CD, KewApiConstants.INHERITED_LABEL);
114 return newDocTypeActiveIndicatorLabels;
115 }
116
117 private static Map<String, String> getActivationPolicyLabels() {
118 Map<String, String> newActivationPolicyLabels = new HashMap<String, String>();
119 newActivationPolicyLabels.put(KewApiConstants.ROUTE_LEVEL_PARALLEL, KewApiConstants.ROUTE_LEVEL_PARALLEL_LABEL);
120 newActivationPolicyLabels.put(KewApiConstants.ROUTE_LEVEL_SEQUENCE, KewApiConstants.ROUTE_LEVEL_SEQUENCE_LABEL);
121 newActivationPolicyLabels.put(KewApiConstants.ROUTE_LEVEL_PRIORITY_PARALLEL, KewApiConstants.ROUTE_LEVEL_PRIORITY_PARALLEL_LABEL);
122 return newActivationPolicyLabels;
123 }
124
125 private static Map<String, String> getApprovePolicyLabels() {
126 Map<String, String> approvePolicyLabels = new HashMap<String, String>();
127 approvePolicyLabels.put(ActionRequestPolicy.ALL.getCode(), ActionRequestPolicy.ALL.getLabel());
128 approvePolicyLabels.put(ActionRequestPolicy.FIRST.getCode(), ActionRequestPolicy.FIRST.getLabel());
129 return approvePolicyLabels;
130 }
131
132
133
134
135
136
137
138
139 static public String getActionRequestLabel(String actionRequestCode) {
140 return (String) arLabels.get(actionRequestCode);
141 }
142
143
144
145
146
147
148
149
150 static public String getActionTakenLabel(String actionTakenCode) {
151 return (String) atLabels.get(actionTakenCode);
152 }
153
154
155
156
157
158
159
160
161 static public String getActionRequestStatusLabel(String status) {
162 return (String) arStatusLabels.get(status);
163 }
164
165 static public String getRouteStatusLabel(String status) {
166 return (String) routeStatusLabels.get(status);
167 }
168
169 static public String getActiveIndicatorLabel(Boolean indicator) {
170 return (String) activeIndicatorLabels.get(indicator);
171 }
172
173 static public String getActivationPolicyLabel(String code) {
174 return (String) activationPolicyLabels.get(code);
175 }
176
177 static public String getPolicyLabel(String code) {
178 return (String) policyLabels.get(code);
179 }
180
181 }