View Javadoc
1   /*
2    * Copyright 2012 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.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  }