1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
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 | |
import java.util.EnumSet; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | 0 | @XmlRootElement(name = "documentStatus") |
34 | |
@XmlType(name = "DocumentStatusType") |
35 | |
@XmlEnum |
36 | |
public enum DocumentStatus implements Coded { |
37 | |
|
38 | 0 | @XmlEnumValue("I") INITIATED("I", DocumentStatusCategory.PENDING), |
39 | 0 | @XmlEnumValue("S") SAVED("S", DocumentStatusCategory.PENDING), |
40 | 0 | @XmlEnumValue("R") ENROUTE("R", DocumentStatusCategory.PENDING), |
41 | 0 | @XmlEnumValue("E") EXCEPTION("E", DocumentStatusCategory.PENDING), |
42 | 0 | @XmlEnumValue("P") PROCESSED("P", DocumentStatusCategory.SUCCESSFUL), |
43 | 0 | @XmlEnumValue("F") FINAL("F", DocumentStatusCategory.SUCCESSFUL), |
44 | 0 | @XmlEnumValue("X") CANCELED("X", DocumentStatusCategory.UNSUCCESSFUL), |
45 | 0 | @XmlEnumValue("D") DISAPPROVED("D", DocumentStatusCategory.UNSUCCESSFUL); |
46 | |
|
47 | |
private final String code; |
48 | |
private final DocumentStatusCategory category; |
49 | |
|
50 | 0 | private DocumentStatus(String code, DocumentStatusCategory category) { |
51 | 0 | this.code = code; |
52 | 0 | this.category = category; |
53 | 0 | } |
54 | |
|
55 | |
@Override |
56 | |
public String getCode() { |
57 | 0 | return code; |
58 | |
} |
59 | |
|
60 | |
public DocumentStatusCategory getCategory() { |
61 | 0 | return category; |
62 | |
} |
63 | |
|
64 | |
public String getLabel() { |
65 | 0 | return name(); |
66 | |
} |
67 | |
|
68 | |
public static DocumentStatus fromCode(String code) { |
69 | 0 | if (code == null) { |
70 | 0 | return null; |
71 | |
} |
72 | 0 | for (DocumentStatus status : values()) { |
73 | 0 | if (status.code.equals(code)) { |
74 | 0 | return status; |
75 | |
} |
76 | |
} |
77 | 0 | throw new IllegalArgumentException("Failed to locate the DocumentStatus with the given code: " + code); |
78 | |
} |
79 | |
|
80 | |
public static EnumSet<DocumentStatus> getStatusesForCategory(DocumentStatusCategory category) { |
81 | 0 | if (category == null) { |
82 | 0 | throw new IllegalArgumentException("category was null"); |
83 | |
} |
84 | 0 | EnumSet<DocumentStatus> categoryStatuses = EnumSet.noneOf(DocumentStatus.class); |
85 | 0 | for (DocumentStatus status : values()) { |
86 | 0 | if (status.category == category) { |
87 | 0 | categoryStatuses.add(status); |
88 | |
} |
89 | |
} |
90 | 0 | return categoryStatuses; |
91 | |
} |
92 | |
|
93 | |
} |