-
Notifications
You must be signed in to change notification settings - Fork 501
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
Fix 7874-Dataset-template-authors-ordering #8228
Fix 7874-Dataset-template-authors-ordering #8228
Conversation
@@ -183,6 +184,10 @@ public String save(String redirectPage) { | |||
Long createdId = new Long(0); | |||
Template created; | |||
try { | |||
Iterator<DatasetField> dsfItSort = template.getDatasetFields().iterator(); |
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.
This looks like a fix, but - wouldn't the other checking in tidyUpFields also make sense before saving the template? If so, perhaps there's also an opportunity to refactor - make tidyUpFields() take dsv.getDatasetFields / template.getDatasetFields as the parameter (perhaps moving that method to a util class).
Also - seeing that the current tidyUpFields is called from other Commands - should the tidying here also be done in the template commands (on principle/to help if there's a future template API where order also needs to be defined)?
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.
Hi @qqmyers,
Yes, my first idea was to run the tidyUpFields() method, however, tidyUpFields also removes all empty fields and this creates another error when editing a template,
If you save an author without affiliation or identifier, when you try to edit it, these fields are no longer displayed. What do you think?
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, but that doesn't happen in dataset metadata. Probably some other method getting called to compensate in datasets. While it would be nice to have templates and datasets work the same, I don't know that its worthwhile to ask you to go investigating when what you've put in the PR is a fix for the issue. Unless somebody else has info or has a reason that not adding the empty field removal and trailing space removal that happens in tidyUpFields() is going to a big deal, I'd say it's OK as is - perhaps just adding a note in the code about this issue/difference with datasets.
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.
So the method that makes sure tou don't have missing fields when editing a dataset is DatasetVersionUI (it also looks like it might handle the orderingsinc it has a sort:
private List initDatasetFields(boolean createBlanks) {
it is private because it's called by:
public DatasetVersionUI initDatasetVersionUI(DatasetVersion datasetVersion, boolean createBlanks) {
which does more than the template would need.
But to avoid technical debt, we'd probably want to rely on trying to use these (possibly needing to be centralized) methods and tidyUpFields.
Hey @alejandratenorio! Thanks for the PR, I hope you are well. @scolapasta and @qqmyers have provided some feedback. Please take a look when you have a chance. I'll assign this to myself and keep this in the review column for now so that we don't lose track of this. |
Hi @djbrooke , |
Thanks @alejandratenorio, please let us know if you have any questions! |
Hi all, I was checking the initDatasetVersionUI and initDatasetFields methods, it would be complicated to use them because they are linked to the datasetVersion, we would have to rebuild a lot of methods. Do you think we should try it? |
Hi @alejandratenorio - I'll move this over to the review column so we can provide some guidance. |
I'm not sure how to connect things to the initDatasetFields method, but here's a ~concrete proposal:
The net affect of that is just having your code also run the trimTrailingSpaces on the template fields (probably good), and a small amount of code consolidation. Whether this is worth doing, or if there's a better option, I'll leave to @scolapasta. (Separate issue: when I was looking at DatasetVersionUI, it seemed to me that dataverse/src/main/java/edu/harvard/iq/dataverse/DatasetVersionUI.java Lines 374 to 395 in 80a42de
|
I think a similar approach as above could be done for initDatasetFields, ie. it could be removed it a DatasetFieldUtil taking in a list of Datasetfields (and some other parameters: a list of metadatablocks and an object (either the version or the template)). That said, I'm also fine with an incremental improvement as the one @qqmyers suggested since it's a step on this direction. If you're willing to try more and also refactor initDatasetFields (so you wouldn't need the extra boolean for blanks, that's fine too. @qqmyers I agree about the extra sort, so maybe that's a small bonus cleanup that can be done when this is worked on. |
Hi guys, Thanks for clarifying the way, we are fine with an incremental improvement, two stages. This way we'll be working with tidyUpFields, then we do the PR and fix the problem in our installation. Later, we continue with initDatasetFields. |
Hi @qqmyers, Happy new year! Returning to this issue, tidyUpFields method is protected, CuratePublishedDatasetVersionCommand, UpdateDatasetVersionCommand and CreateDatasetVersionCommand can use it because this classes extends from AbstractDatasetCommand. So, I have a problem with TemplatePage class, this class can´t see it. |
@alejandratenorio - Happy New Year to you too! I was suggesting that rather than leave the method in AbstractDatasetCommand, create a new DatasetFieldUtil class (e.g. in edu.harvard.iq.dataverse.util) with just this one new public static method. I think that's a little clearer than leaving it in the abstract command class and having non-commands call it. (It could go in some other util class if you see an appropriate one.) |
ec149df
to
1b67084
Compare
Hi @qqmyers |
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 good overall to me. I had one suggested change unless there's a reason it was done as it is.
@alejandratenorio Hi, our db schema has changed slightly due to a column being dropped in a recent PR. Please refresh this branch from develop so that I can deploy and test this. I have read this pr closely so I can begin testing right away once it is done. Thanks! |
What this PR does / why we need it: When saving a template, the order of authors is lost. This PR fixes that error.
Which issue(s) this PR closes: #7874
Closes #7874
Special notes for your reviewer:
Suggestions on how to test this:
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Is there a release notes update needed for this change?:
Additional documentation: