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)
-
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 roles.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)ClassificationServicegetClassificationService()The ClassificationService can be used for operations on all Categories.TaskanaEngineConfigurationgetConfiguration()The Taskana configuration.pro.taskana.common.api.security.CurrentUserContextgetCurrentUserContext()Returns the CurrentUserContext class.JobServicegetJobService()The JobService can be user for all job operations.MonitorServicegetMonitorService()The MonitorService can be used for monitoring Tasks.TaskServicegetTaskService()The TaskService can be used for operations on all Tasks.WorkbasketServicegetWorkbasketService()The WorkbasketService can be used for operations on all Workbaskets.WorkingDaysToDaysConvertergetWorkingDaysToDaysConverter()The WorkingDaysToDaysConverter used to compute holidays.booleanisHistoryEnabled()Checks if the history plugin is enabled.booleanisUserInRole(TaskanaRole... roles)check whether the current user is member of one of the roles specified.<T> TrunAsAdmin(Supplier<T> supplier)This method is supposed to skip further permission checks if we are already in a secured environment.voidsetConnection(Connection connection)Set the connection to be used by taskana in mode CONNECTION_MANAGED_EXTERNALLY.voidsetConnectionManagementMode(TaskanaEngine.ConnectionManagementMode mode)sets the connection management mode.
-
-
-
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) throws SQLException
- Throws:
SQLException
-
-
Method Detail
-
createTaskanaEngine
public static TaskanaEngine createTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration) throws SQLException
- Throws:
SQLException
-
getTaskService
public TaskService getTaskService()
Description copied from interface:TaskanaEngineThe TaskService can be used for operations on all Tasks.- Specified by:
getTaskServicein interfaceTaskanaEngine- Returns:
- the TaskService
-
getMonitorService
public MonitorService getMonitorService()
Description copied from interface:TaskanaEngineThe MonitorService can be used for monitoring Tasks.- Specified by:
getMonitorServicein interfaceTaskanaEngine- Returns:
- the MonitorService
-
getWorkbasketService
public WorkbasketService getWorkbasketService()
Description copied from interface:TaskanaEngineThe WorkbasketService can be used for operations on all Workbaskets.- Specified by:
getWorkbasketServicein interfaceTaskanaEngine- Returns:
- the WorbasketService
-
getClassificationService
public ClassificationService getClassificationService()
Description copied from interface:TaskanaEngineThe ClassificationService can be used for operations on all Categories.- Specified by:
getClassificationServicein interfaceTaskanaEngine- Returns:
- the ClassificationService
-
getJobService
public JobService getJobService()
Description copied from interface:TaskanaEngineThe JobService can be user for all job operations.- Specified by:
getJobServicein interfaceTaskanaEngine- Returns:
- the JobService
-
getConfiguration
public TaskanaEngineConfiguration getConfiguration()
Description copied from interface:TaskanaEngineThe Taskana configuration.- Specified by:
getConfigurationin interfaceTaskanaEngine- Returns:
- the TaskanaConfiguration
-
getWorkingDaysToDaysConverter
public WorkingDaysToDaysConverter getWorkingDaysToDaysConverter()
Description copied from interface:TaskanaEngineThe WorkingDaysToDaysConverter used to compute holidays.- Specified by:
getWorkingDaysToDaysConverterin interfaceTaskanaEngine- Returns:
- the converter
-
isHistoryEnabled
public boolean isHistoryEnabled()
Description copied from interface:TaskanaEngineChecks if the history plugin is enabled.- Specified by:
isHistoryEnabledin interfaceTaskanaEngine- Returns:
- true if the history is enabled. Otherwise false.
-
setConnectionManagementMode
public void setConnectionManagementMode(TaskanaEngine.ConnectionManagementMode mode)
Description copied from interface:TaskanaEnginesets the connection management mode.- Specified by:
setConnectionManagementModein interfaceTaskanaEngine- Parameters:
mode- the connection management mode Valid values 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 the connection to be used by taskana in mode CONNECTION_MANAGED_EXTERNALLY. If this Api is called, taskana 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.- Specified by:
setConnectionin interfaceTaskanaEngine- Parameters:
connection- - The java.sql.Connection that 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 as setConnection(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 roles specified.- Specified by:
isUserInRolein interfaceTaskanaEngine- Parameters:
roles- The roles 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 groups
-
checkRoleMembership
public void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException
Description copied from interface:TaskanaEngineChecks whether current user is member of any of the specified roles.- Specified by:
checkRoleMembershipin interfaceTaskanaEngine- Parameters:
roles- The roles that are checked for membership of the current user- Throws:
NotAuthorizedException- If the current user is not member of any specified role
-
getCurrentUserContext
public pro.taskana.common.api.security.CurrentUserContext getCurrentUserContext()
Description copied from interface:TaskanaEngineReturns the CurrentUserContext class.- Specified by:
getCurrentUserContextin interfaceTaskanaEngine- Returns:
- the CurrentUserContext
-
runAsAdmin
public <T> T runAsAdmin(Supplier<T> supplier)
Description copied from interface:TaskanaEngineThis method is supposed to skip further permission checks if we are already in a secured environment. With great power comes great responsibility.- Specified by:
runAsAdminin interfaceTaskanaEngine- Type Parameters:
T- defined with the supplier return value- Parameters:
supplier- will be executed with admin privileges- Returns:
- output from supplier
-
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.
-
-