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