TSK-155: Extend workbasket level report by subdivision into cluster

- Create method that creates the report by a list of workbaskets, a list
of states and a list of cluster
- Create methods for initialization, create sumline and add counts in
the ReportLines
- Exclude tasks with DUE = null from the query
- Add method for manipulating SQL data
- Set databaseId to allow database specific queries in the mapper
- Remove integration tests and replace them by an acceptance test
- Create an own monitor test data method in TestDataGenerator
- ProvideWorkbasketLevelReportAccTest doesn't extend AbstractAccTest
anymore
This commit is contained in:
Konstantin Kläger 2018-01-23 11:00:23 +01:00 committed by Marcel Lengl
parent 7497518281
commit a41eeffacb
23 changed files with 1263 additions and 1091 deletions

View File

@ -4,6 +4,7 @@ import java.util.List;
import pro.taskana.model.DueWorkbasketCounter; import pro.taskana.model.DueWorkbasketCounter;
import pro.taskana.model.Report; import pro.taskana.model.Report;
import pro.taskana.model.ReportLineItemDefinition;
import pro.taskana.model.TaskState; import pro.taskana.model.TaskState;
import pro.taskana.model.TaskStateCounter; import pro.taskana.model.TaskStateCounter;
@ -50,14 +51,38 @@ public interface TaskMonitorService {
List<DueWorkbasketCounter> getTaskCountByWorkbasketAndDaysInPastAndState(long daysInPast, List<TaskState> states); List<DueWorkbasketCounter> getTaskCountByWorkbasketAndDaysInPastAndState(long daysInPast, List<TaskState> states);
/** /**
* Returns a {@link Report} for a given list of {@link Workbasket} objects and for a given list of {@link TaskState} * Returns a {@link Report} for a given list of {@link Workbasket}s and for a given list of {@link TaskState}s. The
* objects. * report only contains the number of all tasks of the respective workbasket as well as the total sum of all tasks.
* Only tasks with a state in the list of TaskStates are provided. Task with Timestamp DUE = null are not
* considered.
* *
* @param workbaskets * @param workbaskets
* a list of {@link Workbasket} objects * a list of {@link Workbasket} objects that should be listed in the report
* @param states * @param states
* a list of {@link TaskState} objects * a list of {@link TaskState} objects that specify the states of the tasks that are provided
* @return a {@link Report} object * @return a {@link Report} object that only contains the number of all tasks of the respective workbasket as well
* as the total number of all tasks
*/ */
Report getWorkbasketLevelReport(List<Workbasket> workbaskets, List<TaskState> states); Report getWorkbasketLevelReport(List<Workbasket> workbaskets, List<TaskState> states);
/**
* Returns a {@link Report} for a given list of {@link Workbasket}s, a given list of {@link TaskState}s and a given
* list of {@link ReportLineItemDefinition}s. For each workbasket the report contains a list of ReportLineItems that
* subdivides the report in to different cluster grouped by the due date. Only tasks with a state in the list of
* TaskStates are provided. Tasks with Timestamp DUE = null are not considered.
*
* @param workbaskets
* a list of {@link Workbasket} objects that should be listed in the report
* @param states
* a list of {@link TaskState} objects that specify the states of the tasks that are provided
* @param reportLineItemDefinitions
* a list of {@link ReportLineItemDefinition} objects that specify the subdivision into different cluster
* of due dates. Days in past are represented as negative values and days in the future are represented
* as positive values. To avoid tasks are counted multiple times or not be listed in the report, these
* reportLineItemDefinitions should not overlap and should not have gaps. If the ReportLineDefinition
* should represent a single day, lowerLimit and upperLimit have to be equal.
* @return a {@link Report} object that represents an overview of all tasks in the
*/
Report getWorkbasketLevelReport(List<Workbasket> workbaskets, List<TaskState> states,
List<ReportLineItemDefinition> reportLineItemDefinitions);
} }

View File

@ -1,109 +1,109 @@
package pro.taskana.configuration; package pro.taskana.configuration;
import java.sql.SQLException; import java.sql.SQLException;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.apache.ibatis.datasource.pooled.PooledDataSource; import org.apache.ibatis.datasource.pooled.PooledDataSource;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaEngine;
import pro.taskana.impl.TaskanaEngineImpl; import pro.taskana.impl.TaskanaEngineImpl;
/** /**
* This central class creates the TaskanaEngine and holds all the information about DB and Security. * This central class creates the TaskanaEngine and holds all the information about DB and Security.
*/ */
public class TaskanaEngineConfiguration { public class TaskanaEngineConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfiguration.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfiguration.class);
private static final String USER_NAME = "sa"; private static final String USER_NAME = "sa";
private static final String USER_PASSWORD = "sa"; private static final String USER_PASSWORD = "sa";
private static final String JDBC_H2_MEM_TASKANA = "jdbc:h2:mem:taskana"; private static final String JDBC_H2_MEM_TASKANA = "jdbc:h2:mem:taskana";
private static final String H2_DRIVER = "org.h2.Driver"; private static final String H2_DRIVER = "org.h2.Driver";
protected DataSource dataSource; protected DataSource dataSource;
protected DbSchemaCreator dbScriptRunner; protected DbSchemaCreator dbScriptRunner;
// global switch to enable JAAS based authentication and Taskana // global switch to enable JAAS based authentication and Taskana
// authorizations // authorizations
protected boolean securityEnabled; protected boolean securityEnabled;
protected boolean useManagedTransactions; protected boolean useManagedTransactions;
public TaskanaEngineConfiguration() { public TaskanaEngineConfiguration() {
} }
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions) public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions)
throws SQLException { throws SQLException {
this(dataSource, useManagedTransactions, true); this(dataSource, useManagedTransactions, true);
} }
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions, public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions,
boolean securityEnabled) throws SQLException { boolean securityEnabled) throws SQLException {
this.useManagedTransactions = useManagedTransactions; this.useManagedTransactions = useManagedTransactions;
if (dataSource != null) { if (dataSource != null) {
this.dataSource = dataSource; this.dataSource = dataSource;
} else { } else {
// use default In Memory datasource // use default In Memory datasource
this.dataSource = createDefaultDataSource(); this.dataSource = createDefaultDataSource();
} }
dbScriptRunner = new DbSchemaCreator(this.dataSource); dbScriptRunner = new DbSchemaCreator(this.dataSource);
dbScriptRunner.run(); dbScriptRunner.run();
this.securityEnabled = securityEnabled; this.securityEnabled = securityEnabled;
} }
public static DataSource createDefaultDataSource() { public static DataSource createDefaultDataSource() {
LOGGER.warn("No datasource is provided. A inmemory db is used: " LOGGER.warn("No datasource is provided. A inmemory db is used: "
+ "'org.h2.Driver', 'jdbc:h2:mem:taskana', 'sa', 'sa'"); + "'org.h2.Driver', 'jdbc:h2:mem:taskana', 'sa', 'sa'");
return createDatasource(H2_DRIVER, JDBC_H2_MEM_TASKANA, USER_NAME, USER_PASSWORD); return createDatasource(H2_DRIVER, JDBC_H2_MEM_TASKANA, USER_NAME, USER_PASSWORD);
} }
/** /**
* This method creates the TaskanaEngine without an sqlSessionFactory. * This method creates the TaskanaEngine without an sqlSessionFactory.
* *
* @return the TaskanaEngine * @return the TaskanaEngine
*/ */
public TaskanaEngine buildTaskanaEngine() { public TaskanaEngine buildTaskanaEngine() {
return new TaskanaEngineImpl(this); return new TaskanaEngineImpl(this);
} }
/** /**
* This method creates a PooledDataSource, if the needed properties are provided. * This method creates a PooledDataSource, if the needed properties are provided.
* *
* @param driver * @param driver
* the name of the jdbc driver * the name of the jdbc driver
* @param jdbcUrl * @param jdbcUrl
* the url to which the jdbc driver connects * the url to which the jdbc driver connects
* @param username * @param username
* the user name for database access * the user name for database access
* @param password * @param password
* the password for database access * the password for database access
* @return DataSource * @return DataSource
*/ */
public static DataSource createDatasource(String driver, String jdbcUrl, String username, String password) { public static DataSource createDatasource(String driver, String jdbcUrl, String username, String password) {
return new PooledDataSource(driver, jdbcUrl, username, password); return new PooledDataSource(driver, jdbcUrl, username, password);
} }
public boolean isSecurityEnabled() { public boolean isSecurityEnabled() {
return this.securityEnabled; return this.securityEnabled;
} }
public DataSource getDatasource() { public DataSource getDatasource() {
return this.dataSource; return this.dataSource;
} }
public boolean getUseManagedTransactions() { public boolean getUseManagedTransactions() {
return this.useManagedTransactions; return this.useManagedTransactions;
} }
/** /**
* Helper method to determine whether all access ids (user Id and group ids) should be used in lower case. * Helper method to determine whether all access ids (user Id and group ids) should be used in lower case.
* *
* @return true if all access ids should be used in lower case, false otherwise * @return true if all access ids should be used in lower case, false otherwise
*/ */
public static boolean shouldUseLowerCaseForAccessIds() { public static boolean shouldUseLowerCaseForAccessIds() {
return true; return true;
} }
} }

View File

@ -0,0 +1,13 @@
package pro.taskana.exceptions;
/**
* This exception will be thrown if the database name doesn't match to one of the desired databases.
*/
public class UnsupportedDatabaseException extends RuntimeException {
public UnsupportedDatabaseException(String name) {
super("Database with '" + name + "' not found");
}
private static final long serialVersionUID = 1L;
}

View File

@ -12,8 +12,11 @@ import pro.taskana.TaskanaEngine;
import pro.taskana.Workbasket; import pro.taskana.Workbasket;
import pro.taskana.impl.util.LoggerUtils; import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.model.DueWorkbasketCounter; import pro.taskana.model.DueWorkbasketCounter;
import pro.taskana.model.MonitorQueryItem;
import pro.taskana.model.Report; import pro.taskana.model.Report;
import pro.taskana.model.ReportLine; import pro.taskana.model.ReportLine;
import pro.taskana.model.ReportLineItem;
import pro.taskana.model.ReportLineItemDefinition;
import pro.taskana.model.TaskState; import pro.taskana.model.TaskState;
import pro.taskana.model.TaskStateCounter; import pro.taskana.model.TaskStateCounter;
import pro.taskana.model.mappings.TaskMonitorMapper; import pro.taskana.model.mappings.TaskMonitorMapper;
@ -99,21 +102,29 @@ public class TaskMonitorServiceImpl implements TaskMonitorService {
@Override @Override
public Report getWorkbasketLevelReport(List<Workbasket> workbaskets, List<TaskState> states) { public Report getWorkbasketLevelReport(List<Workbasket> workbaskets, List<TaskState> states) {
return getWorkbasketLevelReport(workbaskets, states, null);
}
@Override
public Report getWorkbasketLevelReport(List<Workbasket> workbaskets, List<TaskState> states,
List<ReportLineItemDefinition> reportLineItemDefinitions) {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("entry to getWorkbasketLevelReport(workbaskets = {})", LoggerUtils.listToString(workbaskets)); LOGGER.debug(
"entry to getWorkbasketLevelReport(workbaskets = {}, states = {}, reportLineItemDefinitions = {})",
LoggerUtils.listToString(workbaskets), LoggerUtils.listToString(states),
LoggerUtils.listToString(reportLineItemDefinitions));
} }
try { try {
taskanaEngineImpl.openConnection(); taskanaEngineImpl.openConnection();
Report report = new Report();
report.setDetailLines(taskMonitorMapper.getDetailLinesByWorkbasketIdsAndStates(workbaskets, states)); Report report = createEmptyReport(workbaskets, reportLineItemDefinitions);
int sumLineTotalCount = 0; List<MonitorQueryItem> monitorQueryItems = taskMonitorMapper
for (ReportLine reportLine : report.getDetailLines()) { .findByWorkbasketIdsAndStates(workbaskets, states);
sumLineTotalCount += reportLine.getTotalCount();
for (MonitorQueryItem item : monitorQueryItems) {
report.getDetailLines().get(item.getKey()).addNumberOfTasks(item);
} }
ReportLine sumLine = new ReportLine(); report.generateSumLine();
sumLine.setName("SumLine");
sumLine.setTotalCount(sumLineTotalCount);
report.setSumLine(sumLine);
return report; return report;
} finally { } finally {
@ -123,4 +134,29 @@ public class TaskMonitorServiceImpl implements TaskMonitorService {
} }
} }
} }
private Report createEmptyReport(List<Workbasket> workbaskets,
List<ReportLineItemDefinition> reportLineItemDefinitions) {
Report report = new Report();
for (Workbasket workbasket : workbaskets) {
ReportLine reportLine = new ReportLine();
if (reportLineItemDefinitions != null) {
for (ReportLineItemDefinition reportLineItemDefinition : reportLineItemDefinitions) {
ReportLineItem reportLineItem = new ReportLineItem();
reportLineItem.setReportLineItemDefinition(reportLineItemDefinition);
reportLine.getLineItems().add(reportLineItem);
}
}
report.getDetailLines().put(workbasket.getKey(), reportLine);
}
if (reportLineItemDefinitions != null) {
for (ReportLineItemDefinition reportLineItemDefinition : reportLineItemDefinitions) {
ReportLineItem reportLineItem = new ReportLineItem();
reportLineItem.setReportLineItemDefinition(reportLineItemDefinition);
report.getSumLine().getLineItems().add(reportLineItem);
}
}
return report;
}
} }

View File

@ -1,288 +1,317 @@
package pro.taskana.impl; package pro.taskana.impl;
import java.util.Stack; import java.sql.SQLException;
import java.util.Stack;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration; import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionManager; import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.ibatis.transaction.TransactionFactory; import org.apache.ibatis.session.SqlSessionManager;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory; import org.apache.ibatis.transaction.TransactionFactory;
import org.apache.ibatis.transaction.managed.ManagedTransactionFactory; import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import org.slf4j.Logger; import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
import org.slf4j.LoggerFactory; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.ClassificationService;
import pro.taskana.TaskMonitorService; import pro.taskana.ClassificationService;
import pro.taskana.TaskService; import pro.taskana.TaskMonitorService;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskService;
import pro.taskana.WorkbasketService; import pro.taskana.TaskanaEngine;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.WorkbasketService;
import pro.taskana.exceptions.AutocommitFailedException; import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.ConnectionNotSetException; import pro.taskana.exceptions.AutocommitFailedException;
import pro.taskana.impl.persistence.MapTypeHandler; import pro.taskana.exceptions.ConnectionNotSetException;
import pro.taskana.model.mappings.AttachmentMapper; import pro.taskana.exceptions.UnsupportedDatabaseException;
import pro.taskana.model.mappings.ClassificationMapper; import pro.taskana.impl.persistence.MapTypeHandler;
import pro.taskana.model.mappings.DistributionTargetMapper; import pro.taskana.model.mappings.AttachmentMapper;
import pro.taskana.model.mappings.ObjectReferenceMapper; import pro.taskana.model.mappings.ClassificationMapper;
import pro.taskana.model.mappings.QueryMapper; import pro.taskana.model.mappings.DistributionTargetMapper;
import pro.taskana.model.mappings.TaskMapper; import pro.taskana.model.mappings.ObjectReferenceMapper;
import pro.taskana.model.mappings.TaskMonitorMapper; import pro.taskana.model.mappings.QueryMapper;
import pro.taskana.model.mappings.WorkbasketAccessMapper; import pro.taskana.model.mappings.TaskMapper;
import pro.taskana.model.mappings.WorkbasketMapper; import pro.taskana.model.mappings.TaskMonitorMapper;
import pro.taskana.model.mappings.WorkbasketAccessMapper;
/** import pro.taskana.model.mappings.WorkbasketMapper;
* This is the implementation of TaskanaEngine.
*/ /**
public class TaskanaEngineImpl implements TaskanaEngine { * This is the implementation of TaskanaEngine.
*/
private static final String DEFAULT = "default"; public class TaskanaEngineImpl implements TaskanaEngine {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineImpl.class);
protected static ThreadLocal<Stack<SqlSessionManager>> sessionStack = new ThreadLocal<Stack<SqlSessionManager>>(); private static final String DEFAULT = "default";
protected TaskanaEngineConfiguration taskanaEngineConfiguration; private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineImpl.class);
protected TransactionFactory transactionFactory; protected static ThreadLocal<Stack<SqlSessionManager>> sessionStack = new ThreadLocal<Stack<SqlSessionManager>>();
protected SqlSessionManager sessionManager; protected TaskanaEngineConfiguration taskanaEngineConfiguration;
protected SqlSessionFactory sessionFactory; protected TransactionFactory transactionFactory;
protected ConnectionManagementMode mode = ConnectionManagementMode.PARTICIPATE; protected SqlSessionManager sessionManager;
protected java.sql.Connection connection = null; protected SqlSessionFactory sessionFactory;
protected ConnectionManagementMode mode = ConnectionManagementMode.PARTICIPATE;
public TaskanaEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration) { protected java.sql.Connection connection = null;
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
createTransactionFactory(taskanaEngineConfiguration.getUseManagedTransactions()); public TaskanaEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration) {
this.sessionManager = createSqlSessionManager(); this.taskanaEngineConfiguration = taskanaEngineConfiguration;
} createTransactionFactory(taskanaEngineConfiguration.getUseManagedTransactions());
this.sessionManager = createSqlSessionManager();
@Override }
public TaskService getTaskService() {
SqlSession session = this.sessionManager; @Override
TaskServiceImpl taskServiceImpl = new TaskServiceImpl(this, session.getMapper(TaskMapper.class), public TaskService getTaskService() {
session.getMapper(ObjectReferenceMapper.class), session.getMapper(AttachmentMapper.class)); SqlSession session = this.sessionManager;
return taskServiceImpl; TaskServiceImpl taskServiceImpl = new TaskServiceImpl(this, session.getMapper(TaskMapper.class),
} session.getMapper(ObjectReferenceMapper.class), session.getMapper(AttachmentMapper.class));
return taskServiceImpl;
@Override }
public TaskMonitorService getTaskMonitorService() {
SqlSession session = this.sessionManager; @Override
TaskMonitorServiceImpl taskMonitorServiceImpl = new TaskMonitorServiceImpl(this, public TaskMonitorService getTaskMonitorService() {
session.getMapper(TaskMonitorMapper.class)); SqlSession session = this.sessionManager;
return taskMonitorServiceImpl; TaskMonitorServiceImpl taskMonitorServiceImpl = new TaskMonitorServiceImpl(this,
} session.getMapper(TaskMonitorMapper.class));
return taskMonitorServiceImpl;
@Override }
public WorkbasketService getWorkbasketService() {
SqlSession session = this.sessionManager; @Override
WorkbasketServiceImpl workbasketServiceImpl = new WorkbasketServiceImpl(this, public WorkbasketService getWorkbasketService() {
session.getMapper(WorkbasketMapper.class), SqlSession session = this.sessionManager;
session.getMapper(DistributionTargetMapper.class), WorkbasketServiceImpl workbasketServiceImpl = new WorkbasketServiceImpl(this,
session.getMapper(WorkbasketAccessMapper.class)); session.getMapper(WorkbasketMapper.class),
return workbasketServiceImpl; session.getMapper(DistributionTargetMapper.class),
} session.getMapper(WorkbasketAccessMapper.class));
return workbasketServiceImpl;
@Override }
public ClassificationService getClassificationService() {
SqlSession session = this.sessionManager; @Override
return new ClassificationServiceImpl(this, session.getMapper(ClassificationMapper.class)); public ClassificationService getClassificationService() {
} SqlSession session = this.sessionManager;
return new ClassificationServiceImpl(this, session.getMapper(ClassificationMapper.class));
@Override }
public TaskanaEngineConfiguration getConfiguration() {
return this.taskanaEngineConfiguration; @Override
} public TaskanaEngineConfiguration getConfiguration() {
return this.taskanaEngineConfiguration;
/** }
* sets the connection management mode.
* /**
* @param mode * sets the connection management mode.
* - the connection management mode Valid values are: *
* <ul> * @param mode
* <li>PARTICIPATE - taskana participates in global transaction. This is the default mode.</li> * - the connection management mode Valid values are:
* <li>AUTOCOMMIT - taskana commits each API call separately</li> * <ul>
* <li>EXPLICIT - commit processing is managed explicitly by the client</li> * <li>PARTICIPATE - taskana participates in global transaction. This is the default mode.</li>
* </ul> * <li>AUTOCOMMIT - taskana commits each API call separately</li>
*/ * <li>EXPLICIT - commit processing is managed explicitly by the client</li>
@Override * </ul>
public void setConnectionManagementMode(ConnectionManagementMode mode) { */
if (this.mode == ConnectionManagementMode.EXPLICIT && connection != null @Override
&& mode != ConnectionManagementMode.EXPLICIT) { public void setConnectionManagementMode(ConnectionManagementMode mode) {
if (sessionManager.isManagedSessionStarted()) { if (this.mode == ConnectionManagementMode.EXPLICIT && connection != null
sessionManager.close(); && mode != ConnectionManagementMode.EXPLICIT) {
} if (sessionManager.isManagedSessionStarted()) {
connection = null; sessionManager.close();
} }
this.mode = mode; connection = null;
} }
this.mode = mode;
/** }
* Set the database connection to be used by taskana. If this Api is called, taskana uses the connection passed by
* the client for database access in all subsequent API calls until the client resets this connection. Control over /**
* commit and rollback is the responsibility of the client. In order to close the connection, the client can call * Set the database connection to be used by taskana. If this Api is called, taskana uses the connection passed by
* TaskanaEngine.closeConnection() or TaskanaEngine.setConnection(null). Both calls have the same effect. * the client for database access in all subsequent API calls until the client resets this connection. Control over
* * commit and rollback is the responsibility of the client. In order to close the connection, the client can call
* @param connection * TaskanaEngine.closeConnection() or TaskanaEngine.setConnection(null). Both calls have the same effect.
* TODO *
*/ * @param connection
@Override * TODO
public void setConnection(java.sql.Connection connection) { */
if (connection != null) { @Override
this.connection = connection; public void setConnection(java.sql.Connection connection) {
mode = ConnectionManagementMode.EXPLICIT; if (connection != null) {
sessionManager.startManagedSession(connection); this.connection = connection;
} else if (this.connection != null) { mode = ConnectionManagementMode.EXPLICIT;
this.connection = null; sessionManager.startManagedSession(connection);
if (sessionManager.isManagedSessionStarted()) { } else if (this.connection != null) {
sessionManager.close(); this.connection = null;
} if (sessionManager.isManagedSessionStarted()) {
mode = ConnectionManagementMode.PARTICIPATE; sessionManager.close();
} }
} mode = ConnectionManagementMode.PARTICIPATE;
}
/** }
* closes the connection to the database in mode EXPLICIT. In mode EXPLICIT, closes the client's connection, sets it
* to null and switches to mode PARTICIPATE Has the same effect as setConnection(null) /**
*/ * closes the connection to the database in mode EXPLICIT. In mode EXPLICIT, closes the client's connection, sets it
@Override * to null and switches to mode PARTICIPATE Has the same effect as setConnection(null)
public void closeConnection() { */
if (this.mode == ConnectionManagementMode.EXPLICIT) { @Override
this.connection = null; public void closeConnection() {
if (sessionManager.isManagedSessionStarted()) { if (this.mode == ConnectionManagementMode.EXPLICIT) {
sessionManager.close(); this.connection = null;
} if (sessionManager.isManagedSessionStarted()) {
mode = ConnectionManagementMode.PARTICIPATE; sessionManager.close();
} }
} mode = ConnectionManagementMode.PARTICIPATE;
}
/** }
* Open the connection to the database. to be called at the begin of each Api call that accesses the database
*/ /**
void openConnection() { * Open the connection to the database. to be called at the begin of each Api call that accesses the database
initSqlSession(); */
if (mode != ConnectionManagementMode.EXPLICIT) { void openConnection() {
pushSessionToStack(this.sessionManager); initSqlSession();
} if (mode != ConnectionManagementMode.EXPLICIT) {
} pushSessionToStack(this.sessionManager);
}
/** }
* Initializes the SqlSessionManager.
*/ /**
void initSqlSession() { * Initializes the SqlSessionManager.
if (mode == ConnectionManagementMode.EXPLICIT && this.connection == null) { */
throw new ConnectionNotSetException(); void initSqlSession() {
} else if (mode != ConnectionManagementMode.EXPLICIT) { if (mode == ConnectionManagementMode.EXPLICIT && this.connection == null) {
if (!this.sessionManager.isManagedSessionStarted()) { throw new ConnectionNotSetException();
this.sessionManager.startManagedSession(); } else if (mode != ConnectionManagementMode.EXPLICIT) {
} if (!this.sessionManager.isManagedSessionStarted()) {
} this.sessionManager.startManagedSession();
} }
}
/** }
* Returns the database connection into the pool. In the case of nested calls, simply pops the latest session from
* the session stack. Closes the connection if the session stack is empty. In mode AUTOCOMMIT commits before the /**
* connection is closed. To be called at the end of each Api call that accesses the database * Returns the database connection into the pool. In the case of nested calls, simply pops the latest session from
*/ * the session stack. Closes the connection if the session stack is empty. In mode AUTOCOMMIT commits before the
void returnConnection() { * connection is closed. To be called at the end of each Api call that accesses the database
if (this.mode != ConnectionManagementMode.EXPLICIT) { */
popSessionFromStack(); void returnConnection() {
if (getSessionStack().isEmpty() if (this.mode != ConnectionManagementMode.EXPLICIT) {
&& this.sessionManager != null && this.sessionManager.isManagedSessionStarted()) { popSessionFromStack();
if (this.mode == ConnectionManagementMode.AUTOCOMMIT) { if (getSessionStack().isEmpty()
try { && this.sessionManager != null && this.sessionManager.isManagedSessionStarted()) {
this.sessionManager.commit(); if (this.mode == ConnectionManagementMode.AUTOCOMMIT) {
} catch (Exception e) { try {
LOGGER.error("closeSession(): Tried to Autocommit and caught exception" + e); this.sessionManager.commit();
throw new AutocommitFailedException(e); } catch (Exception e) {
} LOGGER.error("closeSession(): Tried to Autocommit and caught exception" + e);
} throw new AutocommitFailedException(e);
this.sessionManager.close(); }
} }
} this.sessionManager.close();
} }
}
/** }
* retrieve the SqlSession used by taskana.
* /**
* @return the myBatis SqlSession object used by taskana * retrieve the SqlSession used by taskana.
*/ *
SqlSession getSqlSession() { * @return the myBatis SqlSession object used by taskana
return this.sessionManager; */
} SqlSession getSqlSession() {
return this.sessionManager;
/** }
* This method creates the sqlSessionManager of myBatis. It integrates all the SQL mappers
* /**
* @return a {@link SqlSessionFactory} * This method creates the sqlSessionManager of myBatis. It integrates all the SQL mappers and sets the databaseId
*/ * attribute.
private SqlSessionManager createSqlSessionManager() { *
Environment environment = new Environment(DEFAULT, this.transactionFactory, * @return a {@link SqlSessionFactory}
taskanaEngineConfiguration.getDatasource()); */
Configuration configuration = new Configuration(environment); private SqlSessionManager createSqlSessionManager() {
// add mappers Environment environment = new Environment(DEFAULT, this.transactionFactory,
configuration.addMapper(TaskMapper.class); taskanaEngineConfiguration.getDatasource());
configuration.addMapper(TaskMonitorMapper.class); Configuration configuration = new Configuration(environment);
configuration.addMapper(WorkbasketMapper.class);
configuration.addMapper(DistributionTargetMapper.class); // set databaseId
configuration.addMapper(ClassificationMapper.class); String databaseProductName;
configuration.addMapper(WorkbasketAccessMapper.class); try {
configuration.addMapper(ObjectReferenceMapper.class); databaseProductName = taskanaEngineConfiguration.getDatasource()
configuration.addMapper(QueryMapper.class); .getConnection()
configuration.addMapper(AttachmentMapper.class); .getMetaData()
configuration.getTypeHandlerRegistry().register(MapTypeHandler.class); .getDatabaseProductName();
SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(configuration); if (databaseProductName.contains("DB2")) {
SqlSessionManager sessionManager = SqlSessionManager.newInstance(sessionFactory); configuration.setDatabaseId("db2");
return sessionManager; } else if (databaseProductName.contains("H2")) {
} configuration.setDatabaseId("h2");
} else {
/** LOGGER.error(
* creates the MyBatis transaction factory. "Method createSqlSessionManager() didn't find database with name {}. Throwing UnsupportedDatabaseException",
* databaseProductName);
* @param useManagedTransactions throw new UnsupportedDatabaseException(databaseProductName);
*/ }
private void createTransactionFactory(boolean useManagedTransactions) {
if (useManagedTransactions) { } catch (SQLException e) {
this.transactionFactory = new ManagedTransactionFactory(); LOGGER.error(
} else { "Method createSqlSessionManager() could not open a connection to the database. No databaseId has been set.",
this.transactionFactory = new JdbcTransactionFactory(); e);
} throw new RuntimeException(e);
} }
/** // add mappers
* With sessionStack, we maintain a Stack of SqlSessionManager objects on a per thread basis. SqlSessionManager is configuration.addMapper(TaskMapper.class);
* the MyBatis object that wraps database connections. The purpose of this stack is to keep track of nested calls. configuration.addMapper(TaskMonitorMapper.class);
* Each external API call is wrapped into taskanaEngineImpl.openConnection(); ..... configuration.addMapper(WorkbasketMapper.class);
* taskanaEngineImpl.returnConnection(); calls. In order to avoid duplicate opening / closing of connections, we use configuration.addMapper(DistributionTargetMapper.class);
* the sessionStack in the following way: Each time, an openConnection call is received, we push the current configuration.addMapper(ClassificationMapper.class);
* sessionManager onto the stack. On the first call to openConnection, we call sessionManager.startManagedSession() configuration.addMapper(WorkbasketAccessMapper.class);
* to open a database connection. On each call to returnConnection() we pop one instance of sessionManager from the configuration.addMapper(ObjectReferenceMapper.class);
* stack. When the stack becomes empty, we close the database connection by calling sessionManager.close() configuration.addMapper(QueryMapper.class);
* configuration.addMapper(AttachmentMapper.class);
* @return Stack of SqlSessionManager configuration.getTypeHandlerRegistry().register(MapTypeHandler.class);
*/ SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(configuration);
protected static Stack<SqlSessionManager> getSessionStack() { SqlSessionManager sessionManager = SqlSessionManager.newInstance(sessionFactory);
Stack<SqlSessionManager> stack = sessionStack.get(); return sessionManager;
if (stack == null) { }
stack = new Stack<SqlSessionManager>();
sessionStack.set(stack); /**
} * creates the MyBatis transaction factory.
return stack; *
} * @param useManagedTransactions
*/
protected static SqlSessionManager getSessionFromStack() { private void createTransactionFactory(boolean useManagedTransactions) {
Stack<SqlSessionManager> stack = getSessionStack(); if (useManagedTransactions) {
if (stack.isEmpty()) { this.transactionFactory = new ManagedTransactionFactory();
return null; } else {
} this.transactionFactory = new JdbcTransactionFactory();
return stack.peek(); }
} }
protected static void pushSessionToStack(SqlSessionManager session) { /**
getSessionStack().push(session); * With sessionStack, we maintain a Stack of SqlSessionManager objects on a per thread basis. SqlSessionManager is
} * the MyBatis object that wraps database connections. The purpose of this stack is to keep track of nested calls.
* Each external API call is wrapped into taskanaEngineImpl.openConnection(); .....
protected static void popSessionFromStack() { * taskanaEngineImpl.returnConnection(); calls. In order to avoid duplicate opening / closing of connections, we use
Stack<SqlSessionManager> stack = getSessionStack(); * the sessionStack in the following way: Each time, an openConnection call is received, we push the current
if (!stack.isEmpty()) { * sessionManager onto the stack. On the first call to openConnection, we call sessionManager.startManagedSession()
stack.pop(); * to open a database connection. On each call to returnConnection() we pop one instance of sessionManager from the
} * stack. When the stack becomes empty, we close the database connection by calling sessionManager.close()
} *
} * @return Stack of SqlSessionManager
*/
protected static Stack<SqlSessionManager> getSessionStack() {
Stack<SqlSessionManager> stack = sessionStack.get();
if (stack == null) {
stack = new Stack<SqlSessionManager>();
sessionStack.set(stack);
}
return stack;
}
protected static SqlSessionManager getSessionFromStack() {
Stack<SqlSessionManager> stack = getSessionStack();
if (stack.isEmpty()) {
return null;
}
return stack.peek();
}
protected static void pushSessionToStack(SqlSessionManager session) {
getSessionStack().push(session);
}
protected static void popSessionFromStack() {
Stack<SqlSessionManager> stack = getSessionStack();
if (!stack.isEmpty()) {
stack.pop();
}
}
}

View File

@ -0,0 +1,36 @@
package pro.taskana.model;
/**
* The MonitorQueryItem entity contains the number of tasks for a key (e.g. workbasketKey) and age in days.
*/
public class MonitorQueryItem {
private String key;
private int ageInDays;
private int numberOfTasks;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public int getAgeInDays() {
return ageInDays;
}
public void setAgeInDays(int ageInDays) {
this.ageInDays = ageInDays;
}
public int getNumberOfTasks() {
return numberOfTasks;
}
public void setNumberOfTasks(int numberOfTasks) {
this.numberOfTasks = numberOfTasks;
}
}

View File

@ -1,26 +1,30 @@
package pro.taskana.model; package pro.taskana.model;
import java.util.ArrayList; import java.util.Iterator;
import java.util.List; import java.util.LinkedHashMap;
import java.util.Map;
/** /**
* A Report represents a table that consists of {@link ReportLine} objects. * A Report represents a table that consists of {@link ReportLine} objects. The detailLines are the rows of the table
* that contains the total number of all tasks and could be optionally subdivided into different sections. The sumLine
* contains the sums of all tasks and if the detailLines are subdivided into different sections the sumLine also
* contains the number of tasks of the respective section.
*/ */
public class Report { public class Report {
private List<ReportLine> detailLines; private Map<String, ReportLine> detailLines;
private ReportLine sumLine; private ReportLine sumLine;
public Report() { public Report() {
this.detailLines = new ArrayList<>(); this.detailLines = new LinkedHashMap<>();
this.sumLine = new ReportLine(); this.sumLine = new ReportLine();
} }
public List<ReportLine> getDetailLines() { public Map<String, ReportLine> getDetailLines() {
return detailLines; return detailLines;
} }
public void setDetailLines(List<ReportLine> detailLines) { public void setDetailLines(Map<String, ReportLine> detailLines) {
this.detailLines = detailLines; this.detailLines = detailLines;
} }
@ -31,4 +35,20 @@ public class Report {
public void setSumLine(ReportLine sumLine) { public void setSumLine(ReportLine sumLine) {
this.sumLine = sumLine; this.sumLine = sumLine;
} }
public void generateSumLine() {
int totalNumberOfTasks = 0;
for (ReportLine reportLine : this.getDetailLines().values()) {
Iterator<ReportLineItem> reportLineItemIterator = reportLine.getLineItems().iterator();
Iterator<ReportLineItem> sumLineItemIterator = this.sumLine.getLineItems().iterator();
while (reportLineItemIterator.hasNext() && sumLineItemIterator.hasNext()) {
int numberOfTasks = reportLineItemIterator.next().getNumberOfTasks();
sumLineItemIterator.next().addNumberOfTasks(numberOfTasks);
}
totalNumberOfTasks += reportLine.getTotalNumberOfTasks();
}
this.sumLine.setTotalNumberOfTasks(totalNumberOfTasks);
}
} }

View File

@ -1,43 +1,47 @@
package pro.taskana.model; package pro.taskana.model;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* Each ReportLine consists of a name, a list of {@link ReportLineItem} objects and a totalCount that represents the * Each ReportLine consists of a list of {@link ReportLineItem} objects and the number of all tasks of this ReportLine.
* count of all tasks. */
*/ public class ReportLine {
public class ReportLine {
private List<ReportLineItem> lineItems;
private String name; private int totalNumberOfTasks;
private List<ReportLineItem> lineItems;
private int totalCount; public ReportLine() {
this.lineItems = new ArrayList<>();
public ReportLine() { this.totalNumberOfTasks = 0;
this.lineItems = new ArrayList<>(); }
}
public List<ReportLineItem> getLineItems() {
public String getName() { return lineItems;
return name; }
}
public void setLineItems(List<ReportLineItem> lineItems) {
public void setName(String name) { this.lineItems = lineItems;
this.name = name; }
}
public int getTotalNumberOfTasks() {
public List<ReportLineItem> getLineItems() { return totalNumberOfTasks;
return lineItems; }
}
public void setTotalNumberOfTasks(int totalNumberOfTasks) {
public void setLineItems(List<ReportLineItem> lineItems) { this.totalNumberOfTasks = totalNumberOfTasks;
this.lineItems = lineItems; }
}
public void addNumberOfTasks(MonitorQueryItem item) {
public int getTotalCount() { this.totalNumberOfTasks += item.getNumberOfTasks();
return totalCount; for (ReportLineItem reportLineItem : lineItems) {
} int lowerAgeLimit = reportLineItem.getReportLineItemDefinition().getLowerAgeLimit();
int upperAgeLimit = reportLineItem.getReportLineItemDefinition().getUpperAgeLimit();
public void setTotalCount(int totalCount) { if (lowerAgeLimit <= item.getAgeInDays() && upperAgeLimit >= item.getAgeInDays()) {
this.totalCount = totalCount; reportLineItem.addNumberOfTasks(item.getNumberOfTasks());
} break;
} }
}
}
}

View File

@ -1,13 +1,17 @@
package pro.taskana.model; package pro.taskana.model;
/** /**
* Each ReportLineItem consists of a {@link ReportLineItemDefinition} that defines the upper and lower limits of this * Each ReportLineItem consists of a {@link ReportLineItemDefinition} that defines the upper and lower age limits of
* item and a count value that represents the count of tasks of this item. * this item and a number of tasks of this item.
*/ */
public class ReportLineItem { public class ReportLineItem {
private ReportLineItemDefinition reportLineItemDefinition; private ReportLineItemDefinition reportLineItemDefinition;
private int count; private int numberOfTasks;
public ReportLineItem() {
this.numberOfTasks = 0;
}
public ReportLineItemDefinition getReportLineItemDefinition() { public ReportLineItemDefinition getReportLineItemDefinition() {
return reportLineItemDefinition; return reportLineItemDefinition;
@ -17,11 +21,15 @@ public class ReportLineItem {
this.reportLineItemDefinition = reportLineItemDefinition; this.reportLineItemDefinition = reportLineItemDefinition;
} }
public int getCount() { public int getNumberOfTasks() {
return count; return numberOfTasks;
} }
public void setCount(int count) { public void setNumberOfTasks(int numberOfTasks) {
this.count = count; this.numberOfTasks = numberOfTasks;
} }
public void addNumberOfTasks(int numberOfTasks) {
this.numberOfTasks += numberOfTasks;
}
} }

View File

@ -1,27 +1,43 @@
package pro.taskana.model; package pro.taskana.model;
/** /**
* A ReportLineItemDefinition has a lower and an upper limit which subdivide the count of tasks in a workbasket into * A ReportLineItemDefinition has a lower and an upper age limit which subdivide the count of tasks into different
* different sections. * sections. Days in past are represented as negative values and days in the future are represented as positive values.
* To avoid tasks are counted multiple times or not be listed in the report, these reportLineItemDefinitions should not
* overlap and should not have gaps. If the ReportLineDefinition should represent a single day, lowerAgeLimit and
* upperAgeLimit have to be equal.
*/ */
public class ReportLineItemDefinition { public class ReportLineItemDefinition {
private int lowerLimit; private int lowerAgeLimit;
private int upperLimit; private int upperAgeLimit;
public int getLowerLimit() { public ReportLineItemDefinition() {
return lowerLimit;
} }
public void setLowerLimit(int lowerLimit) { public ReportLineItemDefinition(int ageInDays) {
this.lowerLimit = lowerLimit; this.lowerAgeLimit = ageInDays;
this.upperAgeLimit = ageInDays;
} }
public int getUpperLimit() { public ReportLineItemDefinition(int lowerAgeLimit, int upperAgeLimit) {
return upperLimit; this.lowerAgeLimit = lowerAgeLimit;
this.upperAgeLimit = upperAgeLimit;
} }
public void setUpperLimit(int upperLimit) { public int getLowerAgeLimit() {
this.upperLimit = upperLimit; return lowerAgeLimit;
}
public void setLowerAgeLimit(int lowerAgeLimit) {
this.lowerAgeLimit = lowerAgeLimit;
}
public int getUpperAgeLimit() {
return upperAgeLimit;
}
public void setUpperAgeLimit(int upperAgeLimit) {
this.upperAgeLimit = upperAgeLimit;
} }
} }

View File

@ -10,7 +10,7 @@ import org.apache.ibatis.annotations.Select;
import pro.taskana.Workbasket; import pro.taskana.Workbasket;
import pro.taskana.model.DueWorkbasketCounter; import pro.taskana.model.DueWorkbasketCounter;
import pro.taskana.model.ReportLine; import pro.taskana.model.MonitorQueryItem;
import pro.taskana.model.TaskState; import pro.taskana.model.TaskState;
import pro.taskana.model.TaskStateCounter; import pro.taskana.model.TaskStateCounter;
@ -52,14 +52,21 @@ public interface TaskMonitorMapper {
@Param("status") List<TaskState> states); @Param("status") List<TaskState> states);
@Select("<script>" @Select("<script>"
+ "SELECT WORKBASKET_KEY, COUNT(WORKBASKET_KEY) as counter " + "<if test=\"_databaseId == 'db2'\">SELECT WORKBASKET_KEY, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP)) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS</if> "
+ "<if test=\"_databaseId == 'h2'\">SELECT WORKBASKET_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE) as AGE_IN_DAYS, COUNT(*) as NUMBER_OF_TASKS</if> "
+ "FROM TASK " + "FROM TASK "
+ "WHERE WORKBASKET_KEY IN (<foreach collection='workbaskets' item='workbasket' separator=','>#{workbasket.key}</foreach>) " + "WHERE WORKBASKET_KEY IN (<foreach collection='workbaskets' item='workbasket' separator=','>#{workbasket.key}</foreach>) "
+ "AND STATE IN (<foreach collection='status' item='state' separator=','>#{state}</foreach>) " + "AND STATE IN (<foreach collection='states' item='state' separator=','>#{state}</foreach>) "
+ "GROUP BY WORKBASKET_KEY" + "AND DUE IS NOT NULL "
+ "<if test=\"_databaseId == 'db2'\">GROUP BY WORKBASKET_KEY, (DAYS(DUE) - DAYS(CURRENT_TIMESTAMP))</if> "
+ "<if test=\"_databaseId == 'h2'\">GROUP BY WORKBASKET_KEY, DATEDIFF('DAY', CURRENT_TIMESTAMP, DUE)</if> "
+ "</script>") + "</script>")
@Results({ @Result(column = "WORKBASKET_KEY", property = "name"), @Results({
@Result(column = "counter", property = "totalCount") }) @Result(column = "WORKBASKET_KEY", property = "key"),
List<ReportLine> getDetailLinesByWorkbasketIdsAndStates(@Param("workbaskets") List<Workbasket> workbaskets, @Result(column = "AGE_IN_DAYS", property = "ageInDays"),
@Param("status") List<TaskState> states); @Result(column = "NUMBER_OF_TASKS", property = "numberOfTasks") })
List<MonitorQueryItem> findByWorkbasketIdsAndStates(
@Param("workbaskets") List<Workbasket> workbaskets,
@Param("states") List<TaskState> states);
} }

View File

@ -1,93 +1,93 @@
package acceptance; package acceptance;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneOffset; import java.time.ZoneOffset;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import pro.taskana.Attachment; import pro.taskana.Attachment;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode; import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.database.TestDataGenerator; import pro.taskana.database.TestDataGenerator;
import pro.taskana.exceptions.ClassificationNotFoundException; import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.NotAuthorizedException; import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.impl.TaskanaEngineImpl; import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.configuration.DBCleaner; import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest; import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
import pro.taskana.model.ObjectReference; import pro.taskana.model.ObjectReference;
/** /**
* Base class for all acceptance tests. * Base class for all acceptance tests.
*/ */
public abstract class AbstractAccTest { public abstract class AbstractAccTest {
protected static TaskanaEngineConfiguration taskanaEngineConfiguration; protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
protected static TaskanaEngine taskanaEngine; protected static TaskanaEngine taskanaEngine;
@BeforeClass @BeforeClass
public static void setupTest() throws Exception { public static void setupTest() throws Exception {
resetDb(); resetDb();
} }
public static void resetDb() throws SQLException { public static void resetDb() throws SQLException {
DataSource dataSource = TaskanaEngineConfigurationTest.getDataSource(); DataSource dataSource = TaskanaEngineConfigurationTest.getDataSource();
DBCleaner cleaner = new DBCleaner(); DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(dataSource, true); cleaner.clearDb(dataSource, true);
dataSource = TaskanaEngineConfigurationTest.getDataSource(); dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false); taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine(); taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
((TaskanaEngineImpl) taskanaEngine).setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT); ((TaskanaEngineImpl) taskanaEngine).setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
cleaner.clearDb(dataSource, false); cleaner.clearDb(dataSource, false);
TestDataGenerator testDataGenerator = new TestDataGenerator(); TestDataGenerator testDataGenerator = new TestDataGenerator();
testDataGenerator.generateTestData(dataSource); testDataGenerator.generateTestData(dataSource);
} }
protected ObjectReference createObjectReference(String company, String system, String systemInstance, String type, protected ObjectReference createObjectReference(String company, String system, String systemInstance, String type,
String value) { String value) {
ObjectReference objectReference = new ObjectReference(); ObjectReference objectReference = new ObjectReference();
objectReference.setCompany(company); objectReference.setCompany(company);
objectReference.setSystem(system); objectReference.setSystem(system);
objectReference.setSystemInstance(systemInstance); objectReference.setSystemInstance(systemInstance);
objectReference.setType(type); objectReference.setType(type);
objectReference.setValue(value); objectReference.setValue(value);
return objectReference; return objectReference;
} }
protected Map<String, Object> createSimpleCustomProperties(int propertiesCount) { protected Map<String, Object> createSimpleCustomProperties(int propertiesCount) {
HashMap<String, Object> properties = new HashMap<>(); HashMap<String, Object> properties = new HashMap<>();
for (int i = 1; i <= propertiesCount; i++) { for (int i = 1; i <= propertiesCount; i++) {
properties.put("Property_" + i, "Property Value of Property_" + i); properties.put("Property_" + i, "Property Value of Property_" + i);
} }
return properties; return properties;
} }
protected Attachment createAttachment(String classificationKey, ObjectReference objRef, protected Attachment createAttachment(String classificationKey, ObjectReference objRef,
String channel, String receivedDate, Map<String, Object> customAttributes) String channel, String receivedDate, Map<String, Object> customAttributes)
throws ClassificationNotFoundException, NotAuthorizedException { throws ClassificationNotFoundException, NotAuthorizedException {
Attachment attachment = taskanaEngine.getTaskService().newAttachment(); Attachment attachment = taskanaEngine.getTaskService().newAttachment();
attachment.setClassificationSummary( attachment.setClassificationSummary(
taskanaEngine.getClassificationService().getClassification(classificationKey, "DOMAIN_A").asSummary()); taskanaEngine.getClassificationService().getClassification(classificationKey, "DOMAIN_A").asSummary());
attachment.setObjectReference(objRef); attachment.setObjectReference(objRef);
attachment.setChannel(channel); attachment.setChannel(channel);
Instant receivedTimestamp = null; Instant receivedTimestamp = null;
if (receivedDate != null && receivedDate.length() < 11) { if (receivedDate != null && receivedDate.length() < 11) {
// contains only the date, not the time // contains only the date, not the time
LocalDate date = LocalDate.parse(receivedDate); LocalDate date = LocalDate.parse(receivedDate);
receivedTimestamp = date.atStartOfDay().toInstant(ZoneOffset.UTC); receivedTimestamp = date.atStartOfDay().toInstant(ZoneOffset.UTC);
} else { } else {
receivedTimestamp = Instant.parse(receivedDate); receivedTimestamp = Instant.parse(receivedDate);
} }
attachment.setReceived(receivedTimestamp); attachment.setReceived(receivedTimestamp);
attachment.setCustomAttributes(customAttributes); attachment.setCustomAttributes(customAttributes);
return attachment; return attachment;
} }
} }

View File

@ -0,0 +1,175 @@
package acceptance.task;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.sql.DataSource;
import org.h2.store.fs.FileUtils;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import pro.taskana.TaskMonitorService;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.database.TestDataGenerator;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
import pro.taskana.model.Report;
import pro.taskana.model.ReportLineItemDefinition;
import pro.taskana.model.TaskState;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
/**
* Acceptance test for all "workbasket level report" scenarios.
*/
@RunWith(JAASRunner.class)
public class ProvideWorkbasketLevelReportAccTest {
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
protected static TaskanaEngine taskanaEngine;
@BeforeClass
public static void setupTest() throws Exception {
resetDb();
}
public static void resetDb() throws SQLException, IOException {
DataSource dataSource = TaskanaEngineConfigurationTest.getDataSource();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(dataSource, true);
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
((TaskanaEngineImpl) taskanaEngine).setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
cleaner.clearDb(dataSource, false);
TestDataGenerator testDataGenerator = new TestDataGenerator();
testDataGenerator.generateMonitoringTestData(dataSource);
}
@WithAccessId(userName = "monitor_user_1")
@Test
public void testGetTotalNumbersOfTasksOfWorkbasketLevelReport()
throws WorkbasketNotFoundException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<Workbasket> workbaskets = getListOfWorkbaskets();
List<TaskState> states = Arrays.asList(TaskState.READY, TaskState.CLAIMED);
Report report = taskMonitorService.getWorkbasketLevelReport(workbaskets, states);
Assert.assertNotNull(report);
Assert.assertEquals(20, report.getDetailLines().get(workbaskets.get(0).getKey()).getTotalNumberOfTasks());
Assert.assertEquals(20, report.getDetailLines().get(workbaskets.get(1).getKey()).getTotalNumberOfTasks());
Assert.assertEquals(10, report.getDetailLines().get(workbaskets.get(2).getKey()).getTotalNumberOfTasks());
Assert.assertEquals(0, report.getDetailLines().get(workbaskets.get(3).getKey()).getTotalNumberOfTasks());
Assert.assertEquals(50, report.getSumLine().getTotalNumberOfTasks());
}
@WithAccessId(userName = "monitor_user_1")
@Test
public void testGetWorkbasketLevelReportWithReportLineItemDefinitions()
throws WorkbasketNotFoundException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
List<Workbasket> workbaskets = getListOfWorkbaskets();
List<TaskState> states = Arrays.asList(TaskState.READY, TaskState.CLAIMED);
List<ReportLineItemDefinition> reportLineItemDefinitions = getListOfReportLineItemDefinitions();
Report report = taskMonitorService.getWorkbasketLevelReport(workbaskets, states, reportLineItemDefinitions);
int sumLineCount = report.getSumLine().getLineItems().get(0).getNumberOfTasks()
+ report.getSumLine().getLineItems().get(1).getNumberOfTasks()
+ report.getSumLine().getLineItems().get(2).getNumberOfTasks()
+ report.getSumLine().getLineItems().get(3).getNumberOfTasks()
+ report.getSumLine().getLineItems().get(4).getNumberOfTasks()
+ report.getSumLine().getLineItems().get(5).getNumberOfTasks()
+ report.getSumLine().getLineItems().get(6).getNumberOfTasks();
Assert.assertNotNull(report);
Assert.assertEquals(20, report.getDetailLines().get(workbaskets.get(0).getKey()).getTotalNumberOfTasks());
Assert.assertEquals(20, report.getDetailLines().get(workbaskets.get(1).getKey()).getTotalNumberOfTasks());
Assert.assertEquals(10, report.getDetailLines().get(workbaskets.get(2).getKey()).getTotalNumberOfTasks());
Assert.assertEquals(0, report.getDetailLines().get(workbaskets.get(3).getKey()).getTotalNumberOfTasks());
Assert.assertEquals(22, report.getSumLine().getLineItems().get(0).getNumberOfTasks());
Assert.assertEquals(5, report.getSumLine().getLineItems().get(1).getNumberOfTasks());
Assert.assertEquals(3, report.getSumLine().getLineItems().get(2).getNumberOfTasks());
Assert.assertEquals(4, report.getSumLine().getLineItems().get(3).getNumberOfTasks());
Assert.assertEquals(1, report.getSumLine().getLineItems().get(4).getNumberOfTasks());
Assert.assertEquals(4, report.getSumLine().getLineItems().get(5).getNumberOfTasks());
Assert.assertEquals(11, report.getSumLine().getLineItems().get(6).getNumberOfTasks());
Assert.assertEquals(50, report.getSumLine().getTotalNumberOfTasks());
Assert.assertEquals(50, sumLineCount);
}
@WithAccessId(userName = "monitor_user_1")
@Test
public void testGetWorkbasketLevelReportIfWorkbasketContainsNoTask()
throws WorkbasketNotFoundException, NotAuthorizedException {
TaskMonitorService taskMonitorService = taskanaEngine.getTaskMonitorService();
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
List<Workbasket> workbaskets = new ArrayList<>();
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService
.getWorkbasket("WBI:000000000000000000000000000000000004");
workbaskets.add(workbasket);
List<TaskState> states = Arrays.asList(TaskState.READY, TaskState.CLAIMED);
Report report = taskMonitorService.getWorkbasketLevelReport(workbaskets, states);
Assert.assertNotNull(report);
Assert.assertEquals(0, report.getDetailLines().get(workbaskets.get(0).getKey()).getTotalNumberOfTasks());
Assert.assertEquals(0, report.getSumLine().getTotalNumberOfTasks());
}
private List<Workbasket> getListOfWorkbaskets() throws WorkbasketNotFoundException, NotAuthorizedException {
WorkbasketService workbasketService = taskanaEngine.getWorkbasketService();
WorkbasketImpl workbasket1 = (WorkbasketImpl) workbasketService
.getWorkbasket("WBI:000000000000000000000000000000000001");
WorkbasketImpl workbasket2 = (WorkbasketImpl) workbasketService
.getWorkbasket("WBI:000000000000000000000000000000000002");
WorkbasketImpl workbasket3 = (WorkbasketImpl) workbasketService
.getWorkbasket("WBI:000000000000000000000000000000000003");
WorkbasketImpl workbasket4 = (WorkbasketImpl) workbasketService
.getWorkbasket("WBI:000000000000000000000000000000000004");
return Arrays.asList(workbasket1, workbasket2, workbasket3, workbasket4);
}
private List<ReportLineItemDefinition> getListOfReportLineItemDefinitions() {
List<ReportLineItemDefinition> reportLineItemDefinitions = new ArrayList<>();
reportLineItemDefinitions.add(new ReportLineItemDefinition(Integer.MIN_VALUE, -6));
reportLineItemDefinitions.add(new ReportLineItemDefinition(-5, -2));
reportLineItemDefinitions.add(new ReportLineItemDefinition(-1));
reportLineItemDefinitions.add(new ReportLineItemDefinition(0));
reportLineItemDefinitions.add(new ReportLineItemDefinition(1));
reportLineItemDefinitions.add(new ReportLineItemDefinition(2, 5));
reportLineItemDefinitions.add(new ReportLineItemDefinition(6, Integer.MAX_VALUE));
return reportLineItemDefinitions;
}
@AfterClass
public static void cleanUpClass() {
FileUtils.deleteRecursive("~/data", true);
}
}

View File

@ -1,69 +1,123 @@
package pro.taskana.database; package pro.taskana.database;
import java.io.InputStreamReader; import java.io.BufferedReader;
import java.io.PrintWriter; import java.io.ByteArrayInputStream;
import java.io.StringWriter; import java.io.IOException;
import java.sql.Connection; import java.io.InputStreamReader;
import java.sql.SQLException; import java.io.PrintWriter;
import java.io.StringWriter;
import javax.sql.DataSource; import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import org.apache.ibatis.jdbc.ScriptRunner; import java.sql.SQLException;
import org.slf4j.Logger; import java.time.LocalDateTime;
import org.slf4j.LoggerFactory; import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import pro.taskana.configuration.DbSchemaCreator; import java.util.List;
/** import javax.sql.DataSource;
* Generates the test data for integration and acceptance tests.
*/ import org.apache.ibatis.jdbc.ScriptRunner;
public class TestDataGenerator { import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger LOGGER = LoggerFactory.getLogger(DbSchemaCreator.class);
import pro.taskana.configuration.DbSchemaCreator;
private StringWriter outWriter = new StringWriter();
/**
private PrintWriter logWriter; * Generates the test data for integration and acceptance tests.
*/
private StringWriter errorWriter; public class TestDataGenerator {
private PrintWriter errorLogWriter; private static final Logger LOGGER = LoggerFactory.getLogger(DbSchemaCreator.class);
private StringWriter outWriter = new StringWriter();
public TestDataGenerator() { private PrintWriter logWriter;
this.logWriter = new PrintWriter(this.outWriter); private StringWriter errorWriter;
this.errorWriter = new StringWriter(); private PrintWriter errorLogWriter;
this.errorLogWriter = new PrintWriter(this.errorWriter);
} public TestDataGenerator() {
this.logWriter = new PrintWriter(this.outWriter);
public void generateTestData(DataSource dataSource) throws SQLException { this.errorWriter = new StringWriter();
ScriptRunner runner = null; this.errorLogWriter = new PrintWriter(this.errorWriter);
try { }
Connection connection = dataSource.getConnection();
LOGGER.debug(connection.getMetaData().toString()); public void generateTestData(DataSource dataSource) throws SQLException {
runner = new ScriptRunner(connection); ScriptRunner runner = null;
runner.setStopOnError(true); try {
runner.setLogWriter(this.logWriter); Connection connection = dataSource.getConnection();
runner.setErrorLogWriter(this.errorLogWriter); LOGGER.debug(connection.getMetaData().toString());
runner.setStopOnError(true); runner = new ScriptRunner(connection);
runner.setLogWriter(this.logWriter); runner.setStopOnError(true);
runner.setErrorLogWriter(this.errorLogWriter); runner.setLogWriter(this.logWriter);
runner.runScript(new InputStreamReader(this.getClass().getResourceAsStream("/sql/task.sql"))); runner.setErrorLogWriter(this.errorLogWriter);
runner.runScript(new InputStreamReader(this.getClass().getResourceAsStream("/sql/workbasket.sql"))); runner.setStopOnError(true);
runner.runScript( runner.setLogWriter(this.logWriter);
new InputStreamReader(this.getClass().getResourceAsStream("/sql/distribution-targets.sql"))); runner.setErrorLogWriter(this.errorLogWriter);
runner.runScript( runner.runScript(new InputStreamReader(this.getClass().getResourceAsStream("/sql/task.sql")));
new InputStreamReader(this.getClass().getResourceAsStream("/sql/classification.sql"))); runner.runScript(new InputStreamReader(this.getClass().getResourceAsStream("/sql/workbasket.sql")));
runner.runScript( runner.runScript(
new InputStreamReader(this.getClass().getResourceAsStream("/sql/workbasket-access-list.sql"))); new InputStreamReader(this.getClass().getResourceAsStream("/sql/distribution-targets.sql")));
runner.runScript( runner.runScript(
new InputStreamReader(this.getClass().getResourceAsStream("/sql/object-reference.sql"))); new InputStreamReader(this.getClass().getResourceAsStream("/sql/classification.sql")));
} finally { runner.runScript(
new InputStreamReader(this.getClass().getResourceAsStream("/sql/workbasket-access-list.sql")));
runner.closeConnection(); runner.runScript(
LOGGER.debug(outWriter.toString()); new InputStreamReader(this.getClass().getResourceAsStream("/sql/object-reference.sql")));
if (!errorWriter.toString().trim().isEmpty()) { } finally {
LOGGER.error(errorWriter.toString());
} runner.closeConnection();
} LOGGER.debug(outWriter.toString());
} if (!errorWriter.toString().trim().isEmpty()) {
} LOGGER.error(errorWriter.toString());
}
}
}
public void generateMonitoringTestData(DataSource dataSource) throws IOException, SQLException {
ScriptRunner runner = null;
try {
Connection connection = dataSource.getConnection();
LOGGER.debug(connection.getMetaData().toString());
runner = new ScriptRunner(connection);
runner.setStopOnError(true);
runner.setLogWriter(this.logWriter);
runner.setErrorLogWriter(this.errorLogWriter);
runner.setStopOnError(true);
runner.setLogWriter(this.logWriter);
runner.setErrorLogWriter(this.errorLogWriter);
runner.runScript(
new InputStreamReader(
new ByteArrayInputStream(
generateMonitoringSqlData().getBytes(StandardCharsets.UTF_8.name()))));
} finally {
runner.closeConnection();
LOGGER.debug(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
}
}
private String generateMonitoringSqlData() throws IOException {
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(this.getClass().getResourceAsStream("/sql/monitor-sample-data.sql")));
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
StringBuilder sql = new StringBuilder();
String line;
List<Integer> ages = Arrays.asList(-1500, -1200, -1000, -1000, -1000, -500, -500, -300, -200, -100, -50, -20,
-15, -15, -14, -13, -12, -10, -8, -6, -6, -6, -5, -5, -5, -5, -2, -1, -1, -1, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6,
7, 8, 9, 10, 100, 150, 150, 1000, 10000, 100000);
int i = 0;
while ((line = bufferedReader.readLine()) != null) {
if (line.contains("dueDate")) {
line = line.replace("dueDate", "\'" + now.plusDays(ages.get(i)).format(formatter) + "\' ");
i++;
}
sql.append(line).append("\n");
}
bufferedReader.close();
return sql.toString();
}
}

View File

@ -1,6 +1,7 @@
package pro.taskana.impl; package pro.taskana.impl;
import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn;
@ -13,7 +14,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -27,8 +27,9 @@ import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService; import pro.taskana.WorkbasketService;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.model.DueWorkbasketCounter; import pro.taskana.model.DueWorkbasketCounter;
import pro.taskana.model.MonitorQueryItem;
import pro.taskana.model.Report; import pro.taskana.model.Report;
import pro.taskana.model.ReportLine; import pro.taskana.model.ReportLineItemDefinition;
import pro.taskana.model.TaskState; import pro.taskana.model.TaskState;
import pro.taskana.model.TaskStateCounter; import pro.taskana.model.TaskStateCounter;
import pro.taskana.model.mappings.ObjectReferenceMapper; import pro.taskana.model.mappings.ObjectReferenceMapper;
@ -125,23 +126,66 @@ public class TaskMonitorServiceImplTest {
} }
@Test @Test
public void testGetWorkbasketLevelReport() { public void testGetTotalNumbersOfWorkbasketLevelReport() {
List<Workbasket> workbaskets = Arrays.asList(new WorkbasketImpl(), new WorkbasketImpl()); Workbasket workbasket = new WorkbasketImpl();
workbasket.setName("workbasket");
workbasket.setKey("wb1");
List<Workbasket> workbaskets = Arrays.asList(workbasket);
List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY); List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
Report expectedResult = new Report(); List<MonitorQueryItem> expectedResult = new ArrayList<>();
List<ReportLine> expectedDetailLines = new ArrayList<>(); MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
doReturn(expectedDetailLines).when(taskMonitorMapperMock).getDetailLinesByWorkbasketIdsAndStates(any(), any()); monitorQueryItem.setKey("wb1");
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).findByWorkbasketIdsAndStates(workbaskets,
states);
Report actualResult = cut.getWorkbasketLevelReport(workbaskets, states); Report actualResult = cut.getWorkbasketLevelReport(workbaskets, states);
verify(taskanaEngineImpl, times(1)).openConnection(); verify(taskanaEngineImpl, times(1)).openConnection();
verify(taskMonitorMapperMock, times(1)).getDetailLinesByWorkbasketIdsAndStates(any(), any()); verify(taskMonitorMapperMock, times(1)).findByWorkbasketIdsAndStates(any(), any());
verify(taskanaEngineImpl, times(1)).returnConnection(); verify(taskanaEngineImpl, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl, verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
taskMonitorMapperMock, objectReferenceMapperMock, workbasketServiceMock); taskMonitorMapperMock, objectReferenceMapperMock, workbasketServiceMock);
Assert.assertNotNull(actualResult);
assertThat(actualResult.getDetailLines(), equalTo(expectedResult.getDetailLines())); assertNotNull(actualResult);
assertThat(actualResult.getDetailLines().get(workbasket.getKey()).getTotalNumberOfTasks(), equalTo(1));
assertThat(actualResult.getSumLine().getTotalNumberOfTasks(), equalTo(1));
}
@Test
public void testGetWorkbasketLevelReportWithReportLineItemDefinitions() {
Workbasket workbasket = new WorkbasketImpl();
workbasket.setName("workbasket");
workbasket.setKey("wb1");
List<Workbasket> workbaskets = Arrays.asList(workbasket);
List<TaskState> states = Arrays.asList(TaskState.CLAIMED, TaskState.READY);
List<ReportLineItemDefinition> reportLineItemDefinitions = Arrays.asList(new ReportLineItemDefinition(),
new ReportLineItemDefinition());
List<MonitorQueryItem> expectedResult = new ArrayList<>();
MonitorQueryItem monitorQueryItem = new MonitorQueryItem();
monitorQueryItem.setKey("wb1");
monitorQueryItem.setAgeInDays(0);
monitorQueryItem.setNumberOfTasks(1);
expectedResult.add(monitorQueryItem);
doReturn(expectedResult).when(taskMonitorMapperMock).findByWorkbasketIdsAndStates(workbaskets,
states);
Report actualResult = cut.getWorkbasketLevelReport(workbaskets, states, reportLineItemDefinitions);
verify(taskanaEngineImpl, times(1)).openConnection();
verify(taskMonitorMapperMock, times(1)).findByWorkbasketIdsAndStates(any(), any());
verify(taskanaEngineImpl, times(1)).returnConnection();
verifyNoMoreInteractions(taskanaEngineConfigurationMock, taskanaEngineMock, taskanaEngineImpl,
taskMonitorMapperMock, objectReferenceMapperMock, workbasketServiceMock);
assertNotNull(actualResult);
assertThat(actualResult.getDetailLines().get(workbasket.getKey()).getTotalNumberOfTasks(), equalTo(1));
assertThat(actualResult.getDetailLines().get(workbasket.getKey()).getLineItems().get(0).getNumberOfTasks(),
equalTo(1));
assertThat(actualResult.getSumLine().getTotalNumberOfTasks(), equalTo(1));
} }
} }

View File

@ -1,177 +0,0 @@
package pro.taskana.impl.integration;
import java.io.FileNotFoundException;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource;
import org.h2.store.fs.FileUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import pro.taskana.Classification;
import pro.taskana.ClassificationService;
import pro.taskana.TaskMonitorService;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.ClassificationAlreadyExistException;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidOwnerException;
import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.JunitHelper;
import pro.taskana.impl.TaskImpl;
import pro.taskana.impl.TaskServiceImpl;
import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
import pro.taskana.impl.util.IdGenerator;
import pro.taskana.model.Report;
import pro.taskana.model.TaskState;
import pro.taskana.model.WorkbasketAccessItem;
import pro.taskana.model.WorkbasketType;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
/**
* Integration Test for TaskMonitorServiceImpl transactions with connection management mode AUTOCOMMIT.
*/
@RunWith(JAASRunner.class)
public class TaskMonitorServiceImplIntAutocommitTest {
private DataSource dataSource;
private TaskServiceImpl taskServiceImpl;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngine taskanaEngine;
private TaskanaEngineImpl taskanaEngineImpl;
private ClassificationService classificationService;
private WorkbasketService workBasketService;
private TaskMonitorService taskMonitorService;
@BeforeClass
public static void resetDb() throws SQLException {
DataSource ds = TaskanaEngineConfigurationTest.getDataSource();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(ds, true);
}
@Before
public void setup() throws FileNotFoundException, SQLException, LoginException {
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
classificationService = taskanaEngine.getClassificationService();
taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.AUTOCOMMIT);
workBasketService = taskanaEngine.getWorkbasketService();
taskMonitorService = taskanaEngine.getTaskMonitorService();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(dataSource, false);
}
@WithAccessId(userName = "Elena")
@Test
public void testGetWorkbasketLevelReport() throws ClassificationAlreadyExistException, WorkbasketNotFoundException,
ClassificationNotFoundException, NotAuthorizedException, TaskAlreadyExistException, InvalidWorkbasketException,
InvalidArgumentException, TaskNotFoundException, InvalidStateException, InvalidOwnerException {
generateSampleAccessItems();
WorkbasketImpl workbasket1 = (WorkbasketImpl) workBasketService.newWorkbasket();
workbasket1.setName("wb1");
workbasket1.setId("1");
workbasket1.setKey("1");
workbasket1.setDomain("novatec");
workbasket1.setType(WorkbasketType.GROUP);
workBasketService.createWorkbasket(workbasket1);
WorkbasketImpl workbasket2 = (WorkbasketImpl) workBasketService.newWorkbasket();
workbasket2.setName("wb2");
workbasket2.setId("2");
workbasket2.setKey("2");
workbasket2.setDomain("novatec");
workbasket2.setType(WorkbasketType.GROUP);
workBasketService.createWorkbasket(workbasket2);
Classification classification = classificationService.newClassification("novatec", "TEST", "type1");
classificationService.createClassification(classification);
TaskImpl task1 = (TaskImpl) taskServiceImpl.newTask();
task1.setWorkbasketKey(workbasket1.getKey());
task1.setClassificationKey(classification.getKey());
task1.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task1 = (TaskImpl) taskServiceImpl.createTask(task1);
TaskImpl task2 = (TaskImpl) taskServiceImpl.newTask();
task2.setWorkbasketKey(workbasket2.getKey());
task2.setClassificationKey(classification.getKey());
task2.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task2 = (TaskImpl) taskServiceImpl.createTask(task2);
TaskImpl task3 = (TaskImpl) taskServiceImpl.newTask();
task3.setWorkbasketKey(workbasket2.getKey());
task3.setClassificationKey(classification.getKey());
task3.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task3 = (TaskImpl) taskServiceImpl.createTask(task3);
List<Workbasket> workbaskets = Arrays.asList(workbasket1, workbasket2);
List<TaskState> states = Arrays.asList(TaskState.READY, TaskState.CLAIMED);
Report report = taskMonitorService.getWorkbasketLevelReport(workbaskets, states);
int countWorkbasket1 = report.getDetailLines().get(0).getTotalCount();
int countWorkbasket2 = report.getDetailLines().get(1).getTotalCount();
int totalCount = report.getSumLine().getTotalCount();
Assert.assertNotNull(report);
Assert.assertEquals(countWorkbasket1, 1);
Assert.assertEquals(countWorkbasket2, 2);
Assert.assertEquals(countWorkbasket1 + countWorkbasket2, totalCount);
}
private void generateSampleAccessItems() {
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
accessItem.setId(IdGenerator.generateWithPrefix("WAI"));
accessItem.setWorkbasketKey("1");
accessItem.setAccessId("Elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
workBasketService.createWorkbasketAuthorization(accessItem);
WorkbasketAccessItem accessItem2 = new WorkbasketAccessItem();
accessItem2.setId(IdGenerator.generateWithPrefix("WAI"));
accessItem2.setWorkbasketKey("2");
accessItem2.setAccessId("Elena");
accessItem2.setPermAppend(true);
accessItem2.setPermRead(true);
workBasketService.createWorkbasketAuthorization(accessItem2);
}
@After
public void cleanUp() {
taskanaEngineImpl.setConnection(null);
}
@AfterClass
public static void cleanUpClass() {
FileUtils.deleteRecursive("~/data", true);
}
}

View File

@ -1,186 +0,0 @@
package pro.taskana.impl.integration;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import javax.security.auth.login.LoginException;
import javax.sql.DataSource;
import org.h2.store.fs.FileUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import pro.taskana.Classification;
import pro.taskana.ClassificationService;
import pro.taskana.TaskMonitorService;
import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.Workbasket;
import pro.taskana.WorkbasketService;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.ClassificationAlreadyExistException;
import pro.taskana.exceptions.ClassificationNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.InvalidOwnerException;
import pro.taskana.exceptions.InvalidStateException;
import pro.taskana.exceptions.InvalidWorkbasketException;
import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
import pro.taskana.impl.JunitHelper;
import pro.taskana.impl.TaskImpl;
import pro.taskana.impl.TaskServiceImpl;
import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.WorkbasketImpl;
import pro.taskana.impl.configuration.DBCleaner;
import pro.taskana.impl.configuration.TaskanaEngineConfigurationTest;
import pro.taskana.impl.util.IdGenerator;
import pro.taskana.model.Report;
import pro.taskana.model.TaskState;
import pro.taskana.model.WorkbasketAccessItem;
import pro.taskana.model.WorkbasketType;
import pro.taskana.security.JAASRunner;
import pro.taskana.security.WithAccessId;
/**
* Integration Test for TaskMonitorServiceImpl transactions with connection management mode EXPLICIT.
*/
@RunWith(JAASRunner.class)
public class TaskMonitorServiceImplIntExplicitTest {
private DataSource dataSource;
private TaskServiceImpl taskServiceImpl;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngine taskanaEngine;
private TaskanaEngineImpl taskanaEngineImpl;
private ClassificationService classificationService;
private WorkbasketService workBasketService;
private TaskMonitorService taskMonitorService;
@BeforeClass
public static void resetDb() throws SQLException {
DataSource ds = TaskanaEngineConfigurationTest.getDataSource();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(ds, true);
}
@Before
public void setup() throws FileNotFoundException, SQLException, LoginException {
dataSource = TaskanaEngineConfigurationTest.getDataSource();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false);
taskanaEngine = taskanaEngineConfiguration.buildTaskanaEngine();
taskServiceImpl = (TaskServiceImpl) taskanaEngine.getTaskService();
taskanaEngineImpl = (TaskanaEngineImpl) taskanaEngine;
classificationService = taskanaEngine.getClassificationService();
taskanaEngineImpl.setConnectionManagementMode(ConnectionManagementMode.EXPLICIT);
workBasketService = taskanaEngine.getWorkbasketService();
DBCleaner cleaner = new DBCleaner();
cleaner.clearDb(dataSource, false);
}
@WithAccessId(userName = "Elena")
@Test
public void testGetWorkbasketLevelReport() throws SQLException, ClassificationAlreadyExistException,
WorkbasketNotFoundException, ClassificationNotFoundException, NotAuthorizedException, TaskNotFoundException,
TaskAlreadyExistException, InvalidWorkbasketException, InvalidArgumentException, InvalidOwnerException,
InvalidStateException {
Connection connection = dataSource.getConnection();
taskanaEngineImpl.setConnection(connection);
taskMonitorService = taskanaEngine.getTaskMonitorService();
generateSampleAccessItems();
WorkbasketImpl workbasket1 = (WorkbasketImpl) workBasketService.newWorkbasket();
workbasket1.setName("wb1");
workbasket1.setId("1");
workbasket1.setKey("1");
workbasket1.setDomain("novatec");
workbasket1.setType(WorkbasketType.GROUP);
workBasketService.createWorkbasket(workbasket1);
WorkbasketImpl workbasket2 = (WorkbasketImpl) workBasketService.newWorkbasket();
workbasket2.setName("wb2");
workbasket2.setId("2");
workbasket2.setKey("2");
workbasket2.setDomain("novatec");
workbasket2.setType(WorkbasketType.GROUP);
workBasketService.createWorkbasket(workbasket2);
Classification classification = classificationService.newClassification("novatec", "TEST", "type1");
classificationService.createClassification(classification);
TaskImpl task1 = (TaskImpl) taskServiceImpl.newTask();
task1.setWorkbasketKey(workbasket1.getKey());
task1.setClassificationKey(classification.getKey());
task1.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task1 = (TaskImpl) taskServiceImpl.createTask(task1);
connection.commit();
TaskImpl task2 = (TaskImpl) taskServiceImpl.newTask();
task2.setWorkbasketKey(workbasket2.getId());
task2.setClassificationKey(classification.getKey());
task2.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task2 = (TaskImpl) taskServiceImpl.createTask(task2);
connection.commit();
TaskImpl task3 = (TaskImpl) taskServiceImpl.newTask();
task3.setWorkbasketKey(workbasket2.getId());
task3.setClassificationKey(classification.getKey());
task3.setPrimaryObjRef(JunitHelper.createDefaultObjRef());
task3 = (TaskImpl) taskServiceImpl.createTask(task3);
connection.commit();
List<Workbasket> workbaskets = Arrays.asList(workbasket1, workbasket2);
List<TaskState> states = Arrays.asList(TaskState.READY, TaskState.CLAIMED);
Report report = taskMonitorService.getWorkbasketLevelReport(workbaskets, states);
int countWorkbasket1 = report.getDetailLines().get(0).getTotalCount();
int countWorkbasket2 = report.getDetailLines().get(1).getTotalCount();
int totalCount = report.getSumLine().getTotalCount();
Assert.assertNotNull(report);
Assert.assertEquals(countWorkbasket1, 1);
Assert.assertEquals(countWorkbasket2, 2);
Assert.assertEquals(countWorkbasket1 + countWorkbasket2, totalCount);
connection.commit();
}
private void generateSampleAccessItems() {
WorkbasketAccessItem accessItem = new WorkbasketAccessItem();
accessItem.setId(IdGenerator.generateWithPrefix("WAI"));
accessItem.setWorkbasketKey("1");
accessItem.setAccessId("Elena");
accessItem.setPermAppend(true);
accessItem.setPermRead(true);
workBasketService.createWorkbasketAuthorization(accessItem);
WorkbasketAccessItem accessItem2 = new WorkbasketAccessItem();
accessItem2.setId(IdGenerator.generateWithPrefix("WAI"));
accessItem2.setWorkbasketKey("2");
accessItem2.setAccessId("Elena");
accessItem2.setPermAppend(true);
accessItem2.setPermRead(true);
workBasketService.createWorkbasketAuthorization(accessItem2);
}
@After
public void cleanUp() {
taskanaEngineImpl.setConnection(null);
}
@AfterClass
public static void cleanUpClass() {
FileUtils.deleteRecursive("~/data", true);
}
}

View File

@ -0,0 +1,63 @@
-- Tasks
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000001', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task01', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000002', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task02', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000003', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task03', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000004', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task04', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000005', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task05', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000006', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task06', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000007', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task07', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000008', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task08', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000009', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task09', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000010', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task10', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000011', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task11', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000012', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task12', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000013', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task13', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000014', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task14', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000015', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task15', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000016', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task16', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000017', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task17', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000018', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task18', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000019', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task19', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000020', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task20', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000021', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task21', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000022', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task22', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000023', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task23', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000024', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task24', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000025', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task25', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000026', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task26', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000027', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task27', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000028', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task28', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000029', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task29', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000030', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task30', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000031', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task31', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000032', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task32', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000033', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task33', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000034', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task34', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000035', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task35', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000036', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task36', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000037', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task37', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000038', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task38', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000039', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task39', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000040', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task40', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_2', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000041', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task41', 'Some description.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_3', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000042', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task42', 'Some description.', 'Some custom Note', 1, 'CLAIMED', 'T6310', 'USER_1_3', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000043', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task43', 'Some description.', 'Some custom Note', 1, 'CLAIMED', 'T6310', 'USER_1_3', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000044', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task44', 'Some description.', 'Some custom Note', 1, 'CLAIMED', 'T6310', 'USER_1_3', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000045', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task45', 'Some description.', 'Some custom Note', 1, 'CLAIMED', 'T6310', 'USER_1_3', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000046', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task46', 'Some description.', 'Some custom Note', 1, 'CLAIMED', 'T6310', 'USER_1_3', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000047', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task47', 'Some description.', 'Some custom Note', 1, 'CLAIMED', 'T6310', 'USER_1_3', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000048', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task48', 'Some description.', 'Some custom Note', 1, 'CLAIMED', 'T6310', 'USER_1_3', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000049', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task49', 'Some description.', 'Some custom Note', 1, 'CLAIMED', 'T6310', 'USER_1_3', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000050', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, dueDate, 'Task50', 'Some description.', 'Some custom Note', 1, 'CLAIMED', 'T6310', 'USER_1_3', 'DOMAIN_A', 'BPI21', 'PBPI21', 'John', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
-- Workbaskets
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000001', 'USER_1_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'USER_1_1', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 1', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000002', 'USER_1_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'USER_1_2', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 2', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000003', 'USER_1_3', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'USER_1_3', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 3', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:000000000000000000000000000000000004', 'USER_1_4', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'USER_1_4', 'MONITOR_TEST_DOMAIN', 'PERSONAL', 'Monitor Test Postkorb 4', '', '', '', '', '', '', '', '', '');
-- WorkbasketAccessLists
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:000000000000000000000000000000000001', 'USER_1_1', 'monitor_user_1', true, true, true, true, false, false, false, false, false, false, false, false, false);
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:000000000000000000000000000000000002', 'USER_1_2', 'monitor_user_1', true, true, true, true, false, false, false, false, false, false, false, false, false);
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:000000000000000000000000000000000003', 'USER_1_3', 'monitor_user_1', true, true, true, true, false, false, false, false, false, false, false, false, false);
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:000000000000000000000000000000000004', 'USER_1_4', 'monitor_user_1', true, true, true, true, false, false, false, false, false, false, false, false, false);

View File

@ -19,3 +19,4 @@ INSERT INTO TASK VALUES('14', CURRENT_TIMESTAMP, null, null, CURRENT_TIMESTAMP,
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000000', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, 'Task99', 'Lorem ipsum was n Quatsch dolor sit amet.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'Konrad', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000000', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, 'Task99', 'Lorem ipsum was n Quatsch dolor sit amet.', 'Some custom Note', 1, 'READY', 'T6310', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'Konrad', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000001', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, 'Task01', 'Lorem ipsum was n Quatsch dolor sit amet.', 'Some custom Note', 2, 'READY', 'L110102', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'Konrad', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000001', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, 'Task01', 'Lorem ipsum was n Quatsch dolor sit amet.', 'Some custom Note', 2, 'READY', 'L110102', 'USER_1_1', 'DOMAIN_A', 'BPI21', 'PBPI21', 'Konrad', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);
INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000002', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, 'Task02', 'Lorem ipsum was n Quatsch dolor sit amet. Aber stimmt.', 'Some custom Note', 2, 'READY', 'A12', 'GPK_B_KSC', 'DOMAIN_B', 'BPI21', 'PBPI21', 'Konrad', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null); INSERT INTO TASK VALUES('TKI:000000000000000000000000000000000002', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, null, 'Task02', 'Lorem ipsum was n Quatsch dolor sit amet. Aber stimmt.', 'Some custom Note', 2, 'READY', 'A12', 'GPK_B_KSC', 'DOMAIN_B', 'BPI21', 'PBPI21', 'Konrad', 'MyCompany1', 'MySystem1', 'MyInstance1', 'MyType1', 'MyValue1', true, false, null, null, null, null, null, null, null, null, null, null, null);

View File

@ -36,3 +36,4 @@ INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:10000000000000000000000000000000
-- Access to other domains -- Access to other domains
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000023', 'GPK_B_KSC_1', 'group_1', true, false, true, true, false, false, false, false, false, false, false, false, false); INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000023', 'GPK_B_KSC_1', 'group_1', true, false, true, true, false, false, false, false, false, false, false, false, false);
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000024', 'GPK_B_KSC_2', 'group_2', true, false, true, true, false, false, false, false, false, false, false, false, false); INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000024', 'GPK_B_KSC_2', 'group_2', true, false, true, true, false, false, false, false, false, false, false, false, false);

View File

@ -18,3 +18,4 @@ INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000009', 'USER
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000011', 'GPK_B_KSC', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC', '', '', '', '', '', '', '', '', ''); INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000011', 'GPK_B_KSC', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000012', 'GPK_B_KSC_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B1', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 1', '', '', '', '', '', '', '', '', ''); INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000012', 'GPK_B_KSC_1', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B1', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 1', '', '', '', '', '', '', '', '', '');
INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000013', 'GPK_B_KSC_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B2', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 2', '', '', '', '', '', '', '', '', ''); INSERT INTO WORKBASKET VALUES ('WBI:100000000000000000000000000000000013', 'GPK_B_KSC_2', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'Gruppenpostkorb KSC B2', 'DOMAIN_B', 'GROUP', 'Gruppenpostkorb KSC 2', '', '', '', '', '', '', '', '', '');

View File

@ -1,25 +1,26 @@
package pro.taskana; package pro.taskana;
import java.sql.SQLException; import java.sql.SQLException;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import org.apache.ibatis.transaction.managed.ManagedTransactionFactory; import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
import pro.taskana.configuration.SpringTaskanaEngineConfiguration;
import pro.taskana.impl.TaskanaEngineImpl; import pro.taskana.configuration.SpringTaskanaEngineConfiguration;
import pro.taskana.impl.TaskanaEngineImpl;
/**
* This class configures the TaskanaEngine for spring /**
*/ * This class configures the TaskanaEngine for spring
public class SpringTaskanaEngineImpl extends TaskanaEngineImpl { */
public class SpringTaskanaEngineImpl extends TaskanaEngineImpl {
public SpringTaskanaEngineImpl(SpringTaskanaEngineConfiguration taskanaEngineConfiguration) {
super(taskanaEngineConfiguration); public SpringTaskanaEngineImpl(SpringTaskanaEngineConfiguration taskanaEngineConfiguration) {
} super(taskanaEngineConfiguration);
}
@PostConstruct
public void init() throws SQLException { @PostConstruct
this.transactionFactory = new ManagedTransactionFactory(); public void init() throws SQLException {
} this.transactionFactory = new ManagedTransactionFactory();
}
}
}

View File

@ -1,42 +1,43 @@
package pro.taskana.configuration; package pro.taskana.configuration;
import java.sql.SQLException; import java.sql.SQLException;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import pro.taskana.SpringTaskanaEngineImpl;
import pro.taskana.TaskanaEngine; import pro.taskana.SpringTaskanaEngineImpl;
import pro.taskana.TaskanaEngine;
/**
* This class configures the TaskanaEngineConfiguration for spring /**
*/ * This class configures the TaskanaEngineConfiguration for spring
public class SpringTaskanaEngineConfiguration extends TaskanaEngineConfiguration { */
public class SpringTaskanaEngineConfiguration extends TaskanaEngineConfiguration {
private static final Logger logger = LoggerFactory.getLogger(SpringTaskanaEngineConfiguration.class);
private static final Logger logger = LoggerFactory.getLogger(SpringTaskanaEngineConfiguration.class);
/**
* This method creates the Spring-based TaskanaEngine without an /**
* sqlSessionFactory * This method creates the Spring-based TaskanaEngine without an sqlSessionFactory
* *
* @return the TaskanaEngine * @return the TaskanaEngine
*/ */
public TaskanaEngine buildTaskanaEngine() { @Override
this.useManagedTransactions = true; public TaskanaEngine buildTaskanaEngine() {
this.useManagedTransactions = true;
dbScriptRunner = new DbSchemaCreator(this.dataSource);
try { dbScriptRunner = new DbSchemaCreator(this.dataSource);
dbScriptRunner.run(); try {
} catch (SQLException e) { dbScriptRunner.run();
logger.error("The taskana schema could not be created: ", e); } catch (SQLException e) {
} logger.error("The taskana schema could not be created: ", e);
}
return new SpringTaskanaEngineImpl(this);
} return new SpringTaskanaEngineImpl(this);
}
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource; public void setDataSource(DataSource dataSource) {
} this.dataSource = dataSource;
}
}
}