Top Description Inners Fields Constructors Methods
org.jabref.logic.importer.fileformat

public Class MrDLibImporter

extends Importer
Class Inheritance
Imports
java.io.BufferedReader, .IOException, java.util.ArrayList, .Iterator, .List, java.util.stream.Collectors, org.jabref.logic.importer.Importer, .ParserResult, org.jabref.logic.util.StandardFileType, org.jabref.model.database.BibDatabase, org.jabref.model.entry.BibEntry, org.jabref.model.entry.field.StandardField, kong.unirest.core.json.JSONException, kong.unirest.core.json.JSONObject, org.slf4j.Logger, .LoggerFactory

Handles importing of recommended articles to be displayed in the Related Articles tab.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
MrDLibImporter.RankedBibEntry

Small pair-class to ensure the right order of the recommendations.

Field Summary

Modifier and TypeField and Description
private static final Logger
public ParserResult
private String
private String
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private String

Returns:

Returns an String containing the JSON document.
convertToString
(BufferedReader
Takes a BufferedReader with a reference to the JSON document delivered by mdl server.
input
)

Convert Buffered Reader response to string for JSON parsing.

public String
getDescription()

Implements abstract org.jabref.logic.importer.Importer.getDescription.

Returns the description of the import format.

public StandardFileType
getFileType()

Implements abstract org.jabref.logic.importer.Importer.getFileType.

Returns the type of files that this importer can read

public String
getName()

Implements abstract org.jabref.logic.importer.Importer.getName.

Returns the name of this import format.

public ParserResult
public String
public String
public String
public ParserResult
importDatabase(BufferedReader
the input to read from
input
)

Implements abstract org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the source.

public boolean
isRecognizedFormat(BufferedReader input)

Implements abstract org.jabref.logic.importer.Importer.isRecognizedFormat.

Check whether the source is in the correct format for this importer.

private Boolean
isRecommendationFieldPresent(kong.unirest.core.json.JSONObject recommendation, String field)

private void
parse(BufferedReader
A BufferedReader with a reference to a string with the server's response
input
)

Parses the input from the server to a ParserResult

private MrDLibImporter.RankedBibEntry

Returns:

A ranked bib entry created from the recommendation input
populateBibEntry
(kong.unirest.core.json.JSONObject
JSON object of a single recommendation returned by Mr. DLib
recommendation
)

Parses the JSON recommendations into bib entries

Inherited from org.jabref.logic.importer.Importer:
compareToequalsgetCharsetgetIdgetReadergetReaderhashCodeimportDatabaseimportDatabaseisRecognizedFormatisRecognizedFormattoString

Field Detail

LOGGERback to summary
private static final Logger LOGGER

Hides org.jabref.logic.importer.Importer.LOGGER.

parserResultback to summary
public ParserResult parserResult
recommendationsDescriptionback to summary
private String recommendationsDescription
recommendationSetIdback to summary
private String recommendationSetId
recommendationsHeadingback to summary
private String recommendationsHeading

Constructor Detail

MrDLibImporterback to summary
public MrDLibImporter()

Method Detail

convertToStringback to summary
private String convertToString(BufferedReader input)

Convert Buffered Reader response to string for JSON parsing.

Parameters
input:BufferedReader

Takes a BufferedReader with a reference to the JSON document delivered by mdl server.

Returns:String

Returns an String containing the JSON document.

getDescriptionback to summary
public String getDescription()

Implements abstract org.jabref.logic.importer.Importer.getDescription.

Doc from org.jabref.logic.importer.Importer.getDescription.

Returns the description of the import format.

The description should specify

  • what kind of entries from what sources and based on what specification it is able to import
  • by what criteria it recognizes an import format
Returns:String

description of the import format

Annotations
@Override
getFileTypeback to summary
public StandardFileType getFileType()

Implements abstract org.jabref.logic.importer.Importer.getFileType.

Doc from org.jabref.logic.importer.Importer.getFileType.

Returns the type of files that this importer can read

Returns:StandardFileType

FileType corresponding to the importer

Annotations
@Override
getNameback to summary
public String getName()

Implements abstract org.jabref.logic.importer.Importer.getName.

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

Returns the name of this import format.

The name must be unique.

Returns:String

format name, must be unique and not null

Annotations
@Override
getParserResultback to summary
public ParserResult getParserResult()
getRecommendationsDescriptionback to summary
public String getRecommendationsDescription()
getRecommendationSetIdback to summary
public String getRecommendationSetId()
getRecommendationsHeadingback to summary
public String getRecommendationsHeading()
importDatabaseback to summary
public ParserResult importDatabase(BufferedReader input) throws IOException

Implements abstract org.jabref.logic.importer.Importer.importDatabase.

Doc from org.jabref.logic.importer.Importer.importDatabase.

Parse the database in the source.

This method can be called in two different contexts - either when importing in a specified format, or when importing in unknown format. In the latter case, JabRef cycles through all available import formats. No error messages or feedback is displayed from individual import formats in this case.

If importing in a specified format and an empty library is returned, JabRef reports that no entries were found.

This method should never return null.

Parameters
input:BufferedReader

the input to read from

Annotations
@Override
isRecognizedFormatback to summary
public boolean isRecognizedFormat(BufferedReader input) throws IOException

Implements abstract org.jabref.logic.importer.Importer.isRecognizedFormat.

Doc from org.jabref.logic.importer.Importer.isRecognizedFormat.

Check whether the source is in the correct format for this importer.

The effect of this method is primarily to avoid unnecessary processing of files when searching for a suitable import format. If this method returns false, the import routine will move on to the next import format.

Thus, the correct behaviour is to return false if it is certain that the file is not of the suitable type, and true otherwise. Returning true is the safe choice if not certain.

Annotations
@SuppressWarnings:unused
@Override
isRecommendationFieldPresentback to summary
private Boolean isRecommendationFieldPresent(kong.unirest.core.json.JSONObject recommendation, String field)
parseback to summary
private void parse(BufferedReader input) throws IOException

Parses the input from the server to a ParserResult

Parameters
input:BufferedReader

A BufferedReader with a reference to a string with the server's response

populateBibEntryback to summary
private MrDLibImporter.RankedBibEntry populateBibEntry(kong.unirest.core.json.JSONObject recommendation)

Parses the JSON recommendations into bib entries

Parameters
recommendation:kong.unirest.core.json.JSONObject

JSON object of a single recommendation returned by Mr. DLib

Returns:MrDLibImporter.RankedBibEntry

A ranked bib entry created from the recommendation input

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

private Class MrDLibImporter.RankedBibEntry

extends Object
Class Inheritance
  • java.lang.Object
  • org.jabref.logic.importer.fileformat.MrDLibImporter.RankedBibEntry

Small pair-class to ensure the right order of the recommendations.

Field Summary

Modifier and TypeField and Description
public BibEntry
public Integer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

entryback to summary
public BibEntry entry
rankback to summary
public Integer rank

Constructor Detail

RankedBibEntryback to summary
public RankedBibEntry(BibEntry entry, Integer rank)