From 32567a220ac2a04b4736b0738d9cbf4f3d4b74ee Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 29 Nov 2023 19:33:24 +0100 Subject: [PATCH] SEBSERV-494 fixed --- .../webservice/servicelayer/dao/ExamDAO.java | 6 ++--- .../servicelayer/dao/impl/ExamRecordDAO.java | 25 +++++++++---------- .../lms/impl/mockup/MockCourseAccessAPI.java | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java index 79a11977..f6a056ae 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ExamDAO.java @@ -169,7 +169,7 @@ public interface ExamDAO extends ActivatableEntityDAO, BulkActionSup /** This checks if there are write locks that are out of date and release such. */ void releaseAgedLocks(); - /** Use this to check if the exam is up to date + /** Use this to check if the exam is up-to-date * * @param exam the exam to check if it is in sync with the persistent or if there is a newer version * @return Result refer to the up-to-date result or to an error if happened */ @@ -178,7 +178,7 @@ public interface ExamDAO extends ActivatableEntityDAO, BulkActionSup /** Marks the specified exam as updated (sets the last modified date to now) * to notify exam content has changed. * This is automatically done also with normal save but not always an entire - * save is needed. In this cases this can be used to notify a exam content change. + * save is needed. In these cases this can be used to notify a exam content change. * * @param examId The exam identifier */ void setModified(Long examId); @@ -212,7 +212,7 @@ public interface ExamDAO extends ActivatableEntityDAO, BulkActionSup /** Marks the given exam by setting the last-update-time to current time. * This provokes a cache update on distributed setup. - * Additionally this flushes the local cache immediately. + * Additionally, this flushes the local cache immediately. * * @param examId the Exam identifier */ @CacheEvict( diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java index b72109f1..b583c779 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ExamRecordDAO.java @@ -8,6 +8,7 @@ package ch.ethz.seb.sebserver.webservice.servicelayer.dao.impl; +import static ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamRecordDynamicSqlSupport.*; import static org.mybatis.dynamic.sql.SqlBuilder.*; import java.util.ArrayList; @@ -25,6 +26,7 @@ import org.mybatis.dynamic.sql.SqlBuilder; import org.mybatis.dynamic.sql.SqlCriterion; import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter; import org.mybatis.dynamic.sql.select.QueryExpressionDSL; +import org.mybatis.dynamic.sql.update.UpdateDSL; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; @@ -314,20 +316,17 @@ public class ExamRecordDAO { throw new IllegalStateException("Exam is currently locked: " + examId); } - final ExamRecord examRecord = new ExamRecord( - examId, - null, null, - quizData.id, - null, null, null, null, null, null, null, null, - updateId, - null, null, - Utils.getMillisecondsNow(), - quizData.getName(), - quizData.getStartTime(), - quizData.getEndTime(), - BooleanUtils.toIntegerObject(true)); + UpdateDSL.updateWithMapper(examRecordMapper::update, examRecord) + .set(externalId).equalTo(quizData.id) + .set(lastupdate).equalTo(updateId) + .set(lastModified).equalTo(Utils.getMillisecondsNow()) + .set(quizName).equalTo(quizData.getName()) + .set(quizStartTime).equalTo(quizData.getStartTime()) + .set(quizEndTime).equalTo(quizData.getEndTime()) + .where(id, isEqualTo(oldRecord::getId)) + .build() + .execute(); - this.examRecordMapper.updateByPrimaryKeySelective(examRecord); return this.examRecordMapper.selectByPrimaryKey(examId); }) .onError(TransactionHandler::rollback); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java index c78a69bd..14e83fd6 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/lms/impl/mockup/MockCourseAccessAPI.java @@ -85,7 +85,7 @@ public class MockCourseAccessAPI implements CourseAccessAPI { "2019-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( "quiz7", institutionId, lmsSetupId, lmsType, "Demo Quiz 7 (MOCKUP)", "

Demo Quiz Mockup

", - "2018-01-01T09:00:00Z", "2025-01-01T09:00:00Z", "http://lms.mockup.com/api/")); + "2018-01-01T09:00:00Z", null, "http://lms.mockup.com/api/")); this.mockups.add(new QuizData( "quiz10", institutionId, lmsSetupId, lmsType, "Demo Quiz 10 (MOCKUP)",