Package org.mycore.services.fieldquery
Class MCRQuery
java.lang.Object
org.mycore.services.fieldquery.MCRQuery
Represents a query with its condition and optional parameters
-
Constructor Summary
ConstructorDescriptionMCRQuery
(MCRCondition<Void> cond) Builds a new MCRQuery object without sort criteria and unlimited results.MCRQuery
(MCRCondition<Void> cond, List<MCRSortBy> sortBy, int maxResults, List<String> returnFields) Builds a new MCRQuery object with sort criteria and limited number of results. -
Method Summary
Modifier and TypeMethodDescriptionbuildXML()
Builds a XML representation of the queryReturns the query conditionint
Returns the maximum number of results the query should returnint
Returns the number of results per page that the query should returnReturns the list of SOLR-fields they should return for a query resultsReturns the CSV-list of SOLR-fields they should return for a query resultsReturns the list of MCRSortBy criteria for sorting query resultsstatic MCRQuery
Parses a XML representation of a query.void
setMaxResults
(int maxResults) Sets the maximum number of results the query should return.void
setMaxResults
(String maxResultsString) Sets the maximum number of results the query should return.void
setNumPerPage
(int numPerPage) Sets the number of results per page that the query should return.void
setNumPerPage
(String numPerPageString) Sets the number of results per page that the query should return.void
setReturnFields
(String returnFields) Sets the return fields as String for the query resultsvoid
setReturnFields
(List<String> returnFields) Sets the return fields list for the query resultsvoid
Sets the sort criteria for the query resultsvoid
Sets the sort criteria for the query results
-
Constructor Details
-
MCRQuery
Builds a new MCRQuery object without sort criteria and unlimited results.- Parameters:
cond
- the query conditions
-
MCRQuery
public MCRQuery(MCRCondition<Void> cond, List<MCRSortBy> sortBy, int maxResults, List<String> returnFields) Builds a new MCRQuery object with sort criteria and limited number of results.- Parameters:
cond
- the query conditionssortBy
- a list of MCRSortBy criteria for sorting the resultsmaxResults
- the maximum number of results to returnreturnFields
- the return fields for the SOLR parameter fl
-
-
Method Details
-
getCondition
Returns the query condition- Returns:
- the query condition
-
getMaxResults
public int getMaxResults()Returns the maximum number of results the query should return- Returns:
- the maximum number of results, or 0
-
setMaxResults
public void setMaxResults(int maxResults) Sets the maximum number of results the query should return. Default is 0 which means "return all results".- Parameters:
maxResults
- the maximum number of results
-
setMaxResults
Sets the maximum number of results the query should return. Default is 0 which means "return all results".- Parameters:
maxResultsString
- the maximum number of results as String
-
getNumPerPage
public int getNumPerPage()Returns the number of results per page that the query should return- Returns:
- the number of results per page
-
setNumPerPage
public void setNumPerPage(int numPerPage) Sets the number of results per page that the query should return. Default is 10.- Parameters:
numPerPage
- the number of results per page
-
setNumPerPage
Sets the number of results per page that the query should return. Default is 10.- Parameters:
numPerPageString
- the number of results per page as String
-
getSortBy
Returns the list of MCRSortBy criteria for sorting query results- Returns:
- a list of MCRSortBy objects, may be empty
-
setSortBy
Sets the sort criteria for the query results- Parameters:
sortBy
- a list of MCRSortBy objects, may be empty
-
setSortBy
Sets the sort criteria for the query results- Parameters:
sortBy
- a MCRSortBy object
-
getReturnFields
Returns the list of SOLR-fields they should return for a query results- Returns:
- a list of field names, may be empty
-
getReturnFieldsAsString
Returns the CSV-list of SOLR-fields they should return for a query results- Returns:
- a list of field names, may be empty
-
setReturnFields
Sets the return fields list for the query results- Parameters:
returnFields
- a list of SOLR return fields, may be empty
-
setReturnFields
Sets the return fields as String for the query results- Parameters:
returnFields
- a CSV-list of SOLR return fields, may be empty
-
buildXML
Builds a XML representation of the query- Returns:
- a XML document containing all query parameters
-
parseXML
Parses a XML representation of a query.- Parameters:
doc
- the XML document- Returns:
- the parsed MCRQuery
-