-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9635c82
commit 8a2aed2
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
whelktool/scripts/cleanups/2023/06/lxl-4217-move-bad-identifiedby.groovy
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,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] | ||
} |