Class QueryProvider

java.lang.Object
org.nuclos.api.provider.QueryProvider

public class QueryProvider extends Object
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 Details

    • QueryProvider

      QueryProvider()
  • Method Details

    • setQueryService

      public void setQueryService(QueryService service)
    • create

      public static <PK, T extends BusinessObject<PK>> Query<T> create(Class<T> type)
      This methods returns an instance of Query that is type-specific to the class given as parameter. The Query can executed by using method execute(BusinessObjectQuery<T> query)
      Parameters:
      type - - type-specific class that determines the type of the returned Query
      Returns:
      Query
    • execute

      public static <PK, T extends BusinessObject<PK>> List<T> execute(Query<T> query, Attribute<?>... attributes)
      This methods executes a Query and returns a list of found BusinessObject of the type determined by the Query type. An IllegalArgumentException is thrown if an attribute is compared to null and NULL or NOTNULL is not used.
      Parameters:
      query - type-specific list of BusinessObject
      Returns:
      List<BusinessObject>
    • executeSingleResult

      public static <PK, T extends BusinessObject<PK>> T executeSingleResult(Query<T> query, Attribute<?>... attributes) throws BusinessException
      This methods executes a Query and returns a single result BusinessObject of the type determined by the Query type. Returns null if nothing found and throws exception if query returns more than one row. An IllegalArgumentException is thrown if an attribute is compared to null and NULL or NOTNULL is not used.
      Parameters:
      query - type-specific BusinessObject
      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 single BusinessObject that can be found for the given Id; Parameter Class<T> type is necessary to ensure type-safety
      Parameters:
      type - - type-specific class
      id - - 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 all BusinessObjects that contain one of the given processes;
      A Process 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 all BusinessObjects that contain one of the given states;
      A State 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