From 736a686e2a1dde02e3af822b912f75fd2f88aa7c Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 9 Mar 2021 14:29:24 +0100 Subject: [PATCH] fixed deletion --- .../sebserver/gbl/model/EntityDependency.java | 2 +- .../sebserver/gui/content/ExamDeletePopup.java | 10 ++++++++-- .../dao/impl/ClientConnectionDAOImpl.java | 17 +++++++++++++---- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gbl/model/EntityDependency.java b/src/main/java/ch/ethz/seb/sebserver/gbl/model/EntityDependency.java index 8f727e89..1103a9d7 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gbl/model/EntityDependency.java +++ b/src/main/java/ch/ethz/seb/sebserver/gbl/model/EntityDependency.java @@ -23,7 +23,7 @@ public class EntityDependency implements Comparable { public final EntityKey parent; @JsonProperty(value = ATTR_SELF, required = true) public final EntityKey self; - @JsonProperty(value = ATTR_NAME, required = true) + @JsonProperty(value = ATTR_NAME) public final String name; @JsonProperty(ATTR_DESCRIPTION) public final String description; diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamDeletePopup.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamDeletePopup.java index 49b3341f..a8b37306 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamDeletePopup.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/ExamDeletePopup.java @@ -186,8 +186,14 @@ public class ExamDeletePopup { .withURIVariable(API.PARAM_MODEL_ID, entityKey.modelId) .withQueryParam(API.PARAM_BULK_ACTION_TYPE, BulkActionType.HARD_DELETE.name()); - final Set dependencies = restCallBuilder.call().getOrThrow(); - final List list = dependencies.stream().sorted().collect(Collectors.toList()); + final Set dependencies = restCallBuilder + .call() + .getOrThrow(); + final List list = dependencies + .stream() + .sorted() + .collect(Collectors.toList()); + this.pageService. staticListTableBuilder(list, null) .withEmptyMessage(FORM_REPORT_NONE) .withColumn(new ColumnDefinition<>( diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java index bc208567..bf68d880 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java @@ -553,7 +553,7 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO { .map(rec -> new EntityDependency( institutionKey, new EntityKey(rec.getId(), EntityType.CLIENT_CONNECTION), - rec.getExamUserSessionId(), + getDependencyName(rec), rec.getClientAddress())) .collect(Collectors.toList())); } @@ -573,7 +573,7 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO { .map(rec -> new EntityDependency( lmsSetupKey, new EntityKey(rec.getId(), EntityType.CLIENT_CONNECTION), - rec.getExamUserSessionId(), + getDependencyName(rec), rec.getClientAddress())) .collect(Collectors.toList())); } @@ -593,7 +593,7 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO { .map(rec -> new EntityDependency( userKey, new EntityKey(rec.getId(), EntityType.CLIENT_CONNECTION), - rec.getExamUserSessionId(), + getDependencyName(rec), rec.getClientAddress())) .collect(Collectors.toList())); } @@ -609,9 +609,18 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO { .map(rec -> new EntityDependency( examKey, new EntityKey(rec.getId(), EntityType.CLIENT_CONNECTION), - rec.getExamUserSessionId(), + getDependencyName(rec), rec.getClientAddress())) .collect(Collectors.toList())); } + private String getDependencyName(final ClientConnectionRecord record) { + final String examUserSessionId = record.getExamUserSessionId(); + if (StringUtils.isNotBlank(examUserSessionId)) { + return examUserSessionId; + } + + return record.getConnectionToken(); + } + }