View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.api.document;
17  
18  import javax.xml.bind.annotation.XmlEnum;
19  import javax.xml.bind.annotation.XmlEnumValue;
20  import javax.xml.bind.annotation.XmlRootElement;
21  import javax.xml.bind.annotation.XmlType;
22  
23  import org.kuali.rice.core.api.mo.common.Coded;
24  
25  /**
26   * TODO...
27   * 
28   * @author ewestfal
29   *
30   */
31  @XmlRootElement(name = "documentStatus")
32  @XmlType(name = "DocumentStatusType")
33  @XmlEnum
34  public enum DocumentStatus implements Coded {
35  
36  	@XmlEnumValue("I") INITIATED("I"),
37  	@XmlEnumValue("S") SAVED("S"),
38  	@XmlEnumValue("R") ENROUTE("R"),
39  	@XmlEnumValue("P") PROCESSED("P"),
40  	@XmlEnumValue("F") FINAL("F"),
41  	@XmlEnumValue("X") CANCELED("X"),
42  	@XmlEnumValue("D") DISAPPROVED("D"),
43  	@XmlEnumValue("E") EXCEPTION("E");
44  	
45  	private final String code;
46  	
47  	private DocumentStatus(String code) {
48  		this.code = code;
49  	}
50  	
51  	@Override
52  	public String getCode() {
53  		return code;
54  	}
55  	
56  	public String getLabel() {
57  	    return name();
58  	}
59  	
60  	public static DocumentStatus fromCode(String code) {
61  		if (code == null) {
62  			return null;
63  		}
64  		for (DocumentStatus status : values()) {
65  			if (status.code.equals(code)) {
66  				return status;
67  			}
68  		}
69  		throw new IllegalArgumentException("Failed to locate the DocumentStatus with the given code: " + code);
70  	}
71  	
72  }