1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.core.statement.naturallanguage; |
17 |
|
|
18 |
|
import java.util.ArrayList; |
19 |
|
import java.util.Arrays; |
20 |
|
import java.util.List; |
21 |
|
|
22 |
|
import org.kuali.student.core.statement.config.context.lu.MockCluInfo; |
23 |
|
import org.kuali.student.core.statement.config.context.lu.MockCluSetInfo; |
24 |
|
import org.kuali.student.core.statement.config.context.lu.CourseListContextImpl; |
25 |
|
import org.kuali.student.core.statement.config.context.lu.GradeCheckContextImpl; |
26 |
|
import org.kuali.student.core.statement.config.context.lu.CreditContextImpl; |
27 |
|
import org.kuali.student.core.statement.dto.ReqComponentInfo; |
28 |
|
import org.kuali.student.core.statement.dto.StatementOperatorTypeKey; |
29 |
|
import org.kuali.student.core.statement.entity.ReqComponent; |
30 |
|
import org.kuali.student.core.statement.entity.ReqComponentField; |
31 |
|
import org.kuali.student.core.statement.entity.ReqComponentType; |
32 |
|
import org.kuali.student.core.statement.entity.ReqComponentTypeNLTemplate; |
33 |
|
import org.kuali.student.core.statement.entity.Statement; |
34 |
|
import org.kuali.student.core.statement.entity.StatementType; |
35 |
|
import org.kuali.student.core.statement.naturallanguage.ReqComponentFieldTypes; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
|
|
| 85% |
Uncovered Elements: 25 (167) |
Complexity: 17 |
Complexity Density: 0.12 |
|
40 |
|
public class NaturalLanguageUtil { |
41 |
|
|
42 |
|
private final static List<MockCluInfo> cluList = new ArrayList<MockCluInfo>(); |
43 |
|
private final static List<MockCluSetInfo> cluSetList = new ArrayList<MockCluSetInfo>(); |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (33) |
Complexity: 1 |
Complexity Density: 0.03 |
|
45 |
11
|
public static void createData() {... |
46 |
11
|
MockCluInfo clu1 = new MockCluInfo(); |
47 |
11
|
clu1.setId("CLU-NL-1"); |
48 |
11
|
clu1.setCode("MATH152"); |
49 |
11
|
clu1.setShortName("MATH 152"); |
50 |
11
|
clu1.setLongName("MATH 152 Linear Systems"); |
51 |
11
|
cluList.add(clu1); |
52 |
|
|
53 |
11
|
MockCluInfo clu2 = new MockCluInfo(); |
54 |
11
|
clu2.setId("CLU-NL-2"); |
55 |
11
|
clu2.setCode("MATH221"); |
56 |
11
|
clu2.setShortName("MATH 221"); |
57 |
11
|
clu2.setLongName("MATH 221 Matrix Algebra"); |
58 |
11
|
cluList.add(clu2); |
59 |
|
|
60 |
11
|
MockCluInfo clu3 = new MockCluInfo(); |
61 |
11
|
clu3.setId("CLU-NL-3"); |
62 |
11
|
clu3.setCode("MATH180"); |
63 |
11
|
clu3.setShortName("MATH 180"); |
64 |
11
|
clu3.setLongName("MATH 180 Differential Calculus with Physical Applications"); |
65 |
11
|
cluList.add(clu3); |
66 |
|
|
67 |
11
|
MockCluSetInfo cluSet1 = new MockCluSetInfo(); |
68 |
11
|
cluSet1.setId("CLUSET-NL-1"); |
69 |
11
|
cluSet1.setCluIds(Arrays.asList(new String[] {clu1.getId(), clu3.getId()})); |
70 |
11
|
cluSet1.setCluList(Arrays.asList(new MockCluInfo[] {clu1, clu3})); |
71 |
11
|
cluSetList.add(cluSet1); |
72 |
|
|
73 |
11
|
MockCluSetInfo cluSet2 = new MockCluSetInfo(); |
74 |
11
|
cluSet2.setId("CLUSET-NL-2"); |
75 |
11
|
cluSet2.setCluIds(Arrays.asList(new String[] {clu1.getId(), clu2.getId(), clu3.getId()})); |
76 |
11
|
cluSet2.setCluList(Arrays.asList(new MockCluInfo[] {clu1, clu2, clu3})); |
77 |
11
|
cluSetList.add(cluSet2); |
78 |
|
|
79 |
11
|
MockCluSetInfo cluSet3 = new MockCluSetInfo(); |
80 |
11
|
cluSet3.setId("CLUSET-NL-3"); |
81 |
11
|
cluSet3.setCluIds(Arrays.asList(new String[] {clu1.getId(), clu2.getId()})); |
82 |
11
|
cluSet3.setCluList(Arrays.asList(new MockCluInfo[] {clu1, clu2})); |
83 |
11
|
cluSetList.add(cluSet3); |
84 |
|
} |
85 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
86 |
0
|
public static ReqComponentType createReqComponentType(String reqComponentType) {... |
87 |
0
|
ReqComponentType reqCompType = new ReqComponentType(); |
88 |
0
|
reqCompType.setId(reqComponentType); |
89 |
0
|
return reqCompType; |
90 |
|
} |
91 |
|
|
|
|
| 90.7% |
Uncovered Elements: 4 (43) |
Complexity: 7 |
Complexity Density: 0.23 |
|
92 |
37
|
public static ReqComponentType createDefaultReqComponentType(String nlUsageTypeKey, String reqComponentType) {... |
93 |
37
|
ReqComponentType reqCompType = new ReqComponentType(); |
94 |
37
|
reqCompType.setId(reqComponentType); |
95 |
|
|
96 |
37
|
List<ReqComponentTypeNLTemplate> templateList = new ArrayList<ReqComponentTypeNLTemplate>(); |
97 |
37
|
ReqComponentTypeNLTemplate templateEn = new ReqComponentTypeNLTemplate(); |
98 |
37
|
templateEn.setLanguage("en"); |
99 |
37
|
templateEn.setNlUsageTypeKey(nlUsageTypeKey); |
100 |
|
|
101 |
37
|
ReqComponentTypeNLTemplate templateDe = new ReqComponentTypeNLTemplate(); |
102 |
37
|
templateDe.setLanguage("de"); |
103 |
37
|
templateDe.setNlUsageTypeKey(nlUsageTypeKey); |
104 |
|
|
105 |
37
|
if(reqComponentType.equals("kuali.reqComponent.type.courseList.nof")) { |
106 |
31
|
templateEn.setTemplate("Student must have completed $expectedValue of $cluSet.getCluSetAsShortName()"); |
107 |
31
|
templateDe.setTemplate("Student muss abgeschlossen $expectedValue von $cluSet.getCluSetAsShortName()"); |
108 |
6
|
} else if(reqComponentType.equals("kuali.reqComponent.type.courseList.all")) { |
109 |
2
|
templateEn.setTemplate("Student must have completed all of $cluSet.getCluSetAsShortName()"); |
110 |
2
|
templateDe.setTemplate("Student must have completed all of $cluSet.getCluSetAsShortName()"); |
111 |
4
|
} else if(reqComponentType.equals("kuali.reqComponent.type.courseList.none")) { |
112 |
2
|
templateEn.setTemplate("Student must have completed none of $cluSet.getCluSetAsShortName()"); |
113 |
2
|
templateDe.setTemplate("Student must have completed none of $cluSet.getCluSetAsShortName()"); |
114 |
2
|
} else if(reqComponentType.equals("kuali.reqComponent.type.courseList.1of2")) { |
115 |
0
|
templateEn.setTemplate("Student must have completed $cluSet.getCluAsShortName(0) or $cluSet.getCluAsShortName(1)"); |
116 |
0
|
templateDe.setTemplate("Student must have completed $cluSet.getCluAsShortName(0) or $cluSet.getCluAsShortName(1)"); |
117 |
2
|
} else if(reqComponentType.equals("kuali.reqComponent.type.grdCondCourseList")) { |
118 |
1
|
templateEn.setTemplate("Students must take $totalCredits credits from $cluSet.getCluSetAsShortName()"); |
119 |
1
|
templateDe.setTemplate("Students must take $totalCredits credits from $cluSet.getCluSetAsShortName()"); |
120 |
1
|
} else if(reqComponentType.equals("kuali.reqComponent.type.gradecheck")) { |
121 |
1
|
templateEn.setTemplate("Student needs a minimum GPA of $gpa"); |
122 |
1
|
templateDe.setTemplate("Student needs a minimum GPA of $gpa"); |
123 |
|
} |
124 |
|
|
125 |
37
|
templateList.add(templateEn); |
126 |
37
|
templateList.add(templateDe); |
127 |
37
|
reqCompType.setNlUsageTemplates(templateList); |
128 |
|
|
129 |
37
|
return reqCompType; |
130 |
|
} |
131 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
132 |
37
|
public static ReqComponent createReqComponent(String nlUsageTypeKey, String reqComponentType) throws Exception {... |
133 |
37
|
ReqComponent reqComponent = new ReqComponent(); |
134 |
37
|
ReqComponentType reqCompType = createDefaultReqComponentType(nlUsageTypeKey, reqComponentType); |
135 |
37
|
reqComponent.setRequiredComponentType(reqCompType); |
136 |
37
|
return reqComponent; |
137 |
|
} |
138 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
139 |
0
|
public static ReqComponent createReqComponent(String reqComponentType, List<ReqComponentField> fieldList) {... |
140 |
0
|
ReqComponentType reqCompType = createDefaultReqComponentType("KUALI.RULE", reqComponentType); |
141 |
|
|
142 |
0
|
ReqComponent reqComp = new ReqComponent(); |
143 |
0
|
reqComp.setReqComponentFields(fieldList); |
144 |
0
|
reqComp.setRequiredComponentType(reqCompType); |
145 |
|
|
146 |
0
|
return reqComp; |
147 |
|
} |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
|
149 |
35
|
public static List<ReqComponentField> createReqComponentFieldsForCluSet(String expectedValue, String operator, String target) {... |
150 |
35
|
List<ReqComponentField> fieldList = new ArrayList<ReqComponentField>(); |
151 |
35
|
ReqComponentField field1 = new ReqComponentField(); |
152 |
35
|
field1.setId("1"); |
153 |
35
|
field1.setType(ReqComponentFieldTypes.REQUIRED_COUNT_KEY.getType()); |
154 |
35
|
field1.setValue(expectedValue); |
155 |
35
|
fieldList.add(field1); |
156 |
|
|
157 |
35
|
ReqComponentField field2 = new ReqComponentField(); |
158 |
35
|
field2.setId("2"); |
159 |
35
|
field2.setType(ReqComponentFieldTypes.OPERATOR_KEY.getType()); |
160 |
35
|
field2.setValue(operator); |
161 |
35
|
fieldList.add(field2); |
162 |
|
|
163 |
35
|
ReqComponentField field3 = new ReqComponentField(); |
164 |
35
|
field3.setId("3"); |
165 |
35
|
field3.setType(ReqComponentFieldTypes.CLUSET_KEY.getType()); |
166 |
35
|
field3.setValue(target); |
167 |
35
|
fieldList.add(field3); |
168 |
|
|
169 |
35
|
return fieldList; |
170 |
|
} |
171 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
|
172 |
2
|
public static List<ReqComponentField> createReqComponentFieldsForClu(String expectedValue, String operator, String cluIds) {... |
173 |
2
|
List<ReqComponentField> fieldList = new ArrayList<ReqComponentField>(); |
174 |
2
|
ReqComponentField field1 = new ReqComponentField(); |
175 |
2
|
field1.setId("4"); |
176 |
2
|
field1.setType(ReqComponentFieldTypes.REQUIRED_COUNT_KEY.getType()); |
177 |
2
|
field1.setValue(expectedValue); |
178 |
2
|
fieldList.add(field1); |
179 |
|
|
180 |
2
|
ReqComponentField field2 = new ReqComponentField(); |
181 |
2
|
field2.setId("5"); |
182 |
2
|
field2.setType(ReqComponentFieldTypes.OPERATOR_KEY.getType()); |
183 |
2
|
field2.setValue(operator); |
184 |
2
|
fieldList.add(field2); |
185 |
|
|
186 |
2
|
ReqComponentField field3 = new ReqComponentField(); |
187 |
2
|
field3.setId("6"); |
188 |
2
|
field3.setType(ReqComponentFieldTypes.CLU_KEY.getType()); |
189 |
2
|
field3.setValue(cluIds); |
190 |
2
|
fieldList.add(field3); |
191 |
|
|
192 |
2
|
return fieldList; |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
218 |
8
|
public static Statement createStatement(StatementOperatorTypeKey operator) throws Exception {... |
219 |
8
|
Statement stmt = new Statement(); |
220 |
8
|
stmt.setOperator(operator); |
221 |
8
|
StatementType type = new StatementType(); |
222 |
8
|
type.setId("kuali.statement.type.course.academicReadiness.prereq"); |
223 |
|
|
224 |
8
|
stmt.setStatementType(type); |
225 |
8
|
return stmt; |
226 |
|
} |
227 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
228 |
0
|
public static Statement createLuStatementInfo(String id, StatementOperatorTypeKey operator) throws Exception {... |
229 |
0
|
Statement stmt = new Statement(); |
230 |
0
|
stmt.setId(id); |
231 |
0
|
stmt.setOperator(operator); |
232 |
|
|
233 |
|
|
234 |
|
|
235 |
0
|
StatementType type = createLuStatementTypeInfo("kuali.statement.type.course.academicReadiness.prereq"); |
236 |
0
|
stmt.setStatementType(type); |
237 |
0
|
return stmt; |
238 |
|
} |
239 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
240 |
0
|
public static StatementType createLuStatementTypeInfo(String id) throws Exception {... |
241 |
0
|
StatementType type = new StatementType(); |
242 |
0
|
type.setId(id); |
243 |
|
|
244 |
0
|
return type; |
245 |
|
} |
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
|
|
260 |
|
|
261 |
|
|
262 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 1 |
Complexity Density: 0.05 |
|
263 |
11
|
public static ContextRegistry<Context<ReqComponentInfo>> getReqComponentContextRegistry() {... |
264 |
11
|
ContextRegistry<Context<ReqComponentInfo>> contextRegistry = new ContextRegistry<Context<ReqComponentInfo>>(); |
265 |
|
|
266 |
11
|
createData(); |
267 |
11
|
CourseListContextImpl.setCluInfo(cluList); |
268 |
11
|
CourseListContextImpl.setCluSetInfo(cluSetList); |
269 |
11
|
CourseListContextImpl courseListContext = new CourseListContextImpl(); |
270 |
|
|
271 |
11
|
contextRegistry.add("kuali.reqComponent.type.courseList.none", courseListContext); |
272 |
11
|
contextRegistry.add("kuali.reqComponent.type.courseList.all", courseListContext); |
273 |
11
|
contextRegistry.add("kuali.reqComponent.type.courseList.nof", courseListContext); |
274 |
11
|
contextRegistry.add("kuali.reqComponent.type.courseList.1of2", courseListContext); |
275 |
|
|
276 |
11
|
CreditContextImpl.setCluInfo(cluList); |
277 |
11
|
CreditContextImpl.setCluSetInfo(cluSetList); |
278 |
11
|
CreditContextImpl gradeConditionCourseListContext = new CreditContextImpl(); |
279 |
11
|
contextRegistry.add("kuali.reqComponent.type.grdCondCourseList", gradeConditionCourseListContext); |
280 |
11
|
contextRegistry.add("kuali.reqComponent.type.grdCondCourseList", courseListContext); |
281 |
|
|
282 |
11
|
GradeCheckContextImpl.setCluInfo(cluList); |
283 |
11
|
GradeCheckContextImpl.setCluSetInfo(cluSetList); |
284 |
11
|
GradeCheckContextImpl gradeCheckContext = new GradeCheckContextImpl(); |
285 |
11
|
contextRegistry.add("kuali.reqComponent.type.gradecheck", gradeCheckContext); |
286 |
|
|
287 |
11
|
return contextRegistry; |
288 |
|
} |
289 |
|
} |