Coverage Report - org.kuali.rice.kew.util.CodeTranslator
 
Classes in this File Line Coverage Branch Coverage Complexity
CodeTranslator
0%
0/82
N/A
1
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.util;
 18  
 
 19  
 import java.util.HashMap;
 20  
 import java.util.Map;
 21  
 
 22  
 
 23  
 /**
 24  
  * Utility class to translate the various codes into labels and vice versa.
 25  
  *
 26  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 27  
  */
 28  0
 public class CodeTranslator {
 29  0
     public static final Map arLabels = getArLabels();
 30  0
     public static final Map atLabels = getAtLabels();
 31  0
     public static final Map arStatusLabels = getArStatusLabels();
 32  0
     public static final Map routeStatusLabels = getRouteStatusLabels();
 33  0
     public static final Map activeIndicatorLabels = getActiveIndicatorLabels();
 34  0
     public static final Map activationPolicyLabels = getActivationPolicyLabels();
 35  0
     public static final Map policyLabels = getPolicyLabels();
 36  0
     public static final Map approvePolicyLabels = getApprovePolicyLabels();
 37  
 
 38  
     private static Map getAtLabels() {
 39  0
         Map newAtLabels = new HashMap();
 40  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_ACKNOWLEDGED_CD, KEWConstants.ACTION_TAKEN_ACKNOWLEDGED);
 41  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_ADHOC_CD, KEWConstants.ACTION_TAKEN_ADHOC);
 42  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_ADHOC_REVOKED_CD, KEWConstants.ACTION_TAKEN_ADHOC_REVOKED);
 43  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_APPROVED_CD, KEWConstants.ACTION_TAKEN_APPROVED);
 44  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_BLANKET_APPROVE_CD, KEWConstants.ACTION_TAKEN_BLANKET_APPROVE);
 45  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_CANCELED_CD, KEWConstants.ACTION_TAKEN_CANCELED);
 46  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_COMPLETED_CD, KEWConstants.ACTION_TAKEN_COMPLETED);
 47  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_ROUTED_CD, KEWConstants.ACTION_TAKEN_ROUTED);
 48  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_DENIED_CD, KEWConstants.ACTION_TAKEN_DENIED);
 49  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_FYI_CD, KEWConstants.ACTION_TAKEN_FYI);
 50  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_SAVED_CD, KEWConstants.ACTION_TAKEN_SAVED);
 51  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_RETURNED_TO_PREVIOUS_CD, KEWConstants.ACTION_TAKEN_RETURNED_TO_PREVIOUS);
 52  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_LOG_DOCUMENT_ACTION_CD, KEWConstants.ACTION_TAKEN_LOG_DOCUMENT_ACTION);
 53  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_MOVE_CD, KEWConstants.ACTION_TAKEN_MOVE);
 54  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_SU_APPROVED_CD, KEWConstants.ACTION_TAKEN_SU_APPROVED);
 55  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_SU_CANCELED_CD, KEWConstants.ACTION_TAKEN_SU_CANCELED);
 56  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_SU_DISAPPROVED_CD, KEWConstants.ACTION_TAKEN_SU_DISAPPROVED);
 57  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_SU_ROUTE_LEVEL_APPROVED_CD, KEWConstants.ACTION_TAKEN_SU_ROUTE_LEVEL_APPROVED);
 58  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_SU_ACTION_REQUEST_APPROVED_CD, KEWConstants.ACTION_TAKEN_SU_ACTION_REQUEST_APPROVED);
 59  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_SU_RETURNED_TO_PREVIOUS_CD, KEWConstants.ACTION_TAKEN_SU_RETURNED_TO_PREVIOUS);
 60  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_SU_ACTION_REQUEST_ACKNOWLEDGED_CD, KEWConstants.ACTION_TAKEN_SU_ACTION_REQUEST_ACKNOWLEDGED);
 61  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_SU_ACTION_REQUEST_FYI_CD, KEWConstants.ACTION_TAKEN_SU_ACTION_REQUEST_FYI);
 62  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_SU_ACTION_REQUEST_COMPLETED_CD, KEWConstants.ACTION_TAKEN_SU_ACTION_REQUEST_COMPLETED);
 63  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_TAKE_WORKGROUP_AUTHORITY_CD, KEWConstants.ACTION_TAKEN_TAKE_WORKGROUP_AUTHORITY);
 64  0
         newAtLabels.put(KEWConstants.ACTION_TAKEN_RELEASE_WORKGROUP_AUTHORITY_CD, KEWConstants.ACTION_TAKEN_RELEASE_WORKGROUP_AUTHORITY);
 65  0
         return newAtLabels;
 66  
     }
 67  
 
 68  
     private static Map getArLabels() {
 69  0
         Map newArLabels = new HashMap();
 70  0
         newArLabels.put(KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL);
 71  0
         newArLabels.put(KEWConstants.ACTION_REQUEST_APPROVE_REQ, KEWConstants.ACTION_REQUEST_APPROVE_REQ_LABEL);
 72  0
         newArLabels.put(KEWConstants.ACTION_REQUEST_COMPLETE_REQ, KEWConstants.ACTION_REQUEST_COMPLETE_REQ_LABEL);
 73  0
         newArLabels.put(KEWConstants.ACTION_REQUEST_FYI_REQ, KEWConstants.ACTION_REQUEST_FYI_REQ_LABEL);
 74  0
         return newArLabels;
 75  
     }
 76  
 
 77  
     private static Map getArStatusLabels() {
 78  0
         Map newArStatusLabels = new HashMap();
 79  0
         newArStatusLabels.put(KEWConstants.ACTION_REQUEST_ACTIVATED, KEWConstants.ACTIVE_LABEL);
 80  0
         newArStatusLabels.put(KEWConstants.ACTION_REQUEST_INITIALIZED, KEWConstants.ACTION_REQUEST_INITIALIZED_LABEL);
 81  0
         newArStatusLabels.put(KEWConstants.ACTION_REQUEST_DONE_STATE, KEWConstants.ACTION_REQUEST_DONE_STATE_LABEL);
 82  0
         return newArStatusLabels;
 83  
     }
 84  
 
 85  
     private static Map getRouteStatusLabels() {
 86  0
         Map newRouteStatusLabels = new HashMap();
 87  0
         newRouteStatusLabels.put(KEWConstants.ROUTE_HEADER_APPROVED_CD, KEWConstants.ROUTE_HEADER_APPROVED_LABEL);
 88  0
         newRouteStatusLabels.put(KEWConstants.ROUTE_HEADER_CANCEL_CD, KEWConstants.ROUTE_HEADER_CANCEL_LABEL);
 89  0
         newRouteStatusLabels.put(KEWConstants.ROUTE_HEADER_DISAPPROVED_CD, KEWConstants.ROUTE_HEADER_DISAPPROVED_LABEL);
 90  0
         newRouteStatusLabels.put(KEWConstants.ROUTE_HEADER_ENROUTE_CD, KEWConstants.ROUTE_HEADER_ENROUTE_LABEL);
 91  0
         newRouteStatusLabels.put(KEWConstants.ROUTE_HEADER_EXCEPTION_CD, KEWConstants.ROUTE_HEADER_EXCEPTION_LABEL);
 92  0
         newRouteStatusLabels.put(KEWConstants.ROUTE_HEADER_FINAL_CD, KEWConstants.ROUTE_HEADER_FINAL_LABEL);
 93  0
         newRouteStatusLabels.put(KEWConstants.ROUTE_HEADER_INITIATED_CD, KEWConstants.ROUTE_HEADER_INITIATED_LABEL);
 94  0
         newRouteStatusLabels.put(KEWConstants.ROUTE_HEADER_PROCESSED_CD, KEWConstants.ROUTE_HEADER_PROCESSED_LABEL);
 95  0
         newRouteStatusLabels.put(KEWConstants.ROUTE_HEADER_SAVED_CD, KEWConstants.ROUTE_HEADER_SAVED_LABEL);
 96  0
         return newRouteStatusLabels;
 97  
     }
 98  
 
 99  
     private static Map getActiveIndicatorLabels() {
 100  0
         Map newActiveIndicatorLabels = new HashMap();
 101  0
         newActiveIndicatorLabels.put(Boolean.TRUE, KEWConstants.ACTIVE_LABEL_LOWER);
 102  0
         newActiveIndicatorLabels.put(Boolean.FALSE, KEWConstants.INACTIVE_LABEL_LOWER);
 103  0
         return newActiveIndicatorLabels;
 104  
     }
 105  
 
 106  
     private static Map getPolicyLabels() {
 107  0
         Map newDocTypeActiveIndicatorLabels = new HashMap();
 108  0
         newDocTypeActiveIndicatorLabels.put(KEWConstants.TRUE_CD, KEWConstants.YES_LABEL);
 109  0
         newDocTypeActiveIndicatorLabels.put(KEWConstants.FALSE_CD, KEWConstants.NO_LABEL);
 110  0
         newDocTypeActiveIndicatorLabels.put(KEWConstants.INHERITED_CD, KEWConstants.INHERITED_LABEL);
 111  0
         return newDocTypeActiveIndicatorLabels;
 112  
     }
 113  
 
 114  
     private static Map getActivationPolicyLabels() {
 115  0
         Map newActivationPolicyLabels = new HashMap();
 116  0
         newActivationPolicyLabels.put(KEWConstants.ROUTE_LEVEL_PARALLEL, KEWConstants.ROUTE_LEVEL_PARALLEL_LABEL);
 117  0
         newActivationPolicyLabels.put(KEWConstants.ROUTE_LEVEL_SEQUENCE, KEWConstants.ROUTE_LEVEL_SEQUENCE_LABEL);
 118  0
         return newActivationPolicyLabels;
 119  
     }
 120  
 
 121  
     private static Map getApprovePolicyLabels() {
 122  0
         Map approvePolicyLabels = new HashMap();
 123  0
         approvePolicyLabels.put(KEWConstants.APPROVE_POLICY_ALL_APPROVE, KEWConstants.APPROVE_POLICY_ALL_APPROVE_LABEL);
 124  0
         approvePolicyLabels.put(KEWConstants.APPROVE_POLICY_FIRST_APPROVE, KEWConstants.APPROVE_POLICY_FIRST_APPROVE_LABEL);
 125  0
         return approvePolicyLabels;
 126  
     }
 127  
 
 128  
     /**
 129  
      * Given an actionRequest code return the appropriate label.
 130  
      *
 131  
      * @param actionRequestCode
 132  
      *            The actionRequestCode to be translated.
 133  
      * @return action request label
 134  
      */
 135  
     static public String getActionRequestLabel(String actionRequestCode) {
 136  0
         return (String) arLabels.get(actionRequestCode);
 137  
     }
 138  
 
 139  
     /**
 140  
      * Given an action taken code return the appropriate label for it.
 141  
      *
 142  
      * @param actionTakenCode
 143  
      *            action taken code to use to find the label.
 144  
      * @return action taken label
 145  
      */
 146  
     static public String getActionTakenLabel(String actionTakenCode) {
 147  0
         return (String) atLabels.get(actionTakenCode);
 148  
     }
 149  
 
 150  
     /**
 151  
      * Return the label for the given request status level.
 152  
      *
 153  
      * @param status
 154  
      *            code of the request status
 155  
      * @return label for the corresponding code.
 156  
      */
 157  
     static public String getActionRequestStatusLabel(String status) {
 158  0
         return (String) arStatusLabels.get(status);
 159  
     }
 160  
 
 161  
     static public String getRouteStatusLabel(String status) {
 162  0
         return (String) routeStatusLabels.get(status);
 163  
     }
 164  
 
 165  
     static public String getActiveIndicatorLabel(Boolean indicator) {
 166  0
         return (String) activeIndicatorLabels.get(indicator);
 167  
     }
 168  
 
 169  
     static public String getActivationPolicyLabel(String code) {
 170  0
         return (String) activationPolicyLabels.get(code);
 171  
     }
 172  
 
 173  
     static public String getPolicyLabel(String code) {
 174  0
         return (String) policyLabels.get(code);
 175  
     }
 176  
 
 177  
 }