001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.workflow;
016    
017    import java.io.Serializable;
018    
019    import java.util.ArrayList;
020    import java.util.Date;
021    import java.util.List;
022    import java.util.Map;
023    
024    /**
025     * @author Michael C. Han
026     * @author Brian Wing Shun Chan
027     */
028    public class DefaultWorkflowInstance implements Serializable, WorkflowInstance {
029    
030            public void addChildWorkflowInstance(
031                    WorkflowInstance childWorkflowInstance) {
032    
033                    _childrenWorkflowInstances.add(childWorkflowInstance);
034            }
035    
036            public int getChildrenWorkflowInstanceCount() {
037                    return _childrenWorkflowInstances.size();
038            }
039    
040            public List<WorkflowInstance> getChildrenWorkflowInstances() {
041                    return _childrenWorkflowInstances;
042            }
043    
044            public Date getEndDate() {
045                    return _endDate;
046            }
047    
048            public WorkflowInstance getParentWorkflowInstance() {
049                    return _parentWorkflowInstance;
050            }
051    
052            public long getParentWorkflowInstanceId() {
053                    if (_parentWorkflowInstance != null) {
054                            return _parentWorkflowInstance.getWorkflowInstanceId();
055                    }
056                    else {
057                            return 0;
058                    }
059            }
060    
061            public Date getStartDate() {
062                    return _startDate;
063            }
064    
065            public String getState() {
066                    return _state;
067            }
068    
069            public Map<String, Serializable> getWorkflowContext() {
070                    return _workflowContext;
071            }
072    
073            public String getWorkflowDefinitionName() {
074                    return _workflowDefinitionName;
075            }
076    
077            public int getWorkflowDefinitionVersion() {
078                    return _workflowDefinitionVersion;
079            }
080    
081            public long getWorkflowInstanceId() {
082                    return _workflowInstanceId;
083            }
084    
085            public boolean isComplete() {
086                    if (getEndDate() != null) {
087                            return true;
088                    }
089                    else {
090                            return false;
091                    }
092            }
093    
094            public void setChildrenWorkflowInstances(
095                    List<WorkflowInstance> childrenWorkflowInstances) {
096    
097                    _childrenWorkflowInstances = childrenWorkflowInstances;
098            }
099    
100            public void setEndDate(Date endDate) {
101                    _endDate = endDate;
102            }
103    
104            public void setParentWorkflowInstance(
105                    WorkflowInstance parentWorkflowInstance) {
106    
107                    _parentWorkflowInstance = parentWorkflowInstance;
108            }
109    
110            public void setStartDate(Date startDate) {
111                    _startDate = startDate;
112            }
113    
114            public void setState(String state) {
115                    _state = state;
116            }
117    
118            public void setWorkflowContext(Map<String, Serializable> workflowContext) {
119                    _workflowContext = workflowContext;
120            }
121    
122            public void setWorkflowDefinitionName(String workflowDefinitionName) {
123                    _workflowDefinitionName = workflowDefinitionName;
124            }
125    
126            public void setWorkflowDefinitionVersion(int workflowDefinitionVersion) {
127                    _workflowDefinitionVersion = workflowDefinitionVersion;
128            }
129    
130            public void setWorkflowInstanceId(long workflowInstanceId) {
131                    _workflowInstanceId = workflowInstanceId;
132            }
133    
134            private List<WorkflowInstance> _childrenWorkflowInstances =
135                    new ArrayList<WorkflowInstance>();
136            private Date _endDate;
137            private WorkflowInstance _parentWorkflowInstance;
138            private Date _startDate;
139            private String _state;
140            private Map<String, Serializable> _workflowContext;
141            private String _workflowDefinitionName;
142            private int _workflowDefinitionVersion;
143            private long _workflowInstanceId;
144    
145    }