Package org.intermine.api.results
Class WebResults
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
-
- org.intermine.api.results.WebResults
-
- All Implemented Interfaces:
java.lang.Iterable<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
,java.util.Collection<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
,java.util.List<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
,WebTable
public class WebResults extends java.util.AbstractList<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>> implements WebTable
The web version of a Results object. This class handles the mapping between the paths that user selected for the view and the objects that are returned from the query.- Author:
- Kim Rutherford
-
-
Field Summary
Fields Modifier and Type Field Description static int
BIG_BATCH_SIZE
The batch size to use when we need to iterate through the whole result set.protected static org.apache.log4j.Logger
LOG
protected Model
model
protected java.util.LinkedHashMap<java.lang.String,java.lang.Integer>
pathToIndex
-
Constructor Summary
Constructors Constructor Description WebResults(InterMineAPI im, PathQuery pathQuery, Results results, java.util.Map<java.lang.String,QuerySelectable> pathToQueryNode, java.util.Map<java.lang.String,BagQueryResult> pathToBagQueryResult)
Create a new WebResults object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addColumns(java.util.List<Path> paths)
Adds columns that should be displayed to the table.MultiRow<ResultsRow<MultiRowValue<ResultElement>>>
get(int index)
java.util.List<java.lang.String>
getColumnNames()
Return the names of the columns of the results.java.util.List<Column>
getColumns()
Returns the columns for these results.java.util.List<Path>
getColumnsPath()
int
getEstimatedSize()
Get the estimated number of rows of this tableResultsInfo
getInfo()
Return the ResultsInfo object from the underlying Results object.Results
getInterMineResults()
Return the underlying results object.int
getMaxRetrievableIndex()
Returns the ObjectStore's maximum allowable offset.PathQuery
getPathQuery()
Get the PathQuery associated with this WebTablejava.util.Map<java.lang.String,BagQueryResult>
getPathToBagQueryResult()
Returns the pathToBagQueryResult Map.protected java.util.LinkedHashMap<java.lang.String,java.lang.Integer>
getPathToIndex()
Create a map from string paths to index of QueryNodes in the ObjectStore queryjava.util.Map<java.lang.String,QuerySelectable>
getPathToQueryNode()
Returns the pathToQueryNode Map.MultiRow<ResultsRow<MultiRowValue<ResultElement>>>
getResultElements(int index)
Return a List containing a ResultElement object for each element in the given row.void
goFaster()
Calls ObjectStore.goFaster() if this object wraps a Results object from an ObjectStoreInterMineImpl.boolean
isSingleBatch()
Returns true if the results are known to be contained in a single batch.boolean
isSizeEstimate()
Check whether the result of getEstimatedSize() is an estimatejava.util.Iterator<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
iterator()
java.util.Iterator<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
iteratorFrom(int start)
void
releaseGoFaster()
Calls ObjectStore.releaseGoFaster() if this object wraps a Results object from an ObjectStoreInterMineImpl.int
size()
-
Methods inherited from class java.util.AbstractList
add, add, addAll, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
-
-
-
Field Detail
-
LOG
protected static final org.apache.log4j.Logger LOG
-
pathToIndex
protected java.util.LinkedHashMap<java.lang.String,java.lang.Integer> pathToIndex
-
model
protected Model model
-
BIG_BATCH_SIZE
public static final int BIG_BATCH_SIZE
The batch size to use when we need to iterate through the whole result set.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WebResults
public WebResults(InterMineAPI im, PathQuery pathQuery, Results results, java.util.Map<java.lang.String,QuerySelectable> pathToQueryNode, java.util.Map<java.lang.String,BagQueryResult> pathToBagQueryResult)
Create a new WebResults object.- Parameters:
pathQuery
- used to get the paths of the columnsresults
- the underlying Results objectim
- intermine APIpathToQueryNode
- the mapping between Paths (in the columnPaths argument) and the QueryNodes in the results objectpathToBagQueryResult
- a Map containing results from LOOKUP operations
-
-
Method Detail
-
isSingleBatch
public boolean isSingleBatch()
Returns true if the results are known to be contained in a single batch. If true, then it would not be sensible to perform precomputing.- Specified by:
isSingleBatch
in interfaceWebTable
- Returns:
- a boolean
-
getPathToIndex
protected java.util.LinkedHashMap<java.lang.String,java.lang.Integer> getPathToIndex()
Create a map from string paths to index of QueryNodes in the ObjectStore query- Returns:
- a map from string paths to the index of QueryNodes
-
getColumnNames
public java.util.List<java.lang.String> getColumnNames()
Return the names of the columns of the results.- Returns:
- the column name
-
addColumns
public void addColumns(java.util.List<Path> paths)
Description copied from interface:WebTable
Adds columns that should be displayed to the table.- Specified by:
addColumns
in interfaceWebTable
- Parameters:
paths
- columns correspond to paths and columns for these paths should be added
-
get
public MultiRow<ResultsRow<MultiRowValue<ResultElement>>> get(int index)
- Specified by:
get
in interfacejava.util.List<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
- Specified by:
get
in classjava.util.AbstractList<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
-
getEstimatedSize
public int getEstimatedSize()
Get the estimated number of rows of this table- Specified by:
getEstimatedSize
in interfaceWebTable
- Returns:
- the number of rows
-
isSizeEstimate
public boolean isSizeEstimate()
Check whether the result of getEstimatedSize() is an estimate- Specified by:
isSizeEstimate
in interfaceWebTable
- Returns:
- true if the size is an estimate
-
size
public int size()
- Specified by:
size
in interfacejava.util.Collection<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
- Specified by:
size
in interfacejava.util.List<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
- Specified by:
size
in classjava.util.AbstractCollection<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
-
getInfo
public ResultsInfo getInfo() throws ObjectStoreException
Return the ResultsInfo object from the underlying Results object.- Specified by:
getInfo
in interfaceWebTable
- Returns:
- the ResultsInfo object
- Throws:
ObjectStoreException
- if there is an exception while getting the info
-
getInterMineResults
public Results getInterMineResults()
Return the underlying results object.- Returns:
- the results
-
getPathToQueryNode
public java.util.Map<java.lang.String,QuerySelectable> getPathToQueryNode()
Returns the pathToQueryNode Map.- Returns:
- a Map
-
getPathToBagQueryResult
public java.util.Map<java.lang.String,BagQueryResult> getPathToBagQueryResult()
Returns the pathToBagQueryResult Map.- Specified by:
getPathToBagQueryResult
in interfaceWebTable
- Returns:
- a Map
-
goFaster
public void goFaster() throws ObjectStoreException
Calls ObjectStore.goFaster() if this object wraps a Results object from an ObjectStoreInterMineImpl.- Throws:
ObjectStoreException
- if ObjectStoreInterMineImpl.goFaster() throws the exception
-
releaseGoFaster
public void releaseGoFaster() throws ObjectStoreException
Calls ObjectStore.releaseGoFaster() if this object wraps a Results object from an ObjectStoreInterMineImpl.- Throws:
ObjectStoreException
- if ObjectStoreInterMineImpl.releaseGoFaster() throws the exception
-
getMaxRetrievableIndex
public int getMaxRetrievableIndex()
Returns the ObjectStore's maximum allowable offset.- Specified by:
getMaxRetrievableIndex
in interfaceWebTable
- Returns:
- an int
-
getResultElements
public MultiRow<ResultsRow<MultiRowValue<ResultElement>>> getResultElements(int index)
Return a List containing a ResultElement object for each element in the given row. The List will be the same length as the view List.- Specified by:
getResultElements
in interfaceWebTable
- Parameters:
index
- the row of the results to fetch- Returns:
- the results row as ResultElement objects
-
iterator
public java.util.Iterator<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>> iterator()
- Specified by:
iterator
in interfacejava.util.Collection<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
- Specified by:
iterator
in interfacejava.lang.Iterable<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
- Specified by:
iterator
in interfacejava.util.List<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
- Overrides:
iterator
in classjava.util.AbstractList<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
- Returns:
- iterator over results
-
iteratorFrom
public java.util.Iterator<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>> iteratorFrom(int start)
- Parameters:
start
- - first index from which start iteration- Returns:
- iterator over results
-
getColumns
public java.util.List<Column> getColumns()
Returns the columns for these results.- Specified by:
getColumns
in interfaceWebTable
- Returns:
- the columns
-
getColumnsPath
public java.util.List<Path> getColumnsPath()
- Specified by:
getColumnsPath
in interfaceWebTable
- Returns:
- The paths for the displayed columns.
-
getPathQuery
public PathQuery getPathQuery()
Description copied from interface:WebTable
Get the PathQuery associated with this WebTable- Specified by:
getPathQuery
in interfaceWebTable
- Returns:
- path query
-
-