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

Refactor EprintCleanup to handle institution, version, and EID fields #11627

Merged
merged 16 commits into from
Sep 13, 2024

Conversation

18bce133
Copy link
Contributor

@18bce133 18bce133 commented Aug 14, 2024

What

This PR refactors the EprintCleanup class to handle additional fields: INSTITUTION, VERSION, and EID. It also includes new tests to ensure the correct functionality of these changes.

Why

The changes are necessary to improve the handling of e-print entries by including more comprehensive cleanup logic. This ensures that entries with INSTITUTION, VERSION, and EID fields are properly normalized and cleaned up.

Changes

  • Updated EprintCleanup to handle INSTITUTION, VERSION, and EID fields.
  • Added logic to append the version to the EPRINT field if it is not already present.
  • Cleared the VERSION and INSTITUTION fields after processing.
  • Added a new test case in EprintCleanupTest to verify the cleanup of entries with VERSION, INSTITUTION, and EID fields.

Issue
Closes #11306

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Small comment.

Moreover, please add the link to the documentation of the identifier, Tobias provided. That knowledge should be persistet in the code!

Comment on lines +31 to +47
@Test
void cleanupEntryWithVersionAndInstitutionAndEid() {
BibEntry input = new BibEntry()
.withField(StandardField.NOTE, "arXiv: 1503.05173")
.withField(StandardField.VERSION, "1")
.withField(StandardField.INSTITUTION, "arXiv")
.withField(StandardField.EID, "arXiv:1503.05173");

BibEntry expected = new BibEntry()
.withField(StandardField.EPRINT, "1503.05173v1")
.withField(StandardField.EPRINTTYPE, "arxiv");

EprintCleanup cleanup = new EprintCleanup();
cleanup.cleanup(input);

assertEquals(expected, input);
}
Copy link
Member

Choose a reason for hiding this comment

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

Please add another test with INSTITUTION tbd. That field value should be kept IMHO. --> JabRef should not destory data.

Copy link
Contributor Author

@18bce133 18bce133 Aug 21, 2024

Choose a reason for hiding this comment

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

@koppor I have made the suggested changes and pushed it to this PR , please review.

Copy link
Member

Choose a reason for hiding this comment

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

I think, I was not clear with another

This means: A second test case. This means: Keep the original test as is.


I did not also not "unzip" my comment, sorry!

This will require changes in the code. The code needs to check if the institution is arXiv. Then, the field can be cleared. Otherwise, the field needs to be kept.

@koppor koppor marked this pull request as draft August 21, 2024 02:27
@18bce133 18bce133 marked this pull request as ready for review August 21, 2024 02:38
Comment on lines +31 to +47
@Test
void cleanupEntryWithVersionAndInstitutionAndEid() {
BibEntry input = new BibEntry()
.withField(StandardField.NOTE, "arXiv: 1503.05173")
.withField(StandardField.VERSION, "1")
.withField(StandardField.INSTITUTION, "arXiv")
.withField(StandardField.EID, "arXiv:1503.05173");

BibEntry expected = new BibEntry()
.withField(StandardField.EPRINT, "1503.05173v1")
.withField(StandardField.EPRINTTYPE, "arxiv");

EprintCleanup cleanup = new EprintCleanup();
cleanup.cleanup(input);

assertEquals(expected, input);
}
Copy link
Member

Choose a reason for hiding this comment

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

I think, I was not clear with another

This means: A second test case. This means: Keep the original test as is.


I did not also not "unzip" my comment, sorry!

This will require changes in the code. The code needs to check if the institution is arXiv. Then, the field can be cleared. Otherwise, the field needs to be kept.

BibEntry expected = new BibEntry()
.withField(StandardField.EPRINT, "1503.05173v1")
.withField(StandardField.EPRINTTYPE, "arxiv")
.withField(StandardField.INSTITUTION, "tbd");
Copy link
Member

Choose a reason for hiding this comment

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

Lets use other-institution as example for the new test.

Copy link
Contributor Author

@18bce133 18bce133 Sep 7, 2024

Choose a reason for hiding this comment

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

@koppor I have done the necessary changes, updated the EprintCleanup class to clear the institution field if it is "arXiv" else keep it otherInstitution as it is.

@subhramit
Copy link
Collaborator

@18bce133 Hey, how is it going? Are you still working on this PR?
Let us know if you need any help finishing it.

@18bce133
Copy link
Contributor Author

Hey @subhramit ! I'm still on the PR. I've been quite busy lately with some interviews lined up, which slowed me down a bit. I'll make sure to wrap up this PR in the next few days. Thanks for checking in!

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Your code currently does not meet JabRef's code guidelines.
We use OpenRewrite to ensure "modern" Java coding practices.
The issues found can be automatically fixed.
Please execute the gradle task rewriteRun, check the results, commit, and push.

You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite".

koppor
koppor previously approved these changes Sep 13, 2024
@koppor
Copy link
Member

koppor commented Sep 13, 2024

CHANGELOG.md was not modified. I add the entry by myself to get this merged.

koppor
koppor previously approved these changes Sep 13, 2024
@koppor koppor added this pull request to the merge queue Sep 13, 2024
Merged via the queue into JabRef:main with commit f7fde15 Sep 13, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve arxiv parsing
3 participants