|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LuContextImpl | Line # 36 | 70 | 0% | 28 | 5 | 95.5% |
0.954955
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
(55) | |||
Result | |||
0.7477477
|
org.kuali.student.lum.statement.config.context.LuContextImplTest.testCreateContextMap_CluSet org.kuali.student.lum.statement.config.context.LuContextImplTest.testCreateContextMap_CluSet | 1 PASS | |
0.7477477
|
org.kuali.student.lum.statement.config.context.LuContextImplTest.testCreateContextMap_Clu org.kuali.student.lum.statement.config.context.LuContextImplTest.testCreateContextMap_Clu | 1 PASS | |
0.6756757
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_allN_CluSetOfClusets org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_allN_CluSetOfClusets | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_credits_2ofN org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_credits_2ofN | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_enroll_2ofN org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_enroll_2ofN | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_credits_max1 org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_credits_max1 | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_allN org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_allN | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_credits_max2 org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_credits_max2 | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateStatementTree org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateStatementTree | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_noneN org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_noneN | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_credits_none org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_credits_none | 1 PASS | |
0.6216216
|
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.6216216
|
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.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_NotCompletedAnyOfProgram org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_NotCompletedAnyOfProgram | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_enroll_1ofN org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_enroll_1ofN | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_CompletedAllProgram org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_CompletedAllProgram | 1 PASS | |
0.6216216
|
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.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_2CourseCompletedFromPrograms org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_2CourseCompletedFromPrograms | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_1ofN org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_1ofN | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_credits_1ofN org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_credits_1ofN | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_Completed1ofProgram org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_Completed1ofProgram | 1 PASS | |
0.6216216
|
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.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_gradecheck org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_gradecheck | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_courseset_completed_max org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_courseset_completed_max | 1 PASS | |
0.6216216
|
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.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_1CourseCompletedFromPrograms org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_1CourseCompletedFromPrograms | 1 PASS | |
0.6216216
|
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.6216216
|
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.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_2ofN org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_2ofN | 1 PASS | |
0.6216216
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_Completed2ofProgram org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_Completed2ofProgram | 1 PASS | |
0.6216216
|
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.6216216
|
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.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_MaxTestScoreOnTest org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_MaxTestScoreOnTest | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_ProgramAsCluSet org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_ProgramAsCluSet | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_org_duration_ProgramAsCluSet org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_org_duration_ProgramAsCluSet | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_MinTestScoreOnTest org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_MinTestScoreOnTest | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_ProgramAsCluSet org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_ProgramAsCluSet | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_all1 org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_all1 | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_1of1 org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_1of1 | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_NotCompletedProgram org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_NotCompletedProgram | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_DefaultEnglish org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_DefaultEnglish | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_org_duration_ProgramAsCluSet org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_org_duration_ProgramAsCluSet | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_2CourseCompletedFrom1Program org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_2CourseCompletedFrom1Program | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_CompletedSingleProgram org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_CompletedSingleProgram | 1 PASS | |
0.6036036
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_none1 org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponent_none1 | 1 PASS | |
0.44144145
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_kuali_reqComponent_type_program_residence_credits_final org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_kuali_reqComponent_type_program_residence_credits_final | 1 PASS | |
0.44144145
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_notcompleted org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_notcompleted | 1 PASS | |
0.44144145
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_org_duration_ProgramAsClu org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_org_duration_ProgramAsClu | 1 PASS | |
0.44144145
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_ProgramAsClu org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_notadmitted_ProgramAsClu | 1 PASS | |
0.44144145
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_kuali_reqComponent_type_program_enrolled_credits_final org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForProgram.testTranslateReqComponent_kuali_reqComponent_type_program_enrolled_credits_final | 1 PASS | |
0.44144145
|
org.kuali.student.lum.statement.config.context.LuContextImplTest.testCreateContextMap_NullTokenValues org.kuali.student.lum.statement.config.context.LuContextImplTest.testCreateContextMap_NullTokenValues | 1 PASS | |
0.44144145
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_org_duration_ProgramAsClu org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_org_duration_ProgramAsClu | 1 PASS | |
0.44144145
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_ProgramAsClu org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_program_admitted_ProgramAsClu | 1 PASS | |
0.44144145
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_enrolled org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_enrolled | 1 PASS | |
0.44144145
|
org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_completed org.kuali.student.lum.statement.service.impl.TestStatementServiceImplForCourse.testGetNaturalLanguageForReqComponentType_kuali_reqComponent_type_course_completed | 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.ArrayList; | |
19 | import java.util.List; | |
20 | import java.util.Map; | |
21 | ||
22 | import org.kuali.student.core.exceptions.OperationFailedException; | |
23 | import org.kuali.student.core.statement.dto.ReqComponentInfo; | |
24 | import org.kuali.student.core.versionmanagement.dto.VersionDisplayInfo; | |
25 | import org.kuali.student.lum.lu.dto.CluInfo; | |
26 | import org.kuali.student.lum.lu.dto.CluSetInfo; | |
27 | import org.kuali.student.lum.lu.dto.CluSetTreeViewInfo; | |
28 | import org.kuali.student.lum.lu.service.LuService; | |
29 | import org.kuali.student.lum.lu.service.LuServiceConstants; | |
30 | import org.kuali.student.lum.statement.config.context.util.NLCluSet; | |
31 | import org.kuali.student.lum.statement.typekey.ReqComponentFieldTypes; | |
32 | ||
33 | /** | |
34 | * This class creates the template context for course list types. | |
35 | */ | |
36 | public class LuContextImpl extends BasicContextImpl { | |
37 | /** | |
38 | * Learning unit service. | |
39 | */ | |
40 | private LuService luService; | |
41 | ||
42 | /** | |
43 | * <code>clu</code> token (key) references a Clu object used in templates. | |
44 | * e.g. 'Student must have completed all of | |
45 | * $clu.getOfficialIdentifier().getShortName()' | |
46 | */ | |
47 | public final static String CLU_TOKEN = "clu"; | |
48 | public final static String COURSE_CLU_TOKEN = "courseClu"; | |
49 | public final static String PROGRAM_CLU_TOKEN = "programClu"; | |
50 | public final static String TEST_CLU_TOKEN = "testClu"; | |
51 | ||
52 | /** | |
53 | * <code>cluSet</code> token (key) references a Clu set object | |
54 | * used in templates. | |
55 | * e.g. 'Student must have completed all of $cluSet.getCluSetAsCode()' | |
56 | */ | |
57 | public final static String CLU_SET_TOKEN = "cluSet"; | |
58 | public final static String COURSE_CLU_SET_TOKEN = "courseCluSet"; | |
59 | public final static String PROGRAM_CLU_SET_TOKEN = "programCluSet"; | |
60 | public final static String TEST_CLU_SET_TOKEN = "testCluSet"; | |
61 | ||
62 | /** | |
63 | * Sets the LU service. | |
64 | * | |
65 | * @param luService LU service | |
66 | */ | |
67 | 7 | public void setLuService(LuService luService) { |
68 | 7 | this.luService = luService; |
69 | } | |
70 | ||
71 | /** | |
72 | * Gets a CLU. | |
73 | * | |
74 | * @param cluId CLU id | |
75 | * @return CLU | |
76 | * @throws OperationFailedException If retrieving CLU fails | |
77 | */ | |
78 | 21 | public CluInfo getCluInfo(String cluId) throws OperationFailedException { |
79 | 21 | if (cluId == null) { |
80 | 4 | return null; |
81 | } | |
82 | 17 | try { |
83 | 17 | VersionDisplayInfo versionInfo = luService.getCurrentVersion(LuServiceConstants.CLU_NAMESPACE_URI, cluId); |
84 | 17 | CluInfo clu = this.luService.getClu(versionInfo.getId()); |
85 | 17 | return clu; |
86 | } catch(Exception e) { | |
87 | 0 | throw new OperationFailedException(e.getMessage(), e); |
88 | } | |
89 | } | |
90 | ||
91 | 228 | private CluInfo getClu(ReqComponentInfo reqComponent, String key) throws OperationFailedException { |
92 | 228 | Map<String, String> map = getReqComponentFieldMap(reqComponent); |
93 | 228 | if(map.containsKey(key)) { |
94 | 21 | String cluId = map.get(key); |
95 | 21 | return getCluInfo(cluId); |
96 | } | |
97 | 207 | return null; |
98 | } | |
99 | ||
100 | /** | |
101 | * Gets a CLU set. | |
102 | * | |
103 | * @param cluSetId CLU set id | |
104 | * @return CLU set | |
105 | * @throws OperationFailedException If retrieving CLU set fails | |
106 | */ | |
107 | 53 | public CluSetInfo getCluSetInfo(String cluSetId) throws OperationFailedException { |
108 | 53 | if (cluSetId == null) { |
109 | 0 | return null; |
110 | } | |
111 | 53 | try { |
112 | 53 | CluSetInfo cluSet = this.luService.getCluSetInfo(cluSetId); |
113 | 53 | return cluSet; |
114 | } catch(Exception e) { | |
115 | 0 | throw new OperationFailedException(e.getMessage(), e); |
116 | } | |
117 | } | |
118 | ||
119 | /** | |
120 | * Gets the CLU set. | |
121 | * | |
122 | * @param cluSetId CLU set id | |
123 | * @return CLU set | |
124 | * @throws OperationFailedException If building a custom CLU set fails | |
125 | */ | |
126 | 57 | public NLCluSet getCluSet(String cluSetId) throws OperationFailedException { |
127 | 57 | if (cluSetId == null) { |
128 | 4 | return null; |
129 | } | |
130 | 53 | CluSetInfo cluSet = getCluSetInfo(cluSetId); |
131 | 53 | try { |
132 | 53 | List<CluInfo> list = new ArrayList<CluInfo>(); |
133 | 53 | CluSetTreeViewInfo tree = luService.getCluSetTreeView(cluSetId); |
134 | 53 | findClusInCluSet(tree, list); |
135 | 53 | return new NLCluSet(cluSet.getId(), list); |
136 | } catch(Exception e) { | |
137 | 0 | throw new OperationFailedException(e.getMessage(), e); |
138 | } | |
139 | } | |
140 | ||
141 | 55 | private static void findClusInCluSet(CluSetTreeViewInfo tree, List<CluInfo> cluList) { |
142 | 55 | if (tree.getCluSets() != null) { |
143 | 1 | for (CluSetTreeViewInfo cluSet : tree.getCluSets()) { |
144 | 2 | findClusInCluSet(cluSet, cluList); |
145 | } | |
146 | } else { | |
147 | 54 | for (CluInfo clu : tree.getClus()) { |
148 | 98 | if (!containsClu(cluList, clu)) { |
149 | 96 | cluList.add(clu); |
150 | } | |
151 | } | |
152 | } | |
153 | } | |
154 | ||
155 | 98 | private static boolean containsClu(List<CluInfo> cluList, CluInfo clu) { |
156 | 98 | for (CluInfo clu2 : cluList) { |
157 | 54 | if (clu2.getId().equals(clu.getId())) { |
158 | 2 | return true; |
159 | } | |
160 | } | |
161 | 96 | return false; |
162 | } | |
163 | ||
164 | /** | |
165 | * Gets a new CLU set from comma separated list of CLU ids. | |
166 | * | |
167 | * @param cluIds Comma separated list of CLU ids | |
168 | * @return A new CLU set | |
169 | * @throws OperationFailedException If building a custom CLU set fails | |
170 | */ | |
171 | /*public NLCluSet getClusAsCluSet(String cluIds) throws OperationFailedException { | |
172 | String[] cluIdArray = cluIds.split("\\s*,\\s*"); | |
173 | List<CluInfo> list = new ArrayList<CluInfo>(); | |
174 | for(String cluId : cluIdArray) { | |
175 | CluInfo clu = getCluInfo(cluId); | |
176 | list.add(clu); | |
177 | } | |
178 | return new NLCluSet(null, list); | |
179 | }*/ | |
180 | ||
181 | /** | |
182 | * Gets a custom CLU set from a requirement component. | |
183 | * | |
184 | * @param reqComponent Requirement component | |
185 | * @return custom CLU set | |
186 | * @throws OperationFailedException If building a custom CLU set fails | |
187 | */ | |
188 | 228 | public NLCluSet getCluSet(ReqComponentInfo reqComponent, String key) throws OperationFailedException { |
189 | 228 | Map<String, String> map = getReqComponentFieldMap(reqComponent); |
190 | 228 | NLCluSet cluSet = null; |
191 | 228 | if(map.containsKey(key)) { |
192 | 57 | String cluSetId = map.get(key); |
193 | 57 | cluSet = getCluSet(cluSetId); |
194 | } | |
195 | 228 | return cluSet; |
196 | } | |
197 | ||
198 | /** | |
199 | * Creates the context map (template data) for the requirement component. | |
200 | * | |
201 | * @param reqComponent Requirement component | |
202 | * @throws OperationFailedException Creating context map fails | |
203 | */ | |
204 | 57 | public Map<String, Object> createContextMap(ReqComponentInfo reqComponent) throws OperationFailedException { |
205 | 57 | Map<String, Object> contextMap = super.createContextMap(reqComponent); |
206 | ||
207 | 57 | CluInfo clu = getClu(reqComponent, ReqComponentFieldTypes.CLU_KEY.getId()); |
208 | 57 | if(clu != null) { |
209 | 2 | contextMap.put(CLU_TOKEN, clu); |
210 | } | |
211 | 57 | CluInfo courseClu = getClu(reqComponent, ReqComponentFieldTypes.COURSE_CLU_KEY.getId()); |
212 | 57 | if(courseClu != null) { |
213 | 5 | contextMap.put(COURSE_CLU_TOKEN, courseClu); |
214 | } | |
215 | 57 | CluInfo programClu = getClu(reqComponent, ReqComponentFieldTypes.PROGRAM_CLU_KEY.getId()); |
216 | 57 | if(programClu != null) { |
217 | 8 | contextMap.put(PROGRAM_CLU_TOKEN, programClu); |
218 | } | |
219 | 57 | CluInfo testClu = getClu(reqComponent, ReqComponentFieldTypes.TEST_CLU_KEY.getId()); |
220 | 57 | if(testClu != null) { |
221 | 2 | contextMap.put(TEST_CLU_TOKEN, testClu); |
222 | } | |
223 | ||
224 | 57 | NLCluSet cluSet = getCluSet(reqComponent, ReqComponentFieldTypes.CLUSET_KEY.getId()); |
225 | 57 | if(cluSet != null) { |
226 | 2 | contextMap.put(CLU_SET_TOKEN, cluSet); |
227 | } | |
228 | 57 | NLCluSet courseCluSet = getCluSet(reqComponent, ReqComponentFieldTypes.COURSE_CLUSET_KEY.getId()); |
229 | 57 | if(courseCluSet != null) { |
230 | 32 | contextMap.put(COURSE_CLU_SET_TOKEN, courseCluSet); |
231 | } | |
232 | 57 | NLCluSet programCluSet = getCluSet(reqComponent, ReqComponentFieldTypes.PROGRAM_CLUSET_KEY.getId()); |
233 | 57 | if(programCluSet != null) { |
234 | 15 | contextMap.put(PROGRAM_CLU_SET_TOKEN, programCluSet); |
235 | } | |
236 | 57 | NLCluSet testCluSet = getCluSet(reqComponent, ReqComponentFieldTypes.TEST_CLUSET_KEY.getId()); |
237 | 57 | if(testCluSet != null) { |
238 | 4 | contextMap.put(TEST_CLU_SET_TOKEN, testCluSet); |
239 | } | |
240 | ||
241 | 57 | return contextMap; |
242 | } | |
243 | } |
|