Skip to content

Commit

Permalink
Refine NoBibtexFieldChecker to treat more biblatex-only fields
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Dec 11, 2016
1 parent 74a3931 commit 217764a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We changed the order of the cleanup operations so that the generated file name corresponds to the cleaned-up fields. [1441](https://github.com/JabRef/jabref/issues/1441)
- Replaces manual thread management with cached thread pool
- We replaced the field name `journaltitle` by `journal` in BibLaTeX-mode as `journaltitle` was causing headaches [#2209](https://github.com/JabRef/jabref/issues/2209)
- We enhanced the integrity checks testing for biblatex-only fields to be aware of more fields (e.g., `location`).
- Files can now be moved to subfolders named by a custom format pattern, e.g., based on `entrytype`.
The pattern can be specified in the settings like the filename pattern. [#1092](https://github.com/JabRef/jabref/issues/1092)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
package net.sf.jabref.logic.integrity;

import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.stream.Collectors;

import net.sf.jabref.logic.integrity.IntegrityCheck.Checker;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.EntryConverter;
import net.sf.jabref.model.entry.FieldName;

public class NoBibtexFieldChecker implements Checker {

/**
* BibLaTeX package documentation (Section 2.1.1):
* The title of the periodical is given in the journaltitle field.
*/
@Override
public List<IntegrityMessage> check(BibEntry entry) {
Optional<String> value = entry.getField(FieldName.JOURNALTITLE);

//BibTeX
if (!value.isPresent()) {
return Collections.emptyList();
}
else {
return Collections.singletonList(
new IntegrityMessage(Localization.lang("BibLaTeX field only"), entry, FieldName.JOURNALTITLE));
}
SortedSet<String> allBibLaTeXOnlyFields = new TreeSet<>();
allBibLaTeXOnlyFields.addAll(EntryConverter.FIELD_ALIASES_LTX_TO_TEX.keySet());

// file is both in bibtex and biblatex
allBibLaTeXOnlyFields.remove(FieldName.FILE);

// these two are in BibLaTeX only
allBibLaTeXOnlyFields.add(FieldName.JOURNALTITLE);
allBibLaTeXOnlyFields.add(FieldName.JOURNALSUBTITLE);

List<IntegrityMessage> res = new ArrayList<>();
return entry.getFieldNames().stream()
.filter(name -> allBibLaTeXOnlyFields.contains(name))
.map(name -> new IntegrityMessage(Localization.lang("BibLaTeX field only"), entry, name)).collect(Collectors.toList());
}

}

0 comments on commit 217764a

Please sign in to comment.