1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.sys.service.impl;
17  
18  import java.util.List;
19  import java.util.Set;
20  
21  import org.kuali.ole.sys.service.FinancialSystemWorkflowHelperService;
22  import org.kuali.rice.kew.api.WorkflowDocument;
23  import org.kuali.rice.kew.api.action.ActionRequest;
24  import org.kuali.rice.kew.api.document.WorkflowDocumentService;
25  
26  public class FinancialSystemWorkflowHelperServiceImpl implements FinancialSystemWorkflowHelperService {
27  
28      WorkflowDocumentService workflowDocumentService;
29  
30      @Override
31      public boolean isAdhocApprovalRequestedForPrincipal(WorkflowDocument workflowDocument, String principalId ) {
32          if (workflowDocument.isApprovalRequested() ) {
33              Set<String> currentNodes = workflowDocument.getCurrentNodeNames();
34              if ( currentNodes != null ) {
35                  for ( String currentNode : currentNodes ) {
36                      List<ActionRequest> requests = workflowDocumentService.getActionRequestsForPrincipalAtNode(workflowDocument.getDocumentId(), currentNode, principalId );
37                      if ( requests != null ) {
38                          for ( ActionRequest ar : requests ) {
39                              if ( ar.isActivated() && ar.isCurrent() && ar.isApprovalRequest() && ar.isAdHocRequest() ) {
40                                  return true;
41                              }
42                          }
43                      }
44                  }
45              }
46          }
47          return false;
48      }
49  
50      public void setWorkflowDocumentService(WorkflowDocumentService workflowDocumentService) {
51          this.workflowDocumentService = workflowDocumentService;
52      }
53  
54  }