Clover Coverage Report - KS LUM Program 1.1.0-M10-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
57   142   21   5.7
10   112   0.37   10
10     2.1  
1    
 
  MajorDisciplineRpcServlet       Line # 24 57 0% 21 77 0% 0.0
 
No Tests
 
1    package org.kuali.student.lum.program.server;
2   
3    import java.util.ArrayList;
4    import java.util.HashMap;
5    import java.util.List;
6    import java.util.Map;
7   
8    import org.kuali.student.common.ui.client.widgets.rules.ReqComponentInfoUi;
9    import org.kuali.student.common.ui.client.widgets.rules.RulesUtil;
10    import org.kuali.student.common.ui.server.gwt.DataGwtServlet;
11    import org.kuali.student.core.dto.RichTextInfo;
12    import org.kuali.student.core.dto.StatusInfo;
13    import org.kuali.student.core.statement.dto.ReqComponentInfo;
14    import org.kuali.student.core.statement.dto.StatementTreeViewInfo;
15    import org.kuali.student.core.statement.service.StatementService;
16    import org.kuali.student.core.versionmanagement.dto.VersionDisplayInfo;
17    import org.kuali.student.lum.program.client.requirements.ProgramRequirementsDataModel;
18    import org.kuali.student.lum.program.client.requirements.ProgramRequirementsSummaryView;
19    import org.kuali.student.lum.program.client.rpc.MajorDisciplineRpcService;
20    import org.kuali.student.lum.program.dto.ProgramRequirementInfo;
21    import org.kuali.student.lum.program.service.ProgramService;
22    import org.kuali.student.lum.program.service.ProgramServiceConstants;
23   
 
24    public class MajorDisciplineRpcServlet extends DataGwtServlet implements MajorDisciplineRpcService {
25   
26    private static final long serialVersionUID = 1L;
27   
28    private ProgramService programService;
29    private StatementService statementService;
30   
 
31  0 toggle public List<ProgramRequirementInfo> getProgramRequirements(List<String> programRequirementIds) throws Exception {
32   
33  0 List<ProgramRequirementInfo> programReqInfos = new ArrayList<ProgramRequirementInfo>();
34   
35  0 for (String programReqId : programRequirementIds) {
36  0 ProgramRequirementInfo rule = programService.getProgramRequirement(programReqId, null, null);
37  0 setProgReqNL(rule);
38  0 programReqInfos.add(rule);
39    }
40   
41  0 return programReqInfos;
42    }
43   
 
44  0 toggle public Map<Integer, ProgramRequirementInfo> storeProgramRequirements(Map<Integer, ProgramRequirementsDataModel.requirementState> states,
45    Map<Integer, ProgramRequirementInfo> progReqs) throws Exception {
46  0 Map<Integer, ProgramRequirementInfo> storedRules = new HashMap<Integer, ProgramRequirementInfo>();
47   
48  0 for (Integer key : progReqs.keySet()) {
49  0 ProgramRequirementInfo rule = progReqs.get(key);
50  0 switch (states.get(key)) {
51  0 case STORED:
52    //rule was not changed so continue
53  0 storedRules.put(key, null);
54  0 break;
55  0 case ADDED:
56  0 storedRules.put(key, createProgramRequirement(rule));
57  0 break;
58  0 case EDITED:
59  0 storedRules.put(key, updateProgramRequirement(rule));
60  0 break;
61  0 case DELETED:
62  0 storedRules.put(key, null);
63  0 deleteProgramRequirement(rule.getId());
64  0 break;
65  0 default:
66  0 break;
67    }
68    }
69  0 return storedRules;
70    }
71   
 
72  0 toggle public ProgramRequirementInfo createProgramRequirement(ProgramRequirementInfo programRequirementInfo) throws Exception {
73   
74  0 if (programRequirementInfo.getId().indexOf(ProgramRequirementsSummaryView.NEW_PROG_REQ_ID) >= 0) {
75  0 programRequirementInfo.setId(null);
76    }
77   
78  0 ProgramRequirementsDataModel.stripStatementIds(programRequirementInfo.getStatement());
79  0 ProgramRequirementInfo rule = programService.createProgramRequirement(programRequirementInfo);
80  0 setProgReqNL(rule);
81   
82  0 return rule;
83    }
84   
 
85  0 toggle public StatusInfo deleteProgramRequirement(String programRequirementId) throws Exception {
86  0 return programService.deleteProgramRequirement(programRequirementId);
87    }
88   
 
89  0 toggle public ProgramRequirementInfo updateProgramRequirement(ProgramRequirementInfo programRequirementInfo) throws Exception {
90  0 ProgramRequirementsDataModel.stripStatementIds(programRequirementInfo.getStatement());
91   
92    //TODO temporary fix - see KSLUM 1421
93  0 if (programRequirementInfo.getDescr() == null) {
94  0 programRequirementInfo.setDescr(new RichTextInfo());
95    }
96   
97  0 ProgramRequirementInfo rule = programService.updateProgramRequirement(programRequirementInfo);
98  0 setProgReqNL(rule);
99  0 return rule;
100    }
101   
 
102  0 toggle private void setProgReqNL(ProgramRequirementInfo programRequirementInfo) throws Exception {
103  0 setReqCompNL(programRequirementInfo.getStatement());
104    }
105   
 
106  0 toggle private void setReqCompNL(StatementTreeViewInfo tree) throws Exception {
107  0 List<StatementTreeViewInfo> statements = tree.getStatements();
108  0 List<ReqComponentInfo> reqComponentInfos = tree.getReqComponents();
109   
110  0 if ((statements != null) && (statements.size() > 0)) {
111    // retrieve all statements
112  0 for (StatementTreeViewInfo statement : statements) {
113  0 setReqCompNL(statement); // inside set the children of this statementTreeViewInfo
114    }
115  0 } else if ((reqComponentInfos != null) && (reqComponentInfos.size() > 0)) {
116    // retrieve all req. component LEAFS
117  0 for (int i = 0; i < reqComponentInfos.size(); i++) {
118  0 ReqComponentInfoUi reqUi = RulesUtil.clone(reqComponentInfos.get(i));
119  0 reqUi.setNaturalLanguageTranslation(statementService.translateReqComponentToNL(reqUi, "KUALI.RULE", "en"));
120  0 reqUi.setPreviewNaturalLanguageTranslation(statementService.translateReqComponentToNL(reqUi, "KUALI.RULE.PREVIEW", "en"));
121  0 reqComponentInfos.set(i, reqUi);
122    }
123    }
124    }
125   
 
126  0 toggle @Override
127    public Boolean isLatestVersion(String versionIndId, Long versionSequenceNumber) throws Exception {
128  0 VersionDisplayInfo versionDisplayInfo = programService.getLatestVersion(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, versionIndId);
129  0 Long latestSequenceNumber = versionDisplayInfo.getSequenceNumber();
130  0 boolean isLatest = latestSequenceNumber.equals(versionSequenceNumber);
131   
132  0 return isLatest;
133    }
134   
 
135  0 toggle public void setProgramService(ProgramService programService) {
136  0 this.programService = programService;
137    }
138   
 
139  0 toggle public void setStatementService(StatementService statementService) {
140  0 this.statementService = statementService;
141    }
142    }