001/**
002 * Copyright 2005-2018 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kew.api.document;
017
018import org.kuali.rice.core.api.mo.common.Coded;
019
020import javax.xml.bind.annotation.XmlEnum;
021import javax.xml.bind.annotation.XmlEnumValue;
022import javax.xml.bind.annotation.XmlRootElement;
023import javax.xml.bind.annotation.XmlType;
024
025/**
026 * A DocumentStatusCategory is a grouping of document statuses that is searchable
027 * on the document search screen.
028 * 
029 * @author Kuali Rice Team (rice.collab@kuali.org)
030 */
031@XmlRootElement(name = "documentStatusCategory")
032@XmlType(name = "DocumentStatusCategoryType")
033@XmlEnum
034public enum DocumentStatusCategory implements Coded {
035
036    @XmlEnumValue("P") PENDING("P", "Pending"),
037    @XmlEnumValue("S") SUCCESSFUL("S", "Successful"),
038    @XmlEnumValue("U") UNSUCCESSFUL("U", "Unsuccessful");
039
040        private final String code;
041    private final String label;
042
043        private DocumentStatusCategory(String code, String label) {
044                this.code = code;
045        this.label = label;
046        }
047        
048        @Override
049        public String getCode() {
050                return code;
051        }
052        
053        public String getLabel() {
054            return label;
055        }
056        
057        public static DocumentStatusCategory fromCode(String code) {
058                if (code == null) {
059                        return null;
060                }
061                for (DocumentStatusCategory status : values()) {
062                        if (status.code.equals(code)) {
063                                return status;
064                        }
065                }
066                throw new IllegalArgumentException("Failed to locate the DocumentStatusCategory with the given code: " + code);
067        }
068        
069}