Skip to content

Commit

Permalink
remove redundant KnoraGroupService object
Browse files Browse the repository at this point in the history
  • Loading branch information
mpro7 committed Apr 17, 2024
1 parent 07d2894 commit a83c3f1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import zio.ZLayer
import org.knora.webapi.config.AppConfig
import org.knora.webapi.responders.IriService
import org.knora.webapi.slice.admin.domain.service.GroupService
import org.knora.webapi.slice.admin.domain.service.KnoraGroupService.KnoraGroupService
import org.knora.webapi.slice.admin.domain.service.KnoraGroupService
import org.knora.webapi.slice.admin.domain.service.KnoraProjectService
import org.knora.webapi.slice.admin.domain.service.PasswordService
import org.knora.webapi.slice.admin.domain.service.ProjectService
Expand All @@ -24,10 +24,23 @@ import org.knora.webapi.store.triplestore.api.TriplestoreService
object AdminDomainModule {

type Dependencies =
AppConfig & AdminRepoModule.Provided & CacheService & IriService & OntologyRepo & PredicateObjectMapper & TriplestoreService
AppConfig &
AdminRepoModule.Provided &
CacheService &
IriService &
OntologyRepo &
PredicateObjectMapper &
TriplestoreService

type Provided =
AdministrativePermissionService & GroupService & KnoraGroupService & KnoraProjectService & KnoraUserService & MaintenanceService & PasswordService & ProjectService
AdministrativePermissionService &
GroupService &
KnoraGroupService &
KnoraProjectService &
KnoraUserService &
MaintenanceService &
PasswordService &
ProjectService

val layer = ZLayer.makeSome[Dependencies, Provided](
AdministrativePermissionService.layer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ case class KnoraGroupService(

def updateGroup(groupToUpdate: KnoraGroup, request: GroupUpdateRequest): Task[KnoraGroup] =
for {
_ <- request.name match {
case Some(value) => ensureGroupNameIsUnique(value)
case None => ZIO.unit
}
_ <- ZIO.foreachDiscard(request.name)(ensureGroupNameIsUnique)

updatedGroup <-
knoraGroupRepo.save(
Expand All @@ -73,7 +70,5 @@ case class KnoraGroupService(
}

object KnoraGroupService {
object KnoraGroupService {
val layer = ZLayer.derive[KnoraGroupService]
}
val layer = ZLayer.derive[KnoraGroupService]
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.knora.webapi.responders.IriService
import org.knora.webapi.slice.admin.domain.model.User
import org.knora.webapi.slice.admin.domain.repo.KnoraProjectRepoInMemory
import org.knora.webapi.slice.admin.domain.service.KnoraGroupRepo
import org.knora.webapi.slice.admin.domain.service.KnoraGroupService.KnoraGroupService
import org.knora.webapi.slice.admin.domain.service.KnoraGroupService
import org.knora.webapi.slice.admin.domain.service.KnoraProjectRepo.builtIn.SystemProject
import org.knora.webapi.slice.admin.domain.service.KnoraProjectService
import org.knora.webapi.slice.admin.repo.service.KnoraGroupRepoInMemory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
package org.knora.webapi.slice.admin.domain.service

import zio.Scope
import zio.ZIO
import zio.test.Spec
import zio.test.TestEnvironment
import zio.test.ZIOSpecDefault
import zio.test._

import org.knora.webapi.messages.StringFormatter
import org.knora.webapi.messages.store.triplestoremessages.StringLiteralV2
import org.knora.webapi.responders.IriService
import org.knora.webapi.slice.admin.domain.model.{
Group,
GroupDescriptions,
GroupIri,
GroupName,
GroupSelfJoin,
GroupStatus,
KnoraGroup,
}
import org.knora.webapi.slice.admin.domain.model.Group
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.KnoraGroup
import org.knora.webapi.slice.admin.domain.repo.KnoraProjectRepoInMemory
import org.knora.webapi.slice.admin.repo.service.{KnoraGroupRepoInMemory, KnoraGroupRepoLive}
import org.knora.webapi.slice.ontology.repo.service.{OntologyCacheLive, OntologyRepoLive}
import org.knora.webapi.slice.admin.repo.service.KnoraGroupRepoInMemory
import org.knora.webapi.slice.ontology.repo.service.OntologyCacheLive
import org.knora.webapi.slice.ontology.repo.service.OntologyRepoLive
import org.knora.webapi.slice.resourceinfo.domain.IriConverter
import org.knora.webapi.store.cache.CacheService
import org.knora.webapi.store.triplestore.api.TriplestoreServiceInMemory
import zio.{Scope, ZIO}
import zio.test._
import zio.test.{Spec, TestEnvironment, ZIOSpecDefault}

object GroupServiceSpec extends ZIOSpecDefault {
private val exampleGroup = new Group(
Expand Down Expand Up @@ -60,7 +63,7 @@ object GroupServiceSpec extends ZIOSpecDefault {
IriConverter.layer,
IriService.layer,
KnoraGroupRepoInMemory.layer,
KnoraGroupService.KnoraGroupService.layer,
KnoraGroupService.layer,
KnoraProjectRepoInMemory.layer,
KnoraProjectService.layer,
OntologyCacheLive.layer,
Expand Down

0 comments on commit a83c3f1

Please sign in to comment.