Skip to content

Commit b851fad

Browse files
committed
Fix publication place script
1 parent 6a9c54c commit b851fad

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

whelktool/scripts/analysis/lxl-2483-publication-place.groovy

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
import whelk.Document
22

3+
errors = getReportWriter("errors.txt")
4+
35
prod = ['publication', 'production', 'manufacture']
46

57
selectByCollection('bib') { doc ->
8+
try {
9+
process(doc)
10+
}
11+
catch (Exception e) {
12+
def m = "${doc.doc.shortId} $e"
13+
println(m)
14+
errors.println(m)
15+
}
16+
}
17+
18+
void process(doc) {
619
prod.each { p ->
720
getPathSafe(doc.graph, [1, p], []).each {
8-
def place = asList(getPathSafe(it, ['place', 'label'])).flatten()
21+
def place = asList(getPathSafe(it, ['place', 'label'])).flatten().join(' | ')
922
if (place) {
1023
incrementStats(p, place)
1124
}
1225
}
1326
}
14-
1527
}
1628

1729
Object getPathSafe(item, path, defaultTo = null) {

0 commit comments

Comments
 (0)