From 6822d16090fd6456f6ab68e1f6f1ac519f8c7f3a Mon Sep 17 00:00:00 2001 From: Balduin Landolt <33053745+BalduinLandolt@users.noreply.github.com> Date: Tue, 9 Jul 2024 09:50:12 +0200 Subject: [PATCH] refactor: Small refactoring (#3311) --- .../responders/v2/ResourcesResponderV2.scala | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/webapi/src/main/scala/org/knora/webapi/responders/v2/ResourcesResponderV2.scala b/webapi/src/main/scala/org/knora/webapi/responders/v2/ResourcesResponderV2.scala index a91d15eb2e..001e41bf1a 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/v2/ResourcesResponderV2.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/v2/ResourcesResponderV2.scala @@ -634,30 +634,20 @@ final case class ResourcesResponderV2( } // Check if resources are deleted, if so, replace them with DeletedResource - responseWithDeletedResourcesReplaced = apiResponse.resources match { - case resourceList => - if (resourceList.nonEmpty) { - val resourceListWithDeletedResourcesReplaced = resourceList.map { - resource => - resource.deletionInfo match { - // Resource deleted -> return DeletedResource instead - case Some(_) => resource.asDeletedResource() - // Resource not deleted -> return resource - case None => - // deleted values should be shown -> resource can be returned - if (showDeletedValues) resource - // deleted Values should not be shown -> replace them with generic DeletedValue - else resource.withDeletedValues() - } - } - apiResponse.copy(resources = - resourceListWithDeletedResourcesReplaced, - ) - } else { - apiResponse - } - } - + deletedResourcesReplaced = + apiResponse.resources.map { case resource => + resource.deletionInfo match { + // Resource deleted -> return DeletedResource instead + case Some(_) => resource.asDeletedResource() + // Resource not deleted -> return resource + case None => + // deleted values should be shown -> resource can be returned + if (showDeletedValues) resource + // deleted Values should not be shown -> replace them with generic DeletedValue + else resource.withDeletedValues() + } + } + responseWithDeletedResourcesReplaced = apiResponse.copy(resources = deletedResourcesReplaced) } yield responseWithDeletedResourcesReplaced }