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.dto.RichTextInfo; |
9 |
|
import org.kuali.student.common.dto.StatusInfo; |
10 |
|
import org.kuali.student.common.ui.client.widgets.rules.ReqComponentInfoUi; |
11 |
|
import org.kuali.student.common.ui.client.widgets.rules.RulesUtil; |
12 |
|
import org.kuali.student.common.ui.server.gwt.DataGwtServlet; |
13 |
|
import org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo; |
14 |
|
import org.kuali.student.core.statement.dto.ReqComponentInfo; |
15 |
|
import org.kuali.student.core.statement.dto.StatementTreeViewInfo; |
16 |
|
import org.kuali.student.core.statement.service.StatementService; |
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 |
|
|
|
|
| 0% |
Uncovered Elements: 77 (77) |
Complexity: 21 |
Complexity Density: 0.37 |
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
31 |
0
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.25 |
|
44 |
0
|
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 |
|
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
72 |
0
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
0
|
public StatusInfo deleteProgramRequirement(String programRequirementId) throws Exception {... |
86 |
0
|
return programService.deleteProgramRequirement(programRequirementId); |
87 |
|
} |
88 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
89 |
0
|
public ProgramRequirementInfo updateProgramRequirement(ProgramRequirementInfo programRequirementInfo) throws Exception {... |
90 |
0
|
ProgramRequirementsDataModel.stripStatementIds(programRequirementInfo.getStatement()); |
91 |
|
|
92 |
|
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
0
|
private void setProgReqNL(ProgramRequirementInfo programRequirementInfo) throws Exception {... |
103 |
0
|
setReqCompNL(programRequirementInfo.getStatement()); |
104 |
|
} |
105 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 6 |
Complexity Density: 0.55 |
|
106 |
0
|
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 |
|
|
112 |
0
|
for (StatementTreeViewInfo statement : statements) { |
113 |
0
|
setReqCompNL(statement); |
114 |
|
} |
115 |
0
|
} else if ((reqComponentInfos != null) && (reqComponentInfos.size() > 0)) { |
116 |
|
|
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 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
126 |
0
|
@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 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
135 |
0
|
public void setProgramService(ProgramService programService) {... |
136 |
0
|
this.programService = programService; |
137 |
|
} |
138 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
139 |
0
|
public void setStatementService(StatementService statementService) {... |
140 |
0
|
this.statementService = statementService; |
141 |
|
} |
142 |
|
} |