-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an enpoint to get the number of ntriples per composite view (#5195)
Co-authored-by: Simon Dumas <[email protected]>
- Loading branch information
Showing
13 changed files
with
347 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...epfl/bluebrain/nexus/delta/plugins/compositeviews/routes/CompositeSupervisionRoutes.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.routes | ||
|
||
import akka.http.scaladsl.server.Route | ||
import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.client.BlazegraphClient | ||
import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.supervision.BlazegraphSupervision | ||
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.CompositeViews | ||
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.supervision.CompositeViewsByNamespace | ||
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution | ||
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering | ||
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck | ||
import ch.epfl.bluebrain.nexus.delta.sdk.acls.model.AclAddress | ||
import ch.epfl.bluebrain.nexus.delta.sdk.directives.AuthDirectives | ||
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives.emit | ||
import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities | ||
import ch.epfl.bluebrain.nexus.delta.sdk.marshalling.RdfMarshalling | ||
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.Permissions.supervision | ||
import io.circe.syntax.EncoderOps | ||
|
||
class CompositeSupervisionRoutes( | ||
blazegraphSupervision: BlazegraphSupervision, | ||
identities: Identities, | ||
aclCheck: AclCheck | ||
)(implicit cr: RemoteContextResolution, ordering: JsonKeyOrdering) | ||
extends AuthDirectives(identities, aclCheck) | ||
with RdfMarshalling { | ||
|
||
def routes: Route = | ||
pathPrefix("supervision") { | ||
extractCaller { implicit caller => | ||
authorizeFor(AclAddress.Root, supervision.read).apply { | ||
(pathPrefix("composite-views") & get & pathEndOrSingleSlash) { | ||
emit(blazegraphSupervision.get.map(_.asJson)) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
object CompositeSupervisionRoutes { | ||
def apply( | ||
views: CompositeViews, | ||
client: BlazegraphClient, | ||
identities: Identities, | ||
aclCheck: AclCheck, | ||
prefix: String | ||
)(implicit cr: RemoteContextResolution, ordering: JsonKeyOrdering): CompositeSupervisionRoutes = { | ||
val viewsByNameSpace = CompositeViewsByNamespace(views, prefix) | ||
val compositeSupervision = BlazegraphSupervision(client, viewsByNameSpace) | ||
new CompositeSupervisionRoutes(compositeSupervision, identities, aclCheck) | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
.../bluebrain/nexus/delta/plugins/compositeviews/supervision/CompositeViewsByNamespace.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.supervision | ||
|
||
import cats.effect.IO | ||
import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.supervision.ViewByNamespace | ||
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.CompositeViews | ||
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.indexing.{commonNamespace, CompositeViewDef} | ||
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.indexing.CompositeViewDef.ActiveViewDef | ||
import ch.epfl.bluebrain.nexus.delta.sdk.views.ViewRef | ||
import fs2.Stream | ||
|
||
/** | ||
* Allows to get a mapping for the active composite view and their common namespace | ||
*/ | ||
object CompositeViewsByNamespace { | ||
|
||
def apply(compositeViews: CompositeViews, prefix: String): ViewByNamespace = | ||
apply(compositeViews.currentViews.map(_.value), prefix) | ||
|
||
def apply(stream: Stream[IO, CompositeViewDef], prefix: String): ViewByNamespace = new ViewByNamespace { | ||
override def get: IO[Map[String, ViewRef]] = stream | ||
.fold(Map.empty[String, ViewRef]) { | ||
case (acc, view: ActiveViewDef) => | ||
val namespace = commonNamespace(view.uuid, view.indexingRev, prefix) | ||
acc + (namespace -> view.ref) | ||
case (acc, _) => acc | ||
} | ||
.compile | ||
.last | ||
.map(_.getOrElse(Map.empty)) | ||
} | ||
} |
Oops, something went wrong.