1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.framework.document.search;
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 import java.util.Arrays;
23 import java.util.Collections;
24 import java.util.HashSet;
25 import java.util.Set;
26
27
28
29
30
31
32
33 @XmlRootElement(name = "documentSearchResultField")
34 @XmlType(name = "DocumentSearchResultFieldType")
35 @XmlEnum
36 public enum StandardResultField {
37
38 @XmlEnumValue("documentId") DOCUMENT_ID("documentId"),
39 @XmlEnumValue("status") STATUS("status", "statusLabel"),
40 @XmlEnumValue("documentType") DOCUMENT_TYPE("documentType", "documentTypeLabel"),
41 @XmlEnumValue("title") TITLE("title"),
42 @XmlEnumValue("initiator") INITIATOR("initiator", "initiatorDisplayName"),
43 @XmlEnumValue("dateCreated") DATE_CREATED("dateCreated"),
44 @XmlEnumValue("routeLog") ROUTE_LOG("routeLog");
45
46 private final String standardFieldName;
47 private final Set<String> additionalFieldNames;
48
49 private StandardResultField(String standardFieldName, String... additionalFieldNames) {
50 this.standardFieldName = standardFieldName;
51 Set<String> additionalFieldNameSet = new HashSet<String>(Arrays.asList(additionalFieldNames));
52 this.additionalFieldNames = Collections.unmodifiableSet(additionalFieldNameSet);
53 }
54
55
56
57
58
59
60 public String getStandardFieldName() {
61 return standardFieldName;
62 }
63
64
65
66
67
68
69 public Set<String> getAdditionalFieldNames() {
70 return additionalFieldNames;
71 }
72
73
74
75
76
77
78
79
80
81
82 public boolean isFieldNameValid(String fieldName) {
83 return fieldName.equals(standardFieldName) || additionalFieldNames.contains(fieldName);
84 }
85
86 public static StandardResultField fromFieldName(String fieldName) {
87 if (fieldName == null) {
88 return null;
89 }
90 for (StandardResultField resultField : values()) {
91 if (resultField.isFieldNameValid(fieldName)) {
92 return resultField;
93 }
94 }
95 throw new IllegalArgumentException("Failed to locate the StandardResultField with the field name: " + fieldName);
96 }
97
98 }