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

[#4591] Add Integrity check for books with edition reported as 1 #4642

Merged
merged 3 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions src/main/java/org/jabref/logic/integrity/EditionChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class EditionChecker implements ValueChecker {
private static final Predicate<String> FIRST_LETTER_CAPITALIZED = Pattern.compile("^[A-Z]").asPredicate();
private static final Predicate<String> ONLY_NUMERALS_OR_LITERALS = Pattern.compile("^([0-9]+|[^0-9].+)$")
.asPredicate();
private static final String FIRST_EDITION = "1";

private final BibDatabaseContext bibDatabaseContextEdition;

Expand All @@ -38,6 +39,10 @@ public Optional<String> checkValue(String value) {
return Optional.empty();
}

if (value.equals(FIRST_EDITION)) {
return Optional.of(Localization.lang("edition of book reported as just 1"));
}

//biblatex
if (bibDatabaseContextEdition.isBiblatexMode() && !ONLY_NUMERALS_OR_LITERALS.test(value.trim())) {
return Optional.of(Localization.lang("should contain an integer or a literal"));
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,7 @@ Sumatra\ Reader=Sumatra Reader
shared=shared
should\ contain\ an\ integer\ or\ a\ literal=should contain an integer or a literal
should\ have\ the\ first\ letter\ capitalized=should have the first letter capitalized
edition\ of\ book\ reported\ as\ just\ 1=edition of book reported as just 1
Tools=Tools
What\'s\ new\ in\ this\ version?=What\'s new in this version?
Want\ to\ help?=Want to help?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ void testEditionChecks() {
withMode(createContext("edition", "Third, revised and expanded edition"), BibDatabaseMode.BIBLATEX));
assertCorrect(withMode(createContext("edition", "Edition 2000"), BibDatabaseMode.BIBLATEX));
assertWrong(withMode(createContext("edition", "2nd"), BibDatabaseMode.BIBLATEX));
assertWrong(createContext("edition", "1"));
}

@Test
Expand Down