public class GrooqlFilter extends java.lang.Object implements BOFilterI
GrooqlFilter
allow to query BOs
that match given
criteria from the DB and also check if given BOs
match these
criteria, both accomplished using only one single criteria definition.
GrooqlFilter
could thus be seen as a combination of OQL queries
and BOMasken
.
The criteria definition is given as a script in a subset of the Groovy
language. The script is used directly to check if given BOs
match these criteria using the fits()
method. For querying
matching BOs
from the DB the script is automatically transformed
into an OQL query which retrieves a superset of the matching
BOs
which are then post-filtered with the script.
All attributes of the BO
that is currently checked are available
as variables in the script with their simple name; for example if a filter
was defined for the class Benutzer
Name
,
Beschreibung
, AnmeldungVerweigern
etc. would be
available as variables in the script under the exact above names.
Constructor and Description |
---|
GrooqlFilter(EntityI _entity,
java.lang.String _src)
Creates and initializes a new
GrooqlFilter . |
Modifier and Type | Method and Description |
---|---|
long |
count(GrooqlBOLoaderI _bol)
Gets the number of
BOs in the DB that match this filter's
criteria. |
long |
count(GrooqlBOLoaderI _bol,
java.util.Map _binding) |
long |
count(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _additionalClauses) |
long |
count(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _additionalClauses,
java.lang.Object[] _additionalParams) |
boolean |
fits(BOI _bo)
Checks if the given
BOI matches the filter criteria of this
GrooqlFilter . |
boolean |
fits(BOI _bo,
java.util.Map _binding) |
boolean |
fits(BOI _bo,
java.util.Map _binding,
boolean _errorValue) |
boolean |
fits(BOI _bo,
java.util.Map _binding,
boolean _errorValue,
boolean _doLogging) |
EntityI |
getEntity() |
java.lang.String |
getFilterSource() |
OQLQueryInstanceI |
getOQLQuery()
Builds and returns an OQL query that will retrieve a superset of
the
BOs that would result if all existing BOs
would be filtered by this filter's fits() method. |
OQLQueryInstanceI |
getOQLQuery(java.util.Map _binding) |
OQLQueryInstanceI |
getOQLQuery(java.util.Map _binding,
java.lang.String _additionalClauses) |
OQLQueryInstanceI |
getOQLQuery(java.util.Map _binding,
java.lang.String _additionalClauses,
java.lang.Object[] _additionalParams) |
OQLQueryInstanceI |
getOQLQuery(java.util.Map _binding,
java.lang.String _additionalClauses,
java.lang.Object[] _additionalParams,
java.lang.String _queryWhat) |
QueryResultsI |
query(GrooqlBOLoaderI _bol)
Retrieves
BOs via this filter's getOQLQuery()
method and the given GrooqlBOLoaderI and then automatically
post-filters them using this filter's fits() method. |
QueryResultsI |
query(GrooqlBOLoaderI _bol,
java.util.Map _binding) |
QueryResultsI |
query(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _orderBy) |
QueryResultsI |
query(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _orderBy,
int _limit) |
QueryResultsI |
query(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _orderBy,
int _limit,
int _offset) |
QueryResultsI |
query(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _orderBy,
int _limit,
int _offset,
java.lang.String _additionalClauses) |
QueryResultsI |
query(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _orderBy,
int _limit,
int _offset,
java.lang.String _additionalClauses,
java.lang.Object[] _additionalParams) |
java.util.List |
queryBO(GrooqlBOLoaderI _bol)
Retrieves
BOs via this filter's getOQLQuery()
method and the given GrooqlBOLoaderI and then automatically
post-filters them using this filter's fits() method. |
java.util.List |
queryBO(GrooqlBOLoaderI _bol,
java.util.Map _binding) |
java.util.List |
queryBO(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _orderBy) |
java.util.List |
queryBO(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _orderBy,
int _limit) |
java.util.List |
queryBO(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _orderBy,
int _limit,
int _offset) |
java.util.List |
queryBO(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _orderBy,
int _limit,
int _offset,
java.lang.String _additionalClauses) |
java.util.List |
queryBO(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _orderBy,
int _limit,
int _offset,
java.lang.String _additionalClauses,
java.lang.Object[] _additionalParams) |
void |
setEntity(EntityI $11) |
void |
setFilterSource(java.lang.String _src)
Sets the filter script source code and deletes the cached compiled version
of the filter script.
|
long |
upperCount(GrooqlBOLoaderI _bol)
Gets the maximum number of
BOs in the DB that may
match this filter's criteria. |
long |
upperCount(GrooqlBOLoaderI _bol,
java.util.Map _binding) |
long |
upperCount(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _additionalClauses) |
long |
upperCount(GrooqlBOLoaderI _bol,
java.util.Map _binding,
java.lang.String _additionalClauses,
java.lang.Object[] _additionalParams) |
public GrooqlFilter(EntityI _entity, java.lang.String _src) throws org.codehaus.groovy.control.CompilationFailedException
GrooqlFilter
._entity
- the EntityI
which the BOs
must
match_src
- the filter script source used to find and filter the
BOs
org.codehaus.groovy.control.CompilationFailedException
- if the given filter script contained
syntax errors or could not be compiled for other reasonspublic void setFilterSource(java.lang.String _src)
_src
- the filter script source used to find and filter the
BOs
public boolean fits(BOI _bo)
BOI
matches the filter criteria of this
GrooqlFilter
.fits
in interface BOFilterI
_bo
- the BO
for which should be checked if it matches
the criteria of this filter_binding
- a Map
containing name/value pairs that will
be made available as variables for the script used by
fits()
. May be null._errorValue
- the boolean value that is returned if the filter
script evaluation throws an exception; defaults to false._doLogging
- if true (the default) errors during script execution
will be logged; if false not. Basically only for the automatic tests,
since the stacktraces that are printed when error cases are tested are
slightly annoying.public boolean fits(BOI _bo, java.util.Map _binding)
public boolean fits(BOI _bo, java.util.Map _binding, boolean _errorValue)
public boolean fits(BOI _bo, java.util.Map _binding, boolean _errorValue, boolean _doLogging)
public OQLQueryInstanceI getOQLQuery()
BOs
that would result if all existing BOs
would be filtered by this filter's fits()
method.
In most cases the OQL result set will already contain only
BOs
for which fits()
returns true, but this
cannot be guaranteed since it is not possible to filter as finegrained
with OQL as can be done with the filter script.
The query()
and queryBO()
methods of this class
can be used to retrieve the exact set of matching BOs
, since
they will automatically post-filter the set of BOs
retrieved
from the DB with fits()
.
_binding
- a Map
containing name/value pairs that will
be made available as variables for the script used by
fits()
. May be null._additionalClauses
- additional custom WHERE clauses that are
added to the generated OQL's WHERE clause (with "and"). May be and
defaults to null._additionalParams
- parameters for the additional WHERE clauses. May
be and defaults to null.OQLQueryInstanceI
FIXMEpublic OQLQueryInstanceI getOQLQuery(java.util.Map _binding)
public OQLQueryInstanceI getOQLQuery(java.util.Map _binding, java.lang.String _additionalClauses)
public OQLQueryInstanceI getOQLQuery(java.util.Map _binding, java.lang.String _additionalClauses, java.lang.Object[] _additionalParams)
public OQLQueryInstanceI getOQLQuery(java.util.Map _binding, java.lang.String _additionalClauses, java.lang.Object[] _additionalParams, java.lang.String _queryWhat)
public QueryResultsI query(GrooqlBOLoaderI _bol)
BOs
via this filter's getOQLQuery()
method and the given GrooqlBOLoaderI
and then automatically
post-filters them using this filter's fits()
method.
The returned QueryResultsI
will thus only include
BOs
fully matching this filter.
_bol
- a GrooqlBOLoaderI
used to query the
BOs
from the DB_binding
- a Map
containing name/value pairs that will
be made available as variables for the script used by
fits()
. May be and defaults to null._orderBy
- an OQL "order by" clause (not including the actual
"order by" keywords) that is added to the generated query. May be and
defaults to null._limit
- a limit count that is used to restrict the number of
returned BOs
to the given amount. If <= 0 no limit will be
applied and all matching BOs
will be returned. Defaults to
-1._offset
- an offset starting from which the retrieved
BOs
will be returned. Only honoured if _limit > 0 and
_offset >= 0. Defaults to -1._additionalClauses
- additional custom WHERE clauses that are
added to the generated OQL's WHERE clause (with "and"). May be and
defaults to null._additionalParams
- parameters for the additional WHERE clauses. May
be and defaults to null.QueryResultsI
that can be used to retrieve the
queried and matching BOs
public QueryResultsI query(GrooqlBOLoaderI _bol, java.util.Map _binding)
public QueryResultsI query(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _orderBy)
public QueryResultsI query(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _orderBy, int _limit)
public QueryResultsI query(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _orderBy, int _limit, int _offset)
public QueryResultsI query(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _orderBy, int _limit, int _offset, java.lang.String _additionalClauses)
public QueryResultsI query(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _orderBy, int _limit, int _offset, java.lang.String _additionalClauses, java.lang.Object[] _additionalParams)
public java.util.List queryBO(GrooqlBOLoaderI _bol)
BOs
via this filter's getOQLQuery()
method and the given GrooqlBOLoaderI
and then automatically
post-filters them using this filter's fits()
method.
The returned QueryResultsI
will thus only include
BOs
fully matching this filter.
_bol
- a GrooqlBOLoaderI
used to query the
BOs
from the DB_binding
- a Map
containing name/value pairs that will
be made available as variables for the script used by
fits()
. May be and defaults to null._orderBy
- an OQL "order by" clause (not including the actual
"order by" keywords) that is added to the generated query. May be and
defaults to null._limit
- a limit count that is used to restrict the number of
returned BOs
to the given amount. If <= 0 no limit will be
applied and all matching BOs
will be returned. Defaults to
-1._offset
- an offset starting from which the retrieved
BOs
will be returned. Only honoured if _limit > 0 and
_offset >= 0. Defaults to -1._additionalClauses
- additional custom WHERE clauses that are
added to the generated OQL's WHERE clause (with "and"). May be and
defaults to null._additionalParams
- parameters for the additional WHERE clauses. May
be and defaults to null.List
containing all the queried and matching
BOs
public java.util.List queryBO(GrooqlBOLoaderI _bol, java.util.Map _binding)
public java.util.List queryBO(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _orderBy)
public java.util.List queryBO(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _orderBy, int _limit)
public java.util.List queryBO(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _orderBy, int _limit, int _offset)
public java.util.List queryBO(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _orderBy, int _limit, int _offset, java.lang.String _additionalClauses)
public java.util.List queryBO(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _orderBy, int _limit, int _offset, java.lang.String _additionalClauses, java.lang.Object[] _additionalParams)
public long count(GrooqlBOLoaderI _bol)
BOs
in the DB that match this filter's
criteria.
FIXME! Currently this method needs to actually query all the objects
that match the filter which can make it very costly, so only call it if
you really need it. If you need the objects anyway rather use
queryBO()
and get the size of the returned list (this is what
this method does internally basically).
_bol
- a GrooqlBOLoaderI
used to query the
BOs
from the DB_binding
- a Map
containing name/value pairs that will
be made available as variables for the script used by
fits()
. May be and defaults to null._additionalClauses
- additional custom WHERE clauses that are
added to the generated OQL's WHERE clause (with "and"). May be and
defaults to null._additionalParams
- parameters for the additional WHERE clauses. May
be and defaults to null.BOs
in the DB that match this filter's
criteriapublic long count(GrooqlBOLoaderI _bol, java.util.Map _binding)
public long count(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _additionalClauses)
public long count(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _additionalClauses, java.lang.Object[] _additionalParams)
public long upperCount(GrooqlBOLoaderI _bol)
BOs
in the DB that may
match this filter's criteria. Sometimes this is enough information and it
is a good deal less costly than count
._bol
- a GrooqlBOLoaderI
used to query the
BOs
from the DBBOs
in the DB that may
match this filter's criteriapublic long upperCount(GrooqlBOLoaderI _bol, java.util.Map _binding)
public long upperCount(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _additionalClauses)
public long upperCount(GrooqlBOLoaderI _bol, java.util.Map _binding, java.lang.String _additionalClauses, java.lang.Object[] _additionalParams)
public java.lang.String getFilterSource()
public EntityI getEntity()
public void setEntity(EntityI $11)
Copyright © 2000-2024 OAshi S.à r.l. All Rights Reserved.