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