001/**
002 * Copyright 2005-2017 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kew.engine;
017
018import org.kuali.rice.kew.actionrequest.ActionRequestValue;
019import org.kuali.rice.kew.engine.node.RouteNodeInstance;
020
021import java.io.Serializable;
022import java.util.ArrayList;
023import java.util.List;
024
025
026/**
027 * Represents the current state of the workflow engine.
028 * 
029 * @author Kuali Rice Team (rice.collab@kuali.org)
030 */
031public class EngineState implements Serializable {
032    
033        private static final long serialVersionUID = 2405363802483005090L;
034
035        private static int currentSimulationId = -10;
036    
037    private RouteNodeInstance transitioningFrom;
038    private RouteNodeInstance transitioningTo;
039    private List<String> completeNodeInstances = new ArrayList<String>();
040    private List<ActionRequestValue> generatedRequests = new ArrayList<ActionRequestValue>();
041    
042    public List<String> getCompleteNodeInstances() {
043        return completeNodeInstances;
044    }
045    public void setCompleteNodeInstances(List<String> completeNodeInstances) {
046        this.completeNodeInstances = completeNodeInstances;
047    }
048    public RouteNodeInstance getTransitioningFrom() {
049        return transitioningFrom;
050    }
051    public void setTransitioningFrom(RouteNodeInstance transitioningFrom) {
052        this.transitioningFrom = transitioningFrom;
053    }
054    public RouteNodeInstance getTransitioningTo() {
055        return transitioningTo;
056    }
057    public void setTransitioningTo(RouteNodeInstance transitioningTo) {
058        this.transitioningTo = transitioningTo;
059    }
060    public List<ActionRequestValue> getGeneratedRequests() {
061        return generatedRequests;
062    }
063    public void setGeneratedRequests(List<ActionRequestValue> generatedRequests) {
064        this.generatedRequests = generatedRequests;
065    }
066    
067    /**
068     * Gets the next id to be used for simulation purposes.  Since, during simulation, we cannot save to the database and get primary keys
069     * assigned to our data beans, this method will be used to get a new simulation id which is guaranteed to be a negative number
070     * which will be unique for at least the lifetime of the simulation.
071     */
072    public String getNextSimulationId() {
073        synchronized (EngineState.class) {
074            return String.valueOf(currentSimulationId--);
075        }
076    }
077    
078}