Skip to content

Commit

Permalink
Merge pull request #4642 from RonakLakhotia/edition-checker
Browse files Browse the repository at this point in the history
[#4591] Add Integrity check for books with edition reported as 1
  • Loading branch information
koppor committed Feb 13, 2019
2 parents 80192eb + b858a2c commit 4844541
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
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 @@ -1944,6 +1944,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 @@ -84,6 +84,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

0 comments on commit 4844541

Please sign in to comment.