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.io.IOException, java.net.MalformedURLException, .URISyntaxException, .URL, java.util.ArrayList, .Collection, .Collections, .List, .Objects, .Optional, java.util.stream.Collectors, org.jabref.logic.cleanup.FieldFormatterCleanup, .MoveFieldCleanup, org.jabref.logic.formatter.bibtexfields.ClearFormatter, .NormalizeMonthFormatter, .NormalizeNamesFormatter, .RemoveEnclosingBracesFormatter, .RemoveNewlinesFormatter, org.jabref.logic.help.HelpFile, 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.BuildInfo, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.StandardField, .UnknownField, org.jabref.model.paging.Page, org.jabref.model.strings.StringUtil, kong.unirest.core.json.JSONArray, kong.unirest.core.json.JSONException, kong.unirest.core.json.JSONObject, org.apache.hc.core5.net.URIBuilder, org.apache.lucene.queryparser.flexible.core.nodes.QueryNode

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
private static final String
private final ImporterPreferences
private final ImportFormatPreferences

Constructor Summary

AccessConstructor and Description
public

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
)

public void
doPostCleanup(BibEntry
the entry to be cleaned-up
entry
)

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

Performs a cleanup of the fetched entry.

private List<String>

Returns:

list of bibcodes matching the search request. May be empty
fetchBibcodes
(URL
search ul for which bibcode will be returned
url
)

public Optional<HelpFile>
getHelpPage()

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

Returns the help page for this fetcher.

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

Returns:

export URL endpoint
getURLforExport
()

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
(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode
query string, matching the apache solr format
luceneQuery
,
int
the number of the page indexed from 0
pageNumber
)

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

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

public List<BibEntry>
performSearch(BibEntry
entry to search bibliographic information for
entry
)

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

Looks for hits which are matched by the given BibEntry.

public List<BibEntry>
performSearch(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode
the root node of the lucene query
luceneQuery
)

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

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

public Optional<BibEntry>
performSearchById(String
a string which uniquely identifies the item
identifier
)

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

Looks for bibliographic information associated to the given identifier.

private List<BibEntry>

Returns:

list of bibentries matching the bibcodes. Can be empty and differ in size to the size of requested bibcodes
performSearchByIds
(Collection<String>
bibcodes for which bibentries ahould be fetched
identifiers
)

public Page<BibEntry>
performSearchPaged(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode
the root node of the lucene query
luceneQuery
,
int
requested site number indexed from 0
pageNumber
)

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

API_EXPORT_URLback to summary
private static final String API_EXPORT_URL
API_KEYback to summary
private static final String API_KEY
API_SEARCH_URLback to summary
private static final String API_SEARCH_URL
importerPreferencesback to summary
private final ImporterPreferences importerPreferences
preferencesback to summary
private final ImportFormatPreferences preferences

Constructor Detail

AstrophysicsDataSystemback to summary
public AstrophysicsDataSystem(ImportFormatPreferences preferences, 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

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 Formatter for the cleanup. For example, new FieldFormatterCleanup(StandardField.TITLE, new RemoveBracesFormatter()).cleanup(entry);

By default, no cleanup is done.

Parameters
entry:BibEntry

the entry to be cleaned-up

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

getHelpPageback to summary
public Optional<HelpFile> getHelpPage()

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

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

Returns the help page for this fetcher.

Returns:Optional<HelpFile>

the HelpFile enum constant for the help page

Annotations
@Override
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.

Returns:String

the localized name

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 FetcherException, 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(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode luceneQuery, int pageNumber) throws URISyntaxException, MalformedURLException, FetcherException

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
luceneQuery:org.apache.lucene.queryparser.flexible.core.nodes.QueryNode

query string, matching the apache solr format

pageNumber:int

the number of the page indexed from 0

Returns:URL

URL which points to a search request for given query

Annotations
@Override
performSearchback to summary
public List<BibEntry> performSearch(BibEntry entry) throws FetcherException

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

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

Looks for hits which are matched by the given BibEntry.

Parameters
entry:BibEntry

entry to search bibliographic information for

Returns:List<BibEntry>

a list of BibEntry, which are matched by the query (may be empty)

Annotations
@Override
performSearchback to summary
public List<BibEntry> performSearch(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode luceneQuery) 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.

Parameters
luceneQuery:org.apache.lucene.queryparser.flexible.core.nodes.QueryNode

the root node of the lucene query

Returns:List<BibEntry>

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

a list of BibEntry, which are matched by the query (may be empty)

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.

Parameters
identifier:String

a string which uniquely identifies the item

Returns:Optional<BibEntry>

a BibEntry containing the bibliographic information (or an empty optional if no data was found)

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

bibcodes for which bibentries ahould 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(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode luceneQuery, int pageNumber) throws FetcherException

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

Parameters
luceneQuery:org.apache.lucene.queryparser.flexible.core.nodes.QueryNode

Doc from org.jabref.logic.importer.PagedSearchBasedFetcher.performSearchPaged.

the root node of the lucene query

pageNumber:int

Doc from org.jabref.logic.importer.PagedSearchBasedFetcher.performSearchPaged.

requested site number indexed from 0

Returns:Page<BibEntry>

Doc from org.jabref.logic.importer.PagedSearchBasedFetcher.performSearchPaged.

Page with search results

Annotations
@Override