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.doctype;
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;
024
025/**
026 * TODO...
027 *
028 * @author Kuali Rice Team (rice.collab@kuali.org)
029 */
030@XmlRootElement(name = "documentTypePolicy")
031@XmlType(name = "DocumentTypePolicyType")
032@XmlEnum
033public enum DocumentTypePolicy implements Coded {
034    
035        /**
036     * FIXME: needs docs
037     */
038    @XmlEnumValue(Codes.DISAPPROVE) DISAPPROVE(Codes.DISAPPROVE),
039    
040    /**
041     * This policy determines whether to use the internal KEW Super User document handler URL when opening a document from
042     * super user search. If set to false the client must implement a custom super user screen to be used when the doc
043     * handler URL has a post variable of the name defined by {@link KewApiConstants#COMMAND_PARAMETER} and a value of
044     * {@link KewApiConstants#SUPERUSER_COMMAND}. The default is 'true'.
045     */
046    @XmlEnumValue(Codes.USE_KEW_SUPERUSER_DOCHANDLER) USE_KEW_SUPERUSER_DOCHANDLER(Codes.USE_KEW_SUPERUSER_DOCHANDLER),
047
048    /**
049     * determines how to handle the situation where the user has initiated an action but there is not a corresponding pending request. This policy has a default of true.
050     * If set to false an exception should be thrown from ApproveAction, CompleteAction, AcknowledgeAction
051     * and ClearFYIAction classes when there does not exist a corresponding pending request for the user who is submitting the action. 
052     * When set to false, this will result in one of the users getting an error message if 2 users attempt to submit the same action
053     * at the same time (this can happen in workgroup situtations). 
054     */
055    @XmlEnumValue(Codes.ALLOW_UNREQUESTED_ACTION) ALLOW_UNREQUESTED_ACTION(Codes.ALLOW_UNREQUESTED_ACTION),
056    
057    /**
058     * determines whether a document will go processed without any approval requests.  If
059     * a document has this policy set to false and doesn't generate and approval requests the document will
060     * be put in exception routing, which is the exception workgroup associated with the last route node or the
061     * workgroup defined in the 'defaultExceptionGroupName'.  This policy if not defined in this or a parent
062     * document type defaults to true
063     */
064    @XmlEnumValue(Codes.DEFAULT_APPROVE) DEFAULT_APPROVE(Codes.DEFAULT_APPROVE),
065    
066    /**
067     * determines if the user that initiated a document must 'route' the document when it is
068     * in the initiated state.  Defaults to true.
069     */
070    @XmlEnumValue(Codes.INITIATOR_MUST_ROUTE) INITIATOR_MUST_ROUTE(Codes.INITIATOR_MUST_ROUTE),
071    
072    /**
073     * determines if the user that initiated a document must 'route' the document when it is
074     * in the initiated state.  Defaults to true.
075     */
076    @XmlEnumValue(Codes.INITIATOR_MUST_SAVE) INITIATOR_MUST_SAVE(Codes.INITIATOR_MUST_SAVE),
077    
078    @XmlEnumValue(Codes.INITIATOR_MUST_CANCEL) INITIATOR_MUST_CANCEL(Codes.INITIATOR_MUST_CANCEL),
079    
080    @XmlEnumValue(Codes.INITIATOR_MUST_BLANKET_APPROVE) INITIATOR_MUST_BLANKET_APPROVE(Codes.INITIATOR_MUST_BLANKET_APPROVE),
081
082    /**
083     * determines whether the document can be brought into a simulated route from the route log.  A
084     * simulation of where the document would end up if it where routed to completion now.  Defaults to false.
085     * 
086     * determines if route log will show the look into the future link
087     */
088    @XmlEnumValue(Codes.LOOK_FUTURE) LOOK_FUTURE(Codes.LOOK_FUTURE),
089
090    @XmlEnumValue(Codes.SEND_NOTIFICATION_ON_SU_APPROVE) SEND_NOTIFICATION_ON_SU_APPROVE(Codes.SEND_NOTIFICATION_ON_SU_APPROVE),
091
092    @XmlEnumValue(Codes.SUPPORTS_QUICK_INITIATE) SUPPORTS_QUICK_INITIATE(Codes.SUPPORTS_QUICK_INITIATE),
093
094    @XmlEnumValue(Codes.NOTIFY_ON_SAVE) NOTIFY_ON_SAVE(Codes.NOTIFY_ON_SAVE),
095    
096    /**
097     * The Document Status Policy determines whether the KEW Route Status or the Application Document Status (or both) 
098     * are to be used for a specific document type.
099     */
100    @XmlEnumValue(Codes.DOCUMENT_STATUS_POLICY) DOCUMENT_STATUS_POLICY(Codes.DOCUMENT_STATUS_POLICY),
101
102    /**
103     * This document type policy allows us to configure if the "Perform Post Processor Logic" for the super user action on action requests is displayed.  
104     * KULRICE-3584
105     */
106    @XmlEnumValue(Codes.ALLOW_SU_POSTPROCESSOR_OVERRIDE) ALLOW_SU_POSTPROCESSOR_OVERRIDE(Codes.ALLOW_SU_POSTPROCESSOR_OVERRIDE),
107
108    @XmlEnumValue(Codes.FAIL_ON_INACTIVE_GROUP) FAIL_ON_INACTIVE_GROUP(Codes.FAIL_ON_INACTIVE_GROUP),
109
110    @XmlEnumValue(Codes.ENROUTE_ERROR_SUPPRESSION) ENROUTE_ERROR_SUPPRESSION(Codes.ENROUTE_ERROR_SUPPRESSION),
111
112    @XmlEnumValue(Codes.REGENERATE_ACTION_REQUESTS_ON_CHANGE) REGENERATE_ACTION_REQUESTS_ON_CHANGE(Codes.REGENERATE_ACTION_REQUESTS_ON_CHANGE),
113
114    /**
115     * Governs whether FYIs should be sent on *pending* (not completed) action requests when returning to a previous node
116     * @since 2.1
117     * @see https://jira.kuali.org/browse/KULRICE-5931
118     */
119    @XmlEnumValue(Codes.NOTIFY_PENDING_ON_RETURN) NOTIFY_PENDING_ON_RETURN(Codes.NOTIFY_PENDING_ON_RETURN),
120
121    /**
122     * Governs whether FYIs should be sent on *completed* (not pending) action requests when returning to a previous node (for use with Recall)
123     * @since 2.1
124     * @see https://jira.kuali.org/browse/KULRICE-5931
125     */
126    @XmlEnumValue(Codes.NOTIFY_COMPLETED_ON_RETURN) NOTIFY_COMPLETED_ON_RETURN(Codes.NOTIFY_COMPLETED_ON_RETURN),
127    /**
128     * Specifies additional recipients of Recall notifications.  This configuration is supplied as an additional recipients element
129     * in the document policy element, which conforms to the Rule:ResponsibilityIdentifiers group schema.
130     * @since 2.1
131     * @see https://jira.kuali.org/browse/KULRICE-5931
132     */
133    @XmlEnumValue(Codes.RECALL_NOTIFICATION) RECALL_NOTIFICATION(Codes.RECALL_NOTIFICATION),
134    /**
135     * Specifies list of prior actions taken for which a subsequent Recall action will be valid.
136     * @since 2.1
137     * @see https://jira.kuali.org/browse/KULRICE-7798
138     */
139    @XmlEnumValue(Codes.RECALL_VALID_ACTIONSTAKEN) RECALL_VALID_ACTIONSTAKEN(Codes.RECALL_VALID_ACTIONSTAKEN),
140    /**
141     * Specifies whether to send acknowledgements on a super user disapprove action
142     * @since 2.1
143     * @see https://jira.kuali.org/browse/KULRICE-7056
144     */
145    @XmlEnumValue(Codes.SEND_NOTIFICATION_ON_SU_DISAPPROVE) SEND_NOTIFICATION_ON_SU_DISAPPROVE(Codes.SEND_NOTIFICATION_ON_SU_DISAPPROVE),
146    /**
147     * Specifies whether to disallow super user approval on the final route node
148     * @since 2.1
149     * @see https://jira.kuali.org/browse/KULRICE-7057
150     */
151    @XmlEnumValue(Codes.ALLOW_SU_FINAL_APPROVAL) ALLOW_SU_FINAL_APPROVAL(Codes.ALLOW_SU_FINAL_APPROVAL),
152    /**
153     * Specifies whether immediate emails should be suppressed after a superuser action is taken
154     * @since 2.1.3
155     * @see https://jira.kuali.org/browse/KULRICE-8289
156     */
157    @XmlEnumValue(Codes.SUPPRESS_IMMEDIATE_EMAILS_ON_SU_ACTION) SUPPRESS_IMMEDIATE_EMAILS_ON_SU_ACTION(Codes.SUPPRESS_IMMEDIATE_EMAILS_ON_SU_ACTION);
158
159    private final String code;
160
161    private DocumentTypePolicy(String code) {
162        this.code = code;
163    }
164
165    @Override
166    public String getCode() {
167        return code;
168    }
169
170    public static DocumentTypePolicy fromCode(String code) {
171        if (code == null) {
172            return null;
173        }
174        for (DocumentTypePolicy policy : values()) {
175            if (policy.code.equalsIgnoreCase(code)) {
176                return policy;
177            }
178        }
179        throw new IllegalArgumentException("Failed to locate the DocumentTypePolicy with the given code: " + code);
180    }
181        
182    private static final class Codes {
183        private static final String DISAPPROVE = "DISAPPROVE";
184        private static final String USE_KEW_SUPERUSER_DOCHANDLER = "USE_KEW_SUPERUSER_DOCHANDLER";
185        private static final String ALLOW_UNREQUESTED_ACTION = "ALLOW_UNREQUESTED_ACTION";
186        private static final String DEFAULT_APPROVE = "DEFAULT_APPROVE";
187        private static final String INITIATOR_MUST_ROUTE = "INITIATOR_MUST_ROUTE";
188        private static final String INITIATOR_MUST_SAVE = "INITIATOR_MUST_SAVE";
189        private static final String INITIATOR_MUST_CANCEL = "INITIATOR_MUST_CANCEL";
190        private static final String INITIATOR_MUST_BLANKET_APPROVE = "INITIATOR_MUST_BLANKET_APPROVE";
191        private static final String LOOK_FUTURE = "LOOK_FUTURE";
192        private static final String SEND_NOTIFICATION_ON_SU_APPROVE = "SEND_NOTIFICATION_ON_SU_APPROVE";
193        private static final String SUPPORTS_QUICK_INITIATE = "SUPPORTS_QUICK_INITIATE";
194        private static final String NOTIFY_ON_SAVE = "NOTIFY_ON_SAVE";
195        private static final String DOCUMENT_STATUS_POLICY = "DOCUMENT_STATUS_POLICY";
196        private static final String ALLOW_SU_POSTPROCESSOR_OVERRIDE = "ALLOW_SU_POSTPROCESSOR_OVERRIDE";
197        private static final String FAIL_ON_INACTIVE_GROUP = "FAIL_ON_INACTIVE_GROUP";
198        private static final String REGENERATE_ACTION_REQUESTS_ON_CHANGE = "REGENERATE_ACTION_REQUESTS_ON_CHANGE";       
199        private static final String ENROUTE_ERROR_SUPPRESSION = "ENROUTE_ERROR_SUPPRESSION";
200        private static final String NOTIFY_PENDING_ON_RETURN = "NOTIFY_PENDING_ON_RETURN";
201        private static final String NOTIFY_COMPLETED_ON_RETURN = "NOTIFY_COMPLETED_ON_RETURN";
202        private static final String RECALL_NOTIFICATION = "RECALL_NOTIFICATION";
203        private static final String RECALL_VALID_ACTIONSTAKEN = "RECALL_VALID_ACTIONSTAKEN";
204        private static final String SEND_NOTIFICATION_ON_SU_DISAPPROVE = "SEND_NOTIFICATION_ON_SU_DISAPPROVE";
205        private static final String ALLOW_SU_FINAL_APPROVAL = "ALLOW_SU_FINAL_APPROVAL";
206        private static final String SUPPRESS_IMMEDIATE_EMAILS_ON_SU_ACTION = "SUPPRESS_IMMEDIATE_EMAILS_ON_SU_ACTION";
207    }
208    
209}