|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LrcContextImpl | Line # 32 | 39 | 0% | 17 | 6 | 90.3% |
0.9032258
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(16) | |||
Result | |||
0.58064514
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_MinCoursesMinGradeTest_GradeType_Letter org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_MinCoursesMinGradeTest_GradeType_Letter | 1 PASS | |
0.58064514
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_max_GradeType_Letter org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_max_GradeType_Letter | 1 PASS | |
0.58064514
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_min_GradeType_Percentage org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_min_GradeType_Percentage | 1 PASS | |
0.58064514
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_min_GradeType_CompletedNotation org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_min_GradeType_CompletedNotation | 1 PASS | |
0.58064514
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_min_GradeType_Letter org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_min_GradeType_Letter | 1 PASS | |
0.58064514
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_max_GradeType_CompletedNotation org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_max_GradeType_CompletedNotation | 1 PASS | |
0.5645161
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_MinCoursesMinGradeTest_GradeType_CompletedNotation org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_MinCoursesMinGradeTest_GradeType_CompletedNotation | 1 PASS | |
0.5645161
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_min_GradeType_Satisfactory org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_min_GradeType_Satisfactory | 1 PASS | |
0.5645161
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_min_GradeType_PassFail org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_grade_min_GradeType_PassFail | 1 PASS | |
0.5483871
|
org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_GradeTokenValues org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_GradeTokenValues | 1 PASS | |
0.5483871
|
org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap | 1 PASS | |
0.5483871
|
org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_GradeToken org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_GradeToken | 1 PASS | |
0.5483871
|
org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_TokenValues org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_TokenValues | 1 PASS | |
0.43548387
|
org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_GradeTypeTokenValues org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_GradeTypeTokenValues | 1 PASS | |
0.43548387
|
org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_GradeTypeToken org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_GradeTypeToken | 1 PASS | |
0.38709676
|
org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_NullTokenValues org.kuali.student.lum.statement.config.context.LrcContextImplTest.testCreateContextMap_NullTokenValues | 1 PASS | |
1 | /** | |
2 | * Copyright 2010 The Kuali Foundation Licensed under the | |
3 | * Educational Community License, Version 2.0 (the "License"); you may | |
4 | * not use this file except in compliance with the License. You may | |
5 | * obtain a copy of the License at | |
6 | * | |
7 | * http://www.osedu.org/licenses/ECL-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, | |
10 | * software distributed under the License is distributed on an "AS IS" | |
11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | |
12 | * or implied. See the License for the specific language governing | |
13 | * permissions and limitations under the License. | |
14 | */ | |
15 | ||
16 | package org.kuali.student.lum.statement.config.context; | |
17 | ||
18 | import java.util.HashMap; | |
19 | import java.util.List; | |
20 | import java.util.Map; | |
21 | ||
22 | import org.kuali.student.common.exceptions.OperationFailedException; | |
23 | import org.kuali.student.core.statement.dto.ReqComponentInfo; | |
24 | import org.kuali.student.lum.lrc.dto.ResultComponentInfo; | |
25 | import org.kuali.student.lum.lrc.dto.ResultComponentTypeInfo; | |
26 | import org.kuali.student.lum.lrc.service.LrcService; | |
27 | import org.kuali.student.lum.statement.typekey.ReqComponentFieldTypes; | |
28 | ||
29 | /** | |
30 | * This class creates the template context for grade condition type. | |
31 | */ | |
32 | public class LrcContextImpl extends BasicContextImpl { | |
33 | ||
34 | private LrcService lrcService; | |
35 | ||
36 | /** Total credits template token */ | |
37 | public final static String GRADE_TOKEN = "grade"; | |
38 | public final static String GRADE_TYPE_TOKEN = "gradeType"; | |
39 | ||
40 | 11 | public void setLrcService(LrcService lrcService) { |
41 | 11 | this.lrcService = lrcService; |
42 | } | |
43 | ||
44 | 3 | private ResultComponentInfo getResultComponentByResultComponentId(String resultComponentId) throws OperationFailedException { |
45 | 3 | if (resultComponentId == null) { |
46 | 1 | return null; |
47 | } | |
48 | 2 | try { |
49 | 2 | return lrcService.getResultComponent(resultComponentId); |
50 | } catch (Exception e) { | |
51 | 0 | throw new OperationFailedException(e.getMessage(), e); |
52 | } | |
53 | } | |
54 | ||
55 | 16 | private String getResultValue(ResultComponentInfo resultComponent, String resultValue) throws OperationFailedException { |
56 | 16 | if(resultComponent == null || resultValue == null) { |
57 | 3 | return null; |
58 | } | |
59 | 13 | for(String rv : resultComponent.getResultValues()) { |
60 | 21 | if(rv.equals(resultValue)) { |
61 | 13 | return rv; |
62 | } | |
63 | } | |
64 | 0 | throw new OperationFailedException("Result value not found: "+resultValue); |
65 | } | |
66 | ||
67 | 13 | private ResultComponentInfo getResultComponentByResultValueId(String resultValueId) throws OperationFailedException { |
68 | 13 | if(resultValueId == null) { |
69 | 0 | return null; |
70 | } | |
71 | ||
72 | 13 | try { |
73 | 13 | List<ResultComponentTypeInfo> typeList = lrcService.getResultComponentTypes(); |
74 | 13 | for(ResultComponentTypeInfo type : typeList) { |
75 | 49 | List<String> resultComponentIdList = lrcService.getResultComponentIdsByResultComponentType(type.getId()); |
76 | 49 | for(String resultComponentId : resultComponentIdList) { |
77 | 75 | ResultComponentInfo resultComponent = lrcService.getResultComponent(resultComponentId); |
78 | 75 | if(resultComponent.getResultValues().contains(resultValueId)) { |
79 | 13 | return resultComponent; |
80 | } | |
81 | } | |
82 | } | |
83 | } catch (Exception e) { | |
84 | 0 | throw new OperationFailedException(e.getMessage(), e); |
85 | } | |
86 | 0 | throw new OperationFailedException("Result value id not found: "+resultValueId); |
87 | } | |
88 | ||
89 | /** | |
90 | * Creates the context map (template data) for the requirement component. | |
91 | * | |
92 | * @param reqComponent Requirement component | |
93 | * @throws OperationFailedException Creating context map fails | |
94 | */ | |
95 | 16 | public Map<String, Object> createContextMap(ReqComponentInfo reqComponent) throws OperationFailedException { |
96 | 16 | Map<String, Object> contextMap = new HashMap<String, Object>(); |
97 | ||
98 | // String gradeTypeId = getReqComponentFieldValue(reqComponent, ReqComponentFieldTypes.GRADE_TYPE_KEY.getId()); | |
99 | // ResultComponentInfo gradeTypeResultComponent = getResultComponentByResultComponentId(gradeTypeId); | |
100 | // if(gradeTypeResultComponent != null) { | |
101 | // contextMap.put(GRADE_TYPE_TOKEN, gradeTypeResultComponent); | |
102 | // } | |
103 | // | |
104 | // String gradeId = getReqComponentFieldValue(reqComponent, ReqComponentFieldTypes.GRADE_KEY.getId()); | |
105 | // String grade = getResultValue(gradeTypeResultComponent, gradeId); | |
106 | // if(grade != null) { | |
107 | // contextMap.put(GRADE_TOKEN, grade); | |
108 | // } | |
109 | ||
110 | ||
111 | 16 | ResultComponentInfo gradeTypeResultComponent = null; |
112 | 16 | String gradeId = getReqComponentFieldValue(reqComponent, ReqComponentFieldTypes.GRADE_KEY.getId()); |
113 | 16 | if (gradeId == null) { |
114 | 3 | String gradeTypeId = getReqComponentFieldValue(reqComponent, ReqComponentFieldTypes.GRADE_TYPE_KEY.getId()); |
115 | 3 | gradeTypeResultComponent = getResultComponentByResultComponentId(gradeTypeId); |
116 | 3 | if (gradeTypeResultComponent != null) { |
117 | 2 | contextMap.put(GRADE_TYPE_TOKEN, gradeTypeResultComponent); |
118 | } | |
119 | } else { | |
120 | 13 | gradeTypeResultComponent = getResultComponentByResultValueId(gradeId); |
121 | } | |
122 | 16 | if (gradeTypeResultComponent != null) { |
123 | 15 | contextMap.put(GRADE_TYPE_TOKEN, gradeTypeResultComponent); |
124 | } | |
125 | ||
126 | 16 | String grade = getResultValue(gradeTypeResultComponent, gradeId); |
127 | 16 | if(grade != null) { |
128 | 13 | contextMap.put(GRADE_TOKEN, grade); |
129 | } | |
130 | ||
131 | 16 | return contextMap; |
132 | } | |
133 | } |
|