| 1 | 
    
            
    
     | 
    
           | 
  
            
  
    | 2 | 
    
            
    
     | 
    
           | 
  
            
  
    | 3 | 
    
            
    
     | 
    
           | 
  
            
  
    | 4 | 
    
            
    
     | 
    
           | 
  
            
  
    | 5 | 
    
            
    
     | 
    
           | 
  
            
  
    | 6 | 
    
            
    
     | 
    
           | 
  
            
  
    | 7 | 
    
            
    
     | 
    
           | 
  
            
  
    | 8 | 
    
            
    
     | 
    
           | 
  
            
  
    | 9 | 
    
            
    
     | 
    
           | 
  
            
  
    | 10 | 
    
            
    
     | 
    
           | 
  
            
  
    | 11 | 
    
            
    
     | 
    
           | 
  
            
  
    | 12 | 
    
            
    
     | 
    
           | 
  
            
  
    | 13 | 
    
            
    
     | 
    
           | 
  
            
  
    | 14 | 
    
            
    
     | 
    
           | 
  
            
  
    | 15 | 
    
            
    
     | 
    
           | 
  
            
  
    | 16 | 
    
            
    
     | 
    
           | 
  
            
  
    | 17 | 
    
            
    
     | 
    
           | 
  
            
  
    | 18 | 
    
            
    
     | 
    
      package org.kuali.rice.kew.routemodule;     | 
  
            
  
    | 19 | 
    
            
    
     | 
    
           | 
  
            
  
    | 20 | 
    
            
    
     | 
    
      import java.util.ArrayList;     | 
  
            
  
    | 21 | 
    
            
    
     | 
    
      import java.util.HashMap;     | 
  
            
  
    | 22 | 
    
            
    
     | 
    
      import java.util.Iterator;     | 
  
            
  
    | 23 | 
    
            
    
     | 
    
      import java.util.List;     | 
  
            
  
    | 24 | 
    
            
    
     | 
    
      import java.util.Map;     | 
  
            
  
    | 25 | 
    
            
    
     | 
    
           | 
  
            
  
    | 26 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.actionrequest.ActionRequestFactory;     | 
  
            
  
    | 27 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.actionrequest.ActionRequestValue;     | 
  
            
  
    | 28 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.actionrequest.KimGroupRecipient;     | 
  
            
  
    | 29 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.actionrequest.KimPrincipalRecipient;     | 
  
            
  
    | 30 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.actionrequest.Recipient;     | 
  
            
  
    | 31 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.engine.RouteContext;     | 
  
            
  
    | 32 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.exception.ResourceUnavailableException;     | 
  
            
  
    | 33 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.exception.WorkflowException;     | 
  
            
  
    | 34 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;     | 
  
            
  
    | 35 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.service.KEWServiceLocator;     | 
  
            
  
    | 36 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.util.KEWConstants;     | 
  
            
  
    | 37 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.util.ResponsibleParty;     | 
  
            
  
    | 38 | 
    
            
    
     | 
    
           | 
  
            
  
    | 39 | 
    
            
    
     | 
    
           | 
  
            
  
    | 40 | 
    
            
    
     | 
    
           | 
  
            
  
    | 41 | 
    
            
    
     | 
    
      @author     | 
  
            
  
    | 42 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 63 (63) | 
           Complexity: 13 | 
           Complexity Density: 0.32 | 
                        
            
        | 
    
  
  
    | 43 | 
    
            
    
     | 
    
      public class TestRouteModule implements RouteModule {     | 
  
            
  
    | 44 | 
    
            
    
     | 
    
           | 
  
            
  
    | 45 | 
    
            
    
     | 
    
          private static Map responsibilityMap = new HashMap();     | 
  
            
  
    | 46 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 47 | 
    
           0
    
     | 
    
           public List findActionRequests(RouteContext context) throws ResourceUnavailableException, WorkflowException {...     | 
  
            
  
    | 48 | 
    
           0
    
     | 
    
              return findActionRequests(context.getDocument());     | 
  
            
  
    | 49 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 50 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 27 (27) | 
           Complexity: 4 | 
           Complexity Density: 0.19 | 
                        
            
        | 
    
  
  
    | 51 | 
    
           0
    
     | 
    
           public List findActionRequests(DocumentRouteHeaderValue routeHeader) throws ResourceUnavailableException, WorkflowException {...     | 
  
            
  
    | 52 | 
    
           0
    
     | 
    
              TestRouteLevel routeLevel = TestRouteModuleXMLHelper.parseCurrentRouteLevel(routeHeader);     | 
  
            
  
    | 53 | 
    
           0
    
     | 
    
              List actionRequests = new ArrayList();     | 
  
            
  
    | 54 | 
    
           0
    
     | 
    
              if (routeLevel == null) {     | 
  
            
  
    | 55 | 
    
           0
    
     | 
    
                  return actionRequests;     | 
  
            
  
    | 56 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 57 | 
    
           0
    
     | 
    
              for (Iterator iterator = routeLevel.getResponsibilities().iterator(); iterator.hasNext();) {     | 
  
            
  
    | 58 | 
    
           0
    
     | 
    
                  TestResponsibility responsibility = (TestResponsibility) iterator.next();     | 
  
            
  
    | 59 | 
    
           0
    
     | 
    
                  TestRecipient recipient = responsibility.getRecipient();     | 
  
            
  
    | 60 | 
    
           0
    
     | 
    
                  Recipient realRecipient = getRealRecipient(recipient);     | 
  
            
  
    | 61 | 
    
           0
    
     | 
    
                  ActionRequestFactory arFactory = new ActionRequestFactory(routeHeader);     | 
  
            
  
    | 62 | 
    
           0
    
     | 
    
                  Long responsibilityId = KEWServiceLocator.getResponsibilityIdService().getNewResponsibilityId();     | 
  
            
  
    | 63 | 
    
           0
    
     | 
    
                  ActionRequestValue request = arFactory.addRootActionRequest(responsibility.getActionRequested(), new Integer(responsibility.getPriority()), realRecipient, "", responsibilityId, Boolean.FALSE, null, null);     | 
  
            
  
    | 64 | 
    
           0
    
     | 
    
                  responsibilityMap.put(request.getResponsibilityId(), recipient);     | 
  
            
  
    | 65 | 
    
           0
    
     | 
    
                  for (Iterator delIt = responsibility.getDelegations().iterator(); delIt.hasNext();) {     | 
  
            
  
    | 66 | 
    
           0
    
     | 
    
                      TestDelegation delegation = (TestDelegation) delIt.next();     | 
  
            
  
    | 67 | 
    
           0
    
     | 
    
                      TestRecipient delegationRecipient = delegation.getResponsibility().getRecipient();     | 
  
            
  
    | 68 | 
    
           0
    
     | 
    
                      Recipient realDelegationRecipient = getRealRecipient(delegationRecipient);     | 
  
            
  
    | 69 | 
    
           0
    
     | 
    
                      responsibilityId = KEWServiceLocator.getResponsibilityIdService().getNewResponsibilityId();     | 
  
            
  
    | 70 | 
    
           0
    
     | 
    
                      ActionRequestValue delegationRequest = arFactory.addDelegationRequest(request, realDelegationRecipient, responsibilityId, Boolean.FALSE, delegation.getType(), "", null);     | 
  
            
  
    | 71 | 
    
           0
    
     | 
    
                      responsibilityMap.put(delegationRequest.getResponsibilityId(), delegationRecipient);     | 
  
            
  
    | 72 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 73 | 
    
           0
    
     | 
    
                  actionRequests.add(request);     | 
  
            
  
    | 74 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 75 | 
    
           0
    
     | 
    
              return actionRequests;     | 
  
            
  
    | 76 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 77 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 11 (11) | 
           Complexity: 3 | 
           Complexity Density: 0.43 | 
                        
            
        | 
    
  
  
    | 78 | 
    
           0
    
     | 
    
           public Recipient getRealRecipient(TestRecipient recipient) throws WorkflowException {...     | 
  
            
  
    | 79 | 
    
           0
    
     | 
    
              Recipient realRecipient = null;     | 
  
            
  
    | 80 | 
    
           0
    
     | 
    
              if (recipient.getType().equals(KEWConstants.ACTION_REQUEST_USER_RECIPIENT_CD)) {     | 
  
            
  
    | 81 | 
    
           0
    
     | 
    
                  realRecipient = new KimPrincipalRecipient(recipient.getId());     | 
  
            
  
    | 82 | 
    
           0
    
     | 
    
              } else if (recipient.getType().equals(KEWConstants.ACTION_REQUEST_GROUP_RECIPIENT_CD)) {     | 
  
            
  
    | 83 | 
    
           0
    
     | 
    
                  realRecipient = new KimGroupRecipient(recipient.getId());     | 
  
            
  
    | 84 | 
    
            
    
     | 
    
              } else {     | 
  
            
  
    | 85 | 
    
           0
    
     | 
    
                  throw new WorkflowException("Could not resolve recipient with type " + recipient.getType());     | 
  
            
  
    | 86 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 87 | 
    
           0
    
     | 
    
              return realRecipient;     | 
  
            
  
    | 88 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 89 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 20 (20) | 
           Complexity: 5 | 
           Complexity Density: 0.42 | 
                        
            
        | 
    
  
  
    | 90 | 
    
           0
    
     | 
    
           public ResponsibleParty resolveResponsibilityId(Long responsibilityId) throws ResourceUnavailableException, WorkflowException {...     | 
  
            
  
    | 91 | 
    
           0
    
     | 
    
              TestRecipient recipient = (TestRecipient)responsibilityMap.get(responsibilityId);     | 
  
            
  
    | 92 | 
    
           0
    
     | 
    
              if (recipient == null) {     | 
  
            
  
    | 93 | 
    
           0
    
     | 
    
                  return null;     | 
  
            
  
    | 94 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 95 | 
    
           0
    
     | 
    
              ResponsibleParty responsibleParty = new ResponsibleParty();     | 
  
            
  
    | 96 | 
    
           0
    
     | 
    
              if (recipient.getType().equals(KEWConstants.ACTION_REQUEST_USER_RECIPIENT_CD)) {     | 
  
            
  
    | 97 | 
    
           0
    
     | 
    
                  responsibleParty.setPrincipalId(recipient.getId());     | 
  
            
  
    | 98 | 
    
           0
    
     | 
    
              } else if (recipient.getType().equals(KEWConstants.ACTION_REQUEST_GROUP_RECIPIENT_CD)) {     | 
  
            
  
    | 99 | 
    
           0
    
     | 
    
                  responsibleParty.setGroupId(recipient.getId());     | 
  
            
  
    | 100 | 
    
           0
    
     | 
    
              } else if (recipient.getType().equals(KEWConstants.ACTION_REQUEST_ROLE_RECIPIENT_CD)) {     | 
  
            
  
    | 101 | 
    
           0
    
     | 
    
                  responsibleParty.setRoleName(recipient.getId());     | 
  
            
  
    | 102 | 
    
            
    
     | 
    
              } else {     | 
  
            
  
    | 103 | 
    
           0
    
     | 
    
                  throw new WorkflowException("Invalid recipient type code of '"+recipient.getType()+"' for responsibility id "+responsibilityId);     | 
  
            
  
    | 104 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 105 | 
    
           0
    
     | 
    
              return responsibleParty;     | 
  
            
  
    | 106 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 107 | 
    
            
    
     | 
    
           | 
  
            
  
    | 108 | 
    
            
    
     | 
    
      }     |