View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kns.document.authorization;
17  
18  import java.util.HashSet;
19  import java.util.Set;
20  
21  import org.kuali.rice.krad.document.Document;
22  import org.kuali.rice.krad.util.KRADConstants;
23  
24  /**
25   * KNS version of the DocumentPresentationControllerBase - adds #getDocumentActions via {@link DocumentPresentationController}
26   *
27   * @deprecated Use {@link org.kuali.rice.krad.document.DocumentPresentationControllerBase}.
28   */
29  @Deprecated
30  public class DocumentPresentationControllerBase extends org.kuali.rice.krad.document.DocumentPresentationControllerBase implements DocumentPresentationController {
31      /**
32       * @see DocumentPresentationController#getDocumentActions(org.kuali.rice.krad.document.Document)
33       */
34      @Override
35      public Set<String> getDocumentActions(Document document){
36      	Set<String> documentActions = new HashSet<String>();
37      	if (canEdit(document)){
38      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_EDIT);
39      	}
40      	
41      	if(canAnnotate(document)){
42      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_ANNOTATE);
43      	}
44      	 
45      	if(canClose(document)){
46      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_CLOSE);
47      	}
48      	 
49      	if(canSave(document)){
50      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_SAVE);
51      	}
52      	if(canRoute(document)){
53      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_ROUTE);
54      	}
55      	 
56      	if(canCancel(document)){
57      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_CANCEL);
58      	}
59  
60          if(canRecall(document)){
61              documentActions.add(KRADConstants.KUALI_ACTION_CAN_RECALL);
62          }
63      	 
64      	if(canReload(document)){
65      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_RELOAD);
66      	}
67      	if(canCopy(document)){
68      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_COPY);
69      	}
70      	if(canPerformRouteReport(document)){
71      		documentActions.add(KRADConstants.KUALI_ACTION_PERFORM_ROUTE_REPORT);
72      	}
73      	
74      	if(canAddAdhocRequests(document)){
75      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_ADD_ADHOC_REQUESTS);
76      	}
77  
78          // KULRICE-8762: Approve & Blanket Approve should be disabled for a person who is doing COMPLETE action
79          boolean canComplete = this.canComplete(document);
80          if(!canComplete && canBlanketApprove(document)){
81              documentActions.add(KRADConstants.KUALI_ACTION_CAN_BLANKET_APPROVE);
82          }
83          if (!canComplete && canApprove(document)) {
84              documentActions.add(KRADConstants.KUALI_ACTION_CAN_APPROVE);
85          }
86  
87      	if (canDisapprove(document)) {
88      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_DISAPPROVE);
89      	}
90      	if (canSendAdhocRequests(document)) {
91      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_SEND_ADHOC_REQUESTS);
92      	}
93      	if(canSendNoteFyi(document)){
94      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_SEND_NOTE_FYI);
95      	}
96      	if(this.canEditDocumentOverview(document)){
97      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_EDIT_DOCUMENT_OVERVIEW);
98      	}
99      	if (canFyi(document)) {
100     		documentActions.add(KRADConstants.KUALI_ACTION_CAN_FYI);
101     	}
102     	if (canAcknowledge(document)) {
103     		documentActions.add(KRADConstants.KUALI_ACTION_CAN_ACKNOWLEDGE);
104     	}
105         if (canComplete(document)) {
106             documentActions.add(KRADConstants.KUALI_ACTION_CAN_COMPLETE);
107         }
108 
109     	return documentActions;
110     }
111 }