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

public Class MedlineFetcher

extends Object
implements IdBasedParserFetcher, SearchBasedFetcher
Class Inheritance
All Implemented Interfaces
org.jabref.logic.importer.SearchBasedFetcher, org.jabref.logic.importer.WebFetcher, org.jabref.logic.importer.IdBasedParserFetcher, org.jabref.logic.importer.ParserFetcher, org.jabref.logic.importer.IdBasedFetcher
Imports
java.io.BufferedReader, .IOException, .InputStreamReader, java.net.MalformedURLException, .URISyntaxException, .URL, .URLConnection, java.nio.charset.StandardCharsets, java.util.ArrayList, .Collections, .List, .Optional, javax.xml.stream.XMLInputFactory, .XMLStreamConstants, .XMLStreamException, .XMLStreamReader, org.jabref.logic.cleanup.FieldFormatterCleanup, org.jabref.logic.formatter.bibtexfields.ClearFormatter, .NormalizeMonthFormatter, .NormalizeNamesFormatter, org.jabref.logic.help.HelpFile, org.jabref.logic.importer.FetcherException, .IdBasedParserFetcher, .Parser, .ParserResult, .SearchBasedFetcher, org.jabref.logic.importer.fetcher.transformers.MedlineQueryTransformer, org.jabref.logic.importer.fileformat.MedlineImporter, org.jabref.logic.l10n.Localization, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.StandardField, .UnknownField, org.apache.hc.core5.net.URIBuilder, org.apache.lucene.queryparser.flexible.core.nodes.QueryNode, org.slf4j.Logger, .LoggerFactory

Fetch or search from PubMed www.ncbi.nlm.nih.gov The MedlineFetcher fetches the entries from the PubMed database. See docs.jabref.org for a detailed documentation of the available fields.

Field Summary

Modifier and TypeField and Description
private static final String
private static final Logger
private static final int
private int
private static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private URL
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<BibEntry>

Returns:

Will return an empty list on error.
fetchMedline
(List<String>
A list of IDs to search for.
ids
)

Fetch and parse an medline item from eutils.ncbi.nlm.nih.gov.

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
getParser()

Implements org.jabref.logic.importer.IdBasedParserFetcher.getParser.

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

private List<String>
getPubMedIdsFromQuery(String query)

When using 'esearch.fcgi?db=<database>&term;=<query>' we will get a list of IDs matching the query.

public URL
getUrlForIdentifier(String
the ID
identifier
)

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

Constructs a URL based on the query.

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

Implements org.jabref.logic.importer.SearchBasedFetcher.performSearch.

This method is used to send complex queries using fielded search.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ID_URLback to summary
private static final String ID_URL
LOGGERback to summary
private static final Logger LOGGER

Hides org.jabref.logic.importer.IdBasedParserFetcher.LOGGER.

NUMBER_TO_FETCHback to summary
private static final int NUMBER_TO_FETCH
numberOfResultsFoundback to summary
private int numberOfResultsFound
SEARCH_URLback to summary
private static final String SEARCH_URL

Constructor Detail

MedlineFetcherback to summary
public MedlineFetcher()

Method Detail

createSearchUrlback to summary
private URL createSearchUrl(String query) 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 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
fetchMedlineback to summary
private List<BibEntry> fetchMedline(List<String> ids) throws FetcherException

Fetch and parse an medline item from eutils.ncbi.nlm.nih.gov. The E-utilities generate a huge XML file containing all entries for the ids

Parameters
ids:List<String>

A list of IDs to search for.

Returns:List<BibEntry>

Will return an empty list on error.

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.

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

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

Annotations
@Override
getPubMedIdsFromQueryback to summary
private List<String> getPubMedIdsFromQuery(String query) throws FetcherException

When using 'esearch.fcgi?db=<database>&term=<query>' we will get a list of IDs matching the query. Input: Any text query (&term) Output: List of UIDs matching the query

See Also
www.ncbi.nlm.nih.gov/books/NBK25500/
getUrlForIdentifierback to summary
public URL getUrlForIdentifier(String identifier) throws URISyntaxException, MalformedURLException, FetcherException

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

the ID

Annotations
@Override
performSearchback to summary
public List<BibEntry> performSearch(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode luceneQuery) throws FetcherException

Implements org.jabref.logic.importer.SearchBasedFetcher.performSearch.

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

This method is used to send complex queries using fielded search.

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

the root node of the lucene query

Returns:List<BibEntry>

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

Annotations
@Override