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 Map<String, Serializable> getContext() {
47          return _context;
48      }
49  
50      public Date getEndDate() {
51          return _endDate;
52      }
53      public WorkflowInstance getParentWorkflowInstance() {
54          return _parentWorkflowInstance;
55      }
56  
57      public long getParentWorkflowInstanceId() {
58          if (_parentWorkflowInstance != null) {
59              return _parentWorkflowInstance.getWorkflowInstanceId();
60          }
61          else {
62              return 0;
63          }
64      }
65  
66      public Date getStartDate() {
67          return _startDate;
68      }
69  
70      public String getState() {
71          return _state;
72      }
73  
74      public String getWorkflowDefinitionName() {
75          return _workflowDefinitionName;
76      }
77  
78      public int getWorkflowDefinitionVersion() {
79          return _workflowDefinitionVersion;
80      }
81  
82      public long getWorkflowInstanceId() {
83          return _workflowInstanceId;
84      }
85  
86      public void setChildrenWorkflowInstances(
87          List<WorkflowInstance> childrenWorkflowInstances) {
88  
89          _childrenWorkflowInstances = childrenWorkflowInstances;
90      }
91  
92      public void setContext(Map<String, Serializable> context) {
93          _context = context;
94      }
95  
96      public void setEndDate(Date endDate) {
97          _endDate = endDate;
98      }
99  
100     public void setParentWorkflowInstance(
101         WorkflowInstance parentWorkflowInstance) {
102 
103         _parentWorkflowInstance = parentWorkflowInstance;
104     }
105 
106     public void setStartDate(Date startDate) {
107         _startDate = startDate;
108     }
109 
110     public void setState(String state) {
111         _state = state;
112     }
113 
114     public void setWorkflowDefinitionName(String workflowDefinitionName) {
115         _workflowDefinitionName = workflowDefinitionName;
116     }
117 
118     public void setWorkflowDefinitionVersion(int workflowDefinitionVersion) {
119         _workflowDefinitionVersion = workflowDefinitionVersion;
120     }
121 
122     public void setWorkflowInstanceId(long workflowInstanceId) {
123         _workflowInstanceId = workflowInstanceId;
124     }
125 
126     private List<WorkflowInstance> _childrenWorkflowInstances =
127         new ArrayList<WorkflowInstance>();
128     private Map<String, Serializable> _context;
129     private Date _endDate;
130     private WorkflowInstance _parentWorkflowInstance;
131     private Date _startDate;
132     private String _state;
133     private String _workflowDefinitionName;
134     private int _workflowDefinitionVersion;
135     private long _workflowInstanceId;
136 
137 }