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