Package pro.taskana.common.internal
Class TaskanaEngineImpl
- java.lang.Object
-
- pro.taskana.common.internal.TaskanaEngineImpl
-
- All Implemented Interfaces:
TaskanaEngine
public class TaskanaEngineImpl extends Object implements TaskanaEngine
This is the implementation of TaskanaEngine.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface pro.taskana.common.api.TaskanaEngine
TaskanaEngine.ConnectionManagementMode
-
-
Field Summary
Fields Modifier and Type Field Description protected Connectionconnectionprotected TaskanaEngine.ConnectionManagementModemodeprotected org.apache.ibatis.session.SqlSessionManagersessionManagerprotected TaskanaEngineConfigurationtaskanaEngineConfigurationprotected org.apache.ibatis.transaction.TransactionFactorytransactionFactory
-
Constructor Summary
Constructors Modifier Constructor Description protectedTaskanaEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration, TaskanaEngine.ConnectionManagementMode connectionManagementMode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckRoleMembership(TaskanaRole... roles)Checks whether current user is member of any of the specified TaskanaRoles.voidcloseConnection()Closes the client's connection, sets it to null and switches to mode PARTICIPATE.protected org.apache.ibatis.session.SqlSessionManagercreateSqlSessionManager()This method creates the sqlSessionManager of myBatis.static TaskanaEnginecreateTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration)static TaskanaEnginecreateTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration, TaskanaEngine.ConnectionManagementMode connectionManagementMode)ClassificationServicegetClassificationService()Returns a ClassificationService initialized with the current TaskanaEngine.TaskanaEngineConfigurationgetConfiguration()Returns the configuration of the TaskanaEngine.ConfigurationServicegetConfigurationService()Returns a ConfigurationService initialized with the current TaskanaEngine.TaskanaEngine.ConnectionManagementModegetConnectionManagementMode()Returns the ConnectionManagementMode of the TaskanaEngine.pro.taskana.common.api.security.CurrentUserContextgetCurrentUserContext()Returns the CurrentUserContext of the TaskanaEngine.JobServicegetJobService()Returns a JobService initialized with the current TaskanaEngine.MonitorServicegetMonitorService()Returns a MonitorService initialized with the current TaskanaEngine.PriorityServiceManagergetPriorityServiceManager()TaskServicegetTaskService()Returns a TaskService initialized with the current TaskanaEngine.UserServicegetUserService()Returns a UserService initialized with the current TaskanaEngine.WorkbasketServicegetWorkbasketService()Returns a WorkbasketService initialized with the current TaskanaEngine.WorkingDaysToDaysConvertergetWorkingDaysToDaysConverter()Returns the WorkingDaysToDaysConverter of the TaskanaEngine.booleanisHistoryEnabled()Checks if the TaskanaHistory plugin is enabled.booleanisUserInRole(TaskanaRole... roles)Check whether the current user is member of one of the TaskanaRoles specified.<T> TrunAsAdmin(Supplier<T> supplier)Executes a givenSupplierwith admin privileges and thus skips further permission checks.voidsetConnection(Connection connection)Set theConnectionto be used by TASKANA in mode EXPLICIT.voidsetConnectionManagementMode(TaskanaEngine.ConnectionManagementMode mode)Sets ConnectionManagementMode of the TaskanaEngine.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface pro.taskana.common.api.TaskanaEngine
runAsAdmin
-
-
-
-
Field Detail
-
taskanaEngineConfiguration
protected TaskanaEngineConfiguration taskanaEngineConfiguration
-
transactionFactory
protected org.apache.ibatis.transaction.TransactionFactory transactionFactory
-
sessionManager
protected org.apache.ibatis.session.SqlSessionManager sessionManager
-
mode
protected TaskanaEngine.ConnectionManagementMode mode
-
connection
protected Connection connection
-
-
Constructor Detail
-
TaskanaEngineImpl
protected TaskanaEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration, TaskanaEngine.ConnectionManagementMode connectionManagementMode) throws SQLException
- Throws:
SQLException
-
-
Method Detail
-
createTaskanaEngine
public static TaskanaEngine createTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration) throws SQLException
- Throws:
SQLException
-
createTaskanaEngine
public static TaskanaEngine createTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration, TaskanaEngine.ConnectionManagementMode connectionManagementMode) throws SQLException
- Throws:
SQLException
-
getConfigurationService
public ConfigurationService getConfigurationService()
Description copied from interface:TaskanaEngineReturns a ConfigurationService initialized with the current TaskanaEngine. The ConfigurationService can be used to manage custom configuration options.- Specified by:
getConfigurationServicein interfaceTaskanaEngine- Returns:
- an instance of ConfigurationService
-
getTaskService
public TaskService getTaskService()
Description copied from interface:TaskanaEngineReturns a TaskService initialized with the current TaskanaEngine. TaskService can be used for operations on all Tasks.- Specified by:
getTaskServicein interfaceTaskanaEngine- Returns:
- an instance of TaskService
-
getMonitorService
public MonitorService getMonitorService()
Description copied from interface:TaskanaEngineReturns a MonitorService initialized with the current TaskanaEngine. MonitorService can be used for monitoring Tasks.- Specified by:
getMonitorServicein interfaceTaskanaEngine- Returns:
- an instance of MonitorService
-
getWorkbasketService
public WorkbasketService getWorkbasketService()
Description copied from interface:TaskanaEngineReturns a WorkbasketService initialized with the current TaskanaEngine. The WorkbasketService can be used for operations on all Workbaskets.- Specified by:
getWorkbasketServicein interfaceTaskanaEngine- Returns:
- an instance of WorkbasketService
-
getClassificationService
public ClassificationService getClassificationService()
Description copied from interface:TaskanaEngineReturns a ClassificationService initialized with the current TaskanaEngine. The ClassificationService can be used for operations on all Classifications.- Specified by:
getClassificationServicein interfaceTaskanaEngine- Returns:
- an instance of ClassificationService
-
getPriorityServiceManager
public PriorityServiceManager getPriorityServiceManager()
-
getJobService
public JobService getJobService()
Description copied from interface:TaskanaEngineReturns a JobService initialized with the current TaskanaEngine. The JobService can be used for all operations on TaskanaJobs.- Specified by:
getJobServicein interfaceTaskanaEngine- Returns:
- an instance of JobService
-
getUserService
public UserService getUserService()
Description copied from interface:TaskanaEngineReturns a UserService initialized with the current TaskanaEngine. The UserService can be used for all operations on Users.- Specified by:
getUserServicein interfaceTaskanaEngine- Returns:
- an instance of UserService
-
getConfiguration
public TaskanaEngineConfiguration getConfiguration()
Description copied from interface:TaskanaEngineReturns the configuration of the TaskanaEngine.- Specified by:
getConfigurationin interfaceTaskanaEngine- Returns:
- configuration
-
getWorkingDaysToDaysConverter
public WorkingDaysToDaysConverter getWorkingDaysToDaysConverter()
Description copied from interface:TaskanaEngineReturns the WorkingDaysToDaysConverter of the TaskanaEngine. The WorkingDaysToDaysConverter is used to compute holidays.- Specified by:
getWorkingDaysToDaysConverterin interfaceTaskanaEngine- Returns:
- WorkingDaysToDaysConverter
-
isHistoryEnabled
public boolean isHistoryEnabled()
Description copied from interface:TaskanaEngineChecks if the TaskanaHistory plugin is enabled.- Specified by:
isHistoryEnabledin interfaceTaskanaEngine- Returns:
- true if the history is enabled; otherwise false
-
getConnectionManagementMode
public TaskanaEngine.ConnectionManagementMode getConnectionManagementMode()
Description copied from interface:TaskanaEngineReturns the ConnectionManagementMode of the TaskanaEngine.- Specified by:
getConnectionManagementModein interfaceTaskanaEngine- Returns:
- ConnectionManagementMode
-
setConnectionManagementMode
public void setConnectionManagementMode(TaskanaEngine.ConnectionManagementMode mode)
Description copied from interface:TaskanaEngineSets ConnectionManagementMode of the TaskanaEngine.- Specified by:
setConnectionManagementModein interfaceTaskanaEngine- Parameters:
mode- the valid values for the TaskanaEngine.ConnectionManagementMode are:- PARTICIPATE - taskana participates in global transaction; this is the default mode
- AUTOCOMMIT - taskana commits each API call separately
- EXPLICIT - commit processing is managed explicitly by the client
-
setConnection
public void setConnection(Connection connection) throws SQLException
Description copied from interface:TaskanaEngineSet theConnectionto be used by TASKANA in mode EXPLICIT. If this API is called, TASKANA 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.- Specified by:
setConnectionin interfaceTaskanaEngine- Parameters:
connection- - Thejava.sql.Connectionthat is controlled by the client- Throws:
SQLException- if a database access error occurs
-
closeConnection
public void closeConnection()
Description copied from interface:TaskanaEngineCloses the client's connection, sets it to null and switches to mode PARTICIPATE. Only applicable in mode EXPLICIT. Has the same effect assetConnection(null).- Specified by:
closeConnectionin interfaceTaskanaEngine
-
isUserInRole
public boolean isUserInRole(TaskanaRole... roles)
Description copied from interface:TaskanaEngineCheck whether the current user is member of one of the TaskanaRoles specified.- Specified by:
isUserInRolein interfaceTaskanaEngine- Parameters:
roles- The TaskanaRoles 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 TaskanaRole
-
checkRoleMembership
public void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException
Description copied from interface:TaskanaEngineChecks whether current user is member of any of the specified TaskanaRoles.- Specified by:
checkRoleMembershipin interfaceTaskanaEngine- Parameters:
roles- The TaskanaRoles that are checked for membership of the current user- Throws:
NotAuthorizedException- If the current user is not member of any specified TaskanaRole
-
runAsAdmin
public <T> T runAsAdmin(Supplier<T> supplier)
Description copied from interface:TaskanaEngineExecutes a givenSupplierwith admin privileges and thus skips further permission checks. With great power comes great responsibility.- Specified by:
runAsAdminin interfaceTaskanaEngine- Type Parameters:
T- defined with the return value of theSupplier- Parameters:
supplier- will be executed with admin privileges- Returns:
- output from
Supplier
-
getCurrentUserContext
public pro.taskana.common.api.security.CurrentUserContext getCurrentUserContext()
Description copied from interface:TaskanaEngineReturns the CurrentUserContext of the TaskanaEngine.- Specified by:
getCurrentUserContextin interfaceTaskanaEngine- Returns:
- CurrentUserContext
-
createSqlSessionManager
protected org.apache.ibatis.session.SqlSessionManager createSqlSessionManager()
This method creates the sqlSessionManager of myBatis. It integrates all the SQL mappers and sets the databaseId attribute.- Returns:
- a SqlSessionFactory
- Throws:
SystemException- when a connection to the database could not be opened.
-
-