001    /**
002     * Copyright (c) 2000-2011 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    /**
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_USER_ID = "userId";
048    
049            public static final long DEFAULT_GROUP_ID = 0;
050    
051            public static final String LABEL_ANY = "any";
052    
053            public static final String LABEL_APPROVED = "approved";
054    
055            public static final String LABEL_DENIED = "denied";
056    
057            public static final String LABEL_DRAFT = "draft";
058    
059            public static final String LABEL_EXPIRED = "expired";
060    
061            public static final String LABEL_PENDING = "pending";
062    
063            public static final int STATUS_ANY = -1;
064    
065            public static final int STATUS_APPROVED = 0;
066    
067            public static final int STATUS_DENIED = 4;
068    
069            public static final int STATUS_DRAFT = 2;
070    
071            public static final int STATUS_EXPIRED = 3;
072    
073            public static final int STATUS_PENDING = 1;
074    
075            public static String toLabel(int status) {
076                    if (status == STATUS_ANY) {
077                            return LABEL_ANY;
078                    }
079                    else if (status == STATUS_APPROVED) {
080                            return LABEL_APPROVED;
081                    }
082                    else if (status == STATUS_DENIED) {
083                            return LABEL_DENIED;
084                    }
085                    else if (status == STATUS_DRAFT) {
086                            return LABEL_DRAFT;
087                    }
088                    else if (status == STATUS_EXPIRED) {
089                            return LABEL_EXPIRED;
090                    }
091                    else if (status == STATUS_PENDING) {
092                            return LABEL_PENDING;
093                    }
094                    else {
095                            return LABEL_ANY;
096                    }
097            }
098    
099            public static int toStatus(String label) {
100                    if (label.equals(LABEL_ANY)) {
101                            return STATUS_ANY;
102                    }
103                    else if (label.equals(LABEL_APPROVED)) {
104                            return STATUS_APPROVED;
105                    }
106                    else if (label.equals(LABEL_DENIED)) {
107                            return STATUS_DENIED;
108                    }
109                    else if (label.equals(LABEL_DRAFT)) {
110                            return STATUS_DRAFT;
111                    }
112                    else if (label.equals(LABEL_EXPIRED)) {
113                            return STATUS_EXPIRED;
114                    }
115                    else if (label.equals(LABEL_PENDING)) {
116                            return STATUS_PENDING;
117                    }
118                    else {
119                            return STATUS_ANY;
120                    }
121            }
122    
123    }