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-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.kew.engine;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.HashMap;
 20  
 import java.util.LinkedList;
 21  
 import java.util.List;
 22  
 import java.util.Map;
 23  
 
 24  
 import org.kuali.rice.kew.actionrequest.ActionRequestValue;
 25  
 import org.kuali.rice.kew.api.WorkflowRuntimeException;
 26  
 import org.kuali.rice.kew.engine.node.RouteNodeInstance;
 27  
 import org.kuali.rice.kew.routeheader.DocumentContent;
 28  
 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
 29  
 import org.kuali.rice.kew.routeheader.StandardDocumentContent;
 30  
 
 31  
 
 32  
 /**
 33  
  * Represents the current context of a Document being processed by the engine.
 34  
  *
 35  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 36  
  */
 37  
 public class RouteContext implements Serializable {
 38  
 
 39  
         private static final long serialVersionUID = -7125137491367944594L;
 40  
 
 41  
         private DocumentRouteHeaderValue routeHeader;
 42  
 
 43  
         private DocumentContent documentContent;
 44  
 
 45  
         private RouteNodeInstance nodeInstance;
 46  
 
 47  
         private EngineState engineState;
 48  
 
 49  
         private ActionRequestValue actionRequest;
 50  
 
 51  0
         private ActivationContext activationContext = new ActivationContext(!ActivationContext.CONTEXT_IS_SIMULATION);
 52  
 
 53  0
         private boolean doNotSendApproveNotificationEmails = false;
 54  
 
 55  0
         private Map parameters = new HashMap();
 56  
         
 57  0
         private boolean searchIndexingRequestedForContext = false;
 58  
 
 59  0
         public RouteContext() {
 60  0
         }
 61  
 
 62  0
         private static ThreadLocal<List<RouteContext>> ROUTE_CONTEXT_STACK = new ThreadLocal<List<RouteContext>>() {
 63  
                 protected List<RouteContext> initialValue() {
 64  0
                         List<RouteContext> contextStack = new LinkedList<RouteContext>();
 65  0
                         contextStack.add(0, new RouteContext());
 66  0
                         return contextStack;
 67  
                 }
 68  
         };
 69  
 
 70  
         public static RouteContext getCurrentRouteContext() {
 71  0
                 return ROUTE_CONTEXT_STACK.get().get(0);
 72  
         }
 73  
 
 74  
         public static void clearCurrentRouteContext() {
 75  0
                 ROUTE_CONTEXT_STACK.get().remove(0);
 76  0
                 ROUTE_CONTEXT_STACK.get().add(0, new RouteContext());
 77  0
         }
 78  
 
 79  
         public static RouteContext createNewRouteContext() {
 80  0
                 ROUTE_CONTEXT_STACK.get().add(0, new RouteContext());
 81  0
                 return getCurrentRouteContext();
 82  
         }
 83  
 
 84  
         public static RouteContext releaseCurrentRouteContext() {
 85  0
                 return ROUTE_CONTEXT_STACK.get().remove(0);
 86  
         }
 87  
 
 88  
         /**
 89  
          * @deprecated use getDocument() instead
 90  
          */
 91  
         public DocumentRouteHeaderValue getRouteHeader() {
 92  0
                 return routeHeader;
 93  
         }
 94  
 
 95  
         /**
 96  
          * @deprecated user setDocument() instead
 97  
          */
 98  
         public void setRouteHeader(DocumentRouteHeaderValue routeHeader) {
 99  0
                 this.routeHeader = routeHeader;
 100  0
         }
 101  
 
 102  
         public DocumentRouteHeaderValue getDocument() {
 103  0
                 return routeHeader;
 104  
         }
 105  
 
 106  
         public void setDocument(DocumentRouteHeaderValue routeHeader) {
 107  0
                 this.routeHeader = routeHeader;
 108  
                 try {
 109  0
                         setDocumentContent(new StandardDocumentContent(routeHeader.getDocContent(), this));
 110  0
                 } catch (Exception e) {
 111  0
                         throw new WorkflowRuntimeException(e);
 112  0
                 }
 113  0
         }
 114  
 
 115  
         public DocumentContent getDocumentContent() {
 116  0
                 return documentContent;
 117  
         }
 118  
 
 119  
         public void setDocumentContent(DocumentContent documentContent) {
 120  0
                 this.documentContent = documentContent;
 121  0
         }
 122  
 
 123  
         public RouteNodeInstance getNodeInstance() {
 124  0
                 return nodeInstance;
 125  
         }
 126  
 
 127  
         public void setNodeInstance(RouteNodeInstance nodeInstance) {
 128  0
                 this.nodeInstance = nodeInstance;
 129  0
         }
 130  
 
 131  
         public EngineState getEngineState() {
 132  0
                 return engineState;
 133  
         }
 134  
 
 135  
         public void setEngineState(EngineState engineState) {
 136  0
                 this.engineState = engineState;
 137  0
         }
 138  
 
 139  
         public ActionRequestValue getActionRequest() {
 140  0
                 return actionRequest;
 141  
         }
 142  
 
 143  
         public void setActionRequest(ActionRequestValue actionRequest) {
 144  0
                 this.actionRequest = actionRequest;
 145  0
         }
 146  
 
 147  
         public boolean isSimulation() {
 148  0
                 if (activationContext == null) {
 149  0
                         return false;
 150  
                 }
 151  0
                 return activationContext.isSimulation();
 152  
         }
 153  
 
 154  
         public ActivationContext getActivationContext() {
 155  0
                 return activationContext;
 156  
         }
 157  
 
 158  
         public void setActivationContext(ActivationContext activationContext) {
 159  0
                 this.activationContext = activationContext;
 160  0
         }
 161  
 
 162  
         public boolean isDoNotSendApproveNotificationEmails() {
 163  0
                 return doNotSendApproveNotificationEmails;
 164  
         }
 165  
 
 166  
         public void setDoNotSendApproveNotificationEmails(boolean sendNotificationEmails) {
 167  0
                 this.doNotSendApproveNotificationEmails = sendNotificationEmails;
 168  0
         }
 169  
 
 170  
         public Map getParameters() {
 171  0
                 return parameters;
 172  
         }
 173  
 
 174  
         public void setParameters(Map parameters) {
 175  0
                 this.parameters = parameters;
 176  0
         }
 177  
 
 178  
         /**
 179  
          * Determines if search indexing has already been requested during this context
 180  
          * @return the searchIndexingRequestedForContext: true if search indexing has been requested, false otherwise
 181  
          */
 182  
         public boolean isSearchIndexingRequestedForContext() {
 183  0
                 return this.searchIndexingRequestedForContext;
 184  
         }
 185  
 
 186  
         /**
 187  
          * Sets the route context to let it know that search indexing has been requested
 188  
          */
 189  
         public void requestSearchIndexingForContext() {
 190  0
                 this.searchIndexingRequestedForContext = true;
 191  0
         }
 192  
         
 193  
 }