|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LrcServiceAssembler | Line # 40 | 51 | 0% | 9 | 12 | 80.6% |
0.8064516
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(26) | |||
Result | |||
0.6451613
|
org.kuali.student.lum.lrc.service.impl.TestLrcServiceImpl.testResultComponentCrud org.kuali.student.lum.lrc.service.impl.TestLrcServiceImpl.testResultComponentCrud | 1 PASS | |
0.5645161
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testUpdateCourse org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testUpdateCourse | 1 PASS | |
0.5645161
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreditOptions org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreditOptions | 1 PASS | |
0.5645161
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourse org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCreateCourse | 1 PASS | |
0.3548387
|
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.3548387
|
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.3548387
|
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.3548387
|
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.3548387
|
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.3548387
|
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.3548387
|
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.3548387
|
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.3548387
|
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.19354838
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersions org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersions | 1 PASS | |
0.19354838
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseVersioning org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseVersioning | 1 PASS | |
0.19354838
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseCrossListing org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testCourseCrossListing | 1 PASS | |
0.19354838
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetFirstVersion org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetFirstVersion | 1 PASS | |
0.19354838
|
org.kuali.student.lum.lrc.service.impl.TestLrcServiceImpl.testGetResultComponent org.kuali.student.lum.lrc.service.impl.TestLrcServiceImpl.testGetResultComponent | 1 PASS | |
0.19354838
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersion org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersion | 1 PASS | |
0.19354838
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionsInDateRange org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionsInDateRange | 1 PASS | |
0.19354838
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDeleteCourse org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testDeleteCourse | 1 PASS | |
0.19354838
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCourse org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCourse | 1 PASS | |
0.19354838
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersionOnDate org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetCurrentVersionOnDate | 1 PASS | |
0.19354838
|
org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionBySequenceNumber org.kuali.student.lum.course.service.impl.TestCourseServiceImpl.testGetVersionBySequenceNumber | 1 PASS | |
0.16129032
|
org.kuali.student.lum.lrc.service.impl.TestLrcServiceImpl.getResultComponentTypes org.kuali.student.lum.lrc.service.impl.TestLrcServiceImpl.getResultComponentTypes | 1 PASS | |
0.08064516
|
org.kuali.student.lum.lrc.service.impl.TestLrcServiceImpl.testGetResultComponentType org.kuali.student.lum.lrc.service.impl.TestLrcServiceImpl.testGetResultComponentType | 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.lrc.service.impl; | |
17 | ||
18 | import java.util.ArrayList; | |
19 | import java.util.HashMap; | |
20 | import java.util.List; | |
21 | import java.util.Map; | |
22 | import java.util.Map.Entry; | |
23 | ||
24 | import org.kuali.student.common.exceptions.DataValidationErrorException; | |
25 | import org.kuali.student.common.exceptions.DoesNotExistException; | |
26 | import org.kuali.student.common.exceptions.InvalidParameterException; | |
27 | import org.kuali.student.common.service.impl.BaseAssembler; | |
28 | import org.kuali.student.lum.lrc.dao.LrcDao; | |
29 | import org.kuali.student.lum.lrc.dto.ResultComponentInfo; | |
30 | import org.kuali.student.lum.lrc.dto.ResultComponentTypeInfo; | |
31 | import org.kuali.student.lum.lrc.dto.ScaleInfo; | |
32 | import org.kuali.student.lum.lrc.entity.LrcRichText; | |
33 | import org.kuali.student.lum.lrc.entity.ResultComponent; | |
34 | import org.kuali.student.lum.lrc.entity.ResultComponentAttribute; | |
35 | import org.kuali.student.lum.lrc.entity.ResultComponentType; | |
36 | import org.kuali.student.lum.lrc.entity.ResultValue; | |
37 | import org.kuali.student.lum.lrc.entity.Scale; | |
38 | import org.springframework.beans.BeanUtils; | |
39 | ||
40 | public class LrcServiceAssembler extends BaseAssembler { | |
41 | ||
42 | ||
43 | 111 | public static ResultComponentInfo toResultComponentInfo(ResultComponent entity) { |
44 | 111 | ResultComponentInfo dto = new ResultComponentInfo(); |
45 | ||
46 | 111 | BeanUtils.copyProperties(entity, dto, |
47 | new String[] { "resultValues", "desc", "attributes", "type" }); | |
48 | 111 | List<String> resultValues = new ArrayList<String>(entity.getResultValues().size()); |
49 | 111 | for (ResultValue rv : entity.getResultValues()) { |
50 | 272 | resultValues.add(rv.getValue()); |
51 | } | |
52 | 111 | dto.setDesc(toRichTextInfo(entity.getDescr())); |
53 | 111 | dto.setResultValues(resultValues); |
54 | 111 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
55 | 111 | dto.setMetaInfo(toMetaInfo(entity.getMeta(), entity.getVersionNumber())); |
56 | 111 | dto.setType(entity.getType().getId()); |
57 | 111 | return dto; |
58 | } | |
59 | ||
60 | 0 | public static List<ResultComponentInfo> toReListComonentInfos(List<ResultComponent> entities) { |
61 | 0 | List<ResultComponentInfo> dtos = new ArrayList<ResultComponentInfo>(entities.size()); |
62 | 0 | for (ResultComponent entity : entities) { |
63 | 0 | dtos.add(toResultComponentInfo(entity)); |
64 | } | |
65 | 0 | return dtos; |
66 | } | |
67 | ||
68 | 71 | public static ResultComponentTypeInfo toResultComponentTypeInfo(ResultComponentType entity) { |
69 | 71 | ResultComponentTypeInfo dto = new ResultComponentTypeInfo(); |
70 | ||
71 | 71 | BeanUtils.copyProperties(entity, dto, |
72 | new String[] {"attributes" }); | |
73 | 71 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
74 | ||
75 | 71 | return dto; |
76 | } | |
77 | 10 | public static List<ResultComponentTypeInfo> toResultComponentTypeInfos(List<ResultComponentType> entites) { |
78 | 10 | List<ResultComponentTypeInfo> dtos = new ArrayList<ResultComponentTypeInfo>(entites.size()); |
79 | 10 | for (ResultComponentType entity : entites) { |
80 | 70 | dtos.add(toResultComponentTypeInfo(entity)); |
81 | } | |
82 | 10 | return dtos; |
83 | } | |
84 | ||
85 | ||
86 | 0 | public static ScaleInfo toScaleInfo(Scale entity) { |
87 | 0 | ScaleInfo dto = new ScaleInfo(); |
88 | 0 | BeanUtils.copyProperties(entity, dto, |
89 | new String[] { "desc", "attributes" }); | |
90 | 0 | dto.setDesc(toRichTextInfo(entity.getDesc())); |
91 | 0 | dto.setAttributes(toAttributeMap(entity.getAttributes())); |
92 | 0 | return dto; |
93 | } | |
94 | ||
95 | 5 | public static ResultComponent toResultComponent(String resultComponentTypeKey, ResultComponentInfo dto, LrcDao lrcDao) throws DoesNotExistException, InvalidParameterException, DataValidationErrorException { |
96 | 5 | ResultComponent entity = new ResultComponent(); |
97 | 5 | toResultComponent(entity, dto, lrcDao); |
98 | 5 | return entity; |
99 | } | |
100 | ||
101 | 7 | public static void toResultComponent(ResultComponent entity, ResultComponentInfo dto, LrcDao lrcDao) throws DoesNotExistException, InvalidParameterException, DataValidationErrorException { |
102 | 7 | BeanUtils.copyProperties(dto, entity, |
103 | new String[] { "desc", "resultValues", "attributes", "metaInfo", "type" }); | |
104 | 7 | ResultComponentType type = lrcDao.fetch(ResultComponentType.class, dto.getType()); |
105 | 7 | entity.setType(type); |
106 | ||
107 | 7 | entity.setDescr(toRichText(LrcRichText.class, dto.getDesc())); |
108 | ||
109 | //Create new Result Values, and delete unwanted ones, keep the overlap | |
110 | 7 | List<ResultValue> resultValues = new ArrayList<ResultValue>(dto.getResultValues().size()); |
111 | 7 | Map<String,ResultValue> currentResultValues = new HashMap<String,ResultValue>(); |
112 | 7 | if(entity.getResultValues()!=null){ |
113 | 2 | for(ResultValue resultValue:entity.getResultValues()){ |
114 | 3 | currentResultValues.put(resultValue.getValue(),resultValue); |
115 | } | |
116 | } | |
117 | ||
118 | 7 | for(String value:dto.getResultValues()){ |
119 | 21 | if(!currentResultValues.containsKey(value)){ |
120 | 18 | ResultValue newResultValue = new ResultValue(); |
121 | 18 | newResultValue.setValue(value); |
122 | 18 | newResultValue.setResultComponent(entity); |
123 | 18 | resultValues.add(newResultValue); |
124 | }else{ | |
125 | 3 | resultValues.add(currentResultValues.remove(value)); |
126 | } | |
127 | } | |
128 | //Delete leftovers | |
129 | 7 | for(Entry<String,ResultValue> entry:currentResultValues.entrySet()){ |
130 | 0 | lrcDao.delete(entry.getValue()); |
131 | } | |
132 | ||
133 | 7 | entity.setResultValues(resultValues); |
134 | 7 | entity.setAttributes(toGenericAttributes(ResultComponentAttribute.class, dto.getAttributes(), entity, lrcDao)); |
135 | } | |
136 | } |
|