From af8cca8ab26ac31f2cbb9d2f650ee327d5165635 Mon Sep 17 00:00:00 2001 From: anhefti Date: Wed, 28 Oct 2020 17:09:17 +0100 Subject: [PATCH] fixed client config selection only for cc of institution of exam --- .../gui/content/ExamCreateClientConfigPopup.java | 12 +++++++++--- .../ch/ethz/seb/sebserver/gui/content/ExamForm.java | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamCreateClientConfigPopup.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamCreateClientConfigPopup.java index 7625bbe5..45230357 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamCreateClientConfigPopup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamCreateClientConfigPopup.java @@ -24,6 +24,7 @@ import org.springframework.stereotype.Component; import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.model.Domain; +import ch.ethz.seb.sebserver.gbl.model.Entity; import ch.ethz.seb.sebserver.gbl.model.EntityKey; import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigCreationInfo; import ch.ethz.seb.sebserver.gbl.model.sebconfig.SEBClientConfig; @@ -68,7 +69,7 @@ public class ExamCreateClientConfigPopup { this.downloadFileName = downloadFileName; } - public Function exportFunction() { + public Function exportFunction(final Long examInstitutionId) { return action -> { @@ -80,7 +81,8 @@ public class ExamCreateClientConfigPopup { final CreationFormContext creationFormContext = new CreationFormContext( this.pageService, - action.pageContext()); + action.pageContext(), + String.valueOf(examInstitutionId)); final Predicate> doCreate = formHandle -> doCreate( this.pageService, @@ -124,13 +126,16 @@ public class ExamCreateClientConfigPopup { private final PageService pageService; private final PageContext pageContext; + private final String examInstitutionId; protected CreationFormContext( final PageService pageService, - final PageContext pageContext) { + final PageContext pageContext, + final String examInstitutionId) { this.pageService = pageService; this.pageContext = pageContext; + this.examInstitutionId = examInstitutionId; } @Override @@ -138,6 +143,7 @@ public class ExamCreateClientConfigPopup { final List> configs = this.pageService.getRestService().getBuilder(GetClientConfigs.class) .withQueryParam(SEBClientConfig.FILTER_ATTR_ACTIVE, Constants.TRUE_STRING) + .withQueryParam(Entity.FILTER_ATTR_INSTITUTION, this.examInstitutionId) .call() .getOrThrow() .stream() diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java index a0f02401..9f84c6b3 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamForm.java @@ -397,7 +397,7 @@ public class ExamForm implements TemplateComposer { .newAction(ActionDefinition.EXAM_SEB_CLIENT_CONFIG_EXPORT) .withEntityKey(entityKey) - .withExec(this.examCreateClientConfigPopup.exportFunction()) + .withExec(this.examCreateClientConfigPopup.exportFunction(exam.institutionId)) .publishIf(() -> writeGrant && readonly) .newAction(ActionDefinition.EXAM_MODIFY_SEB_RESTRICTION_DETAILS)