| 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 | 0 | @XmlRootElement(name = "documentSearchResultField") |
| 34 | |
@XmlType(name = "DocumentSearchResultFieldType") |
| 35 | |
@XmlEnum |
| 36 | |
public enum StandardResultField { |
| 37 | |
|
| 38 | 0 | @XmlEnumValue("documentId") DOCUMENT_ID("documentId"), |
| 39 | 0 | @XmlEnumValue("status") STATUS("status", "statusLabel"), |
| 40 | 0 | @XmlEnumValue("documentType") DOCUMENT_TYPE("documentType", "documentTypeLabel"), |
| 41 | 0 | @XmlEnumValue("title") TITLE("title"), |
| 42 | 0 | @XmlEnumValue("initiator") INITIATOR("initiator", "initiatorPerson.name"), |
| 43 | 0 | @XmlEnumValue("dateCreated") DATE_CREATED("dateCreated"), |
| 44 | 0 | @XmlEnumValue("routeLog") ROUTE_LOG("routeLog"); |
| 45 | |
|
| 46 | |
private final String standardFieldName; |
| 47 | |
private final Set<String> additionalFieldNames; |
| 48 | |
|
| 49 | 0 | private StandardResultField(String standardFieldName, String... additionalFieldNames) { |
| 50 | 0 | this.standardFieldName = standardFieldName; |
| 51 | 0 | Set<String> additionalFieldNameSet = new HashSet<String>(Arrays.asList(additionalFieldNames)); |
| 52 | 0 | this.additionalFieldNames = Collections.unmodifiableSet(additionalFieldNameSet); |
| 53 | 0 | } |
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
public String getStandardFieldName() { |
| 61 | 0 | return standardFieldName; |
| 62 | |
} |
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
public Set<String> getAdditionalFieldNames() { |
| 70 | 0 | return additionalFieldNames; |
| 71 | |
} |
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
public boolean isFieldNameValid(String fieldName) { |
| 83 | 0 | return fieldName.equals(standardFieldName) || additionalFieldNames.contains(fieldName); |
| 84 | |
} |
| 85 | |
|
| 86 | |
public static StandardResultField fromFieldName(String fieldName) { |
| 87 | 0 | if (fieldName == null) { |
| 88 | 0 | return null; |
| 89 | |
} |
| 90 | 0 | for (StandardResultField resultField : values()) { |
| 91 | 0 | if (resultField.isFieldNameValid(fieldName)) { |
| 92 | 0 | return resultField; |
| 93 | |
} |
| 94 | |
} |
| 95 | 0 | throw new IllegalArgumentException("Failed to locate the StandardResultField with the field name: " + fieldName); |
| 96 | |
} |
| 97 | |
|
| 98 | |
} |