diff --git a/webapi/src/main/resources/knora-ontologies/knora-base.ttl b/webapi/src/main/resources/knora-ontologies/knora-base.ttl index 3b341827d8..910c3492c6 100644 --- a/webapi/src/main/resources/knora-ontologies/knora-base.ttl +++ b/webapi/src/main/resources/knora-ontologies/knora-base.ttl @@ -19,7 +19,7 @@ rdf:type owl:Ontology ; rdfs:label "The Knora base ontology"@en ; :attachedToProject knora-admin:SystemProject ; - :ontologyVersion "knora-base v29" . + :ontologyVersion "knora-base v30" . ################################################################# diff --git a/webapi/src/main/scala/org/knora/webapi/package.scala b/webapi/src/main/scala/org/knora/webapi/package.scala index bad29dc045..3c51e25537 100644 --- a/webapi/src/main/scala/org/knora/webapi/package.scala +++ b/webapi/src/main/scala/org/knora/webapi/package.scala @@ -11,7 +11,7 @@ package object webapi { * The version of `knora-base` and of the other built-in ontologies that this version of Knora requires. * Must be the same as the object of `knora-base:ontologyVersion` in the `knora-base` ontology being used. */ - val KnoraBaseVersion: String = "knora-base v29" + val KnoraBaseVersion: String = "knora-base v30" /** * `IRI` is a synonym for `String`, used to improve code readability. diff --git a/webapi/src/main/scala/org/knora/webapi/store/triplestore/upgrade/RepositoryUpdatePlan.scala b/webapi/src/main/scala/org/knora/webapi/store/triplestore/upgrade/RepositoryUpdatePlan.scala index f9fb9437c8..37994a324f 100644 --- a/webapi/src/main/scala/org/knora/webapi/store/triplestore/upgrade/RepositoryUpdatePlan.scala +++ b/webapi/src/main/scala/org/knora/webapi/store/triplestore/upgrade/RepositoryUpdatePlan.scala @@ -8,6 +8,7 @@ package org.knora.webapi.store.triplestore.upgrade import com.typesafe.scalalogging.Logger import org.knora.webapi.messages.store.triplestoremessages.RdfDataObject +import org.knora.webapi.store.triplestore.upgrade.plugins.UpgradePluginPR3110 import org.knora.webapi.store.triplestore.upgrade.plugins.* /** @@ -64,6 +65,7 @@ object RepositoryUpdatePlan { PluginForKnoraBaseVersion(versionNumber = 27, plugin = new MigrateOnlyBuiltInGraphs), // PR 3026 PluginForKnoraBaseVersion(versionNumber = 28, plugin = new MigrateOnlyBuiltInGraphs), // PR 3038 PluginForKnoraBaseVersion(versionNumber = 29, plugin = new UpgradePluginPR3110()), + PluginForKnoraBaseVersion(versionNumber = 30, plugin = new UpgradePluginPR3111()), // KEEP IT ON THE BOTTOM // From "versionNumber = 6" don't use prBasedVersionString! ) diff --git a/webapi/src/main/scala/org/knora/webapi/store/triplestore/upgrade/plugins/UpgradePluginPR3111.scala b/webapi/src/main/scala/org/knora/webapi/store/triplestore/upgrade/plugins/UpgradePluginPR3111.scala new file mode 100644 index 0000000000..9999e5031f --- /dev/null +++ b/webapi/src/main/scala/org/knora/webapi/store/triplestore/upgrade/plugins/UpgradePluginPR3111.scala @@ -0,0 +1,39 @@ +/* + * Copyright © 2021 - 2024 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. + * SPDX-License-Identifier: Apache-2.0 + */ + +package org.knora.webapi.store.triplestore.upgrade.plugins + +import org.eclipse.rdf4j.sparqlbuilder.core.SparqlBuilder.`var` as variable +import org.eclipse.rdf4j.sparqlbuilder.core.query.ModifyQuery +import org.eclipse.rdf4j.sparqlbuilder.core.query.* +import org.eclipse.rdf4j.sparqlbuilder.rdf.Rdf + +import org.knora.webapi.slice.admin.AdminConstants +import org.knora.webapi.slice.admin.repo.rdf.Vocabulary +import org.knora.webapi.store.triplestore.upgrade.GraphsForMigration +import org.knora.webapi.store.triplestore.upgrade.MigrateSpecificGraphs + +/** + * Certain restricted views have a watermark that is not a boolean. This plugin removes the invalid watermark triples. + */ +class UpgradePluginPR3111 extends AbstractSparqlUpdatePlugin { + + override def graphsForMigration: GraphsForMigration = + MigrateSpecificGraphs.from(AdminConstants.adminDataNamedGraph) + + private val removeInvalidRestrictedViewWatermarkTriples: ModifyQuery = { + val invalidTriple = variable("s").has( + Vocabulary.KnoraAdmin.projectRestrictedViewWatermark, + Rdf.literalOf("path_to_image"), + ) + Queries + .MODIFY() + .prefix(Vocabulary.KnoraAdmin.NS) + .delete(invalidTriple) + .where(invalidTriple.from(Vocabulary.NamedGraphs.knoraAdminIri)) + } + + override def getQueries: List[ModifyQuery] = List(removeInvalidRestrictedViewWatermarkTriples) +}