001    /**
002     * Copyright (c) 2000-2013 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 List<String> getNextTransitionNames(
069                            long companyId, long userId, long workflowTaskId)
070                    throws WorkflowException {
071    
072                    return getWorkflowTaskManager().getNextTransitionNames(
073                            companyId, userId, workflowTaskId);
074            }
075    
076            public static long[] getPooledActorsIds(long companyId, long workflowTaskId)
077                    throws WorkflowException {
078    
079                    return getWorkflowTaskManager().getPooledActorsIds(
080                            companyId, workflowTaskId);
081            }
082    
083            public static WorkflowTask getWorkflowTask(
084                            long companyId, long workflowTaskId)
085                    throws WorkflowException {
086    
087                    return getWorkflowTaskManager().getWorkflowTask(
088                            companyId, workflowTaskId);
089            }
090    
091            public static int getWorkflowTaskCount(long companyId, Boolean completed)
092                    throws WorkflowException {
093    
094                    return getWorkflowTaskManager().getWorkflowTaskCount(
095                            companyId, completed);
096            }
097    
098            public static int getWorkflowTaskCountByRole(
099                            long companyId, long roleId, Boolean completed)
100                    throws WorkflowException {
101    
102                    return getWorkflowTaskManager().getWorkflowTaskCountByRole(
103                            companyId, roleId, completed);
104            }
105    
106            public static int getWorkflowTaskCountBySubmittingUser(
107                            long companyId, long userId, Boolean completed)
108                    throws WorkflowException {
109    
110                    return getWorkflowTaskManager().getWorkflowTaskCountBySubmittingUser(
111                            companyId, userId, completed);
112            }
113    
114            public static int getWorkflowTaskCountByUser(
115                            long companyId, long userId, Boolean completed)
116                    throws WorkflowException {
117    
118                    return getWorkflowTaskManager().getWorkflowTaskCountByUser(
119                            companyId, userId, completed);
120            }
121    
122            public static int getWorkflowTaskCountByUserRoles(
123                            long companyId, long userId, Boolean completed)
124                    throws WorkflowException {
125    
126                    return getWorkflowTaskManager().getWorkflowTaskCountByUserRoles(
127                            companyId, userId, completed);
128            }
129    
130            public static int getWorkflowTaskCountByWorkflowInstance(
131                            long companyId, Long userId, long workflowInstanceId,
132                            Boolean completed)
133                    throws WorkflowException {
134    
135                    return getWorkflowTaskManager().getWorkflowTaskCountByWorkflowInstance(
136                            companyId, userId, workflowInstanceId, completed);
137            }
138    
139            public static WorkflowTaskManager getWorkflowTaskManager() {
140                    PortalRuntimePermission.checkGetBeanProperty(
141                            WorkflowTaskManagerUtil.class);
142    
143                    return _workflowTaskManager;
144            }
145    
146            public static List<WorkflowTask> getWorkflowTasks(
147                            long companyId, Boolean completed, int start, int end,
148                            OrderByComparator orderByComparator)
149                    throws WorkflowException {
150    
151                    return getWorkflowTaskManager().getWorkflowTasks(
152                            companyId, completed, start, end, orderByComparator);
153            }
154    
155            public static List<WorkflowTask> getWorkflowTasksByRole(
156                            long companyId, long roleId, Boolean completed, int start, int end,
157                            OrderByComparator orderByComparator)
158                    throws WorkflowException {
159    
160                    return getWorkflowTaskManager().getWorkflowTasksByRole(
161                            companyId, roleId, completed, start, end, orderByComparator);
162            }
163    
164            public static List<WorkflowTask> getWorkflowTasksBySubmittingUser(
165                            long companyId, long userId, Boolean completed, int start, int end,
166                            OrderByComparator orderByComparator)
167                    throws WorkflowException {
168    
169                    return getWorkflowTaskManager().getWorkflowTasksBySubmittingUser(
170                            companyId, userId, completed, start, end, orderByComparator);
171            }
172    
173            public static List<WorkflowTask> getWorkflowTasksByUser(
174                            long companyId, long userId, Boolean completed, int start, int end,
175                            OrderByComparator orderByComparator)
176                    throws WorkflowException {
177    
178                    return getWorkflowTaskManager().getWorkflowTasksByUser(
179                            companyId, userId, completed, start, end, orderByComparator);
180            }
181    
182            public static List<WorkflowTask> getWorkflowTasksByUserRoles(
183                            long companyId, long userId, Boolean completed, int start, int end,
184                            OrderByComparator orderByComparator)
185                    throws WorkflowException {
186    
187                    return getWorkflowTaskManager().getWorkflowTasksByUserRoles(
188                            companyId, userId, completed, start, end, orderByComparator);
189            }
190    
191            public static List<WorkflowTask> getWorkflowTasksByWorkflowInstance(
192                            long companyId, Long userId, long workflowInstanceId,
193                            Boolean completed, int start, int end,
194                            OrderByComparator orderByComparator)
195                    throws WorkflowException {
196    
197                    return getWorkflowTaskManager().getWorkflowTasksByWorkflowInstance(
198                            companyId, userId, workflowInstanceId, completed, start, end,
199                            orderByComparator);
200            }
201    
202            public static List<WorkflowTask> search(
203                            long companyId, long userId, String keywords, Boolean completed,
204                            Boolean searchByUserRoles, int start, int end,
205                            OrderByComparator orderByComparator)
206                    throws WorkflowException {
207    
208                    return getWorkflowTaskManager().search(
209                            companyId, userId, keywords, completed, searchByUserRoles, start,
210                            end, orderByComparator);
211            }
212    
213            public static List<WorkflowTask> search(
214                            long companyId, long userId, String taskName, String assetType,
215                            Long[] assetPrimaryKey, Date dueDateGT, Date dueDateLT,
216                            Boolean completed, Boolean searchByUserRoles, boolean andOperator,
217                            int start, int end, OrderByComparator orderByComparator)
218                    throws WorkflowException {
219    
220                    return getWorkflowTaskManager().search(
221                            companyId, userId, taskName, assetType, assetPrimaryKey, dueDateGT,
222                            dueDateLT, completed, searchByUserRoles, andOperator, start, end,
223                            orderByComparator);
224            }
225    
226            public static List<WorkflowTask> search(
227                            long companyId, long userId, String keywords, String[] assetTypes,
228                            Boolean completed, Boolean searchByUserRoles, int start, int end,
229                            OrderByComparator orderByComparator)
230                    throws WorkflowException {
231    
232                    return getWorkflowTaskManager().search(
233                            companyId, userId, keywords, assetTypes, completed,
234                            searchByUserRoles, start, end, orderByComparator);
235            }
236    
237            public static int searchCount(
238                            long companyId, long userId, String keywords, Boolean completed,
239                            Boolean searchByUserRoles)
240                    throws WorkflowException {
241    
242                    return getWorkflowTaskManager().searchCount(
243                            companyId, userId, keywords, completed, searchByUserRoles);
244            }
245    
246            public static int searchCount(
247                            long companyId, long userId, String taskName, String assetType,
248                            Long[] assetPrimaryKey, Date dueDateGT, Date dueDateLT,
249                            Boolean completed, Boolean searchByUserRoles, boolean andOperator)
250                    throws WorkflowException {
251    
252                    return getWorkflowTaskManager().searchCount(
253                            companyId, userId, taskName, assetType, assetPrimaryKey, dueDateGT,
254                            dueDateLT, completed, searchByUserRoles, andOperator);
255            }
256    
257            public static int searchCount(
258                            long companyId, long userId, String keywords, String[] assetTypes,
259                            Boolean completed, Boolean searchByUserRoles)
260                    throws WorkflowException {
261    
262                    return getWorkflowTaskManager().searchCount(
263                            companyId, userId, keywords, assetTypes, completed,
264                            searchByUserRoles);
265            }
266    
267            public static WorkflowTask updateDueDate(
268                            long companyId, long userId, long workflowTaskId, String comment,
269                            Date dueDate)
270                    throws WorkflowException {
271    
272                    return getWorkflowTaskManager().updateDueDate(
273                            companyId, userId, workflowTaskId, comment, dueDate);
274            }
275    
276            public void setWorkflowTaskManager(
277                    WorkflowTaskManager workflowTaskManager) {
278    
279                    PortalRuntimePermission.checkSetBeanProperty(getClass());
280    
281                    _workflowTaskManager = workflowTaskManager;
282            }
283    
284            private static WorkflowTaskManager _workflowTaskManager;
285    
286    }