001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.workflow;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    import com.liferay.portal.kernel.util.OrderByComparator;
019    
020    import java.io.Serializable;
021    
022    import java.util.Date;
023    import java.util.List;
024    import java.util.Map;
025    
026    /**
027     * @author Micha Kiener
028     * @author Shuyang Zhou
029     * @author Brian Wing Shun Chan
030     * @author Marcellus Tavares
031     * @author Raymond Aug??
032     */
033    public class WorkflowTaskManagerUtil {
034    
035            public static WorkflowTask assignWorkflowTaskToRole(
036                            long companyId, long userId, long workflowTaskId, long roleId,
037                            String comment, Date dueDate,
038                            Map<String, Serializable> workflowContext)
039                    throws WorkflowException {
040    
041                    return getWorkflowTaskManager().assignWorkflowTaskToRole(
042                            companyId, userId, workflowTaskId, roleId, comment, dueDate,
043                            workflowContext);
044            }
045    
046            public static WorkflowTask assignWorkflowTaskToUser(
047                            long companyId, long userId, long workflowTaskId,
048                            long assigneeUserId, String comment, Date dueDate,
049                            Map<String, Serializable> workflowContext)
050                    throws WorkflowException {
051    
052                    return getWorkflowTaskManager().assignWorkflowTaskToUser(
053                            companyId, userId, workflowTaskId, assigneeUserId, comment, dueDate,
054                            workflowContext);
055            }
056    
057            public static WorkflowTask completeWorkflowTask(
058                            long companyId, long userId, long workflowTaskId,
059                            String transitionName, String comment,
060                            Map<String, Serializable> workflowContext)
061                    throws WorkflowException {
062    
063                    return getWorkflowTaskManager().completeWorkflowTask(
064                            companyId, userId, workflowTaskId, transitionName, comment,
065                            workflowContext);
066            }
067    
068            public static WorkflowTask fetchWorkflowTask(
069                            long companyId, long workflowTaskId)
070                    throws WorkflowException {
071    
072                    return getWorkflowTaskManager().fetchWorkflowTask(
073                            companyId, workflowTaskId);
074            }
075    
076            public static List<String> getNextTransitionNames(
077                            long companyId, long userId, long workflowTaskId)
078                    throws WorkflowException {
079    
080                    return getWorkflowTaskManager().getNextTransitionNames(
081                            companyId, userId, workflowTaskId);
082            }
083    
084            public static long[] getPooledActorsIds(long companyId, long workflowTaskId)
085                    throws WorkflowException {
086    
087                    return getWorkflowTaskManager().getPooledActorsIds(
088                            companyId, workflowTaskId);
089            }
090    
091            public static WorkflowTask getWorkflowTask(
092                            long companyId, long workflowTaskId)
093                    throws WorkflowException {
094    
095                    return getWorkflowTaskManager().getWorkflowTask(
096                            companyId, workflowTaskId);
097            }
098    
099            public static int getWorkflowTaskCount(long companyId, Boolean completed)
100                    throws WorkflowException {
101    
102                    return getWorkflowTaskManager().getWorkflowTaskCount(
103                            companyId, completed);
104            }
105    
106            public static int getWorkflowTaskCountByRole(
107                            long companyId, long roleId, Boolean completed)
108                    throws WorkflowException {
109    
110                    return getWorkflowTaskManager().getWorkflowTaskCountByRole(
111                            companyId, roleId, completed);
112            }
113    
114            public static int getWorkflowTaskCountBySubmittingUser(
115                            long companyId, long userId, Boolean completed)
116                    throws WorkflowException {
117    
118                    return getWorkflowTaskManager().getWorkflowTaskCountBySubmittingUser(
119                            companyId, userId, completed);
120            }
121    
122            public static int getWorkflowTaskCountByUser(
123                            long companyId, long userId, Boolean completed)
124                    throws WorkflowException {
125    
126                    return getWorkflowTaskManager().getWorkflowTaskCountByUser(
127                            companyId, userId, completed);
128            }
129    
130            public static int getWorkflowTaskCountByUserRoles(
131                            long companyId, long userId, Boolean completed)
132                    throws WorkflowException {
133    
134                    return getWorkflowTaskManager().getWorkflowTaskCountByUserRoles(
135                            companyId, userId, completed);
136            }
137    
138            public static int getWorkflowTaskCountByWorkflowInstance(
139                            long companyId, Long userId, long workflowInstanceId,
140                            Boolean completed)
141                    throws WorkflowException {
142    
143                    return getWorkflowTaskManager().getWorkflowTaskCountByWorkflowInstance(
144                            companyId, userId, workflowInstanceId, completed);
145            }
146    
147            public static WorkflowTaskManager getWorkflowTaskManager() {
148                    PortalRuntimePermission.checkGetBeanProperty(
149                            WorkflowTaskManagerUtil.class);
150    
151                    return _workflowTaskManager;
152            }
153    
154            public static List<WorkflowTask> getWorkflowTasks(
155                            long companyId, Boolean completed, int start, int end,
156                            OrderByComparator<WorkflowTask> orderByComparator)
157                    throws WorkflowException {
158    
159                    return getWorkflowTaskManager().getWorkflowTasks(
160                            companyId, completed, start, end, orderByComparator);
161            }
162    
163            public static List<WorkflowTask> getWorkflowTasksByRole(
164                            long companyId, long roleId, Boolean completed, int start, int end,
165                            OrderByComparator<WorkflowTask> orderByComparator)
166                    throws WorkflowException {
167    
168                    return getWorkflowTaskManager().getWorkflowTasksByRole(
169                            companyId, roleId, completed, start, end, orderByComparator);
170            }
171    
172            public static List<WorkflowTask> getWorkflowTasksBySubmittingUser(
173                            long companyId, long userId, Boolean completed, int start, int end,
174                            OrderByComparator<WorkflowTask> orderByComparator)
175                    throws WorkflowException {
176    
177                    return getWorkflowTaskManager().getWorkflowTasksBySubmittingUser(
178                            companyId, userId, completed, start, end, orderByComparator);
179            }
180    
181            public static List<WorkflowTask> getWorkflowTasksByUser(
182                            long companyId, long userId, Boolean completed, int start, int end,
183                            OrderByComparator<WorkflowTask> orderByComparator)
184                    throws WorkflowException {
185    
186                    return getWorkflowTaskManager().getWorkflowTasksByUser(
187                            companyId, userId, completed, start, end, orderByComparator);
188            }
189    
190            public static List<WorkflowTask> getWorkflowTasksByUserRoles(
191                            long companyId, long userId, Boolean completed, int start, int end,
192                            OrderByComparator<WorkflowTask> orderByComparator)
193                    throws WorkflowException {
194    
195                    return getWorkflowTaskManager().getWorkflowTasksByUserRoles(
196                            companyId, userId, completed, start, end, orderByComparator);
197            }
198    
199            public static List<WorkflowTask> getWorkflowTasksByWorkflowInstance(
200                            long companyId, Long userId, long workflowInstanceId,
201                            Boolean completed, int start, int end,
202                            OrderByComparator<WorkflowTask> orderByComparator)
203                    throws WorkflowException {
204    
205                    return getWorkflowTaskManager().getWorkflowTasksByWorkflowInstance(
206                            companyId, userId, workflowInstanceId, completed, start, end,
207                            orderByComparator);
208            }
209    
210            public static List<WorkflowTask> search(
211                            long companyId, long userId, String keywords, Boolean completed,
212                            Boolean searchByUserRoles, int start, int end,
213                            OrderByComparator<WorkflowTask> orderByComparator)
214                    throws WorkflowException {
215    
216                    return getWorkflowTaskManager().search(
217                            companyId, userId, keywords, completed, searchByUserRoles, start,
218                            end, orderByComparator);
219            }
220    
221            public static List<WorkflowTask> search(
222                            long companyId, long userId, String taskName, String assetType,
223                            Long[] assetPrimaryKey, Date dueDateGT, Date dueDateLT,
224                            Boolean completed, Boolean searchByUserRoles, boolean andOperator,
225                            int start, int end,
226                            OrderByComparator<WorkflowTask> orderByComparator)
227                    throws WorkflowException {
228    
229                    return getWorkflowTaskManager().search(
230                            companyId, userId, taskName, assetType, assetPrimaryKey, dueDateGT,
231                            dueDateLT, completed, searchByUserRoles, andOperator, start, end,
232                            orderByComparator);
233            }
234    
235            public static List<WorkflowTask> search(
236                            long companyId, long userId, String keywords, String[] assetTypes,
237                            Boolean completed, Boolean searchByUserRoles, int start, int end,
238                            OrderByComparator<WorkflowTask> orderByComparator)
239                    throws WorkflowException {
240    
241                    return getWorkflowTaskManager().search(
242                            companyId, userId, keywords, assetTypes, completed,
243                            searchByUserRoles, start, end, orderByComparator);
244            }
245    
246            public static int searchCount(
247                            long companyId, long userId, String keywords, Boolean completed,
248                            Boolean searchByUserRoles)
249                    throws WorkflowException {
250    
251                    return getWorkflowTaskManager().searchCount(
252                            companyId, userId, keywords, completed, searchByUserRoles);
253            }
254    
255            public static int searchCount(
256                            long companyId, long userId, String taskName, String assetType,
257                            Long[] assetPrimaryKey, Date dueDateGT, Date dueDateLT,
258                            Boolean completed, Boolean searchByUserRoles, boolean andOperator)
259                    throws WorkflowException {
260    
261                    return getWorkflowTaskManager().searchCount(
262                            companyId, userId, taskName, assetType, assetPrimaryKey, dueDateGT,
263                            dueDateLT, completed, searchByUserRoles, andOperator);
264            }
265    
266            public static int searchCount(
267                            long companyId, long userId, String keywords, String[] assetTypes,
268                            Boolean completed, Boolean searchByUserRoles)
269                    throws WorkflowException {
270    
271                    return getWorkflowTaskManager().searchCount(
272                            companyId, userId, keywords, assetTypes, completed,
273                            searchByUserRoles);
274            }
275    
276            public static WorkflowTask updateDueDate(
277                            long companyId, long userId, long workflowTaskId, String comment,
278                            Date dueDate)
279                    throws WorkflowException {
280    
281                    return getWorkflowTaskManager().updateDueDate(
282                            companyId, userId, workflowTaskId, comment, dueDate);
283            }
284    
285            public void setWorkflowTaskManager(
286                    WorkflowTaskManager workflowTaskManager) {
287    
288                    PortalRuntimePermission.checkSetBeanProperty(getClass());
289    
290                    _workflowTaskManager = workflowTaskManager;
291            }
292    
293            private static WorkflowTaskManager _workflowTaskManager;
294    
295    }