Skip to content

Commit

Permalink
Fix publication place script
Browse files Browse the repository at this point in the history
  • Loading branch information
olovy committed Oct 27, 2021
1 parent 6a9c54c commit b851fad
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions whelktool/scripts/analysis/lxl-2483-publication-place.groovy
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
import whelk.Document

errors = getReportWriter("errors.txt")

prod = ['publication', 'production', 'manufacture']

selectByCollection('bib') { doc ->
try {
process(doc)
}
catch (Exception e) {
def m = "${doc.doc.shortId} $e"
println(m)
errors.println(m)
}
}

void process(doc) {
prod.each { p ->
getPathSafe(doc.graph, [1, p], []).each {
def place = asList(getPathSafe(it, ['place', 'label'])).flatten()
def place = asList(getPathSafe(it, ['place', 'label'])).flatten().join(' | ')
if (place) {
incrementStats(p, place)
}
}
}

}

Object getPathSafe(item, path, defaultTo = null) {
Expand Down

0 comments on commit b851fad

Please sign in to comment.