Skip to content

Commit

Permalink
Merge branch 'master' into add-kamon-span-shacl-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
imsdu authored Apr 5, 2024
2 parents 1aa2be1 + 81efb8e commit 6583385
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ElasticSearchContainer(password: String)
}

object ElasticSearchContainer {
private val Version = "8.12.1"
private val Version = "8.13.0"

val ElasticSearchUser = "elastic"
val ElasticSearchPassword = "password"
Expand Down
4 changes: 2 additions & 2 deletions docs/src/main/paradox/docs/delta/api/assets/version.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"dependencies": {
"blazegraph": "2.1.6-RC",
"postgresql": "15.6",
"elasticsearch": "8.12.1",
"remoteStorage": "1.9.0"
"elasticsearch": "8.13.0",
"remoteStorage": "1.10.0"
},
"plugins": {
"archive": "1.10.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
memory: 1024M

elasticsearch:
image: "docker.elastic.co/elasticsearch/elasticsearch:8.12.1"
image: "docker.elastic.co/elasticsearch/elasticsearch:8.13.0"
environment:
discovery.type: "single-node"
bootstrap.memory_lock: "true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ $ curl http://localhost/v1/version | jq
"delta": "1.10.0",
"dependencies": {
"blazegraph": "2.1.6-SNAPSHOT",
"elasticsearch": "8.12.1",
"elasticsearch": "8.13.0",
"postgres": "15.6"
},
"environment": "dev",
Expand Down
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
2 changes: 1 addition & 1 deletion tests/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ services:
- 9090:8080

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.12.1
image: docker.elastic.co/elasticsearch/elasticsearch:8.13.0
environment:
ES_JAVA_OPTS: "-Xmx2G"
discovery.type: "single-node"
Expand Down

0 comments on commit 6583385

Please sign in to comment.