org.intermine.api.results
Class WebResults

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
          extended by 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.


Field Summary
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
           
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
WebResults(PathQuery pathQuery, Results results, Model model, java.util.Map<java.lang.String,QuerySelectable> pathToQueryNode, java.util.Map<java.lang.String,java.util.List<FieldDescriptor>> classKeys, java.util.Map<java.lang.String,BagQueryResult> pathToBagQueryResult)
          Create a new WebResults object.
 
Method Summary
 void addColumns(java.util.List<Path> columnPaths)
          Adds columns that should be displayed to the table.
 MultiRow<ResultsRow<MultiRowValue<ResultElement>>> get(int index)
          
 java.util.List getColumnNames()
          Return the names of the columns of the results.
 java.util.List getColumns()
          Returns the columns for these results.
 int getEstimatedSize()
          Get the estimated number of rows of this table
 ResultsInfo 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 WebTable
 java.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 query
 java.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 estimate
 java.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
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray
 

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(PathQuery pathQuery,
                  Results results,
                  Model model,
                  java.util.Map<java.lang.String,QuerySelectable> pathToQueryNode,
                  java.util.Map<java.lang.String,java.util.List<FieldDescriptor>> classKeys,
                  java.util.Map<java.lang.String,BagQueryResult> pathToBagQueryResult)
Create a new WebResults object.

Parameters:
pathQuery - used to get the paths of the columns
results - the underlying Results object
model - the Model
pathToQueryNode - the mapping between Paths (in the columnPaths argument) and the QueryNodes in the results object
classKeys - the Map from class name to set of defined keys
pathToBagQueryResult - 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 interface WebTable
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 getColumnNames()
Return the names of the columns of the results.

Returns:
the column name

addColumns

public void addColumns(java.util.List<Path> columnPaths)
Adds columns that should be displayed to the table.

Parameters:
columnPaths - 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 interface java.util.List<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
Specified by:
get in class java.util.AbstractList<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>

getEstimatedSize

public int getEstimatedSize()
Get the estimated number of rows of this table

Specified by:
getEstimatedSize in interface WebTable
Returns:
the number of rows

isSizeEstimate

public boolean isSizeEstimate()
Check whether the result of getEstimatedSize() is an estimate

Specified by:
isSizeEstimate in interface WebTable
Returns:
true if the size is an estimate

size

public int size()

Specified by:
size in interface java.util.Collection<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
Specified by:
size in interface java.util.List<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
Specified by:
size in class java.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 interface WebTable
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 interface WebTable
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 interface WebTable
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 interface WebTable
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 interface java.lang.Iterable<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
Specified by:
iterator in interface java.util.Collection<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
Specified by:
iterator in interface java.util.List<MultiRow<ResultsRow<MultiRowValue<ResultElement>>>>
Overrides:
iterator in class java.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 getColumns()
Returns the columns for these results.

Specified by:
getColumns in interface WebTable
Returns:
the columns

getPathQuery

public PathQuery getPathQuery()
Description copied from interface: WebTable
Get the PathQuery associated with this WebTable

Specified by:
getPathQuery in interface WebTable
Returns:
path query