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

public Class JournalInformationFetcher

extends Object
implements WebFetcher
Class Inheritance
All Implemented Interfaces
org.jabref.logic.importer.WebFetcher
Imports
java.net.URLEncoder, java.nio.charset.StandardCharsets, java.util.ArrayList, .Comparator, .List, .Locale, .Optional, java.util.regex.Pattern, java.util.stream.IntStream, .Stream, javafx.util.Pair, org.jabref.logic.importer.FetcherException, .ImporterPreferences, .WebFetcher, org.jabref.logic.journals.JournalInformation, org.jabref.logic.l10n.Localization, org.jabref.model.entry.identifier.ISSN, kong.unirest.core.HttpResponse, kong.unirest.core.JsonNode, kong.unirest.core.Unirest, kong.unirest.core.UnirestException, kong.unirest.core.json.JSONArray, kong.unirest.core.json.JSONObject, org.jspecify.annotations.NullMarked, org.slf4j.Logger, .LoggerFactory

Fetches journal information from Crossref and OpenAlex.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record
private static record

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private static final FetcherRateLimiter
private final ImporterPreferences
private static final Pattern
private static final Logger
public static final String
private static final String

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
private static String
chooseValue(String preferredValue, String fallbackValue)

private JournalInformation
private String
private Optional<JournalInformationFetcher.JournalIdentity>
private static String
getHIndex(kong.unirest.core.json.JSONObject summaryStats)

private static String
getJoinedArray(kong.unirest.core.json.JSONObject response, String key)

public Optional<JournalInformation>
getJournalInformation(String issnString, String journalName)

private Optional<kong.unirest.core.json.JSONObject>
getJson(String url, String provider)

public String
getName()

Implements org.jabref.logic.importer.WebFetcher.getName.

Returns the localized name of this fetcher.

private Optional<JournalInformationFetcher.OpenAlexInformation>
private Stream<kong.unirest.core.json.JSONObject>
getOpenAlexSources(kong.unirest.core.json.JSONObject response)

pack-priv String
getOpenAlexUrl(String issn, String journalName)

private static List<Pair<Integer, Double>>
getYearlyValues(kong.unirest.core.json.JSONArray yearlyCounts, String key)

pack-priv static boolean
haveMatchingNames(String firstName, String secondName)

private static FetcherException
private static String
private Optional<JournalInformationFetcher.JournalIdentity>
parseCrossrefInformation(kong.unirest.core.json.JSONObject response)

private Optional<JournalInformationFetcher.OpenAlexInformation>
parseOpenAlexInformation(kong.unirest.core.json.JSONObject response)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CROSSREF_API_URLback to summary
private static final String CROSSREF_API_URL
CROSSREF_PROVIDERback to summary
private static final String CROSSREF_PROVIDER
CROSSREF_RATE_LIMITERback to summary
private static final FetcherRateLimiter CROSSREF_RATE_LIMITER
importerPreferencesback to summary
private final ImporterPreferences importerPreferences
JOURNAL_NAME_SEPARATOR_PATTERNback to summary
private static final Pattern JOURNAL_NAME_SEPARATOR_PATTERN
LOGGERback to summary
private static final Logger LOGGER
NAMEback to summary
public static final String NAME
OPENALEX_API_URLback to summary
private static final String OPENALEX_API_URL

Constructor Detail

JournalInformationFetcherback to summary
public JournalInformationFetcher(ImporterPreferences importerPreferences)
JournalInformationFetcherback to summary
public JournalInformationFetcher()

Method Detail

chooseValueback to summary
private static String chooseValue(String preferredValue, String fallbackValue)
createJournalInformationback to summary
private JournalInformation createJournalInformation(Optional<JournalInformationFetcher.JournalIdentity> crossrefInformation, Optional<JournalInformationFetcher.OpenAlexInformation> openAlexInformation)
getCleanedIssnback to summary
private String getCleanedIssn(ISSN issn)
getCrossrefInformationback to summary
private Optional<JournalInformationFetcher.JournalIdentity> getCrossrefInformation(String issn) throws FetcherException
getHIndexback to summary
private static String getHIndex(kong.unirest.core.json.JSONObject summaryStats)
getJoinedArrayback to summary
private static String getJoinedArray(kong.unirest.core.json.JSONObject response, String key)
getJournalInformationback to summary
public Optional<JournalInformation> getJournalInformation(String issnString, String journalName) throws FetcherException
getJsonback to summary
private Optional<kong.unirest.core.json.JSONObject> getJson(String url, String provider) throws FetcherException
getNameback to summary
public String getName()

Implements org.jabref.logic.importer.WebFetcher.getName.

Doc from org.jabref.logic.importer.WebFetcher.getName.

Returns the localized name of this fetcher. The title can be used to display the fetcher in the menu and in the side pane.

Todo

This name is also used for identifying the fetcher in preferences for API keys. Thus, any switch of the language will "remove" API keys.

Annotations
@Override
getOpenAlexInformationback to summary
private Optional<JournalInformationFetcher.OpenAlexInformation> getOpenAlexInformation(String issn, String journalName) throws FetcherException
getOpenAlexSourcesback to summary
private Stream<kong.unirest.core.json.JSONObject> getOpenAlexSources(kong.unirest.core.json.JSONObject response)
getOpenAlexUrlback to summary
pack-priv String getOpenAlexUrl(String issn, String journalName)
getYearlyValuesback to summary
private static List<Pair<Integer, Double>> getYearlyValues(kong.unirest.core.json.JSONArray yearlyCounts, String key)
haveMatchingNamesback to summary
pack-priv static boolean haveMatchingNames(String firstName, String secondName)
journalNotFoundExceptionback to summary
private static FetcherException journalNotFoundException()
normalizeJournalNameback to summary
private static String normalizeJournalName(String journalName)
parseCrossrefInformationback to summary
private Optional<JournalInformationFetcher.JournalIdentity> parseCrossrefInformation(kong.unirest.core.json.JSONObject response)
parseOpenAlexInformationback to summary
private Optional<JournalInformationFetcher.OpenAlexInformation> parseOpenAlexInformation(kong.unirest.core.json.JSONObject response)
org.jabref.logic.importer.fetcher back to summary

private final Record JournalInformationFetcher.JournalIdentity

extends Record
Class Inheritance
Annotations
@NullMarked
Record Components
title:String 
publisher:String 
issn:String 

Field Summary

Modifier and TypeField and Description
private final String
issn

Record Component accessed by issn().

private final String
publisher

Record Component accessed by publisher().

private final String
title

Record Component accessed by title().

Constructor Summary

AccessConstructor and Description
private
JournalIdentity(String title, String publisher, String issn)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public String
issn()

Record Component getter of issn.

public String
publisher()

Record Component getter of publisher.

public String
title()

Record Component getter of title.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

issnback to summary
private final String issn

Record Component accessed by issn().

publisherback to summary
private final String publisher

Record Component accessed by publisher().

titleback to summary
private final String title

Record Component accessed by title().

Constructor Detail

JournalIdentityback to summary
private JournalIdentity(String title, String publisher, String issn)

Method Detail

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).
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.

issnback to summary
public String issn()

Record Component getter of issn.

publisherback to summary
public String publisher()

Record Component getter of publisher.

titleback to summary
public String title()

Record Component getter of title.

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.

org.jabref.logic.importer.fetcher back to summary

private final Record JournalInformationFetcher.OpenAlexInformation

extends Record
Class Inheritance
Annotations
@NullMarked
Record Components
title:String 
publisher:String 
issn:String 
hIndex:String 
worksCount:List<Pair<Integer, Double>> 
citedByCount:List<Pair<Integer, Double>> 

Field Summary

Modifier and TypeField and Description
private final List<Pair<Integer, Double>>
citedByCount

Record Component accessed by citedByCount().

private final String
hIndex

Record Component accessed by hIndex().

private final String
issn

Record Component accessed by issn().

private final String
publisher

Record Component accessed by publisher().

private final String
title

Record Component accessed by title().

private final List<Pair<Integer, Double>>
worksCount

Record Component accessed by worksCount().

Constructor Summary

AccessConstructor and Description
private
OpenAlexInformation(String title, String publisher, String issn, String hIndex, List<Pair<Integer, Double>> worksCount, List<Pair<Integer, Double>> citedByCount)

Method Summary

Modifier and TypeMethod and Description
public List<Pair<Integer, Double>>
citedByCount()

Record Component getter of citedByCount.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

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

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public String
hIndex()

Record Component getter of hIndex.

public String
issn()

Record Component getter of issn.

public String
publisher()

Record Component getter of publisher.

public String
title()

Record Component getter of title.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public List<Pair<Integer, Double>>
worksCount()

Record Component getter of worksCount.

Field Detail

citedByCountback to summary
private final List<Pair<Integer, Double>> citedByCount

Record Component accessed by citedByCount().

hIndexback to summary
private final String hIndex

Record Component accessed by hIndex().

issnback to summary
private final String issn

Record Component accessed by issn().

publisherback to summary
private final String publisher

Record Component accessed by publisher().

titleback to summary
private final String title

Record Component accessed by title().

worksCountback to summary
private final List<Pair<Integer, Double>> worksCount

Record Component accessed by worksCount().

Constructor Detail

OpenAlexInformationback to summary
private OpenAlexInformation(String title, String publisher, String issn, String hIndex, List<Pair<Integer, Double>> worksCount, List<Pair<Integer, Double>> citedByCount)

Method Detail

citedByCountback to summary
public List<Pair<Integer, Double>> citedByCount()

Record Component getter of citedByCount.

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).
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.

hIndexback to summary
public String hIndex()

Record Component getter of hIndex.

issnback to summary
public String issn()

Record Component getter of issn.

publisherback to summary
public String publisher()

Record Component getter of publisher.

titleback to summary
public String title()

Record Component getter of title.

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.

worksCountback to summary
public List<Pair<Integer, Double>> worksCount()

Record Component getter of worksCount.