Skip to content

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

Merged
koppor merged 16 commits into
JabRef:mainfrom
18bce133:fix-11306
Sep 13, 2024
Merged

Refactor EprintCleanup to handle institution, version, and EID fields#11627
koppor merged 16 commits into
JabRef:mainfrom
18bce133:fix-11306

Conversation

@18bce133

@18bce133 18bce133 commented Aug 14, 2024

Copy link
Copy Markdown
Contributor

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.

@koppor koppor left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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.

@18bce133 18bce133 Aug 21, 2024

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@18bce133 18bce133 Sep 7, 2024

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Member

@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
Copy Markdown
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!

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

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".

@18bce133 18bce133 requested a review from koppor September 7, 2024 22:49
@subhramit subhramit requested a review from Siedlerchr September 9, 2024 16:59
koppor
koppor previously approved these changes Sep 13, 2024
@koppor

koppor commented Sep 13, 2024

Copy link
Copy Markdown
Member

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 enabled auto-merge September 13, 2024 12:34
@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
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