Skip to content

Commit

Permalink
Merge pull request #1538 from libris/bugfix/delete-referenced-by-bulk…
Browse files Browse the repository at this point in the history
…-job

Bugfix/delete referenced by bulk job
  • Loading branch information
kwahlin authored Dec 12, 2024
2 parents ef3bb17 + cc77e99 commit 7638f76
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2773,8 +2773,7 @@ class PostgreSQLComponent {
def allow = JsonLd.ALLOW_LINK_TO_DELETED + (jsonld?.cascadingDeleteRelations() ?: Collections.EMPTY_SET)
def referencedBy = followDependers(identifier, allow)
if (!referencedBy.isEmpty()) {
def referencedByStr = referencedBy.collect { shortId, path -> "$shortId at $path" }.join(', ')
throw new RuntimeException("Deleting depended upon records is not allowed. Referenced by: $referencedByStr")
throw new RuntimeException("Deleting depended upon records is not allowed.")
}
}

Expand Down
7 changes: 3 additions & 4 deletions whelktool/src/main/resources/bulk-change-scripts/merge.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ selectByIds([deprecateId]) { obsolete ->
}

selectByIds(dependsOnObsolete) { depender ->
if (depender.doc.getThingType() == JOB_TYPE) {
return
}

List<List> modifiedListPaths = []
def modified = DocumentUtil.traverse(depender.graph) { value, path ->
// TODO: What if there are links to a record uri?
if (path && path.last() == ID_KEY && obsoleteThingUris.contains(value)) {
path.dropRight(1).with {
if (it.last() == DEPRECATE_KEY) {
return
}
if (it.last() instanceof Integer) {
modifiedListPaths.add(it.dropRight(1))
}
Expand Down

0 comments on commit 7638f76

Please sign in to comment.