diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigList.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigList.java index e02d4ad1..984bc580 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigList.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/configs/SEBExamConfigList.java @@ -57,6 +57,8 @@ public class SEBExamConfigList implements TemplateComposer { new LocTextKey("sebserver.examconfig.list.column.description"); private static final LocTextKey STATUS_TEXT_KEY = new LocTextKey("sebserver.examconfig.list.column.status"); + private static final LocTextKey TEMPLATE_TEXT_KEY = + new LocTextKey("sebserver.examconfig.list.column.template"); private static final LocTextKey EMPTY_SELECTION_TEXT_KEY = new LocTextKey("sebserver.examconfig.info.pleaseSelect"); @@ -66,6 +68,7 @@ public class SEBExamConfigList implements TemplateComposer { private final TableFilterAttribute descFilter = new TableFilterAttribute(CriteriaType.TEXT, ConfigurationNode.FILTER_ATTR_DESCRIPTION); private final TableFilterAttribute statusFilter; + private final TableFilterAttribute templateFilter; private final PageService pageService; private final SEBExamConfigImportPopup sebExamConfigImportPopup; @@ -102,6 +105,11 @@ public class SEBExamConfigList implements TemplateComposer { CriteriaType.SINGLE_SELECTION, ConfigurationNode.FILTER_ATTR_STATUS, this.resourceService::examConfigStatusFilterResources); + + this.templateFilter = new TableFilterAttribute( + CriteriaType.SINGLE_SELECTION, + ConfigurationNode.FILTER_ATTR_TEMPLATE_ID, + this.resourceService::getExamConfigTemplateResourcesSelection); } @Override @@ -153,6 +161,13 @@ public class SEBExamConfigList implements TemplateComposer { this.resourceService::localizedExamConfigStatusName) .withFilter(this.statusFilter) .sortable()) + + .withColumn(new ColumnDefinition<>( + Domain.CONFIGURATION_NODE.ATTR_TEMPLATE_ID, + TEMPLATE_TEXT_KEY, + this.resourceService.examConfigTemplateNameFunction()) + .withFilter(this.templateFilter)) + .withDefaultAction(pageActionBuilder .newAction(ActionDefinition.SEB_EXAM_CONFIG_VIEW_PROP_FROM_LIST) .create()) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java b/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java index a085c914..ee703f4c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/service/ResourceService.java @@ -725,6 +725,14 @@ public class ResourceService { } public List> getExamConfigTemplateResources() { + return getExamConfigTemplateResourcesSelection(true); + } + + public List> getExamConfigTemplateResourcesSelection() { + return getExamConfigTemplateResourcesSelection(false); + } + + public List> getExamConfigTemplateResourcesSelection(final boolean withEmpty) { final UserInfo userInfo = this.currentUser.get(); final List> collect = this.restService.getBuilder(GetExamConfigNodes.class) .withQueryParam(Entity.FILTER_ATTR_INSTITUTION, String.valueOf(userInfo.getInstitutionId())) @@ -735,10 +743,27 @@ public class ResourceService { .map(node -> new Tuple<>(node.getModelId(), node.name)) .sorted(RESOURCE_COMPARATOR) .collect(Collectors.toList()); - collect.add(0, new Tuple<>(null, StringUtils.EMPTY)); + if (withEmpty) { + collect.add(0, new Tuple<>(null, StringUtils.EMPTY)); + } return collect; } + public final Function examConfigTemplateNameFunction() { + final List> examTemplateResources = getExamConfigTemplateResourcesSelection(); + return node -> { + if (node.templateId == null) { + return Constants.EMPTY_NOTE; + } + return examTemplateResources + .stream() + .filter(tuple -> node.templateId.toString().equals(tuple._1)) + .map(tuple -> tuple._2) + .findAny() + .orElse(Constants.EMPTY_NOTE); + }; + } + public List> sebRestrictionWhiteListResources() { return Arrays.stream(WhiteListPath.values()) .map(type -> new Tuple3<>( diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationServiceImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationServiceImpl.java index fab53546..7d780dd0 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationServiceImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/PaginationServiceImpl.java @@ -315,6 +315,10 @@ public class PaginationServiceImpl implements PaginationService { configurationNodeTableMap.put( Domain.CONFIGURATION_NODE.ATTR_STATUS, ConfigurationNodeRecordDynamicSqlSupport.status.name()); + configurationNodeTableMap.put( + Domain.CONFIGURATION_NODE.ATTR_TEMPLATE_ID, + ConfigurationNodeRecordDynamicSqlSupport.templateId.name()); + this.sortColumnMapping.put( ConfigurationNodeRecordDynamicSqlSupport.configurationNodeRecord.name(), configurationNodeTableMap); diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index d33e13ee..de96347f 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -807,6 +807,8 @@ sebserver.examconfig.list.column.description=Description sebserver.examconfig.list.column.description.tooltip=The description of the SEB exam configuration

Use the filter above to find configurations that contain specific words or phrases within the description.
{0} sebserver.examconfig.list.column.status=Status sebserver.examconfig.list.column.status.tooltip=The status of the SEB exam configuration

Use the filter above to specify a status
{0} +sebserver.examconfig.list.column.template=Template +sebserver.examconfig.list.column.template.tooltip=The origin template of the SEB exam configuration

Use the filter above to specify a template
{0} sebserver.examconfig.list.actions= @@ -861,7 +863,7 @@ sebserver.examconfig.message.confirm.delete=This will completely delete the exam sebserver.examconfig.message.consistency.error=The exam configuration cannot be deleted since it is used by at least one running or upcoming exam.
Please remove the exam configuration from running and upcoming exams first. sebserver.examconfig.message.delete.confirm=The exam configuration ({0}) was successfully deleted. sebserver.examconfig.message.delete.partialerror=The exam configuration ({0}) was deleted but there where some dependency errors:

{1} -sebserver.examconfig.action.restore.template.settings=Restore Template Settings +sebserver.examconfig.action.restore.template.settings=Reset To Template Settings sebserver.examconfig.action.restore.template.settings.success=Configuration settings successfully restored to template defaults sebserver.examconfig.action.restore.template.settings.confirm=Are you sure to reset this configuration setting to the templates settings?