| 1 | 
    
            
    
     | 
    
      package org.kuali.student.lum.workflow;     | 
  
            
  
    | 2 | 
    
            
    
     | 
    
           | 
  
            
  
    | 3 | 
    
            
    
     | 
    
      import javax.xml.namespace.QName;     | 
  
            
  
    | 4 | 
    
            
    
     | 
    
           | 
  
            
  
    | 5 | 
    
            
    
     | 
    
      import org.apache.commons.lang.StringUtils;     | 
  
            
  
    | 6 | 
    
            
    
     | 
    
      import org.kuali.rice.core.resourceloader.GlobalResourceLoader;     | 
  
            
  
    | 7 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.actiontaken.ActionTakenValue;     | 
  
            
  
    | 8 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.postprocessor.ActionTakenEvent;     | 
  
            
  
    | 9 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.postprocessor.DocumentRouteStatusChange;     | 
  
            
  
    | 10 | 
    
            
    
     | 
    
      import org.kuali.rice.kew.util.KEWConstants;     | 
  
            
  
    | 11 | 
    
            
    
     | 
    
      import org.kuali.student.common.dto.DtoConstants;     | 
  
            
  
    | 12 | 
    
            
    
     | 
    
      import org.kuali.student.common.exceptions.OperationFailedException;     | 
  
            
  
    | 13 | 
    
            
    
     | 
    
      import org.kuali.student.core.atp.service.AtpService;     | 
  
            
  
    | 14 | 
    
            
    
     | 
    
      import org.kuali.student.core.proposal.dto.ProposalInfo;     | 
  
            
  
    | 15 | 
    
            
    
     | 
    
      import org.kuali.student.lum.program.service.ProgramService;     | 
  
            
  
    | 16 | 
    
            
    
     | 
    
      import org.kuali.student.lum.program.service.ProgramServiceConstants;     | 
  
            
  
    | 17 | 
    
            
    
     | 
    
      import org.springframework.transaction.annotation.Transactional;     | 
  
            
  
    | 18 | 
    
            
    
     | 
    
           | 
  
            
  
    | 19 | 
    
            
    
     | 
    
      @Transactional(readOnly=true, rollbackFor={Throwable.class})     | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 67 (67) | 
           Complexity: 18 | 
           Complexity Density: 0.46 | 
                        
            
        | 
    
  
  
    | 20 | 
    
            
    
     | 
    
      public class ProgramPostProcessorBase extends KualiStudentPostProcessorBase {     | 
  
            
  
    | 21 | 
    
            
    
     | 
    
          private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ProgramPostProcessorBase.class);     | 
  
            
  
    | 22 | 
    
            
    
     | 
    
           | 
  
            
  
    | 23 | 
    
            
    
     | 
    
          private ProgramService programService;     | 
  
            
  
    | 24 | 
    
            
    
     | 
    
          private StateChangeService stateChangeService;     | 
  
            
  
    | 25 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 3 (3) | 
           Complexity: 1 | 
           Complexity Density: 0.33 | 
                        
            
        | 
    
  
  
    | 26 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 27 | 
    
            
    
     | 
    
          protected void processWithdrawActionTaken(ActionTakenEvent actionTakenEvent, ProposalInfo proposalInfo) throws Exception {     | 
  
            
  
    | 28 | 
    
           0
    
     | 
    
              LOG.info("Will set CLU state to '" + DtoConstants.STATE_DRAFT + "'");     | 
  
            
  
    | 29 | 
    
           0
    
     | 
    
              String programId = getProgramId(proposalInfo);     | 
  
            
  
    | 30 | 
    
           0
    
     | 
    
              getStateChangeService().changeState(programId, DtoConstants.STATE_DRAFT);     | 
  
            
  
    | 31 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 32 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 33 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 34 | 
    
            
    
     | 
    
          protected boolean processCustomActionTaken(ActionTakenEvent actionTakenEvent, ActionTakenValue actionTaken, ProposalInfo proposalInfo) throws Exception {     | 
  
            
  
    | 35 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 36 | 
    
           0
    
     | 
    
              return true;     | 
  
            
  
    | 37 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 38 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 6 (6) | 
           Complexity: 1 | 
           Complexity Density: 0.17 | 
                        
            
        | 
    
  
  
    | 39 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 40 | 
    
            
    
     | 
    
          protected boolean processCustomRouteStatusChange(DocumentRouteStatusChange statusChangeEvent, ProposalInfo proposalInfo) throws Exception {     | 
  
            
  
    | 41 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 42 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 43 | 
    
           0
    
     | 
    
              String programId = getProgramId(proposalInfo);     | 
  
            
  
    | 44 | 
    
           0
    
     | 
    
              String endEntryTerm = proposalInfo.getAttributes().get("prevEndProgramEntryTerm");     | 
  
            
  
    | 45 | 
    
           0
    
     | 
    
              String endEnrollTerm = proposalInfo.getAttributes().get("prevEndTerm");     | 
  
            
  
    | 46 | 
    
           0
    
     | 
    
              String endInstAdmitTerm = proposalInfo.getAttributes().get("prevEndInstAdmitTerm");     | 
  
            
  
    | 47 | 
    
           0
    
     | 
    
              getStateChangeService().changeState(endEntryTerm, endEnrollTerm, endInstAdmitTerm, programId, getCluStateForRouteStatus("",statusChangeEvent.getNewRouteStatus()));     | 
  
            
  
    | 48 | 
    
           0
    
     | 
    
              return true;     | 
  
            
  
    | 49 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 50 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 6 (6) | 
           Complexity: 2 | 
           Complexity Density: 0.5 | 
                        
            
        | 
    
  
  
    | 51 | 
    
           0
    
     | 
    
           protected String getProgramId(ProposalInfo proposalInfo) throws OperationFailedException {...     | 
  
            
  
    | 52 | 
    
           0
    
     | 
    
              if (proposalInfo.getProposalReference().size() != 1) {     | 
  
            
  
    | 53 | 
    
           0
    
     | 
    
                  LOG.error("Found " + proposalInfo.getProposalReference().size() + " CLU objects linked to proposal with proposalId='" + proposalInfo.getId() + "'. Must have exactly 1 linked.");     | 
  
            
  
    | 54 | 
    
           0
    
     | 
    
                  throw new OperationFailedException("Found " + proposalInfo.getProposalReference().size() + " CLU objects linked to proposal with docId='" + proposalInfo.getWorkflowId() + "' and proposalId='" + proposalInfo.getId() + "'. Must have exactly 1 linked.");     | 
  
            
  
    | 55 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 56 | 
    
           0
    
     | 
    
              return proposalInfo.getProposalReference().get(0);     | 
  
            
  
    | 57 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 58 | 
    
            
    
     | 
    
           | 
  
            
  
    | 59 | 
    
            
    
     | 
    
               | 
  
            
  
    | 60 | 
    
            
    
     | 
    
      @param     | 
  
            
  
    | 61 | 
    
            
    
     | 
    
      @param     | 
  
            
  
    | 62 | 
    
            
    
     | 
    
      @return     | 
  
            
  
    | 63 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 25 (25) | 
           Complexity: 7 | 
           Complexity Density: 0.54 | 
                        
            
        | 
    
  
  
    | 64 | 
    
           0
    
     | 
    
           protected String getCluStateForRouteStatus(String currentCluState, String newWorkflowStatusCode) {...     | 
  
            
  
    | 65 | 
    
           0
    
     | 
    
              if (StringUtils.equals(KEWConstants.ROUTE_HEADER_SAVED_CD, newWorkflowStatusCode)) {     | 
  
            
  
    | 66 | 
    
           0
    
     | 
    
                  return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_DRAFT);     | 
  
            
  
    | 67 | 
    
           0
    
     | 
    
              } else if (KEWConstants.ROUTE_HEADER_CANCEL_CD .equals(newWorkflowStatusCode)) {     | 
  
            
  
    | 68 | 
    
           0
    
     | 
    
                  return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_NOT_APPROVED);     | 
  
            
  
    | 69 | 
    
           0
    
     | 
    
              } else if (KEWConstants.ROUTE_HEADER_ENROUTE_CD.equals(newWorkflowStatusCode)) {     | 
  
            
  
    | 70 | 
    
           0
    
     | 
    
                  return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_DRAFT);     | 
  
            
  
    | 71 | 
    
           0
    
     | 
    
              } else if (KEWConstants.ROUTE_HEADER_DISAPPROVED_CD.equals(newWorkflowStatusCode)) {     | 
  
            
  
    | 72 | 
    
            
    
     | 
    
                       | 
  
            
  
    | 73 | 
    
            
    
     | 
    
           | 
  
            
  
    | 74 | 
    
            
    
     | 
    
           | 
  
            
  
    | 75 | 
    
           0
    
     | 
    
                  return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_NOT_APPROVED);     | 
  
            
  
    | 76 | 
    
           0
    
     | 
    
              } else if (KEWConstants.ROUTE_HEADER_PROCESSED_CD.equals(newWorkflowStatusCode)) {     | 
  
            
  
    | 77 | 
    
           0
    
     | 
    
                  return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_ACTIVE);     | 
  
            
  
    | 78 | 
    
           0
    
     | 
    
              } else if (KEWConstants.ROUTE_HEADER_EXCEPTION_CD.equals(newWorkflowStatusCode)) {     | 
  
            
  
    | 79 | 
    
           0
    
     | 
    
                  return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_DRAFT);     | 
  
            
  
    | 80 | 
    
            
    
     | 
    
              } else {     | 
  
            
  
    | 81 | 
    
            
    
     | 
    
                       | 
  
            
  
    | 82 | 
    
           0
    
     | 
    
                  return null;     | 
  
            
  
    | 83 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 84 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 85 | 
    
            
    
     | 
    
           | 
  
            
  
    | 86 | 
    
            
    
     | 
    
               | 
  
            
  
    | 87 | 
    
            
    
     | 
    
           | 
  
            
  
    | 88 | 
    
            
    
     | 
    
           | 
  
            
  
    | 89 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 5 (5) | 
           Complexity: 2 | 
           Complexity Density: 0.67 | 
                        
            
        | 
    
  
  
    | 90 | 
    
           0
    
     | 
    
           protected String getCourseStateFromNewState(String currentCourseState, String newCourseState) {...     | 
  
            
  
    | 91 | 
    
           0
    
     | 
    
              if (LOG.isInfoEnabled()) {     | 
  
            
  
    | 92 | 
    
           0
    
     | 
    
                  LOG.info("current CLU state is '" + currentCourseState + "' and new CLU state will be '" + newCourseState + "'");     | 
  
            
  
    | 93 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 94 | 
    
           0
    
     | 
    
              return getStateFromNewState(currentCourseState, newCourseState);     | 
  
            
  
    | 95 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 96 | 
    
            
    
     | 
    
           | 
  
            
  
    | 97 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 5 (5) | 
           Complexity: 2 | 
           Complexity Density: 0.67 | 
                        
            
        | 
    
  
  
    | 98 | 
    
           0
    
     | 
    
           protected ProgramService getProgramService() {...     | 
  
            
  
    | 99 | 
    
           0
    
     | 
    
              if (this.programService == null) {     | 
  
            
  
    | 100 | 
    
           0
    
     | 
    
                  this.programService = (ProgramService) GlobalResourceLoader.getService(new QName(ProgramServiceConstants.PROGRAM_NAMESPACE,"ProgramService"));      | 
  
            
  
    | 101 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 102 | 
    
           0
    
     | 
    
              return this.programService;     | 
  
            
  
    | 103 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 104 | 
    
            
    
     | 
    
               | 
  
            
  
    | 105 | 
    
            
    
     | 
    
               | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 8 (8) | 
           Complexity: 2 | 
           Complexity Density: 0.33 | 
                        
            
        | 
    
  
  
    | 106 | 
    
           0
    
     | 
    
           protected StateChangeService getStateChangeService() {...     | 
  
            
  
    | 107 | 
    
           0
    
     | 
    
              if (this.stateChangeService == null) {     | 
  
            
  
    | 108 | 
    
           0
    
     | 
    
                  MajorDisciplineStateChangeServiceImpl stateChangeService = new MajorDisciplineStateChangeServiceImpl();     | 
  
            
  
    | 109 | 
    
           0
    
     | 
    
                  stateChangeService.setProgramService(getProgramService());     | 
  
            
  
    | 110 | 
    
           0
    
     | 
    
                  stateChangeService.setAtpService((AtpService)GlobalResourceLoader.getService(new QName("http://student.kuali.org/wsdl/atp","AtpService")));     | 
  
            
  
    | 111 | 
    
           0
    
     | 
    
                  this.stateChangeService = stateChangeService;     | 
  
            
  
    | 112 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 113 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 114 | 
    
           0
    
     | 
    
              return this.stateChangeService;     | 
  
            
  
    | 115 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 116 | 
    
            
    
     | 
    
           | 
  
            
  
    | 117 | 
    
            
    
     | 
    
      }     |