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

Bugfix/5045 : Modified the existing logic to comply crossref resolution with biblatex specification #5086

Merged
merged 10 commits into from
Aug 22, 2019
18 changes: 16 additions & 2 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;
Copy link
Member

@Siedlerchr Siedlerchr Aug 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check your imports, it seems like you have imported the type from the wrong package.
Must be import org.jabref.model.entry.StandardEntryType;
And CrossRef here looks also odd.

import org.jabref.model.FieldChange;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.entry.event.EntryEventSource;
Expand Down Expand Up @@ -134,12 +136,24 @@ public Optional<String> getResolvedFieldOrAlias(Field field, BibDatabase databas
}

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 (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