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