Interface KadaiEngine

All Known Implementing Classes:
KadaiEngineImpl

public interface KadaiEngine
The KadaiEngine represents an overall set of all needed services.
  • Field Details

  • Method Details

    • buildKadaiEngine

      static KadaiEngine buildKadaiEngine(KadaiConfiguration configuration) throws SQLException
      Throws:
      SQLException
      See Also:
    • buildKadaiEngine

      static KadaiEngine buildKadaiEngine(KadaiConfiguration configuration, KadaiEngine.ConnectionManagementMode connectionManagementMode) throws SQLException
      Builds an KadaiEngine based on KadaiConfiguration and SqlConnectionMode.
      Parameters:
      configuration - complete kadaiConfig to build the engine
      connectionManagementMode - connectionMode for the SqlSession
      Returns:
      a KadaiEngineImpl
      Throws:
      SQLException - when the db schema could not be initialized
    • buildKadaiEngine

      static KadaiEngine buildKadaiEngine(KadaiConfiguration configuration, KadaiEngine.ConnectionManagementMode connectionManagementMode, org.apache.ibatis.transaction.TransactionFactory transactionFactory) throws SQLException
      Builds an KadaiEngine based on KadaiConfiguration, SqlConnectionMode and TransactionFactory.
      Parameters:
      configuration - complete kadaiConfig to build the engine
      connectionManagementMode - connectionMode for the SqlSession
      transactionFactory - the TransactionFactory
      Returns:
      a KadaiEngineImpl
      Throws:
      SQLException - when the db schema could not be initialized
    • getTaskService

      TaskService getTaskService()
      Returns a TaskService initialized with the current KadaiEngine. TaskService can be used for operations on all Tasks.
      Returns:
      an instance of TaskService
    • getMonitorService

      MonitorService getMonitorService()
      Returns a MonitorService initialized with the current KadaiEngine. MonitorService can be used for monitoring Tasks.
      Returns:
      an instance of MonitorService
    • getWorkbasketService

      WorkbasketService getWorkbasketService()
      Returns a WorkbasketService initialized with the current KadaiEngine. The WorkbasketService can be used for operations on all Workbaskets.
      Returns:
      an instance of WorkbasketService
    • getClassificationService

      ClassificationService getClassificationService()
      Returns a ClassificationService initialized with the current KadaiEngine. The ClassificationService can be used for operations on all Classifications.
      Returns:
      an instance of ClassificationService
    • getJobService

      JobService getJobService()
      Returns a JobService initialized with the current KadaiEngine. The JobService can be used for all operations on KadaiJobs.
      Returns:
      an instance of JobService
    • getUserService

      UserService getUserService()
      Returns a UserService initialized with the current KadaiEngine. The UserService can be used for all operations on Users.
      Returns:
      an instance of UserService
    • getConfigurationService

      ConfigurationService getConfigurationService()
      Returns a ConfigurationService initialized with the current KadaiEngine. The ConfigurationService can be used to manage custom configuration options.
      Returns:
      an instance of ConfigurationService
    • getConfiguration

      KadaiConfiguration getConfiguration()
      Returns the configuration of the KadaiEngine.
      Returns:
      configuration
    • getWorkingTimeCalculator

      io.kadai.common.api.WorkingTimeCalculator getWorkingTimeCalculator()
      Returns the WorkingTimeCalculator of the KadaiEngine. The WorkingTimeCalculator is used to add or subtract working time from Instants according to a working time schedule or to calculate the working time between Instants.
      Returns:
      WorkingTimeCalculatorImpl
    • isHistoryEnabled

      boolean isHistoryEnabled()
      Checks if the KadaiHistory plugin is enabled.
      Returns:
      true if the history is enabled; otherwise false
    • getConnectionManagementMode

      KadaiEngine.ConnectionManagementMode getConnectionManagementMode()
      Returns the ConnectionManagementMode of the KadaiEngine.
      Returns:
      ConnectionManagementMode
    • setConnectionManagementMode

      void setConnectionManagementMode(KadaiEngine.ConnectionManagementMode mode)
      Sets ConnectionManagementMode of the KadaiEngine.
      Parameters:
      mode - the valid values for the KadaiEngine.ConnectionManagementMode are:
      • PARTICIPATE - kadai participates in global transaction; this is the default mode
      • AUTOCOMMIT - kadai commits each API call separately
      • EXPLICIT - commit processing is managed explicitly by the client
    • setConnection

      void setConnection(Connection connection) throws SQLException
      Set the Connection to be used by KADAI in mode EXPLICIT. If this API is called, KADAI uses the Connection passed by the client for all subsequent API calls until the client resets this Connection. Control over commit and rollback of the Connection is the responsibility of the client. In order to close the Connection, closeConnection() or setConnection(null) has to be called.
      Parameters:
      connection - - The java.sql.Connection that is controlled by the client
      Throws:
      SQLException - if a database access error occurs
    • closeConnection

      void closeConnection()
      Closes the client's connection, sets it to null and switches to mode PARTICIPATE. Only applicable in mode EXPLICIT. Has the same effect as setConnection(null).
    • isUserInRole

      boolean isUserInRole(io.kadai.common.api.KadaiRole... roles)
      Check whether the current user is member of one of the KadaiRoles specified.
      Parameters:
      roles - The KadaiRoles that are checked for membership of the current user
      Returns:
      true if the current user is a member of at least one of the specified KadaiRole
    • checkRoleMembership

      void checkRoleMembership(io.kadai.common.api.KadaiRole... roles) throws io.kadai.common.api.exceptions.NotAuthorizedException
      Checks whether current user is member of the specified KadaiRoles.
      Parameters:
      roles - The KadaiRoles that are checked for membership of the current user
      Throws:
      io.kadai.common.api.exceptions.NotAuthorizedException - If the current user is not member of any specified KadaiRole
    • runAs

      <T> T runAs(Supplier<T> supplier, io.kadai.common.api.KadaiRole proxy, String userId)
      Execute an action for a user with the privileges of another KadaiRole.

      This can be thought of as temporarily lifting the user into the given role - the role therefore is acting as proxy.

      Type Parameters:
      T - the return value of the action
      Parameters:
      supplier - the action to execute
      proxy - the role to temporarily lift the user to - acting as proxy
      userId - the id of the user to be lifted
      Returns:
      the return value of the action
    • runAs

      default void runAs(Runnable runnable, io.kadai.common.api.KadaiRole proxy, String userId)
      This is a convenience-method for runAs(Supplier, KadaiRole, String).
      Parameters:
      runnable - the action to execute
      proxy - the role to temporarily lift the user to - acting as proxy
      userId - the id of the user to be lifted
      See Also:
    • runAsAdmin

      default <T> T runAsAdmin(Supplier<T> supplier)
      This is a convenience-method for runAs(Supplier, KadaiRole, String).

      It overrides the current userId with one of an admin, leaving the proxy empty.

      Type Parameters:
      T - the return value of the action
      Parameters:
      supplier - the action to execute
      Returns:
      the return value of the action
      See Also:
    • runAsAdmin

      default <T> T runAsAdmin(Supplier<T> supplier, String userId)
      This is a convenience-method for runAs(Supplier, KadaiRole, String).
      Type Parameters:
      T - the return value of the action
      Parameters:
      supplier - the action to execute
      userId - the id of the user to be lifted
      Returns:
      the return value of the action
      See Also:
    • runAsAdmin

      default void runAsAdmin(Runnable runnable)
      This is a convenience-method for runAs(Supplier, KadaiRole, String).

      It overrides the current userId with one of an admin, leaving the proxy empty.

      Parameters:
      runnable - the action to execute
      See Also:
    • runAsAdmin

      default void runAsAdmin(Runnable runnable, String userId)
      This is a convenience-method for runAs(Runnable, KadaiRole, String).
      Parameters:
      runnable - the action to execute
      userId - the id of the user to be lifted
      See Also:
    • getCurrentUserContext

      io.kadai.common.api.security.CurrentUserContext getCurrentUserContext()
      Returns the CurrentUserContext of the KadaiEngine.
      Returns:
      CurrentUserContext
    • clearSqlSessionCache

      void clearSqlSessionCache()
      Clears the cache of the underlying local SQL session.