001    /*
002     * Copyright 2011 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     */
016    package org.kuali.kfs.module.endow.document.authorization;
017    
018    import java.util.Set;
019    
020    import org.kuali.kfs.module.endow.EndowConstants;
021    import org.kuali.kfs.module.endow.document.UnitsTotaling;
022    import org.kuali.kfs.sys.businessobject.FinancialSystemDocumentHeader;
023    import org.kuali.kfs.sys.document.authorization.FinancialSystemTransactionalDocumentPresentationControllerBase;
024    import org.kuali.rice.kns.document.Document;
025    import org.kuali.rice.kns.workflow.service.KualiWorkflowDocument;
026    
027    public class EndowmentTransactionalDocumentPresentationController extends FinancialSystemTransactionalDocumentPresentationControllerBase {
028    
029        /**
030         * @see org.kuali.kfs.sys.document.authorization.FinancialSystemTransactionalDocumentPresentationControllerBase#getEditModes(org.kuali.rice.kns.document.Document)
031         */
032        @Override
033        public Set<String> getEditModes(Document document) {
034            Set<String> editModes = super.getEditModes(document);
035    
036            if (document instanceof UnitsTotaling) {
037                editModes.add(EndowConstants.UNITS_TOTALING_EDITING_MODE);
038            }
039            return editModes;
040        }
041    
042        /**
043         * @see org.kuali.rice.kns.document.authorization.DocumentPresentationControllerBase#canEdit(org.kuali.rice.kns.document.Document)
044         */
045        @Override
046        protected boolean canEdit(Document document) {
047            KualiWorkflowDocument workflowDocument = document.getDocumentHeader().getWorkflowDocument();
048            FinancialSystemDocumentHeader documentheader = (FinancialSystemDocumentHeader) (document.getDocumentHeader());
049    
050            if (workflowDocument.stateIsCanceled() || documentheader.getFinancialDocumentInErrorNumber() != null) {
051                return false;
052            }
053            else
054                return super.canEdit(document);
055        }
056    }