Skip to content

Commit

Permalink
bugfix/5045: Modified the logic to comply crossref resolution with
Browse files Browse the repository at this point in the history
biblatex spec
  • Loading branch information
CyraxSector committed Aug 9, 2019
1 parent 16caddf commit e2f389f
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/main/java/org/jabref/model/entry/BibEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableMap;

import org.jabref.logic.importer.fetcher.CrossRef;
import org.jabref.logic.importer.fileformat.bibtexml.Inproceedings;
import org.jabref.model.FieldChange;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.entry.event.EntryEventSource;
Expand Down Expand Up @@ -133,18 +135,25 @@ public Optional<String> getResolvedFieldOrAlias(Field field, BibDatabase databas
return getCiteKeyOptional();
}

Optional<String> result = Optional.empty();
// If the entry has a crossref, try to look up the field in the
// referred entry: Do not do this for the bibtex key.
if (database != null) {
Optional<String> result = getFieldOrAlias(field);
// If this field is not set, and the entry has a crossref, try to look up the
// field in the referred entry: Do not do this for the bibtex key.
if (!result.isPresent() && (database != null)) {
Optional<BibEntry> referred = database.getReferencedEntry(this);
result = referred.flatMap(entry -> entry.getFieldOrAlias(field));
}

// If this field is not set yet, try to look up the field in the
// main entry.
if (!result.isPresent()) {
result = getFieldOrAlias(field);
if (referred.isPresent()) {
result = referred.get().getFieldOrAlias(field);
if (!result.isPresent() && type.equals(StandardEntryType.InProceedings)) {
if (field == StandardField.BOOKTITLE) {
result = referred.get().getFieldOrAlias(StandardField.TITLE);
}
else if (field == StandardField.BOOKSUBTITLE) {
result = referred.get().getFieldOrAlias(StandardField.SUBTITLE);
}
else if (field == StandardField.BOOKAUTHOR) {
result = referred.get().getFieldOrAlias(StandardField.AUTHOR);
}
}
}
}
return result.map(resultText -> BibDatabase.getText(resultText, database));
}
Expand Down

0 comments on commit e2f389f

Please sign in to comment.