001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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_URL = "url";
055    
056            public static final String CONTEXT_USER_ID = "userId";
057    
058            public static final long DEFAULT_GROUP_ID = 0;
059    
060            public static final String LABEL_ANY = "any";
061    
062            public static final String LABEL_APPROVED = "approved";
063    
064            public static final String LABEL_DENIED = "denied";
065    
066            public static final String LABEL_DRAFT = "draft";
067    
068            public static final String LABEL_EXPIRED = "expired";
069    
070            public static final String LABEL_IN_TRASH = "in-trash";
071    
072            public static final String LABEL_INACTIVE = "inactive";
073    
074            public static final String LABEL_INCOMPLETE = "incomplete";
075    
076            public static final String LABEL_PENDING = "pending";
077    
078            public static final String LABEL_SCHEDULED = "scheduled";
079    
080            public static final int STATUS_ANY = -1;
081    
082            public static final int STATUS_APPROVED = 0;
083    
084            public static final int STATUS_DENIED = 4;
085    
086            public static final int STATUS_DRAFT = 2;
087    
088            /**
089             * @deprecated As of 6.2.0
090             */
091            public static final int STATUS_DRAFT_FROM_APPROVED = 9;
092    
093            public static final int STATUS_EXPIRED = 3;
094    
095            public static final int STATUS_IN_TRASH = 8;
096    
097            public static final int STATUS_INACTIVE = 5;
098    
099            public static final int STATUS_INCOMPLETE = 6;
100    
101            public static final int STATUS_PENDING = 1;
102    
103            public static final int STATUS_SCHEDULED = 7;
104    
105            public static final int TYPE_ASSIGN = 10000;
106    
107            public static final int TYPE_COMPLETE = 10001;
108    
109            public static int getLabelStatus(String label) {
110                    if (label.equals(LABEL_ANY)) {
111                            return STATUS_ANY;
112                    }
113                    else if (label.equals(LABEL_APPROVED)) {
114                            return STATUS_APPROVED;
115                    }
116                    else if (label.equals(LABEL_DENIED)) {
117                            return STATUS_DENIED;
118                    }
119                    else if (label.equals(LABEL_DRAFT)) {
120                            return STATUS_DRAFT;
121                    }
122                    else if (label.equals(LABEL_EXPIRED)) {
123                            return STATUS_EXPIRED;
124                    }
125                    else if (label.equals(LABEL_INACTIVE)) {
126                            return STATUS_INACTIVE;
127                    }
128                    else if (label.equals(LABEL_IN_TRASH)) {
129                            return STATUS_IN_TRASH;
130                    }
131                    else if (label.equals(LABEL_INCOMPLETE)) {
132                            return STATUS_INCOMPLETE;
133                    }
134                    else if (label.equals(LABEL_PENDING)) {
135                            return STATUS_PENDING;
136                    }
137                    else if (label.equals(LABEL_SCHEDULED)) {
138                            return STATUS_SCHEDULED;
139                    }
140                    else {
141                            return STATUS_ANY;
142                    }
143            }
144    
145            public static String getStatusCssClass(int status) {
146                    if (status == STATUS_APPROVED) {
147                            return "label-success";
148                    }
149                    else if (status == STATUS_DRAFT) {
150                            return "label-info";
151                    }
152                    else if (status == STATUS_EXPIRED) {
153                            return "label-important";
154                    }
155                    else if (status == STATUS_PENDING) {
156                            return "label-warning";
157                    }
158    
159                    return StringPool.BLANK;
160            }
161    
162            public static String getStatusLabel(int status) {
163                    if (status == STATUS_ANY) {
164                            return LABEL_ANY;
165                    }
166                    else if (status == STATUS_APPROVED) {
167                            return LABEL_APPROVED;
168                    }
169                    else if (status == STATUS_DENIED) {
170                            return LABEL_DENIED;
171                    }
172                    else if (status == STATUS_DRAFT) {
173                            return LABEL_DRAFT;
174                    }
175                    else if (status == STATUS_EXPIRED) {
176                            return LABEL_EXPIRED;
177                    }
178                    else if (status == STATUS_IN_TRASH) {
179                            return LABEL_IN_TRASH;
180                    }
181                    else if (status == STATUS_INACTIVE) {
182                            return LABEL_INACTIVE;
183                    }
184                    else if (status == STATUS_INCOMPLETE) {
185                            return LABEL_INCOMPLETE;
186                    }
187                    else if (status == STATUS_PENDING) {
188                            return LABEL_PENDING;
189                    }
190                    else if (status == STATUS_SCHEDULED) {
191                            return LABEL_SCHEDULED;
192                    }
193                    else {
194                            return LABEL_ANY;
195                    }
196            }
197    
198            /**
199             * @deprecated As of 6.2.0, replaced by {@link #getStatusLabel(int)}
200             */
201            public static String toLabel(int status) {
202                    return getStatusLabel(status);
203            }
204    
205            /**
206             * @deprecated As of 6.2.0, replaced by {@link #getLabelStatus(String)}
207             */
208            public static int toStatus(String label) {
209                    return getLabelStatus(label);
210            }
211    
212    }