View Javadoc

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