Skip to content

Commit

Permalink
Add cleanup script.
Browse files Browse the repository at this point in the history
  • Loading branch information
jannistsiroyannis committed Jun 29, 2023
1 parent 9635c82 commit 8a2aed2
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
String where = "collection = 'bib' and data#>>'{@graph,1,identifiedBy}' like '%talbok_text%'"

selectBySqlWhere(where) { data ->
boolean changed = false
List identifiedBys = asList(data.graph[1].identifiedBy)

changed = identifiedBys.removeAll { it.value == "talbok_text" }

if (changed) {
identifiedBys.each { identifiedBy ->
if (identifiedBy.typeNote == "MTM medienummer") {
if (identifiedBy.qualifier == null) {
identifiedBy.qualifier = ["talbok_text"]
} else if (identifiedBy.typeNote instanceof List) {
identifiedBy.qualifier.add("talbok_text")
}
}
}

//System.err.println("Changed identifiedBy to: " + data.graph[1].identifiedBy)
data.scheduleSave()
}
}

private List asList(Object o) {
if (o == null)
return []
if (o instanceof List)
return o
return [o]
}

0 comments on commit 8a2aed2

Please sign in to comment.