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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <PK,T extends BusinessObject<PK>>
Query<T>This methods returns an instance ofQuerythat is type-specific to the class given as parameter.static <PK,T extends BusinessObject<PK>>
List<T>This methods executes aQueryand returns a list of foundBusinessObjectof the type determined by theQuerytype.static <PK,T extends BusinessObject<PK>>
TexecuteSingleResult(Query<T> query, Attribute<?>... attributes) This methods executes aQueryand returns a single resultBusinessObjectof the type determined by theQuerytype.static <PK,T extends BusinessObject<PK>>
TDeprecated.getByProcess(Process<T> process, Process<T>... additionalProcesses) This method returns allBusinessObjects that contain one of the given processes;
AProcessis always assigned to one entity, so the type of the BusinessObject does not have to be mentioned explicitly;
There must be at least one processgetByState(Class<T> type, State state, State... additionalStates) This method returns allBusinessObjects that contain one of the given states;
AStateis always assigned to one statemodel, that can be used by several entities.voidsetQueryService(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 aQueryand returns a list of foundBusinessObjectof the type determined by theQuerytype. AnIllegalArgumentExceptionis 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 aQueryand returns a single resultBusinessObjectof the type determined by theQuerytype. Returns null if nothing found and throws exception if query returns more than one row. AnIllegalArgumentExceptionis 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 singleBusinessObjectthat 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 <T extends Stateful> List<T> getByProcess(Process<T> process, Process<T>... additionalProcesses) throws BusinessException This method returns allBusinessObjects that contain one of the given processes;
AProcessis 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 <T extends Stateful> List<T> getByState(Class<T> type, State state, State... additionalStates) throws BusinessException This method returns allBusinessObjects that contain one of the given states;
AStateis 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
-