1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.lum.lu.ui.course.server.gwt; |
17 |
|
|
18 |
|
import java.util.Date; |
19 |
|
import java.util.HashMap; |
20 |
|
import java.util.List; |
21 |
|
import java.util.Map; |
22 |
|
|
23 |
|
import org.kuali.student.common.dto.StatusInfo; |
24 |
|
import org.kuali.student.common.ui.server.gwt.DataGwtServlet; |
25 |
|
import org.kuali.student.core.statement.dto.ReqComponentInfo; |
26 |
|
import org.kuali.student.core.statement.dto.StatementTreeViewInfo; |
27 |
|
import org.kuali.student.core.statement.service.StatementService; |
28 |
|
import org.kuali.student.core.statement.ui.client.widgets.rules.ReqComponentInfoUi; |
29 |
|
import org.kuali.student.core.statement.ui.client.widgets.rules.RulesUtil; |
30 |
|
import org.kuali.student.lum.course.service.CourseService; |
31 |
|
import org.kuali.student.lum.lu.ui.course.client.requirements.CourseRequirementsDataModel; |
32 |
|
import org.kuali.student.lum.lu.ui.course.client.service.CourseRpcService; |
33 |
|
|
|
|
| 0% |
Uncovered Elements: 71 (71) |
Complexity: 21 |
Complexity Density: 0.4 |
|
34 |
|
public class CourseRpcGwtServlet extends DataGwtServlet implements CourseRpcService { |
35 |
|
|
36 |
|
private static final long serialVersionUID = 1L; |
37 |
|
|
38 |
|
private CourseService courseService; |
39 |
|
private StatementService statementService; |
40 |
|
private CourseStateChangeServiceImpl stateChangeService; |
41 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
42 |
0
|
@Override... |
43 |
|
public List<StatementTreeViewInfo> getCourseStatements(String courseId, String nlUsageTypeKey, String language) throws Exception { |
44 |
0
|
List<StatementTreeViewInfo> rules = courseService.getCourseStatements(courseId, nlUsageTypeKey, language); |
45 |
0
|
if (rules != null) { |
46 |
0
|
for (StatementTreeViewInfo rule : rules) { |
47 |
0
|
setReqCompNL(rule); |
48 |
|
} |
49 |
|
} |
50 |
0
|
return rules; |
51 |
|
} |
52 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 5 |
Complexity Density: 0.25 |
|
53 |
0
|
public Map<Integer, StatementTreeViewInfo> storeCourseStatements(String courseId, String courseState, Map<Integer, CourseRequirementsDataModel.requirementState> states,... |
54 |
|
Map<Integer, StatementTreeViewInfo> rules) throws Exception { |
55 |
|
|
56 |
0
|
Map<Integer, StatementTreeViewInfo> storedRules = new HashMap<Integer, StatementTreeViewInfo>(); |
57 |
|
|
58 |
0
|
for (Integer key : rules.keySet()) { |
59 |
0
|
StatementTreeViewInfo rule = rules.get(key); |
60 |
0
|
switch (states.get(key)) { |
61 |
0
|
case STORED: |
62 |
|
|
63 |
0
|
storedRules.put(key, null); |
64 |
0
|
break; |
65 |
0
|
case ADDED: |
66 |
0
|
storedRules.put(key, createCourseStatement(courseId, courseState, rule)); |
67 |
0
|
break; |
68 |
0
|
case EDITED: |
69 |
0
|
storedRules.put(key, updateCourseStatement(courseId, courseState, rule)); |
70 |
0
|
break; |
71 |
0
|
case DELETED: |
72 |
0
|
storedRules.put(key, null); |
73 |
0
|
deleteCourseStatement(courseId, rule); |
74 |
0
|
break; |
75 |
0
|
default: |
76 |
0
|
break; |
77 |
|
} |
78 |
|
} |
79 |
0
|
return storedRules; |
80 |
|
} |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
82 |
0
|
@Override... |
83 |
|
public StatementTreeViewInfo createCourseStatement(String courseId, String courseState, StatementTreeViewInfo statementTreeViewInfo) throws Exception { |
84 |
0
|
CourseStateUtil.updateStatementTreeViewInfoState(courseState, statementTreeViewInfo); |
85 |
0
|
CourseRequirementsDataModel.stripStatementIds(statementTreeViewInfo); |
86 |
0
|
StatementTreeViewInfo rule = courseService.createCourseStatement(courseId, statementTreeViewInfo); |
87 |
0
|
setReqCompNL(rule); |
88 |
0
|
return rule; |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
0
|
@Override... |
92 |
|
public StatusInfo deleteCourseStatement(String courseId, StatementTreeViewInfo statementTreeViewInfo) throws Exception { |
93 |
0
|
return courseService.deleteCourseStatement(courseId, statementTreeViewInfo); |
94 |
|
} |
95 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
96 |
0
|
@Override... |
97 |
|
public StatementTreeViewInfo updateCourseStatement(String courseId, String courseState, StatementTreeViewInfo statementTreeViewInfo) throws Exception { |
98 |
0
|
CourseStateUtil.updateStatementTreeViewInfoState(courseState, statementTreeViewInfo); |
99 |
0
|
CourseRequirementsDataModel.stripStatementIds(statementTreeViewInfo); |
100 |
0
|
StatementTreeViewInfo rule = courseService.updateCourseStatement(courseId, statementTreeViewInfo); |
101 |
0
|
setReqCompNL(rule); |
102 |
0
|
return rule; |
103 |
|
} |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
0
|
public StatusInfo changeState(String courseId, String newState) throws Exception {... |
106 |
0
|
return changeState(courseId, newState, null); |
107 |
|
} |
108 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
109 |
0
|
public StatusInfo changeState(String courseId, String newState, Date currentVersionStart) throws Exception {... |
110 |
0
|
return stateChangeService.changeState(courseId, newState, currentVersionStart); |
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 6 |
Complexity Density: 0.55 |
|
113 |
0
|
private void setReqCompNL(StatementTreeViewInfo tree) throws Exception {... |
114 |
0
|
List<StatementTreeViewInfo> statements = tree.getStatements(); |
115 |
0
|
List<ReqComponentInfo> reqComponentInfos = tree.getReqComponents(); |
116 |
|
|
117 |
0
|
if ((statements != null) && (statements.size() > 0)) { |
118 |
|
|
119 |
0
|
for (StatementTreeViewInfo statement : statements) { |
120 |
0
|
setReqCompNL(statement); |
121 |
|
} |
122 |
0
|
} else if ((reqComponentInfos != null) && (reqComponentInfos.size() > 0)) { |
123 |
|
|
124 |
0
|
for (int i = 0; i < reqComponentInfos.size(); i++) { |
125 |
0
|
ReqComponentInfoUi reqUi = RulesUtil.clone(reqComponentInfos.get(i)); |
126 |
0
|
reqUi.setNaturalLanguageTranslation(statementService.translateReqComponentToNL(reqUi, "KUALI.RULE", "en")); |
127 |
0
|
reqUi.setPreviewNaturalLanguageTranslation(statementService.translateReqComponentToNL(reqUi, "KUALI.RULE.PREVIEW", "en")); |
128 |
0
|
reqComponentInfos.set(i, reqUi); |
129 |
|
} |
130 |
|
} |
131 |
|
} |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
0
|
public void setCourseService(CourseService courseService) {... |
134 |
0
|
this.courseService = courseService; |
135 |
|
} |
136 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
137 |
0
|
public void setStatementService(StatementService statementService) {... |
138 |
0
|
this.statementService = statementService; |
139 |
|
} |
140 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
141 |
0
|
public void setStateChangeService(... |
142 |
|
CourseStateChangeServiceImpl stateChangeService) { |
143 |
0
|
this.stateChangeService = stateChangeService; |
144 |
|
} |
145 |
|
} |