View Javadoc
1   /**
2    * Copyright 2005-2014 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 org.kuali.rice.kew.actionrequest.ActionRequestValue;
19  import org.kuali.rice.kew.engine.node.RouteNodeInstance;
20  
21  import java.io.Serializable;
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  
26  /**
27   * Represents the current state of the workflow engine.
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class EngineState implements Serializable {
32      
33  	private static final long serialVersionUID = 2405363802483005090L;
34  
35  	private static int currentSimulationId = -10;
36      
37      private RouteNodeInstance transitioningFrom;
38      private RouteNodeInstance transitioningTo;
39      private List<String> completeNodeInstances = new ArrayList<String>();
40      private List<ActionRequestValue> generatedRequests = new ArrayList<ActionRequestValue>();
41      
42      public List<String> getCompleteNodeInstances() {
43          return completeNodeInstances;
44      }
45      public void setCompleteNodeInstances(List<String> completeNodeInstances) {
46          this.completeNodeInstances = completeNodeInstances;
47      }
48      public RouteNodeInstance getTransitioningFrom() {
49          return transitioningFrom;
50      }
51      public void setTransitioningFrom(RouteNodeInstance transitioningFrom) {
52          this.transitioningFrom = transitioningFrom;
53      }
54      public RouteNodeInstance getTransitioningTo() {
55          return transitioningTo;
56      }
57      public void setTransitioningTo(RouteNodeInstance transitioningTo) {
58          this.transitioningTo = transitioningTo;
59      }
60      public List<ActionRequestValue> getGeneratedRequests() {
61          return generatedRequests;
62      }
63      public void setGeneratedRequests(List<ActionRequestValue> generatedRequests) {
64          this.generatedRequests = generatedRequests;
65      }
66      
67      /**
68       * Gets the next id to be used for simulation purposes.  Since, during simulation, we cannot save to the database and get primary keys
69       * assigned to our data beans, this method will be used to get a new simulation id which is guaranteed to be a negative number
70       * which will be unique for at least the lifetime of the simulation.
71       */
72      public String getNextSimulationId() {
73          synchronized (EngineState.class) {
74              return String.valueOf(currentSimulationId--);
75          }
76      }
77      
78  }