Package io.kadai.common.api
Interface KadaiEngine
- All Known Implementing Classes:
KadaiEngineImpl
public interface KadaiEngine
The KadaiEngine represents an overall set of all needed services.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Connection management mode. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic KadaiEngine
buildKadaiEngine
(KadaiConfiguration configuration) This method creates the KadaiEngine with KadaiEngine.ConnectionManagementMode.PARTICIPATE.static KadaiEngine
buildKadaiEngine
(KadaiConfiguration configuration, KadaiEngine.ConnectionManagementMode connectionManagementMode) Builds an KadaiEngine based on KadaiConfiguration and SqlConnectionMode.static KadaiEngine
buildKadaiEngine
(KadaiConfiguration configuration, KadaiEngine.ConnectionManagementMode connectionManagementMode, org.apache.ibatis.transaction.TransactionFactory transactionFactory) Builds an KadaiEngine based on KadaiConfiguration, SqlConnectionMode and TransactionFactory.void
checkRoleMembership
(io.kadai.common.api.KadaiRole... roles) Checks whether current user is member of any of the specified KadaiRoles.void
Clears the cache of the underlying local SQL session.void
Closes the client's connection, sets it to null and switches to mode PARTICIPATE.Returns a ClassificationService initialized with the current KadaiEngine.Returns the configuration of the KadaiEngine.Returns a ConfigurationService initialized with the current KadaiEngine.Returns the ConnectionManagementMode of the KadaiEngine.io.kadai.common.api.security.CurrentUserContext
Returns the CurrentUserContext of the KadaiEngine.Returns a JobService initialized with the current KadaiEngine.Returns a MonitorService initialized with the current KadaiEngine.Returns a TaskService initialized with the current KadaiEngine.Returns a UserService initialized with the current KadaiEngine.Returns a WorkbasketService initialized with the current KadaiEngine.io.kadai.common.api.WorkingTimeCalculator
Returns the WorkingTimeCalculator of the KadaiEngine.boolean
Checks if the KadaiHistory plugin is enabled.boolean
isUserInRole
(io.kadai.common.api.KadaiRole... roles) Check whether the current user is member of one of the KadaiRoles specified.default void
runAsAdmin
(Runnable runnable) Executes a givenRunnable
with admin privileges and thus skips further permission checks.<T> T
runAsAdmin
(Supplier<T> supplier) Executes a givenSupplier
with admin privileges and thus skips further permission checks.void
setConnection
(Connection connection) Set theConnection
to be used by KADAI in mode EXPLICIT.void
Sets ConnectionManagementMode of the KadaiEngine.
-
Field Details
-
MINIMAL_KADAI_SCHEMA_VERSION
- See Also:
-
-
Method Details
-
buildKadaiEngine
This method creates the KadaiEngine with KadaiEngine.ConnectionManagementMode.PARTICIPATE.- 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 engineconnectionManagementMode
- 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 engineconnectionManagementMode
- connectionMode for the SqlSessiontransactionFactory
- 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
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
Set theConnection
to be used by KADAI in mode EXPLICIT. If this API is called, KADAI uses theConnection
passed by the client for all subsequent API calls until the client resets thisConnection
. Control over commit and rollback of theConnection
is the responsibility of the client. In order to close theConnection
,closeConnection()
orsetConnection(null)
has to be called.- Parameters:
connection
- - Thejava.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 assetConnection(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 any 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
-
runAsAdmin
Executes a givenSupplier
with admin privileges and thus skips further permission checks. With great power comes great responsibility.- Type Parameters:
T
- defined with the return value of theSupplier
- Parameters:
supplier
- will be executed with admin privileges- Returns:
- output from
Supplier
-
runAsAdmin
Executes a givenRunnable
with admin privileges and thus skips further permission checks. With great power comes great responsibility.- 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.
-