-
Notifications
You must be signed in to change notification settings - Fork 535
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 all 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 (caused by an invalid argument) is remedied returning the currently selected value. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,20 +13,29 @@ | |||||||||||||||
| import jakarta.faces.convert.Converter; | ||||||||||||||||
| import jakarta.faces.convert.FacesConverter; | ||||||||||||||||
|
|
||||||||||||||||
| import java.util.logging.Logger; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * | ||||||||||||||||
| * @author skraffmiller | ||||||||||||||||
| */ | ||||||||||||||||
| @FacesConverter("dataverseConverter") | ||||||||||||||||
| public class DataverseConverter implements Converter { | ||||||||||||||||
| private static final Logger logger = Logger.getLogger(DatasetPage.class.getCanonicalName()); | ||||||||||||||||
|
||||||||||||||||
| private static final Logger logger = Logger.getLogger(DatasetPage.class.getCanonicalName()); | |
| private static final Logger logger = Logger.getLogger(DataverseConverter.class.getCanonicalName()); |
Copilot
AI
Jul 30, 2025
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.
Using Long.valueOf() can throw NumberFormatException even though the regex check should prevent this. However, the regex [0-9]+ doesn't account for potential overflow of Long values. Consider using Long.parseLong() with proper exception handling or add bounds checking.
| return dataverseService.find(Long.valueOf(submittedValue)); | |
| try { | |
| return dataverseService.find(Long.parseLong(submittedValue)); | |
| } catch (NumberFormatException e) { | |
| logger.severe("Submitted value is out of range for a Long: " + submittedValue); | |
| return null; | |
| } |
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.