-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Entry editor shows both journal and journaltitle in the case of BibLa…
…TeX mode
- Loading branch information
Showing
22 changed files
with
129 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 17 additions & 16 deletions
33
src/main/java/net/sf/jabref/logic/integrity/NoBibtexFieldChecker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
package net.sf.jabref.logic.integrity; | ||
|
||
import java.util.Collections; | ||
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); | ||
|
||
// this exists in BibLaTeX only (and is no aliassed field) | ||
allBibLaTeXOnlyFields.add(FieldName.JOURNALSUBTITLE); | ||
|
||
return entry.getFieldNames().stream() | ||
.filter(name -> allBibLaTeXOnlyFields.contains(name)) | ||
.map(name -> new IntegrityMessage(Localization.lang("BibLaTeX field only"), entry, name)).collect(Collectors.toList()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/net/sf/jabref/logic/integrity/NoBibTexFieldCheckerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.sf.jabref.logic.integrity; | ||
|
||
import java.util.Collections; | ||
|
||
import net.sf.jabref.model.entry.BibEntry; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotEquals; | ||
|
||
|
||
public class NoBibTexFieldCheckerTest { | ||
|
||
private NoBibtexFieldChecker checker = new NoBibtexFieldChecker(); | ||
|
||
@Test | ||
public void addressIsNotRecognizedAsBibLaTeXOnlyField() { | ||
BibEntry entry = new BibEntry(); | ||
entry.setField("address", "test"); | ||
assertEquals(Collections.emptyList(), checker.check(entry)); | ||
} | ||
|
||
@Test | ||
public void journalIsNotRecognizedAsBibLaTeXOnlyField() { | ||
BibEntry entry = new BibEntry(); | ||
entry.setField("journal", "test"); | ||
assertEquals(Collections.emptyList(), checker.check(entry)); | ||
} | ||
|
||
@Test | ||
public void journaltitleIsRecognizedAsBibLaTeXOnlyField() { | ||
BibEntry entry = new BibEntry(); | ||
entry.setField("journaltitle", "test"); | ||
assertNotEquals(Collections.emptyList(), checker.check(entry)); | ||
} | ||
|
||
@Test | ||
public void locationIsRecognizedAsBibLaTeXOnlyField() { | ||
BibEntry entry = new BibEntry(); | ||
entry.setField("location", "test"); | ||
assertNotEquals(Collections.emptyList(), checker.check(entry)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest5.bib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/resources/net/sf/jabref/logic/importer/fileformat/MsBibImporterTest6.bib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.