Package org.intermine.objectstore.query
Class QueryCreator
- java.lang.Object
-
- org.intermine.objectstore.query.QueryCreator
-
public final class QueryCreator extends java.lang.Object
Class that helps build queries or parts of queries for common situations.- Author:
- Andrew Varley
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Query
createQueryForExampleObject(Model model, InterMineObject obj, java.util.Set<java.lang.String> fieldNames)
Generates a query that searches for all objects in the database that have the fieldnames set to the values in the object.static Query
createQueryForId(java.lang.Integer id, java.lang.Class<? extends InterMineObject> clazz)
Create a query that will retrieve an object from the objectstore, given an ID.static Query
createQueryForIds(java.util.Collection<java.lang.Integer> ids, java.lang.Class<? extends InterMineObject> clazz)
Create a query that will retrieve all objects with the given IDs from the objectstore.static Query
createQueryForQueryNodeValues(Query q, QueryNode qn)
Create a query that will list the options for a particular field or class in a query, given the existing constraints
-
-
-
Method Detail
-
createQueryForId
public static Query createQueryForId(java.lang.Integer id, java.lang.Class<? extends InterMineObject> clazz)
Create a query that will retrieve an object from the objectstore, given an ID.- Parameters:
id
- the ID of the object to fetchclazz
- a Class in the object- Returns:
- a Query
-
createQueryForIds
public static Query createQueryForIds(java.util.Collection<java.lang.Integer> ids, java.lang.Class<? extends InterMineObject> clazz)
Create a query that will retrieve all objects with the given IDs from the objectstore.- Parameters:
ids
- a collection of ID to fetchclazz
- a Class in the object- Returns:
- a Query
-
createQueryForQueryNodeValues
public static Query createQueryForQueryNodeValues(Query q, QueryNode qn)
Create a query that will list the options for a particular field or class in a query, given the existing constraintsFor example:
Original query: SELECT c, d FROM Company AS c, Department AS d WHERE c.departments CONTAINS d AND c.name LIKE 'A%' We want to know the possible department names are that we might want to constrain Returned query: SELECT DISTINCT d.name FROM Company AS c, Department AS d WHERE c.departments CONTAINS d AND c.name LIKE 'A%'
- Parameters:
q
- the original queryqn
- the QueryNode that we want to know the values for- Returns:
- the Query that will return the requested values
-
createQueryForExampleObject
public static Query createQueryForExampleObject(Model model, InterMineObject obj, java.util.Set<java.lang.String> fieldNames) throws ObjectStoreException
Generates a query that searches for all objects in the database that have the fieldnames set to the values in the object.- Parameters:
model
- a Modelobj
- the Object to take values fromfieldNames
- the field names to search by- Returns:
- a Query
- Throws:
ObjectStoreException
- if something goes wrong
-
-