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