Clover Coverage Report - KS LUM Rice 1.2.1-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
39   117   18   4.88
20   85   0.46   8
8     2.25  
1    
 
  ProgramPostProcessorBase       Line # 20 39 0% 18 67 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.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})
 
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   
 
26  0 toggle @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   
 
33  0 toggle @Override
34    protected boolean processCustomActionTaken(ActionTakenEvent actionTakenEvent, ActionTakenValue actionTaken, ProposalInfo proposalInfo) throws Exception {
35    //TODO Why is this method implemented in course post processor? it might be important for program as well
36  0 return true;
37    }
38   
 
39  0 toggle @Override
40    protected boolean processCustomRouteStatusChange(DocumentRouteStatusChange statusChangeEvent, ProposalInfo proposalInfo) throws Exception {
41    // update the program state based on the route status
42    // Mainly used to approve a proposal
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   
 
51  0 toggle 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 currentCluState - the current state set on the CLU
61    * @param newWorkflowStatusCode - the new route status code that is getting set on the workflow document
62    * @return the CLU state to set or null if the CLU does not need it's state changed
63    */
 
64  0 toggle 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    /* current requirements state that on a Withdraw (which is a KEW Disapproval) the
73    * CLU state should be submitted so no special handling required here
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    // no status to set
82  0 return null;
83    }
84    }
85   
86    /**
87    * Default behavior is to return the <code>newCluState</code> variable only if it differs from the
88    * <code>currentCluState</code> value. Otherwise <code>null</code> will be returned.
89    */
 
90  0 toggle 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   
 
98  0 toggle 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   
 
106  0 toggle 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    }