1 |
|
package org.kuali.student.lum.course.service.impl; |
2 |
|
|
3 |
|
import static org.apache.commons.collections.CollectionUtils.isEmpty; |
4 |
|
|
5 |
|
import java.util.ArrayList; |
6 |
|
import java.util.Date; |
7 |
|
import java.util.List; |
8 |
|
|
9 |
|
import org.apache.log4j.Logger; |
10 |
|
import org.kuali.student.common.validator.Validator; |
11 |
|
import org.kuali.student.common.validator.ValidatorFactory; |
12 |
|
import org.kuali.student.core.assembly.BaseDTOAssemblyNode; |
13 |
|
import org.kuali.student.core.assembly.BaseDTOAssemblyNode.NodeOperation; |
14 |
|
import org.kuali.student.core.assembly.BusinessServiceMethodInvoker; |
15 |
|
import org.kuali.student.core.assembly.data.AssemblyException; |
16 |
|
import org.kuali.student.core.dictionary.dto.ObjectStructureDefinition; |
17 |
|
import org.kuali.student.core.dictionary.service.DictionaryService; |
18 |
|
import org.kuali.student.core.dto.StatusInfo; |
19 |
|
import org.kuali.student.core.exceptions.AlreadyExistsException; |
20 |
|
import org.kuali.student.core.exceptions.CircularReferenceException; |
21 |
|
import org.kuali.student.core.exceptions.CircularRelationshipException; |
22 |
|
import org.kuali.student.core.exceptions.DataValidationErrorException; |
23 |
|
import org.kuali.student.core.exceptions.DependentObjectsExistException; |
24 |
|
import org.kuali.student.core.exceptions.DoesNotExistException; |
25 |
|
import org.kuali.student.core.exceptions.IllegalVersionSequencingException; |
26 |
|
import org.kuali.student.core.exceptions.InvalidParameterException; |
27 |
|
import org.kuali.student.core.exceptions.MissingParameterException; |
28 |
|
import org.kuali.student.core.exceptions.OperationFailedException; |
29 |
|
import org.kuali.student.core.exceptions.PermissionDeniedException; |
30 |
|
import org.kuali.student.core.exceptions.UnsupportedActionException; |
31 |
|
import org.kuali.student.core.exceptions.VersionMismatchException; |
32 |
|
import org.kuali.student.core.statement.dto.RefStatementRelationInfo; |
33 |
|
import org.kuali.student.core.statement.dto.ReqCompFieldInfo; |
34 |
|
import org.kuali.student.core.statement.dto.ReqComponentInfo; |
35 |
|
import org.kuali.student.core.statement.dto.StatementTreeViewInfo; |
36 |
|
import org.kuali.student.core.statement.service.StatementService; |
37 |
|
import org.kuali.student.core.validation.dto.ValidationResultInfo; |
38 |
|
import org.kuali.student.core.versionmanagement.dto.VersionDisplayInfo; |
39 |
|
import org.kuali.student.lum.course.dto.ActivityInfo; |
40 |
|
import org.kuali.student.lum.course.dto.CourseInfo; |
41 |
|
import org.kuali.student.lum.course.dto.CourseJointInfo; |
42 |
|
import org.kuali.student.lum.course.dto.FormatInfo; |
43 |
|
import org.kuali.student.lum.course.dto.LoDisplayInfo; |
44 |
|
import org.kuali.student.lum.course.service.CourseService; |
45 |
|
import org.kuali.student.lum.course.service.CourseServiceConstants; |
46 |
|
import org.kuali.student.lum.course.service.assembler.CourseAssembler; |
47 |
|
import org.kuali.student.lum.course.service.assembler.CourseAssemblerConstants; |
48 |
|
import org.kuali.student.lum.lu.dto.CluInfo; |
49 |
|
import org.kuali.student.lum.lu.dto.CluSetInfo; |
50 |
|
import org.kuali.student.lum.lu.service.LuService; |
51 |
|
import org.kuali.student.lum.lu.service.LuServiceConstants; |
52 |
|
import org.kuali.student.lum.statement.typekey.ReqComponentFieldTypes; |
53 |
|
import org.springframework.transaction.annotation.Transactional; |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
@author |
74 |
|
|
75 |
|
@Transactional(readOnly=true,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
|
|
| 77.3% |
Uncovered Elements: 63 (278) |
Complexity: 83 |
Complexity Density: 0.43 |
|
76 |
|
public class CourseServiceImpl implements CourseService { |
77 |
|
final static Logger LOG = Logger.getLogger(CourseServiceImpl.class); |
78 |
|
|
79 |
|
private LuService luService; |
80 |
|
private CourseAssembler courseAssembler; |
81 |
|
private BusinessServiceMethodInvoker courseServiceMethodInvoker; |
82 |
|
private DictionaryService dictionaryServiceDelegate; |
83 |
|
private ValidatorFactory validatorFactory; |
84 |
|
private StatementService statementService; |
85 |
|
|
|
|
| 50% |
Uncovered Elements: 6 (12) |
Complexity: 5 |
Complexity Density: 0.5 |
|
86 |
13
|
@Override... |
87 |
|
@Transactional(readOnly=false) |
88 |
|
public CourseInfo createCourse(CourseInfo courseInfo) throws AlreadyExistsException, DataValidationErrorException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException, DoesNotExistException, CircularRelationshipException, DependentObjectsExistException, UnsupportedActionException { |
89 |
|
|
90 |
13
|
checkForMissingParameter(courseInfo, "CourseInfo"); |
91 |
|
|
92 |
|
|
93 |
13
|
List<ValidationResultInfo> validationResults = validateCourse("OBJECT", courseInfo); |
94 |
13
|
if (null != validationResults && validationResults.size() > 0) { |
95 |
0
|
throw new DataValidationErrorException("Validation error!", validationResults); |
96 |
|
} |
97 |
|
|
98 |
13
|
try { |
99 |
13
|
return processCourseInfo(courseInfo, NodeOperation.CREATE); |
100 |
|
} catch (AssemblyException e) { |
101 |
0
|
LOG.error("Error disassembling course", e); |
102 |
0
|
throw new OperationFailedException("Error disassembling course"); |
103 |
|
} catch (Exception e){ |
104 |
0
|
LOG.error("Error disassembling course", e); |
105 |
0
|
throw new OperationFailedException("Error disassembling course"); |
106 |
|
} |
107 |
|
} |
108 |
|
|
|
|
| 60% |
Uncovered Elements: 4 (10) |
Complexity: 4 |
Complexity Density: 0.5 |
|
109 |
2
|
@Override... |
110 |
|
@Transactional(readOnly=false) |
111 |
|
public CourseInfo updateCourse(CourseInfo courseInfo) throws DataValidationErrorException, DoesNotExistException, InvalidParameterException, MissingParameterException, VersionMismatchException, OperationFailedException, PermissionDeniedException, AlreadyExistsException, CircularRelationshipException, DependentObjectsExistException, UnsupportedActionException, UnsupportedOperationException, CircularReferenceException { |
112 |
|
|
113 |
2
|
checkForMissingParameter(courseInfo, "CourseInfo"); |
114 |
|
|
115 |
|
|
116 |
2
|
List<ValidationResultInfo> validationResults = validateCourse("OBJECT", courseInfo); |
117 |
2
|
if (null != validationResults && validationResults.size() > 0) { |
118 |
0
|
throw new DataValidationErrorException("Validation error!", validationResults); |
119 |
|
} |
120 |
|
|
121 |
2
|
try { |
122 |
|
|
123 |
2
|
return processCourseInfo(courseInfo, NodeOperation.UPDATE); |
124 |
|
|
125 |
|
} catch (AssemblyException e) { |
126 |
0
|
LOG.error("Error disassembling course", e); |
127 |
0
|
throw new OperationFailedException("Error disassembling course"); |
128 |
|
} |
129 |
|
} |
130 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
131 |
1
|
@Override... |
132 |
|
@Transactional(readOnly=false) |
133 |
|
public StatusInfo deleteCourse(String courseId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, VersionMismatchException, DataValidationErrorException, AlreadyExistsException, CircularRelationshipException, DependentObjectsExistException, UnsupportedActionException, UnsupportedOperationException, CircularReferenceException { |
134 |
|
|
135 |
1
|
try { |
136 |
1
|
CourseInfo course = getCourse(courseId); |
137 |
|
|
138 |
1
|
processCourseInfo(course, NodeOperation.DELETE); |
139 |
|
|
140 |
1
|
StatusInfo status = new StatusInfo(); |
141 |
1
|
status.setSuccess(true); |
142 |
1
|
return status; |
143 |
|
|
144 |
|
} catch (AssemblyException e) { |
145 |
0
|
LOG.error("Error disassembling course", e); |
146 |
0
|
throw new OperationFailedException("Error disassembling course"); |
147 |
|
} |
148 |
|
} |
149 |
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
150 |
14
|
@Override... |
151 |
|
public CourseInfo getCourse(String courseId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
152 |
|
|
153 |
14
|
CluInfo clu = luService.getClu(courseId); |
154 |
|
|
155 |
13
|
CourseInfo course; |
156 |
13
|
try { |
157 |
13
|
course = courseAssembler.assemble(clu, null, false); |
158 |
|
} catch (AssemblyException e) { |
159 |
0
|
LOG.error("Error assembling course", e); |
160 |
0
|
throw new OperationFailedException("Error assembling course"); |
161 |
|
} |
162 |
|
|
163 |
13
|
return course; |
164 |
|
|
165 |
|
} |
166 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
167 |
1
|
@Override... |
168 |
|
public List<ActivityInfo> getCourseActivities(String formatId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
169 |
1
|
throw new UnsupportedOperationException("GetCourseActivities"); |
170 |
|
} |
171 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
172 |
1
|
@Override... |
173 |
|
public List<FormatInfo> getCourseFormats(String courseId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
174 |
1
|
throw new UnsupportedOperationException("GetCourseFormats"); |
175 |
|
} |
176 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
177 |
1
|
@Override... |
178 |
|
public List<LoDisplayInfo> getCourseLos(String courseId) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
179 |
1
|
throw new UnsupportedOperationException("GetCourseLos"); |
180 |
|
} |
181 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 3 |
Complexity Density: 0.27 |
|
182 |
12
|
@Override... |
183 |
|
public List<StatementTreeViewInfo> getCourseStatements(String courseId, String nlUsageTypeKey, String language) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
184 |
12
|
checkForMissingParameter(courseId, "courseId"); |
185 |
|
|
186 |
12
|
CluInfo clu = luService.getClu(courseId); |
187 |
12
|
if (!CourseAssemblerConstants.COURSE_TYPE.equals(clu.getType())) { |
188 |
1
|
throw new DoesNotExistException("Specified CLU is not a Course"); |
189 |
|
} |
190 |
11
|
List<RefStatementRelationInfo> relations = statementService.getRefStatementRelationsByRef(CourseAssemblerConstants.COURSE_TYPE, clu.getId()); |
191 |
11
|
if (relations == null) { |
192 |
7
|
return new ArrayList<StatementTreeViewInfo>(0); |
193 |
|
} |
194 |
|
|
195 |
4
|
List<StatementTreeViewInfo> tree = new ArrayList<StatementTreeViewInfo>(relations.size()); |
196 |
4
|
for (RefStatementRelationInfo relation : relations) { |
197 |
9
|
tree.add(statementService.getStatementTreeView(relation.getStatementId())); |
198 |
|
} |
199 |
4
|
return tree; |
200 |
|
} |
201 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
202 |
15
|
@Override... |
203 |
|
public List<ValidationResultInfo> validateCourse(String validationType, CourseInfo courseInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException { |
204 |
|
|
205 |
15
|
ObjectStructureDefinition objStructure = this.getObjectStructure(CourseInfo.class.getName()); |
206 |
15
|
Validator defaultValidator = validatorFactory.getValidator(); |
207 |
15
|
List<ValidationResultInfo> validationResults = defaultValidator.validateObject(courseInfo, objStructure); |
208 |
15
|
return validationResults; |
209 |
|
} |
210 |
|
|
|
|
| 86.4% |
Uncovered Elements: 3 (22) |
Complexity: 4 |
Complexity Density: 0.22 |
|
211 |
8
|
@Override... |
212 |
|
@Transactional(readOnly=false) |
213 |
|
public StatementTreeViewInfo createCourseStatement(String courseId, StatementTreeViewInfo statementTreeViewInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException { |
214 |
8
|
checkForMissingParameter(courseId, "courseId"); |
215 |
7
|
checkForMissingParameter(statementTreeViewInfo, "statementTreeViewInfo"); |
216 |
|
|
217 |
|
|
218 |
6
|
List<ValidationResultInfo> validationResults = validateCourseStatement(courseId, statementTreeViewInfo); |
219 |
6
|
if (!isEmpty(validationResults)) { |
220 |
0
|
throw new DataValidationErrorException("Validation error!", validationResults); |
221 |
|
} |
222 |
|
|
223 |
6
|
if (findStatementReference(courseId, statementTreeViewInfo) != null) { |
224 |
1
|
throw new InvalidParameterException("Statement is already referenced by this course"); |
225 |
|
} |
226 |
|
|
227 |
5
|
try { |
228 |
5
|
StatementTreeViewInfo tree = statementService.createStatementTreeView(statementTreeViewInfo); |
229 |
5
|
RefStatementRelationInfo relation = new RefStatementRelationInfo(); |
230 |
5
|
relation.setRefObjectId(courseId); |
231 |
5
|
relation.setRefObjectTypeKey(CourseAssemblerConstants.COURSE_TYPE); |
232 |
5
|
relation.setStatementId(tree.getId()); |
233 |
5
|
relation.setType(CourseAssemblerConstants.COURSE_REFERENCE_TYPE); |
234 |
5
|
relation.setState(CourseAssemblerConstants.ACTIVE); |
235 |
5
|
statementService.createRefStatementRelation(relation); |
236 |
|
} catch (Exception e) { |
237 |
0
|
throw new OperationFailedException("Unable to create clu/tree relation", e); |
238 |
|
} |
239 |
5
|
return statementTreeViewInfo; |
240 |
|
} |
241 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
242 |
5
|
@Override... |
243 |
|
@Transactional(readOnly=false) |
244 |
|
public StatusInfo deleteCourseStatement(String courseId, StatementTreeViewInfo statementTreeViewInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { |
245 |
5
|
checkForMissingParameter(courseId, "courseId"); |
246 |
4
|
checkForMissingParameter(statementTreeViewInfo, "statementTreeViewInfo"); |
247 |
|
|
248 |
3
|
RefStatementRelationInfo relation = findStatementReference(courseId, statementTreeViewInfo); |
249 |
3
|
if (relation != null) { |
250 |
1
|
statementService.deleteRefStatementRelation(relation.getId()); |
251 |
1
|
statementService.deleteStatementTreeView(statementTreeViewInfo.getId()); |
252 |
1
|
StatusInfo result = new StatusInfo(); |
253 |
1
|
return result; |
254 |
|
} |
255 |
|
|
256 |
2
|
throw new DoesNotExistException("Course does not have this StatemenTree"); |
257 |
|
} |
258 |
|
|
|
|
| 66.7% |
Uncovered Elements: 4 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
259 |
1
|
@Override... |
260 |
|
@Transactional(readOnly=false) |
261 |
|
public StatementTreeViewInfo updateCourseStatement(String courseId, StatementTreeViewInfo statementTreeViewInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException, DataValidationErrorException, CircularReferenceException, VersionMismatchException { |
262 |
1
|
checkForMissingParameter(courseId, "courseId"); |
263 |
1
|
checkForMissingParameter(statementTreeViewInfo, "statementTreeViewInfo"); |
264 |
|
|
265 |
|
|
266 |
1
|
List<ValidationResultInfo> validationResults = validateCourseStatement(courseId, statementTreeViewInfo); |
267 |
1
|
if (!isEmpty(validationResults)) { |
268 |
0
|
throw new DataValidationErrorException("Validation error!", validationResults); |
269 |
|
} |
270 |
|
|
271 |
1
|
if (findStatementReference(courseId, statementTreeViewInfo) == null) { |
272 |
0
|
throw new InvalidParameterException("Statement is not part of this course"); |
273 |
|
} |
274 |
|
|
275 |
1
|
return statementService.updateStatementTreeView(statementTreeViewInfo.getId(), statementTreeViewInfo); |
276 |
|
} |
277 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 2 |
Complexity Density: 0.22 |
|
278 |
7
|
@Override... |
279 |
|
public List<ValidationResultInfo> validateCourseStatement(String courseId, StatementTreeViewInfo statementTreeViewInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException { |
280 |
7
|
checkForMissingParameter(courseId, "courseId"); |
281 |
7
|
checkForMissingParameter(statementTreeViewInfo, "statementTreeViewInfo"); |
282 |
|
|
283 |
7
|
try { |
284 |
7
|
CluInfo clu = luService.getClu(courseId); |
285 |
|
} catch (DoesNotExistException e) { |
286 |
0
|
throw new InvalidParameterException("course does not exist"); |
287 |
|
} |
288 |
|
|
289 |
7
|
ObjectStructureDefinition objStructure = this.getObjectStructure(StatementTreeViewInfo.class.getName()); |
290 |
7
|
Validator defaultValidator = validatorFactory.getValidator(); |
291 |
7
|
List<ValidationResultInfo> validationResults = defaultValidator.validateObject(statementTreeViewInfo, objStructure); |
292 |
7
|
return validationResults; |
293 |
|
} |
294 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
295 |
23
|
@Override... |
296 |
|
public ObjectStructureDefinition getObjectStructure(String objectTypeKey) { |
297 |
23
|
return dictionaryServiceDelegate.getObjectStructure(objectTypeKey); |
298 |
|
} |
299 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
300 |
1
|
@Override... |
301 |
|
public List<String> getObjectTypes() { |
302 |
1
|
return dictionaryServiceDelegate.getObjectTypes(); |
303 |
|
} |
304 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
305 |
0
|
public CourseAssembler getCourseAssembler() {... |
306 |
0
|
return courseAssembler; |
307 |
|
} |
308 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
309 |
1
|
public void setCourseAssembler(CourseAssembler courseAssembler) {... |
310 |
1
|
this.courseAssembler = courseAssembler; |
311 |
|
} |
312 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
313 |
0
|
public BusinessServiceMethodInvoker getCourseServiceMethodInvoker() {... |
314 |
0
|
return courseServiceMethodInvoker; |
315 |
|
} |
316 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
317 |
1
|
public void setCourseServiceMethodInvoker(BusinessServiceMethodInvoker courseServiceMethodInvoker) {... |
318 |
1
|
this.courseServiceMethodInvoker = courseServiceMethodInvoker; |
319 |
|
} |
320 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
321 |
0
|
public DictionaryService getDictionaryServiceDelegate() {... |
322 |
0
|
return dictionaryServiceDelegate; |
323 |
|
} |
324 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
325 |
1
|
public void setDictionaryServiceDelegate(DictionaryService dictionaryServiceDelegate) {... |
326 |
1
|
this.dictionaryServiceDelegate = dictionaryServiceDelegate; |
327 |
|
} |
328 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
329 |
16
|
private CourseInfo processCourseInfo(CourseInfo courseInfo, NodeOperation operation) throws AssemblyException, OperationFailedException, VersionMismatchException, PermissionDeniedException, MissingParameterException, InvalidParameterException, DoesNotExistException, DataValidationErrorException, AlreadyExistsException, CircularRelationshipException, DependentObjectsExistException, UnsupportedActionException, UnsupportedOperationException, CircularReferenceException {... |
330 |
|
|
331 |
16
|
BaseDTOAssemblyNode<CourseInfo, CluInfo> results = courseAssembler.disassemble(courseInfo, operation); |
332 |
|
|
333 |
|
|
334 |
16
|
courseServiceMethodInvoker.invokeServiceCalls(results); |
335 |
|
|
336 |
15
|
return results.getBusinessDTORef(); |
337 |
|
} |
338 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
339 |
0
|
public ValidatorFactory getValidatorFactory() {... |
340 |
0
|
return validatorFactory; |
341 |
|
} |
342 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
343 |
1
|
public void setValidatorFactory(ValidatorFactory validatorFactory) {... |
344 |
1
|
this.validatorFactory = validatorFactory; |
345 |
|
} |
346 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
347 |
0
|
public LuService getLuService() {... |
348 |
0
|
return luService; |
349 |
|
} |
350 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
351 |
1
|
public void setLuService(LuService luService) {... |
352 |
1
|
this.luService = luService; |
353 |
|
} |
354 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
355 |
0
|
public StatementService getStatementService() {... |
356 |
0
|
return statementService; |
357 |
|
} |
358 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
359 |
1
|
public void setStatementService(StatementService statementService) {... |
360 |
1
|
this.statementService = statementService; |
361 |
|
} |
362 |
|
|
|
|
| 66.7% |
Uncovered Elements: 7 (21) |
Complexity: 8 |
Complexity Density: 0.38 |
|
363 |
8
|
@Override... |
364 |
|
@Transactional(readOnly=false) |
365 |
|
public CourseInfo createNewCourseVersion(String versionIndCourseId, |
366 |
|
String versionComment) throws DataValidationErrorException, |
367 |
|
DoesNotExistException, InvalidParameterException, |
368 |
|
MissingParameterException, OperationFailedException, |
369 |
|
PermissionDeniedException, VersionMismatchException { |
370 |
|
|
371 |
|
|
372 |
8
|
VersionDisplayInfo currentVersion = luService.getCurrentVersion(LuServiceConstants.CLU_NAMESPACE_URI, versionIndCourseId); |
373 |
8
|
CourseInfo originalCourse = getCourse(currentVersion.getId()); |
374 |
|
|
375 |
|
|
376 |
8
|
CluInfo newVersionClu = luService.createNewCluVersion(versionIndCourseId, versionComment); |
377 |
|
|
378 |
8
|
try { |
379 |
8
|
BaseDTOAssemblyNode<CourseInfo, CluInfo> results; |
380 |
|
|
381 |
|
|
382 |
8
|
courseAssembler.assemble(newVersionClu, originalCourse, true); |
383 |
|
|
384 |
|
|
385 |
8
|
resetIds(originalCourse); |
386 |
|
|
387 |
|
|
388 |
8
|
results = courseAssembler.disassemble(originalCourse, NodeOperation.UPDATE); |
389 |
|
|
390 |
|
|
391 |
8
|
courseServiceMethodInvoker.invokeServiceCalls(results); |
392 |
|
|
393 |
|
|
394 |
8
|
List<StatementTreeViewInfo> statementTreeViews = getCourseStatements(currentVersion.getId(),null,null); |
395 |
|
|
396 |
8
|
clearStatementTreeViewIds(statementTreeViews); |
397 |
|
|
398 |
8
|
for(StatementTreeViewInfo statementTreeView:statementTreeViews){ |
399 |
1
|
createCourseStatement(results.getBusinessDTORef().getId(), statementTreeView); |
400 |
|
} |
401 |
|
|
402 |
8
|
return results.getBusinessDTORef(); |
403 |
|
} catch (AlreadyExistsException e) { |
404 |
0
|
throw new OperationFailedException("Error creating new course version",e); |
405 |
|
} catch (DependentObjectsExistException e) { |
406 |
0
|
throw new OperationFailedException("Error creating new course version",e); |
407 |
|
} catch (CircularRelationshipException e) { |
408 |
0
|
throw new OperationFailedException("Error creating new course version",e); |
409 |
|
} catch (UnsupportedActionException e) { |
410 |
0
|
throw new OperationFailedException("Error creating new course version",e); |
411 |
|
} catch (AssemblyException e) { |
412 |
0
|
throw new OperationFailedException("Error creating new course version",e); |
413 |
|
} catch (UnsupportedOperationException e) { |
414 |
0
|
throw new OperationFailedException("Error creating new course version",e); |
415 |
|
} catch (CircularReferenceException e) { |
416 |
0
|
throw new OperationFailedException("Error creating new course version",e); |
417 |
|
} |
418 |
|
|
419 |
|
} |
420 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
421 |
8
|
private void clearStatementTreeViewIds(... |
422 |
|
List<StatementTreeViewInfo> statementTreeViews) throws OperationFailedException { |
423 |
8
|
for(StatementTreeViewInfo statementTreeView:statementTreeViews){ |
424 |
1
|
clearStatementTreeViewIdsRecursively(statementTreeView); |
425 |
|
} |
426 |
|
} |
427 |
|
|
|
|
| 28.6% |
Uncovered Elements: 15 (21) |
Complexity: 6 |
Complexity Density: 0.35 |
|
428 |
3
|
private void clearStatementTreeViewIdsRecursively(StatementTreeViewInfo statementTreeView) throws OperationFailedException{... |
429 |
3
|
statementTreeView.setId(null); |
430 |
3
|
for(ReqComponentInfo reqComp:statementTreeView.getReqComponents()){ |
431 |
4
|
reqComp.setId(null); |
432 |
4
|
for(ReqCompFieldInfo field:reqComp.getReqCompFields()){ |
433 |
0
|
field.setId(null); |
434 |
|
|
435 |
0
|
if(ReqComponentFieldTypes.COURSE_CLUSET_KEY.getId().equals(field.getType())|| |
436 |
|
ReqComponentFieldTypes.PROGRAM_CLUSET_KEY.getId().equals(field.getType())|| |
437 |
|
ReqComponentFieldTypes.CLUSET_KEY.getId().equals(field.getType())){ |
438 |
0
|
try { |
439 |
0
|
CluSetInfo cluSet = luService.getCluSetInfo(field.getValue()); |
440 |
0
|
cluSet.setId(null); |
441 |
|
|
442 |
0
|
if (cluSet.getMembershipQuery() != null){ |
443 |
0
|
cluSet.getCluIds().clear(); |
444 |
0
|
cluSet.getCluSetIds().clear(); |
445 |
|
} |
446 |
0
|
cluSet = luService.createCluSet(cluSet.getType(), cluSet); |
447 |
0
|
field.setValue(cluSet.getId()); |
448 |
|
} catch (Exception e) { |
449 |
0
|
throw new OperationFailedException("Error copying clusets.", e); |
450 |
|
} |
451 |
|
} |
452 |
|
|
453 |
|
} |
454 |
|
} |
455 |
3
|
for(StatementTreeViewInfo child: statementTreeView.getStatements()){ |
456 |
2
|
clearStatementTreeViewIdsRecursively(child); |
457 |
|
} |
458 |
|
} |
459 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
460 |
8
|
private void resetIds(CourseInfo course) {... |
461 |
|
|
462 |
8
|
for(CourseJointInfo joint:course.getJoints()){ |
463 |
0
|
joint.setRelationId(null); |
464 |
|
} |
465 |
|
|
466 |
8
|
for(LoDisplayInfo lo:course.getCourseSpecificLOs()){ |
467 |
16
|
resetLoRecursively(lo); |
468 |
|
} |
469 |
|
|
470 |
8
|
for(FormatInfo format:course.getFormats()){ |
471 |
16
|
format.setId(null); |
472 |
16
|
for(ActivityInfo activity:format.getActivities()){ |
473 |
32
|
activity.setId(null); |
474 |
|
} |
475 |
|
} |
476 |
|
} |
477 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
478 |
112
|
private void resetLoRecursively(LoDisplayInfo lo){... |
479 |
112
|
lo.getLoInfo().setId(null); |
480 |
112
|
for(LoDisplayInfo nestedLo:lo.getLoDisplayInfoList()){ |
481 |
96
|
resetLoRecursively(nestedLo); |
482 |
|
} |
483 |
|
} |
484 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
485 |
2
|
@Override... |
486 |
|
@Transactional(readOnly=false) |
487 |
|
public StatusInfo setCurrentCourseVersion(String courseVersionId, |
488 |
|
Date currentVersionStart) throws DoesNotExistException, |
489 |
|
InvalidParameterException, MissingParameterException, |
490 |
|
IllegalVersionSequencingException, OperationFailedException, |
491 |
|
PermissionDeniedException { |
492 |
2
|
return luService.setCurrentCluVersion(courseVersionId, currentVersionStart); |
493 |
|
} |
494 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
495 |
2
|
@Override... |
496 |
|
public VersionDisplayInfo getCurrentVersion(String refObjectTypeURI, |
497 |
|
String refObjectId) throws DoesNotExistException, |
498 |
|
InvalidParameterException, MissingParameterException, |
499 |
|
OperationFailedException, PermissionDeniedException { |
500 |
2
|
if(CourseServiceConstants.COURSE_NAMESPACE_URI.equals(refObjectTypeURI)){ |
501 |
1
|
return luService.getCurrentVersion(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId); |
502 |
|
} |
503 |
1
|
throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
504 |
|
} |
505 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
506 |
4
|
@Override... |
507 |
|
public VersionDisplayInfo getCurrentVersionOnDate(String refObjectTypeURI, |
508 |
|
String refObjectId, Date date) throws DoesNotExistException, |
509 |
|
InvalidParameterException, MissingParameterException, |
510 |
|
OperationFailedException, PermissionDeniedException { |
511 |
4
|
if(CourseServiceConstants.COURSE_NAMESPACE_URI.equals(refObjectTypeURI)){ |
512 |
3
|
return luService.getCurrentVersionOnDate(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId, date); |
513 |
|
} |
514 |
1
|
throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
515 |
|
} |
516 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
517 |
2
|
@Override... |
518 |
|
public VersionDisplayInfo getFirstVersion(String refObjectTypeURI, |
519 |
|
String refObjectId) throws DoesNotExistException, |
520 |
|
InvalidParameterException, MissingParameterException, |
521 |
|
OperationFailedException, PermissionDeniedException { |
522 |
2
|
if(CourseServiceConstants.COURSE_NAMESPACE_URI.equals(refObjectTypeURI)){ |
523 |
1
|
return luService.getFirstVersion(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId); |
524 |
|
} |
525 |
1
|
throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
526 |
|
|
527 |
|
} |
528 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
529 |
0
|
@Override... |
530 |
|
public VersionDisplayInfo getLatestVersion(String refObjectTypeURI, |
531 |
|
String refObjectId) throws DoesNotExistException, |
532 |
|
InvalidParameterException, MissingParameterException, |
533 |
|
OperationFailedException, PermissionDeniedException { |
534 |
0
|
if(CourseServiceConstants.COURSE_NAMESPACE_URI.equals(refObjectTypeURI)){ |
535 |
0
|
return luService.getLatestVersion(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId); |
536 |
|
} |
537 |
0
|
throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
538 |
|
|
539 |
|
} |
540 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
541 |
2
|
@Override... |
542 |
|
public VersionDisplayInfo getVersionBySequenceNumber( |
543 |
|
String refObjectTypeURI, String refObjectId, Long sequence) |
544 |
|
throws DoesNotExistException, InvalidParameterException, |
545 |
|
MissingParameterException, OperationFailedException, |
546 |
|
PermissionDeniedException { |
547 |
2
|
if(CourseServiceConstants.COURSE_NAMESPACE_URI.equals(refObjectTypeURI)){ |
548 |
1
|
return luService.getVersionBySequenceNumber(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId, sequence); |
549 |
|
} |
550 |
1
|
throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
551 |
|
} |
552 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
553 |
3
|
@Override... |
554 |
|
public List<VersionDisplayInfo> getVersions(String refObjectTypeURI, |
555 |
|
String refObjectId) throws DoesNotExistException, |
556 |
|
InvalidParameterException, MissingParameterException, |
557 |
|
OperationFailedException, PermissionDeniedException { |
558 |
3
|
if(CourseServiceConstants.COURSE_NAMESPACE_URI.equals(refObjectTypeURI)){ |
559 |
2
|
return luService.getVersions(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId); |
560 |
|
} |
561 |
1
|
throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
562 |
|
} |
563 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
564 |
2
|
@Override... |
565 |
|
public List<VersionDisplayInfo> getVersionsInDateRange( |
566 |
|
String refObjectTypeURI, String refObjectId, Date from, Date to) |
567 |
|
throws DoesNotExistException, InvalidParameterException, |
568 |
|
MissingParameterException, OperationFailedException, |
569 |
|
PermissionDeniedException { |
570 |
2
|
if(CourseServiceConstants.COURSE_NAMESPACE_URI.equals(refObjectTypeURI)){ |
571 |
1
|
return luService.getVersionsInDateRange(LuServiceConstants.CLU_NAMESPACE_URI, refObjectId, from, to); |
572 |
|
} |
573 |
1
|
throw new InvalidParameterException("Object type: " + refObjectTypeURI + " is not known to this implementation"); |
574 |
|
} |
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
@param |
580 |
|
@param |
581 |
|
@throws |
582 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
583 |
67
|
private void checkForMissingParameter(Object param, String paramName)... |
584 |
|
throws MissingParameterException { |
585 |
67
|
if (param == null) { |
586 |
4
|
throw new MissingParameterException(paramName + " can not be null"); |
587 |
|
} |
588 |
|
} |
589 |
|
|
590 |
|
|
591 |
|
@param |
592 |
|
@param |
593 |
|
@return |
594 |
|
|
595 |
|
@throws |
596 |
|
@throws |
597 |
|
@throws |
598 |
|
@throws |
599 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
600 |
10
|
private RefStatementRelationInfo findStatementReference(String courseId,... |
601 |
|
StatementTreeViewInfo statementTreeViewInfo) |
602 |
|
throws InvalidParameterException, MissingParameterException, |
603 |
|
OperationFailedException, DoesNotExistException { |
604 |
10
|
List<RefStatementRelationInfo> course = statementService.getRefStatementRelationsByRef(CourseAssemblerConstants.COURSE_TYPE, courseId); |
605 |
10
|
if (course != null) { |
606 |
7
|
for (RefStatementRelationInfo refRelation : course) { |
607 |
20
|
if (refRelation.getStatementId().equals(statementTreeViewInfo.getId())) { |
608 |
3
|
return refRelation; |
609 |
|
} |
610 |
|
} |
611 |
|
} |
612 |
7
|
return null; |
613 |
|
} |
614 |
|
} |