View Javadoc
1   /**
2    * Copyright 2004-2014 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.kpme.tklm.time.missedpunch.authorization;
17  
18  import org.kuali.kpme.tklm.time.missedpunch.MissedPunchDocument;
19  import org.kuali.rice.kim.api.identity.Person;
20  import org.kuali.rice.krad.document.Document;
21  import org.kuali.rice.krad.document.TransactionalDocumentAuthorizerBase;
22  
23  public class MissedPunchDocumentAuthorizer extends TransactionalDocumentAuthorizerBase {
24  
25  	private static final long serialVersionUID = -7136475330057339088L;
26  
27      @Override
28      public boolean canEdit(Document document, Person user) {
29          return canApprove(document, user);
30      }
31  
32      @Override
33      public boolean canDisapprove(Document document, Person user) {
34          return false;
35      }
36  
37      @Override
38      public boolean canSendAdHocRequests(Document document, String actionRequestCd, Person user) {
39          return false;
40      }
41      
42      @Override
43      public boolean canApprove(Document document, Person user) {
44      	boolean canApprove =  super.canApprove(document, user);
45      	if(canApprove) {
46      		MissedPunchDocument missedPunchDocument = (MissedPunchDocument) document;
47      		if(missedPunchDocument.getPrincipalId().equalsIgnoreCase(user.getPrincipalId())) {
48      			canApprove = false;
49      		}
50      	}
51      	return canApprove;
52      }
53  
54  }