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