TSK-1986 remove cycle between TaskanaEngineConfiguration und TaskanaEngine (#2078)
This commit is contained in:
parent
72cc0882c7
commit
53f9dce1db
|
|
@ -100,11 +100,11 @@ public abstract class AbstractAccTest {
|
||||||
|
|
||||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, schemaNameTmp);
|
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, schemaNameTmp);
|
||||||
taskanaEngine =
|
taskanaEngine =
|
||||||
taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT);
|
TaskanaEngine.buildTaskanaEngine(
|
||||||
|
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||||
taskanaHistoryEngine = TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngine);
|
taskanaHistoryEngine = TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngine);
|
||||||
historyService = new SimpleHistoryServiceImpl();
|
historyService = new SimpleHistoryServiceImpl();
|
||||||
historyService.initialize(
|
historyService.initialize(taskanaEngine);
|
||||||
taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT));
|
|
||||||
|
|
||||||
SampleDataGenerator sampleDataGenerator =
|
SampleDataGenerator sampleDataGenerator =
|
||||||
new SampleDataGenerator(dataSource, taskanaEngineConfiguration.getSchemaName());
|
new SampleDataGenerator(dataSource, taskanaEngineConfiguration.getSchemaName());
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class TaskanaEngineConfigurationTest extends AbstractAccTest {
|
||||||
TaskanaEngineConfiguration taskEngineConfiguration =
|
TaskanaEngineConfiguration taskEngineConfiguration =
|
||||||
new TaskanaEngineConfiguration(ds, false, false, DataSourceGenerator.getSchemaName());
|
new TaskanaEngineConfiguration(ds, false, false, DataSourceGenerator.getSchemaName());
|
||||||
|
|
||||||
TaskanaEngine te = taskEngineConfiguration.buildTaskanaEngine();
|
TaskanaEngine te = TaskanaEngine.buildTaskanaEngine(taskEngineConfiguration);
|
||||||
|
|
||||||
assertThat(te).isNotNull();
|
assertThat(te).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,11 @@ package pro.taskana.simplehistory.impl;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.doReturn;
|
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import acceptance.AbstractAccTest;
|
import acceptance.AbstractAccTest;
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.apache.ibatis.session.SqlSession;
|
import org.apache.ibatis.session.SqlSession;
|
||||||
|
|
@ -54,21 +52,6 @@ class SimpleHistoryServiceImplTest {
|
||||||
|
|
||||||
@Mock private SqlSession sqlSessionMock;
|
@Mock private SqlSession sqlSessionMock;
|
||||||
|
|
||||||
@Test
|
|
||||||
void testInitializeSimpleHistoryService() throws SQLException {
|
|
||||||
when(sqlSessionManagerMock.getMapper(TaskHistoryEventMapper.class))
|
|
||||||
.thenReturn(taskHistoryEventMapperMock);
|
|
||||||
when(sqlSessionManagerMock.getMapper(WorkbasketHistoryEventMapper.class))
|
|
||||||
.thenReturn(workbasketHistoryEventMapperMock);
|
|
||||||
when(taskanaHistoryEngineMock.getSqlSession()).thenReturn(sqlSessionManagerMock);
|
|
||||||
doReturn(taskanaHistoryEngineMock).when(cutSpy).getTaskanaEngine(taskanaEngine);
|
|
||||||
doReturn(taskanaEngine).when(taskanaEngineConfiguration).buildTaskanaEngine();
|
|
||||||
cutSpy.initialize(taskanaEngineConfiguration.buildTaskanaEngine());
|
|
||||||
|
|
||||||
verify(sqlSessionManagerMock, times(4)).getMapper(any());
|
|
||||||
verify(taskanaHistoryEngineMock, times(4)).getSqlSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void should_VerifyMethodInvocations_When_CreateTaskHistoryEvent() throws Exception {
|
void should_VerifyMethodInvocations_When_CreateTaskHistoryEvent() throws Exception {
|
||||||
TaskHistoryEvent expectedWb =
|
TaskHistoryEvent expectedWb =
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import pro.taskana.TaskanaEngineConfiguration;
|
import pro.taskana.TaskanaEngineConfiguration;
|
||||||
import pro.taskana.common.api.BaseQuery.SortDirection;
|
import pro.taskana.common.api.BaseQuery.SortDirection;
|
||||||
|
import pro.taskana.common.api.TaskanaEngine;
|
||||||
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
import pro.taskana.common.api.exceptions.InvalidArgumentException;
|
||||||
import pro.taskana.common.rest.QueryPagingParameter;
|
import pro.taskana.common.rest.QueryPagingParameter;
|
||||||
import pro.taskana.common.rest.QuerySortBy;
|
import pro.taskana.common.rest.QuerySortBy;
|
||||||
|
|
@ -47,7 +48,8 @@ public class TaskHistoryEventController {
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
|
|
||||||
this.simpleHistoryService = simpleHistoryServiceImpl;
|
this.simpleHistoryService = simpleHistoryServiceImpl;
|
||||||
this.simpleHistoryService.initialize(taskanaEngineConfiguration.buildTaskanaEngine());
|
this.simpleHistoryService.initialize(
|
||||||
|
TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration));
|
||||||
this.assembler = assembler;
|
this.assembler = assembler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ public class TaskanaProducers {
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
@Produces
|
@Produces
|
||||||
public TaskanaEngine generateTaskEngine() throws SQLException {
|
public TaskanaEngine generateTaskEngine() throws SQLException {
|
||||||
return taskanaEngineConfiguration.buildTaskanaEngine();
|
return TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApplicationScoped
|
@ApplicationScoped
|
||||||
|
|
|
||||||
|
|
@ -213,6 +213,8 @@ class ArchitectureTest {
|
||||||
classes()
|
classes()
|
||||||
.that()
|
.that()
|
||||||
.resideInAPackage("..api..")
|
.resideInAPackage("..api..")
|
||||||
|
.and()
|
||||||
|
.areNotAssignableFrom(TaskanaEngine.class)
|
||||||
.should()
|
.should()
|
||||||
.onlyDependOnClassesThat(
|
.onlyDependOnClassesThat(
|
||||||
resideOutsideOfPackage("..pro.taskana..internal..")
|
resideOutsideOfPackage("..pro.taskana..internal..")
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,8 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import pro.taskana.common.api.CustomHoliday;
|
import pro.taskana.common.api.CustomHoliday;
|
||||||
import pro.taskana.common.api.TaskanaEngine;
|
|
||||||
import pro.taskana.common.api.TaskanaEngine.ConnectionManagementMode;
|
|
||||||
import pro.taskana.common.api.TaskanaRole;
|
import pro.taskana.common.api.TaskanaRole;
|
||||||
import pro.taskana.common.api.exceptions.SystemException;
|
import pro.taskana.common.api.exceptions.SystemException;
|
||||||
import pro.taskana.common.internal.TaskanaEngineImpl;
|
|
||||||
import pro.taskana.common.internal.configuration.DB;
|
import pro.taskana.common.internal.configuration.DB;
|
||||||
import pro.taskana.common.internal.configuration.TaskanaProperty;
|
import pro.taskana.common.internal.configuration.TaskanaProperty;
|
||||||
import pro.taskana.common.internal.util.FileLoaderUtil;
|
import pro.taskana.common.internal.util.FileLoaderUtil;
|
||||||
|
|
@ -241,21 +238,6 @@ public class TaskanaEngineConfiguration {
|
||||||
return createDatasource(driverClass, jdbcUrl, username, password);
|
return createDatasource(driverClass, jdbcUrl, username, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method creates the TaskanaEngine without an sqlSessionFactory.
|
|
||||||
*
|
|
||||||
* @return the TaskanaEngine
|
|
||||||
* @throws SQLException if a database access error occurs
|
|
||||||
*/
|
|
||||||
public TaskanaEngine buildTaskanaEngine() throws SQLException {
|
|
||||||
return TaskanaEngineImpl.createTaskanaEngine(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TaskanaEngine buildTaskanaEngine(ConnectionManagementMode connectionManagementMode)
|
|
||||||
throws SQLException {
|
|
||||||
return TaskanaEngineImpl.createTaskanaEngine(this, connectionManagementMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method creates a PooledDataSource, if the needed properties are provided.
|
* This method creates a PooledDataSource, if the needed properties are provided.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import pro.taskana.TaskanaEngineConfiguration;
|
||||||
import pro.taskana.classification.api.ClassificationService;
|
import pro.taskana.classification.api.ClassificationService;
|
||||||
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
import pro.taskana.common.api.exceptions.NotAuthorizedException;
|
||||||
import pro.taskana.common.api.security.CurrentUserContext;
|
import pro.taskana.common.api.security.CurrentUserContext;
|
||||||
|
import pro.taskana.common.internal.TaskanaEngineImpl;
|
||||||
import pro.taskana.monitor.api.MonitorService;
|
import pro.taskana.monitor.api.MonitorService;
|
||||||
import pro.taskana.task.api.TaskService;
|
import pro.taskana.task.api.TaskService;
|
||||||
import pro.taskana.task.api.models.Task;
|
import pro.taskana.task.api.models.Task;
|
||||||
|
|
@ -83,6 +84,33 @@ public interface TaskanaEngine {
|
||||||
*/
|
*/
|
||||||
TaskanaEngineConfiguration getConfiguration();
|
TaskanaEngineConfiguration getConfiguration();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method creates the {@linkplain TaskanaEngine} with {@linkplain
|
||||||
|
* ConnectionManagementMode#PARTICIPATE }.
|
||||||
|
*
|
||||||
|
* @see TaskanaEngine#buildTaskanaEngine(TaskanaEngineConfiguration, ConnectionManagementMode)
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
|
static TaskanaEngine buildTaskanaEngine(TaskanaEngineConfiguration configuration)
|
||||||
|
throws SQLException {
|
||||||
|
return buildTaskanaEngine(configuration, ConnectionManagementMode.PARTICIPATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds an {@linkplain TaskanaEngine} based on {@linkplain TaskanaEngineConfiguration} and
|
||||||
|
* SqlConnectionMode.
|
||||||
|
*
|
||||||
|
* @param configuration complete taskanaEngineConfig to build the engine
|
||||||
|
* @param connectionManagementMode connectionMode for the SqlSession
|
||||||
|
* @return a {@linkplain TaskanaEngineImpl}
|
||||||
|
* @throws SQLException when the db schema could not be initialized
|
||||||
|
*/
|
||||||
|
static TaskanaEngine buildTaskanaEngine(
|
||||||
|
TaskanaEngineConfiguration configuration, ConnectionManagementMode connectionManagementMode)
|
||||||
|
throws SQLException {
|
||||||
|
return TaskanaEngineImpl.createTaskanaEngine(configuration, connectionManagementMode);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@linkplain WorkingDaysToDaysConverter} of the TaskanaEngine. The {@linkplain
|
* Returns the {@linkplain WorkingDaysToDaysConverter} of the TaskanaEngine. The {@linkplain
|
||||||
* WorkingDaysToDaysConverter} is used to compute holidays.
|
* WorkingDaysToDaysConverter} is used to compute holidays.
|
||||||
|
|
|
||||||
|
|
@ -136,11 +136,6 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
||||||
afterRequestChangesManager = new AfterRequestChangesManager(this);
|
afterRequestChangesManager = new AfterRequestChangesManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TaskanaEngine createTaskanaEngine(
|
|
||||||
TaskanaEngineConfiguration taskanaEngineConfiguration) throws SQLException {
|
|
||||||
return createTaskanaEngine(taskanaEngineConfiguration, ConnectionManagementMode.PARTICIPATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TaskanaEngine createTaskanaEngine(
|
public static TaskanaEngine createTaskanaEngine(
|
||||||
TaskanaEngineConfiguration taskanaEngineConfiguration,
|
TaskanaEngineConfiguration taskanaEngineConfiguration,
|
||||||
ConnectionManagementMode connectionManagementMode)
|
ConnectionManagementMode connectionManagementMode)
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,8 @@ public abstract class AbstractAccTest {
|
||||||
sampleDataGenerator.dropDb();
|
sampleDataGenerator.dropDb();
|
||||||
}
|
}
|
||||||
taskanaEngine =
|
taskanaEngine =
|
||||||
taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT);
|
TaskanaEngine.buildTaskanaEngine(
|
||||||
|
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||||
converter = taskanaEngine.getWorkingDaysToDaysConverter();
|
converter = taskanaEngine.getWorkingDaysToDaysConverter();
|
||||||
taskService = (TaskServiceImpl) taskanaEngine.getTaskService();
|
taskService = (TaskServiceImpl) taskanaEngine.getTaskService();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ class TaskanaEngineConfigTest {
|
||||||
TaskanaEngineConfiguration taskEngineConfiguration =
|
TaskanaEngineConfiguration taskEngineConfiguration =
|
||||||
new TaskanaEngineConfiguration(ds, false, DataSourceGenerator.getSchemaName());
|
new TaskanaEngineConfiguration(ds, false, DataSourceGenerator.getSchemaName());
|
||||||
|
|
||||||
TaskanaEngine te = taskEngineConfiguration.buildTaskanaEngine();
|
TaskanaEngine te = TaskanaEngine.buildTaskanaEngine(taskEngineConfiguration);
|
||||||
|
|
||||||
assertThat(te).isNotNull();
|
assertThat(te).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import pro.taskana.TaskanaEngineConfiguration;
|
import pro.taskana.TaskanaEngineConfiguration;
|
||||||
|
import pro.taskana.common.api.TaskanaEngine;
|
||||||
import pro.taskana.common.api.exceptions.SystemException;
|
import pro.taskana.common.api.exceptions.SystemException;
|
||||||
import pro.taskana.common.internal.configuration.DB;
|
import pro.taskana.common.internal.configuration.DB;
|
||||||
import pro.taskana.common.internal.configuration.DbSchemaCreator;
|
import pro.taskana.common.internal.configuration.DbSchemaCreator;
|
||||||
|
|
@ -75,12 +76,12 @@ class TaskanaSecurityConfigAccTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTaskanaEngine(boolean securityEnabled) throws SQLException {
|
private void createTaskanaEngine(boolean securityEnabled) throws SQLException {
|
||||||
new TaskanaEngineConfiguration(
|
TaskanaEngine.buildTaskanaEngine(
|
||||||
|
new TaskanaEngineConfiguration(
|
||||||
DataSourceGenerator.getDataSource(),
|
DataSourceGenerator.getDataSource(),
|
||||||
false,
|
false,
|
||||||
securityEnabled,
|
securityEnabled,
|
||||||
DataSourceGenerator.getSchemaName())
|
DataSourceGenerator.getSchemaName()));
|
||||||
.buildTaskanaEngine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean retrieveSecurityFlag() throws Exception {
|
private Boolean retrieveSecurityFlag() throws Exception {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,8 @@ class JobRunnerAccTest extends AbstractAccTest {
|
||||||
() -> {
|
() -> {
|
||||||
try {
|
try {
|
||||||
TaskanaEngine taskanaEngine =
|
TaskanaEngine taskanaEngine =
|
||||||
taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT);
|
TaskanaEngine.buildTaskanaEngine(
|
||||||
|
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||||
DataSource dataSource = DataSourceGenerator.getDataSource();
|
DataSource dataSource = DataSourceGenerator.getDataSource();
|
||||||
// We have to slow down the transaction.
|
// We have to slow down the transaction.
|
||||||
// This is necessary to guarantee the execution of
|
// This is necessary to guarantee the execution of
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ public abstract class AbstractReportAccTest {
|
||||||
String schemaName = DataSourceGenerator.getSchemaName();
|
String schemaName = DataSourceGenerator.getSchemaName();
|
||||||
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, schemaName);
|
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false, schemaName);
|
||||||
taskanaEngineConfiguration.setGermanPublicHolidaysEnabled(false);
|
taskanaEngineConfiguration.setGermanPublicHolidaysEnabled(false);
|
||||||
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
|
taskanaEngine = TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||||
taskanaEngine.setConnectionManagementMode(TaskanaEngine.ConnectionManagementMode.AUTOCOMMIT);
|
taskanaEngine.setConnectionManagementMode(TaskanaEngine.ConnectionManagementMode.AUTOCOMMIT);
|
||||||
SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(dataSource, schemaName);
|
SampleDataGenerator sampleDataGenerator = new SampleDataGenerator(dataSource, schemaName);
|
||||||
sampleDataGenerator.clearDb();
|
sampleDataGenerator.clearDb();
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,10 @@ import org.springframework.context.annotation.PropertySource;
|
||||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
import pro.taskana.SpringTaskanaEngineConfiguration;
|
import pro.taskana.TaskanaEngineConfiguration;
|
||||||
import pro.taskana.classification.api.ClassificationService;
|
import pro.taskana.classification.api.ClassificationService;
|
||||||
import pro.taskana.common.api.TaskanaEngine;
|
import pro.taskana.common.api.TaskanaEngine;
|
||||||
|
import pro.taskana.common.internal.SpringTaskanaEngine;
|
||||||
import pro.taskana.task.api.TaskService;
|
import pro.taskana.task.api.TaskService;
|
||||||
import pro.taskana.user.api.UserService;
|
import pro.taskana.user.api.UserService;
|
||||||
import pro.taskana.workbasket.api.WorkbasketService;
|
import pro.taskana.workbasket.api.WorkbasketService;
|
||||||
|
|
@ -49,14 +50,14 @@ public class TaskanaConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SpringTaskanaEngineConfiguration taskanaEngineConfiguration(DataSource dataSource) {
|
public TaskanaEngineConfiguration taskanaEngineConfiguration(DataSource dataSource) {
|
||||||
return new SpringTaskanaEngineConfiguration(dataSource, true, false, schemaName);
|
return new TaskanaEngineConfiguration(dataSource, true, false, schemaName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TaskanaEngine taskanaEngine(SpringTaskanaEngineConfiguration taskanaEngineConfiguration)
|
public TaskanaEngine taskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
return taskanaEngineConfiguration.buildTaskanaEngine();
|
return SpringTaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
package pro.taskana;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
import pro.taskana.common.api.TaskanaEngine;
|
|
||||||
import pro.taskana.common.api.TaskanaEngine.ConnectionManagementMode;
|
|
||||||
import pro.taskana.common.internal.SpringTaskanaEngineImpl;
|
|
||||||
|
|
||||||
/** This class configures the TaskanaEngineConfiguration for spring. */
|
|
||||||
public class SpringTaskanaEngineConfiguration extends TaskanaEngineConfiguration {
|
|
||||||
|
|
||||||
public SpringTaskanaEngineConfiguration(
|
|
||||||
DataSource dataSource,
|
|
||||||
boolean useManagedTransactions,
|
|
||||||
boolean securityEnabled,
|
|
||||||
String schemaName) {
|
|
||||||
super(dataSource, useManagedTransactions, securityEnabled, schemaName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpringTaskanaEngineConfiguration(
|
|
||||||
DataSource dataSource,
|
|
||||||
boolean useManagedTransactions,
|
|
||||||
boolean securityEnabled,
|
|
||||||
String propertiesFileName,
|
|
||||||
String propertiesSeparator,
|
|
||||||
String schemaName) {
|
|
||||||
super(
|
|
||||||
dataSource,
|
|
||||||
useManagedTransactions,
|
|
||||||
securityEnabled,
|
|
||||||
propertiesFileName,
|
|
||||||
propertiesSeparator,
|
|
||||||
schemaName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method creates the Spring-based TaskanaEngine without an sqlSessionFactory.
|
|
||||||
*
|
|
||||||
* @return the TaskanaEngine
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public TaskanaEngine buildTaskanaEngine() throws SQLException {
|
|
||||||
this.useManagedTransactions = true;
|
|
||||||
return new SpringTaskanaEngineImpl(this, ConnectionManagementMode.PARTICIPATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDataSource(DataSource dataSource) {
|
|
||||||
this.dataSource = dataSource;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
package pro.taskana.common.internal;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import pro.taskana.TaskanaEngineConfiguration;
|
||||||
|
import pro.taskana.common.api.TaskanaEngine;
|
||||||
|
|
||||||
|
public interface SpringTaskanaEngine extends TaskanaEngine {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method creates the {@linkplain SpringTaskanaEngine} with {@linkplain
|
||||||
|
* ConnectionManagementMode#PARTICIPATE }.
|
||||||
|
*
|
||||||
|
* @see SpringTaskanaEngine#buildTaskanaEngine(TaskanaEngineConfiguration,
|
||||||
|
* ConnectionManagementMode)
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod")
|
||||||
|
static SpringTaskanaEngine buildTaskanaEngine(TaskanaEngineConfiguration configuration)
|
||||||
|
throws SQLException {
|
||||||
|
return SpringTaskanaEngine.buildTaskanaEngine(
|
||||||
|
configuration, ConnectionManagementMode.PARTICIPATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds an {@linkplain SpringTaskanaEngine} based on {@linkplain TaskanaEngineConfiguration} and
|
||||||
|
* SqlConnectionMode.
|
||||||
|
*
|
||||||
|
* @param configuration complete taskanaEngineConfig to build the engine
|
||||||
|
* @param connectionManagementMode connectionMode for the SqlSession
|
||||||
|
* @return a {@linkplain SpringTaskanaEngineImpl}
|
||||||
|
* @throws SQLException when the db schema could not be initialized
|
||||||
|
*/
|
||||||
|
static SpringTaskanaEngine buildTaskanaEngine(
|
||||||
|
TaskanaEngineConfiguration configuration, ConnectionManagementMode connectionManagementMode)
|
||||||
|
throws SQLException {
|
||||||
|
return SpringTaskanaEngineImpl.createTaskanaEngine(configuration, connectionManagementMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,23 +1,25 @@
|
||||||
package pro.taskana.common.internal;
|
package pro.taskana.common.internal;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
|
import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
|
||||||
|
|
||||||
import pro.taskana.SpringTaskanaEngineConfiguration;
|
import pro.taskana.TaskanaEngineConfiguration;
|
||||||
|
|
||||||
/** This class configures the TaskanaEngine for spring. */
|
/** This class configures the TaskanaEngine for spring. */
|
||||||
public class SpringTaskanaEngineImpl extends TaskanaEngineImpl {
|
public class SpringTaskanaEngineImpl extends TaskanaEngineImpl implements SpringTaskanaEngine {
|
||||||
|
|
||||||
public SpringTaskanaEngineImpl(
|
public SpringTaskanaEngineImpl(
|
||||||
SpringTaskanaEngineConfiguration taskanaEngineConfiguration, ConnectionManagementMode mode)
|
TaskanaEngineConfiguration taskanaEngineConfiguration, ConnectionManagementMode mode)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
super(taskanaEngineConfiguration, mode);
|
super(taskanaEngineConfiguration, mode);
|
||||||
}
|
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void init() {
|
|
||||||
this.transactionFactory = new SpringManagedTransactionFactory();
|
this.transactionFactory = new SpringManagedTransactionFactory();
|
||||||
this.sessionManager = createSqlSessionManager();
|
this.sessionManager = createSqlSessionManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SpringTaskanaEngine createTaskanaEngine(
|
||||||
|
TaskanaEngineConfiguration taskanaEngineConfiguration,
|
||||||
|
ConnectionManagementMode connectionManagementMode)
|
||||||
|
throws SQLException {
|
||||||
|
return new SpringTaskanaEngineImpl(taskanaEngineConfiguration, connectionManagementMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,8 @@ public class TaskanaInitializationExtension implements TestInstancePostProcessor
|
||||||
(spi, serviceProviders) ->
|
(spi, serviceProviders) ->
|
||||||
staticMock.when(() -> SpiLoader.load(spi)).thenReturn(serviceProviders));
|
staticMock.when(() -> SpiLoader.load(spi)).thenReturn(serviceProviders));
|
||||||
taskanaEngine =
|
taskanaEngine =
|
||||||
taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT);
|
TaskanaEngine.buildTaskanaEngine(
|
||||||
|
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
store.put(STORE_TASKANA_ENTITY_MAP, generateTaskanaEntityMap(taskanaEngine));
|
store.put(STORE_TASKANA_ENTITY_MAP, generateTaskanaEntityMap(taskanaEngine));
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ public class ExampleRestConfiguration {
|
||||||
@DependsOn("generateSampleData")
|
@DependsOn("generateSampleData")
|
||||||
public TaskanaEngine getTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration)
|
public TaskanaEngine getTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
return taskanaEngineConfiguration.buildTaskanaEngine();
|
return TaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
// only required to let the adapter example connect to the same database
|
// only required to let the adapter example connect to the same database
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.converter.json.SpringHandlerInstantiator;
|
import org.springframework.http.converter.json.SpringHandlerInstantiator;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
|
|
||||||
import pro.taskana.SpringTaskanaEngineConfiguration;
|
|
||||||
import pro.taskana.TaskanaEngineConfiguration;
|
import pro.taskana.TaskanaEngineConfiguration;
|
||||||
import pro.taskana.classification.api.ClassificationService;
|
import pro.taskana.classification.api.ClassificationService;
|
||||||
import pro.taskana.common.api.ConfigurationService;
|
import pro.taskana.common.api.ConfigurationService;
|
||||||
import pro.taskana.common.api.TaskanaEngine;
|
import pro.taskana.common.api.TaskanaEngine;
|
||||||
import pro.taskana.common.api.security.CurrentUserContext;
|
import pro.taskana.common.api.security.CurrentUserContext;
|
||||||
|
import pro.taskana.common.internal.SpringTaskanaEngine;
|
||||||
import pro.taskana.monitor.api.MonitorService;
|
import pro.taskana.monitor.api.MonitorService;
|
||||||
import pro.taskana.task.api.TaskService;
|
import pro.taskana.task.api.TaskService;
|
||||||
import pro.taskana.user.api.UserService;
|
import pro.taskana.user.api.UserService;
|
||||||
|
|
@ -74,13 +74,13 @@ public class RestConfiguration {
|
||||||
@ConditionalOnMissingBean(TaskanaEngine.class)
|
@ConditionalOnMissingBean(TaskanaEngine.class)
|
||||||
public TaskanaEngine getTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration)
|
public TaskanaEngine getTaskanaEngine(TaskanaEngineConfiguration taskanaEngineConfiguration)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
return taskanaEngineConfiguration.buildTaskanaEngine();
|
return SpringTaskanaEngine.buildTaskanaEngine(taskanaEngineConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean(TaskanaEngineConfiguration.class)
|
@ConditionalOnMissingBean(TaskanaEngineConfiguration.class)
|
||||||
public TaskanaEngineConfiguration taskanaEngineConfiguration(DataSource dataSource) {
|
public TaskanaEngineConfiguration taskanaEngineConfiguration(DataSource dataSource) {
|
||||||
return new SpringTaskanaEngineConfiguration(dataSource, true, true, schemaName);
|
return new TaskanaEngineConfiguration(dataSource, true, true, schemaName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for injection into jackson deserializer.
|
// Needed for injection into jackson deserializer.
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,8 @@ class DmnConverterServiceAccTest {
|
||||||
sampleDataGenerator.dropDb();
|
sampleDataGenerator.dropDb();
|
||||||
}
|
}
|
||||||
taskanaEngine =
|
taskanaEngine =
|
||||||
taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT);
|
TaskanaEngine.buildTaskanaEngine(
|
||||||
|
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||||
|
|
||||||
sampleDataGenerator.clearDb();
|
sampleDataGenerator.clearDb();
|
||||||
sampleDataGenerator.generateTestData();
|
sampleDataGenerator.generateTestData();
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ public abstract class AbstractAccTest {
|
||||||
sampleDataGenerator.clearDb();
|
sampleDataGenerator.clearDb();
|
||||||
sampleDataGenerator.generateTestData();
|
sampleDataGenerator.generateTestData();
|
||||||
taskanaEngine =
|
taskanaEngine =
|
||||||
taskanaEngineConfiguration.buildTaskanaEngine(ConnectionManagementMode.AUTOCOMMIT);
|
TaskanaEngine.buildTaskanaEngine(
|
||||||
|
taskanaEngineConfiguration, ConnectionManagementMode.AUTOCOMMIT);
|
||||||
converter = taskanaEngine.getWorkingDaysToDaysConverter();
|
converter = taskanaEngine.getWorkingDaysToDaysConverter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue