starting collect all room impl
This commit is contained in:
parent
f7d80ed4da
commit
b3f83877f2
5 changed files with 50 additions and 3 deletions
|
@ -34,6 +34,7 @@ public class ProctoringSettings implements Entity {
|
||||||
public static final String ATTR_APP_KEY = "appKey";
|
public static final String ATTR_APP_KEY = "appKey";
|
||||||
public static final String ATTR_APP_SECRET = "appSecret";
|
public static final String ATTR_APP_SECRET = "appSecret";
|
||||||
public static final String ATTR_COLLECTING_ROOM_SIZE = "collectingRoomSize";
|
public static final String ATTR_COLLECTING_ROOM_SIZE = "collectingRoomSize";
|
||||||
|
public static final String ATTR_COLLECT_ALL_ROOM_NAME = "collectAllRoomName";
|
||||||
|
|
||||||
@JsonProperty(Domain.EXAM.ATTR_ID)
|
@JsonProperty(Domain.EXAM.ATTR_ID)
|
||||||
public final Long examId;
|
public final Long examId;
|
||||||
|
|
|
@ -62,9 +62,10 @@ public interface AdditionalAttributesDAO {
|
||||||
|
|
||||||
/** Use this to delete an additional attribute by its entity identifier and name.
|
/** Use this to delete an additional attribute by its entity identifier and name.
|
||||||
*
|
*
|
||||||
|
* @param type the entity type
|
||||||
* @param entityId the entity identifier (primary-key)
|
* @param entityId the entity identifier (primary-key)
|
||||||
* @param name the name of the additional attribute */
|
* @param name the name of the additional attribute */
|
||||||
void delete(Long entityId, String name);
|
void delete(EntityType type, Long entityId, String name);
|
||||||
|
|
||||||
/** Use this to delete all additional attributes for a given entity.
|
/** Use this to delete all additional attributes for a given entity.
|
||||||
*
|
*
|
||||||
|
|
|
@ -145,10 +145,13 @@ public class AdditionalAttributesDAOImpl implements AdditionalAttributesDAO {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delete(final Long entityId, final String name) {
|
public void delete(final EntityType type, final Long entityId, final String name) {
|
||||||
this.additionalAttributeRecordMapper
|
this.additionalAttributeRecordMapper
|
||||||
.deleteByExample()
|
.deleteByExample()
|
||||||
.where(
|
.where(
|
||||||
|
AdditionalAttributeRecordDynamicSqlSupport.entityType,
|
||||||
|
SqlBuilder.isEqualTo(type.name()))
|
||||||
|
.and(
|
||||||
AdditionalAttributeRecordDynamicSqlSupport.entityId,
|
AdditionalAttributeRecordDynamicSqlSupport.entityId,
|
||||||
SqlBuilder.isEqualTo(entityId))
|
SqlBuilder.isEqualTo(entityId))
|
||||||
.and(
|
.and(
|
||||||
|
|
|
@ -44,4 +44,8 @@ public interface ExamProcotringRoomService {
|
||||||
* name of an exam. */
|
* name of an exam. */
|
||||||
void updateProctoringRooms();
|
void updateProctoringRooms();
|
||||||
|
|
||||||
|
Result<String> createCollectAllRoom(Long examId);
|
||||||
|
|
||||||
|
void disposeCollectAllRoom(Long examId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.ProctoringSettings;
|
import ch.ethz.seb.sebserver.gbl.model.exam.ProctoringSettings;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.ProctoringSettings.ProctoringServerType;
|
import ch.ethz.seb.sebserver.gbl.model.exam.ProctoringSettings.ProctoringServerType;
|
||||||
import ch.ethz.seb.sebserver.gbl.model.exam.SEBProctoringConnectionData;
|
import ch.ethz.seb.sebserver.gbl.model.exam.SEBProctoringConnectionData;
|
||||||
|
@ -40,6 +41,7 @@ import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientConnectionR
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientConnectionRecordMapper;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ClientConnectionRecordMapper;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.RemoteProctoringRoomRecordDynamicSqlSupport;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.RemoteProctoringRoomRecordDynamicSqlSupport;
|
||||||
import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ClientConnectionRecord;
|
import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.ClientConnectionRecord;
|
||||||
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.AdditionalAttributesDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.RemoteProctoringRoomDAO;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.RemoteProctoringRoomDAO;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.impl.ClientConnectionDAOImpl;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.impl.ClientConnectionDAOImpl;
|
||||||
import ch.ethz.seb.sebserver.webservice.servicelayer.exam.ExamAdminService;
|
import ch.ethz.seb.sebserver.webservice.servicelayer.exam.ExamAdminService;
|
||||||
|
@ -53,24 +55,29 @@ public class ExamProcotringRoomServiceImpl implements ExamProcotringRoomService
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(ExamProcotringRoomServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(ExamProcotringRoomServiceImpl.class);
|
||||||
|
|
||||||
|
private final static String ACTIVE_COLLECTING_ALL_ROOM_ATTRIBUTE_NAME = "ACTIVE_COLLECTING_ALL_ROOM";
|
||||||
|
|
||||||
private final RemoteProctoringRoomDAO remoteProctoringRoomDAO;
|
private final RemoteProctoringRoomDAO remoteProctoringRoomDAO;
|
||||||
private final ClientConnectionRecordMapper clientConnectionRecordMapper;
|
private final ClientConnectionRecordMapper clientConnectionRecordMapper;
|
||||||
private final SEBInstructionService sebInstructionService;
|
private final SEBInstructionService sebInstructionService;
|
||||||
private final ExamAdminService examAdminService;
|
private final ExamAdminService examAdminService;
|
||||||
private final ExamSessionCacheService examSessionCacheService;
|
private final ExamSessionCacheService examSessionCacheService;
|
||||||
|
private final AdditionalAttributesDAO additionalAttributesDAO;
|
||||||
|
|
||||||
public ExamProcotringRoomServiceImpl(
|
public ExamProcotringRoomServiceImpl(
|
||||||
final RemoteProctoringRoomDAO remoteProctoringRoomDAO,
|
final RemoteProctoringRoomDAO remoteProctoringRoomDAO,
|
||||||
final ClientConnectionRecordMapper clientConnectionRecordMapper,
|
final ClientConnectionRecordMapper clientConnectionRecordMapper,
|
||||||
final SEBInstructionService sebInstructionService,
|
final SEBInstructionService sebInstructionService,
|
||||||
final ExamAdminService examAdminService,
|
final ExamAdminService examAdminService,
|
||||||
final ExamSessionCacheService examSessionCacheService) {
|
final ExamSessionCacheService examSessionCacheService,
|
||||||
|
final AdditionalAttributesDAO additionalAttributesDAO) {
|
||||||
|
|
||||||
this.remoteProctoringRoomDAO = remoteProctoringRoomDAO;
|
this.remoteProctoringRoomDAO = remoteProctoringRoomDAO;
|
||||||
this.clientConnectionRecordMapper = clientConnectionRecordMapper;
|
this.clientConnectionRecordMapper = clientConnectionRecordMapper;
|
||||||
this.sebInstructionService = sebInstructionService;
|
this.sebInstructionService = sebInstructionService;
|
||||||
this.examAdminService = examAdminService;
|
this.examAdminService = examAdminService;
|
||||||
this.examSessionCacheService = examSessionCacheService;
|
this.examSessionCacheService = examSessionCacheService;
|
||||||
|
this.additionalAttributesDAO = additionalAttributesDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -127,6 +134,37 @@ public class ExamProcotringRoomServiceImpl implements ExamProcotringRoomService
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Result<String> createCollectAllRoom(final Long examId) {
|
||||||
|
final String newCollectingRoomName = UUID.randomUUID().toString();
|
||||||
|
return this.additionalAttributesDAO
|
||||||
|
.saveAdditionalAttribute(
|
||||||
|
EntityType.EXAM,
|
||||||
|
examId,
|
||||||
|
ACTIVE_COLLECTING_ALL_ROOM_ATTRIBUTE_NAME,
|
||||||
|
newCollectingRoomName)
|
||||||
|
.map(attr -> attr.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void disposeCollectAllRoom(final Long examId) {
|
||||||
|
this.additionalAttributesDAO.delete(
|
||||||
|
EntityType.EXAM,
|
||||||
|
examId,
|
||||||
|
ACTIVE_COLLECTING_ALL_ROOM_ATTRIBUTE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Result<String> getActiveCollectingAllRoom(final Long examId) {
|
||||||
|
return this.additionalAttributesDAO
|
||||||
|
.getAdditionalAttribute(
|
||||||
|
EntityType.EXAM,
|
||||||
|
examId,
|
||||||
|
ACTIVE_COLLECTING_ALL_ROOM_ATTRIBUTE_NAME)
|
||||||
|
.map(attr -> attr.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
// TODO considering doing bulk update here
|
// TODO considering doing bulk update here
|
||||||
private Collection<ClientConnectionRecord> flagUpdated(final Collection<ClientConnectionRecord> toUpdate) {
|
private Collection<ClientConnectionRecord> flagUpdated(final Collection<ClientConnectionRecord> toUpdate) {
|
||||||
return toUpdate.stream().map(cc -> {
|
return toUpdate.stream().map(cc -> {
|
||||||
|
|
Loading…
Reference in a new issue