Class QueryResultService

  • Direct Known Subclasses:
    TableRowService, TemplateResultService

    public class QueryResultService
    extends AbstractQueryService
    Executes query and returns results. Other parameters in request can specify range of returned results, format ... For using of web service and parameter description see InterMine wiki pages. 1) Validates parameters and tries validate xml query as much as possible. Validates xml query according to XML Schema and and finds out if there were some errors during unmarshalling PathQuery from xml. 2) Executes created PathQuery. 3) Print results to output.
    Author:
    Jakub Kulaviak, Alex Kalderimis
    • Field Detail

      • attributes

        protected java.util.Map<java.lang.String,​java.lang.Object> attributes
    • Constructor Detail

      • QueryResultService

        public QueryResultService​(InterMineAPI im)
        Constructor
        Parameters:
        im - The InterMineAPI settings bundle for this webservice
    • Method Detail

      • execute

        protected void execute()
        Executes service specific logic.
        Specified by:
        execute in class WebService
      • initState

        protected void initState()
        Description copied from class: WebService
        Subclasses can put initialisation here.
        Overrides:
        initState in class WebService
      • getDefaultFormat

        protected Format getDefaultFormat()
        Overrides:
        getDefaultFormat in class WebService
        Returns:
        The default format constant for this service.
      • canServe

        protected boolean canServe​(Format format)
        Description copied from class: WebService
        Check whether the format is acceptable. By default returns true. Services with a particular set of accepted formats should override this and check.
        Overrides:
        canServe in class WebService
        Parameters:
        format - The format to check.
        Returns:
        whether or not this format is acceptable.
      • postInit

        protected void postInit()
        Description copied from class: WebService
        Subclasses can hook in here to do common behaviour that needs to happen after initialisation.
        Overrides:
        postInit in class WebService
      • writeDataPackageAttributes

        protected void writeDataPackageAttributes()
        Writes dataPackageAttributes in the output stream.
      • setHeaderAttributes

        protected void setHeaderAttributes​(PathQuery pq,
                                           java.lang.Integer start,
                                           java.lang.Integer size)
        Set the header attributes of the output based on the values of the PathQuery
        Parameters:
        pq - The path query to be run
        start - The beginning of this set of results
        size - The size of this set of results
      • makeJSONOutput

        protected Output makeJSONOutput​(java.io.PrintWriter out,
                                        java.lang.String separator)
        Description copied from class: WebService
        Make the default JSON output given the HttpResponse's PrintWriter.
        Overrides:
        makeJSONOutput in class WebService
        Parameters:
        out - The PrintWriter from the HttpResponse.
        separator - The line-separator for the client's platform.
        Returns:
        An Output that produces good JSON.
      • encode

        protected static java.lang.String encode​(java.lang.Object o)
        URL Encode an object. Null values are returned as the empty string, and encoding problems throw runtime exceptions.
        Parameters:
        o - The thing to encode.
        Returns:
        The encoded version.
      • runPathQuery

        public void runPathQuery​(PathQuery pathQuery,
                                 int firstResult,
                                 int maxResults)
        Runs path query and returns to output obtained results.
        Parameters:
        pathQuery - path query
        firstResult - index of first result, that should be returned
        maxResults - maximum number of results
      • getPathQueryExecutor

        protected PathQueryExecutor getPathQueryExecutor()
        Return the PathQueryExecutor
        Returns:
        the PathQueryExecutor
      • getFormatType

        protected java.lang.String getFormatType()
        Returns:
        the format requested by user for results file