Class QueryResultService
- java.lang.Object
-
- org.intermine.webservice.server.WebService
-
- org.intermine.webservice.server.query.AbstractQueryService
-
- org.intermine.webservice.server.query.result.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 Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.Object>
attributes
static int
BATCH_SIZE
Batch size to useprotected PathQueryExecutor
executor
-
Fields inherited from class org.intermine.webservice.server.WebService
dataPackageOutput, DEFAULT_CALLBACK, im, os, out, output, request, response, webProperties
-
-
Constructor Summary
Constructors Constructor Description QueryResultService(InterMineAPI im)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canServe(Format format)
Check whether the format is acceptable.protected static java.lang.String
encode(java.lang.Object o)
URL Encode an object.protected void
execute()
Executes service specific logic.protected Format
getDefaultFormat()
protected java.lang.String
getFormatType()
protected PathQueryExecutor
getPathQueryExecutor()
Return the PathQueryExecutorprotected void
initState()
Subclasses can put initialisation here.protected Output
makeJSONOutput(java.io.PrintWriter out, java.lang.String separator)
Make the default JSON output given the HttpResponse's PrintWriter.protected void
postInit()
Subclasses can hook in here to do common behaviour that needs to happen after initialisation.void
runPathQuery(PathQuery pathQuery, int firstResult, int maxResults)
Runs path query and returns to output obtained results.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 PathQueryprotected void
writeDataPackageAttributes()
Writes dataPackageAttributes in the output stream.-
Methods inherited from class org.intermine.webservice.server.query.AbstractQueryService
formatIsJsonObj, getQueryBuilder, getSchemaLocation, getSchemaUrl
-
Methods inherited from class org.intermine.webservice.server.WebService
cleanUp, formatIsFlatFile, formatIsJSON, formatIsJSONP, formatIsXML, getAuthenticatedUser, getCallback, getColumnHeaderStyle, getDefaultFileName, getDefaultOutput, getDefaultOutput, getExtension, getFormat, getIntParameter, getIntParameter, getLineBreak, getListManager, getOptionalParameter, getOptionalParameter, getPermission, getProperty, getRawOutput, getRequestFileName, getRequiredParameter, hasCallback, isAuthenticated, isGzip, isUncompressed, isZip, makeXMLOutput, service, setFormat, setNameSpace, validateState, wantsColumnHeaders, wantsDataPackage
-
-
-
-
Field Detail
-
BATCH_SIZE
public static final int BATCH_SIZE
Batch size to use- See Also:
- Constant Field Values
-
attributes
protected java.util.Map<java.lang.String,java.lang.Object> attributes
-
executor
protected PathQueryExecutor executor
-
-
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 classWebService
-
initState
protected void initState()
Description copied from class:WebService
Subclasses can put initialisation here.- Overrides:
initState
in classWebService
-
getDefaultFormat
protected Format getDefaultFormat()
- Overrides:
getDefaultFormat
in classWebService
- 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 classWebService
- 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 classWebService
-
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 runstart
- The beginning of this set of resultssize
- 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 classWebService
- 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 queryfirstResult
- index of first result, that should be returnedmaxResults
- 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
-
-