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="StatusConstants.java.html"><b><i>View Source</i></b></a>
19   *
20   * @author Jorge Ferrer
21   */
22  public class StatusConstants {
23  
24      public static final int ANY = -1;
25  
26      public static final int APPROVED = 0;
27  
28      public static final int DENIED = 4;
29  
30      public static final int DRAFT = 2;
31  
32      public static final int EXPIRED = 3;
33  
34      public static final String LABEL_ANY = "any";
35  
36      public static final String LABEL_APPROVED = "approved";
37  
38      public static final String LABEL_DENIED = "denied";
39  
40      public static final String LABEL_DRAFT = "draft";
41  
42      public static final String LABEL_EXPIRED = "expired";
43  
44      public static final String LABEL_PENDING = "pending";
45  
46      public static final int PENDING = 1;
47  
48      public static int fromLabel(String status) {
49          if (status.equals(LABEL_ANY)) {
50              return ANY;
51          }
52          else if (status.equals(LABEL_APPROVED)) {
53              return APPROVED;
54          }
55          else if (status.equals(LABEL_DENIED)) {
56              return DENIED;
57          }
58          else if (status.equals(LABEL_DRAFT)) {
59              return DRAFT;
60          }
61          else if (status.equals(LABEL_EXPIRED)) {
62              return EXPIRED;
63          }
64          else if (status.equals(LABEL_PENDING)) {
65              return PENDING;
66          }
67          else {
68              return ANY;
69          }
70      }
71  
72      public static String toLabel(int status) {
73          if (status == ANY) {
74              return LABEL_ANY;
75          }
76          else if (status == APPROVED) {
77              return LABEL_APPROVED;
78          }
79          else if (status == DENIED) {
80              return LABEL_DENIED;
81          }
82          else if (status == DRAFT) {
83              return LABEL_DRAFT;
84          }
85          else if (status == EXPIRED) {
86              return LABEL_EXPIRED;
87          }
88          else if (status == PENDING) {
89              return LABEL_PENDING;
90          }
91          else {
92              return LABEL_ANY;
93          }
94      }
95  
96  }