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.util.List;
021    
022    /**
023     * @author Micha Kiener
024     * @author Shuyang Zhou
025     * @author Brian Wing Shun Chan
026     * @author Marcellus Tavares
027     * @author Eduardo Lundgren
028     * @author Raymond Aug??
029     */
030    public class WorkflowDefinitionManagerUtil {
031    
032            public static WorkflowDefinition deployWorkflowDefinition(
033                            long companyId, long userId, String title, byte[] bytes)
034                    throws WorkflowException {
035    
036                    return getWorkflowDefinitionManager().deployWorkflowDefinition(
037                            companyId, userId, title, bytes);
038            }
039    
040            public static int getActiveWorkflowDefinitionCount(long companyId)
041                    throws WorkflowException {
042    
043                    return getWorkflowDefinitionManager().getActiveWorkflowDefinitionCount(
044                            companyId);
045            }
046    
047            public static int getActiveWorkflowDefinitionCount(
048                            long companyId, String name)
049                    throws WorkflowException {
050    
051                    return getWorkflowDefinitionManager().getActiveWorkflowDefinitionCount(
052                            companyId, name);
053            }
054    
055            public static List<WorkflowDefinition> getActiveWorkflowDefinitions(
056                            long companyId, int start, int end,
057                            OrderByComparator orderByComparator)
058                    throws WorkflowException {
059    
060                    return getWorkflowDefinitionManager().getActiveWorkflowDefinitions(
061                            companyId, start, end, orderByComparator);
062            }
063    
064            public static List<WorkflowDefinition> getActiveWorkflowDefinitions(
065                            long companyId, String name, int start, int end,
066                            OrderByComparator orderByComparator)
067                    throws WorkflowException {
068    
069                    return getWorkflowDefinitionManager().getActiveWorkflowDefinitions(
070                            companyId, name, start, end, orderByComparator);
071            }
072    
073            public static WorkflowDefinition getLatestKaleoDefinition(
074                            long companyId, String name)
075                    throws WorkflowException {
076    
077                    return getWorkflowDefinitionManager().getLatestKaleoDefinition(
078                            companyId, name);
079            }
080    
081            public static WorkflowDefinition getWorkflowDefinition(
082                            long companyId, String name, int version)
083                    throws WorkflowException {
084    
085                    return getWorkflowDefinitionManager().getWorkflowDefinition(
086                            companyId, name, version);
087            }
088    
089            public static int getWorkflowDefinitionCount(long companyId)
090                    throws WorkflowException {
091    
092                    return getWorkflowDefinitionManager().getWorkflowDefinitionCount(
093                            companyId);
094            }
095    
096            public static int getWorkflowDefinitionCount(long companyId, String name)
097                    throws WorkflowException {
098    
099                    return getWorkflowDefinitionManager().getWorkflowDefinitionCount(
100                            companyId, name);
101            }
102    
103            public static WorkflowDefinitionManager getWorkflowDefinitionManager() {
104                    PortalRuntimePermission.checkGetBeanProperty(
105                            WorkflowDefinitionManagerUtil.class);
106    
107                    return _workflowDefinitionManager;
108            }
109    
110            public static List<WorkflowDefinition> getWorkflowDefinitions(
111                            long companyId, int start, int end,
112                            OrderByComparator orderByComparator)
113                    throws WorkflowException {
114    
115                    return getWorkflowDefinitionManager().getWorkflowDefinitions(
116                            companyId, start, end, orderByComparator);
117            }
118    
119            public static List<WorkflowDefinition> getWorkflowDefinitions(
120                            long companyId, String name, int start, int end,
121                            OrderByComparator orderByComparator)
122                    throws WorkflowException {
123    
124                    return getWorkflowDefinitionManager().getWorkflowDefinitions(
125                            companyId, name, start, end, orderByComparator);
126            }
127    
128            public static void undeployWorkflowDefinition(
129                            long companyId, long userId, String name, int version)
130                    throws WorkflowException {
131    
132                    getWorkflowDefinitionManager().undeployWorkflowDefinition(
133                            companyId, userId, name, version);
134            }
135    
136            public static WorkflowDefinition updateActive(
137                            long companyId, long userId, String name, int version,
138                            boolean active)
139                    throws WorkflowException {
140    
141                    return getWorkflowDefinitionManager().updateActive(
142                            companyId, userId, name, version, active);
143            }
144    
145            public static WorkflowDefinition updateTitle(
146                            long companyId, long userId, String name, int version, String title)
147                    throws WorkflowException {
148    
149                    return getWorkflowDefinitionManager().updateTitle(
150                            companyId, userId, name, version, title);
151            }
152    
153            public static void validateWorkflowDefinition(byte[] bytes)
154                    throws WorkflowException {
155    
156                    getWorkflowDefinitionManager().validateWorkflowDefinition(bytes);
157            }
158    
159            public void setWorkflowDefinitionManager(
160                    WorkflowDefinitionManager workflowDefinitionManager) {
161    
162                    PortalRuntimePermission.checkSetBeanProperty(getClass());
163    
164                    _workflowDefinitionManager = workflowDefinitionManager;
165            }
166    
167            private static WorkflowDefinitionManager _workflowDefinitionManager;
168    
169    }