001/**
002 * Copyright 2005-2016 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.action;
017
018import javax.xml.bind.annotation.XmlEnum;
019import javax.xml.bind.annotation.XmlEnumValue;
020import javax.xml.bind.annotation.XmlRootElement;
021import javax.xml.bind.annotation.XmlType;
022
023import org.kuali.rice.core.api.mo.common.Coded;
024import org.kuali.rice.kew.api.KewApiConstants;
025
026@XmlRootElement(name = "actionRequestStatus")
027@XmlType(name = "ActionRequestStatusType")
028@XmlEnum
029public enum ActionRequestStatus implements Coded {
030
031        /**
032         * Code to indicate the request has been satisfied
033         */
034    @XmlEnumValue(KewApiConstants.ActionRequestStatusVals.DONE)
035        DONE(KewApiConstants.ActionRequestStatusVals.DONE, "DONE"),
036    
037    /**
038     * Code to indicate the request is currently active
039     */
040    @XmlEnumValue(KewApiConstants.ActionRequestStatusVals.ACTIVATED)
041            ACTIVATED(KewApiConstants.ActionRequestStatusVals.ACTIVATED, "ACTIVATED"),
042    
043    /**
044     * Code to indicate the request has not been activated
045     */
046    @XmlEnumValue(KewApiConstants.ActionRequestStatusVals.INITIALIZED)
047            INITIALIZED(KewApiConstants.ActionRequestStatusVals.INITIALIZED, "INITIALIZED");
048        
049        private final String code;
050        private final String label;
051        
052        ActionRequestStatus(String code, String label) {
053                this.code = code;
054                this.label = label;
055        }
056        
057        @Override
058        public String getCode() {
059                return code;
060        }
061        
062        public String getLabel() {
063                return label;
064        }
065        
066        public static ActionRequestStatus fromCode(String code) {
067                if (code == null) {
068                        return null;
069                }
070                for (ActionRequestStatus request : values()) {
071                        if (request.code.equals(code)) {
072                                return request;
073                        }
074                }
075                throw new IllegalArgumentException("Failed to locate the ActionRequestStatus with the given code: " + code);
076        }
077        
078}