Class ResultsConverter
- java.lang.Object
-
- org.intermine.objectstore.intermine.ResultsConverter
-
public final class ResultsConverter extends java.lang.Object
Provides a method to convert from SQL ResultSet data to InterMine object-based data.- Author:
- Matthew Wakeling, Andrew Varley
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static java.lang.Object
buildObject(java.sql.ResultSet sqlResults, java.lang.String alias, ObjectStoreInterMineImpl os, java.lang.Class<?> type, java.util.Set<java.lang.String> noObjectClassColumns)
Builds an object from separate fields in flat mode.static java.util.List<ResultsRow<java.lang.Object>>
convert(java.sql.ResultSet sqlResults, Query q, ObjectStoreInterMineImpl os, java.sql.Connection c, java.util.Map<java.lang.Object,java.lang.Integer> sequence, boolean optimise, ExtraQueryTime extra, java.util.Set<PrecomputedTable> goFasterTables, OptimiserCache goFasterCache)
Method to convert from SQL results to InterMine object-based results.protected static java.util.Map<java.lang.Integer,InterMineObject>
fetchByIds(ObjectStoreInterMineImpl os, java.sql.Connection c, java.util.Map<java.lang.Object,java.lang.Integer> sequence, java.lang.Class<?> clazz, java.util.Collection<java.lang.Integer> idsToFetch, ExtraQueryTime extra)
Fetches a group of objects from the database by ID.protected static void
fetchCollectionPathExpression(ObjectStoreInterMineImpl os, java.sql.Connection c, java.util.Map<java.lang.Object,java.lang.Integer> sequence, Query q, QueryCollectionPathExpression qcpe, java.util.List<ResultsRow<java.lang.Object>> retval, boolean optimise, ExtraQueryTime extra, java.util.Set<PrecomputedTable> goFasterTables, OptimiserCache goFasterCache)
Fetches the QueryCollectionPathExpression data for a query.protected static void
fetchObjectPathExpression(ObjectStoreInterMineImpl os, java.sql.Connection c, java.util.Map<java.lang.Object,java.lang.Integer> sequence, Query q, QueryObjectPathExpression qope, java.util.List<ResultsRow<java.lang.Object>> retval, boolean optimise, ExtraQueryTime extra, java.util.Set<PrecomputedTable> goFasterTables, OptimiserCache goFasterCache)
Fetches the contents of a QueryObjectPathExpression for a query.
-
-
-
Method Detail
-
convert
public static java.util.List<ResultsRow<java.lang.Object>> convert(java.sql.ResultSet sqlResults, Query q, ObjectStoreInterMineImpl os, java.sql.Connection c, java.util.Map<java.lang.Object,java.lang.Integer> sequence, boolean optimise, ExtraQueryTime extra, java.util.Set<PrecomputedTable> goFasterTables, OptimiserCache goFasterCache) throws ObjectStoreException
Method to convert from SQL results to InterMine object-based results. This method accepts an SQL ResultSet and a Query as an input. The ResultSet must contain a column named the same as the aliases of the elements in the SELECT list of the Query, each containing either the OBJECT column in the case of a business object, or the value of any other value.
This method will return a List of ResultsRow objects.- Parameters:
sqlResults
- the ResultSetq
- the Queryos
- the ObjectStoreInterMineImpl with which to associate any new lazy objectsc
- a Connection with which to make extra requestssequence
- an object representing the state of the databaseoptimise
- whether to use optimisation on path expression queriesextra
- object to record extra query execution timegoFasterTables
- a Set of PrecomputedTables that may help with extra queriesgoFasterCache
- an OptimiserCache that may help with extra queries- Returns:
- a List of ResultsRow objects
- Throws:
ObjectStoreException
- if the ResultSet does not match the Query in any way, or if a SQL exception occurs
-
buildObject
protected static java.lang.Object buildObject(java.sql.ResultSet sqlResults, java.lang.String alias, ObjectStoreInterMineImpl os, java.lang.Class<?> type, java.util.Set<java.lang.String> noObjectClassColumns) throws java.sql.SQLException
Builds an object from separate fields in flat mode.- Parameters:
sqlResults
- the SQL ResultSetalias
- the name of the column being builtos
- the ObjectStoretype
- a Class matching the QueryClass that is this columnnoObjectClassColumns
- a Set used internally- Returns:
- an InterMineObject
- Throws:
java.sql.SQLException
- if something goes wrong
-
fetchObjectPathExpression
protected static void fetchObjectPathExpression(ObjectStoreInterMineImpl os, java.sql.Connection c, java.util.Map<java.lang.Object,java.lang.Integer> sequence, Query q, QueryObjectPathExpression qope, java.util.List<ResultsRow<java.lang.Object>> retval, boolean optimise, ExtraQueryTime extra, java.util.Set<PrecomputedTable> goFasterTables, OptimiserCache goFasterCache) throws ObjectStoreException
Fetches the contents of a QueryObjectPathExpression for a query.- Parameters:
os
- the ObjectStoreInterMineImplc
- the Connectionsequence
- an object representing the state of the databaseq
- the Queryqope
- the QueryObjectPathExpression to fetch data forretval
- the array of results that will be returnedoptimise
- whether to optimise the queryextra
- object to record extra query execution timegoFasterTables
- a Set of PrecomputedTables that may help with extra queriesgoFasterCache
- an OptimiserCache that may help with extra queries- Throws:
ObjectStoreException
- if something goes wrong
-
fetchCollectionPathExpression
protected static void fetchCollectionPathExpression(ObjectStoreInterMineImpl os, java.sql.Connection c, java.util.Map<java.lang.Object,java.lang.Integer> sequence, Query q, QueryCollectionPathExpression qcpe, java.util.List<ResultsRow<java.lang.Object>> retval, boolean optimise, ExtraQueryTime extra, java.util.Set<PrecomputedTable> goFasterTables, OptimiserCache goFasterCache) throws ObjectStoreException
Fetches the QueryCollectionPathExpression data for a query.- Parameters:
os
- the ObjectStoreInterMineImplc
- the Connectionsequence
- an object representing the state of the databaseq
- the Queryqcpe
- the QueryCollectionPathExpression to fetch data forretval
- the array of results that will be returnedoptimise
- whether to optimise the queryextra
- object to record extra query execution timegoFasterTables
- a Set of PrecomputedTables that may help with extra queriesgoFasterCache
- an OptimiserCache that may help with extra queries- Throws:
ObjectStoreException
- if something goes wrong
-
fetchByIds
protected static java.util.Map<java.lang.Integer,InterMineObject> fetchByIds(ObjectStoreInterMineImpl os, java.sql.Connection c, java.util.Map<java.lang.Object,java.lang.Integer> sequence, java.lang.Class<?> clazz, java.util.Collection<java.lang.Integer> idsToFetch, ExtraQueryTime extra) throws ObjectStoreException
Fetches a group of objects from the database by ID.- Parameters:
os
- the ObjectStorec
- the Connectionsequence
- an object representing the state of the databaseclazz
- the class of the table to search inidsToFetch
- a Collection of IDs to fetchextra
- object to record extra query execution time- Returns:
- a Map from ID to object
- Throws:
ObjectStoreException
- if an error occurs
-
-