Package org.intermine.objectstore.query
Class QueryObjectPathExpression
- java.lang.Object
-
- org.intermine.objectstore.query.QueryObjectPathExpression
-
- All Implemented Interfaces:
Queryable
,QueryPathExpression
,QueryPathExpressionWithSelect
,QuerySelectable
public class QueryObjectPathExpression extends java.lang.Object implements QueryPathExpressionWithSelect, Queryable
An element that can appear in the SELECT clause of a query, representing extra data to be collected for the Results - namely a object referenced by some other object in the results. In order to reference further into this reference, this class contains many of the features of Query. That is, you can add QueryFields and QueryPathExpressions to the SELECT list. You can also add QueryClasses to the FROM list and constraints to the WHERE clause. A default QueryClass corresponding to the reference is available from the getDefaultClass method. Counter-intuitively, this path expression may return multiple rows per original row, if extra things are added to the FROM list for example. In this case, this object should be on the SELECT list of the original Query. In the case where this object is guaranteed to return a maximum of one row per original row, then PathExpressionField objects should be put in the SELECT list of the original query instead. The definition is that if this object contains anything in the FROM element, then we cannot guarantee that it will only have one row per original row.- Author:
- Matthew Wakeling
-
-
Constructor Summary
Constructors Constructor Description QueryObjectPathExpression(QueryClass qc, java.lang.String fieldName)
Constructs a QueryObjectPathExpression representing an object reference from the given QueryClass to the given fieldname.QueryObjectPathExpression(QueryClass qc, java.lang.String fieldName, java.lang.Class<?>... subclasses)
Constructs a QueryObjectPathExpression representing an object reference from the given QueryClass to the given fieldname, constrained to be a particular subclass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addToSelect(QuerySelectable selectable)
Adds an element to the SELECT list.Constraint
getConstraint()
Returns the additional constraint.QueryClass
getDefaultClass()
Returns the QueryClass that represents the collection in this object.java.lang.String
getFieldName()
Returns the name of the field.Query
getQuery(java.util.Collection<java.lang.Integer> bag, boolean isNoNotXml)
Returns the Query that will fetch the data represented by this object, given a Collection of objects to fetch it for.QueryClass
getQueryClass()
Returns the QueryClass of which the field is a member.java.util.List<QuerySelectable>
getSelect()
Returns the SELECT list.java.lang.Class<? extends FastPathObject>
getSubclass()
Returns the subclass if it exists.java.lang.Class<?>
getType()
Get Java type represented by this item.void
setConstraint(Constraint c)
Sets the additional constraint.
-
-
-
Constructor Detail
-
QueryObjectPathExpression
public QueryObjectPathExpression(QueryClass qc, java.lang.String fieldName)
Constructs a QueryObjectPathExpression representing an object reference from the given QueryClass to the given fieldname.- Parameters:
qc
- the QueryClass of the starting classfieldName
- the name of field in qc we want to perform an outer join on- Throws:
java.lang.IllegalArgumentException
- if the field is not an object reference
-
QueryObjectPathExpression
public QueryObjectPathExpression(QueryClass qc, java.lang.String fieldName, java.lang.Class<?>... subclasses)
Constructs a QueryObjectPathExpression representing an object reference from the given QueryClass to the given fieldname, constrained to be a particular subclass.- Parameters:
qc
- the QueryClassfieldName
- the name of the relevant fieldsubclasses
- a Class that is a subclass of the field class- Throws:
java.lang.IllegalArgumentException
- if the field is not an object reference
-
-
Method Detail
-
getQueryClass
public QueryClass getQueryClass()
Returns the QueryClass of which the field is a member.- Specified by:
getQueryClass
in interfaceQueryPathExpressionWithSelect
- Returns:
- the QueryClass
-
getFieldName
public java.lang.String getFieldName()
Returns the name of the field.- Returns:
- field name
-
getSubclass
public java.lang.Class<? extends FastPathObject> getSubclass()
Returns the subclass if it exists.- Returns:
- the subclass
-
getType
public java.lang.Class<?> getType()
Get Java type represented by this item.- Specified by:
getType
in interfaceQuerySelectable
- Returns:
- class describing the type
-
getDefaultClass
public QueryClass getDefaultClass()
Returns the QueryClass that represents the collection in this object.- Returns:
- a QueryClass
-
addToSelect
public void addToSelect(QuerySelectable selectable)
Adds an element to the SELECT list. If the SELECT list is left empty, then the collection will use default behaviour.- Specified by:
addToSelect
in interfaceQueryable
- Specified by:
addToSelect
in interfaceQueryPathExpressionWithSelect
- Parameters:
selectable
- a QuerySelectable
-
getSelect
public java.util.List<QuerySelectable> getSelect()
Returns the SELECT list.
-
setConstraint
public void setConstraint(Constraint c)
Sets the additional constraint.- Specified by:
setConstraint
in interfaceQueryable
- Parameters:
c
- a Constraint
-
getConstraint
public Constraint getConstraint()
Returns the additional constraint.- Specified by:
getConstraint
in interfaceQueryable
- Returns:
- a Constraint
-
getQuery
public Query getQuery(java.util.Collection<java.lang.Integer> bag, boolean isNoNotXml)
Returns the Query that will fetch the data represented by this object, given a Collection of objects to fetch it for.- Parameters:
bag
- a Collection of objects to fetch data for, or null to not constrainisNoNotXml
- true if the database is in missingNotXml mode- Returns:
- a Query
-
-