Package org.intermine.objectstore.query
Class Query
- java.lang.Object
-
- org.intermine.objectstore.query.Query
-
- All Implemented Interfaces:
FromElement
,HasFromList
,Queryable
public class Query extends java.lang.Object implements FromElement, Queryable, HasFromList
This class provides an implementation-independent abstract representation of a query- Author:
- Mark Woodbridge, Richard Smith, Matthew Wakeling
-
-
Constructor Summary
Constructors Constructor Description Query()
Empty constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFrom(FromElement cls)
Adds a FromElement to the FROM clause of this QueryQuery
addFrom(FromElement cls, java.lang.String alias)
Adds a FromElement to the FROM clause of this QueryQuery
addToGroupBy(QueryNode node)
Add a QueryNode to the GROUP BY clause of this QueryQuery
addToOrderBy(QueryOrderable node)
Add a QueryOrderable to the ORDER BY clause of this QueryQuery
addToOrderBy(QueryOrderable node, java.lang.String direction)
Add a QueryOrderable to the ORDER BY clause of this Queryvoid
addToSelect(QuerySelectable node)
Add a QuerySelectable to the SELECT clause of this QueryQuery
addToSelect(QuerySelectable node, java.lang.String alias)
Add a QuerySelectable to the SELECT clause of this Queryvoid
alias(java.lang.Object obj, java.lang.String alias)
Set an alias for an element in the Query.void
clearOrderBy()
Clears the ORDER BY clause of this Queryvoid
clearSelect()
Clears the SELECT listQuery
deleteFrom(FromElement cls)
Remove a FromElement from the FROM clauseQuery
deleteFromGroupBy(QueryNode node)
Remove a QueryNode from the GROUP BY clauseQuery
deleteFromOrderBy(QueryOrderable node)
Remove a QueryOrderable from the ORDER BY clauseQuery
deleteFromSelect(QuerySelectable node)
Remove a QuerySelectable from the SELECT clausejava.util.Map<java.lang.Object,java.lang.String>
getAliases()
Returns the map of QuerySelectables and FromElements to String aliasesConstraint
getConstraint()
Get the current constraint on this Queryjava.util.List<java.lang.Object>
getEffectiveOrderBy()
Gets the effective ORDER BY clause of this Query, such as may be used to create SQL.java.util.Set<FromElement>
getFrom()
Returns all FromElements in the FROM clausejava.util.Set<QueryNode>
getGroupBy()
Gets the GROUP BY clause of this QueryIqlQuery
getIqlQuery()
Returns an IqlQuery object representing this query, that may have been cached.int
getLimit()
Returns the LIMIT parameter for this query.java.util.List<QueryOrderable>
getOrderBy()
Gets the ORDER BY clause of this Queryjava.util.Map<java.lang.String,java.lang.Object>
getReverseAliases()
Returns the map of String aliases to QuerySelectables and FromElementsjava.util.List<QuerySelectable>
getSelect()
Gets the SELECT listboolean
isDistinct()
Get the value of the distinct propertyvoid
setConstraint(Constraint constraint)
Constrain this Query using either a single constraint or a set of constraintsvoid
setDistinct(boolean distinct)
Set the value of the distinct property, which determines whether duplicates are permitted in the results returned by this Queryvoid
setLimit(int limit)
Sets the LIMIT parameter for this query - note that this is only honoured in a subquery.java.lang.String
toString()
Returns a string representation of this Query object
-
-
-
Method Detail
-
setLimit
public void setLimit(int limit)
Sets the LIMIT parameter for this query - note that this is only honoured in a subquery.- Parameters:
limit
- the new limit parameter - the results will be truncated to this many rows
-
getLimit
public int getLimit()
Returns the LIMIT parameter for this query.- Returns:
- the limit parameter
-
addFrom
public void addFrom(FromElement cls)
Adds a FromElement to the FROM clause of this Query- Specified by:
addFrom
in interfaceHasFromList
- Parameters:
cls
- the FromElement to be added
-
addFrom
public Query addFrom(FromElement cls, java.lang.String alias)
Adds a FromElement to the FROM clause of this Query- Parameters:
cls
- the FromElement to be addedalias
- the alias for this FromElement- Returns:
- the updated Query
-
deleteFrom
public Query deleteFrom(FromElement cls)
Remove a FromElement from the FROM clause- Parameters:
cls
- the FromElement to remove- Returns:
- the updated Query
-
getFrom
public java.util.Set<FromElement> getFrom()
Returns all FromElements in the FROM clause- Returns:
- set of FromElements
-
setConstraint
public void setConstraint(Constraint constraint)
Constrain this Query using either a single constraint or a set of constraints- Specified by:
setConstraint
in interfaceQueryable
- Parameters:
constraint
- the constraint or constraint set
-
getConstraint
public Constraint getConstraint()
Get the current constraint on this Query- Specified by:
getConstraint
in interfaceQueryable
- Returns:
- the constraint
-
addToGroupBy
public Query addToGroupBy(QueryNode node)
Add a QueryNode to the GROUP BY clause of this Query- Parameters:
node
- the node to add- Returns:
- the updated Query
-
deleteFromGroupBy
public Query deleteFromGroupBy(QueryNode node)
Remove a QueryNode from the GROUP BY clause- Parameters:
node
- the node to remove- Returns:
- the updated Query
-
getGroupBy
public java.util.Set<QueryNode> getGroupBy()
Gets the GROUP BY clause of this Query- Returns:
- the set of GROUP BY nodes
-
addToOrderBy
public Query addToOrderBy(QueryOrderable node)
Add a QueryOrderable to the ORDER BY clause of this Query- Parameters:
node
- the node to add- Returns:
- the updated Query
-
addToOrderBy
public Query addToOrderBy(QueryOrderable node, java.lang.String direction)
Add a QueryOrderable to the ORDER BY clause of this Query- Parameters:
node
- the node to adddirection
- ascending or descending- Returns:
- the updated Query
-
deleteFromOrderBy
public Query deleteFromOrderBy(QueryOrderable node)
Remove a QueryOrderable from the ORDER BY clause- Parameters:
node
- the node to remove- Returns:
- the updated Query
-
clearOrderBy
public void clearOrderBy()
Clears the ORDER BY clause of this Query
-
getOrderBy
public java.util.List<QueryOrderable> getOrderBy()
Gets the ORDER BY clause of this Query- Returns:
- the List of ORDER BY nodes
-
getEffectiveOrderBy
public java.util.List<java.lang.Object> getEffectiveOrderBy()
Gets the effective ORDER BY clause of this Query, such as may be used to create SQL.- Returns:
- a List of ORDER BY nodes
-
addToSelect
public void addToSelect(QuerySelectable node)
Add a QuerySelectable to the SELECT clause of this Query- Specified by:
addToSelect
in interfaceQueryable
- Parameters:
node
- the QuerySelectable to add
-
addToSelect
public Query addToSelect(QuerySelectable node, java.lang.String alias)
Add a QuerySelectable to the SELECT clause of this Query- Parameters:
node
- the QuerySelectable to addalias
- the alias for this FromElement- Returns:
- the updated Query
-
deleteFromSelect
public Query deleteFromSelect(QuerySelectable node)
Remove a QuerySelectable from the SELECT clause- Parameters:
node
- the QuerySelectable to remove- Returns:
- the updated Query
-
getSelect
public java.util.List<QuerySelectable> getSelect()
Gets the SELECT list
-
clearSelect
public void clearSelect()
Clears the SELECT list
-
isDistinct
public boolean isDistinct()
Get the value of the distinct property- Returns:
- the value of distinct
-
setDistinct
public void setDistinct(boolean distinct)
Set the value of the distinct property, which determines whether duplicates are permitted in the results returned by this Query- Parameters:
distinct
- the value of distinct
-
getAliases
public java.util.Map<java.lang.Object,java.lang.String> getAliases()
Returns the map of QuerySelectables and FromElements to String aliases- Returns:
- the map
-
getReverseAliases
public java.util.Map<java.lang.String,java.lang.Object> getReverseAliases()
Returns the map of String aliases to QuerySelectables and FromElements- Returns:
- the map
-
toString
public java.lang.String toString()
Returns a string representation of this Query object- Overrides:
toString
in classjava.lang.Object
- Returns:
- a String representation
-
getIqlQuery
public IqlQuery getIqlQuery()
Returns an IqlQuery object representing this query, that may have been cached.- Returns:
- an IqlQuery object
-
alias
public void alias(java.lang.Object obj, java.lang.String alias)
Set an alias for an element in the Query.- Parameters:
obj
- the element to aliasalias
- the alias to give
-
-