001 /** 002 * Copyright 2004-2013 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.hr.time.missedpunch; 017 018 import java.util.Set; 019 020 import org.apache.log4j.Logger; 021 import org.kuali.hr.time.util.TKContext; 022 import org.kuali.rice.kew.api.KewApiServiceLocator; 023 import org.kuali.rice.kew.api.document.DocumentStatus; 024 import org.kuali.rice.kim.api.identity.Person; 025 import org.kuali.rice.kns.document.authorization.TransactionalDocumentAuthorizerBase; 026 import org.kuali.rice.krad.document.Document; 027 import org.kuali.rice.krad.util.KRADConstants; 028 029 public class MissedPunchAuthorizer extends TransactionalDocumentAuthorizerBase { 030 031 private static final Logger LOG = Logger.getLogger(MissedPunchAuthorizer.class); 032 033 @Override 034 public boolean canEditDocumentOverview(Document document, Person user) { 035 return true; 036 } 037 038 @Override 039 public Set<String> getDocumentActions(Document document, Person user, 040 Set<String> documentActions) { 041 Set<String> author = super.getDocumentActions(document, user, documentActions); 042 MissedPunchDocument mpDoc = (MissedPunchDocument)document; 043 DocumentStatus documentStatus = document.getDocumentHeader().getWorkflowDocument().getStatus(); 044 045 if(DocumentStatus.ENROUTE.equals(documentStatus) ){ 046 if(KewApiServiceLocator.getWorkflowDocumentActionsService().isFinalApprover(mpDoc.getDocumentNumber(), TKContext.getPrincipalId())){ 047 author.add(KRADConstants.KUALI_ACTION_CAN_EDIT); 048 author.add(KRADConstants.KUALI_ACTION_CAN_APPROVE); 049 } 050 } else if(DocumentStatus.INITIATED.equals(documentStatus) 051 || DocumentStatus.SAVED.equals(documentStatus)){ 052 author.add(KRADConstants.KUALI_ACTION_CAN_EDIT); 053 author.add(KRADConstants.KUALI_ACTION_CAN_ROUTE); 054 } else { 055 author.remove(KRADConstants.KUALI_ACTION_CAN_APPROVE); 056 } 057 author.remove(KRADConstants.KUALI_ACTION_CAN_ADD_ADHOC_REQUESTS); 058 author.remove(KRADConstants.KUALI_ACTION_CAN_SEND_ADHOC_REQUESTS); 059 060 //can never disapprove 061 author.remove(KRADConstants.KUALI_ACTION_CAN_DISAPPROVE); 062 return author; 063 } 064 065 066 067 }