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

public abstract Class AbstractQueryTransformer

extends Object
Class Inheritance
Known Direct Subclasses
org.jabref.logic.importer.fetcher.transformers.BiodiversityLibraryTransformer, org.jabref.logic.importer.fetcher.transformers.CiteSeerQueryTransformer, org.jabref.logic.importer.fetcher.transformers.CollectionOfComputerScienceBibliographiesQueryTransformer, org.jabref.logic.importer.fetcher.transformers.DefaultLuceneQueryTransformer, org.jabref.logic.importer.fetcher.transformers.JstorQueryTransformer, org.jabref.logic.importer.fetcher.transformers.LOBIDQueryTransformer, org.jabref.logic.importer.fetcher.transformers.MedlineQueryTransformer, org.jabref.logic.importer.fetcher.transformers.ResearchGateQueryTransformer, org.jabref.logic.importer.fetcher.transformers.ScholarArchiveQueryTransformer, org.jabref.logic.importer.fetcher.transformers.SpringerQueryTransformer, org.jabref.logic.importer.fetcher.transformers.YearRangeByFilteringQueryTransformer, org.jabref.logic.importer.fetcher.transformers.ZbMathQueryTransformer
Imports
java.util.Optional, .StringJoiner, java.util.stream.Collectors, org.jabref.model.strings.StringUtil, org.apache.lucene.queryparser.flexible.core.nodes.BooleanQueryNode, org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode, org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode, org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode, org.apache.lucene.queryparser.flexible.core.nodes.OrQueryNode, org.apache.lucene.queryparser.flexible.core.nodes.QueryNode, org.slf4j.Logger, .LoggerFactory

In case the transformer contains state for a query transformation (such as the IEEEQueryTransformer), it has to be noted at the JavaDoc. Otherwise, a single instance QueryTransformer can be used.

Field Summary

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

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected String
createKeyValuePair(String fieldAsString, String term)

protected String
createKeyValuePair(String fieldAsString, String term, String separator)

protected abstract String
getLogicalAndOperator()

Returns the logical AND operator used by the library Note: whitespaces have to be included around the operator Example: " AND "

protected abstract String
getLogicalNotOperator()

Returns the logical NOT operator used by the library Example: "!"

protected abstract String
getLogicalOrOperator()

Returns the logical OR operator used by the library Note: whitespaces have to be included around the operator Example: " OR "

protected abstract String
handleAuthor(String author)

Return a string representation of the author fielded term

protected String
protected abstract String
handleJournal(String journalTitle)

Return a string representation of the journal fielded term

protected Optional<String>
handleOtherField(String fieldAsString, String term)

Return a string representation of the provided field If it is not supported return an empty optional.

protected abstract String
handleTitle(String title)

Return a string representation of the title fielded term

protected Optional<String>
handleUnFieldedTerm(String term)

Return a string representation of the un-fielded (default fielded) term

Default implementation: just return the term (in quotes if a space is contained)

protected abstract String
handleYear(String year)

Return a string representation of the year fielded term

protected String
handleYearRange(String yearRange)

Return a string representation of the year-range fielded term Should follow the structure yyyy-yyyy Example: 2015-2021

protected void
parseYearRange(String yearRange)

Parses the year range and fills startYear and endYear.

private String
removeOuterBraces(String query)

Removes the outer braces as they are unnecessary

protected Optional<String>
transform(org.apache.lucene.queryparser.flexible.core.nodes.BooleanQueryNode query)

Transforms a and b and c to (a AND b AND c), where a, b, and c can be complex expressions.

private Optional<String>
transform(org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode query)

private Optional<String>
transform(org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode query)

Handles the not modifier, all other cases are silently ignored

protected Optional<String>
transform(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode query)

public Optional<String>

Returns:

A query string containing all fields that are contained in the original lucene query and that are expressible in the library specific query language, other information either is discarded or stored as part of the state of the transformer if it can be used e.g. as a URL parameter for the query.
transformLuceneQuery
(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode
The lucene query tp transform
luceneQuery
)

Parses the given query string into a complex query using lucene.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

endYearback to summary
protected int endYear
LOGGERback to summary
private static final Logger LOGGER
NO_EXPLICIT_FIELDback to summary
public static final String NO_EXPLICIT_FIELD
startYearback to summary
protected int startYear

Constructor Detail

AbstractQueryTransformerback to summary
public AbstractQueryTransformer()

Method Detail

createKeyValuePairback to summary
protected String createKeyValuePair(String fieldAsString, String term)
createKeyValuePairback to summary
protected String createKeyValuePair(String fieldAsString, String term, String separator)
getLogicalAndOperatorback to summary
protected abstract String getLogicalAndOperator()

Returns the logical AND operator used by the library Note: whitespaces have to be included around the operator Example: " AND "

getLogicalNotOperatorback to summary
protected abstract String getLogicalNotOperator()

Returns the logical NOT operator used by the library Example: "!"

getLogicalOrOperatorback to summary
protected abstract String getLogicalOrOperator()

Returns the logical OR operator used by the library Note: whitespaces have to be included around the operator Example: " OR "

handleAuthorback to summary
protected abstract String handleAuthor(String author)

Return a string representation of the author fielded term

handleDoiback to summary
protected String handleDoi(String term)
handleJournalback to summary
protected abstract String handleJournal(String journalTitle)

Return a string representation of the journal fielded term

handleOtherFieldback to summary
protected Optional<String> handleOtherField(String fieldAsString, String term)

Return a string representation of the provided field If it is not supported return an empty optional.

handleTitleback to summary
protected abstract String handleTitle(String title)

Return a string representation of the title fielded term

handleUnFieldedTermback to summary
protected Optional<String> handleUnFieldedTerm(String term)

Return a string representation of the un-fielded (default fielded) term

Default implementation: just return the term (in quotes if a space is contained)

handleYearback to summary
protected abstract String handleYear(String year)

Return a string representation of the year fielded term

handleYearRangeback to summary
protected String handleYearRange(String yearRange)

Return a string representation of the year-range fielded term Should follow the structure yyyy-yyyy Example: 2015-2021

parseYearRangeback to summary
protected void parseYearRange(String yearRange)

Parses the year range and fills startYear and endYear. Ensures that startYear <= endYear

removeOuterBracesback to summary
private String removeOuterBraces(String query)

Removes the outer braces as they are unnecessary

transformback to summary
protected Optional<String> transform(org.apache.lucene.queryparser.flexible.core.nodes.BooleanQueryNode query)

Transforms a and b and c to (a AND b AND c), where a, b, and c can be complex expressions.

transformback to summary
private Optional<String> transform(org.apache.lucene.queryparser.flexible.core.nodes.FieldQueryNode query)
transformback to summary
private Optional<String> transform(org.apache.lucene.queryparser.flexible.core.nodes.ModifierQueryNode query)

Handles the not modifier, all other cases are silently ignored

transformback to summary
protected Optional<String> transform(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode query)
transformLuceneQueryback to summary
public Optional<String> transformLuceneQuery(org.apache.lucene.queryparser.flexible.core.nodes.QueryNode luceneQuery)

Parses the given query string into a complex query using lucene.

Note

For unique fields, the alphabetically and numerically first instance in the query string is used in the complex query.

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

The lucene query tp transform

Returns:Optional<String>

A query string containing all fields that are contained in the original lucene query and that are expressible in the library specific query language, other information either is discarded or stored as part of the state of the transformer if it can be used e.g. as a URL parameter for the query.