1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.missedpunch;
17
18 import java.util.Set;
19
20 import org.apache.log4j.Logger;
21 import org.kuali.hr.time.util.TKContext;
22 import org.kuali.rice.kew.api.KewApiServiceLocator;
23 import org.kuali.rice.kew.api.document.DocumentStatus;
24 import org.kuali.rice.kim.api.identity.Person;
25 import org.kuali.rice.kns.document.authorization.TransactionalDocumentAuthorizerBase;
26 import org.kuali.rice.krad.document.Document;
27 import org.kuali.rice.krad.util.KRADConstants;
28
29 public class MissedPunchAuthorizer extends TransactionalDocumentAuthorizerBase {
30
31 private static final Logger LOG = Logger.getLogger(MissedPunchAuthorizer.class);
32
33 @Override
34 public boolean canEditDocumentOverview(Document document, Person user) {
35 return true;
36 }
37
38 @Override
39 public Set<String> getDocumentActions(Document document, Person user,
40 Set<String> documentActions) {
41 Set<String> author = super.getDocumentActions(document, user, documentActions);
42 MissedPunchDocument mpDoc = (MissedPunchDocument)document;
43 DocumentStatus documentStatus = document.getDocumentHeader().getWorkflowDocument().getStatus();
44
45 if(DocumentStatus.ENROUTE.equals(documentStatus) ){
46 if(KewApiServiceLocator.getWorkflowDocumentActionsService().isFinalApprover(mpDoc.getDocumentNumber(), TKContext.getPrincipalId())){
47 author.add(KRADConstants.KUALI_ACTION_CAN_EDIT);
48 author.add(KRADConstants.KUALI_ACTION_CAN_APPROVE);
49 }
50 } else if(DocumentStatus.INITIATED.equals(documentStatus)
51 || DocumentStatus.SAVED.equals(documentStatus)){
52 author.add(KRADConstants.KUALI_ACTION_CAN_EDIT);
53 author.add(KRADConstants.KUALI_ACTION_CAN_ROUTE);
54 } else {
55 author.remove(KRADConstants.KUALI_ACTION_CAN_APPROVE);
56 }
57 author.remove(KRADConstants.KUALI_ACTION_CAN_ADD_ADHOC_REQUESTS);
58 author.remove(KRADConstants.KUALI_ACTION_CAN_SEND_ADHOC_REQUESTS);
59
60
61 author.remove(KRADConstants.KUALI_ACTION_CAN_DISAPPROVE);
62 return author;
63 }
64
65
66
67 }