-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: develop
Are you sure you want to change the base?
LGC-39 Udix remove print #836
Conversation
Merge from original repo
Just ignore the commits history, I didn't realise a bunch of old/irrelevant changes stuff was left there. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't there be more records in Udix_ID2.txt? Also, those three records are already deleted. Maybe it's the wrong file?
It was a tmp file, just to test the script. I wasn't sure if it was needed for a code review. But it is now updated with the correct IDs. |
Added correct IDs
Looks good then! Maybe you should check also if the property is left empty after removing the "Externt magasin" object, and if that's the case, remove the property from graph[1]. If you think there are cases where associatedMedia/marc:hasTextualHoldingsBasicBibliographicUnit contains only one ("Externt magasin") object? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, just a couple of minor things you might want to look at. Also be mindful of indentation (makes it easier to read / spot problems). And +1 on what Kalle wrote :)
PrintWriter failedUpdating = getReportWriter("failed-updating") | ||
PrintWriter scheduledForUpdating = getReportWriter("scheduled-updates") |
There was a problem hiding this comment.
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.)
def holds = hold.graph[1] | ||
|
||
propertiesToCheck.each { prop -> | ||
holds[prop].removeIf { it["marc:publicNote"].contains("Externt magasin / Closed stacks") } |
There was a problem hiding this comment.
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 }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
selectByIds( HoldIDs.readLines() ) { hold -> | ||
def holds = hold.graph[1] |
There was a problem hiding this comment.
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 😄).
In general this is probably a very good idea, but the case here is that if there is only one object in associatedMedia/marc:hasTextualHoldingsBasicBibliographicUnit ("Externt magasin") the entire holdings record should be removed. That will be done separately (i.e. registervårdsklienten). |
I see! That was the point with writing a script right... |
No description provided.