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 enumConnection management mode. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic KadaiEnginebuildKadaiEngine(KadaiConfiguration configuration) This method creates the KadaiEngine with KadaiEngine.ConnectionManagementMode.PARTICIPATE.static KadaiEnginebuildKadaiEngine(KadaiConfiguration configuration, KadaiEngine.ConnectionManagementMode connectionManagementMode) Builds an KadaiEngine based on KadaiConfiguration and SqlConnectionMode.static KadaiEnginebuildKadaiEngine(KadaiConfiguration configuration, KadaiEngine.ConnectionManagementMode connectionManagementMode, org.apache.ibatis.transaction.TransactionFactory transactionFactory) Builds an KadaiEngine based on KadaiConfiguration, SqlConnectionMode and TransactionFactory.voidcheckRoleMembership(io.kadai.common.api.KadaiRole... roles) Checks whether current user is member of the specified KadaiRoles.voidClears the cache of the underlying local SQL session.voidCloses 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.CurrentUserContextReturns 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.WorkingTimeCalculatorReturns the WorkingTimeCalculator of the KadaiEngine.booleanChecks if the KadaiHistory plugin is enabled.booleanisUserInRole(io.kadai.common.api.KadaiRole... roles) Check whether the current user is member of one of the KadaiRoles specified.default voidThis is a convenience-method forrunAs(Supplier, KadaiRole, String).<T> TExecute an action for a user with the privileges of anotherKadaiRole.default voidrunAsAdmin(Runnable runnable) This is a convenience-method forrunAs(Supplier, KadaiRole, String).default voidrunAsAdmin(Runnable runnable, String userId) This is a convenience-method forrunAs(Runnable, KadaiRole, String).default <T> TrunAsAdmin(Supplier<T> supplier) This is a convenience-method forrunAs(Supplier, KadaiRole, String).default <T> TrunAsAdmin(Supplier<T> supplier, String userId) This is a convenience-method forrunAs(Supplier, KadaiRole, String).voidsetConnection(Connection connection) Set theConnectionto be used by KADAI in mode EXPLICIT.voidSets 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 theConnectionto be used by KADAI in mode EXPLICIT. If this API is called, KADAI uses theConnectionpassed by the client for all subsequent API calls until the client resets thisConnection. Control over commit and rollback of theConnectionis the responsibility of the client. In order to close theConnection,closeConnection()orsetConnection(null)has to be called.- Parameters:
connection- - Thejava.sql.Connectionthat 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 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
Execute an action for a user with the privileges of anotherKadaiRole.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 executeproxy- the role to temporarily lift the user to - acting as proxyuserId- the id of the user to be lifted- Returns:
- the return value of the action
-
runAs
This is a convenience-method forrunAs(Supplier, KadaiRole, String).- Parameters:
runnable- the action to executeproxy- the role to temporarily lift the user to - acting as proxyuserId- the id of the user to be lifted- See Also:
-
runAsAdmin
This is a convenience-method forrunAs(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
This is a convenience-method forrunAs(Supplier, KadaiRole, String).- Type Parameters:
T- the return value of the action- Parameters:
supplier- the action to executeuserId- the id of the user to be lifted- Returns:
- the return value of the action
- See Also:
-
runAsAdmin
This is a convenience-method forrunAs(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
This is a convenience-method forrunAs(Runnable, KadaiRole, String).- Parameters:
runnable- the action to executeuserId- 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.
-