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

public Class AstrophysicsDataSystem

extends Object
implements IdBasedParserFetcher, PagedSearchBasedParserFetcher, EntryBasedParserFetcher, CustomizableKeyFetcher
Class Inheritance
All Implemented Interfaces
org.jabref.logic.importer.fetcher.CustomizableKeyFetcher, org.jabref.logic.importer.WebFetcher, org.jabref.logic.importer.EntryBasedParserFetcher, org.jabref.logic.importer.ParserFetcher, org.jabref.logic.importer.EntryBasedFetcher, org.jabref.logic.importer.PagedSearchBasedParserFetcher, org.jabref.logic.importer.PagedSearchBasedFetcher, org.jabref.logic.importer.SearchBasedFetcher, org.jabref.logic.importer.SearchBasedParserFetcher, org.jabref.logic.importer.IdBasedParserFetcher, org.jabref.logic.importer.IdBasedFetcher
Imports
java.net.MalformedURLException, .URISyntaxException, .URL, java.util.ArrayList, .Collection, .List, .Optional, java.util.stream.Collectors, org.jabref.logic.cleanup.FieldFormatterCleanup, .MoveFieldCleanup, org.jabref.logic.formatter.bibtexfields.ClearFormatter, .NormalizeMonthFormatter, .NormalizeNamesFormatter, .RemoveEnclosingBracesFormatter, .RemoveNewlinesFormatter, org.jabref.logic.importer.EntryBasedParserFetcher, .FetcherException, .IdBasedParserFetcher, .ImportFormatPreferences, .ImporterPreferences, .PagedSearchBasedParserFetcher, .ParseException, .Parser, org.jabref.logic.importer.fetcher.transformers.DefaultQueryTransformer, org.jabref.logic.importer.fileformat.BibtexParser, org.jabref.logic.net.URLDownload, org.jabref.logic.util.strings.StringUtil, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.StandardField, .UnknownField, org.jabref.model.paging.Page, org.jabref.model.search.query.BaseQueryNode, kong.unirest.core.json.JSONArray, kong.unirest.core.json.JSONException, kong.unirest.core.json.JSONObject, org.apache.hc.core5.net.URIBuilder, org.jspecify.annotations.NonNull

Fetches data from the SAO/NASA Astrophysics Data System (https://ui.adsabs.harvard.edu/)

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
public static final String
private final ImporterPreferences
private final ImportFormatPreferences

Constructor Summary

AccessConstructor and Description
public
AstrophysicsDataSystem(@NonNull ImportFormatPreferences importFormatPreferences, ImporterPreferences importerPreferences)

Method Summary

Modifier and TypeMethod and Description
private static String
buildPostData(Collection<String>
collection of bibcodes for which a JSON object should be created
bibcodes
)

private URL
buildSearchURL(String query, int pageNumber)

public void
doPostCleanup(BibEntry entry)

Overrides default org.jabref.logic.importer.ParserFetcher.doPostCleanup.

Performs a cleanup of the fetched entry.

private List<String>
fetchBibcodes(URL
search ul for which bibcode will be returned
url
)

Returns: list of bibcodes matching the search request.

public String
getName()

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

Returns the localized name of this fetcher.

public Parser
public URLDownload
getUrlDownload(URL url)

Overrides default org.jabref.logic.importer.WebFetcher.getUrlDownload.

Constructs an URLDownload object for downloading content based on the given URL.

public URL

Returns:

URL which points to a search request for given entry
getURLForEntry
(BibEntry
BibEntry for which a search URL is created
entry
)

Implements org.jabref.logic.importer.EntryBasedParserFetcher.getURLForEntry.

Constructs a URL based on the BibEntry.

private static URL
getUrlForExport()

Returns: export URL endpoint

public URL

Returns:

URL which points to a search URL for given identifier
getUrlForIdentifier
(String
bibcode or doi for which a search URL is created
identifier
)

Implements org.jabref.logic.importer.IdBasedParserFetcher.getUrlForIdentifier.

Constructs a URL based on the query.

public URL

Returns:

URL which points to a search request for given query
getURLForQuery
(BaseQueryNode
the list that contains the parsed nodes
queryList
,
int pageNumber)

Implements org.jabref.logic.importer.PagedSearchBasedParserFetcher.getURLForQuery.

Constructs a URL based on the query, size and page number.

public Page<BibEntry>
performRawSearchQueryPaged(String rawQuery, int pageNumber)

Overrides default org.jabref.logic.importer.PagedSearchBasedParserFetcher.performRawSearchQueryPaged.

Default implementation: builds the URL via getURLForRawQuery(String, int), then downloads, parses, and post-cleans the result.

public List<BibEntry>
performSearch(@NonNull BibEntry entry)

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

Looks for hits which are matched by the given BibEntry.

public List<BibEntry>
performSearch(BaseQueryNode queryList)

Overrides default org.jabref.logic.importer.PagedSearchBasedParserFetcher.performSearch.

This method is used to send queries with advanced URL parameters.

public Optional<BibEntry>
performSearchById(String identifier)

Overrides default org.jabref.logic.importer.IdBasedParserFetcher.performSearchById.

Looks for bibliographic information associated to the given identifier.

private List<BibEntry>
performSearchByIds(Collection<String>
bibcodes for which bibentries should be fetched
identifiers
)

Returns: list of bibentries matching the bibcodes.

public Page<BibEntry>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

API_EXPORT_URLback to summary
private static final String API_EXPORT_URL
API_SEARCH_URLback to summary
private static final String API_SEARCH_URL
FETCHER_NAMEback to summary
public static final String FETCHER_NAME
importerPreferencesback to summary
private final ImporterPreferences importerPreferences
importFormatPreferencesback to summary
private final ImportFormatPreferences importFormatPreferences

Constructor Detail

AstrophysicsDataSystemback to summary
public AstrophysicsDataSystem(@NonNull ImportFormatPreferences importFormatPreferences, ImporterPreferences importerPreferences)

Method Detail

buildPostDataback to summary
private static String buildPostData(Collection<String> bibcodes)
Parameters
bibcodes:Collection<String>

collection of bibcodes for which a JSON object should be created

buildSearchURLback to summary
private URL buildSearchURL(String query, int pageNumber) throws URISyntaxException, MalformedURLException
doPostCleanupback to summary
public void doPostCleanup(BibEntry entry)

Overrides default org.jabref.logic.importer.ParserFetcher.doPostCleanup.

Doc from org.jabref.logic.importer.ParserFetcher.doPostCleanup.

Performs a cleanup of the fetched entry.

Only systematic errors of the fetcher should be corrected here (i.e. if information is consistently contained in the wrong field or the wrong format) but not cosmetic issues which may depend on the user's taste (for example, LateX code vs HTML in the abstract).

Try to reuse existing org.jabref.logic.formatter.Formatter for the cleanup. For example, new FieldFormatterCleanup(StandardField.TITLE, new RemoveBracesFormatter()).cleanup(entry);

By default, no cleanup is done.

Annotations
@Override
fetchBibcodesback to summary
private List<String> fetchBibcodes(URL url) throws FetcherException
Parameters
url:URL

search ul for which bibcode will be returned

Returns:List<String>

list of bibcodes matching the search request. May be empty

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
getParserback to summary
public Parser getParser()

Implements org.jabref.logic.importer.IdBasedParserFetcher.getParser, org.jabref.logic.importer.SearchBasedParserFetcher.getParser, org.jabref.logic.importer.EntryBasedParserFetcher.getParser.

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

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

Annotations
@Override
getUrlDownloadback to summary
public URLDownload getUrlDownload(URL url)

Overrides default org.jabref.logic.importer.WebFetcher.getUrlDownload.

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

Constructs an URLDownload object for downloading content based on the given URL. Overwrite, if you need to send additional headers for the download.

Annotations
@Override
getURLForEntryback to summary
public URL getURLForEntry(BibEntry entry) throws URISyntaxException, MalformedURLException

Implements org.jabref.logic.importer.EntryBasedParserFetcher.getURLForEntry.

Doc from org.jabref.logic.importer.EntryBasedParserFetcher.getURLForEntry.

Constructs a URL based on the BibEntry.

Parameters
entry:BibEntry

BibEntry for which a search URL is created

Returns:URL

URL which points to a search request for given entry

Annotations
@Override
getUrlForExportback to summary
private static URL getUrlForExport() throws URISyntaxException, MalformedURLException
Returns:URL

export URL endpoint

getUrlForIdentifierback to summary
public URL getUrlForIdentifier(String identifier) throws URISyntaxException, MalformedURLException

Implements org.jabref.logic.importer.IdBasedParserFetcher.getUrlForIdentifier.

Doc from org.jabref.logic.importer.IdBasedParserFetcher.getUrlForIdentifier.

Constructs a URL based on the query.

Parameters
identifier:String

bibcode or doi for which a search URL is created

Returns:URL

URL which points to a search URL for given identifier

Annotations
@Override
getURLForQueryback to summary
public URL getURLForQuery(BaseQueryNode queryList, int pageNumber) throws URISyntaxException, MalformedURLException

Implements org.jabref.logic.importer.PagedSearchBasedParserFetcher.getURLForQuery.

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

Constructs a URL based on the query, size and page number.

Parameters
queryList:BaseQueryNode

the list that contains the parsed nodes

Returns:URL

URL which points to a search request for given query

Annotations
@Override
performRawSearchQueryPagedback to summary
public Page<BibEntry> performRawSearchQueryPaged(String rawQuery, int pageNumber) throws FetcherException

Overrides default org.jabref.logic.importer.PagedSearchBasedParserFetcher.performRawSearchQueryPaged.

Doc from org.jabref.logic.importer.PagedSearchBasedParserFetcher.performRawSearchQueryPaged.

Default implementation: builds the URL via getURLForRawQuery(String, int), then downloads, parses, and post-cleans the result.

Annotations
@Override
performSearchback to summary
public List<BibEntry> performSearch(@NonNull 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
performSearchback to summary
public List<BibEntry> performSearch(BaseQueryNode queryList) throws FetcherException

Overrides default org.jabref.logic.importer.PagedSearchBasedParserFetcher.performSearch.

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

This method is used to send queries with advanced URL parameters. This method is necessary as the performSearch method does not support certain URL parameters that are used for fielded search, such as a title, author, or year parameter.

Annotations
@Override
performSearchByIdback to summary
public Optional<BibEntry> performSearchById(String identifier) throws FetcherException

Overrides default org.jabref.logic.importer.IdBasedParserFetcher.performSearchById.

Doc from org.jabref.logic.importer.IdBasedFetcher.performSearchById.

Looks for bibliographic information associated to the given identifier.

Annotations
@Override
performSearchByIdsback to summary
private List<BibEntry> performSearchByIds(Collection<String> identifiers) throws FetcherException
Parameters
identifiers:Collection<String>

bibcodes for which bibentries should be fetched

Returns:List<BibEntry>

list of bibentries matching the bibcodes. Can be empty and differ in size to the size of requested bibcodes

performSearchPagedback to summary
public Page<BibEntry> performSearchPaged(BaseQueryNode queryList, int pageNumber) throws FetcherException

Overrides default org.jabref.logic.importer.PagedSearchBasedParserFetcher.performSearchPaged.

Annotations
@Override