-
Notifications
You must be signed in to change notification settings - Fork 541
blocked deposit page, hide host field when only one collection (e.g. root) #11301
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
Changes from 5 commits
0ba0814
e2a6757
56177ba
95860a6
1ebe7f2
34cef44
e587510
ed92750
69b854d
a9ca7bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| ### Reduced chance of losing metadata on Edit Dataset Metadata page | ||
|
|
||
| The remedy for the problem consists of two parts: | ||
| * Do not show the _host dataverse_ field when there is nothing to choose. This mimics the behaviour for templates. | ||
| * When you accidentally start typing in the _host dataverse_ field, undo the change with backspace, fill in the other metadata fields and save the draft, the page used to get blocked due to an exception. Reloading the page would erase all your input. The exception is remedied by looking for the root dataverse. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,9 @@ public class DataverseConverter implements Converter { | |
|
|
||
| @Override | ||
| public Object getAsObject(FacesContext facesContext, UIComponent component, String submittedValue) { | ||
| return dataverseService.find(new Long(submittedValue)); | ||
| var pk = (submittedValue == null || submittedValue.isEmpty() || submittedValue.matches(".*[^0-9].*")) | ||
| ? 0 : Long.valueOf(submittedValue); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW - the root dataverse does not always have id=0
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FWIW: There is a findRoot call that could be used instead.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jo-pol can you please switch this to |
||
| return dataverseService.find(pk); | ||
| //return dataverseService.findByAlias(submittedValue); | ||
| } | ||
|
|
||
|
|
||
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.
The method
isHasDataversesToChoose()callsdataverseService.findAll().size()every time it's invoked, which could be expensive if there are many dataverses. Consider caching this value or using a more efficient query to count dataverses.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.
DataverseServiceBean.getDataverseCount() exists and could be used here. - countDataverses() doesn't exist.
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.
@qqmyers mised these comment so far. Got another suggestion form copilot, perhaps more elaborate to implement but might be more effiecient
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.
Hmm - with maxResults set to one, you'd never know if there was more than one (thanks Copilot!), but I guess it could be limited to 2 instead.
That said, I think they key thing is to avoid getting a list of objects - that's a big expense.
From a quick test, getting two rows is cheaper than getting the count, but both are orders of magnitude less than getting the objects.
I guess since limiting to 2 rows will scale better than getting the count, I guess this approach makes more sense if you're willing to implement it.
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.
Just logged the duration on a VM with almost 100K dataverses
findall: PT15.632S
getDataverseCount: PT-0.026S
Looks good enough with less effort.