Verified Owner
Top Description Inners Fields Constructors Methods
org.jabref.logic.importer.fetcher

public Class MergingIdBasedFetcher

extends Object
Class Inheritance
Imports
java.util.List, .Optional, .Set, java.util.stream.Collectors, org.jabref.logic.importer.FetcherException, .IdBasedFetcher, .ImportFormatPreferences, .WebFetchers, org.jabref.logic.layout.format.NonSpaceWhitespaceRemover, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.Field, .InternalField, .StandardField, org.slf4j.Logger, .LoggerFactory

Fetches and merges bibliographic information from external sources into existing BibEntry objects. Supports multiple identifier types (DOI, ISBN, Eprint) and attempts fetching in a defined order until successful. The merging only adds new fields from the fetched entry and does not modify existing fields in the library entry.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static record

Field Summary

Modifier and TypeField and Description
private final ImportFormatPreferences
private static final Logger
private static final NonSpaceWhitespaceRemover
private static final List<StandardField>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private Optional<MergingIdBasedFetcher.FetcherResult>
executeFetch(IdBasedFetcher fetcher, Field field, String identifier, BibEntry entryFromLibrary)

public Optional<MergingIdBasedFetcher.FetcherResult>
fetchEntry(BibEntry entryFromLibrary)

private Optional<MergingIdBasedFetcher.FetcherResult>
private Optional<MergingIdBasedFetcher.FetcherResult>
fetchWithIdentifier(Field field, String identifier, BibEntry entryFromLibrary)

private Optional<MergingIdBasedFetcher.FetcherResult>
private void
private MergingIdBasedFetcher.FetcherResult
mergeBibEntries(BibEntry entryFromLibrary, BibEntry fetchedEntry)

private boolean
shouldUpdateField(Field field, BibEntry sourceEntry, BibEntry targetEntry)

private boolean
updateCitationKeyFromSource(BibEntry sourceEntry, BibEntry targetEntry)

Carries the fetcher-provided citation key (e.g. an INSPIRE texkey) onto the merged entry, but only if the library entry didn't already have one — an existing key is never overwritten here.

private void
updateField(Field field, BibEntry sourceEntry, BibEntry targetEntry)

private Set<Field>
updateFieldsFromSource(BibEntry sourceEntry, BibEntry targetEntry)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

importFormatPreferencesback to summary
private final ImportFormatPreferences importFormatPreferences
LOGGERback to summary
private static final Logger LOGGER
REMOVE_WHITESPACE_FORMATTERback to summary
private static final NonSpaceWhitespaceRemover REMOVE_WHITESPACE_FORMATTER
SUPPORTED_FIELDSback to summary
private static final List<StandardField> SUPPORTED_FIELDS

Constructor Detail

MergingIdBasedFetcherback to summary
public MergingIdBasedFetcher(ImportFormatPreferences importFormatPreferences)

Method Detail

executeFetchback to summary
private Optional<MergingIdBasedFetcher.FetcherResult> executeFetch(IdBasedFetcher fetcher, Field field, String identifier, BibEntry entryFromLibrary)
fetchEntryback to summary
public Optional<MergingIdBasedFetcher.FetcherResult> fetchEntry(BibEntry entryFromLibrary)
fetchWithFieldback to summary
private Optional<MergingIdBasedFetcher.FetcherResult> fetchWithField(BibEntry entry, Field field)
fetchWithIdentifierback to summary
private Optional<MergingIdBasedFetcher.FetcherResult> fetchWithIdentifier(Field field, String identifier, BibEntry entryFromLibrary)
findFirstValidFetchback to summary
private Optional<MergingIdBasedFetcher.FetcherResult> findFirstValidFetch(BibEntry entry)
logEntryProcessingback to summary
private void logEntryProcessing(BibEntry entry)
mergeBibEntriesback to summary
private MergingIdBasedFetcher.FetcherResult mergeBibEntries(BibEntry entryFromLibrary, BibEntry fetchedEntry)
shouldUpdateFieldback to summary
private boolean shouldUpdateField(Field field, BibEntry sourceEntry, BibEntry targetEntry)
updateCitationKeyFromSourceback to summary
private boolean updateCitationKeyFromSource(BibEntry sourceEntry, BibEntry targetEntry)

Carries the fetcher-provided citation key (e.g. an INSPIRE texkey) onto the merged entry, but only if the library entry didn't already have one — an existing key is never overwritten here.

updateFieldback to summary
private void updateField(Field field, BibEntry sourceEntry, BibEntry targetEntry)
updateFieldsFromSourceback to summary
private Set<Field> updateFieldsFromSource(BibEntry sourceEntry, BibEntry targetEntry)
org.jabref.logic.importer.fetcher back to summary

public final Record MergingIdBasedFetcher.FetcherResult

extends Record
Class Inheritance
Record Components
entryFromLibrary:BibEntry 
mergedEntry:BibEntry 
hasChanges:boolean 
updatedFields:Set<Field> 

Field Summary

Modifier and TypeField and Description
private final BibEntry
entryFromLibrary

Record Component accessed by entryFromLibrary().

private final boolean
hasChanges

Record Component accessed by hasChanges().

private final BibEntry
mergedEntry

Record Component accessed by mergedEntry().

private final Set<Field>
updatedFields

Record Component accessed by updatedFields().

Constructor Summary

AccessConstructor and Description
public
FetcherResult(BibEntry entryFromLibrary, BibEntry mergedEntry, boolean hasChanges, Set<Field> updatedFields)

Method Summary

Modifier and TypeMethod and Description
public BibEntry
entryFromLibrary()

Record Component getter of entryFromLibrary.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public boolean
hasChanges()

Record Component getter of hasChanges.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public BibEntry
mergedEntry()

Record Component getter of mergedEntry.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public Set<Field>
updatedFields()

Record Component getter of updatedFields.

Field Detail

entryFromLibraryback to summary
private final BibEntry entryFromLibrary

Record Component accessed by entryFromLibrary().

hasChangesback to summary
private final boolean hasChanges

Record Component accessed by hasChanges().

mergedEntryback to summary
private final BibEntry mergedEntry

Record Component accessed by mergedEntry().

updatedFieldsback to summary
private final Set<Field> updatedFields

Record Component accessed by updatedFields().

Constructor Detail

FetcherResultback to summary
public FetcherResult(BibEntry entryFromLibrary, BibEntry mergedEntry, boolean hasChanges, Set<Field> updatedFields)

Method Detail

entryFromLibraryback to summary
public BibEntry entryFromLibrary()

Record Component getter of entryFromLibrary.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hasChangesback to summary
public boolean hasChanges()

Record Component getter of hasChanges.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

mergedEntryback to summary
public BibEntry mergedEntry()

Record Component getter of mergedEntry.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

updatedFieldsback to summary
public Set<Field> updatedFields()

Record Component getter of updatedFields.