1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.workflow;
16  
17  /**
18   * <a href="WorkflowConstants.java.html"><b><i>View Source</i></b></a>
19   *
20   * @author Jorge Ferrer
21   */
22  public class WorkflowConstants {
23  
24      public static final int ACTION_PUBLISH = 1;
25  
26      public static final int ACTION_SAVE_DRAFT = 2;
27  
28      public static final String CONTEXT_COMPANY_ID = "companyId";
29  
30      public static final String CONTEXT_ENTRY_CLASS_NAME = "entryClassName";
31  
32      public static final String CONTEXT_ENTRY_CLASS_PK = "entryClassPK";
33  
34      public static final String CONTEXT_ENTRY_TYPE = "entryType";
35  
36      public static final String CONTEXT_GROUP_ID = "groupId";
37  
38      public static final String CONTEXT_SERVICE_CONTEXT = "serviceContext";
39  
40      public static final String CONTEXT_USER_ID = "userId";
41  
42      public static final long DEFAULT_GROUP_ID = 0;
43  
44      public static final String LABEL_ANY = "any";
45  
46      public static final String LABEL_APPROVED = "approved";
47  
48      public static final String LABEL_DENIED = "denied";
49  
50      public static final String LABEL_DRAFT = "draft";
51  
52      public static final String LABEL_EXPIRED = "expired";
53  
54      public static final String LABEL_PENDING = "pending";
55  
56      public static final int STATUS_ANY = -1;
57  
58      public static final int STATUS_APPROVED = 0;
59  
60      public static final int STATUS_DENIED = 4;
61  
62      public static final int STATUS_DRAFT = 2;
63  
64      public static final int STATUS_EXPIRED = 3;
65  
66      public static final int STATUS_PENDING = 1;
67  
68      public static String toLabel(int status) {
69          if (status == STATUS_ANY) {
70              return LABEL_ANY;
71          }
72          else if (status == STATUS_APPROVED) {
73              return LABEL_APPROVED;
74          }
75          else if (status == STATUS_DENIED) {
76              return LABEL_DENIED;
77          }
78          else if (status == STATUS_DRAFT) {
79              return LABEL_DRAFT;
80          }
81          else if (status == STATUS_EXPIRED) {
82              return LABEL_EXPIRED;
83          }
84          else if (status == STATUS_PENDING) {
85              return LABEL_PENDING;
86          }
87          else {
88              return LABEL_ANY;
89          }
90      }
91  
92      public static int toStatus(String label) {
93          if (label.equals(LABEL_ANY)) {
94              return STATUS_ANY;
95          }
96          else if (label.equals(LABEL_APPROVED)) {
97              return STATUS_APPROVED;
98          }
99          else if (label.equals(LABEL_DENIED)) {
100             return STATUS_DENIED;
101         }
102         else if (label.equals(LABEL_DRAFT)) {
103             return STATUS_DRAFT;
104         }
105         else if (label.equals(LABEL_EXPIRED)) {
106             return STATUS_EXPIRED;
107         }
108         else if (label.equals(LABEL_PENDING)) {
109             return STATUS_PENDING;
110         }
111         else {
112             return STATUS_ANY;
113         }
114     }
115 
116 }