From e70a209217851e2d1aab5eb0cde2cdbd9c7e0375 Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 16 Jul 2024 14:15:25 +0200 Subject: [PATCH] SEBSERV-560 SEBSERV-563 implementation --- .../dao/ScreenProctoringGroupDAO.java | 2 ++ .../impl/ScreenProctoringGroupDAOImpl.java | 23 ++++++++++++++++++- .../ScreenProctoringServiceImpl.java | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ScreenProctoringGroupDAO.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ScreenProctoringGroupDAO.java index 49f48fb6..faec1af5 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ScreenProctoringGroupDAO.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/ScreenProctoringGroupDAO.java @@ -79,4 +79,6 @@ public interface ScreenProctoringGroupDAO { Result> deleteGroups(Long examId); void updateGroupSize(String groupUUID, Integer activeCount, Integer totalCount); + + void resetAllForExam(Long examId); } diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ScreenProctoringGroupDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ScreenProctoringGroupDAOImpl.java index 4a2e5334..c8cb838f 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ScreenProctoringGroupDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ScreenProctoringGroupDAOImpl.java @@ -243,7 +243,8 @@ public class ScreenProctoringGroupDAOImpl implements ScreenProctoringGroupDAO { try { - UpdateDSL.updateWithMapper( + UpdateDSL + .updateWithMapper( this.screenProctoringGroopRecordMapper::update, ScreenProctoringGroopRecordDynamicSqlSupport.screenProctoringGroopRecord) .set(ScreenProctoringGroopRecordDynamicSqlSupport.size) @@ -259,6 +260,26 @@ public class ScreenProctoringGroupDAOImpl implements ScreenProctoringGroupDAO { } + @Override + @Transactional + public void resetAllForExam(final Long examId) { + try { + + UpdateDSL + .updateWithMapper( + this.screenProctoringGroopRecordMapper::update, + ScreenProctoringGroopRecordDynamicSqlSupport.screenProctoringGroopRecord) + .set(ScreenProctoringGroopRecordDynamicSqlSupport.size) + .equalTo(0) + .where(ScreenProctoringGroopRecordDynamicSqlSupport.examId, isEqualTo(examId)) + .build() + .execute(); + + } catch (final Exception e) { + log.warn("Failed to reset SPS groups size: {}", e.getMessage()); + } + } + private ScreenProctoringGroup toDomainModel(final ScreenProctoringGroopRecord record) { return new ScreenProctoringGroup( record.getId(), diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ScreenProctoringServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ScreenProctoringServiceImpl.java index bd7812cd..33a73d5b 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ScreenProctoringServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/proctoring/ScreenProctoringServiceImpl.java @@ -318,6 +318,7 @@ public class ScreenProctoringServiceImpl implements ScreenProctoringService { if (event.exam.status != Exam.ExamStatus.UP_COMING) { this.screenProctoringAPIBinding.deactivateScreenProctoring(event.exam); + this.screenProctoringGroupDAO.resetAllForExam(event.exam.id); } }