Class MCRQuery

java.lang.Object
org.mycore.services.fieldquery.MCRQuery

public class MCRQuery extends Object
Represents a query with its condition and optional parameters
  • Constructor Details

    • MCRQuery

      public MCRQuery(MCRCondition<Void> cond)
      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 conditions
      sortBy - a list of MCRSortBy criteria for sorting the results
      maxResults - the maximum number of results to return
      returnFields - the return fields for the SOLR parameter fl
  • Method Details

    • getCondition

      public MCRCondition<Void> 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

      public void setMaxResults(String maxResultsString)
      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

      public void setNumPerPage(String numPerPageString)
      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

      public List<MCRSortBy> getSortBy()
      Returns the list of MCRSortBy criteria for sorting query results
      Returns:
      a list of MCRSortBy objects, may be empty
    • setSortBy

      public void setSortBy(List<MCRSortBy> sortBy)
      Sets the sort criteria for the query results
      Parameters:
      sortBy - a list of MCRSortBy objects, may be empty
    • setSortBy

      public void setSortBy(MCRSortBy sortBy)
      Sets the sort criteria for the query results
      Parameters:
      sortBy - a MCRSortBy object
    • getReturnFields

      public List<String> getReturnFields()
      Returns the list of SOLR-fields they should return for a query results
      Returns:
      a list of field names, may be empty
    • getReturnFieldsAsString

      public String 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

      public void setReturnFields(List<String> returnFields)
      Sets the return fields list for the query results
      Parameters:
      returnFields - a list of SOLR return fields, may be empty
    • setReturnFields

      public void setReturnFields(String returnFields)
      Sets the return fields as String for the query results
      Parameters:
      returnFields - a CSV-list of SOLR return fields, may be empty
    • buildXML

      public Document buildXML()
      Builds a XML representation of the query
      Returns:
      a XML document containing all query parameters
    • parseXML

      public static MCRQuery parseXML(Document doc)
      Parses a XML representation of a query.
      Parameters:
      doc - the XML document
      Returns:
      the parsed MCRQuery