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    /**
018     * @author Jorge Ferrer
019     * @author Zsolt Berentey
020     */
021    public class WorkflowConstants {
022    
023            public static final int ACTION_PUBLISH = 1;
024    
025            public static final int ACTION_SAVE_DRAFT = 2;
026    
027            public static final String CONTEXT_COMPANY_ID = "companyId";
028    
029            public static final String CONTEXT_ENTRY_CLASS_NAME = "entryClassName";
030    
031            public static final String CONTEXT_ENTRY_CLASS_PK = "entryClassPK";
032    
033            public static final String CONTEXT_ENTRY_TYPE = "entryType";
034    
035            public static final String CONTEXT_GROUP_ID = "groupId";
036    
037            public static final String CONTEXT_NOTIFICATION_SENDER_ADDRESS =
038                    "notificationSenderAddress";
039    
040            public static final String CONTEXT_NOTIFICATION_SENDER_NAME =
041                    "notificationSenderName";
042    
043            public static final String CONTEXT_NOTIFICATION_SUBJECT =
044                    "notificationSubject";
045    
046            public static final String CONTEXT_SERVICE_CONTEXT = "serviceContext";
047    
048            public static final String CONTEXT_TASK_COMMENTS = "taskComments";
049    
050            public static final String CONTEXT_TRANSITION_NAME = "transitionName";
051    
052            public static final String CONTEXT_USER_ID = "userId";
053    
054            public static final long DEFAULT_GROUP_ID = 0;
055    
056            public static final String LABEL_ANY = "any";
057    
058            public static final String LABEL_APPROVED = "approved";
059    
060            public static final String LABEL_DENIED = "denied";
061    
062            public static final String LABEL_DRAFT = "draft";
063    
064            public static final String LABEL_EXPIRED = "expired";
065    
066            public static final String LABEL_IN_TRASH = "in-trash";
067    
068            public static final String LABEL_INACTIVE = "inactive";
069    
070            public static final String LABEL_INCOMPLETE = "incomplete";
071    
072            public static final String LABEL_PENDING = "pending";
073    
074            public static final String LABEL_SCHEDULED = "scheduled";
075    
076            public static final int STATUS_ANY = -1;
077    
078            public static final int STATUS_APPROVED = 0;
079    
080            public static final int STATUS_DENIED = 4;
081    
082            public static final int STATUS_DRAFT = 2;
083    
084            /**
085             * @deprecated As of 6.2.0
086             */
087            public static final int STATUS_DRAFT_FROM_APPROVED = 9;
088    
089            public static final int STATUS_EXPIRED = 3;
090    
091            public static final int STATUS_IN_TRASH = 8;
092    
093            public static final int STATUS_INACTIVE = 5;
094    
095            public static final int STATUS_INCOMPLETE = 6;
096    
097            public static final int STATUS_PENDING = 1;
098    
099            public static final int STATUS_SCHEDULED = 7;
100    
101            public static String toLabel(int status) {
102                    if (status == STATUS_ANY) {
103                            return LABEL_ANY;
104                    }
105                    else if (status == STATUS_APPROVED) {
106                            return LABEL_APPROVED;
107                    }
108                    else if (status == STATUS_DENIED) {
109                            return LABEL_DENIED;
110                    }
111                    else if (status == STATUS_DRAFT) {
112                            return LABEL_DRAFT;
113                    }
114                    else if (status == STATUS_EXPIRED) {
115                            return LABEL_EXPIRED;
116                    }
117                    else if (status == STATUS_IN_TRASH) {
118                            return LABEL_IN_TRASH;
119                    }
120                    else if (status == STATUS_INACTIVE) {
121                            return LABEL_INACTIVE;
122                    }
123                    else if (status == STATUS_INCOMPLETE) {
124                            return LABEL_INCOMPLETE;
125                    }
126                    else if (status == STATUS_PENDING) {
127                            return LABEL_PENDING;
128                    }
129                    else if (status == STATUS_SCHEDULED) {
130                            return LABEL_SCHEDULED;
131                    }
132                    else {
133                            return LABEL_ANY;
134                    }
135            }
136    
137            public static int toStatus(String label) {
138                    if (label.equals(LABEL_ANY)) {
139                            return STATUS_ANY;
140                    }
141                    else if (label.equals(LABEL_APPROVED)) {
142                            return STATUS_APPROVED;
143                    }
144                    else if (label.equals(LABEL_DENIED)) {
145                            return STATUS_DENIED;
146                    }
147                    else if (label.equals(LABEL_DRAFT)) {
148                            return STATUS_DRAFT;
149                    }
150                    else if (label.equals(LABEL_EXPIRED)) {
151                            return STATUS_EXPIRED;
152                    }
153                    else if (label.equals(LABEL_INACTIVE)) {
154                            return STATUS_INACTIVE;
155                    }
156                    else if (label.equals(LABEL_IN_TRASH)) {
157                            return STATUS_IN_TRASH;
158                    }
159                    else if (label.equals(LABEL_INCOMPLETE)) {
160                            return STATUS_INCOMPLETE;
161                    }
162                    else if (label.equals(LABEL_PENDING)) {
163                            return STATUS_PENDING;
164                    }
165                    else if (label.equals(LABEL_SCHEDULED)) {
166                            return STATUS_SCHEDULED;
167                    }
168                    else {
169                            return STATUS_ANY;
170                    }
171            }
172    
173    }