/** * @param courseId * @param statementTreeViewInfo * @return reference exists * @throws InvalidParameterException * @throws MissingParameterException * @throws OperationFailedException * @throws DoesNotExistException */ private RefStatementRelationInfo findStatementReference(String courseId, StatementTreeViewInfo statementTreeViewInfo, ContextInfo contextInfo) throws InvalidParameterException, MissingParameterException, OperationFailedException, DoesNotExistException { List<RefStatementRelationInfo> course = R1R2ConverterUtil.convertLists(statementService.getRefStatementRelationsByRef(CourseAssemblerConstants.COURSE_TYPE, courseId), RefStatementRelationInfo.class); if (course != null) { for (RefStatementRelationInfo refRelation : course) { if (refRelation.getStatementId().equals(statementTreeViewInfo.getId())) { return refRelation; } } } return null; }
@Override @Transactional(readOnly = true) public List<StatementTreeViewInfo> getCourseStatements(String courseId, String nlUsageTypeKey, String language, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { checkForMissingParameter(courseId, "courseId"); CluInfo clu = cluService.getClu(courseId, contextInfo); if (!CourseAssemblerConstants.COURSE_TYPE.equals(clu.getTypeKey())) { throw new DoesNotExistException("Specified CLU is not a Course"); } List<RefStatementRelationInfo> relations = R1R2ConverterUtil.convertLists(statementService.getRefStatementRelationsByRef(CourseAssemblerConstants.COURSE_TYPE, clu.getId()), RefStatementRelationInfo.class); if (relations == null) { return new ArrayList<StatementTreeViewInfo>(0); } List<StatementTreeViewInfo> tree = new ArrayList<StatementTreeViewInfo>(relations.size()); for (RefStatementRelationInfo relation : relations) { tree.add(statementService.getStatementTreeView(relation.getStatementId())); } return tree; }
@Transactional(readOnly=false,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) public RefStatementRelationInfo createRefStatementRelation(final RefStatementRelationInfo refStatementRelationInfo) throws AlreadyExistsException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { checkForMissingParameter(refStatementRelationInfo, "refStatementRelationInfo"); Statement statement = this.statementDao.fetch(Statement.class, refStatementRelationInfo.getStatementId()); RefStatementRelationType type = this.statementDao.fetch(RefStatementRelationType.class, refStatementRelationInfo.getType()); // make sure refObjectType exist this.statementDao.fetch(ObjectType.class, refStatementRelationInfo.getRefObjectTypeKey()); RefStatementRelation entity = new RefStatementRelation(); BeanUtils.copyProperties(refStatementRelationInfo, entity, new String[] { "statementId", "attributes", "metaInfo", "type", "id"}); entity.setRefStatementRelationType(type); entity.setStatement(statement); List<RefStatementRelationAttribute> attributes = StatementAssembler.toGenericAttributes(RefStatementRelationAttribute.class, refStatementRelationInfo.getAttributes(), entity, this.statementDao); entity.setAttributes(attributes); RefStatementRelation newEntity = this.statementDao.create(entity); RefStatementRelationInfo newDto = StatementAssembler.toRefStatementRelationInfo(newEntity); return newDto; }
public RefStatementRelation toRefStatementRelation(boolean isUpdate, RefStatementRelationInfo refStatementRelationInfo) throws DoesNotExistException, VersionMismatchException, InvalidParameterException { RefStatementRelation refStatement; if (isUpdate) { refStatement = this.statementDao.fetch(RefStatementRelation.class, refStatementRelationInfo.getId()); if (refStatement == null) { throw new DoesNotExistException("RefStatementRelation does not exist for id: " + refStatementRelationInfo.getId()); } if (!String.valueOf(refStatement.getVersionNumber()).equals(refStatementRelationInfo.getMetaInfo().getVersionInd())) { throw new VersionMismatchException("RefStatementRelation to be updated is not the current version"); } } else { refStatement = new RefStatementRelation(); } BeanUtils.copyProperties(refStatementRelationInfo, refStatement, new String[]{"attributes", "metaInfo", "type", "statementId"}); // make sure refObjectType exist this.statementDao.fetch(ObjectType.class, refStatementRelationInfo.getRefObjectTypeKey()); // Copy generic attributes refStatement.setAttributes(toGenericAttributes(RefStatementRelationAttribute.class, refStatementRelationInfo.getAttributes(), refStatement, this.statementDao)); RefStatementRelationType type = this.statementDao.fetch(RefStatementRelationType.class, refStatementRelationInfo.getType()); refStatement.setRefStatementRelationType(type); Statement statement = this.statementDao.fetch(Statement.class, refStatementRelationInfo.getStatementId()); refStatement.setStatement(statement); return refStatement; }
StatementTreeViewInfo statementTree = new StatementTreeViewInfo(); if (relations != null) { statementTreeViewAssembler.assemble(statementService.getStatementTreeView(relations.get(0).getStatementId()), statementTree, shallowBuild, contextInfo);