From 3a25f22108f9832b526f0990eeeb5bf88b61b0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kleinb=C3=B6lting?= Date: Mon, 4 Mar 2024 10:20:33 +0100 Subject: [PATCH] finetune --- .../webapi/responders/admin/ProjectsResponderADM.scala | 2 +- .../slice/admin/domain/model/RestrictedView.scala | 10 +++++++--- .../slice/admin/domain/service/ProjectADMService.scala | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/webapi/src/main/scala/org/knora/webapi/responders/admin/ProjectsResponderADM.scala b/webapi/src/main/scala/org/knora/webapi/responders/admin/ProjectsResponderADM.scala index 062f407062..7c3f5eb283 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/admin/ProjectsResponderADM.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/admin/ProjectsResponderADM.scala @@ -776,7 +776,7 @@ final case class ProjectsResponderADMLive( ) // create permissions for admins and members of the new group _ <- createPermissionsForAdminsAndMembersOfNewProject(newProjectIRI) - _ <- projectService.setProjectRestrictedView(newProjectADM, RestrictedView.Size.default) + _ <- projectService.setProjectRestrictedView(newProjectADM, RestrictedView.default) } yield ProjectOperationResponseADM(project = newProjectADM.unescape) diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/RestrictedView.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/RestrictedView.scala index f059131f14..2451de0ef4 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/RestrictedView.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/model/RestrictedView.scala @@ -12,12 +12,17 @@ import org.knora.webapi.slice.common.Value.BooleanValue import org.knora.webapi.slice.common.Value.StringValue sealed trait RestrictedView + object RestrictedView { + val default: RestrictedView = Size.default + final case class Watermark private (value: Boolean) extends RestrictedView with BooleanValue object Watermark { - val On = Watermark(true) - val Off = Watermark(false) + + val On: Watermark = Watermark(true) + val Off: Watermark = Watermark(false) + def from(value: Boolean): Watermark = if (value) On else Off } @@ -41,5 +46,4 @@ object RestrictedView { case _ => Left(s"Invalid RestrictedViewSize: $value") } } - } diff --git a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectADMService.scala b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectADMService.scala index 46f22946f9..a98f9aa9c6 100644 --- a/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectADMService.scala +++ b/webapi/src/main/scala/org/knora/webapi/slice/admin/domain/service/ProjectADMService.scala @@ -98,7 +98,7 @@ final case class ProjectADMService( def setProjectRestrictedView(project: KnoraProject, settings: RestrictedView): Task[Unit] = { val newSettings = settings match { - case RestrictedView.Watermark(false) => RestrictedView.Size.default + case RestrictedView.Watermark(false) => RestrictedView.default case s => s } projectRepo.setProjectRestrictedView(project, newSettings)