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