SEBSERV-133 fixed exam template refs

This commit is contained in:
anhefti 2022-05-12 09:19:50 +02:00
parent 38b28838fe
commit d53a4de7a6
2 changed files with 17 additions and 2 deletions

View file

@ -8,6 +8,8 @@
package ch.ethz.seb.sebserver.webservice.servicelayer.dao.impl;
import static ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamTemplateRecordDynamicSqlSupport.configurationTemplateId;
import static ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamTemplateRecordDynamicSqlSupport.examTemplateRecord;
import static org.mybatis.dynamic.sql.SqlBuilder.*;
import java.util.ArrayList;
@ -23,6 +25,7 @@ import org.apache.commons.lang3.StringUtils;
import org.mybatis.dynamic.sql.SqlBuilder;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -45,6 +48,8 @@ import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ConfigurationReco
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ConfigurationRecordMapper;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ConfigurationValueRecordDynamicSqlSupport;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ConfigurationValueRecordMapper;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamTemplateRecordDynamicSqlSupport;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.ExamTemplateRecordMapper;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.InstitutionRecordDynamicSqlSupport;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.OrientationRecordDynamicSqlSupport;
import ch.ethz.seb.sebserver.webservice.datalayer.batis.mapper.OrientationRecordMapper;
@ -67,6 +72,7 @@ public class ConfigurationNodeDAOImpl implements ConfigurationNodeDAO {
private final ConfigurationNodeRecordMapper configurationNodeRecordMapper;
private final ConfigurationValueRecordMapper configurationValueRecordMapper;
private final ConfigurationDAOBatchService configurationDAOBatchService;
private final ExamTemplateRecordMapper examTemplateRecordMapper;
private final ViewRecordMapper viewRecordMapper;
private final OrientationRecordMapper orientationRecordMapper;
@ -76,6 +82,7 @@ public class ConfigurationNodeDAOImpl implements ConfigurationNodeDAO {
final ConfigurationValueRecordMapper configurationValueRecordMapper,
final ConfigurationAttributeRecordMapper configurationAttributeRecordMapper,
final ConfigurationDAOBatchService ConfigurationDAOBatchService,
final ExamTemplateRecordMapper examTemplateRecordMapper,
final ViewRecordMapper viewRecordMapper,
final OrientationRecordMapper orientationRecordMapper) {
@ -83,6 +90,7 @@ public class ConfigurationNodeDAOImpl implements ConfigurationNodeDAO {
this.configurationNodeRecordMapper = configurationNodeRecordMapper;
this.configurationValueRecordMapper = configurationValueRecordMapper;
this.configurationDAOBatchService = ConfigurationDAOBatchService;
this.examTemplateRecordMapper = examTemplateRecordMapper;
this.viewRecordMapper = viewRecordMapper;
this.orientationRecordMapper = orientationRecordMapper;
}
@ -323,6 +331,13 @@ public class ConfigurationNodeDAOImpl implements ConfigurationNodeDAO {
.where(ConfigurationNodeRecordDynamicSqlSupport.templateId, isIn(configurationIds))
.build()
.execute();
// update all examTemplates that uses one of the templates
UpdateDSL.updateWithMapper(this.examTemplateRecordMapper::update, examTemplateRecord)
.set(configurationTemplateId).equalToNull()
.where(ExamTemplateRecordDynamicSqlSupport.configurationTemplateId, isIn(configurationIds))
.build()
.execute();
}
private Result<Collection<EntityDependency>> allIdsOfInstitution(final EntityKey institutionKey) {

View file

@ -817,7 +817,7 @@ sebserver.clientconfig.action.activate=Activate Connection Configuration
sebserver.clientconfig.action.deactivate=Deactivate Connection Configuration
sebserver.clientconfig.action.export=Export Connection Configuration
sebserver.clientconfig.action.delete=Delete Connection Configuration
sebserver.clientconfig.action.delete.confirm=Please note that after deletion of this Connection Configuration, a SEB that loads a former download of this<br/>Connection Configuration will never be able to connect to SEB Server again.
sebserver.clientconfig.action.delete.confirm=Please note that after deletion of this Connection Configuration, a SEB that loads a former download of this configuration,<br/>either from this page or from the exam page as Exam Connection Configuration,<br/>Connection Configuration will never be able to connect to SEB Server again.
sebserver.clientconfig.action.delete.success=Connection Configuration successfully deleted
################################
@ -1676,7 +1676,7 @@ sebserver.configtemplate.attr.action.setdefault=Set Default Values
sebserver.configtemplate.attr.action.template=View Configuration Template
sebserver.configtemplate.action.delete=Delete Configuration Template
sebserver.configtemplate.message.confirm.delete=This will completely delete the configuration template<br/>and reset all exam configuration that uses this template to the default template (no SEB settings change)<br/><br/>Are you sure you want to delete this configuration template?
sebserver.configtemplate.message.confirm.delete=This will completely delete the configuration template<br/>and reset all exam configuration as well as exam templates that uses this template to the default template<br/><br/>Are you sure you want to delete this configuration template?
sebserver.configtemplate.message.delete.confirm=The configuration template ({0}) was successfully deleted.
sebserver.configtemplate.message.delete.partialerror=The configuration template ({0}) was deleted but there where some dependency errors:<br/><br/>{1}