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

public Class OpenAlex

extends Object
implements CustomizableKeyFetcher, SearchBasedParserFetcher, FulltextFetcher, EntryBasedFetcher, CitationFetcher
Class Inheritance
All Implemented Interfaces
org.jabref.logic.importer.fetcher.citation.CitationFetcher, org.jabref.logic.importer.fetcher.citation.CitationCountFetcher, org.jabref.logic.importer.EntryBasedFetcher, org.jabref.logic.importer.WebFetcher, org.jabref.logic.importer.FulltextFetcher, org.jabref.logic.importer.SearchBasedParserFetcher, org.jabref.logic.importer.ParserFetcher, org.jabref.logic.importer.SearchBasedFetcher, org.jabref.logic.importer.fetcher.CustomizableKeyFetcher
Annotations
@NullMarked
Imports
java.io.IOException, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, java.util.ArrayList, .List, .Locale, .Map, .Objects, .Optional, java.util.function.Function, java.util.stream.Collectors, .IntStream, org.jabref.logic.cleanup.DoiCleanup, org.jabref.logic.importer.EntryBasedFetcher, .FetcherClientException, .FetcherException, .FulltextFetcher, .ImporterPreferences, .ParseException, .Parser, .SearchBasedParserFetcher, org.jabref.logic.importer.fetcher.citation.CitationFetcher, org.jabref.logic.importer.fetcher.transformers.DefaultQueryTransformer, org.jabref.logic.importer.util.JsonReader, org.jabref.logic.net.ProgressInputStream, org.jabref.logic.util.URLUtil, org.jabref.logic.util.strings.StringUtil, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.StandardField, org.jabref.model.entry.identifier.DOI, org.jabref.model.entry.types.BiblatexNonStandardEntryType, .EntryType, .StandardEntryType, .UnknownEntryType, org.jabref.model.search.query.BaseQueryNode, com.google.common.annotations.VisibleForTesting, kong.unirest.core.json.JSONArray, kong.unirest.core.json.JSONException, kong.unirest.core.json.JSONObject, org.apache.hc.core5.net.URIBuilder, org.jooq.lambda.Unchecked, org.jspecify.annotations.NullMarked, .Nullable, org.slf4j.Logger, .LoggerFactory

Fetcher for OpenAlex Works API Docs: OpenAlex API Docs

Field Summary

Modifier and TypeField and Description
public static final String
private final ImporterPreferences
private static final Logger
private static final Map<String, EntryType>
private static final String

Constructor Summary

AccessConstructor and Description
public
OpenAlex(ImporterPreferences importerPreferences)

Method Summary

Modifier and TypeMethod and Description
private String
collectAuthorships(kong.unirest.core.json.JSONArray authorships)

pack-priv Optional<String>
private List<BibEntry>
fetch(Optional<URI> apiUri, String arrayElementName, Function<kong.unirest.core.json.JSONArray, List<BibEntry>> handler)

public Optional<URL>
public Optional<Integer>
getCitationCount(BibEntry entry)

Implements org.jabref.logic.importer.fetcher.citation.CitationCountFetcher.getCitationCount.

Get the paper details that includes citation count field for a given BibEntry.

public List<BibEntry>
public Optional<URI>
getCitationsApiUri(BibEntry entry)

Overrides default org.jabref.logic.importer.fetcher.citation.CitationFetcher.getCitationsApiUri.

Returns the API URL for fetching citations

public String
public Parser
getParser()

Implements org.jabref.logic.importer.SearchBasedParserFetcher.getParser.

Returns the parser used to convert the response to a list of BibEntry.

public List<BibEntry>
public Optional<URI>
getReferencesApiUri(BibEntry entry)

Overrides default org.jabref.logic.importer.fetcher.citation.CitationFetcher.getReferencesApiUri.

Returns the API URL for fetching references

public TrustLevel
getTrustLevel()

Implements org.jabref.logic.importer.FulltextFetcher.getTrustLevel.

Returns the level of trust for this fetcher.

private URIBuilder
getUriBuilder(String tail, List<String> fieldsToSelect)

private Optional<URL>
getUrl(BibEntry entry, List<String> fieldsToSelect)

private URL
getUrl(String tail, List<String> fieldsToSelect)

public URL
getURLForQuery(BaseQueryNode queryNode)

Implements org.jabref.logic.importer.SearchBasedParserFetcher.getURLForQuery.

Constructs a URL based on the lucene query.

private Optional<kong.unirest.core.json.JSONObject>
getWorkObject(BibEntry entry, List<String> fieldsToSelect)

private BibEntry
jsonItemToBibEntry(kong.unirest.core.json.JSONObject item)

pack-priv EntryType
public List<BibEntry>
performSearch(BibEntry entry)

Implements org.jabref.logic.importer.EntryBasedFetcher.performSearch.

Looks for hits which are matched by the given BibEntry.

private List<BibEntry>
workArrayToBibEntryList(@Nullable kong.unirest.core.json.JSONArray workUrlArray)

private List<BibEntry>
workUrlsToBibEntryList(@Nullable kong.unirest.core.json.JSONArray workUrlArray)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FETCHER_NAMEback to summary
public static final String FETCHER_NAME
importerPreferencesback to summary
private final ImporterPreferences importerPreferences
LOGGERback to summary
private static final Logger LOGGER
OPENALEX_TYPE_TO_ENTRY_TYPEback to summary
private static final Map<String, EntryType> OPENALEX_TYPE_TO_ENTRY_TYPE
URL_PATTERNback to summary
private static final String URL_PATTERN

Constructor Detail

OpenAlexback to summary
public OpenAlex(ImporterPreferences importerPreferences)

Method Detail

collectAuthorshipsback to summary
private String collectAuthorships(kong.unirest.core.json.JSONArray authorships)
extractOpenAlexIdback to summary
pack-priv Optional<String> extractOpenAlexId(String url)
Annotations
@VisibleForTesting
fetchback to summary
private List<BibEntry> fetch(Optional<URI> apiUri, String arrayElementName, Function<kong.unirest.core.json.JSONArray, List<BibEntry>> handler) throws FetcherException
findFullTextback to summary
public Optional<URL> findFullText(BibEntry entry) throws IOException, FetcherException
Annotations
@Override
getCitationCountback to summary
public Optional<Integer> getCitationCount(BibEntry entry) throws FetcherException

Implements org.jabref.logic.importer.fetcher.citation.CitationCountFetcher.getCitationCount.

Doc from org.jabref.logic.importer.fetcher.citation.CitationCountFetcher.getCitationCount.

Get the paper details that includes citation count field for a given BibEntry.

Annotations
@Override
getCitationsback to summary
public List<BibEntry> getCitations(BibEntry entry) throws FetcherException

Implements org.jabref.logic.importer.fetcher.citation.CitationFetcher.getCitations.

Doc from org.jabref.logic.importer.fetcher.citation.CitationFetcher.getCitations.

Looks for hits which are citing the given BibEntry.

Annotations
@Override
getCitationsApiUriback to summary
public Optional<URI> getCitationsApiUri(BibEntry entry)

Overrides default org.jabref.logic.importer.fetcher.citation.CitationFetcher.getCitationsApiUri.

Doc from org.jabref.logic.importer.fetcher.citation.CitationFetcher.getCitationsApiUri.

Returns the API URL for fetching citations

Annotations
@Override
getNameback to summary
public String getName()

Implements org.jabref.logic.importer.WebFetcher.getName, org.jabref.logic.importer.fetcher.citation.CitationFetcher.getName.

Doc from org.jabref.logic.importer.fetcher.citation.CitationFetcher.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.

Annotations
@Override
getParserback to summary
public Parser getParser()

Implements org.jabref.logic.importer.SearchBasedParserFetcher.getParser.

Doc from org.jabref.logic.importer.SearchBasedParserFetcher.getParser.

Returns the parser used to convert the response to a list of BibEntry.

Annotations
@Override
getReferencesback to summary
public List<BibEntry> getReferences(BibEntry entry) throws FetcherException

Implements org.jabref.logic.importer.fetcher.citation.CitationFetcher.getReferences.

Doc from org.jabref.logic.importer.fetcher.citation.CitationFetcher.getReferences.

Looks for hits which are cited by the given BibEntry. This typically is the "References" (or "Bibliography" or "Literature") section of a paper.

Implementation Note

This method is similar to getCitations(BibEntry). Streamlining this into one is not leading to more maintainable code, because handling the exceptions properly

Annotations
@Override
getReferencesApiUriback to summary
public Optional<URI> getReferencesApiUri(BibEntry entry)

Overrides default org.jabref.logic.importer.fetcher.citation.CitationFetcher.getReferencesApiUri.

Doc from org.jabref.logic.importer.fetcher.citation.CitationFetcher.getReferencesApiUri.

Returns the API URL for fetching references

Annotations
@Override
getTrustLevelback to summary
public TrustLevel getTrustLevel()

Implements org.jabref.logic.importer.FulltextFetcher.getTrustLevel.

Doc from org.jabref.logic.importer.FulltextFetcher.getTrustLevel.

Returns the level of trust for this fetcher. We distinguish between publishers and meta search engines for example.

Annotations
@Override
getUriBuilderback to summary
private URIBuilder getUriBuilder(String tail, List<String> fieldsToSelect) throws MalformedURLException
getUrlback to summary
private Optional<URL> getUrl(BibEntry entry, List<String> fieldsToSelect) throws MalformedURLException
getUrlback to summary
private URL getUrl(String tail, List<String> fieldsToSelect) throws MalformedURLException
getURLForQueryback to summary
public URL getURLForQuery(BaseQueryNode queryNode) throws URISyntaxException, MalformedURLException

Implements org.jabref.logic.importer.SearchBasedParserFetcher.getURLForQuery.

Doc from org.jabref.logic.importer.SearchBasedParserFetcher.getURLForQuery.

Constructs a URL based on the lucene query.

Annotations
@Override
getWorkObjectback to summary
private Optional<kong.unirest.core.json.JSONObject> getWorkObject(BibEntry entry, List<String> fieldsToSelect) throws FetcherException
jsonItemToBibEntryback to summary
private BibEntry jsonItemToBibEntry(kong.unirest.core.json.JSONObject item) throws ParseException
mapOpenAlexTypeToEntryTypeback to summary
pack-priv EntryType mapOpenAlexTypeToEntryType(String openAlexType)
Annotations
@VisibleForTesting
performSearchback to summary
public List<BibEntry> performSearch(BibEntry entry) throws FetcherException

Implements org.jabref.logic.importer.EntryBasedFetcher.performSearch.

Doc from org.jabref.logic.importer.EntryBasedFetcher.performSearch.

Looks for hits which are matched by the given BibEntry.

Annotations
@Override
workArrayToBibEntryListback to summary
private List<BibEntry> workArrayToBibEntryList(@Nullable kong.unirest.core.json.JSONArray workUrlArray)
workUrlsToBibEntryListback to summary
private List<BibEntry> workUrlsToBibEntryList(@Nullable kong.unirest.core.json.JSONArray workUrlArray)