Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LGC-39 Udix remove print #836

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
3 changes: 3 additions & 0 deletions whelktool/scripts/syslib/2021/01/Udix_ID2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
37ftj0m8013f94l
djrzr21k4kqfkk1
v06lbxc13vtklgf
22 changes: 22 additions & 0 deletions whelktool/scripts/syslib/2021/01/Udix_remove_print.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
PrintWriter failedUpdating = getReportWriter("failed-updating")
PrintWriter scheduledForUpdating = getReportWriter("scheduled-updates")
Comment on lines +1 to +2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK created/modified/deleted are now default reports, created automatically, so these shouldn't be necessary. (Which means scheduledForUpdating and failedUpdating below can also be removed.)


File HoldIDs = new File(scriptDir, "Udix_ID2.txt")

List propertiesToCheck = ["associatedMedia", "marc:hasTextualHoldingsBasicBibliographicUnit"]

selectByIds( HoldIDs.readLines() ) { hold ->
def holds = hold.graph[1]
Comment on lines +8 to +9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: the use of hold (an individual hold) vs holds (here a part of that individual hold) is slightly confusing. Maybe "holds" => "item" would be better. (Doesn't matter for a one-off script, but for the future 😄).


propertiesToCheck.each { prop ->
holds[prop].removeIf { it["marc:publicNote"].contains("Externt magasin / Closed stacks") }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If holds doesn't have prop, or it doesn't have "marc:publicNote", you'll get a NullPointerException, so being a bit more defensive might be in order. E.g.,
holds[prop]?.removeIf { it["marc:publicNote"]?.contains("Externt magasin / Closed stacks") || false }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!


}

scheduledForUpdating.println("${hold.doc.getURI()}")
hold.scheduleSave(loud: true, onError: { e ->
failedUpdating.println("Failed to update ${hold.doc.shortId} due to: $e")

})

}