001: /*
002: * Copyright 2005-2006 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.util;
018:
019: import java.util.HashMap;
020: import java.util.Map;
021:
022: import edu.iu.uis.eden.EdenConstants;
023:
024: /**
025: * Utility class to translate the various codes used in Eden into labels and vice versa.
026: *
027: * @author rkirkend
028: */
029: public class CodeTranslator {
030: public static final Map arLabels = getArLabels();
031: public static final Map atLabels = getAtLabels();
032: public static final Map arStatusLabels = getArStatusLabels();
033: public static final Map routeStatusLabels = getRouteStatusLabels();
034: public static final Map activeIndicatorLabels = getActiveIndicatorLabels();
035: public static final Map activationPolicyLabels = getActivationPolicyLabels();
036: public static final Map policyLabels = getPolicyLabels();
037: public static final Map approvePolicyLabels = getApprovePolicyLabels();
038: public static final Map routeQueueStatusLabels = getRouteQueueStatusLabels();
039:
040: private static Map getAtLabels() {
041: Map newAtLabels = new HashMap();
042: newAtLabels.put(EdenConstants.ACTION_TAKEN_ACKNOWLEDGED_CD,
043: EdenConstants.ACTION_TAKEN_ACKNOWLEDGED);
044: newAtLabels.put(EdenConstants.ACTION_TAKEN_ADHOC_CD,
045: EdenConstants.ACTION_TAKEN_ADHOC);
046: newAtLabels.put(EdenConstants.ACTION_TAKEN_ADHOC_REVOKED_CD,
047: EdenConstants.ACTION_TAKEN_ADHOC_REVOKED);
048: newAtLabels.put(EdenConstants.ACTION_TAKEN_APPROVED_CD,
049: EdenConstants.ACTION_TAKEN_APPROVED);
050: newAtLabels.put(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD,
051: EdenConstants.ACTION_TAKEN_BLANKET_APPROVE);
052: newAtLabels.put(EdenConstants.ACTION_TAKEN_CANCELED_CD,
053: EdenConstants.ACTION_TAKEN_CANCELED);
054: newAtLabels.put(EdenConstants.ACTION_TAKEN_COMPLETED_CD,
055: EdenConstants.ACTION_TAKEN_COMPLETED);
056: newAtLabels.put(EdenConstants.ACTION_TAKEN_ROUTED_CD,
057: EdenConstants.ACTION_TAKEN_ROUTED);
058: newAtLabels.put(EdenConstants.ACTION_TAKEN_DENIED_CD,
059: EdenConstants.ACTION_TAKEN_DENIED);
060: newAtLabels.put(EdenConstants.ACTION_TAKEN_FYI_CD,
061: EdenConstants.ACTION_TAKEN_FYI);
062: newAtLabels.put(EdenConstants.ACTION_TAKEN_SAVED_CD,
063: EdenConstants.ACTION_TAKEN_SAVED);
064: newAtLabels.put(
065: EdenConstants.ACTION_TAKEN_RETURNED_TO_PREVIOUS_CD,
066: EdenConstants.ACTION_TAKEN_RETURNED_TO_PREVIOUS);
067: newAtLabels.put(
068: EdenConstants.ACTION_TAKEN_LOG_DOCUMENT_ACTION_CD,
069: EdenConstants.ACTION_TAKEN_LOG_DOCUMENT_ACTION);
070: newAtLabels.put(EdenConstants.ACTION_TAKEN_MOVE_CD,
071: EdenConstants.ACTION_TAKEN_MOVE);
072: newAtLabels.put(EdenConstants.ACTION_TAKEN_SU_APPROVED_CD,
073: EdenConstants.ACTION_TAKEN_SU_APPROVED);
074: newAtLabels.put(EdenConstants.ACTION_TAKEN_SU_CANCELED_CD,
075: EdenConstants.ACTION_TAKEN_SU_CANCELED);
076: newAtLabels.put(EdenConstants.ACTION_TAKEN_SU_DISAPPROVED_CD,
077: EdenConstants.ACTION_TAKEN_SU_DISAPPROVED);
078: newAtLabels.put(
079: EdenConstants.ACTION_TAKEN_SU_ROUTE_LEVEL_APPROVED_CD,
080: EdenConstants.ACTION_TAKEN_SU_ROUTE_LEVEL_APPROVED);
081: newAtLabels
082: .put(
083: EdenConstants.ACTION_TAKEN_SU_ACTION_REQUEST_APPROVED_CD,
084: EdenConstants.ACTION_TAKEN_SU_ACTION_REQUEST_APPROVED);
085: newAtLabels.put(
086: EdenConstants.ACTION_TAKEN_SU_RETURNED_TO_PREVIOUS_CD,
087: EdenConstants.ACTION_TAKEN_SU_RETURNED_TO_PREVIOUS);
088: newAtLabels
089: .put(
090: EdenConstants.ACTION_TAKEN_SU_ACTION_REQUEST_ACKNOWLEDGED_CD,
091: EdenConstants.ACTION_TAKEN_SU_ACTION_REQUEST_ACKNOWLEDGED);
092: newAtLabels.put(
093: EdenConstants.ACTION_TAKEN_SU_ACTION_REQUEST_FYI_CD,
094: EdenConstants.ACTION_TAKEN_SU_ACTION_REQUEST_FYI);
095: newAtLabels
096: .put(
097: EdenConstants.ACTION_TAKEN_SU_ACTION_REQUEST_COMPLETED_CD,
098: EdenConstants.ACTION_TAKEN_SU_ACTION_REQUEST_COMPLETED);
099: newAtLabels.put(
100: EdenConstants.ACTION_TAKEN_TAKE_WORKGROUP_AUTHORITY_CD,
101: EdenConstants.ACTION_TAKEN_TAKE_WORKGROUP_AUTHORITY);
102: newAtLabels
103: .put(
104: EdenConstants.ACTION_TAKEN_RELEASE_WORKGROUP_AUTHORITY_CD,
105: EdenConstants.ACTION_TAKEN_RELEASE_WORKGROUP_AUTHORITY);
106: return newAtLabels;
107: }
108:
109: private static Map getArLabels() {
110: Map newArLabels = new HashMap();
111: newArLabels.put(EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ,
112: EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL);
113: newArLabels.put(EdenConstants.ACTION_REQUEST_APPROVE_REQ,
114: EdenConstants.ACTION_REQUEST_APPROVE_REQ_LABEL);
115: newArLabels.put(EdenConstants.ACTION_REQUEST_COMPLETE_REQ,
116: EdenConstants.ACTION_REQUEST_COMPLETE_REQ_LABEL);
117: newArLabels.put(EdenConstants.ACTION_REQUEST_FYI_REQ,
118: EdenConstants.ACTION_REQUEST_FYI_REQ_LABEL);
119: return newArLabels;
120: }
121:
122: private static Map getArStatusLabels() {
123: Map newArStatusLabels = new HashMap();
124: newArStatusLabels.put(EdenConstants.ACTION_REQUEST_ACTIVATED,
125: EdenConstants.ACTIVE_LABEL);
126: newArStatusLabels.put(EdenConstants.ACTION_REQUEST_INITIALIZED,
127: EdenConstants.ACTION_REQUEST_INITIALIZED_LABEL);
128: newArStatusLabels.put(EdenConstants.ACTION_REQUEST_DONE_STATE,
129: EdenConstants.ACTION_REQUEST_DONE_STATE_LABEL);
130: return newArStatusLabels;
131: }
132:
133: private static Map getRouteStatusLabels() {
134: Map newRouteStatusLabels = new HashMap();
135: newRouteStatusLabels.put(
136: EdenConstants.ROUTE_HEADER_APPROVED_CD,
137: EdenConstants.ROUTE_HEADER_APPROVED_LABEL);
138: newRouteStatusLabels.put(EdenConstants.ROUTE_HEADER_CANCEL_CD,
139: EdenConstants.ROUTE_HEADER_CANCEL_LABEL);
140: newRouteStatusLabels.put(
141: EdenConstants.ROUTE_HEADER_DISAPPROVED_CD,
142: EdenConstants.ROUTE_HEADER_DISAPPROVED_LABEL);
143: newRouteStatusLabels.put(EdenConstants.ROUTE_HEADER_ENROUTE_CD,
144: EdenConstants.ROUTE_HEADER_ENROUTE_LABEL);
145: newRouteStatusLabels.put(
146: EdenConstants.ROUTE_HEADER_EXCEPTION_CD,
147: EdenConstants.ROUTE_HEADER_EXCEPTION_LABEL);
148: newRouteStatusLabels.put(EdenConstants.ROUTE_HEADER_FINAL_CD,
149: EdenConstants.ROUTE_HEADER_FINAL_LABEL);
150: newRouteStatusLabels.put(
151: EdenConstants.ROUTE_HEADER_INITIATED_CD,
152: EdenConstants.ROUTE_HEADER_INITIATED_LABEL);
153: newRouteStatusLabels.put(
154: EdenConstants.ROUTE_HEADER_PROCESSED_CD,
155: EdenConstants.ROUTE_HEADER_PROCESSED_LABEL);
156: newRouteStatusLabels.put(EdenConstants.ROUTE_HEADER_SAVED_CD,
157: EdenConstants.ROUTE_HEADER_SAVED_LABEL);
158: return newRouteStatusLabels;
159: }
160:
161: private static Map getActiveIndicatorLabels() {
162: Map newActiveIndicatorLabels = new HashMap();
163: newActiveIndicatorLabels.put(new Boolean(true),
164: EdenConstants.ACTIVE_LABEL_LOWER);
165: newActiveIndicatorLabels.put(new Boolean(false),
166: EdenConstants.INACTIVE_LABEL_LOWER);
167: return newActiveIndicatorLabels;
168: }
169:
170: private static Map getPolicyLabels() {
171: Map newDocTypeActiveIndicatorLabels = new HashMap();
172: newDocTypeActiveIndicatorLabels.put(EdenConstants.TRUE_CD,
173: EdenConstants.YES_LABEL);
174: newDocTypeActiveIndicatorLabels.put(EdenConstants.FALSE_CD,
175: EdenConstants.NO_LABEL);
176: newDocTypeActiveIndicatorLabels.put(EdenConstants.INHERITED_CD,
177: EdenConstants.INHERITED_LABEL);
178: return newDocTypeActiveIndicatorLabels;
179: }
180:
181: private static Map getActivationPolicyLabels() {
182: Map newActivationPolicyLabels = new HashMap();
183: newActivationPolicyLabels.put(
184: EdenConstants.ROUTE_LEVEL_PARALLEL,
185: EdenConstants.ROUTE_LEVEL_PARALLEL_LABEL);
186: newActivationPolicyLabels.put(
187: EdenConstants.ROUTE_LEVEL_SEQUENCE,
188: EdenConstants.ROUTE_LEVEL_SEQUENCE_LABEL);
189: return newActivationPolicyLabels;
190: }
191:
192: private static Map getApprovePolicyLabels() {
193: Map approvePolicyLabels = new HashMap();
194: approvePolicyLabels.put(
195: EdenConstants.APPROVE_POLICY_ALL_APPROVE,
196: EdenConstants.APPROVE_POLICY_ALL_APPROVE_LABEL);
197: approvePolicyLabels.put(
198: EdenConstants.APPROVE_POLICY_FIRST_APPROVE,
199: EdenConstants.APPROVE_POLICY_FIRST_APPROVE_LABEL);
200: return approvePolicyLabels;
201: }
202:
203: private static Map getRouteQueueStatusLabels() {
204: Map routeQueueStatusLabels = new HashMap();
205: routeQueueStatusLabels.put(EdenConstants.ROUTE_QUEUE_EXCEPTION,
206: EdenConstants.ROUTE_QUEUE_EXCEPTION_LABEL);
207: routeQueueStatusLabels.put(EdenConstants.ROUTE_QUEUE_QUEUED,
208: EdenConstants.ROUTE_QUEUE_QUEUED_LABEL);
209: routeQueueStatusLabels.put(EdenConstants.ROUTE_QUEUE_ROUTING,
210: EdenConstants.ROUTE_QUEUE_ROUTING_LABEL);
211: return routeQueueStatusLabels;
212: }
213:
214: /**
215: * Given an actionRequest code return the appropriate label.
216: *
217: * @param actionRequestCode
218: * The actionRequestCode to be translated.
219: * @return action request label
220: */
221: static public String getActionRequestLabel(String actionRequestCode) {
222: return (String) arLabels.get(actionRequestCode);
223: }
224:
225: /**
226: * Given an action taken code return the appropriate label for it.
227: *
228: * @param actionTakenCode
229: * action taken code to use to find the label.
230: * @return action taken label
231: */
232: static public String getActionTakenLabel(String actionTakenCode) {
233: return (String) atLabels.get(actionTakenCode);
234: }
235:
236: /**
237: * Return the label for the given request status level.
238: *
239: * @param status
240: * code of the request status
241: * @return label for the corresponding code.
242: */
243: static public String getActionRequestStatusLabel(String status) {
244: return (String) arStatusLabels.get(status);
245: }
246:
247: static public String getRouteStatusLabel(String status) {
248: return (String) routeStatusLabels.get(status);
249: }
250:
251: static public String getActiveIndicatorLabel(Boolean indicator) {
252: return (String) activeIndicatorLabels.get(indicator);
253: }
254:
255: static public String getActivationPolicyLabel(String code) {
256: return (String) activationPolicyLabels.get(code);
257: }
258:
259: static public String getPolicyLabel(String code) {
260: return (String) policyLabels.get(code);
261: }
262:
263: static public String getRouteQueueStatusLabel(
264: String routeQueueStatusCode) {
265: return (String) routeQueueStatusLabels
266: .get(routeQueueStatusCode);
267: }
268:
269: }
|