Coverage Report - org.kuali.rice.kew.engine.RouteContext
 
Classes in this File Line Coverage Branch Coverage Complexity
RouteContext
0%
0/51
0%
0/2
1.148
RouteContext$1
0%
0/4
N/A
1.148
 
 1  
 /*
 2  
  * Copyright 2005-2008 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.engine;
 18  
 
 19  
 import java.io.Serializable;
 20  
 import java.util.HashMap;
 21  
 import java.util.LinkedList;
 22  
 import java.util.List;
 23  
 import java.util.Map;
 24  
 
 25  
 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
 26  
 import org.kuali.rice.kew.api.WorkflowRuntimeException;
 27  
 import org.kuali.rice.kew.engine.node.RouteNodeInstance;
 28  
 import org.kuali.rice.kew.routeheader.DocumentContent;
 29  
 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
 30  
 import org.kuali.rice.kew.routeheader.StandardDocumentContent;
 31  
 
 32  
 
 33  
 /**
 34  
  * Represents the current context of a Document being processed by the engine.
 35  
  *
 36  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 37  
  */
 38  
 public class RouteContext implements Serializable {
 39  
 
 40  
         private static final long serialVersionUID = -7125137491367944594L;
 41  
 
 42  
         private DocumentRouteHeaderValue routeHeader;
 43  
 
 44  
         private DocumentContent documentContent;
 45  
 
 46  
         private RouteNodeInstance nodeInstance;
 47  
 
 48  
         private EngineState engineState;
 49  
 
 50  
         private ActionRequestValue actionRequest;
 51  
 
 52  0
         private ActivationContext activationContext = new ActivationContext(!ActivationContext.CONTEXT_IS_SIMULATION);
 53  
 
 54  0
         private boolean doNotSendApproveNotificationEmails = false;
 55  
 
 56  0
         private Map parameters = new HashMap();
 57  
         
 58  0
         private boolean searchIndexingRequestedForContext = false;
 59  
 
 60  0
         public RouteContext() {
 61  0
         }
 62  
 
 63  0
         private static ThreadLocal<List<RouteContext>> ROUTE_CONTEXT_STACK = new ThreadLocal<List<RouteContext>>() {
 64  
                 protected List<RouteContext> initialValue() {
 65  0
                         List<RouteContext> contextStack = new LinkedList<RouteContext>();
 66  0
                         contextStack.add(0, new RouteContext());
 67  0
                         return contextStack;
 68  
                 }
 69  
         };
 70  
 
 71  
         public static RouteContext getCurrentRouteContext() {
 72  0
                 return ROUTE_CONTEXT_STACK.get().get(0);
 73  
         }
 74  
 
 75  
         public static void clearCurrentRouteContext() {
 76  0
                 ROUTE_CONTEXT_STACK.get().remove(0);
 77  0
                 ROUTE_CONTEXT_STACK.get().add(0, new RouteContext());
 78  0
         }
 79  
 
 80  
         public static RouteContext createNewRouteContext() {
 81  0
                 ROUTE_CONTEXT_STACK.get().add(0, new RouteContext());
 82  0
                 return getCurrentRouteContext();
 83  
         }
 84  
 
 85  
         public static RouteContext releaseCurrentRouteContext() {
 86  0
                 return ROUTE_CONTEXT_STACK.get().remove(0);
 87  
         }
 88  
 
 89  
         /**
 90  
          * @deprecated use getDocument() instead
 91  
          */
 92  
         public DocumentRouteHeaderValue getRouteHeader() {
 93  0
                 return routeHeader;
 94  
         }
 95  
 
 96  
         /**
 97  
          * @deprecated user setDocument() instead
 98  
          */
 99  
         public void setRouteHeader(DocumentRouteHeaderValue routeHeader) {
 100  0
                 this.routeHeader = routeHeader;
 101  0
         }
 102  
 
 103  
         public DocumentRouteHeaderValue getDocument() {
 104  0
                 return routeHeader;
 105  
         }
 106  
 
 107  
         public void setDocument(DocumentRouteHeaderValue routeHeader) {
 108  0
                 this.routeHeader = routeHeader;
 109  
                 try {
 110  0
                         setDocumentContent(new StandardDocumentContent(routeHeader.getDocContent(), this));
 111  0
                 } catch (Exception e) {
 112  0
                         throw new WorkflowRuntimeException(e);
 113  0
                 }
 114  0
         }
 115  
 
 116  
         public DocumentContent getDocumentContent() {
 117  0
                 return documentContent;
 118  
         }
 119  
 
 120  
         public void setDocumentContent(DocumentContent documentContent) {
 121  0
                 this.documentContent = documentContent;
 122  0
         }
 123  
 
 124  
         public RouteNodeInstance getNodeInstance() {
 125  0
                 return nodeInstance;
 126  
         }
 127  
 
 128  
         public void setNodeInstance(RouteNodeInstance nodeInstance) {
 129  0
                 this.nodeInstance = nodeInstance;
 130  0
         }
 131  
 
 132  
         public EngineState getEngineState() {
 133  0
                 return engineState;
 134  
         }
 135  
 
 136  
         public void setEngineState(EngineState engineState) {
 137  0
                 this.engineState = engineState;
 138  0
         }
 139  
 
 140  
         public ActionRequestValue getActionRequest() {
 141  0
                 return actionRequest;
 142  
         }
 143  
 
 144  
         public void setActionRequest(ActionRequestValue actionRequest) {
 145  0
                 this.actionRequest = actionRequest;
 146  0
         }
 147  
 
 148  
         public boolean isSimulation() {
 149  0
                 if (activationContext == null) {
 150  0
                         return false;
 151  
                 }
 152  0
                 return activationContext.isSimulation();
 153  
         }
 154  
 
 155  
         public ActivationContext getActivationContext() {
 156  0
                 return activationContext;
 157  
         }
 158  
 
 159  
         public void setActivationContext(ActivationContext activationContext) {
 160  0
                 this.activationContext = activationContext;
 161  0
         }
 162  
 
 163  
         public boolean isDoNotSendApproveNotificationEmails() {
 164  0
                 return doNotSendApproveNotificationEmails;
 165  
         }
 166  
 
 167  
         public void setDoNotSendApproveNotificationEmails(boolean sendNotificationEmails) {
 168  0
                 this.doNotSendApproveNotificationEmails = sendNotificationEmails;
 169  0
         }
 170  
 
 171  
         public Map getParameters() {
 172  0
                 return parameters;
 173  
         }
 174  
 
 175  
         public void setParameters(Map parameters) {
 176  0
                 this.parameters = parameters;
 177  0
         }
 178  
 
 179  
         /**
 180  
          * Determines if search indexing has already been requested during this context
 181  
          * @return the searchIndexingRequestedForContext: true if search indexing has been requested, false otherwise
 182  
          */
 183  
         public boolean isSearchIndexingRequestedForContext() {
 184  0
                 return this.searchIndexingRequestedForContext;
 185  
         }
 186  
 
 187  
         /**
 188  
          * Sets the route context to let it know that search indexing has been requested
 189  
          */
 190  
         public void requestSearchIndexingForContext() {
 191  0
                 this.searchIndexingRequestedForContext = true;
 192  0
         }
 193  
         
 194  
 }