Package org.nuclos.api.provider
Class QueryProvider
java.lang.Object
org.nuclos.api.provider.QueryProvider
QueryProvider
provides methods for creating and executing
Query
for data access and methods to read
single BusinessObject
.
This Class is usually used in Rule-classes and allows API access only
- Author:
- Matthias Reichart
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <PK,
T extends BusinessObject<PK>>
Query<T>This methods returns an instance ofQuery
that is type-specific to the class given as parameter.static <PK,
T extends BusinessObject<PK>>
List<T>This methods executes aQuery
and returns a list of foundBusinessObject
of the type determined by theQuery
type.static <PK,
T extends BusinessObject<PK>>
TexecuteSingleResult
(Query<T> query, Attribute<?>... attributes) This methods executes aQuery
and returns a single resultBusinessObject
of the type determined by theQuery
type.static <PK,
T extends BusinessObject<PK>>
TDeprecated.static <PK,
T extends Stateful & BusinessObject<PK>>
List<T>getByProcess
(Process<T> process, Process<T>... additionalProcesses) This method returns allBusinessObject
s that contain one of the given processes;
AProcess
is always assigned to one entity, so the type of the BusinessObject does not have to be mentioned explicitly;
There must be at least one processstatic <PK,
T extends Stateful & BusinessObject<PK>>
List<T>getByState
(Class<T> type, State state, State... additionalStates) This method returns allBusinessObject
s that contain one of the given states;
AState
is always assigned to one statemodel, that can be used by several entities.void
setQueryService
(QueryService service)
-
Constructor Details
-
QueryProvider
QueryProvider()
-
-
Method Details
-
setQueryService
-
create
-
execute
public static <PK,T extends BusinessObject<PK>> List<T> execute(Query<T> query, Attribute<?>... attributes) This methods executes aQuery
and returns a list of foundBusinessObject
of the type determined by theQuery
type. AnIllegalArgumentException
is thrown if an attribute is compared to null and NULL or NOTNULL is not used.- Parameters:
query
- type-specific list ofBusinessObject
- Returns:
- List<
BusinessObject
>
-
executeSingleResult
public static <PK,T extends BusinessObject<PK>> T executeSingleResult(Query<T> query, Attribute<?>... attributes) throws BusinessException This methods executes aQuery
and returns a single resultBusinessObject
of the type determined by theQuery
type. Returns null if nothing found and throws exception if query returns more than one row. AnIllegalArgumentException
is thrown if an attribute is compared to null and NULL or NOTNULL is not used.- Parameters:
query
- type-specificBusinessObject
- Returns:
BusinessObject
;- Throws:
BusinessException
-
getById
@Deprecated public static <PK,T extends BusinessObject<PK>> T getById(Class<T> type, PK id, Attribute<?>... attributes) Deprecated.This method returns one singleBusinessObject
that can be found for the given Id; Parameter Class<T> type is necessary to ensure type-safety- Parameters:
type
- - type-specific classid
- - Id of the element to search for in the database- Returns:
- type-specific -
BusinessObject
-
getByProcess
public static <PK,T extends Stateful & BusinessObject<PK>> List<T> getByProcess(Process<T> process, Process<T>... additionalProcesses) throws BusinessException This method returns allBusinessObject
s that contain one of the given processes;
AProcess
is always assigned to one entity, so the type of the BusinessObject does not have to be mentioned explicitly;
There must be at least one process- Parameters:
process
-additionalProcesses
-- Returns:
- Throws:
BusinessException
-
getByState
public static <PK,T extends Stateful & BusinessObject<PK>> List<T> getByState(Class<T> type, State state, State... additionalStates) throws BusinessException This method returns allBusinessObject
s that contain one of the given states;
AState
is always assigned to one statemodel, that can be used by several entities. So the type of the BusinessObject must be mentioned explicitly;
There must be at least one state- Parameters:
type
-state
-additionalStates
-- Returns:
- Throws:
BusinessException
-