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

Fix clear year and month field when converting to biblatex #6434

Merged
merged 25 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
788f395
ISSUE :: 6224 - allow merging of year and date if identical
catarinagomespt May 6, 2020
05518d2
fix comment
catarinagomespt May 6, 2020
e1cfa25
Merge branch 'master' of github.com:JabRef/jabref into fix-for-issue-…
catarinagomespt May 7, 2020
93de4bc
Updated Changelog.md file with fixed issue
catarinagomespt May 7, 2020
29ae438
Fix changelog.md file
catarinagomespt May 7, 2020
559e749
Check If date field is filled and is equal to year it should be remov…
catarinagomespt May 8, 2020
c4a4b15
Added unit test: Cleanup With Date Already Present And Equals To Year…
catarinagomespt May 8, 2020
e810e1e
ISSUE :: 6224 - Removed Unused import - java.util.Optional
catarinagomespt May 8, 2020
8750df7
ISSUE :: 6224 - Separated org.jabref.model.FieldChange from previous …
catarinagomespt May 8, 2020
433e800
Merge branch 'master' of github.com:JabRef/jabref into fix-for-issue-…
catarinagomespt May 8, 2020
bf16459
remove checkstyle warning
catarinagomespt May 8, 2020
0eb5906
Change variable newYear name
catarinagomespt May 8, 2020
1628f21
Merge branch 'master' of github.com:JabRef/jabref into fix-for-issue-…
catarinagomespt May 9, 2020
5b1c852
Update Changelog.md
catarinagomespt May 9, 2020
05c86c2
ISSUE :: 6224 - Added month validation and tests
catarinagomespt May 10, 2020
fb75aa5
ISSUE :: 6224 - For inconsistent data: Do not overwrite/move
catarinagomespt May 12, 2020
3541c2f
ISSUE :: 6224 - Fix Test
catarinagomespt May 12, 2020
23b9878
Merge branch 'master' of github.com:JabRef/jabref into fix-for-issue-…
catarinagomespt May 12, 2020
935f656
ISSUE :: 6224 - Added month checking Test
catarinagomespt May 12, 2020
c2b1950
ISSUE :: 6224 - Fix Test
catarinagomespt May 12, 2020
5604f3c
ISSUE :: 6224 - Change Date.parse
catarinagomespt May 13, 2020
28e9c6d
ISSUE :: 6224 - Update Date class
catarinagomespt May 13, 2020
3c0d2a4
ISSUE :: 6224 - Fix Date
catarinagomespt May 13, 2020
3b910f6
ISSUE :: 6224 - Added new test
catarinagomespt May 13, 2020
440db88
Merge branch 'master' of github.com:JabRef/jabref into fix-for-issue-…
catarinagomespt May 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the Preferences entry preview will be unexpected modified leads to Value too long exception [#6198](https://github.com/JabRef/jabref/issues/6198)
- We fixed an issue where custom jstyles for Open/LibreOffice would only be valid if a layout line for the entry type `default` was at the end of the layout section [#6303](https://github.com/JabRef/jabref/issues/6303)
- We fixed an issue where sort on numeric cases was broken. [#6349](https://github.com/JabRef/jabref/issues/6349)

- We fixed an issue where year and month fields were not cleared when converting to biblatex [#6224](https://github.com/JabRef/jabref/issues/6224)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,18 @@ public List<FieldChange> cleanup(BibEntry entry) {
entry.clearField(StandardField.YEAR).ifPresent(changes::add);
entry.clearField(StandardField.MONTH).ifPresent(changes::add);
});
} else {
// If date field is filled and is equal to year it should be removed the year and month fields
entry.getFieldOrAlias(StandardField.DATE).ifPresent(date -> {
entry.getFieldOrAlias(StandardField.YEAR).ifPresent(checkYear -> {
// Get the year of the date field (4 digits).
if (date.substring(0, 4).equals(checkYear)) {
catarinagomespt marked this conversation as resolved.
Show resolved Hide resolved
entry.clearField(StandardField.YEAR).ifPresent(changes::add);
entry.clearField(StandardField.MONTH).ifPresent(changes::add);
}
});
});
}
return changes;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void cleanupMovesYearMonthToDate() {
}

@Test
public void cleanupWithDateAlreadyPresentDoesNothing() {
public void cleanupWithDateAlreadyPresentAndDifferentFromYearDoesNothing() {
BibEntry entry = new BibEntry();
entry.setField(StandardField.YEAR, "2011");
entry.setField(StandardField.MONTH, "#jan#");
Expand All @@ -46,6 +46,20 @@ public void cleanupWithDateAlreadyPresentDoesNothing() {
assertEquals(Optional.of("2012"), entry.getField(StandardField.DATE));
}

@Test
public void cleanupWithDateAlreadyPresentAndEqualsToYearRemovesYearAndMonth() {
BibEntry entry = new BibEntry();
entry.setField(StandardField.YEAR, "2011");
entry.setField(StandardField.MONTH, "#jan#");
entry.setField(StandardField.DATE, "2011");

worker.cleanup(entry);

assertEquals(Optional.empty(), entry.getField(StandardField.YEAR));
assertEquals(Optional.empty(), entry.getField(StandardField.MONTH));
assertEquals(Optional.of("2011"), entry.getField(StandardField.DATE));
catarinagomespt marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
public void cleanupMovesJournalToJournaltitle() {
BibEntry entry = new BibEntry().withField(StandardField.JOURNAL, "Best of JabRef");
Expand Down