-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add database migration which removes invalid triples from the da…
…tabase
- Loading branch information
Showing
4 changed files
with
44 additions
and
2 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
39 changes: 39 additions & 0 deletions
39
...c/main/scala/org/knora/webapi/store/triplestore/upgrade/plugins/UpgradePluginPR3116.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,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 UpgradePluginPR3116 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) | ||
} |