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