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