Clover Coverage Report - KS LUM 1.2-M3-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Jun 6 2011 06:27:19 EDT
../../../../../img/srcFileCovDistChart0.png 53% of files have more coverage
35   111   18   4.38
20   80   0.51   8
8     2.25  
1    
 
  ProgramPostProcessorBase       Line # 19 35 0% 18 63 0% 0.0
 
No Tests
 
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.proposal.dto.ProposalInfo;
14    import org.kuali.student.lum.program.service.ProgramService;
15    import org.kuali.student.lum.program.service.ProgramServiceConstants;
16    import org.springframework.transaction.annotation.Transactional;
17   
18    @Transactional(readOnly=true, rollbackFor={Throwable.class})
 
19    public class ProgramPostProcessorBase extends KualiStudentPostProcessorBase {
20    private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ProgramPostProcessorBase.class);
21   
22    private ProgramService programService;
23    private StateChangeService stateChangeService;
24   
 
25  0 toggle @Override
26    protected void processWithdrawActionTaken(ActionTakenEvent actionTakenEvent, ProposalInfo proposalInfo) throws Exception {
27  0 LOG.info("Will set CLU state to '" + DtoConstants.STATE_SUBMITTED + "'");
28  0 String programId = getProgramId(proposalInfo);
29  0 stateChangeService.changeState(programId, DtoConstants.STATE_SUBMITTED);
30    }
31   
 
32  0 toggle @Override
33    protected boolean processCustomActionTaken(ActionTakenEvent actionTakenEvent, ActionTakenValue actionTaken, ProposalInfo proposalInfo) throws Exception {
34    //TODO Why is this method implemented in course post processor? it might be important for program as well
35  0 return true;
36    }
37   
 
38  0 toggle @Override
39    protected boolean processCustomRouteStatusChange(DocumentRouteStatusChange statusChangeEvent, ProposalInfo proposalInfo) throws Exception {
40    // update the program state based on the route status
41    // Mainly used to approve a proposal
42  0 String programId = getProgramId(proposalInfo);
43  0 stateChangeService.changeState(programId, getCluStateForRouteStatus("",statusChangeEvent.getNewRouteStatus()));
44  0 return true;
45    }
46   
 
47  0 toggle protected String getProgramId(ProposalInfo proposalInfo) throws OperationFailedException {
48  0 if (proposalInfo.getProposalReference().size() != 1) {
49  0 LOG.error("Found " + proposalInfo.getProposalReference().size() + " CLU objects linked to proposal with proposalId='" + proposalInfo.getId() + "'. Must have exactly 1 linked.");
50  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.");
51    }
52  0 return proposalInfo.getProposalReference().get(0);
53    }
54   
55    /**
56    * @param currentCluState - the current state set on the CLU
57    * @param newWorkflowStatusCode - the new route status code that is getting set on the workflow document
58    * @return the CLU state to set or null if the CLU does not need it's state changed
59    */
 
60  0 toggle protected String getCluStateForRouteStatus(String currentCluState, String newWorkflowStatusCode) {
61  0 if (StringUtils.equals(KEWConstants.ROUTE_HEADER_SAVED_CD, newWorkflowStatusCode)) {
62  0 return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_DRAFT);
63  0 } else if (KEWConstants.ROUTE_HEADER_CANCEL_CD .equals(newWorkflowStatusCode)) {
64  0 return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_DRAFT);
65  0 } else if (KEWConstants.ROUTE_HEADER_ENROUTE_CD.equals(newWorkflowStatusCode)) {
66  0 return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_SUBMITTED);
67  0 } else if (KEWConstants.ROUTE_HEADER_DISAPPROVED_CD.equals(newWorkflowStatusCode)) {
68    /* current requirements state that on a Withdraw (which is a KEW Disapproval) the
69    * CLU state should be submitted so no special handling required here
70    */
71  0 return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_SUBMITTED);
72  0 } else if (KEWConstants.ROUTE_HEADER_PROCESSED_CD.equals(newWorkflowStatusCode)) {
73  0 return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_APPROVED);
74  0 } else if (KEWConstants.ROUTE_HEADER_EXCEPTION_CD.equals(newWorkflowStatusCode)) {
75  0 return getCourseStateFromNewState(currentCluState, DtoConstants.STATE_SUBMITTED);
76    } else {
77    // no status to set
78  0 return null;
79    }
80    }
81   
82    /**
83    * Default behavior is to return the <code>newCluState</code> variable only if it differs from the
84    * <code>currentCluState</code> value. Otherwise <code>null</code> will be returned.
85    */
 
86  0 toggle protected String getCourseStateFromNewState(String currentCourseState, String newCourseState) {
87  0 if (LOG.isInfoEnabled()) {
88  0 LOG.info("current CLU state is '" + currentCourseState + "' and new CLU state will be '" + newCourseState + "'");
89    }
90  0 return getStateFromNewState(currentCourseState, newCourseState);
91    }
92   
93   
 
94  0 toggle protected ProgramService getProgramService() {
95  0 if (this.programService == null) {
96  0 this.programService = (ProgramService) GlobalResourceLoader.getService(new QName(ProgramServiceConstants.PROGRAM_NAMESPACE,"ProgramService"));
97    }
98  0 return this.programService;
99    }
100   
 
101  0 toggle protected StateChangeService getStateChangeService() {
102  0 if (this.stateChangeService == null) {
103  0 MajorDisciplineStateChangeServiceImpl stateChangeService = new MajorDisciplineStateChangeServiceImpl();
104  0 stateChangeService.setProgramService(getProgramService());
105  0 this.stateChangeService = stateChangeService;
106    }
107   
108  0 return this.stateChangeService;
109    }
110   
111    }