From 85bea5727119e18b75a0a98fc5c4b843defc7d49 Mon Sep 17 00:00:00 2001 From: Prasan Yapa Date: Fri, 28 Jun 2019 23:49:31 +0530 Subject: [PATCH 1/4] bugfix/5045 :Modified the existing logic to comply crossref resolution with biblatex specification --- .../java/org/jabref/model/entry/BibEntry.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index be2842e5f88..7a9d68a913e 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -132,14 +132,19 @@ public Optional getResolvedFieldOrAlias(String field, BibDatabase databa return getCiteKeyOptional(); } - Optional 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 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 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); + } return result.map(resultText -> BibDatabase.getText(resultText, database)); } From e2f389f7ebcbe310c5ba05ee83aef999e30a777b Mon Sep 17 00:00:00 2001 From: Prasan Yapa Date: Fri, 9 Aug 2019 15:23:11 +0530 Subject: [PATCH 2/4] bugfix/5045: Modified the logic to comply crossref resolution with biblatex spec --- .../java/org/jabref/model/entry/BibEntry.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index e36d5d6a94d..6026db73d72 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -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; @@ -133,18 +135,25 @@ public Optional getResolvedFieldOrAlias(Field field, BibDatabase databas return getCiteKeyOptional(); } - Optional 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 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 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)); } From 88245437d5cb97d31a0b084a069c2ac2ea0255da Mon Sep 17 00:00:00 2001 From: Prasan Yapa Date: Wed, 21 Aug 2019 22:25:15 +0530 Subject: [PATCH 3/4] bugfix/5045: Organizes imports --- .../java/org/jabref/model/entry/BibEntry.java | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index 6026db73d72..8e90ec33ecb 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -1,18 +1,7 @@ package org.jabref.model.entry; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Pattern; - +import com.google.common.base.Strings; +import com.google.common.eventbus.EventBus; import javafx.beans.Observable; import javafx.beans.binding.Bindings; import javafx.beans.binding.ObjectBinding; @@ -20,9 +9,6 @@ import javafx.beans.property.SimpleObjectProperty; 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; @@ -35,12 +21,13 @@ import org.jabref.model.entry.identifier.DOI; import org.jabref.model.strings.LatexToUnicodeAdapter; import org.jabref.model.strings.StringUtil; - -import com.google.common.base.Strings; -import com.google.common.eventbus.EventBus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.Pattern; + public class BibEntry implements Cloneable { public static final EntryType DEFAULT_TYPE = StandardEntryType.Misc; From 33b730932bf9bb720ae9b3581ef3f221b24f77d6 Mon Sep 17 00:00:00 2001 From: Prasan Yapa Date: Thu, 22 Aug 2019 12:54:49 +0530 Subject: [PATCH 4/4] bugfix/5045: Organized imports. --- .../java/org/jabref/model/entry/BibEntry.java | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/model/entry/BibEntry.java b/src/main/java/org/jabref/model/entry/BibEntry.java index 8e90ec33ecb..b7e13ed723c 100644 --- a/src/main/java/org/jabref/model/entry/BibEntry.java +++ b/src/main/java/org/jabref/model/entry/BibEntry.java @@ -1,7 +1,18 @@ package org.jabref.model.entry; -import com.google.common.base.Strings; -import com.google.common.eventbus.EventBus; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.Pattern; + import javafx.beans.Observable; import javafx.beans.binding.Bindings; import javafx.beans.binding.ObjectBinding; @@ -9,6 +20,7 @@ import javafx.beans.property.SimpleObjectProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableMap; + import org.jabref.model.FieldChange; import org.jabref.model.database.BibDatabase; import org.jabref.model.entry.event.EntryEventSource; @@ -21,13 +33,12 @@ import org.jabref.model.entry.identifier.DOI; import org.jabref.model.strings.LatexToUnicodeAdapter; import org.jabref.model.strings.StringUtil; + +import com.google.common.base.Strings; +import com.google.common.eventbus.EventBus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.regex.Pattern; - public class BibEntry implements Cloneable { public static final EntryType DEFAULT_TYPE = StandardEntryType.Misc;