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_DRAFT_FROM_APPROVED = "draft";
065    
066            public static final String LABEL_EXPIRED = "expired";
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            public static final int STATUS_DRAFT_FROM_APPROVED = 9;
085    
086            public static final int STATUS_EXPIRED = 3;
087    
088            public static final int STATUS_INACTIVE = 5;
089    
090            public static final int STATUS_INCOMPLETE = 6;
091    
092            public static final int STATUS_PENDING = 1;
093    
094            public static final int STATUS_SCHEDULED = 7;
095    
096            public static String toLabel(int status) {
097                    if (status == STATUS_ANY) {
098                            return LABEL_ANY;
099                    }
100                    else if (status == STATUS_APPROVED) {
101                            return LABEL_APPROVED;
102                    }
103                    else if (status == STATUS_DENIED) {
104                            return LABEL_DENIED;
105                    }
106                    else if ((status == STATUS_DRAFT) ||
107                                     (status == STATUS_DRAFT_FROM_APPROVED)) {
108    
109                            return LABEL_DRAFT;
110                    }
111                    else if (status == STATUS_EXPIRED) {
112                            return LABEL_EXPIRED;
113                    }
114                    else if (status == STATUS_INACTIVE) {
115                            return LABEL_INACTIVE;
116                    }
117                    else if (status == STATUS_INCOMPLETE) {
118                            return LABEL_INCOMPLETE;
119                    }
120                    else if (status == STATUS_PENDING) {
121                            return LABEL_PENDING;
122                    }
123                    else if (status == STATUS_SCHEDULED) {
124                            return LABEL_SCHEDULED;
125                    }
126                    else {
127                            return LABEL_ANY;
128                    }
129            }
130    
131            public static int toStatus(String label) {
132                    if (label.equals(LABEL_ANY)) {
133                            return STATUS_ANY;
134                    }
135                    else if (label.equals(LABEL_APPROVED)) {
136                            return STATUS_APPROVED;
137                    }
138                    else if (label.equals(LABEL_DENIED)) {
139                            return STATUS_DENIED;
140                    }
141                    else if (label.equals(LABEL_DRAFT) ||
142                                     label.equals(LABEL_DRAFT_FROM_APPROVED)) {
143    
144                            return STATUS_DRAFT;
145                    }
146                    else if (label.equals(LABEL_EXPIRED)) {
147                            return STATUS_EXPIRED;
148                    }
149                    else if (label.equals(LABEL_INACTIVE)) {
150                            return STATUS_INACTIVE;
151                    }
152                    else if (label.equals(LABEL_INCOMPLETE)) {
153                            return STATUS_INCOMPLETE;
154                    }
155                    else if (label.equals(LABEL_PENDING)) {
156                            return STATUS_PENDING;
157                    }
158                    else if (label.equals(LABEL_SCHEDULED)) {
159                            return STATUS_SCHEDULED;
160                    }
161                    else {
162                            return STATUS_ANY;
163                    }
164            }
165    
166    }