View Javadoc
1   /**
2    * Copyright 2005-2015 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.kim.api.identity.Person;
22  import org.kuali.rice.krad.document.Document;
23  import org.kuali.rice.krad.util.KRADConstants;
24  
25  /**
26   * KNS version of the DocumentPresentationControllerBase - adds #getDocumentActions via {@link DocumentPresentationController}
27   *
28   * @deprecated Use {@link org.kuali.rice.krad.document.DocumentPresentationControllerBase}.
29   */
30  @Deprecated
31  public class DocumentPresentationControllerBase extends org.kuali.rice.krad.document.DocumentPresentationControllerBase implements DocumentPresentationController {
32      /**
33       * @see DocumentPresentationController#getDocumentActions(org.kuali.rice.krad.document.Document)
34       */
35      @Override
36      public Set<String> getDocumentActions(Document document){
37      	Set<String> documentActions = new HashSet<String>();
38      	if (canEdit(document)){
39      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_EDIT);
40      	}
41      	
42      	if(canAnnotate(document)){
43      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_ANNOTATE);
44      	}
45      	 
46      	if(canClose(document)){
47      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_CLOSE);
48      	}
49      	 
50      	if(canSave(document)){
51      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_SAVE);
52      	}
53      	if(canRoute(document)){
54      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_ROUTE);
55      	}
56      	 
57      	if(canCancel(document)){
58      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_CANCEL);
59      	}
60  
61          if(canRecall(document)){
62              documentActions.add(KRADConstants.KUALI_ACTION_CAN_RECALL);
63          }
64      	 
65      	if(canReload(document)){
66      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_RELOAD);
67      	}
68      	if(canCopy(document)){
69      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_COPY);
70      	}
71      	if(canPerformRouteReport(document)){
72      		documentActions.add(KRADConstants.KUALI_ACTION_PERFORM_ROUTE_REPORT);
73      	}
74      	
75      	if(canAddAdhocRequests(document)){
76      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_ADD_ADHOC_REQUESTS);
77      	}
78  
79          // KULRICE-8762: Approve & Blanket Approve should be disabled for a person who is doing COMPLETE action
80          boolean canComplete = this.canComplete(document);
81          if(!canComplete && canBlanketApprove(document)){
82              documentActions.add(KRADConstants.KUALI_ACTION_CAN_BLANKET_APPROVE);
83          }
84          if (!canComplete && canApprove(document)) {
85              documentActions.add(KRADConstants.KUALI_ACTION_CAN_APPROVE);
86          }
87  
88      	if (canDisapprove(document)) {
89      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_DISAPPROVE);
90      	}
91      	if (canSendAdhocRequests(document)) {
92      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_SEND_ADHOC_REQUESTS);
93      	}
94      	if(canSendNoteFyi(document)){
95      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_SEND_NOTE_FYI);
96      	}
97      	if(this.canEditDocumentOverview(document)){
98      		documentActions.add(KRADConstants.KUALI_ACTION_CAN_EDIT_DOCUMENT_OVERVIEW);
99      	}
100     	if (canFyi(document)) {
101     		documentActions.add(KRADConstants.KUALI_ACTION_CAN_FYI);
102     	}
103     	if (canAcknowledge(document)) {
104     		documentActions.add(KRADConstants.KUALI_ACTION_CAN_ACKNOWLEDGE);
105     	}
106         if (canComplete(document)) {
107             documentActions.add(KRADConstants.KUALI_ACTION_CAN_COMPLETE);
108         }
109 
110     	return documentActions;
111     }
112 
113     public boolean canClose(Document document) {
114         return true;
115     }
116 
117 }