Skip to content

Commit

Permalink
Merge branch 'master' into update-elasticsearch-8-13
Browse files Browse the repository at this point in the history
  • Loading branch information
imsdu authored Apr 5, 2024
2 parents d0f6e0d + f9f1498 commit 08146cd
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceLoader
import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.{contexts => bgContexts}
import ch.epfl.bluebrain.nexus.delta.plugins.compositeviews.model.{contexts => compositeViewContexts}
import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.{contexts => esContexts}
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.contexts
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution}
Expand All @@ -22,26 +23,71 @@ object ContextWiring {

def remoteContextResolution: IO[RemoteContextResolution] =
for {
metadataCtx <- ContextValue.fromFile("contexts/metadata.json")
pipelineCtx <- ContextValue.fromFile("contexts/pipeline.json")
shaclCtx <- ContextValue.fromFile("contexts/shacl.json")
schemasMetaCtx <- ContextValue.fromFile("contexts/schemas-metadata.json")
elasticsearchCtx <- ContextValue.fromFile("contexts/elasticsearch.json")
blazegraphCtx <- ContextValue.fromFile("contexts/sparql.json")
compositeCtx <- ContextValue.fromFile("contexts/composite-views.json")
// Delta
bulkOpCtx <- ContextValue.fromFile("contexts/bulk-operation.json")
errorCtx <- ContextValue.fromFile("contexts/error.json")
metadataCtx <- ContextValue.fromFile("contexts/metadata.json")
searchCtx <- ContextValue.fromFile("contexts/search.json")
pipelineCtx <- ContextValue.fromFile("contexts/pipeline.json")
remoteContextsCtx <- ContextValue.fromFile("contexts/remote-contexts.json")
tagsCtx <- ContextValue.fromFile("contexts/tags.json")
versionCtx <- ContextValue.fromFile("contexts/version.json")
validationCtx <- ContextValue.fromFile("contexts/validation.json")
// Project
projectsCtx <- ContextValue.fromFile("contexts/projects.json")
projectsMetaCtx <- ContextValue.fromFile("contexts/projects-metadata.json")
// Resolver
resolversCtx <- ContextValue.fromFile("contexts/resolvers.json")
resolversMetaCtx <- ContextValue.fromFile("contexts/resolvers-metadata.json")
// Schema
shaclCtx <- ContextValue.fromFile("contexts/shacl.json")
schemasMetaCtx <- ContextValue.fromFile("contexts/schemas-metadata.json")
// ElasticSearch
aggregationsCtx <- ContextValue.fromFile("contexts/aggregations.json")
elasticsearchCtx <- ContextValue.fromFile("contexts/elasticsearch.json")
elasticsearchMetaCtx <- ContextValue.fromFile("contexts/elasticsearch-metadata.json")
elasticsearchIdxCtx <- ContextValue.fromFile("contexts/elasticsearch-indexing.json")
offsetCtx <- ContextValue.fromFile("contexts/offset.json")
statisticsCtx <- ContextValue.fromFile("contexts/statistics.json")
// Blazegraph
blazegraphCtx <- ContextValue.fromFile("contexts/sparql.json")
blazegraphMetaCtx <- ContextValue.fromFile("contexts/sparql-metadata.json")
// Composite views
compositeCtx <- ContextValue.fromFile("contexts/composite-views.json")
compositeMetaCtx <- ContextValue.fromFile("contexts/composite-views-metadata.json")
} yield RemoteContextResolution.fixed(
// Delta
contexts.metadata -> metadataCtx,
contexts.pipeline -> pipelineCtx,
contexts.error -> errorCtx,
contexts.metadata -> metadataCtx,
contexts.search -> searchCtx,
contexts.pipeline -> pipelineCtx,
contexts.remoteContexts -> remoteContextsCtx,
contexts.tags -> tagsCtx,
contexts.version -> versionCtx,
contexts.validation -> validationCtx,
contexts.bulkOperation -> bulkOpCtx,
// Project
contexts.projects -> projectsCtx,
contexts.projectsMetadata -> projectsMetaCtx,
// Resolver
contexts.resolvers -> resolversCtx,
contexts.resolversMetadata -> resolversMetaCtx,
// Schema
contexts.shacl -> shaclCtx,
contexts.schemasMetadata -> schemasMetaCtx,
contexts.shacl -> shaclCtx,
contexts.schemasMetadata -> schemasMetaCtx,
// ElasticSearch
esContexts.elasticsearch -> elasticsearchCtx,
esContexts.aggregations -> aggregationsCtx,
esContexts.elasticsearch -> elasticsearchCtx,
esContexts.elasticsearchMetadata -> elasticsearchMetaCtx,
esContexts.elasticsearchIndexing -> elasticsearchIdxCtx,
Vocabulary.contexts.offset -> offsetCtx,
Vocabulary.contexts.statistics -> statisticsCtx,
// Blazegraph
bgContexts.blazegraph -> blazegraphCtx,
bgContexts.blazegraph -> blazegraphCtx,
bgContexts.blazegraphMetadata -> blazegraphMetaCtx,
// Composite views
compositeViewContexts.compositeViews -> compositeCtx
compositeViewContexts.compositeViews -> compositeCtx,
compositeViewContexts.compositeViewsMetadata -> compositeMetaCtx
)

def resolverContextResolution(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import ch.epfl.bluebrain.nexus.delta.kernel.Logger
import ch.epfl.bluebrain.nexus.delta.kernel.utils.UUIDF
import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.BlazegraphViewEvent._
import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.BlazegraphViewRejection.{IncorrectRev, ResourceAlreadyExists}
import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.{BlazegraphViewEvent, BlazegraphViewValue, ViewResource}
import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.model.{defaultViewId, BlazegraphViewEvent, BlazegraphViewValue, ViewResource}
import ch.epfl.bluebrain.nexus.delta.plugins.blazegraph.{BlazegraphViews, ValidateBlazegraphView}
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContext
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.ResolverContextResolution
import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors
Expand Down Expand Up @@ -38,11 +39,20 @@ class BlazegraphViewProcessor private (

private def evaluateInternal(event: BlazegraphViewEvent): IO[ImportStatus] = {
implicit val s: Subject = event.subject
implicit val c: Caller = Caller(s, Set.empty)
val cRev = event.rev - 1
val project = projectMapper.map(event.project)
event match {
case e: BlazegraphViewCreated => views(event.uuid).flatMap(_.create(e.id, project, e.value))
case e: BlazegraphViewUpdated => views(event.uuid).flatMap(_.update(e.id, project, cRev, e.value))
case e: BlazegraphViewCreated =>
e.id match {
case id if id == defaultViewId => views(event.uuid).flatMap(_.create(e.id, project, e.value))
case _ => views(event.uuid).flatMap(_.create(e.id, project, e.source))
}
case e: BlazegraphViewUpdated =>
e.id match {
case id if id == defaultViewId => views(event.uuid).flatMap(_.update(e.id, project, cRev, e.value))
case _ => views(event.uuid).flatMap(_.update(e.id, project, cRev, e.source))
}
case e: BlazegraphViewDeprecated => views(event.uuid).flatMap(_.deprecate(e.id, project, cRev))
case e: BlazegraphViewUndeprecated => views(event.uuid).flatMap(_.undeprecate(e.id, project, cRev))
case _: BlazegraphViewTagAdded => IO.unit // TODO: Can we tag?
Expand Down Expand Up @@ -74,7 +84,7 @@ object BlazegraphViewProcessor {
val noValidation = new ValidateBlazegraphView {
override def apply(value: BlazegraphViewValue): IO[Unit] = IO.unit
}
val prefix = "wrong_prefix" // TODO: fix prefix
val prefix = "nexus" // TODO: use the config?

val views = (uuid: UUID) =>
BlazegraphViews(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import ch.epfl.bluebrain.nexus.delta.kernel.Logger
import ch.epfl.bluebrain.nexus.delta.kernel.utils.{ClasspathResourceLoader, UUIDF}
import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.ElasticSearchViewEvent._
import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.ElasticSearchViewRejection.{IncorrectRev, ResourceAlreadyExists}
import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.{ElasticSearchFiles, ElasticSearchViewEvent, ElasticSearchViewValue}
import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.model.{defaultViewId, ElasticSearchFiles, ElasticSearchViewEvent, ElasticSearchViewValue}
import ch.epfl.bluebrain.nexus.delta.plugins.elasticsearch.{ElasticSearchViews, ValidateElasticSearchView}
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.api.JsonLdApi
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.projects.FetchContext
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.ResolverContextResolution
import ch.epfl.bluebrain.nexus.delta.sdk.views.IndexingRev
Expand Down Expand Up @@ -39,11 +40,20 @@ class ElasticSearchViewProcessor private (

private def evaluateInternal(event: ElasticSearchViewEvent): IO[ImportStatus] = {
implicit val s: Subject = event.subject
implicit val c: Caller = Caller(s, Set.empty)
val cRev = event.rev - 1
val project = projectMapper.map(event.project)
event match {
case e: ElasticSearchViewCreated => views(event.uuid).flatMap(_.create(e.id, project, e.value))
case e: ElasticSearchViewUpdated => views(event.uuid).flatMap(_.update(e.id, project, cRev, e.value))
case e: ElasticSearchViewCreated =>
e.id match {
case id if id == defaultViewId => views(event.uuid).flatMap(_.create(e.id, project, e.value))
case _ => views(event.uuid).flatMap(_.create(e.id, project, e.source))
}
case e: ElasticSearchViewUpdated =>
e.id match {
case id if id == defaultViewId => views(event.uuid).flatMap(_.update(e.id, project, cRev, e.value))
case _ => views(event.uuid).flatMap(_.update(e.id, project, cRev, e.source))
}
case e: ElasticSearchViewDeprecated => views(event.uuid).flatMap(_.deprecate(e.id, project, cRev))
case e: ElasticSearchViewUndeprecated => views(event.uuid).flatMap(_.undeprecate(e.id, project, cRev))
case _: ElasticSearchViewTagAdded => IO.unit // TODO: Check if this is correct
Expand Down Expand Up @@ -78,7 +88,7 @@ object ElasticSearchViewProcessor {
val noValidation = new ValidateElasticSearchView {
override def apply(uuid: UUID, indexingRev: IndexingRev, v: ElasticSearchViewValue): IO[Unit] = IO.unit
}
val prefix = "wrong_prefix" // TODO: fix prefix
val prefix = "nexus" // TODO: use the config?
val esFiles = ElasticSearchFiles.mk(loader)

for {
Expand Down

0 comments on commit 08146cd

Please sign in to comment.