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.List;
023    import java.util.Map;
024    
025    /**
026     * @author Micha Kiener
027     * @author Shuyang Zhou
028     * @author Brian Wing Shun Chan
029     * @author Marcellus Tavares
030     * @author Raymond Aug??
031     */
032    public class WorkflowInstanceManagerUtil {
033    
034            public static void deleteWorkflowInstance(
035                            long companyId, long workflowInstanceId)
036                    throws WorkflowException {
037    
038                    getWorkflowInstanceManager().deleteWorkflowInstance(
039                            companyId, workflowInstanceId);
040            }
041    
042            public static List<String> getNextTransitionNames(
043                            long companyId, long userId, long workflowInstanceId)
044                    throws WorkflowException {
045    
046                    return getWorkflowInstanceManager().getNextTransitionNames(
047                            companyId, userId, workflowInstanceId);
048            }
049    
050            public static WorkflowInstance getWorkflowInstance(
051                            long companyId, long workflowInstanceId)
052                    throws WorkflowException {
053    
054                    return getWorkflowInstanceManager().getWorkflowInstance(
055                            companyId, workflowInstanceId);
056            }
057    
058            public static int getWorkflowInstanceCount(
059                            long companyId, Long userId, String assetClassName,
060                            Long assetClassPK, Boolean completed)
061                    throws WorkflowException {
062    
063                    return getWorkflowInstanceManager().getWorkflowInstanceCount(
064                            companyId, userId, assetClassName, assetClassPK, completed);
065            }
066    
067            public static int getWorkflowInstanceCount(
068                            long companyId, Long userId, String[] assetClassNames,
069                            Boolean completed)
070                    throws WorkflowException {
071    
072                    return getWorkflowInstanceManager().getWorkflowInstanceCount(
073                            companyId, userId, assetClassNames, completed);
074            }
075    
076            public static int getWorkflowInstanceCount(
077                            long companyId, String workflowDefinitionName,
078                            Integer workflowDefinitionVersion, Boolean completed)
079                    throws WorkflowException {
080    
081                    return getWorkflowInstanceManager().getWorkflowInstanceCount(
082                            companyId, workflowDefinitionName, workflowDefinitionVersion,
083                            completed);
084            }
085    
086            public static WorkflowInstanceManager getWorkflowInstanceManager() {
087                    PortalRuntimePermission.checkGetBeanProperty(
088                            WorkflowInstanceManagerUtil.class);
089    
090                    return _workflowInstanceManager;
091            }
092    
093            public static List<WorkflowInstance> getWorkflowInstances(
094                            long companyId, Long userId, String assetClassName,
095                            Long assetClassPK, Boolean completed, int start, int end,
096                            OrderByComparator orderByComparator)
097                    throws WorkflowException {
098    
099                    return getWorkflowInstanceManager().getWorkflowInstances(
100                            companyId, userId, assetClassName, assetClassPK, completed, start,
101                            end, orderByComparator);
102            }
103    
104            public static List<WorkflowInstance> getWorkflowInstances(
105                            long companyId, Long userId, String[] assetClassNames,
106                            Boolean completed, int start, int end,
107                            OrderByComparator orderByComparator)
108                    throws WorkflowException {
109    
110                    return getWorkflowInstanceManager().getWorkflowInstances(
111                            companyId, userId, assetClassNames, completed, start, end,
112                            orderByComparator);
113            }
114    
115            public static List<WorkflowInstance> getWorkflowInstances(
116                            long companyId, String workflowDefinitionName,
117                            Integer workflowDefinitionVersion, Boolean completed, int start,
118                            int end, OrderByComparator orderByComparator)
119                    throws WorkflowException {
120    
121                    return getWorkflowInstanceManager().getWorkflowInstances(
122                            companyId, workflowDefinitionName, workflowDefinitionVersion,
123                            completed, start, end, orderByComparator);
124            }
125    
126            public static WorkflowInstance signalWorkflowInstance(
127                            long companyId, long userId, long workflowInstanceId,
128                            String transitionName, Map<String, Serializable> workflowContext)
129                    throws WorkflowException {
130    
131                    return getWorkflowInstanceManager().signalWorkflowInstance(
132                            companyId, userId, workflowInstanceId, transitionName,
133                            workflowContext);
134            }
135    
136            public static WorkflowInstance startWorkflowInstance(
137                            long companyId, long groupId, long userId,
138                            String workflowDefinitionName, Integer workflowDefinitionVersion,
139                            String transitionName, Map<String, Serializable> workflowContext)
140                    throws WorkflowException {
141    
142                    return getWorkflowInstanceManager().startWorkflowInstance(
143                            companyId, groupId, userId, workflowDefinitionName,
144                            workflowDefinitionVersion, transitionName, workflowContext);
145            }
146    
147            public static WorkflowInstance updateWorkflowContext(
148                            long companyId, long workflowInstanceId,
149                            Map<String, Serializable> workflowContext)
150                    throws WorkflowException {
151    
152                    return getWorkflowInstanceManager().updateWorkflowContext(
153                            companyId, workflowInstanceId, workflowContext);
154            }
155    
156            public void setWorkflowInstanceManager(
157                    WorkflowInstanceManager workflowInstanceManager) {
158    
159                    PortalRuntimePermission.checkSetBeanProperty(getClass());
160    
161                    _workflowInstanceManager = workflowInstanceManager;
162            }
163    
164            private static WorkflowInstanceManager _workflowInstanceManager;
165    
166    }