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