From 736a686e2a1dde02e3af822b912f75fd2f88aa7c Mon Sep 17 00:00:00 2001 From: anhefti Date: Tue, 9 Mar 2021 14:29:24 +0100 Subject: [PATCH 1/2] 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(); + } + } From ed9ded57db5046655e98667bf3f30068b39d56ab Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 11 Mar 2021 13:05:24 +0100 Subject: [PATCH 2/2] SEBSERV-176 fixed --- .../sebserver/gui/content/SEBClientEvents.java | 16 +++++++++++----- .../dao/impl/ClientEventDAOImpl.java | 3 +++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientEvents.java b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientEvents.java index a3b1f244..e3aa051c 100644 --- a/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientEvents.java +++ b/src/main/java/ch/ethz/seb/sebserver/gui/content/SEBClientEvents.java @@ -224,9 +224,14 @@ public class SEBClientEvents implements TemplateComposer { .publishIf(() -> writeGrant, table.hasAnyContent()); } - private PageAction getOpenDelete(final PageAction pageAction, final MultiValueMap filterCriteria) { + private PageAction getOpenDelete( + final PageAction pageAction, + final MultiValueMap filterCriteria) { + try { - final List ids = this.restService.getBuilder(GetClientEventNames.class) + + final List ids = this.restService + .getBuilder(GetClientEventNames.class) .withQueryParams(filterCriteria) .call() .getOrThrow() @@ -234,9 +239,10 @@ public class SEBClientEvents implements TemplateComposer { .map(EntityName::getModelId) .collect(Collectors.toList()); - final PageAction deleteAction = pageAction.withAttribute( - PageContext.AttributeKeys.ENTITY_ID_LIST, - StringUtils.join(ids, Constants.COMMA)) + final PageAction deleteAction = pageAction + .withAttribute( + PageContext.AttributeKeys.ENTITY_ID_LIST, + StringUtils.join(ids, Constants.COMMA)) .withAttribute( PageContext.AttributeKeys.ENTITY_LIST_TYPE, EntityType.CLIENT_EVENT.name()); diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientEventDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientEventDAOImpl.java index 7b850519..12c747ed 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientEventDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientEventDAOImpl.java @@ -92,6 +92,9 @@ public class ClientEventDAOImpl implements ClientEventDAO { .and( ClientConnectionRecordDynamicSqlSupport.examId, isEqualToWhenPresent(filterMap.getClientEventExamId())) + .and( + ClientConnectionRecordDynamicSqlSupport.examUserSessionId, + SqlBuilder.isLikeWhenPresent(filterMap.getSQLWildcard(ClientConnection.FILTER_ATTR_SESSION_ID))) .and( ClientEventRecordDynamicSqlSupport.clientConnectionId, isEqualToWhenPresent(filterMap.getClientEventConnectionId()))