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.util.StringPool;
018    
019    /**
020     * @author Jorge Ferrer
021     * @author Zsolt Berentey
022     */
023    public class WorkflowConstants {
024    
025            public static final int ACTION_PUBLISH = 1;
026    
027            public static final int ACTION_SAVE_DRAFT = 2;
028    
029            public static final String CONTEXT_COMMAND = "command";
030    
031            public static final String CONTEXT_COMPANY_ID = "companyId";
032    
033            public static final String CONTEXT_ENTRY_CLASS_NAME = "entryClassName";
034    
035            public static final String CONTEXT_ENTRY_CLASS_PK = "entryClassPK";
036    
037            public static final String CONTEXT_ENTRY_TYPE = "entryType";
038    
039            public static final String CONTEXT_GROUP_ID = "groupId";
040    
041            public static final String CONTEXT_NOTIFICATION_SENDER_ADDRESS =
042                    "notificationSenderAddress";
043    
044            public static final String CONTEXT_NOTIFICATION_SENDER_NAME =
045                    "notificationSenderName";
046    
047            public static final String CONTEXT_NOTIFICATION_SUBJECT =
048                    "notificationSubject";
049    
050            public static final String CONTEXT_SERVICE_CONTEXT = "serviceContext";
051    
052            public static final String CONTEXT_TASK_COMMENTS = "taskComments";
053    
054            public static final String CONTEXT_TRANSITION_NAME = "transitionName";
055    
056            public static final String CONTEXT_URL = "url";
057    
058            public static final String CONTEXT_USER_ID = "userId";
059    
060            public static final String CONTEXT_USER_PORTRAIT_URL = "userPortraitURL";
061    
062            public static final String CONTEXT_USER_URL = "userURL";
063    
064            public static final long DEFAULT_GROUP_ID = 0;
065    
066            public static final String LABEL_ANY = "any";
067    
068            public static final String LABEL_APPROVED = "approved";
069    
070            public static final String LABEL_DENIED = "denied";
071    
072            public static final String LABEL_DRAFT = "draft";
073    
074            public static final String LABEL_EXPIRED = "expired";
075    
076            public static final String LABEL_IN_TRASH = "in-trash";
077    
078            public static final String LABEL_INACTIVE = "inactive";
079    
080            public static final String LABEL_INCOMPLETE = "incomplete";
081    
082            public static final String LABEL_PENDING = "pending";
083    
084            public static final String LABEL_SCHEDULED = "scheduled";
085    
086            public static final int STATUS_ANY = -1;
087    
088            public static final int STATUS_APPROVED = 0;
089    
090            public static final int STATUS_DENIED = 4;
091    
092            public static final int STATUS_DRAFT = 2;
093    
094            /**
095             * @deprecated As of 6.2.0
096             */
097            @Deprecated
098            public static final int STATUS_DRAFT_FROM_APPROVED = 9;
099    
100            public static final int STATUS_EXPIRED = 3;
101    
102            public static final int STATUS_IN_TRASH = 8;
103    
104            public static final int STATUS_INACTIVE = 5;
105    
106            public static final int STATUS_INCOMPLETE = 6;
107    
108            public static final int STATUS_PENDING = 1;
109    
110            public static final int STATUS_SCHEDULED = 7;
111    
112            public static final int TYPE_ASSIGN = 10000;
113    
114            public static final int TYPE_COMPLETE = 10001;
115    
116            public static int getLabelStatus(String label) {
117                    if (label.equals(LABEL_ANY)) {
118                            return STATUS_ANY;
119                    }
120                    else if (label.equals(LABEL_APPROVED)) {
121                            return STATUS_APPROVED;
122                    }
123                    else if (label.equals(LABEL_DENIED)) {
124                            return STATUS_DENIED;
125                    }
126                    else if (label.equals(LABEL_DRAFT)) {
127                            return STATUS_DRAFT;
128                    }
129                    else if (label.equals(LABEL_EXPIRED)) {
130                            return STATUS_EXPIRED;
131                    }
132                    else if (label.equals(LABEL_INACTIVE)) {
133                            return STATUS_INACTIVE;
134                    }
135                    else if (label.equals(LABEL_IN_TRASH)) {
136                            return STATUS_IN_TRASH;
137                    }
138                    else if (label.equals(LABEL_INCOMPLETE)) {
139                            return STATUS_INCOMPLETE;
140                    }
141                    else if (label.equals(LABEL_PENDING)) {
142                            return STATUS_PENDING;
143                    }
144                    else if (label.equals(LABEL_SCHEDULED)) {
145                            return STATUS_SCHEDULED;
146                    }
147                    else {
148                            return STATUS_ANY;
149                    }
150            }
151    
152            public static String getStatusCssClass(int status) {
153                    if (status == STATUS_APPROVED) {
154                            return "label-success";
155                    }
156                    else if (status == STATUS_DRAFT) {
157                            return "label-info";
158                    }
159                    else if (status == STATUS_EXPIRED) {
160                            return "label-danger";
161                    }
162                    else if (status == STATUS_PENDING) {
163                            return "label-warning";
164                    }
165    
166                    return StringPool.BLANK;
167            }
168    
169            public static String getStatusLabel(int status) {
170                    if (status == STATUS_ANY) {
171                            return LABEL_ANY;
172                    }
173                    else if (status == STATUS_APPROVED) {
174                            return LABEL_APPROVED;
175                    }
176                    else if (status == STATUS_DENIED) {
177                            return LABEL_DENIED;
178                    }
179                    else if (status == STATUS_DRAFT) {
180                            return LABEL_DRAFT;
181                    }
182                    else if (status == STATUS_EXPIRED) {
183                            return LABEL_EXPIRED;
184                    }
185                    else if (status == STATUS_IN_TRASH) {
186                            return LABEL_IN_TRASH;
187                    }
188                    else if (status == STATUS_INACTIVE) {
189                            return LABEL_INACTIVE;
190                    }
191                    else if (status == STATUS_INCOMPLETE) {
192                            return LABEL_INCOMPLETE;
193                    }
194                    else if (status == STATUS_PENDING) {
195                            return LABEL_PENDING;
196                    }
197                    else if (status == STATUS_SCHEDULED) {
198                            return LABEL_SCHEDULED;
199                    }
200                    else {
201                            return LABEL_ANY;
202                    }
203            }
204    
205            /**
206             * @deprecated As of 6.2.0, replaced by {@link #getStatusLabel(int)}
207             */
208            @Deprecated
209            public static String toLabel(int status) {
210                    return getStatusLabel(status);
211            }
212    
213            /**
214             * @deprecated As of 6.2.0, replaced by {@link #getLabelStatus(String)}
215             */
216            @Deprecated
217            public static int toStatus(String label) {
218                    return getLabelStatus(label);
219            }
220    
221    }