Skip to content

Commit

Permalink
Merge pull request #1280 from libris/feature/lxl-4217
Browse files Browse the repository at this point in the history
Add cleanup script.
  • Loading branch information
jannistsiroyannis authored Aug 14, 2023
2 parents c54af16 + 8a2aed2 commit 3afc377
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 3afc377

Please sign in to comment.