public class BasicQuery extends Object implements Query
BasicQuery(Cloud, BasicSearchQuery).BasicSearchQuery| Modifier and Type | Field and Description |
|---|---|
protected boolean |
aggregating
Whether this Query is aggregating.
|
protected Cloud |
cloud
reference to the cloud.
|
protected List<BasicStepField> |
explicitFields
The explicitely added 'extra' fields.
|
protected List<BasicStepField> |
implicitFields
The implicitely added 'extra' fields.
|
protected Constraint |
insecureConstraint
If a the constraint was made 'secure', in insecureConstraint the original Constraint is
stored.
|
protected BasicSearchQuery |
query
The core query which is 'wrapped'
|
protected Authorization.QueryCheck |
queryCheck
The QueryCheck object associated with this Query, or null if no such object was determined yet.
|
protected boolean |
used
Whether this Query was used already.
|
DEFAULT_MAX_NUMBER, DEFAULT_OFFSET| Constructor and Description |
|---|
BasicQuery(Cloud c) |
BasicQuery(Cloud c,
BasicSearchQuery q) |
BasicQuery(Cloud c,
boolean aggregating) |
| Modifier and Type | Method and Description |
|---|---|
AggregatedField |
addAggregatedField(Step step,
Field field,
int aggregationType)
Add an aggregated field to a step
|
StepField |
addField(Step step,
Field field)
Adds a field to a step.
|
StepField |
addField(String fieldIdentifier)
Adds a field by string
|
protected void |
addFieldImplicit(Step step,
Field field)
Fields which are added 'implicity' should be added by this function.
|
void |
addNode(Step s,
int nodeNumber) |
void |
addNode(Step s,
Node node)
Adds a node to a step.
|
protected BasicRelationStep |
addRelationStep(InsRel insrel,
NodeManager otherNodeManager,
int direction) |
RelationStep |
addRelationStep(NodeManager otherNodeManager)
If you need to add a 'related' NodeManager without specifying a role/searchDir
simply use these addRelationStep.
|
RelationStep |
addRelationStep(NodeManager otherNodeManager,
String role,
String direction)
Adds new Relation step to the query.
|
protected RelationStep |
addRelationStep(NodeManager otherNodeManager,
String role,
String direction,
boolean warnOnImpossibleStep) |
SortOrder |
addSortOrder(StepField f,
int direction)
Defaulting version of
Query.addSortOrder(StepField, int, boolean, int) (sorting case
insensitively, and no date parts). |
SortOrder |
addSortOrder(StepField f,
int direction,
boolean caseSensitive)
Defaulting version of
Query.addSortOrder(StepField, int, boolean, int) (no date parts) |
SortOrder |
addSortOrder(StepField f,
int direction,
boolean caseSensitive,
int part)
Adds an order on a certain field.
|
Step |
addStep(NodeManager nm)
Adds a NodeManager to this Query.
|
Query |
aggregatingClone()
Creates an unused aggregate clone of this query.
|
BasicQuery |
clone()
Create an (unused) clone
|
Query |
cloneWithoutFields()
Clones this object, only without the fields
|
protected String |
createAlias(String name)
Creates a unique alias for this Query based on a given base String
|
CompositeConstraint |
createConstraint(Constraint c1,
int operator,
Constraint c2)
Combines two Constraints to one new one, using a boolean operator (AND or OR).
|
FieldNullConstraint |
createConstraint(StepField f)
Create a constraint (for use with this Query object).
|
FieldValueConstraint |
createConstraint(StepField f,
int op,
Object v)
Create a constraint (for use with this Query object).
|
FieldValueConstraint |
createConstraint(StepField f,
int op,
Object v,
int part)
Create a constraint (for use with this Query object).
|
CompareFieldsConstraint |
createConstraint(StepField f,
int op,
StepField v)
Create a constraint (for use with this Query object).
|
FieldValueConstraint |
createConstraint(StepField f,
Object v)
Create a constraint (for use with this Query object).
|
FieldValueBetweenConstraint |
createConstraint(StepField f,
Object o1,
Object o2)
Create a constraint (for use with this Query object).
|
FieldValueInQueryConstraint |
createConstraint(StepField f,
Query q) |
FieldValueInConstraint |
createConstraint(StepField f,
SortedSet<? extends Object> v)
Create a constraint (for use with this Query object).
|
LegacyConstraint |
createConstraint(String s)
Create a constraint (for use with this Query object).
|
protected void |
createNewQuery() |
StepField |
createStepField(Step step,
Field field)
Creates a StepField object withouth adding it (needed for aggregated queries).
|
StepField |
createStepField(Step step,
String fieldName)
Creates a StepField object withouth adding it (needed for aggregated queries).
|
StepField |
createStepField(String fieldIdentifier)
Creates the step field for the given name.
|
boolean |
equals(Object obj)
Compares this query to the specified object.
|
CachePolicy |
getCachePolicy()
Returns the CachePolicy of the object.
|
Constraint |
getCleanConstraint()
Gets the 'clean' constraint on this query.
|
Cloud |
getCloud()
Returns the Cloud for which this Query was defined.
|
Constraint |
getConstraint()
Gets the constraints on the search results.
|
List<StepField> |
getFields()
Gets the stepfields in the search request.
|
NodeList |
getList()
Executes the query and returns the resulting node list.
|
int |
getMaxNumber()
Gets the maximum number of results to be returned, or -1 if the number of results to be returned is unlimited.
|
int |
getOffset()
Gets the (zerobased) offset in the list of results, of the first result to return.
|
BasicSearchQuery |
getQuery() |
List<SortOrder> |
getSortOrders()
Gets the SortOrder objects in the order they are to be applied.
|
String |
getSql()
Getter for use in EL.
|
Step |
getStep(String stepAlias)
Returns the step with given alias, or null if it is not present
|
List<Step> |
getSteps()
Gets the steps in the search request.
|
protected String |
glueAlias(String aliasBase,
Integer seq)
Glues a string and integer together to a new string.
|
int |
hashCode() |
boolean |
isAggregating()
Tests if this is an aggregating query, i.e.
|
boolean |
isDistinct()
Tests if the search request is to return distinct results.
|
(package private) boolean |
isSecure() |
boolean |
isUsed()
Whether this query was used or not.
|
boolean |
markUsed()
Mark this query 'used'.
|
void |
removeFields()
Removes all fields from the Query object.
|
void |
removeImplicitFields() |
(package private) void |
removeSecurityConstraint()
Remove a previously set security constraint (if set one)
|
protected void |
removeSecurityConstraintFromClone(BasicSearchQuery clone) |
void |
setAlias(Step step,
String alias)
Sets the alias to the given step.
|
void |
setCachePolicy(CachePolicy policy)
Sets the CachePolicy of the query.
|
FieldConstraint |
setCaseSensitive(FieldConstraint c,
boolean s)
Changes the given constraint's 'case sensitivity' (if applicable).
|
void |
setConstraint(Constraint c)
The (composite) constraint can actually be set into the query with this method.
|
Query |
setDistinct(boolean distinct)
Specifies wether the query result must contain only 'distinct' results.
|
Constraint |
setInverse(Constraint c,
boolean i)
Changes the given constraint's 'inverse' (if applicable).
|
Query |
setMaxNumber(int maxNumber)
Limits the query-result to maxNumber records.
|
Query |
setOffset(int offset)
Offsets the query-result with offset records.
|
(package private) void |
setSecurityConstraint(Authorization.QueryCheck c)
Applies a security-constraint to this Query.
|
String |
toSql()
Shows the query in a human-readable SQL form.
|
String |
toString()
Returns a string representation of this SearchQuery.
|
SearchQuery |
unwrap() |
protected boolean used
protected boolean aggregating
protected Authorization.QueryCheck queryCheck
protected Constraint insecureConstraint
protected BasicSearchQuery query
protected Cloud cloud
protected List<BasicStepField> implicitFields
protected List<BasicStepField> explicitFields
public BasicQuery(Cloud c)
public BasicQuery(Cloud c, boolean aggregating)
public BasicQuery(Cloud c, BasicSearchQuery q)
public BasicSearchQuery getQuery()
public SearchQuery unwrap()
unwrap in interface SearchQueryWrapperprotected void createNewQuery()
public List<Step> getSteps()
SearchQueryThis corresponds to the tables in SQL SELECT-syntax.
getSteps in interface SearchQuerypublic List<StepField> getFields()
SearchQueryThis corresponds to the fields in SQL SELECT-syntax.
getFields in interface SearchQuerypublic Constraint getConstraint()
SearchQueryThis corresponds to (part of) the constraints in the WHERE-clause in SQL SELECT-syntax.
getConstraint in interface SearchQuerypublic Constraint getCleanConstraint()
QuerygetCleanConstraint in interface Querypublic int getMaxNumber()
SearchQueryNote: limiting the number of results may not be supported by the database layer.
getMaxNumber in interface SearchQuerypublic int getOffset()
SearchQueryNote: skipping results may not be supported by the database layer.
getOffset in interface SearchQuerypublic List<SortOrder> getSortOrders()
SearchQueryThis corresponds to the ORDER BY clause in SQL SELECT syntax.
getSortOrders in interface SearchQuerypublic boolean isDistinct()
SearchQueryThis corresponds to the use of "DISTINCT" in SQL SELECT-syntax .
isDistinct in interface SearchQuerypublic boolean isAggregating()
SearchQueryisAggregating in interface SearchQuerypublic CachePolicy getCachePolicy()
CacheablegetCachePolicy in interface CacheableCachePolicy object.public void setCachePolicy(CachePolicy policy)
CacheablesetCachePolicy in interface Cacheablepolicy - the CachePolicy object.protected void removeSecurityConstraintFromClone(BasicSearchQuery clone)
public BasicQuery clone()
Querypublic Query aggregatingClone()
QueryaggregatingClone in interface Querypublic Query cloneWithoutFields()
QuerycloneWithoutFields in interface Queryprotected String createAlias(String name)
protected String glueAlias(String aliasBase, Integer seq)
public Step addStep(NodeManager nm)
QueryaddStep in interface Querynm - The nodeManager associated with the step.Query.addRelationStep(NodeManager)public void setAlias(Step step, String alias)
Queryprotected BasicRelationStep addRelationStep(InsRel insrel, NodeManager otherNodeManager, int direction)
public RelationStep addRelationStep(NodeManager otherNodeManager)
QueryaddRelationStep in interface QueryotherNodeManager - node manager on the other side of the relationpublic RelationStep addRelationStep(NodeManager otherNodeManager, String role, String direction)
Query getNext() on
the relationstep, and cast to Step.addRelationStep in interface QueryotherNodeManager - node manager on the other side of the relationrole - role of a relationdirection - the direction of the relationprotected RelationStep addRelationStep(NodeManager otherNodeManager, String role, String direction, boolean warnOnImpossibleStep)
public void removeFields()
QueryremoveFields in interface Querypublic StepField addField(Step step, Field field)
Querypublic StepField addField(String fieldIdentifier)
Queryprotected void addFieldImplicit(Step step, Field field)
public StepField createStepField(Step step, Field field)
QuerycreateStepField in interface Querystep - step to create StepField fromfield - field to create StepField frompublic StepField createStepField(Step step, String fieldName)
QuerycreateStepField in interface Querystep - step to create StepField fromfieldName - name of field to create StepField frompublic Step getStep(String stepAlias)
Querypublic StepField createStepField(String fieldIdentifier)
QuerycreateStepField in interface QueryfieldIdentifier - field identifier to create StepField frompublic AggregatedField addAggregatedField(Step step, Field field, int aggregationType)
QueryaddAggregatedField in interface Querystep - step to add field tofield - field to addaggregationType - Type of aggregationpublic void removeImplicitFields()
removeImplicitFields in interface Querypublic Query setDistinct(boolean distinct)
QuerysetDistinct in interface Querydistinct - 'distinct' resultsBasicSearchQuery.setDistinct(boolean),
SearchQuery.isDistinct()public Query setMaxNumber(int maxNumber)
QuerysetMaxNumber in interface QuerymaxNumber - max number of resultsBasicSearchQuery.setMaxNumber(int)public Query setOffset(int offset)
QuerysetOffset in interface Queryoffset - offset in resultsBasicSearchQuery.setOffset(int)public LegacyConstraint createConstraint(String s)
QuerycreateConstraint in interface Querys - String with LegacyConstraintCloud.getList(String startNodes, String nodePath, String fields, String constraints, String orderby, String directions, String searchDir, boolean distinct),
NodeManager.getList(String constraints, String orderby, String directions)public FieldNullConstraint createConstraint(StepField f)
QuerycreateConstraint in interface Queryf - Stepfieldpublic FieldValueConstraint createConstraint(StepField f, Object v)
QuerycreateConstraint in interface Queryf - fieldv - valuepublic FieldValueConstraint createConstraint(StepField f, int op, Object v, int part)
QuerycreateConstraint in interface Queryf - fieldop - operatorv - valuepart - part of the date valuepublic FieldValueConstraint createConstraint(StepField f, int op, Object v)
QuerycreateConstraint in interface Queryf - fieldop - operatorv - valuepublic CompareFieldsConstraint createConstraint(StepField f, int op, StepField v)
QuerycreateConstraint in interface Queryf - fieldop - operatorv - valuepublic FieldValueBetweenConstraint createConstraint(StepField f, Object o1, Object o2)
QuerycreateConstraint in interface Queryf - fieldo1 - value oneo2 - value twopublic FieldValueInConstraint createConstraint(StepField f, SortedSet<? extends Object> v)
QuerycreateConstraint in interface Queryf - fieldv - valuepublic FieldValueInQueryConstraint createConstraint(StepField f, Query q)
createConstraint in interface Querypublic Constraint setInverse(Constraint c, boolean i)
QuerysetInverse in interface Queryc - constrainti - inversepublic FieldConstraint setCaseSensitive(FieldConstraint c, boolean s)
QuerysetCaseSensitive in interface Queryc - constraint to changes - case sensitivitypublic CompositeConstraint createConstraint(Constraint c1, int operator, Constraint c2)
QuerycreateConstraint in interface Queryc1 - constraint oneoperator - operator (CompositeConstraint.LOGICAL_AND, CompositeConstraint.LOGICAL_OR)c2 - constraint twopublic void setConstraint(Constraint c)
QuerysetConstraint in interface Queryc - constraintpublic SortOrder addSortOrder(StepField f, int direction)
QueryQuery.addSortOrder(StepField, int, boolean, int) (sorting case
insensitively, and no date parts).addSortOrder in interface Queryf - fielddirection - SortOrder.ORDER_ASCENDING or SortOrder.ORDER_DESCENDINGpublic SortOrder addSortOrder(StepField f, int direction, boolean caseSensitive)
QueryQuery.addSortOrder(StepField, int, boolean, int) (no date parts)addSortOrder in interface Queryf - fielddirection - SortOrder.ORDER_ASCENDING or SortOrder.ORDER_DESCENDINGcaseSensitive - case sensitivitypublic SortOrder addSortOrder(StepField f, int direction, boolean caseSensitive, int part)
QueryaddSortOrder in interface Queryf - fielddirection - SortOrder.ORDER_ASCENDING or SortOrder.ORDER_DESCENDINGcaseSensitive - case sensitivitypart - part to sort on for a date valueBasicSearchQuery.addSortOrder(org.mmbase.storage.search.StepField)public void addNode(Step s, int nodeNumber)
public void addNode(Step s, Node node)
Querypublic boolean isUsed()
Querypublic boolean markUsed()
QuerymarkUsed in interface QuerymarkUsed in interface SearchQueryboolean isSecure()
void setSecurityConstraint(Authorization.QueryCheck c)
removeSecurityConstraint()void removeSecurityConstraint()
public Cloud getCloud()
Querypublic NodeList getList()
Querypublic boolean equals(Object obj)
SearchQuerytrue if and only if the argument is a non-null
SearchQuery object representing the same query.equals in interface SearchQueryequals in class Objectobj - The object to compare with.true if the objects are equal,
false otherwise.public int hashCode()
hashCode in interface SearchQueryhashCode in class Objectpublic String toString()
SearchQueryisDistinct()
getSteps()
getFields()
getConstraint()
getSortOrders()
getMaxNumber()
getOffset()
toString in interface SearchQuerytoString in class Objectpublic String toSql()
QueryMMBase 1.9-SNAPSHOT - ${javadoctimestamp}