1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.workflow;
16  
17  import java.io.Serializable;
18  
19  import java.util.ArrayList;
20  import java.util.Date;
21  import java.util.List;
22  import java.util.Map;
23  
24  /**
25   * <a href="DefaultWorkflowInstance.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Michael C. Han
28   * @author Brian Wing Shun Chan
29   */
30  public class DefaultWorkflowInstance implements Serializable, WorkflowInstance {
31  
32      public void addChildWorkflowInstance(
33          WorkflowInstance childWorkflowInstance) {
34  
35          _childrenWorkflowInstances.add(childWorkflowInstance);
36      }
37  
38      public int getChildrenWorkflowInstanceCount() {
39          return _childrenWorkflowInstances.size();
40      }
41  
42      public List<WorkflowInstance> getChildrenWorkflowInstances() {
43          return _childrenWorkflowInstances;
44      }
45  
46      public Date getEndDate() {
47          return _endDate;
48      }
49  
50      public WorkflowInstance getParentWorkflowInstance() {
51          return _parentWorkflowInstance;
52      }
53  
54      public long getParentWorkflowInstanceId() {
55          if (_parentWorkflowInstance != null) {
56              return _parentWorkflowInstance.getWorkflowInstanceId();
57          }
58          else {
59              return 0;
60          }
61      }
62  
63      public Date getStartDate() {
64          return _startDate;
65      }
66  
67      public String getState() {
68          return _state;
69      }
70  
71      public Map<String, Serializable> getWorkflowContext() {
72          return _workflowContext;
73      }
74  
75      public String getWorkflowDefinitionName() {
76          return _workflowDefinitionName;
77      }
78  
79      public int getWorkflowDefinitionVersion() {
80          return _workflowDefinitionVersion;
81      }
82  
83      public long getWorkflowInstanceId() {
84          return _workflowInstanceId;
85      }
86  
87      public void setChildrenWorkflowInstances(
88          List<WorkflowInstance> childrenWorkflowInstances) {
89  
90          _childrenWorkflowInstances = childrenWorkflowInstances;
91      }
92  
93      public void setEndDate(Date endDate) {
94          _endDate = endDate;
95      }
96  
97      public void setParentWorkflowInstance(
98          WorkflowInstance parentWorkflowInstance) {
99  
100         _parentWorkflowInstance = parentWorkflowInstance;
101     }
102 
103     public void setStartDate(Date startDate) {
104         _startDate = startDate;
105     }
106 
107     public void setState(String state) {
108         _state = state;
109     }
110 
111     public void setWorkflowContext(Map<String, Serializable> workflowContext) {
112         _workflowContext = workflowContext;
113     }
114 
115     public void setWorkflowDefinitionName(String workflowDefinitionName) {
116         _workflowDefinitionName = workflowDefinitionName;
117     }
118 
119     public void setWorkflowDefinitionVersion(int workflowDefinitionVersion) {
120         _workflowDefinitionVersion = workflowDefinitionVersion;
121     }
122 
123     public void setWorkflowInstanceId(long workflowInstanceId) {
124         _workflowInstanceId = workflowInstanceId;
125     }
126 
127     private List<WorkflowInstance> _childrenWorkflowInstances =
128         new ArrayList<WorkflowInstance>();
129     private Date _endDate;
130     private WorkflowInstance _parentWorkflowInstance;
131     private Date _startDate;
132     private String _state;
133     private Map<String, Serializable> _workflowContext;
134     private String _workflowDefinitionName;
135     private int _workflowDefinitionVersion;
136     private long _workflowInstanceId;
137 
138 }