Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: KnoraUserGroup and KnoraUserGroupRepo (DEV-3288) #3059

Merged
merged 8 commits into from
Mar 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package org.knora.webapi.responders.admin
import java.util.UUID

import dsp.errors.*
import dsp.valueobjects.Group.*
import dsp.valueobjects.V2
import org.knora.webapi.*
import org.knora.webapi.messages.admin.responder.groupsmessages.*
Expand All @@ -19,7 +18,11 @@ import org.knora.webapi.sharedtestdata.SharedTestDataADM.*
import org.knora.webapi.slice.admin.api.GroupsRequests.GroupCreateRequest
import org.knora.webapi.slice.admin.api.GroupsRequests.GroupStatusUpdateRequest
import org.knora.webapi.slice.admin.api.GroupsRequests.GroupUpdateRequest
import org.knora.webapi.slice.admin.domain.model.GroupDescriptions
import org.knora.webapi.slice.admin.domain.model.GroupIri
import org.knora.webapi.slice.admin.domain.model.GroupName
import org.knora.webapi.slice.admin.domain.model.GroupSelfJoin
import org.knora.webapi.slice.admin.domain.model.GroupStatus
import org.knora.webapi.slice.admin.domain.model.KnoraProject.ProjectIri
import org.knora.webapi.util.MutableTestIri
import org.knora.webapi.util.ZioScalaTestUtil.assertFailsWithA
Expand Down Expand Up @@ -71,7 +74,7 @@ class GroupsResponderADMSpec extends CoreSpec {
),
project = ProjectIri.unsafeFrom(imagesProjectIri),
status = GroupStatus.active,
selfjoin = GroupSelfJoin.impossible
selfjoin = GroupSelfJoin.disabled
),
UUID.randomUUID
)
Expand Down Expand Up @@ -101,7 +104,7 @@ class GroupsResponderADMSpec extends CoreSpec {
.unsafeFrom(Seq(V2.StringLiteralV2(value = "NewGroupDescription", language = Some("en")))),
project = ProjectIri.unsafeFrom(imagesProjectIri),
status = GroupStatus.active,
selfjoin = GroupSelfJoin.impossible
selfjoin = GroupSelfJoin.disabled
),
UUID.randomUUID
)
Expand All @@ -124,7 +127,7 @@ class GroupsResponderADMSpec extends CoreSpec {
)
),
status = Some(GroupStatus.active),
selfjoin = Some(GroupSelfJoin.impossible)
selfjoin = Some(GroupSelfJoin.disabled)
),
UUID.randomUUID
)
Expand All @@ -151,7 +154,7 @@ class GroupsResponderADMSpec extends CoreSpec {
.unsafeFrom(Seq(V2.StringLiteralV2(value = "UpdatedDescription", language = Some("en"))))
),
status = Some(GroupStatus.active),
selfjoin = Some(GroupSelfJoin.impossible)
selfjoin = Some(GroupSelfJoin.disabled)
),
UUID.randomUUID
)
Expand All @@ -174,7 +177,7 @@ class GroupsResponderADMSpec extends CoreSpec {
.unsafeFrom(Seq(V2.StringLiteralV2(value = "UpdatedDescription", language = Some("en"))))
),
status = Some(GroupStatus.active),
selfjoin = Some(GroupSelfJoin.impossible)
selfjoin = Some(GroupSelfJoin.disabled)
),
UUID.randomUUID
)
Expand Down
68 changes: 0 additions & 68 deletions webapi/src/main/scala/dsp/valueobjects/Group.scala

This file was deleted.

8 changes: 7 additions & 1 deletion webapi/src/main/scala/dsp/valueobjects/V2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package dsp.valueobjects

import org.eclipse.rdf4j.sparqlbuilder.rdf.Rdf
import org.eclipse.rdf4j.sparqlbuilder.rdf.RdfLiteral.StringLiteral
import zio.json.*

object V2 {
Expand All @@ -15,7 +17,11 @@ object V2 {
* @param value the string value.
* @param language the language iso.
*/
case class StringLiteralV2(value: String, language: Option[String])
case class StringLiteralV2(value: String, language: Option[String]) {
def toRdfLiteral: StringLiteral =
language.map(Rdf.literalOfLanguage(value, _)).getOrElse(Rdf.literalOf(value))
}

object StringLiteralV2 {
implicit val codec: JsonCodec[StringLiteralV2] = DeriveJsonCodec.gen[StringLiteralV2]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ object OntologyConstants {
val IsInGroup: IRI = KnoraAdminPrefixExpansion + "isInGroup"
val IsInSystemAdminGroup: IRI = KnoraAdminPrefixExpansion + "isInSystemAdminGroup"

/* Status used for User and Project*/
/* Status used for User, Group and Project */
val StatusProp: IRI = KnoraAdminPrefixExpansion + "status"

/* Project */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import zio.macros.accessible
import java.util.UUID

import dsp.errors.*
import dsp.valueobjects.Group.GroupStatus
import org.knora.webapi.*
import org.knora.webapi.core.MessageHandler
import org.knora.webapi.core.MessageRelay
Expand Down Expand Up @@ -40,6 +39,7 @@ import org.knora.webapi.slice.admin.api.GroupsRequests.GroupCreateRequest
import org.knora.webapi.slice.admin.api.GroupsRequests.GroupStatusUpdateRequest
import org.knora.webapi.slice.admin.api.GroupsRequests.GroupUpdateRequest
import org.knora.webapi.slice.admin.domain.model.GroupIri
import org.knora.webapi.slice.admin.domain.model.GroupStatus
import org.knora.webapi.slice.admin.domain.model.KnoraProject.Shortcode
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.slice.admin.domain.model.UserIri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,15 @@ import sttp.tapir.Codec
import sttp.tapir.CodecFormat
import zio.json.JsonCodec

import dsp.valueobjects.Group.GroupDescriptions
import dsp.valueobjects.Group.GroupName
import dsp.valueobjects.Group.GroupSelfJoin
import dsp.valueobjects.Group.GroupStatus
import dsp.valueobjects.V2
import org.knora.webapi.slice.admin.api.model.MaintenanceRequests.AssetId
import org.knora.webapi.slice.admin.domain.model.Email
import org.knora.webapi.slice.admin.domain.model.FamilyName
import org.knora.webapi.slice.admin.domain.model.GivenName
import org.knora.webapi.slice.admin.domain.model.GroupIri
import org.knora.webapi.slice.admin.domain.model.KnoraProject.*
import org.knora.webapi.slice.admin.domain.model.ListProperties.Comments
import org.knora.webapi.slice.admin.domain.model.ListProperties.Labels
import org.knora.webapi.slice.admin.domain.model.ListProperties.ListIri
import org.knora.webapi.slice.admin.domain.model.ListProperties.ListName
import org.knora.webapi.slice.admin.domain.model.ListProperties.Position
import org.knora.webapi.slice.admin.domain.model.Password
import org.knora.webapi.slice.admin.domain.model.RestrictedViewSize
import org.knora.webapi.slice.admin.domain.model.SystemAdmin
import org.knora.webapi.slice.admin.domain.model.UserIri
import org.knora.webapi.slice.admin.domain.model.UserStatus
import org.knora.webapi.slice.admin.domain.model.Username
import org.knora.webapi.slice.admin.domain.model.*
siers marked this conversation as resolved.
Show resolved Hide resolved
import org.knora.webapi.slice.common.Value.BooleanValue
import org.knora.webapi.slice.common.Value.IntValue
import org.knora.webapi.slice.common.Value.StringValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ import zio.*
import zio.json.DeriveJsonCodec
import zio.json.JsonCodec

import dsp.valueobjects.Group.GroupDescriptions
import dsp.valueobjects.Group.GroupName
import dsp.valueobjects.Group.GroupSelfJoin
import dsp.valueobjects.Group.GroupStatus
import org.knora.webapi.messages.admin.responder.groupsmessages.*
import org.knora.webapi.messages.admin.responder.usersmessages.GroupMembersGetResponseADM
import org.knora.webapi.messages.admin.responder.usersmessages.UsersADMJsonProtocol.*
import org.knora.webapi.slice.admin.api.AdminPathVariables.groupIriPathVar
import org.knora.webapi.slice.admin.api.GroupsRequests.GroupCreateRequest
import org.knora.webapi.slice.admin.api.GroupsRequests.GroupStatusUpdateRequest
import org.knora.webapi.slice.admin.api.GroupsRequests.GroupUpdateRequest
import org.knora.webapi.slice.admin.domain.model.GroupDescriptions
import org.knora.webapi.slice.admin.domain.model.GroupIri
import org.knora.webapi.slice.admin.domain.model.GroupName
import org.knora.webapi.slice.admin.domain.model.GroupSelfJoin
import org.knora.webapi.slice.admin.domain.model.GroupStatus
import org.knora.webapi.slice.admin.domain.model.KnoraProject.ProjectIri
import org.knora.webapi.slice.common.api.BaseEndpoints

Expand Down

This file was deleted.

Loading
Loading