001
014
015 package com.liferay.portal.kernel.workflow;
016
017 import com.liferay.portal.model.User;
018
019 import java.io.Serializable;
020
021 import java.util.ArrayList;
022 import java.util.Collection;
023 import java.util.Collections;
024 import java.util.Date;
025 import java.util.List;
026 import java.util.Map;
027
028
033 public class DefaultWorkflowTask implements Serializable, WorkflowTask {
034
035 @Override
036 public long getAssigneeUserId() {
037 if (!isAssignedToSingleUser()) {
038 return -1;
039 }
040
041 WorkflowTaskAssignee workflowTaskAssignee = _workflowTaskAssignees.get(
042 0);
043
044 return workflowTaskAssignee.getAssigneeClassPK();
045 }
046
047 @Override
048 public Date getCompletionDate() {
049 return _completionDate;
050 }
051
052 @Override
053 public Date getCreateDate() {
054 return _createDate;
055 }
056
057 @Override
058 public String getDescription() {
059 return _description;
060 }
061
062 @Override
063 public Date getDueDate() {
064 return _dueDate;
065 }
066
067 @Override
068 public String getName() {
069 return _name;
070 }
071
072 @Override
073 public Map<String, Serializable> getOptionalAttributes() {
074 return _optionalAttributes;
075 }
076
077 @Override
078 public long getWorkflowDefinitionId() {
079 return _workflowDefinitionId;
080 }
081
082 @Override
083 public String getWorkflowDefinitionName() {
084 return _workflowDefinitionName;
085 }
086
087 @Override
088 public int getWorkflowDefinitionVersion() {
089 return _workflowDefinitionVersion;
090 }
091
092 @Override
093 public long getWorkflowInstanceId() {
094 return _workflowInstanceId;
095 }
096
097 @Override
098 public List<WorkflowTaskAssignee> getWorkflowTaskAssignees() {
099 if (_workflowTaskAssignees == null) {
100 return Collections.emptyList();
101 }
102
103 return _workflowTaskAssignees;
104 }
105
106 @Override
107 public long getWorkflowTaskId() {
108 return _workflowTaskId;
109 }
110
111 @Override
112 public boolean isAssignedToSingleUser() {
113 if (_workflowTaskAssignees == null) {
114 return false;
115 }
116
117 if (_workflowTaskAssignees.size() != 1) {
118 return false;
119 }
120
121 WorkflowTaskAssignee workflowTaskAssignee = _workflowTaskAssignees.get(
122 0);
123
124 if (User.class.getName().equals(
125 workflowTaskAssignee.getAssigneeClassName())) {
126
127 return true;
128 }
129 else {
130 return false;
131 }
132 }
133
134 @Override
135 public boolean isAsynchronous() {
136 return _asynchronous;
137 }
138
139 @Override
140 public boolean isCompleted() {
141 if (_completionDate != null) {
142 return true;
143 }
144 else {
145 return false;
146 }
147 }
148
149 public void setAsynchronous(boolean asynchronous) {
150 _asynchronous = asynchronous;
151 }
152
153 public void setCompletionDate(Date completionDate) {
154 _completionDate = completionDate;
155 }
156
157 public void setCreateDate(Date createDate) {
158 _createDate = createDate;
159 }
160
161 public void setDescription(String description) {
162 _description = description;
163 }
164
165 public void setDueDate(Date dueDate) {
166 _dueDate = dueDate;
167 }
168
169 public void setName(String name) {
170 _name = name;
171 }
172
173 public void setOptionalAttributes(
174 Map<String, Serializable> optionalAttributes) {
175
176 _optionalAttributes = optionalAttributes;
177 }
178
179 public void setWorkflowDefinitionId(long workflowDefinitionId) {
180 _workflowDefinitionId = workflowDefinitionId;
181 }
182
183 public void setWorkflowDefinitionName(String workflowDefinitionName) {
184 _workflowDefinitionName = workflowDefinitionName;
185 }
186
187 public void setWorkflowDefinitionVersion(int workflowDefinitionVersion) {
188 _workflowDefinitionVersion = workflowDefinitionVersion;
189 }
190
191 public void setWorkflowInstanceId(long workflowInstanceId) {
192 _workflowInstanceId = workflowInstanceId;
193 }
194
195 public void setWorkflowTaskAssignees(
196 Collection<WorkflowTaskAssignee> workflowTaskAssignees) {
197
198 if (_workflowTaskAssignees == null) {
199 _workflowTaskAssignees = new ArrayList<WorkflowTaskAssignee>();
200 }
201
202 _workflowTaskAssignees.addAll(workflowTaskAssignees);
203 }
204
205 public void setWorkflowTaskId(long workflowTaskId) {
206 _workflowTaskId = workflowTaskId;
207 }
208
209 private boolean _asynchronous;
210 private Date _completionDate;
211 private Date _createDate;
212 private String _description;
213 private Date _dueDate;
214 private String _name;
215 private Map<String, Serializable> _optionalAttributes;
216 private long _workflowDefinitionId;
217 private String _workflowDefinitionName;
218 private int _workflowDefinitionVersion;
219 private long _workflowInstanceId;
220 private List<WorkflowTaskAssignee> _workflowTaskAssignees;
221 private long _workflowTaskId;
222
223 }