diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/AttributeMapping.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/AttributeMapping.java index 9b6582e8..1be18805 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/AttributeMapping.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/examconfig/impl/AttributeMapping.java @@ -12,7 +12,6 @@ import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; -import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.OrientationRecord; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -20,6 +19,7 @@ import org.slf4j.LoggerFactory; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationAttribute; import ch.ethz.seb.sebserver.gbl.model.sebconfig.Orientation; import ch.ethz.seb.sebserver.gbl.util.Utils; +import org.springframework.core.io.ClassPathResource; public class AttributeMapping { @@ -46,7 +46,6 @@ public class AttributeMapping { Objects.requireNonNull(orientations); this.templateId = templateId; - this.orientationAttributeMapping = Utils.immutableMapOf(orientations .stream() .collect(Collectors.toMap( @@ -74,6 +73,7 @@ public class AttributeMapping { this.orientationAttributeNameMapping = Utils.immutableMapOf(orientations .stream() + .filter(o -> this.attributeIdMapping.containsKey(o.attributeId)) .collect(Collectors.toMap( o -> this.attributeIdMapping.get(o.attributeId).name, Function.identity(), diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/datalayer/checks/DowngradeSEBSettingsCheck.java b/src/main/java/ch/ethz/seb/sebserver/webservice/datalayer/checks/DowngradeSEBSettingsCheck.java index 3abf81b3..6200d0c4 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/datalayer/checks/DowngradeSEBSettingsCheck.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/datalayer/checks/DowngradeSEBSettingsCheck.java @@ -3,7 +3,6 @@ package ch.ethz.seb.sebserver.webservice.datalayer.checks; import javax.sql.DataSource; import java.sql.Connection; import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.util.Arrays; import java.util.List; import java.util.Set; @@ -114,11 +113,19 @@ public class DowngradeSEBSettingsCheck implements DBIntegrityCheck { INIT_LOGGER.error(" ---> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); INIT_LOGGER.error(" ---> !!! Detected a Database version integrity violation, probably due to SEB Server version downgrade."); INIT_LOGGER.error(" ---> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); - INIT_LOGGER.error(" ---> !!!! Please check the following correction and set 'sebserver.init.database.integrity.fix.downgrade'"); - INIT_LOGGER.error(" ---> !!!! to true to apply repair with next startup. Then SEB Server will apply the repair task"); + INIT_LOGGER.error(" ---> !!!! Please check if there was a SEB Server downgrade that causes this or if this is caused by actual development. "); + INIT_LOGGER.error(" ---> !!!! "); + INIT_LOGGER.error(" ---> !!!! If new SEB Settings are added to the default SEB Settings view in actual development, just add the new attributes ids"); + INIT_LOGGER.error(" ---> !!!! To the list in class DowngradeSEBSettingsCheck to fix this issue."); + INIT_LOGGER.error(" ---> !!!! "); + INIT_LOGGER.error(" ---> !!!! If a SEB Server version downgrade is the cause of this issue, please check the following"); + INIT_LOGGER.error(" ---> !!!! correction and set 'sebserver.init.database.integrity.fix.downgrade' to true"); + INIT_LOGGER.error(" ---> !!!! to apply repair with next startup. Then SEB Server will apply the repair task"); INIT_LOGGER.error(" ---> !!!! After successfully repair you can set 'sebserver.init.database.integrity.fix.downgrade' back to false "); + INIT_LOGGER.error(" ---> !!!! "); INIT_LOGGER.error(" ---> !!!! NOTE: Repair will delete the following SEB Settings orientation for Exam Configuration default Views"); INIT_LOGGER.error(" ---> !!!! Exam Configurations built from Configuration Template will stay the same and might have incorrect View Tabs"); + INIT_LOGGER.error(" ---> !!!! "); INIT_LOGGER.error(" ---> !!!! Repair will remove following SEB Settings from default view:\n {}", allNames); INIT_LOGGER.error(" ---> !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); throw new WebserviceInitException("Detected a Database version integrity violation, probably due to SEB Server version downgrade. See logs above");