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.kns.document.authorization; 017 018import java.util.HashSet; 019import java.util.Set; 020 021import org.kuali.rice.krad.document.Document; 022import org.kuali.rice.krad.util.KRADConstants; 023 024/** 025 * KNS version of the DocumentPresentationControllerBase - adds #getDocumentActions via {@link DocumentPresentationController} 026 */ 027public class DocumentPresentationControllerBase extends org.kuali.rice.krad.document.DocumentPresentationControllerBase implements DocumentPresentationController { 028 /** 029 * @see DocumentPresentationController#getDocumentActions(org.kuali.rice.krad.document.Document) 030 */ 031 @Override 032 public Set<String> getDocumentActions(Document document){ 033 Set<String> documentActions = new HashSet<String>(); 034 if (canEdit(document)){ 035 documentActions.add(KRADConstants.KUALI_ACTION_CAN_EDIT); 036 } 037 038 if(canAnnotate(document)){ 039 documentActions.add(KRADConstants.KUALI_ACTION_CAN_ANNOTATE); 040 } 041 042 if(canClose(document)){ 043 documentActions.add(KRADConstants.KUALI_ACTION_CAN_CLOSE); 044 } 045 046 if(canSave(document)){ 047 documentActions.add(KRADConstants.KUALI_ACTION_CAN_SAVE); 048 } 049 if(canRoute(document)){ 050 documentActions.add(KRADConstants.KUALI_ACTION_CAN_ROUTE); 051 } 052 053 if(canCancel(document)){ 054 documentActions.add(KRADConstants.KUALI_ACTION_CAN_CANCEL); 055 } 056 057 if(canRecall(document)){ 058 documentActions.add(KRADConstants.KUALI_ACTION_CAN_RECALL); 059 } 060 061 if(canReload(document)){ 062 documentActions.add(KRADConstants.KUALI_ACTION_CAN_RELOAD); 063 } 064 if(canCopy(document)){ 065 documentActions.add(KRADConstants.KUALI_ACTION_CAN_COPY); 066 } 067 if(canPerformRouteReport(document)){ 068 documentActions.add(KRADConstants.KUALI_ACTION_PERFORM_ROUTE_REPORT); 069 } 070 071 if(canAddAdhocRequests(document)){ 072 documentActions.add(KRADConstants.KUALI_ACTION_CAN_ADD_ADHOC_REQUESTS); 073 } 074 075 // KULRICE-8762: Approve & Blanket Approve should be disabled for a person who is doing COMPLETE action 076 boolean canComplete = this.canComplete(document); 077 if(!canComplete && canBlanketApprove(document)){ 078 documentActions.add(KRADConstants.KUALI_ACTION_CAN_BLANKET_APPROVE); 079 } 080 if (!canComplete && canApprove(document)) { 081 documentActions.add(KRADConstants.KUALI_ACTION_CAN_APPROVE); 082 } 083 084 if (canDisapprove(document)) { 085 documentActions.add(KRADConstants.KUALI_ACTION_CAN_DISAPPROVE); 086 } 087 if (canSendAdhocRequests(document)) { 088 documentActions.add(KRADConstants.KUALI_ACTION_CAN_SEND_ADHOC_REQUESTS); 089 } 090 if(canSendNoteFyi(document)){ 091 documentActions.add(KRADConstants.KUALI_ACTION_CAN_SEND_NOTE_FYI); 092 } 093 if(this.canEditDocumentOverview(document)){ 094 documentActions.add(KRADConstants.KUALI_ACTION_CAN_EDIT_DOCUMENT_OVERVIEW); 095 } 096 if (canFyi(document)) { 097 documentActions.add(KRADConstants.KUALI_ACTION_CAN_FYI); 098 } 099 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}