TSK-1009: refactored project

This commit is contained in:
Mustapha Zorgati 2020-01-07 07:41:21 +01:00
parent 86476de4ad
commit afdb22e311
424 changed files with 54601 additions and 52258 deletions

View File

@ -2,14 +2,12 @@ package pro.taskana.simplehistory;
import pro.taskana.history.api.TaskanaHistory;
/**
* The TaskanaHistoryEngine represents an overall set of all needed services.
*/
/** The TaskanaHistoryEngine represents an overall set of all needed services. */
public interface TaskanaHistoryEngine {
/**
* The TaskanaHistory can be used for operations on all history events.
*
* @return the HistoryService
*/
TaskanaHistory getTaskanaHistoryService();
/**
* The TaskanaHistory can be used for operations on all history events.
*
* @return the HistoryService
*/
TaskanaHistory getTaskanaHistoryService();
}

View File

@ -10,73 +10,70 @@ import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Create the schema for the taskana history.
*/
/** Create the schema for the taskana history. */
public class DbSchemaCreator {
private static final Logger LOGGER = LoggerFactory.getLogger(DbSchemaCreator.class);
private static final String DB_SCHEMA = "/sql/taskana-history-schema.sql";
private DataSource dataSource;
private String schemaName;
private StringWriter outWriter = new StringWriter();
private PrintWriter logWriter = new PrintWriter(outWriter);
private StringWriter errorWriter = new StringWriter();
private PrintWriter errorLogWriter = new PrintWriter(errorWriter);
private static final Logger LOGGER = LoggerFactory.getLogger(DbSchemaCreator.class);
private static final String DB_SCHEMA = "/sql/taskana-history-schema.sql";
private DataSource dataSource;
private String schemaName;
private StringWriter outWriter = new StringWriter();
private PrintWriter logWriter = new PrintWriter(outWriter);
private StringWriter errorWriter = new StringWriter();
private PrintWriter errorLogWriter = new PrintWriter(errorWriter);
public DbSchemaCreator(DataSource dataSource, String schema) throws SQLException {
this.dataSource = dataSource;
this.schemaName = schema;
public DbSchemaCreator(DataSource dataSource, String schema) throws SQLException {
this.dataSource = dataSource;
this.schemaName = schema;
}
/**
* Run all db scripts.
*
* @throws SQLException will be thrown if there will be some incorrect SQL statements invoked.
*/
public void run() throws SQLException {
Connection connection = dataSource.getConnection();
connection.setSchema(schemaName);
ScriptRunner runner = new ScriptRunner(connection);
runner.setStopOnError(true);
runner.setLogWriter(logWriter);
runner.setErrorLogWriter(errorLogWriter);
try {
InputStream resourceAsStream = this.getClass().getResourceAsStream(DB_SCHEMA);
BufferedReader reader =
new BufferedReader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
runner.runScript(getSqlWithSchemaNameParsed(reader));
} finally {
runner.closeConnection();
}
/**
* Run all db scripts.
*
* @throws SQLException
* will be thrown if there will be some incorrect SQL statements invoked.
*/
public void run() throws SQLException {
Connection connection = dataSource.getConnection();
connection.setSchema(schemaName);
ScriptRunner runner = new ScriptRunner(connection);
runner.setStopOnError(true);
runner.setLogWriter(logWriter);
runner.setErrorLogWriter(errorLogWriter);
try {
InputStream resourceAsStream = this.getClass().getResourceAsStream(DB_SCHEMA);
BufferedReader reader = new BufferedReader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
runner.runScript(getSqlWithSchemaNameParsed(reader));
} finally {
runner.closeConnection();
}
LOGGER.debug(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
LOGGER.debug(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
}
private StringReader getSqlWithSchemaNameParsed(BufferedReader reader) {
StringBuilder content = new StringBuilder();
try {
String line = "";
while (line != null) {
line = reader.readLine();
if (line != null) {
content.append(line.replaceAll("%schemaName%", schemaName)).append(System.lineSeparator());
}
}
} catch (IOException e) {
e.printStackTrace();
LOGGER.error("SchemaName sql parsing failed for schemaName {}", schemaName);
private StringReader getSqlWithSchemaNameParsed(BufferedReader reader) {
StringBuilder content = new StringBuilder();
try {
String line = "";
while (line != null) {
line = reader.readLine();
if (line != null) {
content
.append(line.replaceAll("%schemaName%", schemaName))
.append(System.lineSeparator());
}
return new StringReader(content.toString());
}
} catch (IOException e) {
e.printStackTrace();
LOGGER.error("SchemaName sql parsing failed for schemaName {}", schemaName);
}
return new StringReader(content.toString());
}
}

View File

@ -2,13 +2,10 @@ package pro.taskana.simplehistory.impl;
import pro.taskana.history.api.TaskanaHistoryEvent;
/**
* This entity contains the most important information about a history event.
*/
/** This entity contains the most important information about a history event. */
public class HistoryEventImpl extends TaskanaHistoryEvent {
public HistoryEventImpl() {
super();
}
public HistoryEventImpl() {
super();
}
}

View File

@ -2,7 +2,6 @@ package pro.taskana.simplehistory.impl;
import java.sql.SQLException;
import java.time.Instant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -13,51 +12,52 @@ import pro.taskana.simplehistory.impl.mappings.HistoryEventMapper;
import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
import pro.taskana.simplehistory.query.HistoryQuery;
/**
* This is the implementation of TaskanaHistory.
*/
/** This is the implementation of TaskanaHistory. */
public class SimpleHistoryServiceImpl implements TaskanaHistory {
private static final Logger LOGGER = LoggerFactory.getLogger(SimpleHistoryServiceImpl.class);
private TaskanaHistoryEngineImpl taskanaHistoryEngine;
private HistoryEventMapper historyEventMapper;
private HistoryQueryMapper historyQueryMapper;
@Override
public void initialize(TaskanaEngineConfiguration taskanaEngineConfiguration) {
try {
this.taskanaHistoryEngine = TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngineConfiguration);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Simple history service implementation initialized with schemaName: {} ",
taskanaEngineConfiguration.getSchemaName());
}
} catch (SQLException e) {
LOGGER.error("There was an error creating Taskana history engine", e);
e.printStackTrace();
}
this.historyEventMapper = this.taskanaHistoryEngine.getSqlSession().getMapper(HistoryEventMapper.class);
this.historyQueryMapper = this.taskanaHistoryEngine.getSqlSession().getMapper(HistoryQueryMapper.class);
private static final Logger LOGGER = LoggerFactory.getLogger(SimpleHistoryServiceImpl.class);
private TaskanaHistoryEngineImpl taskanaHistoryEngine;
private HistoryEventMapper historyEventMapper;
private HistoryQueryMapper historyQueryMapper;
@Override
public void initialize(TaskanaEngineConfiguration taskanaEngineConfiguration) {
try {
this.taskanaHistoryEngine =
TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngineConfiguration);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Simple history service implementation initialized with schemaName: {} ",
taskanaEngineConfiguration.getSchemaName());
}
} catch (SQLException e) {
LOGGER.error("There was an error creating Taskana history engine", e);
e.printStackTrace();
}
this.historyEventMapper =
this.taskanaHistoryEngine.getSqlSession().getMapper(HistoryEventMapper.class);
this.historyQueryMapper =
this.taskanaHistoryEngine.getSqlSession().getMapper(HistoryQueryMapper.class);
}
@Override
public void create(TaskanaHistoryEvent event) {
try {
taskanaHistoryEngine.openConnection();
if (event.getCreated() == null) {
Instant now = Instant.now();
event.setCreated(now);
}
historyEventMapper.insert(event);
} catch (SQLException e) {
e.printStackTrace();
} finally {
taskanaHistoryEngine.returnConnection();
LOGGER.debug("exit from create(TaskanaHistoryEvent event). Returning object = {}.", event);
}
@Override
public void create(TaskanaHistoryEvent event) {
try {
taskanaHistoryEngine.openConnection();
if (event.getCreated() == null) {
Instant now = Instant.now();
event.setCreated(now);
}
historyEventMapper.insert(event);
} catch (SQLException e) {
e.printStackTrace();
} finally {
taskanaHistoryEngine.returnConnection();
LOGGER.debug("exit from create(TaskanaHistoryEvent event). Returning object = {}.", event);
}
}
public HistoryQuery createHistoryQuery() {
return new HistoryQueryImpl(taskanaHistoryEngine, historyQueryMapper);
}
public HistoryQuery createHistoryQuery() {
return new HistoryQueryImpl(taskanaHistoryEngine, historyQueryMapper);
}
}

View File

@ -3,7 +3,6 @@ package pro.taskana.simplehistory.impl;
import java.sql.SQLException;
import java.util.ArrayDeque;
import java.util.Deque;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
@ -21,155 +20,151 @@ import pro.taskana.simplehistory.configuration.DbSchemaCreator;
import pro.taskana.simplehistory.impl.mappings.HistoryEventMapper;
import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
/**
* This is the implementation of TaskanaHistoryEngine.
*/
/** This is the implementation of TaskanaHistoryEngine. */
public class TaskanaHistoryEngineImpl implements TaskanaHistoryEngine {
private static final String DEFAULT = "default";
protected static final ThreadLocal<Deque<SqlSessionManager>> SESSION_STACK = new ThreadLocal<>();
private static final String DEFAULT = "default";
TaskanaEngineConfiguration taskanaEngineConfiguration;
protected SqlSessionManager sessionManager;
protected TransactionFactory transactionFactory;
protected TaskanaHistory taskanaHistoryService;
TaskanaEngineConfiguration taskanaEngineConfiguration;
protected TaskanaHistoryEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration)
throws SQLException {
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
protected SqlSessionManager sessionManager;
createTransactionFactory(this.taskanaEngineConfiguration.getUseManagedTransactions());
this.sessionManager = createSqlSessionManager();
new DbSchemaCreator(
taskanaEngineConfiguration.getDatasource(), taskanaEngineConfiguration.getSchemaName())
.run();
}
protected TransactionFactory transactionFactory;
public static TaskanaHistoryEngineImpl createTaskanaEngine(
TaskanaEngineConfiguration taskanaEngineConfiguration) throws SQLException {
return new TaskanaHistoryEngineImpl(taskanaEngineConfiguration);
}
protected static final ThreadLocal<Deque<SqlSessionManager>> SESSION_STACK = new ThreadLocal<>();
protected TaskanaHistory taskanaHistoryService;
protected TaskanaHistoryEngineImpl(TaskanaEngineConfiguration taskanaEngineConfiguration) throws SQLException {
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
createTransactionFactory(this.taskanaEngineConfiguration.getUseManagedTransactions());
this.sessionManager = createSqlSessionManager();
new DbSchemaCreator(taskanaEngineConfiguration.getDatasource(),
taskanaEngineConfiguration.getSchemaName()).
run();
@Override
public TaskanaHistory getTaskanaHistoryService() {
if (taskanaHistoryService == null) {
SimpleHistoryServiceImpl historyService = new SimpleHistoryServiceImpl();
historyService.initialize(taskanaEngineConfiguration);
this.taskanaHistoryService = historyService;
}
return this.taskanaHistoryService;
}
public static TaskanaHistoryEngineImpl createTaskanaEngine(
TaskanaEngineConfiguration taskanaEngineConfiguration) throws SQLException {
return new TaskanaHistoryEngineImpl(taskanaEngineConfiguration);
/**
* Open the connection to the database. to be called at the begin of each Api call that accesses
* the database
*
* @throws SQLException thrown if the connection could not be opened.
*/
void openConnection() throws SQLException {
initSqlSession();
this.sessionManager.getConnection().setSchema(taskanaEngineConfiguration.getSchemaName());
}
/**
* 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
*/
void returnConnection() {
popSessionFromStack();
if (getSessionStack().isEmpty()
&& this.sessionManager != null
&& this.sessionManager.isManagedSessionStarted()) {
try {
this.sessionManager.commit();
} catch (Exception e) {
}
this.sessionManager.close();
}
}
@Override
public TaskanaHistory getTaskanaHistoryService() {
if (taskanaHistoryService == null) {
SimpleHistoryServiceImpl historyService = new SimpleHistoryServiceImpl();
historyService.initialize(taskanaEngineConfiguration);
this.taskanaHistoryService = historyService;
}
return this.taskanaHistoryService;
/** Initializes the SqlSessionManager. */
void initSqlSession() {
this.sessionManager.startManagedSession();
}
/**
* retrieve the SqlSession used by taskana.
*
* @return the myBatis SqlSession object used by taskana
*/
SqlSession getSqlSession() {
return this.sessionManager;
}
protected SqlSessionManager createSqlSessionManager() {
Environment environment =
new Environment(
DEFAULT, this.transactionFactory, taskanaEngineConfiguration.getDatasource());
Configuration configuration = new Configuration(environment);
// add mappers
configuration.addMapper(HistoryEventMapper.class);
configuration.addMapper(HistoryQueryMapper.class);
SqlSessionFactory localSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
return SqlSessionManager.newInstance(localSessionFactory);
}
protected static void pushSessionToStack(SqlSessionManager session) {
getSessionStack().push(session);
}
protected static void popSessionFromStack() {
Deque<SqlSessionManager> stack = getSessionStack();
if (!stack.isEmpty()) {
stack.pop();
}
}
/**
* Open the connection to the database. to be called at the begin of each Api call that accesses the database
*
* @throws SQLException
* thrown if the connection could not be opened.
*/
void openConnection() throws SQLException {
initSqlSession();
this.sessionManager.getConnection().setSchema(taskanaEngineConfiguration.getSchemaName());
/**
* 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(); ..... taskanaEngineImpl.returnConnection(); calls. In order
* to avoid duplicate opening / closing of connections, we use the sessionStack in the following
* way: Each time, an openConnection call is received, we push the current sessionManager onto the
* stack. On the first call to openConnection, we call sessionManager.startManagedSession() 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 Deque<SqlSessionManager> getSessionStack() {
Deque<SqlSessionManager> stack = SESSION_STACK.get();
if (stack == null) {
stack = new ArrayDeque<>();
SESSION_STACK.set(stack);
}
return stack;
}
/**
* 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
*/
void returnConnection() {
popSessionFromStack();
if (getSessionStack().isEmpty()
&& this.sessionManager != null && this.sessionManager.isManagedSessionStarted()) {
try {
this.sessionManager.commit();
} catch (Exception e) {
}
this.sessionManager.close();
}
protected static SqlSessionManager getSessionFromStack() {
Deque<SqlSessionManager> stack = getSessionStack();
if (stack.isEmpty()) {
return null;
}
return stack.peek();
}
/**
* Initializes the SqlSessionManager.
*/
void initSqlSession() {
this.sessionManager.startManagedSession();
}
/**
* retrieve the SqlSession used by taskana.
*
* @return the myBatis SqlSession object used by taskana
*/
SqlSession getSqlSession() {
return this.sessionManager;
}
/**
* creates the MyBatis transaction factory.
*
* @param useManagedTransactions
* true if TASKANA should use a ManagedTransactionFactory.
*/
private void createTransactionFactory(boolean useManagedTransactions) {
if (useManagedTransactions) {
this.transactionFactory = new ManagedTransactionFactory();
} else {
this.transactionFactory = new JdbcTransactionFactory();
}
}
protected SqlSessionManager createSqlSessionManager() {
Environment environment = new Environment(DEFAULT, this.transactionFactory,
taskanaEngineConfiguration.getDatasource());
Configuration configuration = new Configuration(environment);
// add mappers
configuration.addMapper(HistoryEventMapper.class);
configuration.addMapper(HistoryQueryMapper.class);
SqlSessionFactory localSessionFactory = new SqlSessionFactoryBuilder().build(configuration);
return SqlSessionManager.newInstance(localSessionFactory);
}
protected static void pushSessionToStack(SqlSessionManager session) {
getSessionStack().push(session);
}
protected static void popSessionFromStack() {
Deque<SqlSessionManager> stack = getSessionStack();
if (!stack.isEmpty()) {
stack.pop();
}
}
/**
* 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(); .....
* taskanaEngineImpl.returnConnection(); calls. In order to avoid duplicate opening / closing of connections, we use
* the sessionStack in the following way: Each time, an openConnection call is received, we push the current
* sessionManager onto the stack. On the first call to openConnection, we call sessionManager.startManagedSession()
* 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 Deque<SqlSessionManager> getSessionStack() {
Deque<SqlSessionManager> stack = SESSION_STACK.get();
if (stack == null) {
stack = new ArrayDeque<>();
SESSION_STACK.set(stack);
}
return stack;
}
protected static SqlSessionManager getSessionFromStack() {
Deque<SqlSessionManager> stack = getSessionStack();
if (stack.isEmpty()) {
return null;
}
return stack.peek();
/**
* creates the MyBatis transaction factory.
*
* @param useManagedTransactions true if TASKANA should use a ManagedTransactionFactory.
*/
private void createTransactionFactory(boolean useManagedTransactions) {
if (useManagedTransactions) {
this.transactionFactory = new ManagedTransactionFactory();
} else {
this.transactionFactory = new JdbcTransactionFactory();
}
}
}

View File

@ -5,24 +5,21 @@ import org.apache.ibatis.annotations.Param;
import pro.taskana.history.api.TaskanaHistoryEvent;
/**
* This class is the mybatis mapping of workbaskets.
*/
/** This class is the mybatis mapping of workbaskets. */
public interface HistoryEventMapper {
@Insert(
"<script>INSERT INTO HISTORY_EVENTS (BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, TASK_ID,"
+ " EVENT_TYPE, CREATED, USER_ID, DOMAIN, WORKBASKET_KEY, POR_COMPANY, POR_SYSTEM, POR_INSTANCE,"
+ " POR_TYPE, POR_VALUE, TASK_CLASSIFICATION_KEY, TASK_CLASSIFICATION_CATEGORY, ATTACHMENT_CLASSIFICATION_KEY, "
+ " COMMENT, OLD_VALUE, NEW_VALUE, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, OLD_DATA, NEW_DATA)"
+ " VALUES ( #{historyEvent.businessProcessId}, #{historyEvent.parentBusinessProcessId}, #{historyEvent.taskId},"
+ " #{historyEvent.eventType}, #{historyEvent.created}, #{historyEvent.userId}, #{historyEvent.domain}, #{historyEvent.workbasketKey},"
+ " #{historyEvent.porCompany}, #{historyEvent.porSystem}, #{historyEvent.porInstance}, #{historyEvent.porType},"
+ " #{historyEvent.porValue}, #{historyEvent.taskClassificationKey}, #{historyEvent.taskClassificationCategory},"
+ " #{historyEvent.attachmentClassificationKey}, #{historyEvent.comment}, #{historyEvent.oldValue}, #{historyEvent.newValue},"
+ " #{historyEvent.custom1}, #{historyEvent.custom2}, #{historyEvent.custom3}, #{historyEvent.custom4},"
+ " #{historyEvent.oldData}, #{historyEvent.newData}) "
+ "</script>")
void insert(@Param("historyEvent") TaskanaHistoryEvent historyEvent);
@Insert(
"<script>INSERT INTO HISTORY_EVENTS (BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, TASK_ID,"
+ " EVENT_TYPE, CREATED, USER_ID, DOMAIN, WORKBASKET_KEY, POR_COMPANY, POR_SYSTEM, POR_INSTANCE,"
+ " POR_TYPE, POR_VALUE, TASK_CLASSIFICATION_KEY, TASK_CLASSIFICATION_CATEGORY, ATTACHMENT_CLASSIFICATION_KEY, "
+ " COMMENT, OLD_VALUE, NEW_VALUE, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, OLD_DATA, NEW_DATA)"
+ " VALUES ( #{historyEvent.businessProcessId}, #{historyEvent.parentBusinessProcessId}, #{historyEvent.taskId},"
+ " #{historyEvent.eventType}, #{historyEvent.created}, #{historyEvent.userId}, #{historyEvent.domain}, #{historyEvent.workbasketKey},"
+ " #{historyEvent.porCompany}, #{historyEvent.porSystem}, #{historyEvent.porInstance}, #{historyEvent.porType},"
+ " #{historyEvent.porValue}, #{historyEvent.taskClassificationKey}, #{historyEvent.taskClassificationCategory},"
+ " #{historyEvent.attachmentClassificationKey}, #{historyEvent.comment}, #{historyEvent.oldValue}, #{historyEvent.newValue},"
+ " #{historyEvent.custom1}, #{historyEvent.custom2}, #{historyEvent.custom3}, #{historyEvent.custom4},"
+ " #{historyEvent.oldData}, #{historyEvent.newData}) "
+ "</script>")
void insert(@Param("historyEvent") TaskanaHistoryEvent historyEvent);
}

View File

@ -1,7 +1,6 @@
package pro.taskana.simplehistory.impl.mappings;
import java.util.List;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
@ -9,221 +8,221 @@ import org.apache.ibatis.annotations.Select;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.impl.HistoryQueryImpl;
/**
* This class is the mybatis mapping of historyQueries.
*/
/** This class is the mybatis mapping of historyQueries. */
public interface HistoryQueryMapper {
@Select(
"<script>"
+ "SELECT ID, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, TASK_ID, EVENT_TYPE, CREATED, USER_ID, DOMAIN, WORKBASKET_KEY, "
+ "POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, TASK_CLASSIFICATION_KEY, TASK_CLASSIFICATION_CATEGORY,"
+ "ATTACHMENT_CLASSIFICATION_KEY, COMMENT, OLD_VALUE, NEW_VALUE, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, OLD_DATA, NEW_DATA "
+ "FROM HISTORY_EVENTS"
+ "<where>"
// IN-Queries
+ "<if test='idIn != null'>AND UPPER(ID) IN (<foreach item='item' collection='idIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='businessProcessIdIn != null'>AND UPPER(BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='businessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='parentBusinessProcessIdIn != null'>AND UPPER(PARENT_BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='parentBusinessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskIdIn != null'>AND UPPER(TASK_ID) IN (<foreach item='item' collection='taskIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='eventTypeIn != null'>AND UPPER(EVENT_TYPE) IN (<foreach item='item' collection='eventTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='createdIn !=null'> AND ( <foreach item='item' collection='createdIn' separator=',' > ( <if test='item.begin!=null'> CREATED &gt;= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> CREATED &lt;=#{item.end} </if>)</foreach>)</if> "
+ "<if test='userIdIn != null'>AND UPPER(USER_ID) IN (<foreach item='item' collection='userIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='domainIn != null'>AND UPPER(DOMAIN) IN (<foreach item='item' collection='domainIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='workbasketKeyIn != null'>AND UPPER(WORKBASKET_KEY) IN (<foreach item='item' collection='workbasketKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porCompanyIn != null'>AND UPPER(POR_COMPANY) IN (<foreach item='item' collection='porCompanyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porSystemIn != null'>AND UPPER(POR_SYSTEM) IN (<foreach item='item' collection='porSystemIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porInstanceIn != null'>AND UPPER(POR_INSTANCE) IN (<foreach item='item' collection='porInstanceIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porTypeIn != null'>AND UPPER(POR_TYPE) IN (<foreach item='item' collection='porTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porValueIn != null'>AND UPPER(POR_VALUE) IN (<foreach item='item' collection='porValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyIn != null'>AND UPPER(TASK_CLASSIFICATION_KEY) IN (<foreach item='item' collection='taskClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryIn != null'>AND UPPER(TASK_CLASSIFICATION_CATEGORY) IN (<foreach item='item' collection='taskClassificationCategoryIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyIn != null'>AND UPPER(ATTACHMENT_CLASSIFICATION_KEY) IN (<foreach item='item' collection='attachmentClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='commentIn != null'>AND UPPER(COMMENT) IN (<foreach item='item' collection='commentIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldValueIn != null'>AND UPPER(OLD_VALUE) IN (<foreach item='item' collection='oldValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newValueIn != null'>AND UPPER(NEW_VALUE) IN (<foreach item='item' collection='newValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom1In != null'>AND UPPER(CUSTOM_1) IN (<foreach item='item' collection='custom1In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom2In != null'>AND UPPER(CUSTOM_2) IN (<foreach item='item' collection='custom2In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom3In != null'>AND UPPER(CUSTOM_3) IN (<foreach item='item' collection='custom3In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom4In != null'>AND UPPER(CUSTOM_4) IN (<foreach item='item' collection='custom4In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldDataIn != null'>AND UPPER(OLD_DATA) IN (<foreach item='item' collection='oldDataIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newDataIn != null'>AND UPPER(NEW_DATA) IN (<foreach item='item' collection='newDataIn' separator=',' >#{item}</foreach>)</if> "
// LIKE-Queries
+ "<if test='businessProcessIdLike != null'>AND (<foreach item='item' collection='businessProcessIdLike' separator='OR' > UPPER(BUSINESS_PROCESS_ID) LIKE #{item} </foreach>)</if> "
+ "<if test='parentBusinessProcessIdLike != null'>AND (<foreach item='item' collection='parentBusinessProcessIdLike' separator=' OR ' >UPPER(PARENT_BUSINESS_PROCESS_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='taskIdLike != null'>AND (<foreach item='item' collection='taskIdLike' separator=' OR ' >UPPER(TASK_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='eventTypeLike != null'>AND (<foreach item='item' collection='eventTypeLike' separator=' OR ' >UPPER(EVENT_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='userIdLike != null'>AND (<foreach item='item' collection='userIdLike' separator=' OR ' >UPPER(USER_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='domainLike != null'>AND (<foreach item='item' collection='domainLike' separator=' OR ' >UPPER(DOMAIN) LIKE #{item}</foreach>)</if> "
+ "<if test='workbasketKeyLike != null'>AND (<foreach item='item' collection='workbasketKeyLike' separator=' OR ' >UPPER(WORKBASKET_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='porCompanyLike != null'>AND (<foreach item='item' collection='porCompanyLike' separator=' OR ' >UPPER(POR_COMPANY) LIKE #{item}</foreach>)</if> "
+ "<if test='porSystemLike != null'>AND (<foreach item='item' collection='porSystemLike' separator=' OR ' >UPPER(POR_SYSTEM) LIKE #{item}</foreach>)</if> "
+ "<if test='porInstanceLike != null'>AND (<foreach item='item' collection='porInstanceLike' separator=' OR ' >UPPER(POR_INSTANCE) LIKE #{item}</foreach>)</if> "
+ "<if test='porTypeLike != null'>AND (<foreach item='item' collection='porTypeLike' separator=' OR ' >UPPER(POR_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='porValueLike != null'>AND (<foreach item='item' collection='porValueLike' separator=' OR ' >UPPER(POR_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyLike != null'>AND (<foreach item='item' collection='taskClassificationKeyLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryLike != null'>AND (<foreach item='item' collection='taskClassificationCategoryLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_CATEGORY) LIKE #{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyLike != null'>AND (<foreach item='item' collection='attachmentClassificationKeyLike' separator=' OR ' >UPPER(ATTACHMENT_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='commentLike != null'>AND (<foreach item='item' collection='commentLike' separator=' OR ' >UPPER(COMMENT) LIKE #{item}</foreach>)</if> "
+ "<if test='oldValueLike != null'>AND (<foreach item='item' collection='oldValueLike' separator=' OR ' >UPPER(OLD_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='newValueLike != null'>AND (<foreach item='item' collection='newValueLike' separator=' OR ' >UPPER(NEW_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='custom1Like != null'>AND (<foreach item='item' collection='custom1Like' separator=' OR ' >UPPER(CUSTOM_1) LIKE #{item}</foreach>)</if> "
+ "<if test='custom2Like != null'>AND (<foreach item='item' collection='custom2Like' separator=' OR ' >UPPER(CUSTOM_2) LIKE #{item}</foreach>)</if> "
+ "<if test='custom3Like != null'>AND (<foreach item='item' collection='custom3Like' separator=' OR ' >UPPER(CUSTOM_3) LIKE #{item}</foreach>)</if> "
+ "<if test='custom4Like != null'>AND (<foreach item='item' collection='custom4Like' separator=' OR ' >UPPER(CUSTOM_4) LIKE #{item}</foreach>)</if> "
+ "<if test='oldDataLike != null'>AND (<foreach item='item' collection='oldDataLike' separator=' OR ' >UPPER(OLD_DATA) LIKE #{item}</foreach>)</if> "
+ "<if test='newDataLike != null'>AND (<foreach item='item' collection='newDataLike' separator=' OR ' >UPPER(NEW_DATA) LIKE #{item}</foreach>)</if> "
+ "</where>"
+ "<if test='!orderBy.isEmpty()'>ORDER BY <foreach item='item' collection='orderBy' separator=',' >${item}</foreach></if> "
+ "<if test='maxRows > 0'> FETCH FIRST #{maxRows} ROWS ONLY </if>"
+ "</script>")
@Results(value = {
@Result(property = "id", column = "ID"),
@Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"),
@Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"),
@Result(property = "taskId", column = "TASK_ID"),
@Result(property = "eventType", column = "EVENT_TYPE"),
@Result(property = "created", column = "CREATED"),
@Result(property = "userId", column = "USER_ID"),
@Result(property = "domain", column = "DOMAIN"),
@Result(property = "workbasketKey", column = "WORKBASKET_KEY"),
@Result(property = "porCompany", column = "POR_COMPANY"),
@Result(property = "porSystem", column = "POR_SYSTEM"),
@Result(property = "porInstance", column = "POR_INSTANCE"),
@Result(property = "porType", column = "POR_TYPE"),
@Result(property = "porValue", column = "POR_VALUE"),
@Result(property = "taskClassificationKey", column = "TASK_CLASSIFICATION_KEY"),
@Result(property = "taskClassificationCategory", column = "TASK_CLASSIFICATION_CATEGORY"),
@Result(property = "attachmentClassificationKey", column = "ATTACHMENT_CLASSIFICATION_KEY"),
@Result(property = "comment", column = "COMMENT"),
@Result(property = "oldValue", column = "OLD_VALUE"),
@Result(property = "newValue", column = "NEW_VALUE"),
@Result(property = "custom1", column = "CUSTOM_1"),
@Result(property = "custom2", column = "CUSTOM_2"),
@Result(property = "custom3", column = "CUSTOM_3"),
@Result(property = "custom4", column = "CUSTOM_4"),
@Result(property = "oldData", column = "OLD_DATA"),
@Result(property = "newData", column = "NEW_DATA")
})
List<HistoryEventImpl> queryHistoryEvent(HistoryQueryImpl historyEventQuery);
@Select(
"<script>"
+ "SELECT ID, BUSINESS_PROCESS_ID, PARENT_BUSINESS_PROCESS_ID, TASK_ID, EVENT_TYPE, CREATED, USER_ID, DOMAIN, WORKBASKET_KEY, "
+ "POR_COMPANY, POR_SYSTEM, POR_INSTANCE, POR_TYPE, POR_VALUE, TASK_CLASSIFICATION_KEY, TASK_CLASSIFICATION_CATEGORY,"
+ "ATTACHMENT_CLASSIFICATION_KEY, COMMENT, OLD_VALUE, NEW_VALUE, CUSTOM_1, CUSTOM_2, CUSTOM_3, CUSTOM_4, OLD_DATA, NEW_DATA "
+ "FROM HISTORY_EVENTS"
+ "<where>"
// IN-Queries
+ "<if test='idIn != null'>AND UPPER(ID) IN (<foreach item='item' collection='idIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='businessProcessIdIn != null'>AND UPPER(BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='businessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='parentBusinessProcessIdIn != null'>AND UPPER(PARENT_BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='parentBusinessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskIdIn != null'>AND UPPER(TASK_ID) IN (<foreach item='item' collection='taskIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='eventTypeIn != null'>AND UPPER(EVENT_TYPE) IN (<foreach item='item' collection='eventTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='createdIn !=null'> AND ( <foreach item='item' collection='createdIn' separator=',' > ( <if test='item.begin!=null'> CREATED &gt;= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> CREATED &lt;=#{item.end} </if>)</foreach>)</if> "
+ "<if test='userIdIn != null'>AND UPPER(USER_ID) IN (<foreach item='item' collection='userIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='domainIn != null'>AND UPPER(DOMAIN) IN (<foreach item='item' collection='domainIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='workbasketKeyIn != null'>AND UPPER(WORKBASKET_KEY) IN (<foreach item='item' collection='workbasketKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porCompanyIn != null'>AND UPPER(POR_COMPANY) IN (<foreach item='item' collection='porCompanyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porSystemIn != null'>AND UPPER(POR_SYSTEM) IN (<foreach item='item' collection='porSystemIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porInstanceIn != null'>AND UPPER(POR_INSTANCE) IN (<foreach item='item' collection='porInstanceIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porTypeIn != null'>AND UPPER(POR_TYPE) IN (<foreach item='item' collection='porTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porValueIn != null'>AND UPPER(POR_VALUE) IN (<foreach item='item' collection='porValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyIn != null'>AND UPPER(TASK_CLASSIFICATION_KEY) IN (<foreach item='item' collection='taskClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryIn != null'>AND UPPER(TASK_CLASSIFICATION_CATEGORY) IN (<foreach item='item' collection='taskClassificationCategoryIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyIn != null'>AND UPPER(ATTACHMENT_CLASSIFICATION_KEY) IN (<foreach item='item' collection='attachmentClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='commentIn != null'>AND UPPER(COMMENT) IN (<foreach item='item' collection='commentIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldValueIn != null'>AND UPPER(OLD_VALUE) IN (<foreach item='item' collection='oldValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newValueIn != null'>AND UPPER(NEW_VALUE) IN (<foreach item='item' collection='newValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom1In != null'>AND UPPER(CUSTOM_1) IN (<foreach item='item' collection='custom1In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom2In != null'>AND UPPER(CUSTOM_2) IN (<foreach item='item' collection='custom2In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom3In != null'>AND UPPER(CUSTOM_3) IN (<foreach item='item' collection='custom3In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom4In != null'>AND UPPER(CUSTOM_4) IN (<foreach item='item' collection='custom4In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldDataIn != null'>AND UPPER(OLD_DATA) IN (<foreach item='item' collection='oldDataIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newDataIn != null'>AND UPPER(NEW_DATA) IN (<foreach item='item' collection='newDataIn' separator=',' >#{item}</foreach>)</if> "
// LIKE-Queries
+ "<if test='businessProcessIdLike != null'>AND (<foreach item='item' collection='businessProcessIdLike' separator='OR' > UPPER(BUSINESS_PROCESS_ID) LIKE #{item} </foreach>)</if> "
+ "<if test='parentBusinessProcessIdLike != null'>AND (<foreach item='item' collection='parentBusinessProcessIdLike' separator=' OR ' >UPPER(PARENT_BUSINESS_PROCESS_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='taskIdLike != null'>AND (<foreach item='item' collection='taskIdLike' separator=' OR ' >UPPER(TASK_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='eventTypeLike != null'>AND (<foreach item='item' collection='eventTypeLike' separator=' OR ' >UPPER(EVENT_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='userIdLike != null'>AND (<foreach item='item' collection='userIdLike' separator=' OR ' >UPPER(USER_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='domainLike != null'>AND (<foreach item='item' collection='domainLike' separator=' OR ' >UPPER(DOMAIN) LIKE #{item}</foreach>)</if> "
+ "<if test='workbasketKeyLike != null'>AND (<foreach item='item' collection='workbasketKeyLike' separator=' OR ' >UPPER(WORKBASKET_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='porCompanyLike != null'>AND (<foreach item='item' collection='porCompanyLike' separator=' OR ' >UPPER(POR_COMPANY) LIKE #{item}</foreach>)</if> "
+ "<if test='porSystemLike != null'>AND (<foreach item='item' collection='porSystemLike' separator=' OR ' >UPPER(POR_SYSTEM) LIKE #{item}</foreach>)</if> "
+ "<if test='porInstanceLike != null'>AND (<foreach item='item' collection='porInstanceLike' separator=' OR ' >UPPER(POR_INSTANCE) LIKE #{item}</foreach>)</if> "
+ "<if test='porTypeLike != null'>AND (<foreach item='item' collection='porTypeLike' separator=' OR ' >UPPER(POR_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='porValueLike != null'>AND (<foreach item='item' collection='porValueLike' separator=' OR ' >UPPER(POR_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyLike != null'>AND (<foreach item='item' collection='taskClassificationKeyLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryLike != null'>AND (<foreach item='item' collection='taskClassificationCategoryLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_CATEGORY) LIKE #{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyLike != null'>AND (<foreach item='item' collection='attachmentClassificationKeyLike' separator=' OR ' >UPPER(ATTACHMENT_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='commentLike != null'>AND (<foreach item='item' collection='commentLike' separator=' OR ' >UPPER(COMMENT) LIKE #{item}</foreach>)</if> "
+ "<if test='oldValueLike != null'>AND (<foreach item='item' collection='oldValueLike' separator=' OR ' >UPPER(OLD_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='newValueLike != null'>AND (<foreach item='item' collection='newValueLike' separator=' OR ' >UPPER(NEW_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='custom1Like != null'>AND (<foreach item='item' collection='custom1Like' separator=' OR ' >UPPER(CUSTOM_1) LIKE #{item}</foreach>)</if> "
+ "<if test='custom2Like != null'>AND (<foreach item='item' collection='custom2Like' separator=' OR ' >UPPER(CUSTOM_2) LIKE #{item}</foreach>)</if> "
+ "<if test='custom3Like != null'>AND (<foreach item='item' collection='custom3Like' separator=' OR ' >UPPER(CUSTOM_3) LIKE #{item}</foreach>)</if> "
+ "<if test='custom4Like != null'>AND (<foreach item='item' collection='custom4Like' separator=' OR ' >UPPER(CUSTOM_4) LIKE #{item}</foreach>)</if> "
+ "<if test='oldDataLike != null'>AND (<foreach item='item' collection='oldDataLike' separator=' OR ' >UPPER(OLD_DATA) LIKE #{item}</foreach>)</if> "
+ "<if test='newDataLike != null'>AND (<foreach item='item' collection='newDataLike' separator=' OR ' >UPPER(NEW_DATA) LIKE #{item}</foreach>)</if> "
+ "</where>"
+ "<if test='!orderBy.isEmpty()'>ORDER BY <foreach item='item' collection='orderBy' separator=',' >${item}</foreach></if> "
+ "<if test='maxRows > 0'> FETCH FIRST #{maxRows} ROWS ONLY </if>"
+ "</script>")
@Results(
value = {
@Result(property = "id", column = "ID"),
@Result(property = "businessProcessId", column = "BUSINESS_PROCESS_ID"),
@Result(property = "parentBusinessProcessId", column = "PARENT_BUSINESS_PROCESS_ID"),
@Result(property = "taskId", column = "TASK_ID"),
@Result(property = "eventType", column = "EVENT_TYPE"),
@Result(property = "created", column = "CREATED"),
@Result(property = "userId", column = "USER_ID"),
@Result(property = "domain", column = "DOMAIN"),
@Result(property = "workbasketKey", column = "WORKBASKET_KEY"),
@Result(property = "porCompany", column = "POR_COMPANY"),
@Result(property = "porSystem", column = "POR_SYSTEM"),
@Result(property = "porInstance", column = "POR_INSTANCE"),
@Result(property = "porType", column = "POR_TYPE"),
@Result(property = "porValue", column = "POR_VALUE"),
@Result(property = "taskClassificationKey", column = "TASK_CLASSIFICATION_KEY"),
@Result(property = "taskClassificationCategory", column = "TASK_CLASSIFICATION_CATEGORY"),
@Result(property = "attachmentClassificationKey", column = "ATTACHMENT_CLASSIFICATION_KEY"),
@Result(property = "comment", column = "COMMENT"),
@Result(property = "oldValue", column = "OLD_VALUE"),
@Result(property = "newValue", column = "NEW_VALUE"),
@Result(property = "custom1", column = "CUSTOM_1"),
@Result(property = "custom2", column = "CUSTOM_2"),
@Result(property = "custom3", column = "CUSTOM_3"),
@Result(property = "custom4", column = "CUSTOM_4"),
@Result(property = "oldData", column = "OLD_DATA"),
@Result(property = "newData", column = "NEW_DATA")
})
List<HistoryEventImpl> queryHistoryEvent(HistoryQueryImpl historyEventQuery);
@Select(
"<script>"
+ "SELECT COUNT(ID) "
+ "FROM HISTORY_EVENTS"
+ "<where>"
// IN-Queries
+ "<if test='businessProcessIdIn != null'>AND UPPER(BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='businessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='parentBusinessProcessIdIn != null'>AND UPPER(PARENT_BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='parentBusinessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskIdIn != null'>AND UPPER(TASK_ID) IN (<foreach item='item' collection='taskIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='eventTypeIn != null'>AND UPPER(EVENT_TYPE) IN (<foreach item='item' collection='eventTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='createdIn !=null'> AND ( <foreach item='item' collection='createdIn' separator=',' > ( <if test='item.begin!=null'> CREATED &gt;= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> CREATED &lt;=#{item.end} </if>)</foreach>)</if> "
+ "<if test='userIdIn != null'>AND UPPER(USER_ID) IN (<foreach item='item' collection='userIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='domainIn != null'>AND UPPER(DOMAIN) IN (<foreach item='item' collection='domainIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='workbasketKeyIn != null'>AND UPPER(WORKBASKET_KEY) IN (<foreach item='item' collection='workbasketKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porCompanyIn != null'>AND UPPER(POR_COMPANY) IN (<foreach item='item' collection='porCompanyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porSystemIn != null'>AND UPPER(POR_SYSTEM) IN (<foreach item='item' collection='porSystemIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porInstanceIn != null'>AND UPPER(POR_INSTANCE) IN (<foreach item='item' collection='porInstanceIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porTypeIn != null'>AND UPPER(POR_TYPE) IN (<foreach item='item' collection='porTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porValueIn != null'>AND UPPER(POR_VALUE) IN (<foreach item='item' collection='porValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyIn != null'>AND UPPER(TASK_CLASSIFICATION_KEY) IN (<foreach item='item' collection='taskClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryIn != null'>AND UPPER(TASK_CLASSIFICATION_CATEGORY) IN (<foreach item='item' collection='taskClassificationCategoryIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyIn != null'>AND UPPER(ATTACHMENT_CLASSIFICATION_KEY) IN (<foreach item='item' collection='attachmentClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='commentIn != null'>AND UPPER(COMMENT) IN (<foreach item='item' collection='commentIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldValueIn != null'>AND UPPER(OLD_VALUE) IN (<foreach item='item' collection='oldValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newValueIn != null'>AND UPPER(NEW_VALUE) IN (<foreach item='item' collection='newValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom1In != null'>AND UPPER(CUSTOM_1) IN (<foreach item='item' collection='custom1In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom2In != null'>AND UPPER(CUSTOM_2) IN (<foreach item='item' collection='custom2In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom3In != null'>AND UPPER(CUSTOM_3) IN (<foreach item='item' collection='custom3In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom4In != null'>AND UPPER(CUSTOM_4) IN (<foreach item='item' collection='custom4In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldDataIn != null'>AND UPPER(OLD_DATA) IN (<foreach item='item' collection='oldDataIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newDataIn != null'>AND UPPER(NEW_DATA) IN (<foreach item='item' collection='newDataIn' separator=',' >#{item}</foreach>)</if> "
// LIKE-Queries
+ "<if test='businessProcessIdLike != null'>AND (<foreach item='item' collection='businessProcessIdLike' separator='OR' > UPPER(BUSINESS_PROCESS_ID) LIKE #{item} </foreach>)</if> "
+ "<if test='parentBusinessProcessIdLike != null'>AND (<foreach item='item' collection='parentBusinessProcessIdLike' separator=' OR ' >UPPER(PARENT_BUSINESS_PROCESS_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='taskIdLike != null'>AND (<foreach item='item' collection='taskIdLike' separator=' OR ' >UPPER(TASK_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='eventTypeLike != null'>AND (<foreach item='item' collection='eventTypeLike' separator=' OR ' >UPPER(EVENT_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='userIdLike != null'>AND (<foreach item='item' collection='userIdLike' separator=' OR ' >UPPER(USER_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='domainLike != null'>AND (<foreach item='item' collection='domainLike' separator=' OR ' >UPPER(DOMAIN) LIKE #{item}</foreach>)</if> "
+ "<if test='workbasketKeyLike != null'>AND (<foreach item='item' collection='workbasketKeyLike' separator=' OR ' >UPPER(WORKBASKET_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='porCompanyLike != null'>AND (<foreach item='item' collection='porCompanyLike' separator=' OR ' >UPPER(POR_COMPANY) LIKE #{item}</foreach>)</if> "
+ "<if test='porSystemLike != null'>AND (<foreach item='item' collection='porSystemLike' separator=' OR ' >UPPER(POR_SYSTEM) LIKE #{item}</foreach>)</if> "
+ "<if test='porInstanceLike != null'>AND (<foreach item='item' collection='porInstanceLike' separator=' OR ' >UPPER(POR_INSTANCE) LIKE #{item}</foreach>)</if> "
+ "<if test='porTypeLike != null'>AND (<foreach item='item' collection='porTypeLike' separator=' OR ' >UPPER(POR_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='porValueLike != null'>AND (<foreach item='item' collection='porValueLike' separator=' OR ' >UPPER(POR_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyLike != null'>AND (<foreach item='item' collection='taskClassificationKeyLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryLike != null'>AND (<foreach item='item' collection='taskClassificationCategoryLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_CATEGORY) LIKE #{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyLike != null'>AND (<foreach item='item' collection='attachmentClassificationKeyLike' separator=' OR ' >UPPER(ATTACHMENT_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='commentLike != null'>AND (<foreach item='item' collection='commentLike' separator=' OR ' >UPPER(COMMENT) LIKE #{item}</foreach>)</if> "
+ "<if test='oldValueLike != null'>AND (<foreach item='item' collection='oldValueLike' separator=' OR ' >UPPER(OLD_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='newValueLike != null'>AND (<foreach item='item' collection='newValueLike' separator=' OR ' >UPPER(NEW_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='custom1Like != null'>AND (<foreach item='item' collection='custom1Like' separator=' OR ' >UPPER(CUSTOM_1) LIKE #{item}</foreach>)</if> "
+ "<if test='custom2Like != null'>AND (<foreach item='item' collection='custom2Like' separator=' OR ' >UPPER(CUSTOM_2) LIKE #{item}</foreach>)</if> "
+ "<if test='custom3Like != null'>AND (<foreach item='item' collection='custom3Like' separator=' OR ' >UPPER(CUSTOM_3) LIKE #{item}</foreach>)</if> "
+ "<if test='custom4Like != null'>AND (<foreach item='item' collection='custom4Like' separator=' OR ' >UPPER(CUSTOM_4) LIKE #{item}</foreach>)</if> "
+ "<if test='oldDataLike != null'>AND (<foreach item='item' collection='oldDataLike' separator=' OR ' >UPPER(OLD_DATA) LIKE #{item}</foreach>)</if> "
+ "<if test='newDataLike != null'>AND (<foreach item='item' collection='newDataLike' separator=' OR ' >UPPER(NEW_DATA) LIKE #{item}</foreach>)</if> "
+ "</where>"
+ "</script>")
long countHistoryEvent(HistoryQueryImpl historyEventQuery);
@Select(
"<script>"
+ "SELECT COUNT(ID) "
+ "FROM HISTORY_EVENTS"
+ "<where>"
// IN-Queries
+ "<if test='businessProcessIdIn != null'>AND UPPER(BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='businessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='parentBusinessProcessIdIn != null'>AND UPPER(PARENT_BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='parentBusinessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskIdIn != null'>AND UPPER(TASK_ID) IN (<foreach item='item' collection='taskIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='eventTypeIn != null'>AND UPPER(EVENT_TYPE) IN (<foreach item='item' collection='eventTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='createdIn !=null'> AND ( <foreach item='item' collection='createdIn' separator=',' > ( <if test='item.begin!=null'> CREATED &gt;= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> CREATED &lt;=#{item.end} </if>)</foreach>)</if> "
+ "<if test='userIdIn != null'>AND UPPER(USER_ID) IN (<foreach item='item' collection='userIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='domainIn != null'>AND UPPER(DOMAIN) IN (<foreach item='item' collection='domainIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='workbasketKeyIn != null'>AND UPPER(WORKBASKET_KEY) IN (<foreach item='item' collection='workbasketKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porCompanyIn != null'>AND UPPER(POR_COMPANY) IN (<foreach item='item' collection='porCompanyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porSystemIn != null'>AND UPPER(POR_SYSTEM) IN (<foreach item='item' collection='porSystemIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porInstanceIn != null'>AND UPPER(POR_INSTANCE) IN (<foreach item='item' collection='porInstanceIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porTypeIn != null'>AND UPPER(POR_TYPE) IN (<foreach item='item' collection='porTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porValueIn != null'>AND UPPER(POR_VALUE) IN (<foreach item='item' collection='porValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyIn != null'>AND UPPER(TASK_CLASSIFICATION_KEY) IN (<foreach item='item' collection='taskClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryIn != null'>AND UPPER(TASK_CLASSIFICATION_CATEGORY) IN (<foreach item='item' collection='taskClassificationCategoryIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyIn != null'>AND UPPER(ATTACHMENT_CLASSIFICATION_KEY) IN (<foreach item='item' collection='attachmentClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='commentIn != null'>AND UPPER(COMMENT) IN (<foreach item='item' collection='commentIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldValueIn != null'>AND UPPER(OLD_VALUE) IN (<foreach item='item' collection='oldValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newValueIn != null'>AND UPPER(NEW_VALUE) IN (<foreach item='item' collection='newValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom1In != null'>AND UPPER(CUSTOM_1) IN (<foreach item='item' collection='custom1In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom2In != null'>AND UPPER(CUSTOM_2) IN (<foreach item='item' collection='custom2In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom3In != null'>AND UPPER(CUSTOM_3) IN (<foreach item='item' collection='custom3In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom4In != null'>AND UPPER(CUSTOM_4) IN (<foreach item='item' collection='custom4In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldDataIn != null'>AND UPPER(OLD_DATA) IN (<foreach item='item' collection='oldDataIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newDataIn != null'>AND UPPER(NEW_DATA) IN (<foreach item='item' collection='newDataIn' separator=',' >#{item}</foreach>)</if> "
// LIKE-Queries
+ "<if test='businessProcessIdLike != null'>AND (<foreach item='item' collection='businessProcessIdLike' separator='OR' > UPPER(BUSINESS_PROCESS_ID) LIKE #{item} </foreach>)</if> "
+ "<if test='parentBusinessProcessIdLike != null'>AND (<foreach item='item' collection='parentBusinessProcessIdLike' separator=' OR ' >UPPER(PARENT_BUSINESS_PROCESS_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='taskIdLike != null'>AND (<foreach item='item' collection='taskIdLike' separator=' OR ' >UPPER(TASK_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='eventTypeLike != null'>AND (<foreach item='item' collection='eventTypeLike' separator=' OR ' >UPPER(EVENT_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='userIdLike != null'>AND (<foreach item='item' collection='userIdLike' separator=' OR ' >UPPER(USER_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='domainLike != null'>AND (<foreach item='item' collection='domainLike' separator=' OR ' >UPPER(DOMAIN) LIKE #{item}</foreach>)</if> "
+ "<if test='workbasketKeyLike != null'>AND (<foreach item='item' collection='workbasketKeyLike' separator=' OR ' >UPPER(WORKBASKET_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='porCompanyLike != null'>AND (<foreach item='item' collection='porCompanyLike' separator=' OR ' >UPPER(POR_COMPANY) LIKE #{item}</foreach>)</if> "
+ "<if test='porSystemLike != null'>AND (<foreach item='item' collection='porSystemLike' separator=' OR ' >UPPER(POR_SYSTEM) LIKE #{item}</foreach>)</if> "
+ "<if test='porInstanceLike != null'>AND (<foreach item='item' collection='porInstanceLike' separator=' OR ' >UPPER(POR_INSTANCE) LIKE #{item}</foreach>)</if> "
+ "<if test='porTypeLike != null'>AND (<foreach item='item' collection='porTypeLike' separator=' OR ' >UPPER(POR_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='porValueLike != null'>AND (<foreach item='item' collection='porValueLike' separator=' OR ' >UPPER(POR_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyLike != null'>AND (<foreach item='item' collection='taskClassificationKeyLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryLike != null'>AND (<foreach item='item' collection='taskClassificationCategoryLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_CATEGORY) LIKE #{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyLike != null'>AND (<foreach item='item' collection='attachmentClassificationKeyLike' separator=' OR ' >UPPER(ATTACHMENT_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='commentLike != null'>AND (<foreach item='item' collection='commentLike' separator=' OR ' >UPPER(COMMENT) LIKE #{item}</foreach>)</if> "
+ "<if test='oldValueLike != null'>AND (<foreach item='item' collection='oldValueLike' separator=' OR ' >UPPER(OLD_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='newValueLike != null'>AND (<foreach item='item' collection='newValueLike' separator=' OR ' >UPPER(NEW_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='custom1Like != null'>AND (<foreach item='item' collection='custom1Like' separator=' OR ' >UPPER(CUSTOM_1) LIKE #{item}</foreach>)</if> "
+ "<if test='custom2Like != null'>AND (<foreach item='item' collection='custom2Like' separator=' OR ' >UPPER(CUSTOM_2) LIKE #{item}</foreach>)</if> "
+ "<if test='custom3Like != null'>AND (<foreach item='item' collection='custom3Like' separator=' OR ' >UPPER(CUSTOM_3) LIKE #{item}</foreach>)</if> "
+ "<if test='custom4Like != null'>AND (<foreach item='item' collection='custom4Like' separator=' OR ' >UPPER(CUSTOM_4) LIKE #{item}</foreach>)</if> "
+ "<if test='oldDataLike != null'>AND (<foreach item='item' collection='oldDataLike' separator=' OR ' >UPPER(OLD_DATA) LIKE #{item}</foreach>)</if> "
+ "<if test='newDataLike != null'>AND (<foreach item='item' collection='newDataLike' separator=' OR ' >UPPER(NEW_DATA) LIKE #{item}</foreach>)</if> "
+ "</where>"
+ "</script>")
long countHistoryEvent(HistoryQueryImpl historyEventQuery);
@Select("<script>SELECT DISTINCT ${columnName} "
+ "FROM HISTORY_EVENTS"
+ "<where>"
// IN-Queries
+ "<if test='idIn != null'>AND UPPER(ID) IN (<foreach item='item' collection='idIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='businessProcessIdIn != null'>AND UPPER(BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='businessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='parentBusinessProcessIdIn != null'>AND UPPER(PARENT_BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='parentBusinessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskIdIn != null'>AND UPPER(TASK_ID) IN (<foreach item='item' collection='taskIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='eventTypeIn != null'>AND UPPER(EVENT_TYPE) IN (<foreach item='item' collection='eventTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='createdIn !=null'> AND ( <foreach item='item' collection='createdIn' separator=',' > ( <if test='item.begin!=null'> CREATED &gt;= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> CREATED &lt;=#{item.end} </if>)</foreach>)</if> "
+ "<if test='userIdIn != null'>AND UPPER(USER_ID) IN (<foreach item='item' collection='userIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='domainIn != null'>AND UPPER(DOMAIN) IN (<foreach item='item' collection='domainIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='workbasketKeyIn != null'>AND UPPER(WORKBASKET_KEY) IN (<foreach item='item' collection='workbasketKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porCompanyIn != null'>AND UPPER(POR_COMPANY) IN (<foreach item='item' collection='porCompanyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porSystemIn != null'>AND UPPER(POR_SYSTEM) IN (<foreach item='item' collection='porSystemIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porInstanceIn != null'>AND UPPER(POR_INSTANCE) IN (<foreach item='item' collection='porInstanceIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porTypeIn != null'>AND UPPER(POR_TYPE) IN (<foreach item='item' collection='porTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porValueIn != null'>AND UPPER(POR_VALUE) IN (<foreach item='item' collection='porValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyIn != null'>AND UPPER(TASK_CLASSIFICATION_KEY) IN (<foreach item='item' collection='taskClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryIn != null'>AND UPPER(TASK_CLASSIFICATION_CATEGORY) IN (<foreach item='item' collection='taskClassificationCategoryIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyIn != null'>AND UPPER(ATTACHMENT_CLASSIFICATION_KEY) IN (<foreach item='item' collection='attachmentClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='commentIn != null'>AND UPPER(COMMENT) IN (<foreach item='item' collection='commentIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldValueIn != null'>AND UPPER(OLD_VALUE) IN (<foreach item='item' collection='oldValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newValueIn != null'>AND UPPER(NEW_VALUE) IN (<foreach item='item' collection='newValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom1In != null'>AND UPPER(CUSTOM_1) IN (<foreach item='item' collection='custom1In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom2In != null'>AND UPPER(CUSTOM_2) IN (<foreach item='item' collection='custom2In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom3In != null'>AND UPPER(CUSTOM_3) IN (<foreach item='item' collection='custom3In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom4In != null'>AND UPPER(CUSTOM_4) IN (<foreach item='item' collection='custom4In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldDataIn != null'>AND UPPER(OLD_DATA) IN (<foreach item='item' collection='oldDataIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newDataIn != null'>AND UPPER(NEW_DATA) IN (<foreach item='item' collection='newDataIn' separator=',' >#{item}</foreach>)</if> "
// LIKE-Queries
+ "<if test='businessProcessIdLike != null'>AND (<foreach item='item' collection='businessProcessIdLike' separator='OR' > UPPER(BUSINESS_PROCESS_ID) LIKE #{item} </foreach>)</if> "
+ "<if test='parentBusinessProcessIdLike != null'>AND (<foreach item='item' collection='parentBusinessProcessIdLike' separator=' OR ' >UPPER(PARENT_BUSINESS_PROCESS_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='taskIdLike != null'>AND (<foreach item='item' collection='taskIdLike' separator=' OR ' >UPPER(TASK_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='eventTypeLike != null'>AND (<foreach item='item' collection='eventTypeLike' separator=' OR ' >UPPER(EVENT_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='userIdLike != null'>AND (<foreach item='item' collection='userIdLike' separator=' OR ' >UPPER(USER_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='domainLike != null'>AND (<foreach item='item' collection='domainLike' separator=' OR ' >UPPER(DOMAIN) LIKE #{item}</foreach>)</if> "
+ "<if test='workbasketKeyLike != null'>AND (<foreach item='item' collection='workbasketKeyLike' separator=' OR ' >UPPER(WORKBASKET_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='porCompanyLike != null'>AND (<foreach item='item' collection='porCompanyLike' separator=' OR ' >UPPER(POR_COMPANY) LIKE #{item}</foreach>)</if> "
+ "<if test='porSystemLike != null'>AND (<foreach item='item' collection='porSystemLike' separator=' OR ' >UPPER(POR_SYSTEM) LIKE #{item}</foreach>)</if> "
+ "<if test='porInstanceLike != null'>AND (<foreach item='item' collection='porInstanceLike' separator=' OR ' >UPPER(POR_INSTANCE) LIKE #{item}</foreach>)</if> "
+ "<if test='porTypeLike != null'>AND (<foreach item='item' collection='porTypeLike' separator=' OR ' >UPPER(POR_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='porValueLike != null'>AND (<foreach item='item' collection='porValueLike' separator=' OR ' >UPPER(POR_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyLike != null'>AND (<foreach item='item' collection='taskClassificationKeyLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryLike != null'>AND (<foreach item='item' collection='taskClassificationCategoryLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_CATEGORY) LIKE #{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyLike != null'>AND (<foreach item='item' collection='attachmentClassificationKeyLike' separator=' OR ' >UPPER(ATTACHMENT_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='commentLike != null'>AND (<foreach item='item' collection='commentLike' separator=' OR ' >UPPER(COMMENT) LIKE #{item}</foreach>)</if> "
+ "<if test='oldValueLike != null'>AND (<foreach item='item' collection='oldValueLike' separator=' OR ' >UPPER(OLD_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='newValueLike != null'>AND (<foreach item='item' collection='newValueLike' separator=' OR ' >UPPER(NEW_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='custom1Like != null'>AND (<foreach item='item' collection='custom1Like' separator=' OR ' >UPPER(CUSTOM_1) LIKE #{item}</foreach>)</if> "
+ "<if test='custom2Like != null'>AND (<foreach item='item' collection='custom2Like' separator=' OR ' >UPPER(CUSTOM_2) LIKE #{item}</foreach>)</if> "
+ "<if test='custom3Like != null'>AND (<foreach item='item' collection='custom3Like' separator=' OR ' >UPPER(CUSTOM_3) LIKE #{item}</foreach>)</if> "
+ "<if test='custom4Like != null'>AND (<foreach item='item' collection='custom4Like' separator=' OR ' >UPPER(CUSTOM_4) LIKE #{item}</foreach>)</if> "
+ "<if test='oldDataLike != null'>AND (<foreach item='item' collection='oldDataLike' separator=' OR ' >UPPER(OLD_DATA) LIKE #{item}</foreach>)</if> "
+ "<if test='newDataLike != null'>AND (<foreach item='item' collection='newDataLike' separator=' OR ' >UPPER(NEW_DATA) LIKE #{item}</foreach>)</if> "
+ "</where>"
+ "<if test='!orderBy.isEmpty()'>ORDER BY <foreach item='item' collection='orderBy' separator=',' >${item}</foreach></if> "
+ "</script>")
List<String> queryHistoryColumnValues(HistoryQueryImpl historyQuery);
@Select(
"<script>SELECT DISTINCT ${columnName} "
+ "FROM HISTORY_EVENTS"
+ "<where>"
// IN-Queries
+ "<if test='idIn != null'>AND UPPER(ID) IN (<foreach item='item' collection='idIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='businessProcessIdIn != null'>AND UPPER(BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='businessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='parentBusinessProcessIdIn != null'>AND UPPER(PARENT_BUSINESS_PROCESS_ID) IN (<foreach item='item' collection='parentBusinessProcessIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskIdIn != null'>AND UPPER(TASK_ID) IN (<foreach item='item' collection='taskIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='eventTypeIn != null'>AND UPPER(EVENT_TYPE) IN (<foreach item='item' collection='eventTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='createdIn !=null'> AND ( <foreach item='item' collection='createdIn' separator=',' > ( <if test='item.begin!=null'> CREATED &gt;= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> CREATED &lt;=#{item.end} </if>)</foreach>)</if> "
+ "<if test='userIdIn != null'>AND UPPER(USER_ID) IN (<foreach item='item' collection='userIdIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='domainIn != null'>AND UPPER(DOMAIN) IN (<foreach item='item' collection='domainIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='workbasketKeyIn != null'>AND UPPER(WORKBASKET_KEY) IN (<foreach item='item' collection='workbasketKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porCompanyIn != null'>AND UPPER(POR_COMPANY) IN (<foreach item='item' collection='porCompanyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porSystemIn != null'>AND UPPER(POR_SYSTEM) IN (<foreach item='item' collection='porSystemIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porInstanceIn != null'>AND UPPER(POR_INSTANCE) IN (<foreach item='item' collection='porInstanceIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porTypeIn != null'>AND UPPER(POR_TYPE) IN (<foreach item='item' collection='porTypeIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='porValueIn != null'>AND UPPER(POR_VALUE) IN (<foreach item='item' collection='porValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyIn != null'>AND UPPER(TASK_CLASSIFICATION_KEY) IN (<foreach item='item' collection='taskClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryIn != null'>AND UPPER(TASK_CLASSIFICATION_CATEGORY) IN (<foreach item='item' collection='taskClassificationCategoryIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyIn != null'>AND UPPER(ATTACHMENT_CLASSIFICATION_KEY) IN (<foreach item='item' collection='attachmentClassificationKeyIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='commentIn != null'>AND UPPER(COMMENT) IN (<foreach item='item' collection='commentIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldValueIn != null'>AND UPPER(OLD_VALUE) IN (<foreach item='item' collection='oldValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newValueIn != null'>AND UPPER(NEW_VALUE) IN (<foreach item='item' collection='newValueIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom1In != null'>AND UPPER(CUSTOM_1) IN (<foreach item='item' collection='custom1In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom2In != null'>AND UPPER(CUSTOM_2) IN (<foreach item='item' collection='custom2In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom3In != null'>AND UPPER(CUSTOM_3) IN (<foreach item='item' collection='custom3In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='custom4In != null'>AND UPPER(CUSTOM_4) IN (<foreach item='item' collection='custom4In' separator=',' >#{item}</foreach>)</if> "
+ "<if test='oldDataIn != null'>AND UPPER(OLD_DATA) IN (<foreach item='item' collection='oldDataIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='newDataIn != null'>AND UPPER(NEW_DATA) IN (<foreach item='item' collection='newDataIn' separator=',' >#{item}</foreach>)</if> "
// LIKE-Queries
+ "<if test='businessProcessIdLike != null'>AND (<foreach item='item' collection='businessProcessIdLike' separator='OR' > UPPER(BUSINESS_PROCESS_ID) LIKE #{item} </foreach>)</if> "
+ "<if test='parentBusinessProcessIdLike != null'>AND (<foreach item='item' collection='parentBusinessProcessIdLike' separator=' OR ' >UPPER(PARENT_BUSINESS_PROCESS_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='taskIdLike != null'>AND (<foreach item='item' collection='taskIdLike' separator=' OR ' >UPPER(TASK_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='eventTypeLike != null'>AND (<foreach item='item' collection='eventTypeLike' separator=' OR ' >UPPER(EVENT_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='userIdLike != null'>AND (<foreach item='item' collection='userIdLike' separator=' OR ' >UPPER(USER_ID) LIKE #{item}</foreach>)</if> "
+ "<if test='domainLike != null'>AND (<foreach item='item' collection='domainLike' separator=' OR ' >UPPER(DOMAIN) LIKE #{item}</foreach>)</if> "
+ "<if test='workbasketKeyLike != null'>AND (<foreach item='item' collection='workbasketKeyLike' separator=' OR ' >UPPER(WORKBASKET_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='porCompanyLike != null'>AND (<foreach item='item' collection='porCompanyLike' separator=' OR ' >UPPER(POR_COMPANY) LIKE #{item}</foreach>)</if> "
+ "<if test='porSystemLike != null'>AND (<foreach item='item' collection='porSystemLike' separator=' OR ' >UPPER(POR_SYSTEM) LIKE #{item}</foreach>)</if> "
+ "<if test='porInstanceLike != null'>AND (<foreach item='item' collection='porInstanceLike' separator=' OR ' >UPPER(POR_INSTANCE) LIKE #{item}</foreach>)</if> "
+ "<if test='porTypeLike != null'>AND (<foreach item='item' collection='porTypeLike' separator=' OR ' >UPPER(POR_TYPE) LIKE #{item}</foreach>)</if> "
+ "<if test='porValueLike != null'>AND (<foreach item='item' collection='porValueLike' separator=' OR ' >UPPER(POR_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationKeyLike != null'>AND (<foreach item='item' collection='taskClassificationKeyLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='taskClassificationCategoryLike != null'>AND (<foreach item='item' collection='taskClassificationCategoryLike' separator=' OR ' >UPPER(TASK_CLASSIFICATION_CATEGORY) LIKE #{item}</foreach>)</if> "
+ "<if test='attachmentClassificationKeyLike != null'>AND (<foreach item='item' collection='attachmentClassificationKeyLike' separator=' OR ' >UPPER(ATTACHMENT_CLASSIFICATION_KEY) LIKE #{item}</foreach>)</if> "
+ "<if test='commentLike != null'>AND (<foreach item='item' collection='commentLike' separator=' OR ' >UPPER(COMMENT) LIKE #{item}</foreach>)</if> "
+ "<if test='oldValueLike != null'>AND (<foreach item='item' collection='oldValueLike' separator=' OR ' >UPPER(OLD_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='newValueLike != null'>AND (<foreach item='item' collection='newValueLike' separator=' OR ' >UPPER(NEW_VALUE) LIKE #{item}</foreach>)</if> "
+ "<if test='custom1Like != null'>AND (<foreach item='item' collection='custom1Like' separator=' OR ' >UPPER(CUSTOM_1) LIKE #{item}</foreach>)</if> "
+ "<if test='custom2Like != null'>AND (<foreach item='item' collection='custom2Like' separator=' OR ' >UPPER(CUSTOM_2) LIKE #{item}</foreach>)</if> "
+ "<if test='custom3Like != null'>AND (<foreach item='item' collection='custom3Like' separator=' OR ' >UPPER(CUSTOM_3) LIKE #{item}</foreach>)</if> "
+ "<if test='custom4Like != null'>AND (<foreach item='item' collection='custom4Like' separator=' OR ' >UPPER(CUSTOM_4) LIKE #{item}</foreach>)</if> "
+ "<if test='oldDataLike != null'>AND (<foreach item='item' collection='oldDataLike' separator=' OR ' >UPPER(OLD_DATA) LIKE #{item}</foreach>)</if> "
+ "<if test='newDataLike != null'>AND (<foreach item='item' collection='newDataLike' separator=' OR ' >UPPER(NEW_DATA) LIKE #{item}</foreach>)</if> "
+ "</where>"
+ "<if test='!orderBy.isEmpty()'>ORDER BY <foreach item='item' collection='orderBy' separator=',' >${item}</foreach></if> "
+ "</script>")
List<String> queryHistoryColumnValues(HistoryQueryImpl historyQuery);
}

View File

@ -3,46 +3,48 @@ package pro.taskana.simplehistory.query;
import pro.taskana.QueryColumnName;
/**
* Enum containing the column names for @see pro.taskana.simplehistory.mappings.HistoryQueryMapper#queryHistoryColumnValues(pro.taskana.simplehistory.impl.HistoryQueryImpl).
* Enum containing the column names for @see
* pro.taskana.simplehistory.mappings.HistoryQueryMapper#queryHistoryColumnValues(pro.taskana.simplehistory.impl.HistoryQueryImpl).
*
* @author bv
*/
public enum HistoryQueryColumnName implements QueryColumnName {
ID("id"),
BUSINESS_PROCESS_ID("business_process_id"),
PARENT_BUSINESS_PROCESS_ID("parent_business_process_id"),
TASK_ID("task_id"),
EVENT_TYPE("event_type"),
CREATED("created"),
USER_ID("user_id"),
DOMAIN("domain"),
WORKBASKET_KEY("workbasket_key"),
POR_COMPANY("por_company"),
POR_SYSTEM("por_system"),
POR_INSTANCE("por_instance"),
POR_TYPE("por_type"),
POR_VALUE("por_value"),
TASK_CLASSIFICATION_KEY("task_classification_key"),
TASK_CLASSIFICATION_CATEGORY("task_classification_category"),
ATTACHMENT_CLASSIFICATION_KEY("attachment_classification_key"),
COMMENT("comment"),
OLD_VALUE("old_value"),
NEW_VALUE("new_value"),
CUSTOM_1("custom_1"),
CUSTOM_2("custom_2"),
CUSTOM_3("custom_3"),
CUSTOM_4("custom_4"),
OLD_DATA("old_data"),
NEW_DATA("new_data"),
TYPE("type");
ID("id"),
BUSINESS_PROCESS_ID("business_process_id"),
PARENT_BUSINESS_PROCESS_ID("parent_business_process_id"),
TASK_ID("task_id"),
EVENT_TYPE("event_type"),
CREATED("created"),
USER_ID("user_id"),
DOMAIN("domain"),
WORKBASKET_KEY("workbasket_key"),
POR_COMPANY("por_company"),
POR_SYSTEM("por_system"),
POR_INSTANCE("por_instance"),
POR_TYPE("por_type"),
POR_VALUE("por_value"),
TASK_CLASSIFICATION_KEY("task_classification_key"),
TASK_CLASSIFICATION_CATEGORY("task_classification_category"),
ATTACHMENT_CLASSIFICATION_KEY("attachment_classification_key"),
COMMENT("comment"),
OLD_VALUE("old_value"),
NEW_VALUE("new_value"),
CUSTOM_1("custom_1"),
CUSTOM_2("custom_2"),
CUSTOM_3("custom_3"),
CUSTOM_4("custom_4"),
OLD_DATA("old_data"),
NEW_DATA("new_data"),
TYPE("type");
private String name;
HistoryQueryColumnName(String name) {
this.name = name;
}
private String name;
@Override
public String toString() {
return name;
}
HistoryQueryColumnName(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
}

View File

@ -1,5 +1,6 @@
package acceptance;
import configuration.DBWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@ -7,234 +8,239 @@ import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import configuration.DBWriter;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
/**
* Set up database for tests.
*/
/** Set up database for tests. */
public class AbstractAccTest {
public static SimpleHistoryServiceImpl historyService;
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAccTest.class);
private static final int POOL_TIME_TO_WAIT = 50;
public static SimpleHistoryServiceImpl historyService;
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
private static DataSource dataSource = null;
private static String schemaName = null;
protected static TaskanaEngineConfiguration taskanaEngineConfiguration;
protected AbstractAccTest() {
// not called
}
private static DataSource dataSource = null;
@BeforeClass
public static void setupTest() throws Exception {
resetDb(null);
}
private static String schemaName = null;
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractAccTest.class);
private static final int POOL_TIME_TO_WAIT = 50;
protected AbstractAccTest() {
// not called
}
@BeforeClass
public static void setupTest() throws Exception {
resetDb(null);
}
public static void resetDb(String schemaName) throws SQLException {
DataSource dataSource = getDataSource();
DBWriter writer = new DBWriter();
taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, false,
public static void resetDb(String schemaName) throws SQLException {
DataSource dataSource = getDataSource();
DBWriter writer = new DBWriter();
taskanaEngineConfiguration =
new TaskanaEngineConfiguration(
dataSource,
false,
schemaName != null && !schemaName.isEmpty() ? schemaName : getSchemaName());
historyService = new SimpleHistoryServiceImpl();
historyService.initialize(taskanaEngineConfiguration);
historyService = new SimpleHistoryServiceImpl();
historyService.initialize(taskanaEngineConfiguration);
writer.clearDB(dataSource);
writer.generateTestData(dataSource);
writer.clearDB(dataSource);
writer.generateTestData(dataSource);
}
/**
* returns the DataSource used for Junit test. If the file {user.home}/taskanaUnitTest.properties
* is present, the Datasource is created according to the properties jdbcDriver, jdbcUrl,
* dbUserName and dbPassword. Assuming, the database has the name tskdb, a sample properties file
* for DB2 looks as follows: jdbcDriver=com.ibm.db2.jcc.DB2Driver
* jdbcUrl=jdbc:db2://localhost:50000/tskdb dbUserName=db2user dbPassword=db2password If any of
* these properties is missing, or the file doesn't exist, the default Datasource for h2 in-memory
* db is created.
*
* @return dataSource for unit test
*/
public static DataSource getDataSource() {
if (dataSource == null) {
String userHomeDirectroy = System.getProperty("user.home");
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
File f = new File(propertiesFileName);
if (f.exists() && !f.isDirectory()) {
dataSource = createDataSourceFromProperties(propertiesFileName);
} else {
dataSource = createDefaultDataSource();
}
}
return dataSource;
}
/**
* returns the SchemaName used for Junit test. If the file {user.home}/taskanaUnitTest.properties
* is present, the SchemaName is created according to the property schemaName. a sample properties
* file for DB2 looks as follows: jdbcDriver=com.ibm.db2.jcc.DB2Driver
* jdbcUrl=jdbc:db2://localhost:50000/tskdb dbUserName=db2user dbPassword=db2password
* schemaName=TASKANA If any of these properties is missing, or the file doesn't exist, the
* default schemaName TASKANA is created used.
*
* @return String for unit test
*/
public static String getSchemaName() {
if (schemaName == null) {
String userHomeDirectroy = System.getProperty("user.home");
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
File f = new File(propertiesFileName);
if (f.exists() && !f.isDirectory()) {
schemaName = getSchemaNameFromPropertiesObject(propertiesFileName);
} else {
schemaName = "TASKANA";
}
}
return schemaName;
}
/**
* create historyEvent object.
*
* @param workbasketKey the workbasketKey, the task currently resides in.
* @param taskId the taskid the event belongs to.
* @param type the type of the event.
* @param comment the individual comment.
* @param previousWorkbasketId the workbasketId of the previous workbasket (if applicable).
* @return History event object created.
*/
public static HistoryEventImpl createHistoryEvent(
String workbasketKey,
String taskId,
String type,
String comment,
String previousWorkbasketId) {
HistoryEventImpl historyEvent = new HistoryEventImpl();
historyEvent.setWorkbasketKey(workbasketKey);
historyEvent.setTaskId(taskId);
historyEvent.setEventType(type);
historyEvent.setComment(comment);
historyEvent.setOldValue(previousWorkbasketId);
return historyEvent;
}
/**
* create Default DataSource for in-memory database.
*
* @return the TASKANA default datasource.
*/
private static DataSource createDefaultDataSource() {
String jdbcDriver = "org.h2.Driver";
String jdbcUrl = "jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0";
String dbUserName = "sa";
String dbPassword = "sa";
DataSource ds =
new PooledDataSource(
Thread.currentThread().getContextClassLoader(),
jdbcDriver,
jdbcUrl,
dbUserName,
dbPassword);
((PooledDataSource) ds).setPoolTimeToWait(POOL_TIME_TO_WAIT);
((PooledDataSource) ds)
.forceCloseAll(); // otherwise the MyBatis pool is not initialized correctly
return ds;
}
/**
* create data source from properties file.
*
* @param propertiesFileName the name of the properties file.
* @return the datasource constructed from the information in the properties file.
*/
private static DataSource createDataSourceFromProperties(String propertiesFileName) {
DataSource ds = null;
try (InputStream input = new FileInputStream(propertiesFileName)) {
Properties prop = new Properties();
prop.load(input);
boolean propertiesFileIsComplete = true;
String warningMessage = "";
String jdbcDriver = prop.getProperty("jdbcDriver");
if (jdbcDriver == null || jdbcDriver.length() == 0) {
propertiesFileIsComplete = false;
warningMessage += ", jdbcDriver property missing";
}
String jdbcUrl = prop.getProperty("jdbcUrl");
if (jdbcUrl == null || jdbcUrl.length() == 0) {
propertiesFileIsComplete = false;
warningMessage += ", jdbcUrl property missing";
}
String dbUserName = prop.getProperty("dbUserName");
if (dbUserName == null || dbUserName.length() == 0) {
propertiesFileIsComplete = false;
warningMessage += ", dbUserName property missing";
}
String dbPassword = prop.getProperty("dbPassword");
if (dbPassword == null || dbPassword.length() == 0) {
propertiesFileIsComplete = false;
warningMessage += ", dbPassword property missing";
}
if (propertiesFileIsComplete) {
ds =
new PooledDataSource(
Thread.currentThread().getContextClassLoader(),
jdbcDriver,
jdbcUrl,
dbUserName,
dbPassword);
((PooledDataSource) ds)
.forceCloseAll(); // otherwise the MyBatis pool is not initialized correctly
} else {
LOGGER.warn("propertiesFile " + propertiesFileName + " is incomplete" + warningMessage);
LOGGER.warn("Using default Datasource for Test");
ds = createDefaultDataSource();
}
} catch (FileNotFoundException e) {
LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
LOGGER.warn("Using default Datasource for Test");
ds = createDefaultDataSource();
} catch (IOException e) {
LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
LOGGER.warn("Using default Datasource for Test");
ds = createDefaultDataSource();
}
/**
* returns the DataSource used for Junit test. If the file {user.home}/taskanaUnitTest.properties is present, the
* Datasource is created according to the properties jdbcDriver, jdbcUrl, dbUserName and dbPassword. Assuming, the
* database has the name tskdb, a sample properties file for DB2 looks as follows:
* jdbcDriver=com.ibm.db2.jcc.DB2Driver jdbcUrl=jdbc:db2://localhost:50000/tskdb dbUserName=db2user
* dbPassword=db2password If any of these properties is missing, or the file doesn't exist, the default Datasource
* for h2 in-memory db is created.
*
* @return dataSource for unit test
*/
public static DataSource getDataSource() {
if (dataSource == null) {
String userHomeDirectroy = System.getProperty("user.home");
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
File f = new File(propertiesFileName);
if (f.exists() && !f.isDirectory()) {
dataSource = createDataSourceFromProperties(propertiesFileName);
} else {
dataSource = createDefaultDataSource();
}
}
return dataSource;
return ds;
}
private static String getSchemaNameFromPropertiesObject(String propertiesFileName) {
String schemaName = "TASKANA";
try (InputStream input = new FileInputStream(propertiesFileName)) {
Properties prop = new Properties();
prop.load(input);
boolean propertiesFileIsComplete = true;
String warningMessage = "";
schemaName = prop.getProperty("schemaName");
if (schemaName == null || schemaName.length() == 0) {
propertiesFileIsComplete = false;
warningMessage += ", schemaName property missing";
}
if (!propertiesFileIsComplete) {
LOGGER.warn("propertiesFile " + propertiesFileName + " is incomplete" + warningMessage);
LOGGER.warn("Using default Datasource for Test");
schemaName = "TASKANA";
}
} catch (FileNotFoundException e) {
LOGGER.warn("getSchemaNameFromPropertiesObject caught Exception " + e);
LOGGER.warn("Using default schemaName for Test");
} catch (IOException e) {
LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
LOGGER.warn("Using default Datasource for Test");
}
/**
* create Default DataSource for in-memory database.
*
* @return the TASKANA default datasource.
*/
private static DataSource createDefaultDataSource() {
String jdbcDriver = "org.h2.Driver";
String jdbcUrl = "jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0";
String dbUserName = "sa";
String dbPassword = "sa";
DataSource ds = new PooledDataSource(Thread.currentThread().getContextClassLoader(), jdbcDriver,
jdbcUrl, dbUserName, dbPassword);
((PooledDataSource) ds).setPoolTimeToWait(POOL_TIME_TO_WAIT);
((PooledDataSource) ds).forceCloseAll(); // otherwise the MyBatis pool is not initialized correctly
return ds;
}
/**
* returns the SchemaName used for Junit test. If the file {user.home}/taskanaUnitTest.properties is present, the
* SchemaName is created according to the property schemaName. a sample properties file for DB2 looks as follows:
* jdbcDriver=com.ibm.db2.jcc.DB2Driver jdbcUrl=jdbc:db2://localhost:50000/tskdb dbUserName=db2user
* dbPassword=db2password schemaName=TASKANA If any of these properties is missing, or the file doesn't exist, the
* default schemaName TASKANA is created used.
*
* @return String for unit test
*/
public static String getSchemaName() {
if (schemaName == null) {
String userHomeDirectroy = System.getProperty("user.home");
String propertiesFileName = userHomeDirectroy + "/taskanaUnitTest.properties";
File f = new File(propertiesFileName);
if (f.exists() && !f.isDirectory()) {
schemaName = getSchemaNameFromPropertiesObject(propertiesFileName);
} else {
schemaName = "TASKANA";
}
}
return schemaName;
}
/**
* create historyEvent object.
*
* @param workbasketKey
* the workbasketKey, the task currently resides in.
* @param taskId
* the taskid the event belongs to.
* @param type
* the type of the event.
* @param comment
* the individual comment.
* @param previousWorkbasketId
* the workbasketId of the previous workbasket (if applicable).
* @return History event object created.
*/
public static HistoryEventImpl createHistoryEvent(String workbasketKey, String taskId, String type, String comment,
String previousWorkbasketId) {
HistoryEventImpl historyEvent = new HistoryEventImpl();
historyEvent.setWorkbasketKey(workbasketKey);
historyEvent.setTaskId(taskId);
historyEvent.setEventType(type);
historyEvent.setComment(comment);
historyEvent.setOldValue(previousWorkbasketId);
return historyEvent;
}
/**
* create data source from properties file.
*
* @param propertiesFileName
* the name of the properties file.
* @return the datasource constructed from the information in the properties file.
*/
private static DataSource createDataSourceFromProperties(String propertiesFileName) {
DataSource ds = null;
try (InputStream input = new FileInputStream(propertiesFileName)) {
Properties prop = new Properties();
prop.load(input);
boolean propertiesFileIsComplete = true;
String warningMessage = "";
String jdbcDriver = prop.getProperty("jdbcDriver");
if (jdbcDriver == null || jdbcDriver.length() == 0) {
propertiesFileIsComplete = false;
warningMessage += ", jdbcDriver property missing";
}
String jdbcUrl = prop.getProperty("jdbcUrl");
if (jdbcUrl == null || jdbcUrl.length() == 0) {
propertiesFileIsComplete = false;
warningMessage += ", jdbcUrl property missing";
}
String dbUserName = prop.getProperty("dbUserName");
if (dbUserName == null || dbUserName.length() == 0) {
propertiesFileIsComplete = false;
warningMessage += ", dbUserName property missing";
}
String dbPassword = prop.getProperty("dbPassword");
if (dbPassword == null || dbPassword.length() == 0) {
propertiesFileIsComplete = false;
warningMessage += ", dbPassword property missing";
}
if (propertiesFileIsComplete) {
ds = new PooledDataSource(Thread.currentThread().getContextClassLoader(), jdbcDriver,
jdbcUrl, dbUserName, dbPassword);
((PooledDataSource) ds).forceCloseAll(); // otherwise the MyBatis pool is not initialized correctly
} else {
LOGGER.warn("propertiesFile " + propertiesFileName + " is incomplete" + warningMessage);
LOGGER.warn("Using default Datasource for Test");
ds = createDefaultDataSource();
}
} catch (FileNotFoundException e) {
LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
LOGGER.warn("Using default Datasource for Test");
ds = createDefaultDataSource();
} catch (IOException e) {
LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
LOGGER.warn("Using default Datasource for Test");
ds = createDefaultDataSource();
}
return ds;
}
private static String getSchemaNameFromPropertiesObject(String propertiesFileName) {
String schemaName = "TASKANA";
try (InputStream input = new FileInputStream(propertiesFileName)) {
Properties prop = new Properties();
prop.load(input);
boolean propertiesFileIsComplete = true;
String warningMessage = "";
schemaName = prop.getProperty("schemaName");
if (schemaName == null || schemaName.length() == 0) {
propertiesFileIsComplete = false;
warningMessage += ", schemaName property missing";
}
if (!propertiesFileIsComplete) {
LOGGER.warn("propertiesFile " + propertiesFileName + " is incomplete" + warningMessage);
LOGGER.warn("Using default Datasource for Test");
schemaName = "TASKANA";
}
} catch (FileNotFoundException e) {
LOGGER.warn("getSchemaNameFromPropertiesObject caught Exception " + e);
LOGGER.warn("Using default schemaName for Test");
} catch (IOException e) {
LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
LOGGER.warn("Using default Datasource for Test");
}
return schemaName;
}
return schemaName;
}
}

View File

@ -5,308 +5,345 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import acceptance.AbstractAccTest;
import java.time.Instant;
import java.util.List;
import org.junit.Test;
import acceptance.AbstractAccTest;
import pro.taskana.BaseQuery.SortDirection;
import pro.taskana.TimeInterval;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.query.HistoryQuery;
import pro.taskana.simplehistory.query.HistoryQueryColumnName;
/**
* Test for History queries.
*/
/** Test for History queries. */
public class QueryHistoryAccTest extends AbstractAccTest {
public QueryHistoryAccTest() {
super();
}
public QueryHistoryAccTest() {
super();
}
@Test
public void testListValuesAscendingAndDescending() {
List<String> defaultList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.COMMENT, null);
List<String> ascendingList = historyService.createHistoryQuery()
@Test
public void testListValuesAscendingAndDescending() {
List<String> defaultList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.COMMENT, null);
List<String> ascendingList =
historyService
.createHistoryQuery()
.listValues(HistoryQueryColumnName.COMMENT, SortDirection.ASCENDING);
List<String> descendingList = historyService.createHistoryQuery()
List<String> descendingList =
historyService
.createHistoryQuery()
.listValues(HistoryQueryColumnName.COMMENT, SortDirection.DESCENDING);
assertEquals(3, ascendingList.size());
assertArrayEquals(defaultList.toArray(), ascendingList.toArray());
assertEquals(ascendingList.get(2), descendingList.get(0));
}
assertEquals(3, ascendingList.size());
assertArrayEquals(defaultList.toArray(), ascendingList.toArray());
assertEquals(ascendingList.get(2), descendingList.get(0));
}
@Test
public void testComplexQuery() {
HistoryQuery query = historyService.createHistoryQuery()
@Test
public void testComplexQuery() {
HistoryQuery query =
historyService
.createHistoryQuery()
.businessProcessIdLike("just some string", "BPI:%")
.domainLike("%A")
.orderByCreated(SortDirection.DESCENDING);
List<HistoryEventImpl> results = query.list();
assertEquals(2, results.size());
assertEquals("admin", results.get(0).getUserId());
assertEquals("peter", results.get(1).getUserId());
List<HistoryEventImpl> results = query.list();
assertEquals(2, results.size());
assertEquals("admin", results.get(0).getUserId());
assertEquals("peter", results.get(1).getUserId());
results = query.orderByUserId(SortDirection.DESCENDING).list();
assertEquals(2, results.size());
assertEquals("admin", results.get(0).getUserId());
assertEquals("peter", results.get(1).getUserId());
assertEquals(3, query.domainLike().count());
results = query.orderByUserId(SortDirection.DESCENDING).list();
assertEquals(2, results.size());
assertEquals("admin", results.get(0).getUserId());
assertEquals("peter", results.get(1).getUserId());
assertEquals(3, query.domainLike().count());
}
}
@Test
public void testQueryListOffset() {
List<HistoryEventImpl> result = historyService.createHistoryQuery().list(1, 2);
List<HistoryEventImpl> wrongList = historyService.createHistoryQuery().list();
@Test
public void testQueryListOffset() {
List<HistoryEventImpl> result = historyService.createHistoryQuery().list(1, 2);
List<HistoryEventImpl> wrongList = historyService.createHistoryQuery().list();
assertEquals(2, result.size());
assertEquals(2, result.size());
assertNotEquals(wrongList.get(0).getUserId(), result.get(0).getUserId());
assertEquals(wrongList.get(1).getUserId(), result.get(0).getUserId());
}
assertNotEquals(wrongList.get(0).getUserId(), result.get(0).getUserId());
assertEquals(wrongList.get(1).getUserId(), result.get(0).getUserId());
}
@Test
public void testCorrectResultWithWrongConstraints() {
List<HistoryEventImpl> result = historyService.createHistoryQuery().list(1, 1000);
assertEquals(2, result.size());
assertEquals("created by Peter", result.get(0).getComment());
@Test
public void testCorrectResultWithWrongConstraints() {
List<HistoryEventImpl> result = historyService.createHistoryQuery().list(1, 1000);
assertEquals(2, result.size());
assertEquals("created by Peter", result.get(0).getComment());
result = historyService.createHistoryQuery().list(100, 1000);
assertTrue(result.isEmpty());
}
result = historyService.createHistoryQuery().list(100, 1000);
assertTrue(result.isEmpty());
@Test
public void testSingle() {
HistoryEventImpl single = historyService.createHistoryQuery().userIdIn("peter").single();
assertEquals("CREATE", single.getEventType());
}
single = historyService.createHistoryQuery().eventTypeIn("CREATE", "xy").single();
assertEquals("admin", single.getUserId());
}
@Test
public void testSingle() {
HistoryEventImpl single = historyService.createHistoryQuery().userIdIn("peter").single();
assertEquals("CREATE", single.getEventType());
@Test
public void testCount() {
long count = historyService.createHistoryQuery().userIdIn("peter").count();
assertEquals(1, count);
single = historyService.createHistoryQuery().eventTypeIn("CREATE", "xy").single();
assertEquals("admin", single.getUserId());
}
count = historyService.createHistoryQuery().count();
assertEquals(3, count);
@Test
public void testCount() {
long count = historyService.createHistoryQuery().userIdIn("peter").count();
assertEquals(1, count);
count = historyService.createHistoryQuery().userIdIn("klaus", "arnold", "benni").count();
assertEquals(0, count);
}
count = historyService.createHistoryQuery().count();
assertEquals(3, count);
@Test
public void testQueryAttributesIn() {
List<HistoryEventImpl> returnValues =
historyService.createHistoryQuery().businessProcessIdIn("BPI:01", "BPI:02").list();
assertEquals(2, returnValues.size());
count = historyService.createHistoryQuery().userIdIn("klaus", "arnold", "benni").count();
assertEquals(0, count);
}
returnValues = historyService.createHistoryQuery().parentBusinessProcessIdIn("BPI:01").list();
assertEquals(1, returnValues.size());
@Test
public void testQueryAttributesIn() {
List<HistoryEventImpl> returnValues = historyService.createHistoryQuery()
.businessProcessIdIn("BPI:01", "BPI:02")
returnValues =
historyService
.createHistoryQuery()
.taskIdIn("TKI:000000000000000000000000000000000000")
.list();
assertEquals(2, returnValues.size());
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().parentBusinessProcessIdIn("BPI:01").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().eventTypeIn("CREATE").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().taskIdIn("TKI:000000000000000000000000000000000000").list();
assertEquals(2, returnValues.size());
TimeInterval timeInterval = new TimeInterval(Instant.now().minusSeconds(10), Instant.now());
returnValues = historyService.createHistoryQuery().createdWithin(timeInterval).list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().eventTypeIn("CREATE").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().userIdIn("admin").list();
assertEquals(2, returnValues.size());
TimeInterval timeInterval = new TimeInterval(Instant.now().minusSeconds(10), Instant.now());
returnValues = historyService.createHistoryQuery().createdWithin(timeInterval).list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().domainIn("DOMAIN_A").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().userIdIn("admin").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().domainIn("DOMAIN_A").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery()
returnValues =
historyService
.createHistoryQuery()
.workbasketKeyIn("WBI:100000000000000000000000000000000001")
.list();
assertEquals(2, returnValues.size());
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().porCompanyIn("00").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().porCompanyIn("00").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().porSystemIn("PASystem").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().porSystemIn("PASystem").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().porInstanceIn("22").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().porInstanceIn("22").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().porTypeIn("VN").list();
assertEquals(0, returnValues.size());
returnValues = historyService.createHistoryQuery().porTypeIn("VN").list();
assertEquals(0, returnValues.size());
returnValues = historyService.createHistoryQuery().porValueIn("11223344").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().porValueIn("11223344").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().taskClassificationKeyIn("L140101").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().taskClassificationKeyIn("L140101").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().taskClassificationCategoryIn("TASK").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().taskClassificationCategoryIn("TASK").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().attachmentClassificationKeyIn("DOCTYPE_DEFAULT").list();
assertEquals(1, returnValues.size());
returnValues =
historyService.createHistoryQuery().attachmentClassificationKeyIn("DOCTYPE_DEFAULT").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().custom1In("custom1").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().custom1In("custom1").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().custom2In("custom2").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().custom2In("custom2").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().custom3In("custom3").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().custom3In("custom3").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().custom4In("custom4").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().custom4In("custom4").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().commentIn("created a bug").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().commentIn("created a bug").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().oldValueIn("old_val").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().oldValueIn("old_val").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().newValueIn("new_val").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().newValueIn("new_val").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().oldDataIn("123").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().oldDataIn("123").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().newDataIn("456").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().oldValueLike("old%").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().newDataIn("456").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().oldValueLike("old%").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().newValueLike("new_%").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().newValueLike("new_%").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().oldDataLike("%23%").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().oldDataLike("%23%").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().newDataLike("456%").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().newDataLike("456%").list();
assertEquals(3, returnValues.size());
}
}
@Test
public void testSomeLikeMethods() {
List<HistoryEventImpl> returnValues =
historyService.createHistoryQuery().businessProcessIdLike("BPI:0%").list();
assertEquals(3, returnValues.size());
@Test
public void testSomeLikeMethods() {
List<HistoryEventImpl> returnValues = historyService.createHistoryQuery()
.businessProcessIdLike("BPI:0%")
.list();
assertEquals(3, returnValues.size());
returnValues =
historyService.createHistoryQuery().parentBusinessProcessIdLike("BPI:01", " %").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().parentBusinessProcessIdLike("BPI:01", " %").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().taskIdLike("TKI:000000000000000%").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().taskIdLike("TKI:000000000000000%").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().oldValueLike("old%").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().oldValueLike("old%").list();
assertEquals(1, returnValues.size());
returnValues = historyService.createHistoryQuery().newValueLike("new_%").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().newValueLike("new_%").list();
assertEquals(2, returnValues.size());
returnValues = historyService.createHistoryQuery().oldDataLike("%23%").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().oldDataLike("%23%").list();
assertEquals(3, returnValues.size());
returnValues = historyService.createHistoryQuery().newDataLike("456%").list();
assertEquals(3, returnValues.size());
}
returnValues = historyService.createHistoryQuery().newDataLike("456%").list();
assertEquals(3, returnValues.size());
@Test
public void testListValues() {
List<String> returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.ID, null);
assertEquals(3, returnedList.size());
}
returnedList =
historyService
.createHistoryQuery()
.listValues(HistoryQueryColumnName.BUSINESS_PROCESS_ID, null);
assertEquals(3, returnedList.size());
@Test
public void testListValues() {
List<String> returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.ID, null);
assertEquals(3, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.BUSINESS_PROCESS_ID, null);
assertEquals(3, returnedList.size());
returnedList = historyService.createHistoryQuery()
returnedList =
historyService
.createHistoryQuery()
.listValues(HistoryQueryColumnName.PARENT_BUSINESS_PROCESS_ID, null);
assertEquals(2, returnedList.size());
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.TASK_ID, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.TASK_ID, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.EVENT_TYPE, null);
assertEquals(1, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.EVENT_TYPE, null);
assertEquals(1, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.CREATED, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.CREATED, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.USER_ID, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.USER_ID, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.DOMAIN, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.DOMAIN, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.WORKBASKET_KEY, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.WORKBASKET_KEY, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.POR_COMPANY, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.POR_COMPANY, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.POR_SYSTEM, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.POR_SYSTEM, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.POR_INSTANCE, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.POR_INSTANCE, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.POR_TYPE, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.POR_TYPE, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.POR_VALUE, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.POR_VALUE, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery()
returnedList =
historyService
.createHistoryQuery()
.listValues(HistoryQueryColumnName.TASK_CLASSIFICATION_KEY, null);
assertEquals(2, returnedList.size());
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery()
returnedList =
historyService
.createHistoryQuery()
.listValues(HistoryQueryColumnName.TASK_CLASSIFICATION_CATEGORY, null);
assertEquals(2, returnedList.size());
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery()
returnedList =
historyService
.createHistoryQuery()
.listValues(HistoryQueryColumnName.ATTACHMENT_CLASSIFICATION_KEY, null);
assertEquals(2, returnedList.size());
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.COMMENT, null);
assertEquals(3, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.COMMENT, null);
assertEquals(3, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.OLD_VALUE, null);
assertEquals(3, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.OLD_VALUE, null);
assertEquals(3, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.NEW_VALUE, null);
assertEquals(3, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.NEW_VALUE, null);
assertEquals(3, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_1, null);
assertEquals(1, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_1, null);
assertEquals(1, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_2, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_2, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_3, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_3, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_4, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.CUSTOM_4, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.OLD_DATA, null);
assertEquals(2, returnedList.size());
returnedList = historyService.createHistoryQuery().listValues(HistoryQueryColumnName.NEW_DATA, null);
assertEquals(1, returnedList.size());
}
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.OLD_DATA, null);
assertEquals(2, returnedList.size());
returnedList =
historyService.createHistoryQuery().listValues(HistoryQueryColumnName.NEW_DATA, null);
assertEquals(1, returnedList.size());
}
}

View File

@ -6,75 +6,69 @@ import java.io.StringReader;
import java.io.StringWriter;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Set up the database's writer and generates data for tests.
*/
/** Set up the database's writer and generates data for tests. */
public class DBWriter {
private static final Logger LOGGER = LoggerFactory.getLogger(DBWriter.class);
private static final String INSERTVALUES = "/sql/history-events.sql";
private StringWriter outWriter = new StringWriter();
private PrintWriter logWriter;
private StringWriter errorWriter;
private PrintWriter errorLogWriter;
private static final Logger LOGGER = LoggerFactory.getLogger(DBWriter.class);
private static final String INSERTVALUES = "/sql/history-events.sql";
private StringWriter outWriter = new StringWriter();
private PrintWriter logWriter;
private StringWriter errorWriter;
private PrintWriter errorLogWriter;
public DBWriter() {
this.logWriter = new PrintWriter(this.outWriter);
this.errorWriter = new StringWriter();
this.errorLogWriter = new PrintWriter(this.errorWriter);
}
public DBWriter() {
this.logWriter = new PrintWriter(this.outWriter);
this.errorWriter = new StringWriter();
this.errorLogWriter = new PrintWriter(this.errorWriter);
}
public void generateTestData(DataSource dataSource) throws SQLException {
ScriptRunner runner = null;
try {
runner = configScriptRunner(dataSource);
runner.runScript(
new InputStreamReader(
this.getClass().getResourceAsStream(INSERTVALUES)));
} finally {
if (runner != null) {
runner.closeConnection();
}
LOGGER.debug(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
}
public void generateTestData(DataSource dataSource) throws SQLException {
ScriptRunner runner = null;
try {
runner = configScriptRunner(dataSource);
runner.runScript(new InputStreamReader(this.getClass().getResourceAsStream(INSERTVALUES)));
} finally {
if (runner != null) {
runner.closeConnection();
}
LOGGER.debug(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
}
}
public void clearDB(DataSource dataSource) throws SQLException {
ScriptRunner runner = null;
try {
runner = configScriptRunner(dataSource);
runner.runScript(new StringReader("DELETE FROM HISTORY_EVENTS;"));
} finally {
if (runner != null) {
runner.closeConnection();
}
LOGGER.debug(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
}
public void clearDB(DataSource dataSource) throws SQLException {
ScriptRunner runner = null;
try {
runner = configScriptRunner(dataSource);
runner.runScript(new StringReader("DELETE FROM HISTORY_EVENTS;"));
} finally {
if (runner != null) {
runner.closeConnection();
}
LOGGER.debug(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
}
}
private ScriptRunner configScriptRunner(DataSource dataSource) throws SQLException {
Connection connection = dataSource.getConnection();
LOGGER.debug(connection.getMetaData().toString());
ScriptRunner 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);
return runner;
}
private ScriptRunner configScriptRunner(DataSource dataSource) throws SQLException {
Connection connection = dataSource.getConnection();
LOGGER.debug(connection.getMetaData().toString());
ScriptRunner 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);
return runner;
}
}

View File

@ -2,14 +2,12 @@ package configuration;
import static org.junit.Assert.assertEquals;
import acceptance.AbstractAccTest;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.junit.Assert;
import org.junit.Test;
import acceptance.AbstractAccTest;
import pro.taskana.TaskanaEngine;
import pro.taskana.configuration.TaskanaEngineConfiguration;
@ -20,27 +18,25 @@ import pro.taskana.configuration.TaskanaEngineConfiguration;
*/
public class TaskanaEngineConfigurationTest extends AbstractAccTest {
@Test
public void testCreateTaskanaEngine() throws SQLException {
DataSource ds = getDataSource();
TaskanaEngineConfiguration taskEngineConfiguration = new TaskanaEngineConfiguration(ds, false,
getSchemaName());
@Test
public void testCreateTaskanaEngine() throws SQLException {
DataSource ds = getDataSource();
TaskanaEngineConfiguration taskEngineConfiguration =
new TaskanaEngineConfiguration(ds, false, getSchemaName());
TaskanaEngine te = taskEngineConfiguration.buildTaskanaEngine();
TaskanaEngine te = taskEngineConfiguration.buildTaskanaEngine();
Assert.assertNotNull(te);
}
@Test
public void testCreateTaskanaHistoryEventWithNonDefaultSchemaName() throws SQLException {
resetDb("SOMECUSTOMSCHEMANAME");
long count = historyService.createHistoryQuery().workbasketKeyIn("wbKey1").count();
assertEquals(0, count);
historyService.create(
AbstractAccTest.createHistoryEvent("wbKey1", "taskId1", "type1", "Some comment", "wbKey2"));
count = historyService.createHistoryQuery().workbasketKeyIn("wbKey1").count();
assertEquals(1, count);
}
Assert.assertNotNull(te);
}
@Test
public void testCreateTaskanaHistoryEventWithNonDefaultSchemaName() throws SQLException {
resetDb("SOMECUSTOMSCHEMANAME");
long count = historyService.createHistoryQuery().workbasketKeyIn("wbKey1").count();
assertEquals(0, count);
historyService.create(
AbstractAccTest.createHistoryEvent("wbKey1", "taskId1", "type1", "Some comment", "wbKey2"));
count = historyService.createHistoryQuery().workbasketKeyIn("wbKey1").count();
assertEquals(1, count);
}
}

View File

@ -9,7 +9,6 @@ import java.sql.SQLException;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -27,50 +26,55 @@ import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
@RunWith(MockitoJUnitRunner.class)
public class HistoryQueryImplTest {
private HistoryQueryImpl historyQueryImpl;
private HistoryQueryImpl historyQueryImpl;
@Mock
private TaskanaHistoryEngineImpl taskanaHistoryEngineMock;
@Mock private TaskanaHistoryEngineImpl taskanaHistoryEngineMock;
@Mock
private HistoryQueryMapper historyQueryMock;
@Mock private HistoryQueryMapper historyQueryMock;
@Before
public void setup() {
historyQueryImpl = new HistoryQueryImpl(taskanaHistoryEngineMock, historyQueryMock);
}
@Before
public void setup() {
historyQueryImpl = new HistoryQueryImpl(taskanaHistoryEngineMock, historyQueryMock);
}
@Test
public void testShouldReturnList() throws SQLException {
List<HistoryEventImpl> returnList = new ArrayList<>();
returnList.add(createHistoryEvent("abcd", "T22", "car", "BV", "this was important", null));
TimeInterval interval = new TimeInterval(Instant.now().minusNanos(1000), Instant.now());
@Test
public void testShouldReturnList() throws SQLException {
List<HistoryEventImpl> returnList = new ArrayList<>();
returnList.add(createHistoryEvent("abcd", "T22", "car", "BV", "this was important", null));
TimeInterval interval = new TimeInterval(Instant.now().minusNanos(1000), Instant.now());
doNothing().when(taskanaHistoryEngineMock).openConnection();
doNothing().when(taskanaHistoryEngineMock).returnConnection();
doReturn(returnList).when(historyQueryMock).queryHistoryEvent(historyQueryImpl);
doNothing().when(taskanaHistoryEngineMock).openConnection();
doNothing().when(taskanaHistoryEngineMock).returnConnection();
doReturn(returnList).when(historyQueryMock).queryHistoryEvent(historyQueryImpl);
List<HistoryEventImpl> result = historyQueryImpl
List<HistoryEventImpl> result =
historyQueryImpl
.taskIdIn("TKI:01")
.workbasketKeyIn("T22", "some_long_long, long loooooooooooooooooooooooooooooooooooong String.")
.workbasketKeyIn(
"T22", "some_long_long, long loooooooooooooooooooooooooooooooooooong String.")
.userIdIn("BV")
.commentLike("%as important")
.createdWithin(interval)
.list();
validateMockitoUsage();
assertArrayEquals(returnList.toArray(), result.toArray());
}
validateMockitoUsage();
assertArrayEquals(returnList.toArray(), result.toArray());
}
private HistoryEventImpl createHistoryEvent(String taskId, String workbasketKey, String type, String userId,
String comment, Instant created) {
HistoryEventImpl he = new HistoryEventImpl();
he.setTaskId(taskId);
he.setWorkbasketKey(workbasketKey);
he.setEventType(type);
he.setUserId(userId);
he.setComment(comment);
he.setCreated(created);
return he;
}
private HistoryEventImpl createHistoryEvent(
String taskId,
String workbasketKey,
String type,
String userId,
String comment,
Instant created) {
HistoryEventImpl he = new HistoryEventImpl();
he.setTaskId(taskId);
he.setWorkbasketKey(workbasketKey);
he.setEventType(type);
he.setUserId(userId);
he.setComment(comment);
he.setCreated(created);
return he;
}
}

View File

@ -8,10 +8,10 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import acceptance.AbstractAccTest;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.ibatis.session.SqlSessionManager;
import org.junit.Before;
import org.junit.Test;
@ -25,7 +25,6 @@ import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import acceptance.AbstractAccTest;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.simplehistory.impl.mappings.HistoryEventMapper;
import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
@ -40,83 +39,86 @@ import pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper;
@PowerMockIgnore("javax.management.*")
public class SimpleHistoryServiceImplTest {
@InjectMocks
private SimpleHistoryServiceImpl cutSpy;
@InjectMocks private SimpleHistoryServiceImpl cutSpy;
@Mock
private HistoryEventMapper historyEventMapperMock;
@Mock private HistoryEventMapper historyEventMapperMock;
@Mock
private HistoryQueryMapper historyQueryMapperMock;
@Mock private HistoryQueryMapper historyQueryMapperMock;
@Mock
private TaskanaHistoryEngineImpl taskanaHistoryEngineMock;
@Mock private TaskanaHistoryEngineImpl taskanaHistoryEngineMock;
@Mock
private TaskanaEngineConfiguration taskanaEngineConfiguration;
@Mock private TaskanaEngineConfiguration taskanaEngineConfiguration;
@Mock
private SqlSessionManager sqlSessionManagerMock;
@Mock private SqlSessionManager sqlSessionManagerMock;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
@Test
public void testInitializeSimpleHistoryService() throws SQLException {
doReturn(historyEventMapperMock).when(sqlSessionManagerMock).getMapper(HistoryEventMapper.class);
doReturn(historyQueryMapperMock).when(sqlSessionManagerMock).getMapper(HistoryQueryMapper.class);
doReturn(sqlSessionManagerMock).when(taskanaHistoryEngineMock).getSqlSession();
PowerMockito.mockStatic(TaskanaHistoryEngineImpl.class);
Mockito.when(TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngineConfiguration))
.thenReturn(taskanaHistoryEngineMock);
cutSpy.initialize(taskanaEngineConfiguration);
@Test
public void testInitializeSimpleHistoryService() throws SQLException {
doReturn(historyEventMapperMock)
.when(sqlSessionManagerMock)
.getMapper(HistoryEventMapper.class);
doReturn(historyQueryMapperMock)
.when(sqlSessionManagerMock)
.getMapper(HistoryQueryMapper.class);
doReturn(sqlSessionManagerMock).when(taskanaHistoryEngineMock).getSqlSession();
PowerMockito.mockStatic(TaskanaHistoryEngineImpl.class);
Mockito.when(TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngineConfiguration))
.thenReturn(taskanaHistoryEngineMock);
cutSpy.initialize(taskanaEngineConfiguration);
verify(sqlSessionManagerMock, times(2)).getMapper(any());
verify(taskanaHistoryEngineMock, times(2)).getSqlSession();
}
verify(sqlSessionManagerMock, times(2)).getMapper(any());
verify(taskanaHistoryEngineMock, times(2)).getSqlSession();
}
@Test
public void testInitializeSimpleHistoryServiceWithNonDefaultSchemaName() throws SQLException {
@Test
public void testInitializeSimpleHistoryServiceWithNonDefaultSchemaName() throws SQLException {
doReturn(historyEventMapperMock).when(sqlSessionManagerMock).getMapper(HistoryEventMapper.class);
doReturn(historyQueryMapperMock).when(sqlSessionManagerMock).getMapper(HistoryQueryMapper.class);
doReturn(sqlSessionManagerMock).when(taskanaHistoryEngineMock).getSqlSession();
PowerMockito.mockStatic(TaskanaHistoryEngineImpl.class);
Mockito.when(TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngineConfiguration))
.thenReturn(taskanaHistoryEngineMock);
cutSpy.initialize(taskanaEngineConfiguration);
doReturn(historyEventMapperMock)
.when(sqlSessionManagerMock)
.getMapper(HistoryEventMapper.class);
doReturn(historyQueryMapperMock)
.when(sqlSessionManagerMock)
.getMapper(HistoryQueryMapper.class);
doReturn(sqlSessionManagerMock).when(taskanaHistoryEngineMock).getSqlSession();
PowerMockito.mockStatic(TaskanaHistoryEngineImpl.class);
Mockito.when(TaskanaHistoryEngineImpl.createTaskanaEngine(taskanaEngineConfiguration))
.thenReturn(taskanaHistoryEngineMock);
cutSpy.initialize(taskanaEngineConfiguration);
verify(sqlSessionManagerMock, times(2)).getMapper(any());
verify(taskanaHistoryEngineMock, times(2)).getSqlSession();
}
verify(sqlSessionManagerMock, times(2)).getMapper(any());
verify(taskanaHistoryEngineMock, times(2)).getSqlSession();
}
@Test
public void testCreateEvent() throws SQLException {
HistoryEventImpl expectedWb = AbstractAccTest.createHistoryEvent("wbKey1", "taskId1", "type1", "Some comment",
"wbKey2");
doNothing().when(historyEventMapperMock).insert(expectedWb);
@Test
public void testCreateEvent() throws SQLException {
HistoryEventImpl expectedWb =
AbstractAccTest.createHistoryEvent("wbKey1", "taskId1", "type1", "Some comment", "wbKey2");
doNothing().when(historyEventMapperMock).insert(expectedWb);
cutSpy.create(expectedWb);
verify(taskanaHistoryEngineMock, times(1)).openConnection();
verify(historyEventMapperMock, times(1)).insert(expectedWb);
verify(taskanaHistoryEngineMock, times(1)).returnConnection();
assertNotNull(expectedWb.getCreated());
}
cutSpy.create(expectedWb);
verify(taskanaHistoryEngineMock, times(1)).openConnection();
verify(historyEventMapperMock, times(1)).insert(expectedWb);
verify(taskanaHistoryEngineMock, times(1)).returnConnection();
assertNotNull(expectedWb.getCreated());
}
@Test
public void testQueryEvent() throws SQLException {
List<HistoryEventImpl> returnList = new ArrayList<>();
returnList.add(AbstractAccTest.createHistoryEvent("wbKey1", "taskId1", "type1", "Some comment", "wbKey2"));
doReturn(returnList).when(historyQueryMapperMock).queryHistoryEvent(any());
@Test
public void testQueryEvent() throws SQLException {
List<HistoryEventImpl> returnList = new ArrayList<>();
returnList.add(
AbstractAccTest.createHistoryEvent("wbKey1", "taskId1", "type1", "Some comment", "wbKey2"));
doReturn(returnList).when(historyQueryMapperMock).queryHistoryEvent(any());
List<HistoryEventImpl> result = cutSpy.createHistoryQuery().taskIdIn("taskId1").list();
List<HistoryEventImpl> result = cutSpy.createHistoryQuery().taskIdIn("taskId1").list();
verify(taskanaHistoryEngineMock, times(1)).openConnection();
verify(historyQueryMapperMock, times(1)).queryHistoryEvent(any());
verify(taskanaHistoryEngineMock, times(1)).returnConnection();
assertEquals(returnList.size(), result.size());
assertEquals(returnList.get(0).getWorkbasketKey(), result.get(0).getWorkbasketKey());
}
verify(taskanaHistoryEngineMock, times(1)).openConnection();
verify(historyQueryMapperMock, times(1)).queryHistoryEvent(any());
verify(taskanaHistoryEngineMock, times(1)).returnConnection();
assertEquals(returnList.size(), result.size());
assertEquals(returnList.get(0).getWorkbasketKey(), result.get(0).getWorkbasketKey());
}
}

View File

@ -1,9 +1,7 @@
package rest.pro.taskana.rest.simplehistory;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@ -20,47 +18,47 @@ import org.springframework.transaction.PlatformTransactionManager;
import pro.taskana.rest.simplehistory.TaskHistoryRestConfiguration;
import pro.taskana.rest.simplehistory.sampledata.SampleDataGenerator;
/**
* Example Application showing the implementation of taskana-rest-spring.
*/
/** Example Application showing the implementation of taskana-rest-spring. */
@SpringBootApplication
@ComponentScan(basePackages = "pro.taskana.rest.simplehistory")
@Import({TaskHistoryRestConfiguration.class, WebMvcConfig.class})
public class ExampleRestApplication {
@Value("${taskana.schemaName:TASKANA}")
public String schemaName;
@Value("${taskana.schemaName:TASKANA}")
public String schemaName;
private SampleDataGenerator sampleDataGenerator;
private SampleDataGenerator sampleDataGenerator;
public static void main(String[] args) {
SpringApplication.run(ExampleRestApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(ExampleRestApplication.class, args);
}
@Bean
@Primary
@ConfigurationProperties(prefix = "datasource")
public DataSourceProperties dataSourceProperties() {
DataSourceProperties props = new DataSourceProperties();
props.setUrl("jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS " + schemaName);
return props;
}
@Bean
@Primary
@ConfigurationProperties(prefix = "datasource")
public DataSourceProperties dataSourceProperties() {
DataSourceProperties props = new DataSourceProperties();
props.setUrl(
"jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS "
+ schemaName);
return props;
}
@Bean
public DataSource dataSource(DataSourceProperties properties) {
return properties.initializeDataSourceBuilder().build();
}
@Bean
public DataSource dataSource(DataSourceProperties properties) {
return properties.initializeDataSourceBuilder().build();
}
@Bean
public PlatformTransactionManager txManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean
public PlatformTransactionManager txManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean
@DependsOn("getTaskanaEngine") // generate sample data after schema was inserted
public SampleDataGenerator generateSampleData(DataSource dataSource) throws SQLException {
sampleDataGenerator = new SampleDataGenerator(dataSource);
sampleDataGenerator.generateSampleData(schemaName);
return sampleDataGenerator;
}
@Bean
@DependsOn("getTaskanaEngine") // generate sample data after schema was inserted
public SampleDataGenerator generateSampleData(DataSource dataSource) throws SQLException {
sampleDataGenerator = new SampleDataGenerator(dataSource);
sampleDataGenerator.generateSampleData(schemaName);
return sampleDataGenerator;
}
}

View File

@ -1,9 +1,9 @@
package rest.pro.taskana.rest.simplehistory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
@ -11,50 +11,47 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
/**
* The Web MVC Configuration.
*/
/** The Web MVC Configuration. */
@Configuration
@EnableWebMvc
public class WebMvcConfig implements WebMvcConfigurer {
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
"classpath:/META-INF/resources/", "classpath:/resources/",
"classpath:/static/", "classpath:/public/"};
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
"classpath:/META-INF/resources/", "classpath:/resources/",
"classpath:/static/", "classpath:/public/"
};
private ObjectMapper objectMapper;
private ObjectMapper objectMapper;
WebMvcConfig(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
WebMvcConfig(ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
if (!registry.hasMappingForPattern("/webjars/**")) {
registry
.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
if (!registry.hasMappingForPattern("/webjars/**")) {
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/");
}
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**").addResourceLocations(
CLASSPATH_RESOURCE_LOCATIONS);
}
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**").addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);
}
}
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
for (HttpMessageConverter<?> converter : converters) {
if (converter instanceof MappingJackson2HttpMessageConverter) {
MappingJackson2HttpMessageConverter jacksonConverter = (MappingJackson2HttpMessageConverter) converter;
jacksonConverter.setPrettyPrint(true);
}
}
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
for (HttpMessageConverter<?> converter : converters) {
if (converter instanceof MappingJackson2HttpMessageConverter) {
MappingJackson2HttpMessageConverter jacksonConverter =
(MappingJackson2HttpMessageConverter) converter;
jacksonConverter.setPrettyPrint(true);
}
}
}
@PostConstruct
public void enableObjectIndent() {
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
}
@PostConstruct
public void enableObjectIndent() {
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
}
}

View File

@ -6,24 +6,23 @@ import org.springframework.hateoas.mvc.ResourceAssemblerSupport;
import pro.taskana.history.api.TaskanaHistoryEvent;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
/**
* Transforms any {@link HistoryEventImpl} into its {@link TaskHistoryEventResource}.
*/
public class TaskHistoryEventAssembler extends ResourceAssemblerSupport<TaskanaHistoryEvent, TaskHistoryEventResource> {
/** Transforms any {@link HistoryEventImpl} into its {@link TaskHistoryEventResource}. */
public class TaskHistoryEventAssembler
extends ResourceAssemblerSupport<TaskanaHistoryEvent, TaskHistoryEventResource> {
public TaskHistoryEventAssembler() {
super(HistoryEventImpl.class, TaskHistoryEventResource.class);
}
public TaskHistoryEventAssembler() {
super(HistoryEventImpl.class, TaskHistoryEventResource.class);
}
@Override
public TaskHistoryEventResource toResource(TaskanaHistoryEvent historyEvent) {
TaskHistoryEventResource resource = createResourceWithId(historyEvent.getId(), historyEvent);
BeanUtils.copyProperties(historyEvent, resource);
if (historyEvent.getCreated() != null) {
resource.setCreated(historyEvent.getCreated().toString());
}
resource.setTaskHistoryId(String.valueOf(historyEvent.getId()));
resource.removeLinks();
return resource;
@Override
public TaskHistoryEventResource toResource(TaskanaHistoryEvent historyEvent) {
TaskHistoryEventResource resource = createResourceWithId(historyEvent.getId(), historyEvent);
BeanUtils.copyProperties(historyEvent, resource);
if (historyEvent.getCreated() != null) {
resource.setCreated(historyEvent.getCreated().toString());
}
resource.setTaskHistoryId(String.valueOf(historyEvent.getId()));
resource.removeLinks();
return resource;
}
}

View File

@ -3,48 +3,45 @@ package pro.taskana.rest.resource;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import java.util.List;
import org.springframework.hateoas.Link;
import pro.taskana.rest.resource.PagedResources.PageMetadata;
import pro.taskana.rest.simplehistory.TaskHistoryEventController;
import pro.taskana.simplehistory.impl.HistoryEventImpl;
/**
* Mapper to convert from a list of HistoryEventImpl to a TaskHistoryEventResource.
*/
/** Mapper to convert from a list of HistoryEventImpl to a TaskHistoryEventResource. */
public class TaskHistoryEventListAssembler extends AbstractRessourcesAssembler {
public TaskHistoryEventListAssembler() {
public TaskHistoryEventListAssembler() {}
public TaskHistoryEventListResource toResources(
List<HistoryEventImpl> historyEvents, PageMetadata pageMetadata) {
TaskHistoryEventAssembler assembler = new TaskHistoryEventAssembler();
List<TaskHistoryEventResource> resources = assembler.toResources(historyEvents);
TaskHistoryEventListResource pagedResources =
new TaskHistoryEventListResource(resources, pageMetadata);
pagedResources.add(new Link(original.toUriString()).withSelfRel());
if (pageMetadata != null) {
pagedResources.add(linkTo(TaskHistoryEventController.class).withRel("allTaskHistoryEvent"));
pagedResources.add(
new Link(original.replaceQueryParam("page", 1).toUriString()).withRel(Link.REL_FIRST));
pagedResources.add(
new Link(original.replaceQueryParam("page", pageMetadata.getTotalPages()).toUriString())
.withRel(Link.REL_LAST));
if (pageMetadata.getNumber() > 1) {
pagedResources.add(
new Link(original.replaceQueryParam("page", pageMetadata.getNumber() - 1).toUriString())
.withRel(Link.REL_PREVIOUS));
}
if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) {
pagedResources.add(
new Link(original.replaceQueryParam("page", pageMetadata.getNumber() + 1).toUriString())
.withRel(Link.REL_NEXT));
}
}
public TaskHistoryEventListResource toResources(List<HistoryEventImpl> historyEvents,
PageMetadata pageMetadata) {
TaskHistoryEventAssembler assembler = new TaskHistoryEventAssembler();
List<TaskHistoryEventResource> resources = assembler.toResources(historyEvents);
TaskHistoryEventListResource pagedResources = new TaskHistoryEventListResource(
resources,
pageMetadata);
pagedResources.add(new Link(original.toUriString()).withSelfRel());
if (pageMetadata != null) {
pagedResources.add(linkTo(TaskHistoryEventController.class).withRel("allTaskHistoryEvent"));
pagedResources.add(new Link(original.replaceQueryParam("page", 1).toUriString()).withRel(Link.REL_FIRST));
pagedResources.add(new Link(original.replaceQueryParam("page", pageMetadata.getTotalPages()).toUriString())
.withRel(Link.REL_LAST));
if (pageMetadata.getNumber() > 1) {
pagedResources
.add(new Link(original.replaceQueryParam("page", pageMetadata.getNumber() - 1).toUriString())
.withRel(Link.REL_PREVIOUS));
}
if (pageMetadata.getNumber() < pageMetadata.getTotalPages()) {
pagedResources
.add(new Link(original.replaceQueryParam("page", pageMetadata.getNumber() + 1).toUriString())
.withRel(Link.REL_NEXT));
}
}
return pagedResources;
}
return pagedResources;
}
}

View File

@ -1,34 +1,29 @@
package pro.taskana.rest.resource;
import java.util.Collection;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.PagedResources.PageMetadata;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collection;
import org.springframework.hateoas.Link;
/**
* Resource class for {@link TaskHistoryEventResource} with Pagination.
*/
/** Resource class for {@link TaskHistoryEventResource} with Pagination. */
public class TaskHistoryEventListResource extends PagedResources<TaskHistoryEventResource> {
public TaskHistoryEventListResource() {
super();
}
public TaskHistoryEventListResource() {
super();
}
public TaskHistoryEventListResource(Collection<TaskHistoryEventResource> content, PageMetadata metadata,
Link... links) {
super(content, metadata, links);
}
public TaskHistoryEventListResource(
Collection<TaskHistoryEventResource> content, PageMetadata metadata, Link... links) {
super(content, metadata, links);
}
public TaskHistoryEventListResource(Collection<TaskHistoryEventResource> content, PageMetadata metadata,
Iterable<Link> links) {
super(content, metadata, links);
}
public TaskHistoryEventListResource(
Collection<TaskHistoryEventResource> content, PageMetadata metadata, Iterable<Link> links) {
super(content, metadata, links);
}
@Override
@JsonProperty("taskHistoryEvents")
public Collection<TaskHistoryEventResource> getContent() {
return super.getContent();
}
@Override
@JsonProperty("taskHistoryEvents")
public Collection<TaskHistoryEventResource> getContent() {
return super.getContent();
}
}

View File

@ -1,266 +1,275 @@
package pro.taskana.rest.resource;
import javax.validation.constraints.NotNull;
import org.springframework.hateoas.ResourceSupport;
/**
* Resource class for {@link pro.taskana.history.api.TaskanaHistoryEvent}.
*/
/** Resource class for {@link pro.taskana.history.api.TaskanaHistoryEvent}. */
public class TaskHistoryEventResource extends ResourceSupport {
@NotNull
private String taskHistoryEventId;
@NotNull private String taskHistoryEventId;
private String businessProcessId;
private String parentBusinessProcessId;
private String taskId;
private String eventType;
private String created;
private String userId;
private String domain;
private String workbasketKey;
private String porCompany;
private String porType;
private String porSystem;
private String porInstance;
private String porValue;
private String taskClassificationKey;
private String taskClassificationCategory;
private String attachmentClassificationKey;
private String comment;
private String oldValue;
private String newValue;
private String custom1;
private String custom2;
private String custom3;
private String custom4;
private String oldData;
private String newData;
private String businessProcessId;
private String parentBusinessProcessId;
private String taskId;
private String eventType;
private String created;
private String userId;
private String domain;
private String workbasketKey;
private String porCompany;
private String porType;
private String porSystem;
private String porInstance;
private String porValue;
private String taskClassificationKey;
private String taskClassificationCategory;
private String attachmentClassificationKey;
private String comment;
private String oldValue;
private String newValue;
private String custom1;
private String custom2;
private String custom3;
private String custom4;
private String oldData;
private String newData;
public String getTaskHistoryId() {
return taskHistoryEventId;
}
public String getTaskHistoryId() {
return taskHistoryEventId;
}
public void setTaskHistoryId(String taskHistoryId) {
this.taskHistoryEventId = taskHistoryId;
}
public void setTaskHistoryId(String taskHistoryId) {
this.taskHistoryEventId = taskHistoryId;
}
public String getBusinessProcessId() {
return businessProcessId;
}
public String getBusinessProcessId() {
return businessProcessId;
}
public void setBusinessProcessId(String businessProcessId) {
this.businessProcessId = businessProcessId;
}
public void setBusinessProcessId(String businessProcessId) {
this.businessProcessId = businessProcessId;
}
public String getParentBusinessProcessId() {
return parentBusinessProcessId;
}
public String getParentBusinessProcessId() {
return parentBusinessProcessId;
}
public void setParentBusinessProcessId(String parentBusinessProcessId) {
this.parentBusinessProcessId = parentBusinessProcessId;
}
public void setParentBusinessProcessId(String parentBusinessProcessId) {
this.parentBusinessProcessId = parentBusinessProcessId;
}
public String getTaskId() {
return taskId;
}
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getEventType() {
return eventType;
}
public String getEventType() {
return eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public void setEventType(String eventType) {
this.eventType = eventType;
}
public String getCreated() {
return created;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public void setCreated(String created) {
this.created = created;
}
public String getUserId() {
return userId;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getDomain() {
return domain;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
public String getWorkbasketKey() {
return workbasketKey;
}
public String getWorkbasketKey() {
return workbasketKey;
}
public void setWorkbasketKey(String workbasketKey) {
this.workbasketKey = workbasketKey;
}
public void setWorkbasketKey(String workbasketKey) {
this.workbasketKey = workbasketKey;
}
public String getPorCompany() {
return porCompany;
}
public String getPorCompany() {
return porCompany;
}
public void setPorCompany(String porCompany) {
this.porCompany = porCompany;
}
public void setPorCompany(String porCompany) {
this.porCompany = porCompany;
}
public String getPorType() {
return porType;
}
public String getPorType() {
return porType;
}
public void setPorType(String porType) {
this.porType = porType;
}
public void setPorType(String porType) {
this.porType = porType;
}
public String getPorSystem() {
return porSystem;
}
public String getPorSystem() {
return porSystem;
}
public void setPorSystem(String porSystem) {
this.porSystem = porSystem;
}
public void setPorSystem(String porSystem) {
this.porSystem = porSystem;
}
public String getPorInstance() {
return porInstance;
}
public String getPorInstance() {
return porInstance;
}
public void setPorInstance(String porInstance) {
this.porInstance = porInstance;
}
public void setPorInstance(String porInstance) {
this.porInstance = porInstance;
}
public String getPorValue() {
return porValue;
}
public String getPorValue() {
return porValue;
}
public void setPorValue(String porValue) {
this.porValue = porValue;
}
public void setPorValue(String porValue) {
this.porValue = porValue;
}
public String getTaskClassificationKey() {
return taskClassificationKey;
}
public String getTaskClassificationKey() {
return taskClassificationKey;
}
public void setTaskClassificationKey(String taskClassificationKey) {
this.taskClassificationKey = taskClassificationKey;
}
public void setTaskClassificationKey(String taskClassificationKey) {
this.taskClassificationKey = taskClassificationKey;
}
public String getTaskClassificationCategory() {
return taskClassificationCategory;
}
public String getTaskClassificationCategory() {
return taskClassificationCategory;
}
public void setTaskClassificationCategory(String taskClassificationCategory) {
this.taskClassificationCategory = taskClassificationCategory;
}
public void setTaskClassificationCategory(String taskClassificationCategory) {
this.taskClassificationCategory = taskClassificationCategory;
}
public String getAttachmentClassificationKey() {
return attachmentClassificationKey;
}
public String getAttachmentClassificationKey() {
return attachmentClassificationKey;
}
public void setAttachmentClassificationKey(String attachmentClassificationKey) {
this.attachmentClassificationKey = attachmentClassificationKey;
}
public void setAttachmentClassificationKey(String attachmentClassificationKey) {
this.attachmentClassificationKey = attachmentClassificationKey;
}
public String getComment() {
return comment;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public String getOldValue() {
return oldValue;
}
public String getOldValue() {
return oldValue;
}
public void setOldValue(String oldValue) {
this.oldValue = oldValue;
}
public void setOldValue(String oldValue) {
this.oldValue = oldValue;
}
public String getNewValue() {
return newValue;
}
public String getNewValue() {
return newValue;
}
public void setNewValue(String newValue) {
this.newValue = newValue;
}
public void setNewValue(String newValue) {
this.newValue = newValue;
}
public String getCustom1() {
return custom1;
}
public String getCustom1() {
return custom1;
}
public void setCustom1(String custom1) {
this.custom1 = custom1;
}
public void setCustom1(String custom1) {
this.custom1 = custom1;
}
public String getCustom2() {
return custom2;
}
public String getCustom2() {
return custom2;
}
public void setCustom2(String custom2) {
this.custom2 = custom2;
}
public void setCustom2(String custom2) {
this.custom2 = custom2;
}
public String getCustom3() {
return custom3;
}
public String getCustom3() {
return custom3;
}
public void setCustom3(String custom3) {
this.custom3 = custom3;
}
public void setCustom3(String custom3) {
this.custom3 = custom3;
}
public String getCustom4() {
return custom4;
}
public String getCustom4() {
return custom4;
}
public void setCustom4(String custom4) {
this.custom4 = custom4;
}
public void setCustom4(String custom4) {
this.custom4 = custom4;
}
public String getOldData() {
return oldData;
}
public String getOldData() {
return oldData;
}
public void setOldData(String oldData) {
this.oldData = oldData;
}
public void setOldData(String oldData) {
this.oldData = oldData;
}
public String getNewData() {
return newData;
}
public String getNewData() {
return newData;
}
public void setNewData(String newData) {
this.newData = newData;
}
public void setNewData(String newData) {
this.newData = newData;
}
@Override
public String toString() {
return "TaskHistoryEventResource ["
+ "taskHistoryEventId= " + this.taskHistoryEventId
+ "businessProcessId= " + this.businessProcessId
+ "parentBusinessProcessId= " + this.parentBusinessProcessId
+ "taskId= " + this.taskId
+ "eventType= " + this.eventType
+ "created= " + this.created
+ "userId= " + this.userId
+ "domain= " + this.domain
+ "workbasketKey= " + this.workbasketKey
+ "oldValue= " + this.oldValue
+ "newValue= " + this.newValue
+ "oldData= " + this.oldData
+ "newData= " + this.newData
+ "]";
}
@Override
public String toString() {
return "TaskHistoryEventResource ["
+ "taskHistoryEventId= "
+ this.taskHistoryEventId
+ "businessProcessId= "
+ this.businessProcessId
+ "parentBusinessProcessId= "
+ this.parentBusinessProcessId
+ "taskId= "
+ this.taskId
+ "eventType= "
+ this.eventType
+ "created= "
+ this.created
+ "userId= "
+ this.userId
+ "domain= "
+ this.domain
+ "workbasketKey= "
+ this.workbasketKey
+ "oldValue= "
+ this.oldValue
+ "newValue= "
+ this.newValue
+ "oldData= "
+ this.oldData
+ "newData= "
+ this.newData
+ "]";
}
}

View File

@ -4,7 +4,6 @@ import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.hateoas.config.EnableHypermediaSupport;
@ -30,445 +29,456 @@ import pro.taskana.simplehistory.impl.HistoryEventImpl;
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
import pro.taskana.simplehistory.query.HistoryQuery;
/**
* Controller for all TaskHistoryEvent related endpoints.
*/
/** Controller for all TaskHistoryEvent related endpoints. */
@RestController
@EnableHypermediaSupport(type = EnableHypermediaSupport.HypermediaType.HAL)
@RequestMapping(path = "/api/v1/task-history-event", produces = "application/hal+json")
public class TaskHistoryEventController extends AbstractPagingController {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskHistoryEventController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(TaskHistoryEventController.class);
private static final String LIKE = "%";
private static final String LIKE = "%";
private static final String BUSINESS_PROCESS_ID = "business-process-id";
private static final String BUSINESS_PROCESS_ID = "business-process-id";
private static final String BUSINESS_PROCESS_ID_LIKE = "business-process-id-like";
private static final String BUSINESS_PROCESS_ID_LIKE = "business-process-id-like";
private static final String PARENT_BUSINESS_PROCESS_ID = "parent-business-process-id";
private static final String PARENT_BUSINESS_PROCESS_ID = "parent-business-process-id";
private static final String PARENT_BUSINESS_PROCESS_ID_LIKE = "parent-business-process-id-like";
private static final String PARENT_BUSINESS_PROCESS_ID_LIKE = "parent-business-process-id-like";
private static final String TASK_ID = "task-id";
private static final String TASK_ID = "task-id";
private static final String TASK_ID_LIKE = "task-id-like";
private static final String TASK_ID_LIKE = "task-id-like";
private static final String EVENT_TYPE = "event-type";
private static final String EVENT_TYPE = "event-type";
private static final String EVENT_TYPE_LIKE = "event-type-like";
private static final String EVENT_TYPE_LIKE = "event-type-like";
private static final String CREATED = "created";
private static final String CREATED = "created";
private static final String USER_ID = "user-id";
private static final String USER_ID = "user-id";
private static final String USER_ID_LIKE = "user-id-like";
private static final String USER_ID_LIKE = "user-id-like";
private static final String DOMAIN = "domain";
private static final String DOMAIN = "domain";
private static final String WORKBASKET_KEY = "workbasket-key";
private static final String WORKBASKET_KEY = "workbasket-key";
private static final String WORKBASKET_KEY_LIKE = "workbasket-key-like";
private static final String WORKBASKET_KEY_LIKE = "workbasket-key-like";
private static final String POR_COMPANY = "por-company";
private static final String POR_COMPANY = "por-company";
private static final String POR_COMPANY_LIKE = "por-company-like";
private static final String POR_COMPANY_LIKE = "por-company-like";
private static final String POR_SYSTEM = "por-system";
private static final String POR_SYSTEM = "por-system";
private static final String POR_SYSTEM_LIKE = "por-system-like";
private static final String POR_SYSTEM_LIKE = "por-system-like";
private static final String POR_INSTANCE = "por-instance";
private static final String POR_INSTANCE = "por-instance";
private static final String POR_INSTANCE_LIKE = "por-instance-like";
private static final String POR_INSTANCE_LIKE = "por-instance-like";
private static final String POR_TYPE = "por-type";
private static final String POR_TYPE = "por-type";
private static final String POR_TYPE_LIKE = "por-type-like";
private static final String POR_TYPE_LIKE = "por-type-like";
private static final String POR_VALUE = "por-value";
private static final String POR_VALUE = "por-value";
private static final String POR_VALUE_LIKE = "por-value-like";
private static final String POR_VALUE_LIKE = "por-value-like";
private static final String TASK_CLASSIFICATION_KEY = "task-classification-key";
private static final String TASK_CLASSIFICATION_KEY = "task-classification-key";
private static final String TASK_CLASSIFICATION_KEY_LIKE = "task-classification-key-like";
private static final String TASK_CLASSIFICATION_KEY_LIKE = "task-classification-key-like";
private static final String TASK_CLASSIFICATION_CATEGORY = "task-classification-category";
private static final String TASK_CLASSIFICATION_CATEGORY = "task-classification-category";
private static final String TASK_CLASSIFICATION_CATEGORY_LIKE = "task-classification-category-like";
private static final String TASK_CLASSIFICATION_CATEGORY_LIKE =
"task-classification-category-like";
private static final String ATTACHMENT_CLASSIFICATION_KEY = "attachment-classification-key";
private static final String ATTACHMENT_CLASSIFICATION_KEY = "attachment-classification-key";
private static final String ATTACHMENT_CLASSIFICATION_KEY_LIKE = "attachment-classification-key-like";
private static final String ATTACHMENT_CLASSIFICATION_KEY_LIKE =
"attachment-classification-key-like";
private static final String CUSTOM_1 = "custom-1";
private static final String CUSTOM_1 = "custom-1";
private static final String CUSTOM_1_LIKE = "custom-1-like";
private static final String CUSTOM_1_LIKE = "custom-1-like";
private static final String CUSTOM_2 = "custom-2";
private static final String CUSTOM_2 = "custom-2";
private static final String CUSTOM_2_LIKE = "custom-2-like";
private static final String CUSTOM_2_LIKE = "custom-2-like";
private static final String CUSTOM_3 = "custom-3";
private static final String CUSTOM_3 = "custom-3";
private static final String CUSTOM_3_LIKE = "custom-3-like";
private static final String CUSTOM_3_LIKE = "custom-3-like";
private static final String CUSTOM_4 = "custom-4";
private static final String CUSTOM_4 = "custom-4";
private static final String CUSTOM_4_LIKE = "custom-4-like";
private static final String CUSTOM_4_LIKE = "custom-4-like";
private static final String SORT_BY = "sort-by";
private static final String SORT_BY = "sort-by";
private static final String SORT_DIRECTION = "order";
private static final String SORT_DIRECTION = "order";
private static final String PAGING_PAGE = "page";
private static final String PAGING_PAGE = "page";
private static final String PAGING_PAGE_SIZE = "page-size";
private static final String PAGING_PAGE_SIZE = "page-size";
private SimpleHistoryServiceImpl simpleHistoryService;
private SimpleHistoryServiceImpl simpleHistoryService;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
public TaskHistoryEventController(TaskanaEngineConfiguration taskanaEngineConfiguration,
SimpleHistoryServiceImpl simpleHistoryServiceImpl) {
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
this.simpleHistoryService = simpleHistoryServiceImpl;
simpleHistoryService.initialize(taskanaEngineConfiguration);
public TaskHistoryEventController(
TaskanaEngineConfiguration taskanaEngineConfiguration,
SimpleHistoryServiceImpl simpleHistoryServiceImpl) {
this.taskanaEngineConfiguration = taskanaEngineConfiguration;
this.simpleHistoryService = simpleHistoryServiceImpl;
simpleHistoryService.initialize(taskanaEngineConfiguration);
}
@GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskHistoryEventListResource> getTaskHistoryEvent(
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getTaskHistoryEvent(params= {})", LoggerUtils.mapToString(params));
}
@GetMapping
@Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<TaskHistoryEventListResource> getTaskHistoryEvent(
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getTaskHistoryEvent(params= {})", LoggerUtils.mapToString(params));
}
HistoryQuery query = simpleHistoryService.createHistoryQuery();
query = applySortingParams(query, params);
query = applyFilterParams(query, params);
HistoryQuery query = simpleHistoryService.createHistoryQuery();
query = applySortingParams(query, params);
query = applyFilterParams(query, params);
PageMetadata pageMetadata = null;
List<HistoryEventImpl> historyEvents = null;
String page = params.getFirst(PAGING_PAGE);
String pageSize = params.getFirst(PAGING_PAGE_SIZE);
params.remove(PAGING_PAGE);
params.remove(PAGING_PAGE_SIZE);
validateNoInvalidParameterIsLeft(params);
if (page != null && pageSize != null) {
long totalElements = query.count();
pageMetadata = initPageMetadata(pageSize, page, totalElements);
historyEvents = query.listPage((int) pageMetadata.getNumber(),
(int) pageMetadata.getSize());
} else if (page == null && pageSize == null) {
historyEvents = query.list();
} else {
throw new InvalidArgumentException("Paging information is incomplete.");
}
TaskHistoryEventListAssembler assembler = new TaskHistoryEventListAssembler();
TaskHistoryEventListResource pagedResources = assembler.toResources(historyEvents, pageMetadata);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTaskHistoryEvent(), returning {}",
new ResponseEntity<>(pagedResources, HttpStatus.OK));
}
return new ResponseEntity<>(pagedResources, HttpStatus.OK);
PageMetadata pageMetadata = null;
List<HistoryEventImpl> historyEvents = null;
String page = params.getFirst(PAGING_PAGE);
String pageSize = params.getFirst(PAGING_PAGE_SIZE);
params.remove(PAGING_PAGE);
params.remove(PAGING_PAGE_SIZE);
validateNoInvalidParameterIsLeft(params);
if (page != null && pageSize != null) {
long totalElements = query.count();
pageMetadata = initPageMetadata(pageSize, page, totalElements);
historyEvents = query.listPage((int) pageMetadata.getNumber(), (int) pageMetadata.getSize());
} else if (page == null && pageSize == null) {
historyEvents = query.list();
} else {
throw new InvalidArgumentException("Paging information is incomplete.");
}
private HistoryQuery applySortingParams(HistoryQuery query, MultiValueMap<String, String> params)
throws IllegalArgumentException, InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applySortingParams(params= {})", LoggerUtils.mapToString(params));
}
TaskHistoryEventListAssembler assembler = new TaskHistoryEventListAssembler();
TaskHistoryEventListResource pagedResources =
assembler.toResources(historyEvents, pageMetadata);
String sortBy = params.getFirst(SORT_BY);
if (sortBy != null) {
BaseQuery.SortDirection sortDirection;
if (params.getFirst(SORT_DIRECTION) != null && "desc".equals(params.getFirst(SORT_DIRECTION))) {
sortDirection = BaseQuery.SortDirection.DESCENDING;
} else {
sortDirection = BaseQuery.SortDirection.ASCENDING;
}
switch (sortBy) {
case (BUSINESS_PROCESS_ID):
query = query.orderByBusinessProcessId(sortDirection);
break;
case (PARENT_BUSINESS_PROCESS_ID):
query = query.orderByParentBusinessProcessId(sortDirection);
break;
case (TASK_ID):
query = query.orderByTaskId(sortDirection);
break;
case (EVENT_TYPE):
query = query.orderByEventType(sortDirection);
break;
case (CREATED):
query = query.orderByCreated(sortDirection);
break;
case (USER_ID):
query = query.orderByUserId(sortDirection);
break;
case (DOMAIN):
query = query.orderByDomain(sortDirection);
break;
case (WORKBASKET_KEY):
query = query.orderByWorkbasketKey(sortDirection);
break;
case (POR_COMPANY):
query = query.orderByPorCompany(sortDirection);
break;
case (POR_SYSTEM):
query = query.orderByPorSystem(sortDirection);
break;
case (POR_INSTANCE):
query = query.orderByPorInstance(sortDirection);
break;
case (POR_TYPE):
query = query.orderByPorType(sortDirection);
break;
case (POR_VALUE):
query = query.orderByPorValue(sortDirection);
break;
case (TASK_CLASSIFICATION_KEY):
query = query.orderByTaskClassificationKey(sortDirection);
break;
case (TASK_CLASSIFICATION_CATEGORY):
query = query.orderByTaskClassificationCategory(sortDirection);
break;
case (ATTACHMENT_CLASSIFICATION_KEY):
query = query.orderByAttachmentClassificationKey(sortDirection);
break;
case (CUSTOM_1):
query = query.orderByCustomAttribute(1, sortDirection);
break;
case (CUSTOM_2):
query = query.orderByCustomAttribute(2, sortDirection);
break;
case (CUSTOM_3):
query = query.orderByCustomAttribute(3, sortDirection);
break;
case (CUSTOM_4):
query = query.orderByCustomAttribute(4, sortDirection);
break;
default:
throw new IllegalArgumentException("Unknown order '" + sortBy + "'");
}
}
params.remove(SORT_BY);
params.remove(SORT_DIRECTION);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applySortingParams(), returning {}", query);
}
return query;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
"Exit from getTaskHistoryEvent(), returning {}",
new ResponseEntity<>(pagedResources, HttpStatus.OK));
}
private HistoryQuery applyFilterParams(HistoryQuery query,
MultiValueMap<String, String> params) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params);
}
return new ResponseEntity<>(pagedResources, HttpStatus.OK);
}
if (params.containsKey(BUSINESS_PROCESS_ID)) {
String[] businessProcessId = extractCommaSeparatedFields(params.get(BUSINESS_PROCESS_ID));
query.businessProcessIdIn(businessProcessId);
params.remove(BUSINESS_PROCESS_ID);
}
if (params.containsKey(BUSINESS_PROCESS_ID_LIKE)) {
query.businessProcessIdLike(LIKE + params.get(BUSINESS_PROCESS_ID_LIKE).get(0) + LIKE);
params.remove(BUSINESS_PROCESS_ID_LIKE);
}
if (params.containsKey(PARENT_BUSINESS_PROCESS_ID)) {
String[] parentBusinessProcessId = extractCommaSeparatedFields(params.get(PARENT_BUSINESS_PROCESS_ID));
query.parentBusinessProcessIdIn(parentBusinessProcessId);
params.remove(PARENT_BUSINESS_PROCESS_ID);
}
if (params.containsKey(PARENT_BUSINESS_PROCESS_ID_LIKE)) {
query.parentBusinessProcessIdLike(LIKE + params.get(PARENT_BUSINESS_PROCESS_ID_LIKE).get(0) + LIKE);
params.remove(PARENT_BUSINESS_PROCESS_ID_LIKE);
}
if (params.containsKey(TASK_ID)) {
String[] taskId = extractCommaSeparatedFields(params.get(TASK_ID));
query.taskIdIn(taskId);
params.remove(TASK_ID);
}
if (params.containsKey(TASK_ID_LIKE)) {
query.taskIdLike(LIKE + params.get(TASK_ID_LIKE).get(0) + LIKE);
params.remove(TASK_ID_LIKE);
}
if (params.containsKey(EVENT_TYPE)) {
String[] eventType = extractCommaSeparatedFields(params.get(EVENT_TYPE));
query.eventTypeIn(eventType);
params.remove(EVENT_TYPE);
}
if (params.containsKey(EVENT_TYPE_LIKE)) {
query.eventTypeLike(LIKE + params.get(EVENT_TYPE_LIKE).get(0) + LIKE);
params.remove(EVENT_TYPE_LIKE);
}
if (params.containsKey(CREATED)) {
String[] created = extractCommaSeparatedFields(params.get(CREATED));
TimeInterval timeInterval = getTimeIntervalOf(created);
query.createdWithin(timeInterval);
params.remove(CREATED);
}
if (params.containsKey(USER_ID)) {
String[] userId = extractCommaSeparatedFields(params.get(USER_ID));
query.userIdIn(userId);
params.remove(USER_ID);
}
if (params.containsKey(USER_ID_LIKE)) {
query.userIdLike(LIKE + params.get(USER_ID_LIKE).get(0) + LIKE);
params.remove(USER_ID_LIKE);
}
if (params.containsKey(DOMAIN)) {
query.domainIn(extractCommaSeparatedFields(params.get(DOMAIN)));
params.remove(DOMAIN);
}
if (params.containsKey(WORKBASKET_KEY)) {
String[] workbasketKey = extractCommaSeparatedFields(params.get(WORKBASKET_KEY));
query.workbasketKeyIn(workbasketKey);
params.remove(WORKBASKET_KEY);
}
if (params.containsKey(WORKBASKET_KEY_LIKE)) {
query.workbasketKeyLike(LIKE + params.get(WORKBASKET_KEY_LIKE).get(0) + LIKE);
params.remove(WORKBASKET_KEY_LIKE);
}
if (params.containsKey(POR_COMPANY)) {
String[] porCompany = extractCommaSeparatedFields(params.get(POR_COMPANY));
query.porCompanyIn(porCompany);
params.remove(POR_COMPANY);
}
if (params.containsKey(POR_COMPANY_LIKE)) {
query.porCompanyLike(LIKE + params.get(POR_COMPANY_LIKE).get(0) + LIKE);
params.remove(POR_COMPANY_LIKE);
}
if (params.containsKey(POR_SYSTEM)) {
String[] porSystem = extractCommaSeparatedFields(params.get(POR_SYSTEM));
query.porSystemIn(porSystem);
params.remove(POR_SYSTEM);
}
if (params.containsKey(POR_SYSTEM_LIKE)) {
query.porSystemLike(LIKE + params.get(POR_SYSTEM_LIKE).get(0) + LIKE);
params.remove(POR_SYSTEM_LIKE);
}
if (params.containsKey(POR_INSTANCE)) {
String[] porInstance = extractCommaSeparatedFields(params.get(POR_INSTANCE));
query.porInstanceIn(porInstance);
params.remove(POR_INSTANCE);
}
if (params.containsKey(POR_INSTANCE_LIKE)) {
query.porInstanceLike(LIKE + params.get(POR_INSTANCE_LIKE).get(0) + LIKE);
params.remove(POR_INSTANCE_LIKE);
}
if (params.containsKey(POR_TYPE)) {
String[] porType = extractCommaSeparatedFields(params.get(POR_TYPE));
query.porTypeIn(porType);
params.remove(POR_TYPE);
}
if (params.containsKey(POR_TYPE_LIKE)) {
query.porTypeLike(LIKE + params.get(POR_TYPE_LIKE).get(0) + LIKE);
params.remove(POR_TYPE_LIKE);
}
if (params.containsKey(POR_VALUE)) {
String[] porValue = extractCommaSeparatedFields(params.get(POR_VALUE));
query.porValueIn(porValue);
params.remove(POR_VALUE);
}
if (params.containsKey(POR_VALUE_LIKE)) {
query.porValueLike(LIKE + params.get(POR_VALUE_LIKE).get(0) + LIKE);
params.remove(POR_VALUE_LIKE);
}
if (params.containsKey(TASK_CLASSIFICATION_KEY)) {
String[] taskClassificationKey = extractCommaSeparatedFields(params.get(TASK_CLASSIFICATION_KEY));
query.taskClassificationKeyIn(taskClassificationKey);
params.remove(TASK_CLASSIFICATION_KEY);
}
if (params.containsKey(TASK_CLASSIFICATION_KEY_LIKE)) {
query.taskClassificationKeyLike(LIKE + params.get(TASK_CLASSIFICATION_KEY_LIKE).get(0) + LIKE);
params.remove(TASK_CLASSIFICATION_KEY_LIKE);
}
if (params.containsKey(TASK_CLASSIFICATION_CATEGORY)) {
String[] taskClassificationCategory = extractCommaSeparatedFields(params.get(TASK_CLASSIFICATION_CATEGORY));
query.taskClassificationCategoryIn(taskClassificationCategory);
params.remove(TASK_CLASSIFICATION_CATEGORY);
}
if (params.containsKey(TASK_CLASSIFICATION_CATEGORY_LIKE)) {
query.taskClassificationCategoryLike(LIKE + params.get(TASK_CLASSIFICATION_CATEGORY_LIKE).get(0) + LIKE);
params.remove(TASK_CLASSIFICATION_CATEGORY_LIKE);
}
if (params.containsKey(ATTACHMENT_CLASSIFICATION_KEY)) {
String[] attachmentClassificationKey = extractCommaSeparatedFields(
params.get(ATTACHMENT_CLASSIFICATION_KEY));
query.attachmentClassificationKeyIn(attachmentClassificationKey);
params.remove(ATTACHMENT_CLASSIFICATION_KEY);
}
if (params.containsKey(ATTACHMENT_CLASSIFICATION_KEY_LIKE)) {
query.attachmentClassificationKeyLike(LIKE + params.get(ATTACHMENT_CLASSIFICATION_KEY_LIKE).get(0) + LIKE);
params.remove(ATTACHMENT_CLASSIFICATION_KEY_LIKE);
}
if (params.containsKey(CUSTOM_1)) {
String[] custom1 = extractCommaSeparatedFields(params.get(CUSTOM_1));
query.custom1In(custom1);
params.remove(CUSTOM_1);
}
if (params.containsKey(CUSTOM_1_LIKE)) {
query.custom1Like(LIKE + params.get(CUSTOM_1_LIKE).get(0) + LIKE);
params.remove(CUSTOM_1_LIKE);
}
if (params.containsKey(CUSTOM_2)) {
String[] custom2 = extractCommaSeparatedFields(params.get(CUSTOM_2));
query.custom2In(custom2);
params.remove(CUSTOM_2);
}
if (params.containsKey(CUSTOM_2_LIKE)) {
query.custom2Like(LIKE + params.get(CUSTOM_2_LIKE).get(0) + LIKE);
params.remove(CUSTOM_2_LIKE);
}
if (params.containsKey(CUSTOM_3)) {
String[] custom3 = extractCommaSeparatedFields(params.get(CUSTOM_3));
query.custom3In(custom3);
params.remove(CUSTOM_3);
}
if (params.containsKey(CUSTOM_3_LIKE)) {
query.custom3Like(LIKE + params.get(CUSTOM_3_LIKE).get(0) + LIKE);
params.remove(CUSTOM_3_LIKE);
}
if (params.containsKey(CUSTOM_4)) {
String[] custom4 = extractCommaSeparatedFields(params.get(CUSTOM_4));
query.custom4In(custom4);
params.remove(CUSTOM_4);
}
if (params.containsKey(CUSTOM_4_LIKE)) {
query.custom4Like(LIKE + params.get(CUSTOM_4_LIKE).get(0) + LIKE);
params.remove(CUSTOM_4_LIKE);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
}
return query;
private HistoryQuery applySortingParams(HistoryQuery query, MultiValueMap<String, String> params)
throws IllegalArgumentException, InvalidArgumentException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applySortingParams(params= {})", LoggerUtils.mapToString(params));
}
private TimeInterval getTimeIntervalOf(String[] created) {
LocalDate begin;
LocalDate end;
try {
begin = LocalDate.parse(created[0]);
} catch (Exception e) {
throw new IllegalArgumentException(
"Cannot parse String '" + created[0] + "'. Expected a String of the Format 'yyyy-MM-dd'.");
}
if (created.length < 2) {
end = begin.plusDays(1);
} else {
end = LocalDate.parse(created[1]);
}
Instant beginInst = begin.atStartOfDay(ZoneId.systemDefault()).toInstant();
Instant endInst = end.atStartOfDay(ZoneId.systemDefault()).toInstant();
TimeInterval timeInterval = new TimeInterval(beginInst, endInst);
return timeInterval;
String sortBy = params.getFirst(SORT_BY);
if (sortBy != null) {
BaseQuery.SortDirection sortDirection;
if (params.getFirst(SORT_DIRECTION) != null
&& "desc".equals(params.getFirst(SORT_DIRECTION))) {
sortDirection = BaseQuery.SortDirection.DESCENDING;
} else {
sortDirection = BaseQuery.SortDirection.ASCENDING;
}
switch (sortBy) {
case (BUSINESS_PROCESS_ID):
query = query.orderByBusinessProcessId(sortDirection);
break;
case (PARENT_BUSINESS_PROCESS_ID):
query = query.orderByParentBusinessProcessId(sortDirection);
break;
case (TASK_ID):
query = query.orderByTaskId(sortDirection);
break;
case (EVENT_TYPE):
query = query.orderByEventType(sortDirection);
break;
case (CREATED):
query = query.orderByCreated(sortDirection);
break;
case (USER_ID):
query = query.orderByUserId(sortDirection);
break;
case (DOMAIN):
query = query.orderByDomain(sortDirection);
break;
case (WORKBASKET_KEY):
query = query.orderByWorkbasketKey(sortDirection);
break;
case (POR_COMPANY):
query = query.orderByPorCompany(sortDirection);
break;
case (POR_SYSTEM):
query = query.orderByPorSystem(sortDirection);
break;
case (POR_INSTANCE):
query = query.orderByPorInstance(sortDirection);
break;
case (POR_TYPE):
query = query.orderByPorType(sortDirection);
break;
case (POR_VALUE):
query = query.orderByPorValue(sortDirection);
break;
case (TASK_CLASSIFICATION_KEY):
query = query.orderByTaskClassificationKey(sortDirection);
break;
case (TASK_CLASSIFICATION_CATEGORY):
query = query.orderByTaskClassificationCategory(sortDirection);
break;
case (ATTACHMENT_CLASSIFICATION_KEY):
query = query.orderByAttachmentClassificationKey(sortDirection);
break;
case (CUSTOM_1):
query = query.orderByCustomAttribute(1, sortDirection);
break;
case (CUSTOM_2):
query = query.orderByCustomAttribute(2, sortDirection);
break;
case (CUSTOM_3):
query = query.orderByCustomAttribute(3, sortDirection);
break;
case (CUSTOM_4):
query = query.orderByCustomAttribute(4, sortDirection);
break;
default:
throw new IllegalArgumentException("Unknown order '" + sortBy + "'");
}
}
params.remove(SORT_BY);
params.remove(SORT_DIRECTION);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applySortingParams(), returning {}", query);
}
return query;
}
private HistoryQuery applyFilterParams(HistoryQuery query, MultiValueMap<String, String> params) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params);
}
if (params.containsKey(BUSINESS_PROCESS_ID)) {
String[] businessProcessId = extractCommaSeparatedFields(params.get(BUSINESS_PROCESS_ID));
query.businessProcessIdIn(businessProcessId);
params.remove(BUSINESS_PROCESS_ID);
}
if (params.containsKey(BUSINESS_PROCESS_ID_LIKE)) {
query.businessProcessIdLike(LIKE + params.get(BUSINESS_PROCESS_ID_LIKE).get(0) + LIKE);
params.remove(BUSINESS_PROCESS_ID_LIKE);
}
if (params.containsKey(PARENT_BUSINESS_PROCESS_ID)) {
String[] parentBusinessProcessId =
extractCommaSeparatedFields(params.get(PARENT_BUSINESS_PROCESS_ID));
query.parentBusinessProcessIdIn(parentBusinessProcessId);
params.remove(PARENT_BUSINESS_PROCESS_ID);
}
if (params.containsKey(PARENT_BUSINESS_PROCESS_ID_LIKE)) {
query.parentBusinessProcessIdLike(
LIKE + params.get(PARENT_BUSINESS_PROCESS_ID_LIKE).get(0) + LIKE);
params.remove(PARENT_BUSINESS_PROCESS_ID_LIKE);
}
if (params.containsKey(TASK_ID)) {
String[] taskId = extractCommaSeparatedFields(params.get(TASK_ID));
query.taskIdIn(taskId);
params.remove(TASK_ID);
}
if (params.containsKey(TASK_ID_LIKE)) {
query.taskIdLike(LIKE + params.get(TASK_ID_LIKE).get(0) + LIKE);
params.remove(TASK_ID_LIKE);
}
if (params.containsKey(EVENT_TYPE)) {
String[] eventType = extractCommaSeparatedFields(params.get(EVENT_TYPE));
query.eventTypeIn(eventType);
params.remove(EVENT_TYPE);
}
if (params.containsKey(EVENT_TYPE_LIKE)) {
query.eventTypeLike(LIKE + params.get(EVENT_TYPE_LIKE).get(0) + LIKE);
params.remove(EVENT_TYPE_LIKE);
}
if (params.containsKey(CREATED)) {
String[] created = extractCommaSeparatedFields(params.get(CREATED));
TimeInterval timeInterval = getTimeIntervalOf(created);
query.createdWithin(timeInterval);
params.remove(CREATED);
}
if (params.containsKey(USER_ID)) {
String[] userId = extractCommaSeparatedFields(params.get(USER_ID));
query.userIdIn(userId);
params.remove(USER_ID);
}
if (params.containsKey(USER_ID_LIKE)) {
query.userIdLike(LIKE + params.get(USER_ID_LIKE).get(0) + LIKE);
params.remove(USER_ID_LIKE);
}
if (params.containsKey(DOMAIN)) {
query.domainIn(extractCommaSeparatedFields(params.get(DOMAIN)));
params.remove(DOMAIN);
}
if (params.containsKey(WORKBASKET_KEY)) {
String[] workbasketKey = extractCommaSeparatedFields(params.get(WORKBASKET_KEY));
query.workbasketKeyIn(workbasketKey);
params.remove(WORKBASKET_KEY);
}
if (params.containsKey(WORKBASKET_KEY_LIKE)) {
query.workbasketKeyLike(LIKE + params.get(WORKBASKET_KEY_LIKE).get(0) + LIKE);
params.remove(WORKBASKET_KEY_LIKE);
}
if (params.containsKey(POR_COMPANY)) {
String[] porCompany = extractCommaSeparatedFields(params.get(POR_COMPANY));
query.porCompanyIn(porCompany);
params.remove(POR_COMPANY);
}
if (params.containsKey(POR_COMPANY_LIKE)) {
query.porCompanyLike(LIKE + params.get(POR_COMPANY_LIKE).get(0) + LIKE);
params.remove(POR_COMPANY_LIKE);
}
if (params.containsKey(POR_SYSTEM)) {
String[] porSystem = extractCommaSeparatedFields(params.get(POR_SYSTEM));
query.porSystemIn(porSystem);
params.remove(POR_SYSTEM);
}
if (params.containsKey(POR_SYSTEM_LIKE)) {
query.porSystemLike(LIKE + params.get(POR_SYSTEM_LIKE).get(0) + LIKE);
params.remove(POR_SYSTEM_LIKE);
}
if (params.containsKey(POR_INSTANCE)) {
String[] porInstance = extractCommaSeparatedFields(params.get(POR_INSTANCE));
query.porInstanceIn(porInstance);
params.remove(POR_INSTANCE);
}
if (params.containsKey(POR_INSTANCE_LIKE)) {
query.porInstanceLike(LIKE + params.get(POR_INSTANCE_LIKE).get(0) + LIKE);
params.remove(POR_INSTANCE_LIKE);
}
if (params.containsKey(POR_TYPE)) {
String[] porType = extractCommaSeparatedFields(params.get(POR_TYPE));
query.porTypeIn(porType);
params.remove(POR_TYPE);
}
if (params.containsKey(POR_TYPE_LIKE)) {
query.porTypeLike(LIKE + params.get(POR_TYPE_LIKE).get(0) + LIKE);
params.remove(POR_TYPE_LIKE);
}
if (params.containsKey(POR_VALUE)) {
String[] porValue = extractCommaSeparatedFields(params.get(POR_VALUE));
query.porValueIn(porValue);
params.remove(POR_VALUE);
}
if (params.containsKey(POR_VALUE_LIKE)) {
query.porValueLike(LIKE + params.get(POR_VALUE_LIKE).get(0) + LIKE);
params.remove(POR_VALUE_LIKE);
}
if (params.containsKey(TASK_CLASSIFICATION_KEY)) {
String[] taskClassificationKey =
extractCommaSeparatedFields(params.get(TASK_CLASSIFICATION_KEY));
query.taskClassificationKeyIn(taskClassificationKey);
params.remove(TASK_CLASSIFICATION_KEY);
}
if (params.containsKey(TASK_CLASSIFICATION_KEY_LIKE)) {
query.taskClassificationKeyLike(
LIKE + params.get(TASK_CLASSIFICATION_KEY_LIKE).get(0) + LIKE);
params.remove(TASK_CLASSIFICATION_KEY_LIKE);
}
if (params.containsKey(TASK_CLASSIFICATION_CATEGORY)) {
String[] taskClassificationCategory =
extractCommaSeparatedFields(params.get(TASK_CLASSIFICATION_CATEGORY));
query.taskClassificationCategoryIn(taskClassificationCategory);
params.remove(TASK_CLASSIFICATION_CATEGORY);
}
if (params.containsKey(TASK_CLASSIFICATION_CATEGORY_LIKE)) {
query.taskClassificationCategoryLike(
LIKE + params.get(TASK_CLASSIFICATION_CATEGORY_LIKE).get(0) + LIKE);
params.remove(TASK_CLASSIFICATION_CATEGORY_LIKE);
}
if (params.containsKey(ATTACHMENT_CLASSIFICATION_KEY)) {
String[] attachmentClassificationKey =
extractCommaSeparatedFields(params.get(ATTACHMENT_CLASSIFICATION_KEY));
query.attachmentClassificationKeyIn(attachmentClassificationKey);
params.remove(ATTACHMENT_CLASSIFICATION_KEY);
}
if (params.containsKey(ATTACHMENT_CLASSIFICATION_KEY_LIKE)) {
query.attachmentClassificationKeyLike(
LIKE + params.get(ATTACHMENT_CLASSIFICATION_KEY_LIKE).get(0) + LIKE);
params.remove(ATTACHMENT_CLASSIFICATION_KEY_LIKE);
}
if (params.containsKey(CUSTOM_1)) {
String[] custom1 = extractCommaSeparatedFields(params.get(CUSTOM_1));
query.custom1In(custom1);
params.remove(CUSTOM_1);
}
if (params.containsKey(CUSTOM_1_LIKE)) {
query.custom1Like(LIKE + params.get(CUSTOM_1_LIKE).get(0) + LIKE);
params.remove(CUSTOM_1_LIKE);
}
if (params.containsKey(CUSTOM_2)) {
String[] custom2 = extractCommaSeparatedFields(params.get(CUSTOM_2));
query.custom2In(custom2);
params.remove(CUSTOM_2);
}
if (params.containsKey(CUSTOM_2_LIKE)) {
query.custom2Like(LIKE + params.get(CUSTOM_2_LIKE).get(0) + LIKE);
params.remove(CUSTOM_2_LIKE);
}
if (params.containsKey(CUSTOM_3)) {
String[] custom3 = extractCommaSeparatedFields(params.get(CUSTOM_3));
query.custom3In(custom3);
params.remove(CUSTOM_3);
}
if (params.containsKey(CUSTOM_3_LIKE)) {
query.custom3Like(LIKE + params.get(CUSTOM_3_LIKE).get(0) + LIKE);
params.remove(CUSTOM_3_LIKE);
}
if (params.containsKey(CUSTOM_4)) {
String[] custom4 = extractCommaSeparatedFields(params.get(CUSTOM_4));
query.custom4In(custom4);
params.remove(CUSTOM_4);
}
if (params.containsKey(CUSTOM_4_LIKE)) {
query.custom4Like(LIKE + params.get(CUSTOM_4_LIKE).get(0) + LIKE);
params.remove(CUSTOM_4_LIKE);
}
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
}
return query;
}
private TimeInterval getTimeIntervalOf(String[] created) {
LocalDate begin;
LocalDate end;
try {
begin = LocalDate.parse(created[0]);
} catch (Exception e) {
throw new IllegalArgumentException(
"Cannot parse String '"
+ created[0]
+ "'. Expected a String of the Format 'yyyy-MM-dd'.");
}
if (created.length < 2) {
end = begin.plusDays(1);
} else {
end = LocalDate.parse(created[1]);
}
Instant beginInst = begin.atStartOfDay(ZoneId.systemDefault()).toInstant();
Instant endInst = end.atStartOfDay(ZoneId.systemDefault()).toInstant();
TimeInterval timeInterval = new TimeInterval(beginInst, endInst);
return timeInterval;
}
}

View File

@ -7,17 +7,14 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import pro.taskana.simplehistory.impl.SimpleHistoryServiceImpl;
/**
* Configuration for Taskana history REST service.
*/
/** Configuration for Taskana history REST service. */
@Configuration
@ComponentScan(basePackages = {"pro.taskana.rest", "pro.taskana.rest.simplehistory"})
@EnableTransactionManagement
public class TaskHistoryRestConfiguration {
@Bean
public SimpleHistoryServiceImpl getSimpleHistoryService() {
return new SimpleHistoryServiceImpl();
}
@Bean
public SimpleHistoryServiceImpl getSimpleHistoryService() {
return new SimpleHistoryServiceImpl();
}
}

View File

@ -8,76 +8,75 @@ import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.configuration.DB;
/**
* This class generates sample data for manual testing purposes.
*/
/** This class generates sample data for manual testing purposes. */
public class SampleDataGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(SampleDataGenerator.class);
private static final String TEST_DATA = "/sql.sample-data";
private static final String CLEAR = TEST_DATA + "/clear-db.sql";
private static final String HISTORY_EVENT = TEST_DATA + "/history-event.sql";
private ScriptRunner runner;
private static final Logger LOGGER = LoggerFactory.getLogger(SampleDataGenerator.class);
private static final String TEST_DATA = "/sql.sample-data";
private static final String CLEAR = TEST_DATA + "/clear-db.sql";
private static final String HISTORY_EVENT = TEST_DATA + "/history-event.sql";
DataSource dataSource;
String dbProductName;
private ScriptRunner runner;
DataSource dataSource;
String dbProductName;
public SampleDataGenerator(DataSource dataSource) throws SQLException {
try (Connection connection = dataSource.getConnection()) {
dbProductName = connection.getMetaData().getDatabaseProductName();
if (LOGGER.isTraceEnabled()) {
String msg = connection.getMetaData().toString();
LOGGER.trace(msg);
}
}
this.dataSource = dataSource;
public SampleDataGenerator(DataSource dataSource) throws SQLException {
try (Connection connection = dataSource.getConnection()) {
dbProductName = connection.getMetaData().getDatabaseProductName();
if (LOGGER.isTraceEnabled()) {
String msg = connection.getMetaData().toString();
LOGGER.trace(msg);
}
}
this.dataSource = dataSource;
runner = new ScriptRunner(dataSource.getConnection());
}
runner = new ScriptRunner(dataSource.getConnection());
public void generateSampleData(String schemaName) {
StringWriter outWriter = new StringWriter();
PrintWriter logWriter = new PrintWriter(outWriter);
StringWriter errorWriter = new StringWriter();
PrintWriter errorLogWriter = new PrintWriter(errorWriter);
try {
runner.runScript(selectSchemaScript(dbProductName, schemaName));
runner.setStopOnError(false);
runner.runScript(
new BufferedReader(
new InputStreamReader(
this.getClass().getResourceAsStream(CLEAR), StandardCharsets.UTF_8)));
} catch (Exception e) {
LOGGER.error("caught Exception {}", e, e);
}
public void generateSampleData(String schemaName) {
StringWriter outWriter = new StringWriter();
PrintWriter logWriter = new PrintWriter(outWriter);
runner.setStopOnError(true);
runner.setLogWriter(logWriter);
runner.setErrorLogWriter(errorLogWriter);
StringWriter errorWriter = new StringWriter();
PrintWriter errorLogWriter = new PrintWriter(errorWriter);
try {
runner.runScript(selectSchemaScript(dbProductName, schemaName));
runner.setStopOnError(false);
runner.runScript(new BufferedReader(
new InputStreamReader(this.getClass().getResourceAsStream(CLEAR), StandardCharsets.UTF_8)));
} catch (Exception e) {
LOGGER.error("caught Exception {}", e, e);
}
runner.runScript(
new BufferedReader(
new InputStreamReader(
this.getClass().getResourceAsStream(HISTORY_EVENT), StandardCharsets.UTF_8)));
runner.setStopOnError(true);
runner.setLogWriter(logWriter);
runner.setErrorLogWriter(errorLogWriter);
runner.closeConnection();
runner.runScript(new BufferedReader(
new InputStreamReader(this.getClass().getResourceAsStream(HISTORY_EVENT), StandardCharsets.UTF_8)));
runner.closeConnection();
LOGGER.trace(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
LOGGER.trace(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
}
private StringReader selectSchemaScript(String dbProductName, String schemaName) {
return new StringReader(DB.isPostgreSQL(dbProductName)
private StringReader selectSchemaScript(String dbProductName, String schemaName) {
return new StringReader(
DB.isPostgreSQL(dbProductName)
? "SET search_path TO " + schemaName + ";"
: "SET SCHEMA " + schemaName + ";");
}
}
}

View File

@ -1,9 +1,7 @@
package pro.taskana.rest;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
@ -21,48 +19,47 @@ import org.springframework.transaction.PlatformTransactionManager;
import pro.taskana.rest.simplehistory.TaskHistoryRestConfiguration;
import pro.taskana.rest.simplehistory.sampledata.SampleDataGenerator;
/**
* Example Application to create the documentation.
*/
/** Example Application to create the documentation. */
@SpringBootApplication
@ComponentScan(basePackages = "pro.taskana.rest.simplehistory")
@Import({TaskHistoryRestConfiguration.class})
public class ExampleDocumentationApplication {
@Value("${taskana.schemaName:TASKANA}")
private String schemaName;
@Value("${taskana.schemaName:TASKANA}")
private String schemaName;
@Autowired
private SampleDataGenerator sampleDataGenerator;
@Autowired private SampleDataGenerator sampleDataGenerator;
public static void main(String[] args) {
SpringApplication.run(ExampleDocumentationApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(ExampleDocumentationApplication.class, args);
}
@Bean
@Primary
@ConfigurationProperties(prefix = "datasource")
public DataSourceProperties dataSourceProperties() {
DataSourceProperties props = new DataSourceProperties();
props.setUrl("jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS " + schemaName);
return props;
}
@Bean
@Primary
@ConfigurationProperties(prefix = "datasource")
public DataSourceProperties dataSourceProperties() {
DataSourceProperties props = new DataSourceProperties();
props.setUrl(
"jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0;INIT=CREATE SCHEMA IF NOT EXISTS "
+ schemaName);
return props;
}
@Bean
public DataSource dataSource(DataSourceProperties properties) {
return properties.initializeDataSourceBuilder().build();
}
@Bean
public DataSource dataSource(DataSourceProperties properties) {
return properties.initializeDataSourceBuilder().build();
}
@Bean
public PlatformTransactionManager txManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean
public PlatformTransactionManager txManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}
@Bean
@DependsOn("getTaskanaEngine") // generate sample data after schema was inserted
public SampleDataGenerator generateSampleData(DataSource dataSource) throws SQLException {
sampleDataGenerator = new SampleDataGenerator(dataSource);
sampleDataGenerator.generateSampleData(schemaName);
return sampleDataGenerator;
}
@Bean
@DependsOn("getTaskanaEngine") // generate sample data after schema was inserted
public SampleDataGenerator generateSampleData(DataSource dataSource) throws SQLException {
sampleDataGenerator = new SampleDataGenerator(dataSource);
sampleDataGenerator.generateSampleData(schemaName);
return sampleDataGenerator;
}
}

View File

@ -5,12 +5,12 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.util.Collections;
import javax.sql.DataSource;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -35,171 +35,176 @@ import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.exceptions.SystemException;
import pro.taskana.rest.resource.TaskHistoryEventListResource;
import pro.taskana.rest.simplehistory.TaskHistoryRestConfiguration;
import pro.taskana.rest.simplehistory.sampledata.SampleDataGenerator;
/**
* Controller for integration test.
*/
/** Controller for integration test. */
@EnableAutoConfiguration
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {TaskHistoryRestConfiguration.class},
@SpringBootTest(
classes = {TaskHistoryRestConfiguration.class},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TaskHistoryEventControllerIntTest {
@Value("${taskana.schemaName:TASKANA}")
public String schemaName;
private static final Logger LOGGER =
LoggerFactory.getLogger(TaskHistoryEventControllerIntTest.class);
@Value("${taskana.schemaName:TASKANA}")
public String schemaName;
String server = "http://127.0.0.1:";
private static final Logger LOGGER = LoggerFactory.getLogger(TaskHistoryEventControllerIntTest.class);
RestTemplate template;
String server = "http://127.0.0.1:";
HttpEntity<String> request;
RestTemplate template;
@LocalServerPort int port;
HttpEntity<String> request;
@Autowired private DataSource dataSource;
@LocalServerPort
int port;
@Autowired
private DataSource dataSource;
@Before
public void before() {
template = getRestTemplate();
SampleDataGenerator sampleDataGenerator;
try {
sampleDataGenerator = new SampleDataGenerator(dataSource);
sampleDataGenerator.generateSampleData(schemaName);
} catch (SQLException e) {
throw new SystemException("tried to reset DB and caught Exception " + e, e);
}
@Before
public void before() {
template = getRestTemplate();
SampleDataGenerator sampleDataGenerator;
try {
sampleDataGenerator = new SampleDataGenerator(dataSource);
sampleDataGenerator.generateSampleData(schemaName);
} catch (SQLException e) {
throw new SystemException("tried to reset DB and caught Exception " + e, e);
}
}
@Test
public void testGetAllHistoryEvent() {
ResponseEntity<TaskHistoryEventListResource> response = template.exchange(
server + port + "/api/v1/task-history-event", HttpMethod.GET, request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {
});
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(50, response.getBody().getContent().size());
}
@Test
public void testGetAllHistoryEvent() {
ResponseEntity<TaskHistoryEventListResource> response =
template.exchange(
server + port + "/api/v1/task-history-event",
HttpMethod.GET,
request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {});
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(50, response.getBody().getContent().size());
}
@Test
public void testGetAllHistoryEventDescendingOrder() {
String parameters = "/api/v1/task-history-event?sort-by=business-process-id&order=desc&page-size=3&page=1";
ResponseEntity<TaskHistoryEventListResource> response = template.exchange(
server + port + parameters, HttpMethod.GET, request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {
});
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(3, response.getBody().getContent().size());
assertTrue(response.getBody()
.getLink(Link.REL_SELF)
.getHref()
.endsWith(parameters));
}
@Test
public void testGetAllHistoryEventDescendingOrder() {
String parameters =
"/api/v1/task-history-event?sort-by=business-process-id&order=desc&page-size=3&page=1";
ResponseEntity<TaskHistoryEventListResource> response =
template.exchange(
server + port + parameters,
HttpMethod.GET,
request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {});
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(3, response.getBody().getContent().size());
assertTrue(response.getBody().getLink(Link.REL_SELF).getHref().endsWith(parameters));
}
@Test
public void testGetSpecificTaskHistoryEvent() {
ResponseEntity<TaskHistoryEventListResource> response = template.exchange(
server + port
@Test
public void testGetSpecificTaskHistoryEvent() {
ResponseEntity<TaskHistoryEventListResource> response =
template.exchange(
server
+ port
+ "/api/v1/task-history-event?business-process-id=BPI:01&sort-by=business-process-id&order=asc&page-size=6&page=1",
HttpMethod.GET, request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {
HttpMethod.GET,
request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {});
});
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertNotNull(response.getBody().getLinks());
assertNotNull(response.getBody().getMetadata());
assertEquals(1, response.getBody().getContent().size());
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertNotNull(response.getBody().getLinks());
assertNotNull(response.getBody().getMetadata());
assertEquals(1, response.getBody().getContent().size());
}
@Test
public void testThrowsExceptionIfInvalidFilterIsUsed() {
try {
template.exchange(
server + port + "/api/v1/task-history-event?invalid=BPI:01",
HttpMethod.GET,
request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {});
fail();
} catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
assertTrue(e.getResponseBodyAsString().contains("[invalid]"));
}
}
@Test
public void testGetHistoryEventOfDate() {
String currentTime = LocalDateTime.now().toString();
try {
template.exchange(
server + port + "/api/v1/task-history-event?created=" + currentTime,
HttpMethod.GET,
request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {});
fail();
} catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
assertTrue(e.getResponseBodyAsString().contains(currentTime));
}
@Test
public void testThrowsExceptionIfInvalidFilterIsUsed() {
try {
template.exchange(
server + port + "/api/v1/task-history-event?invalid=BPI:01", HttpMethod.GET, request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {
});
fail();
} catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
assertTrue(e.getResponseBodyAsString().contains("[invalid]"));
}
}
// correct Format 'yyyy-MM-dd'
currentTime = currentTime.substring(0, 10);
ResponseEntity<TaskHistoryEventListResource> response =
template.exchange(
server + port + "/api/v1/task-history-event?created=" + currentTime,
HttpMethod.GET,
request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {});
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(25, response.getBody().getContent().size());
}
@Test
public void testGetHistoryEventOfDate() {
String currentTime = LocalDateTime.now().toString();
@Test
public void testGetSecondPageSortedByKey() {
String parameters =
"/api/v1/task-history-event?sort-by=workbasket-key&order=desc&page=2&page-size=2";
ResponseEntity<TaskHistoryEventListResource> response =
template.exchange(
server + port + parameters,
HttpMethod.GET,
request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {});
try {
template.exchange(
server + port + "/api/v1/task-history-event?created=" + currentTime, HttpMethod.GET, request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {
});
fail();
} catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
assertTrue(e.getResponseBodyAsString().contains(currentTime));
}
// correct Format 'yyyy-MM-dd'
currentTime = currentTime.substring(0, 10);
ResponseEntity<TaskHistoryEventListResource> response = template.exchange(
server + port + "/api/v1/task-history-event?created=" + currentTime, HttpMethod.GET, request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {
});
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertEquals(25, response.getBody().getContent().size());
}
@Test
public void testGetSecondPageSortedByKey() {
String parameters = "/api/v1/task-history-event?sort-by=workbasket-key&order=desc&page=2&page-size=2";
ResponseEntity<TaskHistoryEventListResource> response = template.exchange(
server + port + parameters, HttpMethod.GET, request,
new ParameterizedTypeReference<TaskHistoryEventListResource>() {
});
assertEquals(2, response.getBody().getContent().size());
assertEquals("WBI:100000000000000000000000000000000002",
response.getBody().getContent().iterator().next().getWorkbasketKey());
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertTrue(response.getBody()
.getLink(Link.REL_SELF)
.getHref()
.endsWith(parameters));
assertNotNull(response.getBody().getLink("allTaskHistoryEvent"));
assertTrue(response.getBody()
assertEquals(2, response.getBody().getContent().size());
assertEquals(
"WBI:100000000000000000000000000000000002",
response.getBody().getContent().iterator().next().getWorkbasketKey());
assertNotNull(response.getBody().getLink(Link.REL_SELF));
assertTrue(response.getBody().getLink(Link.REL_SELF).getHref().endsWith(parameters));
assertNotNull(response.getBody().getLink("allTaskHistoryEvent"));
assertTrue(
response
.getBody()
.getLink("allTaskHistoryEvent")
.getHref()
.endsWith("/api/v1/task-history-event"));
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
assertNotNull(response.getBody().getLink(Link.REL_LAST));
}
assertNotNull(response.getBody().getLink(Link.REL_FIRST));
assertNotNull(response.getBody().getLink(Link.REL_LAST));
}
/**
* Return a REST template which is capable of dealing with responses in HAL format.
*
* @return RestTemplate
*/
private RestTemplate getRestTemplate() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new Jackson2HalModule());
/**
* Return a REST template which is capable of dealing with responses in HAL format.
*
* @return RestTemplate
*/
private RestTemplate getRestTemplate() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new Jackson2HalModule());
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
converter.setObjectMapper(mapper);
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
return template;
}
RestTemplate template =
new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));
return template;
}
}

View File

@ -10,7 +10,6 @@ import static org.springframework.restdocs.payload.PayloadDocumentation.response
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
import java.util.HashMap;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -30,168 +29,177 @@ import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.simplehistory.TaskHistoryRestConfiguration;
/**
* Generate documentation for the history event controller.
*/
/** Generate documentation for the history event controller. */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TaskHistoryRestConfiguration.class,
@SpringBootTest(
classes = TaskHistoryRestConfiguration.class,
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TaskHistoryEventControllerRestDocumentation {
@LocalServerPort
int port;
@Rule public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
@LocalServerPort int port;
@Autowired private WebApplicationContext context;
@Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
private MockMvc mockMvc;
@Autowired
private WebApplicationContext context;
private HashMap<String, String> taskHistoryEventFieldDescriptionsMap =
new HashMap<String, String>();
private MockMvc mockMvc;
private FieldDescriptor[] allTaskHistoryEventFieldDescriptors;
private HashMap<String, String> taskHistoryEventFieldDescriptionsMap = new HashMap<String, String>();
private FieldDescriptor[] taskHistoryEventFieldDescriptors;
private FieldDescriptor[] allTaskHistoryEventFieldDescriptors;
@Before
public void setUp() {
document("{methodName}", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()));
private FieldDescriptor[] taskHistoryEventFieldDescriptors;
@Before
public void setUp() {
document("{methodName}",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()));
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(documentationConfiguration(this.restDocumentation)
.operationPreprocessors()
.withResponseDefaults(prettyPrint())
.withRequestDefaults(prettyPrint()))
this.mockMvc =
MockMvcBuilders.webAppContextSetup(this.context)
.apply(
documentationConfiguration(this.restDocumentation)
.operationPreprocessors()
.withResponseDefaults(prettyPrint())
.withRequestDefaults(prettyPrint()))
.build();
taskHistoryEventFieldDescriptionsMap.put("taskHistoryId", "Unique ID");
taskHistoryEventFieldDescriptionsMap.put("businessProcessId", "The id of the business process");
taskHistoryEventFieldDescriptionsMap.put("parentBusinessProcessId",
"The id of the parent business process");
taskHistoryEventFieldDescriptionsMap.put("taskId", "The id of the task");
taskHistoryEventFieldDescriptionsMap.put("eventType", "The type of the event");
taskHistoryEventFieldDescriptionsMap.put("created", "The time was created");
taskHistoryEventFieldDescriptionsMap.put("userId", "The id of the user");
taskHistoryEventFieldDescriptionsMap.put("domain", "Domain");
taskHistoryEventFieldDescriptionsMap.put("workbasketKey", "The key of workbasket");
taskHistoryEventFieldDescriptionsMap.put("porCompany", "");
taskHistoryEventFieldDescriptionsMap.put("porSystem", "");
taskHistoryEventFieldDescriptionsMap.put("porInstance", "");
taskHistoryEventFieldDescriptionsMap.put("porValue", "");
taskHistoryEventFieldDescriptionsMap.put("porType", "");
taskHistoryEventFieldDescriptionsMap.put("taskClassificationKey", "The key of classification task");
taskHistoryEventFieldDescriptionsMap.put("taskClassificationCategory",
"The category of classification");
taskHistoryEventFieldDescriptionsMap.put("attachmentClassificationKey", "");
taskHistoryEventFieldDescriptionsMap.put("comment", "");
taskHistoryEventFieldDescriptionsMap.put("oldValue", "The old value");
taskHistoryEventFieldDescriptionsMap.put("newValue", "The new value");
taskHistoryEventFieldDescriptionsMap.put("custom1", "A custom property with name \"1\"");
taskHistoryEventFieldDescriptionsMap.put("custom2", "A custom property with name \"2\"");
taskHistoryEventFieldDescriptionsMap.put("custom3", "A custom property with name \"3\"");
taskHistoryEventFieldDescriptionsMap.put("custom4", "A custom property with name \"4\"");
taskHistoryEventFieldDescriptionsMap.put("oldData", "The old data");
taskHistoryEventFieldDescriptionsMap.put("newData", "The new data");
taskHistoryEventFieldDescriptionsMap.put("_links.self.href", "The links of this task history event");
taskHistoryEventFieldDescriptionsMap.put("_links.allTaskHistoryEvent.href", "Link to all task history event");
taskHistoryEventFieldDescriptionsMap.put("_links.first.href", "Link to the first result");
taskHistoryEventFieldDescriptionsMap.put("_links.last.href", "Link to the last result");
taskHistoryEventFieldDescriptionsMap.put("taskHistoryId", "Unique ID");
taskHistoryEventFieldDescriptionsMap.put("businessProcessId", "The id of the business process");
taskHistoryEventFieldDescriptionsMap.put(
"parentBusinessProcessId", "The id of the parent business process");
taskHistoryEventFieldDescriptionsMap.put("taskId", "The id of the task");
taskHistoryEventFieldDescriptionsMap.put("eventType", "The type of the event");
taskHistoryEventFieldDescriptionsMap.put("created", "The time was created");
taskHistoryEventFieldDescriptionsMap.put("userId", "The id of the user");
taskHistoryEventFieldDescriptionsMap.put("domain", "Domain");
taskHistoryEventFieldDescriptionsMap.put("workbasketKey", "The key of workbasket");
taskHistoryEventFieldDescriptionsMap.put("porCompany", "");
taskHistoryEventFieldDescriptionsMap.put("porSystem", "");
taskHistoryEventFieldDescriptionsMap.put("porInstance", "");
taskHistoryEventFieldDescriptionsMap.put("porValue", "");
taskHistoryEventFieldDescriptionsMap.put("porType", "");
taskHistoryEventFieldDescriptionsMap.put(
"taskClassificationKey", "The key of classification task");
taskHistoryEventFieldDescriptionsMap.put(
"taskClassificationCategory", "The category of classification");
taskHistoryEventFieldDescriptionsMap.put("attachmentClassificationKey", "");
taskHistoryEventFieldDescriptionsMap.put("comment", "");
taskHistoryEventFieldDescriptionsMap.put("oldValue", "The old value");
taskHistoryEventFieldDescriptionsMap.put("newValue", "The new value");
taskHistoryEventFieldDescriptionsMap.put("custom1", "A custom property with name \"1\"");
taskHistoryEventFieldDescriptionsMap.put("custom2", "A custom property with name \"2\"");
taskHistoryEventFieldDescriptionsMap.put("custom3", "A custom property with name \"3\"");
taskHistoryEventFieldDescriptionsMap.put("custom4", "A custom property with name \"4\"");
taskHistoryEventFieldDescriptionsMap.put("oldData", "The old data");
taskHistoryEventFieldDescriptionsMap.put("newData", "The new data");
taskHistoryEventFieldDescriptionsMap.put(
"_links.self.href", "The links of this task history event");
taskHistoryEventFieldDescriptionsMap.put(
"_links.allTaskHistoryEvent.href", "Link to all task history event");
taskHistoryEventFieldDescriptionsMap.put("_links.first.href", "Link to the first result");
taskHistoryEventFieldDescriptionsMap.put("_links.last.href", "Link to the last result");
allTaskHistoryEventFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("taskHistoryEvents").description("An array of Task history event"),
fieldWithPath("_links.allTaskHistoryEvent.href").ignored(),
fieldWithPath("_links.self.href").ignored(),
fieldWithPath("_links.first.href").ignored(),
fieldWithPath("_links.last.href").ignored(),
fieldWithPath("_links.next.href").ignored(),
fieldWithPath("page.size").ignored(),
fieldWithPath("page.totalElements").ignored(),
fieldWithPath("page.totalPages").ignored(),
fieldWithPath("page.number").ignored()
allTaskHistoryEventFieldDescriptors =
new FieldDescriptor[] {
subsectionWithPath("taskHistoryEvents").description("An array of Task history event"),
fieldWithPath("_links.allTaskHistoryEvent.href").ignored(),
fieldWithPath("_links.self.href").ignored(),
fieldWithPath("_links.first.href").ignored(),
fieldWithPath("_links.last.href").ignored(),
fieldWithPath("_links.next.href").ignored(),
fieldWithPath("page.size").ignored(),
fieldWithPath("page.totalElements").ignored(),
fieldWithPath("page.totalPages").ignored(),
fieldWithPath("page.number").ignored()
};
taskHistoryEventFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("taskHistoryEvents[].taskHistoryId").description(
taskHistoryEventFieldDescriptionsMap.get("taskHistoryId")),
fieldWithPath("taskHistoryEvents[].businessProcessId").description(
taskHistoryEventFieldDescriptionsMap.get("businessProcessId")),
fieldWithPath("taskHistoryEvents[].parentBusinessProcessId").description(
taskHistoryEventFieldDescriptionsMap.get("parentBusinessProcessId")),
fieldWithPath("taskHistoryEvents[].taskId").description(
taskHistoryEventFieldDescriptionsMap.get("taskId")),
fieldWithPath("taskHistoryEvents[].eventType").description(
taskHistoryEventFieldDescriptionsMap.get("eventType")),
fieldWithPath("taskHistoryEvents[].created").description(
taskHistoryEventFieldDescriptionsMap.get("created")),
fieldWithPath("taskHistoryEvents[].userId").description(
taskHistoryEventFieldDescriptionsMap.get("userId")),
fieldWithPath("taskHistoryEvents[].domain").description(
taskHistoryEventFieldDescriptionsMap.get("domain")),
fieldWithPath("taskHistoryEvents[].workbasketKey").description(
taskHistoryEventFieldDescriptionsMap.get("workbasketKey")),
fieldWithPath("taskHistoryEvents[].porCompany").description(
taskHistoryEventFieldDescriptionsMap.get("porCompany")),
fieldWithPath("taskHistoryEvents[].porSystem").description(
taskHistoryEventFieldDescriptionsMap.get("porSystem")),
fieldWithPath("taskHistoryEvents[].porInstance").description(
taskHistoryEventFieldDescriptionsMap.get("porInstance")),
fieldWithPath("taskHistoryEvents[].porValue").description(
taskHistoryEventFieldDescriptionsMap.get("porValue")),
fieldWithPath("taskHistoryEvents[].porType").description(
taskHistoryEventFieldDescriptionsMap.get("porType")),
fieldWithPath("taskHistoryEvents[].taskClassificationKey").description(
taskHistoryEventFieldDescriptionsMap.get("taskClassificationKey")),
fieldWithPath("taskHistoryEvents[].taskClassificationCategory").description(
taskHistoryEventFieldDescriptionsMap.get("taskClassificationCategory")),
fieldWithPath("taskHistoryEvents[].attachmentClassificationKey").description(
taskHistoryEventFieldDescriptionsMap.get("attachmentClassificationKey")),
fieldWithPath("taskHistoryEvents[].comment").description(
taskHistoryEventFieldDescriptionsMap.get("comment")),
fieldWithPath("taskHistoryEvents[].oldValue").description(
taskHistoryEventFieldDescriptionsMap.get("oldValue")),
fieldWithPath("taskHistoryEvents[].newValue").description(
taskHistoryEventFieldDescriptionsMap.get("newValue")),
fieldWithPath("taskHistoryEvents[].custom1").description(
taskHistoryEventFieldDescriptionsMap.get("custom1")),
fieldWithPath("taskHistoryEvents[].custom2").description(
taskHistoryEventFieldDescriptionsMap.get("custom2")),
fieldWithPath("taskHistoryEvents[].custom3").description(
taskHistoryEventFieldDescriptionsMap.get("custom3")),
fieldWithPath("taskHistoryEvents[].custom4").description(
taskHistoryEventFieldDescriptionsMap.get("custom4")),
fieldWithPath("taskHistoryEvents[].oldData").description(
taskHistoryEventFieldDescriptionsMap.get("oldData")),
fieldWithPath("taskHistoryEvents[].newData").description(
taskHistoryEventFieldDescriptionsMap.get("newData")),
fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored()
taskHistoryEventFieldDescriptors =
new FieldDescriptor[] {
fieldWithPath("taskHistoryEvents[].taskHistoryId")
.description(taskHistoryEventFieldDescriptionsMap.get("taskHistoryId")),
fieldWithPath("taskHistoryEvents[].businessProcessId")
.description(taskHistoryEventFieldDescriptionsMap.get("businessProcessId")),
fieldWithPath("taskHistoryEvents[].parentBusinessProcessId")
.description(taskHistoryEventFieldDescriptionsMap.get("parentBusinessProcessId")),
fieldWithPath("taskHistoryEvents[].taskId")
.description(taskHistoryEventFieldDescriptionsMap.get("taskId")),
fieldWithPath("taskHistoryEvents[].eventType")
.description(taskHistoryEventFieldDescriptionsMap.get("eventType")),
fieldWithPath("taskHistoryEvents[].created")
.description(taskHistoryEventFieldDescriptionsMap.get("created")),
fieldWithPath("taskHistoryEvents[].userId")
.description(taskHistoryEventFieldDescriptionsMap.get("userId")),
fieldWithPath("taskHistoryEvents[].domain")
.description(taskHistoryEventFieldDescriptionsMap.get("domain")),
fieldWithPath("taskHistoryEvents[].workbasketKey")
.description(taskHistoryEventFieldDescriptionsMap.get("workbasketKey")),
fieldWithPath("taskHistoryEvents[].porCompany")
.description(taskHistoryEventFieldDescriptionsMap.get("porCompany")),
fieldWithPath("taskHistoryEvents[].porSystem")
.description(taskHistoryEventFieldDescriptionsMap.get("porSystem")),
fieldWithPath("taskHistoryEvents[].porInstance")
.description(taskHistoryEventFieldDescriptionsMap.get("porInstance")),
fieldWithPath("taskHistoryEvents[].porValue")
.description(taskHistoryEventFieldDescriptionsMap.get("porValue")),
fieldWithPath("taskHistoryEvents[].porType")
.description(taskHistoryEventFieldDescriptionsMap.get("porType")),
fieldWithPath("taskHistoryEvents[].taskClassificationKey")
.description(taskHistoryEventFieldDescriptionsMap.get("taskClassificationKey")),
fieldWithPath("taskHistoryEvents[].taskClassificationCategory")
.description(taskHistoryEventFieldDescriptionsMap.get("taskClassificationCategory")),
fieldWithPath("taskHistoryEvents[].attachmentClassificationKey")
.description(taskHistoryEventFieldDescriptionsMap.get("attachmentClassificationKey")),
fieldWithPath("taskHistoryEvents[].comment")
.description(taskHistoryEventFieldDescriptionsMap.get("comment")),
fieldWithPath("taskHistoryEvents[].oldValue")
.description(taskHistoryEventFieldDescriptionsMap.get("oldValue")),
fieldWithPath("taskHistoryEvents[].newValue")
.description(taskHistoryEventFieldDescriptionsMap.get("newValue")),
fieldWithPath("taskHistoryEvents[].custom1")
.description(taskHistoryEventFieldDescriptionsMap.get("custom1")),
fieldWithPath("taskHistoryEvents[].custom2")
.description(taskHistoryEventFieldDescriptionsMap.get("custom2")),
fieldWithPath("taskHistoryEvents[].custom3")
.description(taskHistoryEventFieldDescriptionsMap.get("custom3")),
fieldWithPath("taskHistoryEvents[].custom4")
.description(taskHistoryEventFieldDescriptionsMap.get("custom4")),
fieldWithPath("taskHistoryEvents[].oldData")
.description(taskHistoryEventFieldDescriptionsMap.get("oldData")),
fieldWithPath("taskHistoryEvents[].newData")
.description(taskHistoryEventFieldDescriptionsMap.get("newData")),
fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored()
};
}
}
@Test
public void getAllTaskHistoryEventDocTest() throws Exception {
this.mockMvc.perform(
@Test
public void getAllTaskHistoryEventDocTest() throws Exception {
this.mockMvc
.perform(
RestDocumentationRequestBuilders.get(
"http://127.0.0.1:" + port + "/api/v1/task-history-event?page=1&page-size=3")
"http://127.0.0.1:" + port + "/api/v1/task-history-event?page=1&page-size=3")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllTaskHistoryEventDocTest",
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(
MockMvcRestDocumentation.document(
"GetAllTaskHistoryEventDocTest",
responseFields(allTaskHistoryEventFieldDescriptors)));
}
}
@Test
public void getSpecificTaskHistoryEventDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders.get(
"http://127.0.0.1:" + port + "/api/v1/task-history-event?business-process-id=BPI:02")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetSpecificTaskHistoryEventDocTest",
@Test
public void getSpecificTaskHistoryEventDocTest() throws Exception {
this.mockMvc
.perform(
RestDocumentationRequestBuilders.get(
"http://127.0.0.1:"
+ port
+ "/api/v1/task-history-event?business-process-id=BPI:02")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk())
.andDo(
MockMvcRestDocumentation.document(
"GetSpecificTaskHistoryEventDocTest",
responseFields(taskHistoryEventFieldDescriptors)));
}
}
}

View File

@ -15,37 +15,33 @@ import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
/**
* Example Bootstrap Application.
*/
/** Example Bootstrap Application. */
@ApplicationScoped
public class ExampleBootstrap {
@EJB
private TaskanaEjb taskanaEjb;
@PostConstruct
public void init(@Observes @Initialized(ApplicationScoped.class) Object init)
throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, InvalidStateException, InvalidOwnerException, TaskAlreadyExistException,
InvalidArgumentException {
System.out.println("---------------------------> Start App");
Task task = taskanaEjb.getTaskService().newTask(null);
ObjectReference objRef = new ObjectReference();
objRef.setCompany("aCompany");
objRef.setSystem("aSystem");
objRef.setSystemInstance("anInstance");
objRef.setType("aType");
objRef.setValue("aValue");
task.setPrimaryObjRef(objRef);
task = taskanaEjb.getTaskService().createTask(task);
System.out.println("---------------------------> Task started: " + task.getId());
taskanaEjb.getTaskService().claim(task.getId());
System.out.println(
"---------------------------> Task claimed: "
+ taskanaEjb.getTaskService().getTask(task.getId()).getOwner());
taskanaEjb.getTaskService().completeTask(task.getId());
System.out.println("---------------------------> Task completed");
}
@EJB private TaskanaEjb taskanaEjb;
@PostConstruct
public void init(@Observes @Initialized(ApplicationScoped.class) Object init)
throws TaskNotFoundException, NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, InvalidStateException, InvalidOwnerException,
TaskAlreadyExistException, InvalidArgumentException {
System.out.println("---------------------------> Start App");
Task task = taskanaEjb.getTaskService().newTask(null);
ObjectReference objRef = new ObjectReference();
objRef.setCompany("aCompany");
objRef.setSystem("aSystem");
objRef.setSystemInstance("anInstance");
objRef.setType("aType");
objRef.setValue("aValue");
task.setPrimaryObjRef(objRef);
task = taskanaEjb.getTaskService().createTask(task);
System.out.println("---------------------------> Task started: " + task.getId());
taskanaEjb.getTaskService().claim(task.getId());
System.out.println(
"---------------------------> Task claimed: "
+ taskanaEjb.getTaskService().getTask(task.getId()).getOwner());
taskanaEjb.getTaskService().completeTask(task.getId());
System.out.println("---------------------------> Task completed");
}
}

View File

@ -3,16 +3,13 @@ package pro.taskana;
import javax.ejb.Stateless;
import javax.inject.Inject;
/**
* example Taskana EJB.
*/
/** example Taskana EJB. */
@Stateless
public class TaskanaEjb {
@Inject
private TaskService taskService;
@Inject private TaskService taskService;
public TaskService getTaskService() {
return taskService;
}
public TaskService getTaskService() {
return taskService;
}
}

View File

@ -6,7 +6,6 @@ import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
import java.util.Properties;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
@ -15,71 +14,67 @@ import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.configuration.TaskanaEngineConfiguration;
/**
* TODO.
*/
/** TODO. */
@ApplicationScoped
public class TaskanaProducers {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaProducers.class);
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaProducers.class);
private static final String TASKANA_PROPERTIES = "taskana.properties";
private static final String TASKANA_PROPERTIES = "taskana.properties";
@Inject
private TaskanaEngine taskanaEngine;
@Inject private TaskanaEngine taskanaEngine;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
private TaskanaEngineConfiguration taskanaEngineConfiguration;
@PostConstruct
public void init() {
// Load Properties and get Datasource via Context
// Load DataSource via Container
Context ctx;
DataSource dataSource;
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
try (InputStream propertyStream = classloader.getResourceAsStream(TASKANA_PROPERTIES)) {
Properties properties = new Properties();
ctx = new InitialContext();
properties.load(propertyStream);
dataSource = (DataSource) ctx.lookup(properties.getProperty("datasource.jndi"));
try (Connection connection = dataSource.getConnection()) {
DatabaseMetaData metaData = connection.getMetaData();
LOGGER.debug("---------------> " + metaData);
}
this.taskanaEngineConfiguration = new TaskanaEngineConfiguration(dataSource, true, false, "TASKANA");
} catch (NamingException | SQLException | IOException e) {
LOGGER.error("Could not start Taskana: ", e);
}
@PostConstruct
public void init() {
// Load Properties and get Datasource via Context
// Load DataSource via Container
Context ctx;
DataSource dataSource;
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
try (InputStream propertyStream = classloader.getResourceAsStream(TASKANA_PROPERTIES)) {
Properties properties = new Properties();
ctx = new InitialContext();
properties.load(propertyStream);
dataSource = (DataSource) ctx.lookup(properties.getProperty("datasource.jndi"));
try (Connection connection = dataSource.getConnection()) {
DatabaseMetaData metaData = connection.getMetaData();
LOGGER.debug("---------------> " + metaData);
}
this.taskanaEngineConfiguration =
new TaskanaEngineConfiguration(dataSource, true, false, "TASKANA");
} catch (NamingException | SQLException | IOException e) {
LOGGER.error("Could not start Taskana: ", e);
}
}
@ApplicationScoped
@Produces
public TaskanaEngine generateTaskEngine() {
return taskanaEngineConfiguration.buildTaskanaEngine();
}
@ApplicationScoped
@Produces
public TaskanaEngine generateTaskEngine() {
return taskanaEngineConfiguration.buildTaskanaEngine();
}
@ApplicationScoped
@Produces
public TaskService generateTaskService() {
return taskanaEngine.getTaskService();
}
@ApplicationScoped
@Produces
public TaskService generateTaskService() {
return taskanaEngine.getTaskService();
}
@ApplicationScoped
@Produces
public ClassificationService generateClassificationService() {
return taskanaEngine.getClassificationService();
}
@ApplicationScoped
@Produces
public WorkbasketService generateWorkbasketService() {
return taskanaEngine.getWorkbasketService();
}
@ApplicationScoped
@Produces
public ClassificationService generateClassificationService() {
return taskanaEngine.getClassificationService();
}
@ApplicationScoped
@Produces
public WorkbasketService generateWorkbasketService() {
return taskanaEngine.getWorkbasketService();
}
}

View File

@ -3,9 +3,6 @@ package pro.taskana;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
/**
* TODO Why does this test exist?
*/
/** TODO Why does this test exist? */
@ApplicationPath("/rest")
public class RestApplication extends Application {
}
public class RestApplication extends Application {}

View File

@ -9,47 +9,42 @@ import pro.taskana.exceptions.NotAuthorizedException;
import pro.taskana.exceptions.TaskAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
/**
* TODO.
*/
/** TODO. */
@Stateless
public class TaskanaEjb {
@Inject
private TaskService taskService;
@Inject private TaskService taskService;
@Inject
private ClassificationService classificationService;
@Inject private ClassificationService classificationService;
@Inject
private WorkbasketService workbasketService;
@Inject private WorkbasketService workbasketService;
public TaskService getTaskService() {
return taskService;
}
public TaskService getTaskService() {
return taskService;
}
public ClassificationService getClassificationService() {
return classificationService;
}
public ClassificationService getClassificationService() {
return classificationService;
}
public WorkbasketService getWorkbasketService() {
return workbasketService;
}
public WorkbasketService getWorkbasketService() {
return workbasketService;
}
public void triggerRollback() throws NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, TaskAlreadyExistException, InvalidArgumentException {
Task task = taskService.newTask(null);
ObjectReference objRef = new ObjectReference();
objRef.setCompany("aCompany");
objRef.setSystem("aSystem");
objRef.setSystemInstance("anInstance");
objRef.setType("aType");
objRef.setValue("aValue");
task.setPrimaryObjRef(objRef);
taskService.createTask(task);
System.out.println("---------------->" + task.getId());
throw new RuntimeException();
}
public void triggerRollback()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, InvalidArgumentException {
Task task = taskService.newTask(null);
ObjectReference objRef = new ObjectReference();
objRef.setCompany("aCompany");
objRef.setSystem("aSystem");
objRef.setSystemInstance("anInstance");
objRef.setType("aType");
objRef.setValue("aValue");
task.setPrimaryObjRef(objRef);
taskService.createTask(task);
System.out.println("---------------->" + task.getId());
throw new RuntimeException();
}
}

View File

@ -4,10 +4,8 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
@ -17,64 +15,66 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.swarm.undertow.WARArchive;
/**
* TODO.
*/
/** TODO. */
@RunWith(Arquillian.class)
public class TaskanaProducersTest {
@Deployment(testable = false)
public static Archive<?> createDeployment() throws Exception {
WARArchive deployment = ShrinkWrap.create(WARArchive.class);
deployment.addPackage("pro.taskana");
deployment.addClass(TaskanaProducers.class);
deployment.addAllDependencies();
deployment.addDependency("org.mybatis:mybatis:3.4.2");
deployment.addDependency("org.mybatis:mybatis-cdi:1.0.0");
deployment.addDependency("pro.taskana:taskana-core");
deployment.addAsResource("META-INF/beans.xml");
deployment.addAsResource("taskana.properties");
deployment.addAsResource("project-defaults.yml");
return deployment;
}
@Deployment(testable = false)
public static Archive<?> createDeployment() throws Exception {
WARArchive deployment = ShrinkWrap.create(WARArchive.class);
deployment.addPackage("pro.taskana");
deployment.addClass(TaskanaProducers.class);
deployment.addAllDependencies();
deployment.addDependency("org.mybatis:mybatis:3.4.2");
deployment.addDependency("org.mybatis:mybatis-cdi:1.0.0");
deployment.addDependency("pro.taskana:taskana-core");
deployment.addAsResource("META-INF/beans.xml");
deployment.addAsResource("taskana.properties");
deployment.addAsResource("project-defaults.yml");
return deployment;
}
@Test
public void testCommit() throws SQLException, ClassNotFoundException {
@Test
public void testCommit() throws SQLException, ClassNotFoundException {
Client client = ClientBuilder.newClient();
client.target("http://127.0.0.1:8090/rest/test").request().get();
Client client = ClientBuilder.newClient();
client.target("http://127.0.0.1:8090/rest/test").request().get();
Class.forName("org.h2.Driver");
int resultCount = 0;
try (Connection conn = DriverManager.getConnection(
Class.forName("org.h2.Driver");
int resultCount = 0;
try (Connection conn =
DriverManager.getConnection(
"jdbc:h2:~/taskana-h2-data/testdb;AUTO_SERVER=TRUE;IGNORECASE=TRUE;LOCK_MODE=0",
"SA", "SA")) {
ResultSet rs = conn.createStatement().executeQuery("SELECT ID, OWNER FROM TASKANA.TASK");
"SA",
"SA")) {
ResultSet rs = conn.createStatement().executeQuery("SELECT ID, OWNER FROM TASKANA.TASK");
while (rs.next()) {
resultCount++;
}
}
Assert.assertEquals(0, resultCount);
while (rs.next()) {
resultCount++;
}
}
Assert.assertEquals(0, resultCount);
}
@Test
public void testRollback() throws SQLException, ClassNotFoundException {
Client client = ClientBuilder.newClient();
client.target("http://127.0.0.1:8090/rest/test").request().post(null);
@Test
public void testRollback() throws SQLException, ClassNotFoundException {
Client client = ClientBuilder.newClient();
client.target("http://127.0.0.1:8090/rest/test").request().post(null);
Class.forName("org.h2.Driver");
int resultCount = 0;
try (Connection conn = DriverManager.getConnection(
Class.forName("org.h2.Driver");
int resultCount = 0;
try (Connection conn =
DriverManager.getConnection(
"jdbc:h2:~/taskana-h2-data/testdb;AUTO_SERVER=TRUE;IGNORECASE=TRUE;LOCK_MODE=0",
"SA", "SA")) {
ResultSet rs = conn.createStatement().executeQuery("SELECT ID, OWNER FROM TASKANA.TASK");
"SA",
"SA")) {
ResultSet rs = conn.createStatement().executeQuery("SELECT ID, OWNER FROM TASKANA.TASK");
while (rs.next()) {
resultCount++;
}
}
Assert.assertEquals(0, resultCount);
while (rs.next()) {
resultCount++;
}
}
Assert.assertEquals(0, resultCount);
}
}

View File

@ -8,7 +8,6 @@ import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -25,61 +24,60 @@ import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
/**
* TODO.
*/
/** TODO. */
@Path("/test")
public class TaskanaRestTest {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaRestTest.class);
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaRestTest.class);
@EJB
private TaskanaEjb taskanaEjb;
@EJB private TaskanaEjb taskanaEjb;
@Inject
private ClassificationService classificationService;
@Inject private ClassificationService classificationService;
@GET
public Response startTask() throws NotAuthorizedException, WorkbasketNotFoundException,
ClassificationNotFoundException, ClassificationAlreadyExistException, InvalidWorkbasketException,
TaskAlreadyExistException, InvalidArgumentException, WorkbasketAlreadyExistException, DomainNotFoundException {
Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket("key", "cdiDomain");
workbasket.setName("wb");
workbasket.setType(WorkbasketType.PERSONAL);
taskanaEjb.getWorkbasketService().createWorkbasket(workbasket);
Classification classification = classificationService.newClassification("TEST", "cdiDomain", "t1");
taskanaEjb.getClassificationService().createClassification(classification);
@GET
public Response startTask()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
ClassificationAlreadyExistException, InvalidWorkbasketException,
TaskAlreadyExistException, InvalidArgumentException, WorkbasketAlreadyExistException,
DomainNotFoundException {
Workbasket workbasket = taskanaEjb.getWorkbasketService().newWorkbasket("key", "cdiDomain");
workbasket.setName("wb");
workbasket.setType(WorkbasketType.PERSONAL);
taskanaEjb.getWorkbasketService().createWorkbasket(workbasket);
Classification classification =
classificationService.newClassification("TEST", "cdiDomain", "t1");
taskanaEjb.getClassificationService().createClassification(classification);
Task task = taskanaEjb.getTaskService().newTask(workbasket.getKey());
task.setClassificationKey(classification.getKey());
ObjectReference objRef = new ObjectReference();
objRef.setCompany("aCompany");
objRef.setSystem("aSystem");
objRef.setSystemInstance("anInstance");
objRef.setType("aType");
objRef.setValue("aValue");
task.setPrimaryObjRef(objRef);
Task task = taskanaEjb.getTaskService().newTask(workbasket.getKey());
task.setClassificationKey(classification.getKey());
ObjectReference objRef = new ObjectReference();
objRef.setCompany("aCompany");
objRef.setSystem("aSystem");
objRef.setSystemInstance("anInstance");
objRef.setType("aType");
objRef.setValue("aValue");
task.setPrimaryObjRef(objRef);
Task result = taskanaEjb.getTaskService().createTask(task);
Task result = taskanaEjb.getTaskService().createTask(task);
LOGGER.info(result.getId() + ":" + result.getOwner());
return Response.status(200).entity(result.getId()).build();
}
LOGGER.info(result.getId() + ":" + result.getOwner());
return Response.status(200).entity(result.getId()).build();
}
@POST
public Response rollbackTask()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, InvalidArgumentException {
taskanaEjb.triggerRollback();
return Response.status(204).build();
}
@DELETE
@Path("{id}")
public void completeTask(@PathParam("id") String id)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException {
LOGGER.info(id);
taskanaEjb.getTaskService().forceCompleteTask(id);
}
@POST
public Response rollbackTask()
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, InvalidArgumentException {
taskanaEjb.triggerRollback();
return Response.status(204).build();
}
@DELETE
@Path("{id}")
public void completeTask(@PathParam("id") String id)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException,
NotAuthorizedException {
LOGGER.info(id);
taskanaEjb.getTaskService().forceCompleteTask(id);
}
}

View File

@ -6,64 +6,58 @@ package pro.taskana;
* @param <Q> the actual WorkbasketAccessItemQuery behind this interface class
* @param <T> the workbasket access item
*/
public interface AbstractWorkbasketAccessItemQuery<Q extends AbstractWorkbasketAccessItemQuery<Q, T>, T extends WorkbasketAccessItem>
public interface AbstractWorkbasketAccessItemQuery<
Q extends AbstractWorkbasketAccessItemQuery<Q, T>, T extends WorkbasketAccessItem>
extends BaseQuery<T, AccessItemQueryColumnName> {
/**
* Add your unique entry id to your query as filter.
*
* @param ids
* the unique entry IDs
* @return the query
*/
Q idIn(String... ids);
/**
* Add your unique entry id to your query as filter.
*
* @param ids the unique entry IDs
* @return the query
*/
Q idIn(String... ids);
/**
* Add your workbasket id to your query.
*
* @param workbasketId
* the workbasket Id
* @return the query
*/
Q workbasketIdIn(String... workbasketId);
/**
* Add your workbasket id to your query.
*
* @param workbasketId the workbasket Id
* @return the query
*/
Q workbasketIdIn(String... workbasketId);
/**
* Add your accessIds to your query.
*
* @param accessId
* as access Ids
* @return the query
*/
Q accessIdIn(String... accessId);
/**
* Add your accessIds to your query.
*
* @param accessId as access Ids
* @return the query
*/
Q accessIdIn(String... accessId);
/**
* Sort the query result by workbasket id.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
Q orderByWorkbasketId(SortDirection sortDirection);
/**
* Sort the query result by workbasket id.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
Q orderByWorkbasketId(SortDirection sortDirection);
/**
* Sort the query result by access Id.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
Q orderByAccessId(SortDirection sortDirection);
/**
* Sort the query result by Id.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
Q orderById(SortDirection sortDirection);
/**
* Sort the query result by access Id.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
Q orderByAccessId(SortDirection sortDirection);
/**
* Sort the query result by Id.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
Q orderById(SortDirection sortDirection);
}

View File

@ -1,24 +1,25 @@
package pro.taskana;
/**
* Enum containing the column names for @see pro.taskana.mappings.QueryMapper#queryWorkbasketAccessItemColumnValues(WorkbasketAccessItemQuery).
* Enum containing the column names for @see
* pro.taskana.mappings.QueryMapper#queryWorkbasketAccessItemColumnValues(WorkbasketAccessItemQuery).
*
* @author jsa
*/
public enum AccessItemQueryColumnName implements QueryColumnName {
ID("id"),
WORKBASKET_ID("workbasket_id"),
WORKBASKET_KEY("wb.key"),
ACCESS_ID("access_id");
ID("id"),
WORKBASKET_ID("workbasket_id"),
WORKBASKET_KEY("wb.key"),
ACCESS_ID("access_id");
private String name;
private String name;
AccessItemQueryColumnName(String name) {
this.name = name;
}
AccessItemQueryColumnName(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
@Override
public String toString() {
return name;
}
}

View File

@ -3,119 +3,112 @@ package pro.taskana;
import java.time.Instant;
import java.util.Map;
/**
* Attachment-Interface to specify Attachment Attributes.
*/
/** Attachment-Interface to specify Attachment Attributes. */
public interface Attachment {
/**
* Returns the current id of the attachment.
*
* @return ID of attachment
*/
String getId();
/**
* Returns the current id of the attachment.
*
* @return ID of attachment
*/
String getId();
/**
* Returns the id of the associated task.
*
* @return taskId
*/
String getTaskId();
/**
* Returns the id of the associated task.
*
* @return taskId
*/
String getTaskId();
/**
* Returns the time when the attachment was created.
*
* @return the created time as {@link Instant}
*/
Instant getCreated();
/**
* Returns the time when the attachment was created.
*
* @return the created time as {@link Instant}
*/
Instant getCreated();
/**
* Returns the time when the attachment was last modified.
*
* @return modified {@link Instant} of the attachment
*/
Instant getModified();
/**
* Returns the time when the attachment was last modified.
*
* @return modified {@link Instant} of the attachment
*/
Instant getModified();
/**
* Returns the classification summary of the attachment.
*
* @return the {@link ClassificationSummary} of this attachment
*/
ClassificationSummary getClassificationSummary();
/**
* Returns the classification summary of the attachment.
*
* @return the {@link ClassificationSummary} of this attachment
*/
ClassificationSummary getClassificationSummary();
/**
* Set the classification summary for this attachment.
*
* @param classificationSummary
* the {@link ClassificationSummary} for this attachment
*/
void setClassificationSummary(ClassificationSummary classificationSummary);
/**
* Set the classification summary for this attachment.
*
* @param classificationSummary the {@link ClassificationSummary} for this attachment
*/
void setClassificationSummary(ClassificationSummary classificationSummary);
/**
* Returns the {@link ObjectReference primaryObjectReference} of the attachment.
*
* @return {@link ObjectReference primaryObjectReference} of the attachment
**/
ObjectReference getObjectReference();
/**
* Returns the {@link ObjectReference primaryObjectReference} of the attachment.
*
* @return {@link ObjectReference primaryObjectReference} of the attachment
*/
ObjectReference getObjectReference();
/**
* Sets the {@link ObjectReference primaryObjectReference} of the attachment.
*
* @param objectReference
* the {@link ObjectReference primaryObjectReference} of the attachment
*/
void setObjectReference(ObjectReference objectReference);
/**
* Sets the {@link ObjectReference primaryObjectReference} of the attachment.
*
* @param objectReference the {@link ObjectReference primaryObjectReference} of the attachment
*/
void setObjectReference(ObjectReference objectReference);
/**
* Returns the Channel on which the attachment was received.
*
* @return the Channel on which the attachment was received.
**/
String getChannel();
/**
* Returns the Channel on which the attachment was received.
*
* @return the Channel on which the attachment was received.
*/
String getChannel();
/**
* Sets the Channel on which the attachment was received.
*
* @param channel
* the channel on which the attachment was received
*/
void setChannel(String channel);
/**
* Sets the Channel on which the attachment was received.
*
* @param channel the channel on which the attachment was received
*/
void setChannel(String channel);
/**
* Returns the time when this attachment was received.
*
* @return received time as exact {@link Instant}
*/
Instant getReceived();
/**
* Returns the time when this attachment was received.
*
* @return received time as exact {@link Instant}
*/
Instant getReceived();
/**
* Sets the time when the attachment was received.
*
* @param received
* the time as {@link Instant} when the attachment was received
**/
void setReceived(Instant received);
/**
* Sets the time when the attachment was received.
*
* @param received the time as {@link Instant} when the attachment was received
*/
void setReceived(Instant received);
/**
* Returns the custom attributes of this attachment.
*
* @return customAttributes as {@link Map}
*/
Map<String, String> getCustomAttributes();
/**
* Returns the custom attributes of this attachment.
*
* @return customAttributes as {@link Map}
*/
Map<String, String> getCustomAttributes();
/**
* Sets the custom attribute Map of the attachment.
*
* @param customAttributes
* a {@link Map} that contains the custom attributes of the attachment as key, value pairs
*/
void setCustomAttributes(Map<String, String> customAttributes);
/**
* Return a summary of the current Attachment.
*
* @return the AttachmentSummary object for the current attachment
*/
AttachmentSummary asSummary();
/**
* Sets the custom attribute Map of the attachment.
*
* @param customAttributes a {@link Map} that contains the custom attributes of the attachment as
* key, value pairs
*/
void setCustomAttributes(Map<String, String> customAttributes);
/**
* Return a summary of the current Attachment.
*
* @return the AttachmentSummary object for the current attachment
*/
AttachmentSummary asSummary();
}

View File

@ -3,64 +3,64 @@ package pro.taskana;
import java.time.Instant;
/**
* Interface for AttachmentSummaries. This is a specific short model-object which only contains the most important
* information.
* Interface for AttachmentSummaries. This is a specific short model-object which only contains the
* most important information.
*/
public interface AttachmentSummary {
/**
* Gets the id of the attachment.
*
* @return attachmentId
*/
String getId();
/**
* Gets the id of the attachment.
*
* @return attachmentId
*/
String getId();
/**
* Gets the id of the associated task.
*
* @return taskId
*/
String getTaskId();
/**
* Gets the id of the associated task.
*
* @return taskId
*/
String getTaskId();
/**
* Gets the time when the attachment was created.
*
* @return the created Instant
*/
Instant getCreated();
/**
* Gets the time when the attachment was created.
*
* @return the created Instant
*/
Instant getCreated();
/**
* Gets the time when the attachment was last modified.
*
* @return the last modified Instant
*/
Instant getModified();
/**
* Gets the time when the attachment was last modified.
*
* @return the last modified Instant
*/
Instant getModified();
/**
* Gets the {@link ObjectReference primaryObjectReference} of the attachment.
*
* @return {@link ObjectReference primaryObjectReference} of the attachment
**/
ObjectReference getObjectReference();
/**
* Gets the {@link ObjectReference primaryObjectReference} of the attachment.
*
* @return {@link ObjectReference primaryObjectReference} of the attachment
*/
ObjectReference getObjectReference();
/**
* Gets the Channel on which the attachment was received.
*
* @return the channel
**/
String getChannel();
/**
* Gets the Channel on which the attachment was received.
*
* @return the channel
*/
String getChannel();
/**
* Gets the classificationSummary of the attachment.
*
* @return the classification summary
*/
ClassificationSummary getClassificationSummary();
/**
* Gets the classificationSummary of the attachment.
*
* @return the classification summary
*/
ClassificationSummary getClassificationSummary();
/**
* Gets the time when the attachment was received.
*
* @return received Instant
*/
Instant getReceived();
/**
* Gets the time when the attachment was received.
*
* @return received Instant
*/
Instant getReceived();
}

View File

@ -6,112 +6,105 @@ import java.util.List;
* Main query interface.
*
* @author EH
* @param <T>
* specifies the return type of the follwing methods
* @param <U>
* specifies the type of the enum used
* @param <T> specifies the return type of the follwing methods
* @param <U> specifies the type of the enum used
*/
public interface BaseQuery<T, U extends Enum<U> & QueryColumnName> {
/**
* This method will return a list of defined {@link T} objects. In case of a TaskQuery, this method can throw a
* NotAuthorizedToQueryWorkbasketException.
*
* @return List containing elements of type T
*/
List<T> list();
/**
* This method will return a list of defined {@link T} objects. In case of a TaskQuery, this
* method can throw a NotAuthorizedToQueryWorkbasketException.
*
* @return List containing elements of type T
*/
List<T> list();
/**
* This method will return a list of defined {@link T} objects with specified offset and an limit. In case of a
* TaskQuery, this method can throw a NotAuthorizedToQueryWorkbasketException.
*
* @param offset
* index of the first element which should be returned.
* @param limit
* number of elements which should be returned beginning with offset.
* @return List containing elements of type T
*/
List<T> list(int offset, int limit);
/**
* This method will return a list of defined {@link T} objects with specified offset and an limit.
* In case of a TaskQuery, this method can throw a NotAuthorizedToQueryWorkbasketException.
*
* @param offset index of the first element which should be returned.
* @param limit number of elements which should be returned beginning with offset.
* @return List containing elements of type T
*/
List<T> list(int offset, int limit);
/**
* This method will return all currently existing values of a DB-Table once. The order of the returning values can
* be configured ASC oder DEC - DEFAULT at NULL is ASC. <br>
* All called orderBy()-Methods will be override. Just the current column-values will be ordered itself by the given
* direction.
*
* @param dbColumnName
* column name of a existing DB Table.
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return a list of all existing values.
*/
List<String> listValues(U dbColumnName, SortDirection sortDirection);
/**
* This method will return all currently existing values of a DB-Table once. The order of the
* returning values can be configured ASC oder DEC - DEFAULT at NULL is ASC. <br>
* All called orderBy()-Methods will be override. Just the current column-values will be ordered
* itself by the given direction.
*
* @param dbColumnName column name of a existing DB Table.
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return a list of all existing values.
*/
List<String> listValues(U dbColumnName, SortDirection sortDirection);
/**
* This method will return all results for page X with a size of Y of the current query.<br>
* Negative pageNumber/size will be changed to 1 or 0 and the last page might contains less elements. In case of a
* TaskQuery, this method can throw a NotAuthorizedToQueryWorkbasketException.
*
* @param pageNumber
* current pagination page starting at 1.
* @param pageSize
* amount of elements for this page.
* @return resulList for the current query starting at X and returning max Y elements.
*/
default List<T> listPage(int pageNumber, int pageSize) {
int offset = (pageNumber < 1) ? 0 : ((pageNumber - 1) * pageSize);
int limit = (pageSize < 0) ? 0 : pageSize;
return list(offset, limit);
/**
* This method will return all results for page X with a size of Y of the current query.<br>
* Negative pageNumber/size will be changed to 1 or 0 and the last page might contains less
* elements. In case of a TaskQuery, this method can throw a
* NotAuthorizedToQueryWorkbasketException.
*
* @param pageNumber current pagination page starting at 1.
* @param pageSize amount of elements for this page.
* @return resulList for the current query starting at X and returning max Y elements.
*/
default List<T> listPage(int pageNumber, int pageSize) {
int offset = (pageNumber < 1) ? 0 : ((pageNumber - 1) * pageSize);
int limit = (pageSize < 0) ? 0 : pageSize;
return list(offset, limit);
}
/**
* This method will return a single object of {@link T}. In case of a TaskQuery, this method can
* throw a NotAuthorizedToQueryWorkbasketException.
*
* @return T a single object of given Type.
*/
T single();
/**
* Counting the amount of rows/results for the current query. This can be used for a pagination
* afterwards. In case of a TaskQuery, this method can throw a
* NotAuthorizedToQueryWorkbasketException.
*
* @return resultRowCount
*/
long count();
default String[] toUpperCopy(String... source) {
if (source == null || source.length == 0) {
return null;
} else {
String[] target = new String[source.length];
for (int i = 0; i < source.length; i++) {
target[i] = source[i].toUpperCase();
}
return target;
}
}
/**
* Determines the sort direction.
*
* @author bbr
*/
enum SortDirection {
ASCENDING("ASC"),
DESCENDING("DESC");
private final String sortDirection;
SortDirection(String sortDirection) {
this.sortDirection = sortDirection;
}
/**
* This method will return a single object of {@link T}. In case of a TaskQuery, this method can throw a
* NotAuthorizedToQueryWorkbasketException.
*
* @return T a single object of given Type.
*/
T single();
/**
* Counting the amount of rows/results for the current query. This can be used for a pagination afterwards. In case
* of a TaskQuery, this method can throw a NotAuthorizedToQueryWorkbasketException.
*
* @return resultRowCount
*/
long count();
/**
* Determines the sort direction.
*
* @author bbr
*/
enum SortDirection {
ASCENDING("ASC"),
DESCENDING("DESC");
private final String sortDirection;
SortDirection(String sortDirection) {
this.sortDirection = sortDirection;
}
@Override
public String toString() {
return sortDirection;
}
@Override
public String toString() {
return sortDirection;
}
default String[] toUpperCopy(String... source) {
if (source == null || source.length == 0) {
return null;
} else {
String[] target = new String[source.length];
for (int i = 0; i < source.length; i++) {
target[i] = source[i].toUpperCase();
}
return target;
}
}
}
}

View File

@ -4,135 +4,132 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pro.taskana.impl.util.LoggerUtils;
/**
* Returning type for a bulk db interaction with errors. This wrapper is storing them with a matching object ID.
* Returning type for a bulk db interaction with errors. This wrapper is storing them with a
* matching object ID.
*
* @param <K>
* unique keys for the logs.
* @param <V>
* type of the stored informations
* @param <K> unique keys for the logs.
* @param <V> type of the stored informations
*/
public class BulkOperationResults<K, V> {
private Map<K, V> errorMap = new HashMap<>();
private static final Logger LOGGER = LoggerFactory.getLogger(BulkOperationResults.class);
private static final Logger LOGGER = LoggerFactory.getLogger(BulkOperationResults.class);
private Map<K, V> errorMap = new HashMap<>();
/**
* Returning a list of current errors as map. If there are no errors the result will be empty.
*
* @return map of errors which can´t be null.
*/
public Map<K, V> getErrorMap() {
return this.errorMap;
/**
* Returning a list of current errors as map. If there are no errors the result will be empty.
*
* @return map of errors which can´t be null.
*/
public Map<K, V> getErrorMap() {
return this.errorMap;
}
/**
* Adding an appearing error to the map and list them by a unique ID as key. NULL keys will be
* ignored.
*
* @param objectId unique key of a entity.
* @param error occurred error of a interaction with the entity
* @return status of adding the values.
*/
public boolean addError(K objectId, V error) {
boolean status = false;
try {
if (objectId != null) {
this.errorMap.put(objectId, error);
status = true;
}
} catch (Exception e) {
LOGGER.warn(
"Can´t add bulkoperation-error, because of a map failure. ID={}, error={} and current failure={}",
objectId,
error,
e);
}
return status;
}
/**
* Returning the status of a bulk-error-log.
*
* @return true if there are logged errors.
*/
public boolean containsErrors() {
boolean isContainingErrors = false;
if (!this.errorMap.isEmpty()) {
isContainingErrors = true;
}
return isContainingErrors;
}
/**
* Returns the stored error for a unique ID or NULL if there is no error stored or ID invalid.
*
* @param idKey which is mapped with an error
* @return stored error for ID
*/
public V getErrorForId(K idKey) {
V result = null;
if (idKey != null) {
result = this.errorMap.get(idKey);
}
return result;
}
/**
* Returns the IDs of the Object with failed requests.
*
* @return a List of IDs that could not be processed successfully.
*/
public List<K> getFailedIds() {
return new ArrayList<>(this.errorMap.keySet());
}
/** Clearing the map - all entries will be removed. */
public void clearErrors() {
this.errorMap.clear();
}
/**
* Add all errors from another BulkOperationResult to this.
*
* @param log the other log
*/
public void addAllErrors(BulkOperationResults<K, V> log) {
if (log != null && log.containsErrors()) {
List<K> failedIds = log.getFailedIds();
for (K id : failedIds) {
addError(id, log.getErrorForId(id));
}
}
}
/**
* Map from any exception type to Exception.
*
* @return map of errors which can´t be null.
*/
public BulkOperationResults<K, Exception> mapBulkOperationResults() {
BulkOperationResults<K, Exception> bulkLogMapped = new BulkOperationResults<>();
List<K> failedIds = this.getFailedIds();
for (K id : failedIds) {
bulkLogMapped.addError(id, (Exception) this.getErrorForId(id));
}
/**
* Adding an appearing error to the map and list them by a unique ID as key. NULL keys will be ignored.
*
* @param objectId
* unique key of a entity.
* @param error
* occurred error of a interaction with the entity
* @return status of adding the values.
*/
public boolean addError(K objectId, V error) {
boolean status = false;
try {
if (objectId != null) {
this.errorMap.put(objectId, error);
status = true;
}
} catch (Exception e) {
LOGGER.warn(
"Can´t add bulkoperation-error, because of a map failure. ID={}, error={} and current failure={}",
objectId, error, e);
}
return status;
}
return bulkLogMapped;
}
/**
* Returning the status of a bulk-error-log.
*
* @return true if there are logged errors.
*/
public boolean containsErrors() {
boolean isContainingErrors = false;
if (!this.errorMap.isEmpty()) {
isContainingErrors = true;
}
return isContainingErrors;
}
/**
* Returns the stored error for a unique ID or NULL if there is no error stored or ID invalid.
*
* @param idKey
* which is mapped with an error
* @return stored error for ID
*/
public V getErrorForId(K idKey) {
V result = null;
if (idKey != null) {
result = this.errorMap.get(idKey);
}
return result;
}
/**
* Returns the IDs of the Object with failed requests.
*
* @return a List of IDs that could not be processed successfully.
*/
public List<K> getFailedIds() {
return new ArrayList<>(this.errorMap.keySet());
}
/**
* Clearing the map - all entries will be removed.
*/
public void clearErrors() {
this.errorMap.clear();
}
/**
* Add all errors from another BulkOperationResult to this.
*
* @param log
* the other log
*/
public void addAllErrors(BulkOperationResults<K, V> log) {
if (log != null && log.containsErrors()) {
List<K> failedIds = log.getFailedIds();
for (K id : failedIds) {
addError(id, log.getErrorForId(id));
}
}
}
/**
* Map from any exception type to Exception.
*
* @return map of errors which can´t be null.
*/
public BulkOperationResults<K, Exception> mapBulkOperationResults() {
BulkOperationResults<K, Exception> bulkLogMapped = new BulkOperationResults<>();
List<K> failedIds = this.getFailedIds();
for (K id : failedIds) {
bulkLogMapped.addError(id, (Exception) this.getErrorForId(id));
}
return bulkLogMapped;
}
@Override
public String toString() {
return "BulkOperationResults [BulkOperationResults= " + LoggerUtils.mapToString(this.errorMap) + "]";
}
@Override
public String toString() {
return "BulkOperationResults [BulkOperationResults= "
+ LoggerUtils.mapToString(this.errorMap)
+ "]";
}
}

View File

@ -1,8 +1,12 @@
package pro.taskana;
/**
* This enum contains all status of synchronization between a taskana task and a task in a remote system.
* This enum contains all status of synchronization between a taskana task and a task in a remote
* system.
*/
public enum CallbackState {
NONE, CALLBACK_PROCESSING_REQUIRED, CLAIMED, CALLBACK_PROCESSING_COMPLETED
NONE,
CALLBACK_PROCESSING_REQUIRED,
CLAIMED,
CALLBACK_PROCESSING_COMPLETED
}

View File

@ -1,200 +1,183 @@
package pro.taskana;
import java.time.Instant;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.time.Instant;
import pro.taskana.impl.ClassificationImpl;
/**
* Interface used to specify the Classification-Model.
*/
/** Interface used to specify the Classification-Model. */
@JsonDeserialize(as = ClassificationImpl.class)
public interface Classification extends ClassificationSummary {
/**
* Set/Change a reference to the current parent classification via ID. EMPTY if there is no parent.
*
* @param parentId
* The ID of the parent classification.
*/
void setParentId(String parentId);
/**
* Set/Change a reference to the current parent classification via ID. EMPTY if there is no
* parent.
*
* @param parentId The ID of the parent classification.
*/
void setParentId(String parentId);
/**
* Set/Change a reference to the current parent classification via key. EMPTY if there is no parent.
*
* @param parentKey
* The key of the parent classification.
*/
void setParentKey(String parentKey);
/**
* Set/Change a reference to the current parent classification via key. EMPTY if there is no
* parent.
*
* @param parentKey The key of the parent classification.
*/
void setParentKey(String parentKey);
/**
* Set/Change the category of this classification.
*
* @param category
* The category of the classification.
*/
void setCategory(String category);
/**
* Set/Change the category of this classification.
*
* @param category The category of the classification.
*/
void setCategory(String category);
/**
* Get the current domain-name of this classification.
*
* @return domain name
*/
String getDomain();
/**
* Get the current domain-name of this classification.
*
* @return domain name
*/
String getDomain();
/**
* Get a flag if the classification if currently valid in the used domain.
*
* @return isValidInDomain - flag
*/
Boolean getIsValidInDomain();
/**
* Get a flag if the classification if currently valid in the used domain.
*
* @return isValidInDomain - flag
*/
Boolean getIsValidInDomain();
/**
* Set/Change the flag which marks the classification as valid/invalid in the currently used domain.
*
* @param isValidInDomain
* - flag
*/
void setIsValidInDomain(Boolean isValidInDomain);
/**
* Set/Change the flag which marks the classification as valid/invalid in the currently used
* domain.
*
* @param isValidInDomain - flag
*/
void setIsValidInDomain(Boolean isValidInDomain);
/**
* Get the timestamp when this classification was as created.
*
* @return created as instant
*/
Instant getCreated();
/**
* Get the timestamp when this classification was as created.
*
* @return created as instant
*/
Instant getCreated();
/**
* Get the timestamp when this classification was as modified the last time.
*
* @return modified as instant
*/
Instant getModified();
/**
* Get the timestamp when this classification was as modified the last time.
*
* @return modified as instant
*/
Instant getModified();
/**
* Set/Change the classification name.
*
* @param name
* the name of the Classification
*/
void setName(String name);
/**
* Set/Change the classification name.
*
* @param name the name of the Classification
*/
void setName(String name);
/**
* Get the description of a classification.
*
* @return description
*/
String getDescription();
/**
* Get the description of a classification.
*
* @return description
*/
String getDescription();
/**
* Set/Change the classification description.
*
* @param description
* the description of the Classification
*/
void setDescription(String description);
/**
* Set/Change the classification description.
*
* @param description the description of the Classification
*/
void setDescription(String description);
/**
* Set/Change the numeric priority of a classification.
*
* @param priority
* the Priority of the Classification
*/
void setPriority(int priority);
/**
* Set/Change the numeric priority of a classification.
*
* @param priority the Priority of the Classification
*/
void setPriority(int priority);
/**
* Set/Change the service level.
*
* @param serviceLevel
* the service level. Must be a String in ISO-8601 duration format. See the parse() method of
* {@code Duration} for details.
*/
void setServiceLevel(String serviceLevel);
/**
* Set/Change the service level.
*
* @param serviceLevel the service level. Must be a String in ISO-8601 duration format. See the
* parse() method of {@code Duration} for details.
*/
void setServiceLevel(String serviceLevel);
/**
* Get the logical name of the associated application entry point.
*
* @return applicationEntryPoint
*/
String getApplicationEntryPoint();
/**
* Get the logical name of the associated application entry point.
*
* @return applicationEntryPoint
*/
String getApplicationEntryPoint();
/**
* Set the logical name of the associated application entry point.
*
* @param applicationEntryPoint
* The application entry point
*/
void setApplicationEntryPoint(String applicationEntryPoint);
/**
* Set the logical name of the associated application entry point.
*
* @param applicationEntryPoint The application entry point
*/
void setApplicationEntryPoint(String applicationEntryPoint);
/**
* Set/Change the 1. custom-attribute.
*
* @param custom1
* the first custom attribute
*/
void setCustom1(String custom1);
/**
* Set/Change the 1. custom-attribute.
*
* @param custom1 the first custom attribute
*/
void setCustom1(String custom1);
/**
* Set/Change the 2. custom-attribute.
*
* @param custom2
* the second custom attribute
*/
void setCustom2(String custom2);
/**
* Set/Change the 2. custom-attribute.
*
* @param custom2 the second custom attribute
*/
void setCustom2(String custom2);
/**
* Set/Change the 3. custom-attribute.
*
* @param custom3
* the third custom attribute
*/
void setCustom3(String custom3);
/**
* Set/Change the 3. custom-attribute.
*
* @param custom3 the third custom attribute
*/
void setCustom3(String custom3);
/**
* Set/Change the 4. custom-attribute.
*
* @param custom4
* the fourth custom attribute
*/
void setCustom4(String custom4);
/**
* Set/Change the 4. custom-attribute.
*
* @param custom4 the fourth custom attribute
*/
void setCustom4(String custom4);
/**
* Set/Change the 5. custom-attribute.
*
* @param custom5
* the fifth custom attribute
*/
void setCustom5(String custom5);
/**
* Set/Change the 5. custom-attribute.
*
* @param custom5 the fifth custom attribute
*/
void setCustom5(String custom5);
/**
* Set/Change the 6. custom-attribute.
*
* @param custom6
* the sixth custom attribute
*/
void setCustom6(String custom6);
/**
* Set/Change the 6. custom-attribute.
*
* @param custom6 the sixth custom attribute
*/
void setCustom6(String custom6);
/**
* Set/Change the 7. custom-attribute.
*
* @param custom7
* the seventh custom attribute
*/
void setCustom7(String custom7);
/**
* Set/Change the 7. custom-attribute.
*
* @param custom7 the seventh custom attribute
*/
void setCustom7(String custom7);
/**
* Set/Change the 8. custom-attribute.
*
* @param custom8
* the eight custom attribute
*/
void setCustom8(String custom8);
/**
* Set/Change the 8. custom-attribute.
*
* @param custom8 the eight custom attribute
*/
void setCustom8(String custom8);
/**
* Return a summary of the current Classification.
*
* @return the ClassificationSummary object for the current classification
*/
ClassificationSummary asSummary();
/**
* Return a summary of the current Classification.
*
* @return the ClassificationSummary object for the current classification
*/
ClassificationSummary asSummary();
}

View File

@ -2,302 +2,269 @@ package pro.taskana;
import pro.taskana.exceptions.InvalidArgumentException;
/**
* ClassificationQuery for generating dynamic sql.
*/
public interface ClassificationQuery extends BaseQuery<ClassificationSummary, ClassificationQueryColumnName> {
/** ClassificationQuery for generating dynamic sql. */
public interface ClassificationQuery
extends BaseQuery<ClassificationSummary, ClassificationQueryColumnName> {
/**
* Add your key to your query.
*
* @param key
* as String
* @return the query
*/
ClassificationQuery keyIn(String... key);
/**
* Add your key to your query.
*
* @param key as String
* @return the query
*/
ClassificationQuery keyIn(String... key);
/**
* Add your Id to your query.
*
* @param id
* as String
* @return the query
*/
ClassificationQuery idIn(String... id);
/**
* Add your Id to your query.
*
* @param id as String
* @return the query
*/
ClassificationQuery idIn(String... id);
/**
* Add your parentIds to your query.
*
* @param parentId
* as an array of Strings
* @return the query
*/
ClassificationQuery parentIdIn(String... parentId);
/**
* Add your parentIds to your query.
*
* @param parentId as an array of Strings
* @return the query
*/
ClassificationQuery parentIdIn(String... parentId);
/**
* Add your parentKeys to your query.
*
* @param parentKey
* as an array of Strings
* @return the query
*/
ClassificationQuery parentKeyIn(String... parentKey);
/**
* Add your parentKeys to your query.
*
* @param parentKey as an array of Strings
* @return the query
*/
ClassificationQuery parentKeyIn(String... parentKey);
/**
* Add your category to your query.
*
* @param category
* as String
* @return the query
*/
ClassificationQuery categoryIn(String... category);
/**
* Add your category to your query.
*
* @param category as String
* @return the query
*/
ClassificationQuery categoryIn(String... category);
/**
* Add your type to your query.
*
* @param type
* as String
* @return the query
*/
ClassificationQuery typeIn(String... type);
/**
* Add your type to your query.
*
* @param type as String
* @return the query
*/
ClassificationQuery typeIn(String... type);
/**
* Add your domains to your query which are used as filter.
*
* @param domain
* or domains for filtering.
* @return the query
*/
ClassificationQuery domainIn(String... domain);
/**
* Add your domains to your query which are used as filter.
*
* @param domain or domains for filtering.
* @return the query
*/
ClassificationQuery domainIn(String... domain);
/**
* Add to your query if the Classification shall be valid in its domain.
*
* @param validInDomain
* a simple flag showing if domain is valid
* @return the query
*/
ClassificationQuery validInDomainEquals(Boolean validInDomain);
/**
* Add to your query if the Classification shall be valid in its domain.
*
* @param validInDomain a simple flag showing if domain is valid
* @return the query
*/
ClassificationQuery validInDomainEquals(Boolean validInDomain);
/**
* Add your created-Dates to your query.
*
* @param createdIn
* the {@link TimeInterval} within which the searched-for classifications were created.
* @return the query
*/
ClassificationQuery createdWithin(TimeInterval... createdIn);
/**
* Add your created-Dates to your query.
*
* @param createdIn the {@link TimeInterval} within which the searched-for classifications were
* created.
* @return the query
*/
ClassificationQuery createdWithin(TimeInterval... createdIn);
/**
* Add your modified-Dates to your query.
*
* @param modifiedIn
* the {@link TimeInterval} within which the searched-for classifications were modified the last time.
* @return the query
*/
ClassificationQuery modifiedWithin(TimeInterval... modifiedIn);
/**
* Add your modified-Dates to your query.
*
* @param modifiedIn the {@link TimeInterval} within which the searched-for classifications were
* modified the last time.
* @return the query
*/
ClassificationQuery modifiedWithin(TimeInterval... modifiedIn);
/**
* Add your name to your query.
*
* @param nameIn
* as String
* @return the query
*/
ClassificationQuery nameIn(String... nameIn);
/**
* Add your name to your query.
*
* @param nameIn as String
* @return the query
*/
ClassificationQuery nameIn(String... nameIn);
/**
* Add your name to your query. It will be compared in SQL with an LIKE.
*
* @param nameLike
* as String
* @return the query
*/
ClassificationQuery nameLike(String... nameLike);
/**
* Add your name to your query. It will be compared in SQL with an LIKE.
*
* @param nameLike as String
* @return the query
*/
ClassificationQuery nameLike(String... nameLike);
/**
* Add your description to your query. It will be compared in SQL with an LIKE. If you use a wildcard like % then it
* will be transmitted to the database.
*
* @param descriptionLike
* your description
* @return the query
*/
ClassificationQuery descriptionLike(String descriptionLike);
/**
* Add your description to your query. It will be compared in SQL with an LIKE. If you use a
* wildcard like % then it will be transmitted to the database.
*
* @param descriptionLike your description
* @return the query
*/
ClassificationQuery descriptionLike(String descriptionLike);
/**
* Add your priority to your query.
*
* @param priorities
* as integers
* @return the query
*/
ClassificationQuery priorityIn(int... priorities);
/**
* Add your priority to your query.
*
* @param priorities as integers
* @return the query
*/
ClassificationQuery priorityIn(int... priorities);
/**
* Add your serviceLevel to your query.
*
* @param serviceLevelIn
* as String
* @return the query
*/
ClassificationQuery serviceLevelIn(String... serviceLevelIn);
/**
* Add your serviceLevel to your query.
*
* @param serviceLevelIn as String
* @return the query
*/
ClassificationQuery serviceLevelIn(String... serviceLevelIn);
/**
* Add your serviceLevel to your query. It will be compared in SQL with an LIKE.
*
* @param serviceLevelLike
* as String
* @return the query
*/
ClassificationQuery serviceLevelLike(String... serviceLevelLike);
/**
* Add your serviceLevel to your query. It will be compared in SQL with an LIKE.
*
* @param serviceLevelLike as String
* @return the query
*/
ClassificationQuery serviceLevelLike(String... serviceLevelLike);
/**
* Add your applicationEntryPoint to your query.
*
* @param applicationEntryPointIn
* name of the applications entrypoint
* @return the query
*/
ClassificationQuery applicationEntryPointIn(String... applicationEntryPointIn);
/**
* Add your applicationEntryPoint to your query.
*
* @param applicationEntryPointIn name of the applications entrypoint
* @return the query
*/
ClassificationQuery applicationEntryPointIn(String... applicationEntryPointIn);
/**
* Add your applicationEntryPoint to your query. It will be compared in SQL with an LIKE.
*
* @param applicationEntryPointLike
* name of the applications entrypoint
* @return the query
*/
ClassificationQuery applicationEntryPointLike(String... applicationEntryPointLike);
/**
* Add your applicationEntryPoint to your query. It will be compared in SQL with an LIKE.
*
* @param applicationEntryPointLike name of the applications entrypoint
* @return the query
*/
ClassificationQuery applicationEntryPointLike(String... applicationEntryPointLike);
/**
* Add a custom to your query.
*
* @param num
* the number of the custom as String (eg "4")
* @param customIn
* filter for this custom
* @return the query
* @throws InvalidArgumentException
* when the number of the custom is incorrect.
*/
ClassificationQuery customAttributeIn(String num, String... customIn) throws InvalidArgumentException;
/**
* Add a custom to your query.
*
* @param num the number of the custom as String (eg "4")
* @param customIn filter for this custom
* @return the query
* @throws InvalidArgumentException when the number of the custom is incorrect.
*/
ClassificationQuery customAttributeIn(String num, String... customIn)
throws InvalidArgumentException;
/**
* Add a custom to your query.
*
* @param num
* the number of the custom as String (eg "4")
* @param customLike
* filter for this custom with a LIKE-query
* @return the query
* @throws InvalidArgumentException
* when the number of the custom is incorrect.
*/
ClassificationQuery customAttributeLike(String num, String... customLike) throws InvalidArgumentException;
/**
* Add a custom to your query.
*
* @param num the number of the custom as String (eg "4")
* @param customLike filter for this custom with a LIKE-query
* @return the query
* @throws InvalidArgumentException when the number of the custom is incorrect.
*/
ClassificationQuery customAttributeLike(String num, String... customLike)
throws InvalidArgumentException;
/**
* Sort the query result by key.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByKey(SortDirection sortDirection);
/**
* Sort the query result by key.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByKey(SortDirection sortDirection);
/**
* Sort the query result by the parent classification ID.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByParentId(SortDirection sortDirection);
/**
* Sort the query result by the parent classification ID.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByParentId(SortDirection sortDirection);
/**
* Sort the query result by the parent classification key.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByParentKey(SortDirection sortDirection);
/**
* Sort the query result by the parent classification key.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByParentKey(SortDirection sortDirection);
/**
* Sort the query result by category.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByCategory(SortDirection sortDirection);
/**
* Sort the query result by category.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByCategory(SortDirection sortDirection);
/**
* Sort the query result by domain.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByDomain(SortDirection sortDirection);
/**
* Sort the query result by domain.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByDomain(SortDirection sortDirection);
/**
* Sort the query result by name.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByName(SortDirection sortDirection);
/**
* Sort the query result by name.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByName(SortDirection sortDirection);
/**
* Sort the query result by service level.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByServiceLevel(SortDirection sortDirection);
/**
* Sort the query result by service level.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByServiceLevel(SortDirection sortDirection);
/**
* Sort the query result by priority.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByPriority(SortDirection sortDirection);
/**
* Sort the query result by priority.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByPriority(SortDirection sortDirection);
/**
* Sort the query result by the application entry point name.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByApplicationEntryPoint(SortDirection sortDirection);
/**
* Sort the query result by a custom.
*
* @param num
* the number of the custom as String (eg "4")
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
* @throws InvalidArgumentException
* when the number of the custom is incorrect.
*/
ClassificationQuery orderByCustomAttribute(String num, SortDirection sortDirection) throws InvalidArgumentException;
/**
* Sort the query result by the application entry point name.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
ClassificationQuery orderByApplicationEntryPoint(SortDirection sortDirection);
/**
* Sort the query result by a custom.
*
* @param num the number of the custom as String (eg "4")
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
* @throws InvalidArgumentException when the number of the custom is incorrect.
*/
ClassificationQuery orderByCustomAttribute(String num, SortDirection sortDirection)
throws InvalidArgumentException;
}

View File

@ -1,42 +1,44 @@
package pro.taskana;
/**
* Enum containing the column names for @see pro.taskana.mappings.QueryMapper#queryClassificationColumnValues(pro.taskana.impl.ClassificationQueryImpl).
* Enum containing the column names for @see
* pro.taskana.mappings.QueryMapper#queryClassificationColumnValues(pro.taskana.impl.ClassificationQueryImpl).
*
* @author jsa
*/
public enum ClassificationQueryColumnName implements QueryColumnName {
ID("id"),
KEY("key"),
PARENT_ID("parent_id"),
PARENT_KEY("parent_key"),
CATEGORY("category"),
TYPE("type"),
DOMAIN("domain"),
VALID_IN_DOMAIN("valid_in_domain"),
CREATED("created"),
MODIFIED("modified"),
NAME("name"),
DESCRIPTION("description"),
PRIORITY("priority"),
SERVICELEVEL("serviceLevel"),
APPLICATION_ENTRY_POINT("application_entry_point"),
CUSTOM_1("custom_1"),
CUSTOM_2("custom_2"),
CUSTOM_3("custom_3"),
CUSTOM_4("custom_4"),
CUSTOM_5("custom_5"),
CUSTOM_6("custom_6"),
CUSTOM_7("custom_7"),
CUSTOM_8("custom_8");
ID("id"),
KEY("key"),
PARENT_ID("parent_id"),
PARENT_KEY("parent_key"),
CATEGORY("category"),
TYPE("type"),
DOMAIN("domain"),
VALID_IN_DOMAIN("valid_in_domain"),
CREATED("created"),
MODIFIED("modified"),
NAME("name"),
DESCRIPTION("description"),
PRIORITY("priority"),
SERVICELEVEL("serviceLevel"),
APPLICATION_ENTRY_POINT("application_entry_point"),
CUSTOM_1("custom_1"),
CUSTOM_2("custom_2"),
CUSTOM_3("custom_3"),
CUSTOM_4("custom_4"),
CUSTOM_5("custom_5"),
CUSTOM_6("custom_6"),
CUSTOM_7("custom_7"),
CUSTOM_8("custom_8");
private String name;
ClassificationQueryColumnName(String name) {
this.name = name;
}
private String name;
@Override
public String toString() {
return name;
}
ClassificationQueryColumnName(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
}

View File

@ -8,125 +8,111 @@ import pro.taskana.exceptions.DomainNotFoundException;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
/**
* This class manages the classifications.
*/
/** This class manages the classifications. */
public interface ClassificationService {
/**
* Get the Classification for key and domain. If there's no Classification in the given domain, return the
* Classification from the master domain.
*
* @param key
* the key of the searched-for classifications
* @param domain
* the domain of the searched-for classifications
* @return If exist: domain-specific classification, else master classification
* @throws ClassificationNotFoundException
* if no classification is found that matches the key either in domain or in the master domain.
*/
Classification getClassification(String key, String domain) throws ClassificationNotFoundException;
/**
* Get the Classification for key and domain. If there's no Classification in the given domain,
* return the Classification from the master domain.
*
* @param key the key of the searched-for classifications
* @param domain the domain of the searched-for classifications
* @return If exist: domain-specific classification, else master classification
* @throws ClassificationNotFoundException if no classification is found that matches the key
* either in domain or in the master domain.
*/
Classification getClassification(String key, String domain)
throws ClassificationNotFoundException;
/**
* Get the Classification by id.
*
* @param id
* the id of the searched-for classifications
* @return the classification identified by id
* @throws ClassificationNotFoundException
* if no classification is found that matches the id.
*/
Classification getClassification(String id) throws ClassificationNotFoundException;
/**
* Get the Classification by id.
*
* @param id the id of the searched-for classifications
* @return the classification identified by id
* @throws ClassificationNotFoundException if no classification is found that matches the id.
*/
Classification getClassification(String id) throws ClassificationNotFoundException;
/**
* Delete a classification with all child classifications.
*
* @param id
* the id of the searched-for classifications
* @throws ClassificationInUseException
* if there are Task existing, which refer to this classification.
* @throws ClassificationNotFoundException
* if for an domain no classification specification is found.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/
void deleteClassification(String id)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException;
/**
* Delete a classification with all child classifications.
*
* @param id the id of the searched-for classifications
* @throws ClassificationInUseException if there are Task existing, which refer to this
* classification.
* @throws ClassificationNotFoundException if for an domain no classification specification is
* found.
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
*/
void deleteClassification(String id)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException;
/**
* Delete a classification with all child classifications.
*
* @param classificationKey
* the key of the classification you want to delete.
* @param domain
* the domains for which you want to delete the classification. if "", the function tries to delete the
* "master domain" classification and any other classification with this key.
* @throws ClassificationInUseException
* if there are Task existing, which refer to this classification.
* @throws ClassificationNotFoundException
* if for an domain no classification specification is found.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/
void deleteClassification(String classificationKey, String domain)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException;
/**
* Delete a classification with all child classifications.
*
* @param classificationKey the key of the classification you want to delete.
* @param domain the domains for which you want to delete the classification. if "", the function
* tries to delete the "master domain" classification and any other classification with this
* key.
* @throws ClassificationInUseException if there are Task existing, which refer to this
* classification.
* @throws ClassificationNotFoundException if for an domain no classification specification is
* found.
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
*/
void deleteClassification(String classificationKey, String domain)
throws ClassificationInUseException, ClassificationNotFoundException, NotAuthorizedException;
/**
* Persists a new classification after adding default values. <br >
* The classification will be added to master-domain, too - if not already existing.
*
* @param classification
* the classification to insert
* @return classification which is persisted with unique ID.
* @throws ClassificationAlreadyExistException
* when the classification does already exists at the given domain.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
* @throws DomainNotFoundException
* if the domain does not exist in the configuration
* @throws InvalidArgumentException
* if the ServiceLevel property does not comply with the ISO 8601 specification
*/
Classification createClassification(Classification classification)
throws ClassificationAlreadyExistException, NotAuthorizedException,
DomainNotFoundException, InvalidArgumentException;
/**
* Persists a new classification after adding default values. <br>
* The classification will be added to master-domain, too - if not already existing.
*
* @param classification the classification to insert
* @return classification which is persisted with unique ID.
* @throws ClassificationAlreadyExistException when the classification does already exists at the
* given domain.
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
* @throws DomainNotFoundException if the domain does not exist in the configuration
* @throws InvalidArgumentException if the ServiceLevel property does not comply with the ISO 8601
* specification
*/
Classification createClassification(Classification classification)
throws ClassificationAlreadyExistException, NotAuthorizedException, DomainNotFoundException,
InvalidArgumentException;
/**
* Updates a Classification.
*
* @param classification
* the Classification to update
* @return the updated Classification.
* @throws ClassificationNotFoundException
* when the classification OR it´s parent does not exist.
* @throws NotAuthorizedException
* when the caller got no ADMIN or BUSINESS_ADMIN permissions.
* @throws ConcurrencyException
* when the Classification was modified meanwhile and is not latest anymore.
* @throws InvalidArgumentException
* if the ServiceLevel property does not comply with the ISO 8601 specification
*/
Classification updateClassification(Classification classification)
throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException, InvalidArgumentException;
/**
* Updates a Classification.
*
* @param classification the Classification to update
* @return the updated Classification.
* @throws ClassificationNotFoundException when the classification OR it´s parent does not exist.
* @throws NotAuthorizedException when the caller got no ADMIN or BUSINESS_ADMIN permissions.
* @throws ConcurrencyException when the Classification was modified meanwhile and is not latest
* anymore.
* @throws InvalidArgumentException if the ServiceLevel property does not comply with the ISO 8601
* specification
*/
Classification updateClassification(Classification classification)
throws ClassificationNotFoundException, NotAuthorizedException, ConcurrencyException,
InvalidArgumentException;
/**
* This method provides a query builder for quering the database.
*
* @return a {@link ClassificationQuery}
*/
ClassificationQuery createClassificationQuery();
/**
* This method provides a query builder for quering the database.
*
* @return a {@link ClassificationQuery}
*/
ClassificationQuery createClassificationQuery();
/**
* Creating a new {@link Classification} with unchangeable default values. It will be only generated and is not
* persisted until CREATE-call.
*
* @param key
* the key of the classification
* @param domain
* the domain of the new classification
* @param type
* the type of the new classification
* @return classification to specify
*/
Classification newClassification(String key, String domain, String type);
/**
* Creating a new {@link Classification} with unchangeable default values. It will be only
* generated and is not persisted until CREATE-call.
*
* @param key the key of the classification
* @param domain the domain of the new classification
* @param type the type of the new classification
* @return classification to specify
*/
Classification newClassification(String key, String domain, String type);
}

View File

@ -1,136 +1,135 @@
package pro.taskana;
/**
* Interface for ClassificationSummaries. This is a specific short model-object which only requieres the most important
* informations. Specific ones can be load afterwards via ID.
* Interface for ClassificationSummaries. This is a specific short model-object which only requieres
* the most important informations. Specific ones can be load afterwards via ID.
*/
public interface ClassificationSummary {
/**
* Gets the id of the classification.
*
* @return classificationId
*/
String getId();
/**
* Gets the id of the classification.
*
* @return classificationId
*/
String getId();
/**
* Gets the key of the classification.
*
* @return classificationKey
*/
String getKey();
/**
* Gets the key of the classification.
*
* @return classificationKey
*/
String getKey();
/**
* Gets the category of the classification.
*
* @return classificationCategory
*/
String getCategory();
/**
* Gets the category of the classification.
*
* @return classificationCategory
*/
String getCategory();
/**
* Gets the type of the classification.
*
* @return classificationType
*/
String getType();
/**
* Gets the type of the classification.
*
* @return classificationType
*/
String getType();
/**
* Gets the domain of the classification.
*
* @return classificationDomain
*/
String getDomain();
/**
* Gets the domain of the classification.
*
* @return classificationDomain
*/
String getDomain();
/**
* Gets the name of the classification.
*
* @return classificationName
*/
String getName();
/**
* Gets the name of the classification.
*
* @return classificationName
*/
String getName();
/**
* Gets the ID of the parent classification.
*
* @return parentId
*/
String getParentId();
/**
* Gets the ID of the parent classification.
*
* @return parentId
*/
String getParentId();
/**
* Gets the key of the parent classification.
*
* @return parentKey
*/
String getParentKey();
/**
* Gets the key of the parent classification.
*
* @return parentKey
*/
String getParentKey();
/**
* Gets the service level of the parent classification. It is a String in ISO-8601 duration format. See the parse()
* method of {@code Duration} for details.
*
* @return the service level
*/
String getServiceLevel();
/**
* Gets the service level of the parent classification. It is a String in ISO-8601 duration
* format. See the parse() method of {@code Duration} for details.
*
* @return the service level
*/
String getServiceLevel();
/**
* Gets the priority of the classification.
*
* @return the priority
*/
int getPriority();
/**
* Gets the priority of the classification.
*
* @return the priority
*/
int getPriority();
/**
* Get the 1. custom-attribute.
*
* @return custom1
*/
String getCustom1();
/**
* Get the 1. custom-attribute.
*
* @return custom1
*/
String getCustom1();
/**
* Get the 2. custom-attribute.
*
* @return custom2
*/
String getCustom2();
/**
* Get the 2. custom-attribute.
*
* @return custom2
*/
String getCustom2();
/**
* Get the 3. custom-attribute.
*
* @return custom3
*/
String getCustom3();
/**
* Get the 3. custom-attribute.
*
* @return custom3
*/
String getCustom3();
/**
* Get the 4. custom-attribute.
*
* @return custom4
*/
String getCustom4();
/**
* Get the 4. custom-attribute.
*
* @return custom4
*/
String getCustom4();
/**
* Get the 5. custom-attribute.
*
* @return custom5
*/
String getCustom5();
/**
* Get the 5. custom-attribute.
*
* @return custom5
*/
String getCustom5();
/**
* Get the 6. custom-attribute.
*
* @return custom6
*/
String getCustom6();
/**
* Get the 6. custom-attribute.
*
* @return custom6
*/
String getCustom6();
/**
* Get the 7. custom-attribute.
*
* @return custom7
*/
String getCustom7();
/**
* Get the 8. custom-attribute.
*
* @return custom8
*/
String getCustom8();
/**
* Get the 7. custom-attribute.
*
* @return custom7
*/
String getCustom7();
/**
* Get the 8. custom-attribute.
*
* @return custom8
*/
String getCustom8();
}

View File

@ -1,23 +1,21 @@
package pro.taskana;
/**
* This enum contains the fields CUSTOM_1 - CUSTOM_10 for the task entity.
*/
/** This enum contains the fields CUSTOM_1 - CUSTOM_10 for the task entity. */
public enum CustomField {
CUSTOM_1,
CUSTOM_2,
CUSTOM_3,
CUSTOM_4,
CUSTOM_5,
CUSTOM_6,
CUSTOM_7,
CUSTOM_8,
CUSTOM_9,
CUSTOM_10,
CUSTOM_11,
CUSTOM_12,
CUSTOM_13,
CUSTOM_14,
CUSTOM_15,
CUSTOM_16
CUSTOM_1,
CUSTOM_2,
CUSTOM_3,
CUSTOM_4,
CUSTOM_5,
CUSTOM_6,
CUSTOM_7,
CUSTOM_8,
CUSTOM_9,
CUSTOM_10,
CUSTOM_11,
CUSTOM_12,
CUSTOM_13,
CUSTOM_14,
CUSTOM_15,
CUSTOM_16
}

View File

@ -2,18 +2,14 @@ package pro.taskana;
import pro.taskana.jobs.ScheduledJob;
/**
* Service to manage the TASKANA jobs.
*/
/** Service to manage the TASKANA jobs. */
public interface JobService {
/**
* Create a schedule a new job.
*
* @param job
* {@link ScheduledJob} The job to be created.
* @return {@link ScheduledJob} The created job.
*/
ScheduledJob createJob(ScheduledJob job);
/**
* Create a schedule a new job.
*
* @param job {@link ScheduledJob} The job to be created.
* @return {@link ScheduledJob} The created job.
*/
ScheduledJob createJob(ScheduledJob job);
}

View File

@ -7,74 +7,70 @@ package pro.taskana;
*/
public class KeyDomain {
private String key;
private String domain;
private String key;
private String domain;
public KeyDomain(String key, String domain) {
this.key = key;
this.domain = domain;
public KeyDomain(String key, String domain) {
this.key = key;
this.domain = domain;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
this.domain = domain;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((domain == null) ? 0 : domain.hashCode());
result = prime * result + ((key == null) ? 0 : key.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
public String getKey() {
return key;
if (obj == null) {
return false;
}
public void setKey(String key) {
this.key = key;
if (!getClass().isAssignableFrom(obj.getClass())) {
return false;
}
public String getDomain() {
return domain;
KeyDomain other = (KeyDomain) obj;
if (domain == null) {
if (other.domain != null) {
return false;
}
} else if (!domain.equals(other.domain)) {
return false;
}
public void setDomain(String domain) {
this.domain = domain;
}
@Override
public String toString() {
return "KeyDomain ["
+ "key=" + this.key
+ ", domain=" + this.domain
+ "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((domain == null) ? 0 : domain.hashCode());
result = prime * result + ((key == null) ? 0 : key.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!getClass().isAssignableFrom(obj.getClass())) {
return false;
}
KeyDomain other = (KeyDomain) obj;
if (domain == null) {
if (other.domain != null) {
return false;
}
} else if (!domain.equals(other.domain)) {
return false;
}
if (key == null) {
if (other.key != null) {
return false;
}
} else if (!key.equals(other.key)) {
return false;
}
return true;
if (key == null) {
if (other.key != null) {
return false;
}
} else if (!key.equals(other.key)) {
return false;
}
return true;
}
@Override
public String toString() {
return "KeyDomain [" + "key=" + this.key + ", domain=" + this.domain + "]";
}
}

View File

@ -1,136 +1,143 @@
package pro.taskana;
/**
* ObjectReference entity.
*/
/** ObjectReference entity. */
public class ObjectReference {
private String id;
private String company;
private String system;
private String systemInstance;
private String type;
private String value;
private String id;
private String company;
private String system;
private String systemInstance;
private String type;
private String value;
public String getId() {
return id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getCompany() {
return company;
}
public void setCompany(String company) {
this.company = company;
}
public String getSystem() {
return system;
}
public void setSystem(String system) {
this.system = system;
}
public String getSystemInstance() {
return systemInstance;
}
public void setSystemInstance(String systemInstance) {
this.systemInstance = systemInstance;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((company == null) ? 0 : company.hashCode());
result = prime * result + ((system == null) ? 0 : system.hashCode());
result = prime * result + ((systemInstance == null) ? 0 : systemInstance.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
public void setId(String id) {
this.id = id;
if (other == null) {
return false;
}
public String getCompany() {
return company;
if (!getClass().isAssignableFrom(other.getClass())) {
return false;
}
ObjectReference o = (ObjectReference) other;
public void setCompany(String company) {
this.company = company;
if (id == null && o.id != null) {
return false;
}
public String getSystem() {
return system;
if (id != null && !(id.equals(o.id))) {
return false;
}
public void setSystem(String system) {
this.system = system;
if (company == null && o.company != null) {
return false;
}
public String getSystemInstance() {
return systemInstance;
if (company != null && !(company.equals(o.company))) {
return false;
}
public void setSystemInstance(String systemInstance) {
this.systemInstance = systemInstance;
if (system == null && o.system != null) {
return false;
}
public String getType() {
return type;
if (system != null && !(system.equals(o.system))) {
return false;
}
public void setType(String type) {
this.type = type;
if (systemInstance == null && o.systemInstance != null) {
return false;
}
public String getValue() {
return value;
if (systemInstance != null && !(systemInstance.equals(o.systemInstance))) {
return false;
}
public void setValue(String value) {
this.value = value;
if (type == null && o.type != null) {
return false;
}
@Override
public String toString() {
return "ObjectReference ["
+ "id=" + this.id + ", company="
+ this.company + ", system=" + this.system
+ ", systemInstance=" + this.systemInstance
+ ", type=" + this.type + ", value=" + this.value + "]";
if (type != null && !(type.equals(o.type))) {
return false;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((company == null) ? 0 : company.hashCode());
result = prime * result + ((system == null) ? 0 : system.hashCode());
result = prime * result + ((systemInstance == null) ? 0 : systemInstance.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
if (value == null && o.value != null) {
return false;
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (other == null) {
return false;
}
if (!getClass().isAssignableFrom(other.getClass())) {
return false;
}
ObjectReference o = (ObjectReference) other;
if (id == null && o.id != null) {
return false;
}
if (id != null && !(id.equals(o.id))) {
return false;
}
if (company == null && o.company != null) {
return false;
}
if (company != null && !(company.equals(o.company))) {
return false;
}
if (system == null && o.system != null) {
return false;
}
if (system != null && !(system.equals(o.system))) {
return false;
}
if (systemInstance == null && o.systemInstance != null) {
return false;
}
if (systemInstance != null && !(systemInstance.equals(o.systemInstance))) {
return false;
}
if (type == null && o.type != null) {
return false;
}
if (type != null && !(type.equals(o.type))) {
return false;
}
if (value == null && o.value != null) {
return false;
}
if (value != null && !(value.equals(o.value))) {
return false;
}
return true;
if (value != null && !(value.equals(o.value))) {
return false;
}
return true;
}
@Override
public String toString() {
return "ObjectReference ["
+ "id="
+ this.id
+ ", company="
+ this.company
+ ", system="
+ this.system
+ ", systemInstance="
+ this.systemInstance
+ ", type="
+ this.type
+ ", value="
+ this.value
+ "]";
}
}

View File

@ -1,52 +1,46 @@
package pro.taskana;
/**
* ObjectReferenceQuery for generating dynamic sql.
*/
public interface ObjectReferenceQuery extends BaseQuery<ObjectReference, ObjectReferenceQueryColumnName> {
/** ObjectReferenceQuery for generating dynamic sql. */
public interface ObjectReferenceQuery
extends BaseQuery<ObjectReference, ObjectReferenceQueryColumnName> {
/**
* Add your company to your query.
*
* @param companies
* as Strings
* @return the query
*/
ObjectReferenceQuery companyIn(String... companies);
/**
* Add your company to your query.
*
* @param companies as Strings
* @return the query
*/
ObjectReferenceQuery companyIn(String... companies);
/**
* Add your system to your query.
*
* @param systems
* as Strings
* @return the query
*/
ObjectReferenceQuery systemIn(String... systems);
/**
* Add your system to your query.
*
* @param systems as Strings
* @return the query
*/
ObjectReferenceQuery systemIn(String... systems);
/**
* Add your systemInstance to your query.
*
* @param systemInstances
* as Strings
* @return the query
*/
ObjectReferenceQuery systemInstanceIn(String... systemInstances);
/**
* Add your systemInstance to your query.
*
* @param systemInstances as Strings
* @return the query
*/
ObjectReferenceQuery systemInstanceIn(String... systemInstances);
/**
* Add your type to your query.
*
* @param types
* as Strings
* @return the query
*/
ObjectReferenceQuery typeIn(String... types);
/**
* Add your type to your query.
*
* @param types as Strings
* @return the query
*/
ObjectReferenceQuery typeIn(String... types);
/**
* Add your value to your query.
*
* @param values
* as Strings
* @return the query
*/
ObjectReferenceQuery valueIn(String... values);
/**
* Add your value to your query.
*
* @param values as Strings
* @return the query
*/
ObjectReferenceQuery valueIn(String... values);
}

View File

@ -1,26 +1,27 @@
package pro.taskana;
/**
* Enum containing the column names for @see {@link pro.taskana.mappings.QueryMapper#queryObjectReferenceColumnValues(pro.taskana.impl.ObjectReferenceQueryImpl)}.
* Enum containing the column names for @see {@link
* pro.taskana.mappings.QueryMapper#queryObjectReferenceColumnValues(pro.taskana.impl.ObjectReferenceQueryImpl)}.
*
* @author jsa
*/
public enum ObjectReferenceQueryColumnName implements QueryColumnName {
ID("id"),
COMPANY("company"),
SYSTEM("system"),
SYSTEM_INSTANCE("system_instance"),
TYPE("type"),
VALUE("value");
ID("id"),
COMPANY("company"),
SYSTEM("system"),
SYSTEM_INSTANCE("system_instance"),
TYPE("type"),
VALUE("value");
private String name;
ObjectReferenceQueryColumnName(String name) {
this.name = name;
}
private String name;
@Override
public String toString() {
return name;
}
ObjectReferenceQueryColumnName(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
}

View File

@ -5,5 +5,4 @@ package pro.taskana;
*
* @author jsa
*/
public interface QueryColumnName {
}
public interface QueryColumnName {}

View File

@ -6,376 +6,357 @@ import java.util.Map;
import pro.taskana.exceptions.InvalidArgumentException;
/**
* task-Interface to specify attribute interactions.
*/
/** task-Interface to specify attribute interactions. */
public interface Task {
/**
* Returns the current id of the task.
*
* @return taskId
*/
String getId();
/**
* The key that is used to supply Callback_state within the CallbackInfo map. The Callback_state
* is used predominantly by the taskana adapter. It controls synchronization between taskana and
* the external system.
*/
String CALLBACK_STATE = "callbackState";
/**
* Returns the external id of the task. This Id can be used to correlate the task to a task in an external
* system and to enforce idempotency of task creation. If not set by the client, it will be set by taskana.
*
* @return external Id
*/
String getExternalId();
/**
* Returns the current id of the task.
*
* @return taskId
*/
String getId();
/**
* Sets the external Id. It can be used to correlate the task to a task in an external system.
* The external Id is enforced to be unique. An attempt to create a task with
* an existing external Id will be rejected. So, this Id can be used to enforce idempotency of task creation.
* The externalId can only be set before the task is persisted. Taskana rejects attempts to modify externalId.
*
* @param externalId the external Id
*
*/
void setExternalId(String externalId);
/**
* Returns the external id of the task. This Id can be used to correlate the task to a task in an
* external system and to enforce idempotency of task creation. If not set by the client, it will
* be set by taskana.
*
* @return external Id
*/
String getExternalId();
/**
* Gets the UserId of the task-creator.
*
* @return creator
*/
String getCreator();
/**
* Sets the external Id. It can be used to correlate the task to a task in an external system. The
* external Id is enforced to be unique. An attempt to create a task with an existing external Id
* will be rejected. So, this Id can be used to enforce idempotency of task creation. The
* externalId can only be set before the task is persisted. Taskana rejects attempts to modify
* externalId.
*
* @param externalId the external Id
*/
void setExternalId(String externalId);
/**
* Returns the time when the task was {@link TaskState#READY}.
*
* @return created as exact {@link Instant}
*/
Instant getCreated();
/**
* Gets the UserId of the task-creator.
*
* @return creator
*/
String getCreator();
/**
* Returns the time when the task was set to {@link TaskState#CLAIMED} by/to a user.
*
* @return claimed as exact {@link Instant}
*/
Instant getClaimed();
/**
* Returns the time when the task was {@link TaskState#READY}.
*
* @return created as exact {@link Instant}
*/
Instant getCreated();
/**
* Returns the time when the task was set into {@link TaskState#COMPLETED}.
*
* @return completed as exact {@link Instant}
*/
Instant getCompleted();
/**
* Returns the time when the task was set to {@link TaskState#CLAIMED} by/to a user.
*
* @return claimed as exact {@link Instant}
*/
Instant getClaimed();
/**
* Returns the time when the task was modified the last time.
*
* @return modified as exact {@link Instant}
*/
Instant getModified();
/**
* Returns the time when the task was set into {@link TaskState#COMPLETED}.
*
* @return completed as exact {@link Instant}
*/
Instant getCompleted();
/**
* Returns the time when the work on this task was planned to be started.
*
* @return planned as exact {@link Instant}
*/
Instant getPlanned();
/**
* Returns the time when the task was modified the last time.
*
* @return modified as exact {@link Instant}
*/
Instant getModified();
/**
* Sets the time when the work on this task should be started.
*
* @param planned
* as exact {@link Instant}
*/
void setPlanned(Instant planned);
/**
* Returns the time when the work on this task was planned to be started.
*
* @return planned as exact {@link Instant}
*/
Instant getPlanned();
/**
* Returns the time when this task should be finished.
*
* @return due as exact {@link Instant}
*/
Instant getDue();
/**
* Sets the time when the work on this task should be started.
*
* @param planned as exact {@link Instant}
*/
void setPlanned(Instant planned);
/**
* Sets the time when the work on this task should be finished.
*
* @param due
* as exact {@link Instant}
*/
void setDue(Instant due);
/**
* Returns the time when this task should be finished.
*
* @return due as exact {@link Instant}
*/
Instant getDue();
/**
* Return the name of the current task.
*
* @return name of the task
*/
String getName();
/**
* Sets the time when the work on this task should be finished.
*
* @param due as exact {@link Instant}
*/
void setDue(Instant due);
/**
* Sets the name of the current task.
*
* @param name
* the name of the task
*/
void setName(String name);
/**
* Return the name of the current task.
*
* @return name of the task
*/
String getName();
/**
* Return the task-description.
*
* @return description of a task
*/
String getDescription();
/**
* Sets the name of the current task.
*
* @param name the name of the task
*/
void setName(String name);
/**
* Sets the description of the task.
*
* @param description
* the description of the task
*/
void setDescription(String description);
/**
* Return the task-description.
*
* @return description of a task
*/
String getDescription();
/**
* Returns the numeric priority of a task.
*
* @return priority of the task
*/
int getPriority();
/**
* Sets the description of the task.
*
* @param description the description of the task
*/
void setDescription(String description);
/**
* Returns the current {@link TaskState} of the task.
*
* @return taskState
*/
TaskState getState();
/**
* Returns the numeric priority of a task.
*
* @return priority of the task
*/
int getPriority();
/**
* Returns the {@link ClassificationSummary} of the task.
*
* @return classification summary for the task
*/
ClassificationSummary getClassificationSummary();
/**
* Returns the current {@link TaskState} of the task.
*
* @return taskState
*/
TaskState getState();
/**
* Sets the Classification key that - together with the Domain from this task's work basket - selects the
* appropriate {@link Classification} for this task.
*
* @param classificationKey
* the classification key for the task
*/
void setClassificationKey(String classificationKey);
/**
* Returns the {@link ClassificationSummary} of the task.
*
* @return classification summary for the task
*/
ClassificationSummary getClassificationSummary();
/**
* Returns the key of the Workbasket where the task is stored in.
*
* @return workbasketKey
*/
String getWorkbasketKey();
/**
* Sets the Classification key that - together with the Domain from this task's work basket -
* selects the appropriate {@link Classification} for this task.
*
* @param classificationKey the classification key for the task
*/
void setClassificationKey(String classificationKey);
/**
* Returns the the Summary of the workbasket where the task is stored in.
*
* @return workbasketSummary
*/
WorkbasketSummary getWorkbasketSummary();
/**
* Returns the key of the Workbasket where the task is stored in.
*
* @return workbasketKey
*/
String getWorkbasketKey();
/**
* Returns the Domain, to which the Task belongs at this moment.
*
* @return domain the current domain of the task
*/
String getDomain();
/**
* Returns the the Summary of the workbasket where the task is stored in.
*
* @return workbasketSummary
*/
WorkbasketSummary getWorkbasketSummary();
/**
* Returns the businessProcessId of a task.
*
* @return businessProcessId Gets the business process id the task belongs to.
*/
String getBusinessProcessId();
/**
* Returns the Domain, to which the Task belongs at this moment.
*
* @return domain the current domain of the task
*/
String getDomain();
/**
* Sets the external business process id.
*
* @param businessProcessId
* Sets the business process id the task belongs to.
*/
void setBusinessProcessId(String businessProcessId);
/**
* Returns the businessProcessId of a task.
*
* @return businessProcessId Gets the business process id the task belongs to.
*/
String getBusinessProcessId();
/**
* Returns the parentBusinessProcessId of a task.
*
* @return parentBusinessProcessId Gets the parent business process id the task belongs to
*/
String getParentBusinessProcessId();
/**
* Sets the external business process id.
*
* @param businessProcessId Sets the business process id the task belongs to.
*/
void setBusinessProcessId(String businessProcessId);
/**
* Sets the parent business process id to group associated processes.
*
* @param parentBusinessProcessId
* Sets the parent business process id the task belongs to
*/
void setParentBusinessProcessId(String parentBusinessProcessId);
/**
* Returns the parentBusinessProcessId of a task.
*
* @return parentBusinessProcessId Gets the parent business process id the task belongs to
*/
String getParentBusinessProcessId();
/**
* Return the id of the task-owner.
*
* @return taskOwnerId
*/
String getOwner();
/**
* Sets the parent business process id to group associated processes.
*
* @param parentBusinessProcessId Sets the parent business process id the task belongs to
*/
void setParentBusinessProcessId(String parentBusinessProcessId);
/**
* Sets the ownerId of this task.
*
* @param taskOwnerId
* the user id of the task's owner
*/
void setOwner(String taskOwnerId);
/**
* Return the id of the task-owner.
*
* @return taskOwnerId
*/
String getOwner();
/**
* Returns the {@link ObjectReference primaryObjectReference} of the task.
*
* @return primaryObjRef to task main-subject
*/
ObjectReference getPrimaryObjRef();
/**
* Sets the ownerId of this task.
*
* @param taskOwnerId the user id of the task's owner
*/
void setOwner(String taskOwnerId);
/**
* Sets the {@link ObjectReference primaryObjectReference} of the task.
*
* @param primaryObjRef
* to task main-subject
*/
void setPrimaryObjRef(ObjectReference primaryObjRef);
/**
* Returns the {@link ObjectReference primaryObjectReference} of the task.
*
* @return primaryObjRef to task main-subject
*/
ObjectReference getPrimaryObjRef();
/**
* Return the isRead-flag, which flags a task as viewed at least one time.
*
* @return isRead-flag
*/
boolean isRead();
/**
* Sets the {@link ObjectReference primaryObjectReference} of the task.
*
* @param primaryObjRef to task main-subject
*/
void setPrimaryObjRef(ObjectReference primaryObjRef);
/**
* Return the isTransferred-flag, which flags a task as transfered into an other workbasket.
*
* @return isTransferred-flag
*/
boolean isTransferred();
/**
* Return the isRead-flag, which flags a task as viewed at least one time.
*
* @return isRead-flag
*/
boolean isRead();
/**
* Returns a Map of custom Attributes.
*
* @return customAttributes as {@link Map}
*/
Map<String, String> getCustomAttributes();
/**
* Return the isTransferred-flag, which flags a task as transfered into an other workbasket.
*
* @return isTransferred-flag
*/
boolean isTransferred();
/**
* Sets a Map of custom Attributes.
*
* @param customAttributes
* a {@link Map} that contains the custom attributes
*/
void setCustomAttributes(Map<String, String> customAttributes);
/**
* Returns a Map of custom Attributes.
*
* @return customAttributes as {@link Map}
*/
Map<String, String> getCustomAttributes();
/**
* Returns a Map of Callback info.
*
* @return callbackInfo as {@link Map}
*/
Map<String, String> getCallbackInfo();
/**
* Sets a Map of custom Attributes.
*
* @param customAttributes a {@link Map} that contains the custom attributes
*/
void setCustomAttributes(Map<String, String> customAttributes);
/**
* Sets a Map of callback info.
*
* @param callbackInfo
* a {@link Map} that contains the callback info
*/
void setCallbackInfo(Map<String, String> callbackInfo);
/**
* Returns a Map of Callback info.
*
* @return callbackInfo as {@link Map}
*/
Map<String, String> getCallbackInfo();
/**
* Return the value for custom Attribute number num.
*
* @param num
* identifies which custom attribute is requested. Taskana concatenates "custom_" with num and the
* resulting String must match the name of the database column that contains the custom attribute. Valid
* values are "1", "2" .. "16"
* @return the value of custom attribute number num
* @throws InvalidArgumentException
* if num has not a value of "1", "2" ... "16"
*/
String getCustomAttribute(String num) throws InvalidArgumentException;
/**
* Sets a Map of callback info.
*
* @param callbackInfo a {@link Map} that contains the callback info
*/
void setCallbackInfo(Map<String, String> callbackInfo);
/**
* Sets the value for custom Attribute number num.
*
* @param num
* identifies which custom attribute is to be set. Taskana concatenates "custom_" with num and the
* resulting String must match the name of the database column that contains the custom attribute. Valid
* values are "1", "2" .. "16"
* @param value
* the value of the custom attribute to be set
* @throws InvalidArgumentException
* if num has not a value of "1", "2" ... "16"
*/
void setCustomAttribute(String num, String value) throws InvalidArgumentException;
/**
* Return the value for custom Attribute number num.
*
* @param num identifies which custom attribute is requested. Taskana concatenates "custom_" with
* num and the resulting String must match the name of the database column that contains the
* custom attribute. Valid values are "1", "2" .. "16"
* @return the value of custom attribute number num
* @throws InvalidArgumentException if num has not a value of "1", "2" ... "16"
*/
String getCustomAttribute(String num) throws InvalidArgumentException;
/**
* Add an attachment.<br>
* NULL will be ignored and an attachment with the same ID will be replaced by the newer one.<br>
*
* @param attachment
* the {@link Attachment attachment} to be added to the task
*/
void addAttachment(Attachment attachment);
/**
* Sets the value for custom Attribute number num.
*
* @param num identifies which custom attribute is to be set. Taskana concatenates "custom_" with
* num and the resulting String must match the name of the database column that contains the
* custom attribute. Valid values are "1", "2" .. "16"
* @param value the value of the custom attribute to be set
* @throws InvalidArgumentException if num has not a value of "1", "2" ... "16"
*/
void setCustomAttribute(String num, String value) throws InvalidArgumentException;
/**
* Return the attachments for this task. <br>
* Do not use List.add()/addAll() for adding Elements, because it can cause redundant data. Use addAttachment().
* Clear() and remove() can be used, because it´s a controllable change.
*
* @return the {@link List list} of {@link Attachment attachments} for this task
*/
List<Attachment> getAttachments();
/**
* Add an attachment.<br>
* NULL will be ignored and an attachment with the same ID will be replaced by the newer one.<br>
*
* @param attachment the {@link Attachment attachment} to be added to the task
*/
void addAttachment(Attachment attachment);
/**
* Returns the custom note for this Task.
*
* @return the custom note for this TAsk
*/
String getNote();
/**
* Return the attachments for this task. <br>
* Do not use List.add()/addAll() for adding Elements, because it can cause redundant data. Use
* addAttachment(). Clear() and remove() can be used, because it´s a controllable change.
*
* @return the {@link List list} of {@link Attachment attachments} for this task
*/
List<Attachment> getAttachments();
/**
* Sets/Changing the custom note for this Task.
*
* @param note
* the custom note for this Task.
*/
void setNote(String note);
/**
* Returns the custom note for this Task.
*
* @return the custom note for this TAsk
*/
String getNote();
/**
* Return a summary of the current Task.
*
* @return the TaskSummary object for the current task
*/
TaskSummary asSummary();
/**
* Sets/Changing the custom note for this Task.
*
* @param note the custom note for this Task.
*/
void setNote(String note);
/**
* Removes an attachment of the current task locally, when the ID is represented and does return the removed
* attachment or null if there was no match.<br>
* The changed Task need to be updated calling the {@link TaskService#updateTask(Task)}.
*
* @param attachmentID
* ID of the attachment which should be removed.
* @return attachment which will be removed after updating OR null if there was no matching attachment
*/
Attachment removeAttachment(String attachmentID);
/**
* Return a summary of the current Task.
*
* @return the TaskSummary object for the current task
*/
TaskSummary asSummary();
/**
* Returns the category of the current classification.
*
* @return classificationCategory
*/
String getClassificationCategory();
/**
* Removes an attachment of the current task locally, when the ID is represented and does return
* the removed attachment or null if there was no match.<br>
* The changed Task need to be updated calling the {@link TaskService#updateTask(Task)}.
*
* @param attachmentID ID of the attachment which should be removed.
* @return attachment which will be removed after updating OR null if there was no matching
* attachment
*/
Attachment removeAttachment(String attachmentID);
/**
* The key that is used to supply Callback_state within the CallbackInfo map.
* The Callback_state is used predominantly by the taskana adapter. It controls synchronization between taskana and the external system.
*
*/
String CALLBACK_STATE = "callbackState";
/**
* Returns the category of the current classification.
*
* @return classificationCategory
*/
String getClassificationCategory();
}

View File

@ -3,62 +3,58 @@ package pro.taskana;
import pro.taskana.report.CategoryReport;
import pro.taskana.report.ClassificationReport;
import pro.taskana.report.CustomFieldValueReport;
import pro.taskana.report.TimestampReport;
import pro.taskana.report.TaskStatusReport;
import pro.taskana.report.TimestampReport;
import pro.taskana.report.WorkbasketReport;
/**
* The Task Monitor Service manages operations on tasks regarding the monitoring.
*/
/** The Task Monitor Service manages operations on tasks regarding the monitoring. */
public interface TaskMonitorService {
/**
* Provides a {@link WorkbasketReport.Builder} for creating a {@link WorkbasketReport}, list the task ids of this report
* and list the values of an entered custom attribute.
*
* @return a {@link WorkbasketReport.Builder}
*/
WorkbasketReport.Builder createWorkbasketReportBuilder();
/**
* Provides a {@link WorkbasketReport.Builder} for creating a {@link WorkbasketReport}, list the
* task ids of this report and list the values of an entered custom attribute.
*
* @return a {@link WorkbasketReport.Builder}
*/
WorkbasketReport.Builder createWorkbasketReportBuilder();
/**
* Provides a {@link CategoryReport.Builder} for creating a {@link CategoryReport}, list the task ids of this report and list
* the values of an entered custom attribute.
*
* @return a {@link CategoryReport.Builder}
*/
CategoryReport.Builder createCategoryReportBuilder();
/**
* Provides a {@link CategoryReport.Builder} for creating a {@link CategoryReport}, list the task
* ids of this report and list the values of an entered custom attribute.
*
* @return a {@link CategoryReport.Builder}
*/
CategoryReport.Builder createCategoryReportBuilder();
/**
* Provides a {@link ClassificationReport.Builder} for creating a {@link ClassificationReport} or a
* DetailedClassificationReport, list the task ids of these reports and list the values of an entered custom
* attribute.
*
* @return a {@link ClassificationReport.Builder}
*/
ClassificationReport.Builder createClassificationReportBuilder();
/**
* Provides a {@link ClassificationReport.Builder} for creating a {@link ClassificationReport} or
* a DetailedClassificationReport, list the task ids of these reports and list the values of an
* entered custom attribute.
*
* @return a {@link ClassificationReport.Builder}
*/
ClassificationReport.Builder createClassificationReportBuilder();
/**
* Provides a {@link CustomFieldValueReport.Builder} for creating a {@link CustomFieldValueReport} and list the values of
* an entered custom attribute.
*
* @param customField
* the customField whose values should appear in the report
* @return a {@link CustomFieldValueReport.Builder}
*/
CustomFieldValueReport.Builder createCustomFieldValueReportBuilder(CustomField customField);
/**
* Provides a {@link CustomFieldValueReport.Builder} for creating a {@link CustomFieldValueReport}
* and list the values of an entered custom attribute.
*
* @param customField the customField whose values should appear in the report
* @return a {@link CustomFieldValueReport.Builder}
*/
CustomFieldValueReport.Builder createCustomFieldValueReportBuilder(CustomField customField);
/**
* Provides a {@link TaskStatusReport.Builder} for creating a {@link TaskStatusReport}.
*
* @return a {@link TaskStatusReport.Builder}
*/
TaskStatusReport.Builder createTaskStatusReportBuilder();
/**
* Provides a {@link TimestampReport.Builder} for creating a {@link TimestampReport}.
*
* @return a {@link TimestampReport.Builder}
*/
TimestampReport.Builder createTimestampReportBuilder();
/**
* Provides a {@link TaskStatusReport.Builder} for creating a {@link TaskStatusReport}.
*
* @return a {@link TaskStatusReport.Builder}
*/
TaskStatusReport.Builder createTaskStatusReportBuilder();
/**
* Provides a {@link TimestampReport.Builder} for creating a {@link TimestampReport}.
*
* @return a {@link TimestampReport.Builder}
*/
TimestampReport.Builder createTimestampReportBuilder();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,75 +1,77 @@
package pro.taskana;
/**
* Enum containing the column names for @see pro.taskana.mappings.QueryMapper#queryTaskColumnValues(pro.taskana.impl.TaskQueryImpl).
* Enum containing the column names for @see
* pro.taskana.mappings.QueryMapper#queryTaskColumnValues(pro.taskana.impl.TaskQueryImpl).
*
* @author jsa
*/
public enum TaskQueryColumnName implements QueryColumnName {
ID("t.id"),
EXTERNAL_ID("t.external_id"),
CREATED("t.created"),
CLAIMED("t.claimed"),
COMPLETED("t.completed"),
MODIFIED("t.modified"),
PLANNED("t.planned"),
DUE("t.due"),
NAME("t.name"),
CREATOR("t.creator"),
DESCRIPTION("t.description"),
NOTE("t.note"),
PRIORITY("t.priority"),
STATE("t.state"),
CLASSIFICATION_CATEGORY("t.classification_category"),
CLASSIFICATION_KEY("t.classification_key"),
CLASSIFICATION_ID("t.classification_id"),
CLASSIFICATION_NAME("c.name"),
WORKBASKET_ID("t.workbasket_id"),
WORKBASKET_KEY("t.workbasket_key"),
DOMAIN("t.domain"),
BUSINESS_PROCESS_ID("t.business_process_id"),
PARENT_BUSINESS_PROCESS_ID("t.parent_business_process_id"),
OWNER("t.owner"),
POR_COMPANY("t.por_company"),
POR_SYSTEM("t.por_system"),
POR_INSTANCE("t.por_instance"),
POR_TYPE("t.por_type"),
POR_VALUE("t.por_value"),
IS_READ("t.is_read"),
IS_TRANSFERRED("t.is_transferred"),
CUSTOM_1("t.custom_1"),
CUSTOM_2("t.custom_2"),
CUSTOM_3("t.custom_3"),
CUSTOM_4("t.custom_4"),
CUSTOM_5("t.custom_5"),
CUSTOM_6("t.custom_6"),
CUSTOM_7("t.custom_7"),
CUSTOM_8("t.custom_8"),
CUSTOM_9("t.custom_9"),
CUSTOM_10("t.custom_10"),
CUSTOM_11("t.custom_11"),
CUSTOM_12("t.custom_12"),
CUSTOM_13("t.custom_13"),
CUSTOM_14("t.custom_14"),
CUSTOM_15("t.custom_15"),
CUSTOM_16("t.custom_16"),
A_CLASSIFICATION_KEY("a.classification_key"),
A_CLASSIFICATION_ID("a.classification_id"),
A_CLASSIFICATION_NAME("ac.name"),
A_CHANNEL("a.channel"),
A_REF_VALUE("a.ref_value");
ID("t.id"),
EXTERNAL_ID("t.external_id"),
CREATED("t.created"),
CLAIMED("t.claimed"),
COMPLETED("t.completed"),
MODIFIED("t.modified"),
PLANNED("t.planned"),
DUE("t.due"),
NAME("t.name"),
CREATOR("t.creator"),
DESCRIPTION("t.description"),
NOTE("t.note"),
PRIORITY("t.priority"),
STATE("t.state"),
CLASSIFICATION_CATEGORY("t.classification_category"),
CLASSIFICATION_KEY("t.classification_key"),
CLASSIFICATION_ID("t.classification_id"),
CLASSIFICATION_NAME("c.name"),
WORKBASKET_ID("t.workbasket_id"),
WORKBASKET_KEY("t.workbasket_key"),
DOMAIN("t.domain"),
BUSINESS_PROCESS_ID("t.business_process_id"),
PARENT_BUSINESS_PROCESS_ID("t.parent_business_process_id"),
OWNER("t.owner"),
POR_COMPANY("t.por_company"),
POR_SYSTEM("t.por_system"),
POR_INSTANCE("t.por_instance"),
POR_TYPE("t.por_type"),
POR_VALUE("t.por_value"),
IS_READ("t.is_read"),
IS_TRANSFERRED("t.is_transferred"),
CUSTOM_1("t.custom_1"),
CUSTOM_2("t.custom_2"),
CUSTOM_3("t.custom_3"),
CUSTOM_4("t.custom_4"),
CUSTOM_5("t.custom_5"),
CUSTOM_6("t.custom_6"),
CUSTOM_7("t.custom_7"),
CUSTOM_8("t.custom_8"),
CUSTOM_9("t.custom_9"),
CUSTOM_10("t.custom_10"),
CUSTOM_11("t.custom_11"),
CUSTOM_12("t.custom_12"),
CUSTOM_13("t.custom_13"),
CUSTOM_14("t.custom_14"),
CUSTOM_15("t.custom_15"),
CUSTOM_16("t.custom_16"),
A_CLASSIFICATION_KEY("a.classification_key"),
A_CLASSIFICATION_ID("a.classification_id"),
A_CLASSIFICATION_NAME("ac.name"),
A_CHANNEL("a.channel"),
A_REF_VALUE("a.ref_value");
private String name;
TaskQueryColumnName(String name) {
this.name = name;
}
private String name;
@Override
public String toString() {
return name;
}
TaskQueryColumnName(String name) {
this.name = name;
}
public boolean isAttachmentColumn() {
return this.name().startsWith("A_");
}
public boolean isAttachmentColumn() {
return this.name().startsWith("A_");
}
@Override
public String toString() {
return name;
}
}

View File

@ -15,418 +15,356 @@ import pro.taskana.exceptions.TaskNotFoundException;
import pro.taskana.exceptions.TaskanaException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
/**
* The Task Service manages all operations on tasks.
*/
/** The Task Service manages all operations on tasks. */
public interface TaskService {
/**
* Claim an existing task for the current user.
*
* @param taskId
* the id of the task to be claimed
* @return claimed Task
* @throws TaskNotFoundException
* if the task with taskId was not found
* @throws InvalidStateException
* if the state of the task with taskId is not READY
* @throws InvalidOwnerException
* if the task with taskId is claimed by some else
* @throws NotAuthorizedException
* if the current user has no read permission for the workbasket the task is in
*/
Task claim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
/**
* Claim an existing task for the current user.
*
* @param taskId the id of the task to be claimed
* @return claimed Task
* @throws TaskNotFoundException if the task with taskId was not found
* @throws InvalidStateException if the state of the task with taskId is not READY
* @throws InvalidOwnerException if the task with taskId is claimed by some else
* @throws NotAuthorizedException if the current user has no read permission for the workbasket
* the task is in
*/
Task claim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException;
/**
* Claim an existing task for the current user even if it is already claimed by someone else.
*
* @param taskId
* the id of the task to be claimed
* @return claimed Task
* @throws TaskNotFoundException
* if the task with taskId was not found
* @throws InvalidStateException
* if the state of the task with taskId is not READY
* @throws InvalidOwnerException
* if the task with taskId is claimed by someone else
* @throws NotAuthorizedException
* if the current user has no read permission for the workbasket the task is in
*/
Task forceClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
/**
* Claim an existing task for the current user even if it is already claimed by someone else.
*
* @param taskId the id of the task to be claimed
* @return claimed Task
* @throws TaskNotFoundException if the task with taskId was not found
* @throws InvalidStateException if the state of the task with taskId is not READY
* @throws InvalidOwnerException if the task with taskId is claimed by someone else
* @throws NotAuthorizedException if the current user has no read permission for the workbasket
* the task is in
*/
Task forceClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException;
/**
* Cancel the claim of an existing task if it was claimed by the current user before.
*
* @param taskId
* id of the task which should be unclaimed.
* @return updated unclaimed task
* @throws TaskNotFoundException
* if the task can´t be found or does not exist
* @throws InvalidStateException
* when the task is already completed.
* @throws InvalidOwnerException
* when the task is claimed by another user.
* @throws NotAuthorizedException
* if the current user has no read permission for the workbasket the task is in
*/
Task cancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
/**
* Cancel the claim of an existing task if it was claimed by the current user before.
*
* @param taskId id of the task which should be unclaimed.
* @return updated unclaimed task
* @throws TaskNotFoundException if the task can´t be found or does not exist
* @throws InvalidStateException when the task is already completed.
* @throws InvalidOwnerException when the task is claimed by another user.
* @throws NotAuthorizedException if the current user has no read permission for the workbasket
* the task is in
*/
Task cancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException;
/**
* Cancel the claim of an existing task even if it was claimed by another user.
*
* @param taskId
* id of the task which should be unclaimed.
* @return updated unclaimed task
* @throws TaskNotFoundException
* if the task can´t be found or does not exist
* @throws InvalidStateException
* when the task is already completed.
* @throws InvalidOwnerException
* when forceCancel is false and the task is claimed by another user.
* @throws NotAuthorizedException
* if the current user has no read permission for the workbasket the task is in
*/
Task forceCancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException, NotAuthorizedException;
/**
* Cancel the claim of an existing task even if it was claimed by another user.
*
* @param taskId id of the task which should be unclaimed.
* @return updated unclaimed task
* @throws TaskNotFoundException if the task can´t be found or does not exist
* @throws InvalidStateException when the task is already completed.
* @throws InvalidOwnerException when forceCancel is false and the task is claimed by another
* user.
* @throws NotAuthorizedException if the current user has no read permission for the workbasket
* the task is in
*/
Task forceCancelClaim(String taskId)
throws TaskNotFoundException, InvalidStateException, InvalidOwnerException,
NotAuthorizedException;
/**
* Complete a claimed Task as owner/admin and update State and Timestamps. If task is already completed, the task is
* returned as itself.
*
* @param taskId
* - Id of the Task which should be completed.
* @return Task - updated task after completion.
* @throws InvalidStateException
* when Task wasn´t claimed before.
* @throws TaskNotFoundException
* if the given Task can´t be found in DB.
* @throws InvalidOwnerException
* if current user is not the task-owner or administrator.
* @throws NotAuthorizedException
* if the current user has no read permission for the workbasket the task is in
*/
Task completeTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException;
/**
* Complete a claimed Task as owner/admin and update State and Timestamps. If task is already
* completed, the task is returned as itself.
*
* @param taskId - Id of the Task which should be completed.
* @return Task - updated task after completion.
* @throws InvalidStateException when Task wasn´t claimed before.
* @throws TaskNotFoundException if the given Task can´t be found in DB.
* @throws InvalidOwnerException if current user is not the task-owner or administrator.
* @throws NotAuthorizedException if the current user has no read permission for the workbasket
* the task is in
*/
Task completeTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException,
NotAuthorizedException;
/**
* Complete a Task and update State and Timestamps in every case if the Task exists. If task is already completed,
* the task is returned as itself.
*
* @param taskId
* - Id of the Task which should be completed.
* @return Task - updated task after completion.
* @throws InvalidStateException
* when Task wasn´t claimed before.
* @throws TaskNotFoundException
* if the given Task can´t be found in DB.
* @throws InvalidOwnerException
* if current user is not the task-owner or administrator.
* @throws NotAuthorizedException
* if the current user has no read permission for the workbasket the task is in
*/
Task forceCompleteTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException, NotAuthorizedException;
/**
* Complete a Task and update State and Timestamps in every case if the Task exists. If task is
* already completed, the task is returned as itself.
*
* @param taskId - Id of the Task which should be completed.
* @return Task - updated task after completion.
* @throws InvalidStateException when Task wasn´t claimed before.
* @throws TaskNotFoundException if the given Task can´t be found in DB.
* @throws InvalidOwnerException if current user is not the task-owner or administrator.
* @throws NotAuthorizedException if the current user has no read permission for the workbasket
* the task is in
*/
Task forceCompleteTask(String taskId)
throws TaskNotFoundException, InvalidOwnerException, InvalidStateException,
NotAuthorizedException;
/**
* Persists a not persisted Task which does not exist already.
*
* @param taskToCreate
* the transient task object to be persisted
* @return the created and persisted task
* @throws TaskAlreadyExistException
* when the Task does already exist.
* @throws NotAuthorizedException
* thrown if the current user is not authorized to create that task
* @throws WorkbasketNotFoundException
* thrown if the work basket referenced by the task is not found
* @throws ClassificationNotFoundException
* thrown if the {@link Classification} referenced by the task is not found
* @throws InvalidArgumentException
* thrown if the primary ObjectReference is invalid
*/
Task createTask(Task taskToCreate)
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, InvalidArgumentException;
/**
* Persists a not persisted Task which does not exist already.
*
* @param taskToCreate the transient task object to be persisted
* @return the created and persisted task
* @throws TaskAlreadyExistException when the Task does already exist.
* @throws NotAuthorizedException thrown if the current user is not authorized to create that task
* @throws WorkbasketNotFoundException thrown if the work basket referenced by the task is not
* found
* @throws ClassificationNotFoundException thrown if the {@link Classification} referenced by the
* task is not found
* @throws InvalidArgumentException thrown if the primary ObjectReference is invalid
*/
Task createTask(Task taskToCreate)
throws NotAuthorizedException, WorkbasketNotFoundException, ClassificationNotFoundException,
TaskAlreadyExistException, InvalidArgumentException;
/**
* Get the details of a task by Id without checking permissions.
*
* @param taskId
* the id of the task
* @return the Task
* @throws TaskNotFoundException
* thrown of the {@link Task} with taskId is not found
* @throws NotAuthorizedException
* if the current user has no READ permission for the workbasket the task is in.
*/
Task getTask(String taskId) throws TaskNotFoundException, NotAuthorizedException;
/**
* Get the details of a task by Id without checking permissions.
*
* @param taskId the id of the task
* @return the Task
* @throws TaskNotFoundException thrown of the {@link Task} with taskId is not found
* @throws NotAuthorizedException if the current user has no READ permission for the workbasket
* the task is in.
*/
Task getTask(String taskId) throws TaskNotFoundException, NotAuthorizedException;
/**
* Transfer a task to another work basket. The transfer sets the transferred flag and resets the read flag.
*
* @param taskId
* The id of the {@link Task} to be transferred
* @param destinationWorkbasketId
* The Id of the target work basket
* @return the transferred task
* @throws TaskNotFoundException
* Thrown if the {@link Task} with taskId was not found.
* @throws WorkbasketNotFoundException
* Thrown if the target work basket was not found.
* @throws NotAuthorizedException
* Thrown if the current user is not authorized to transfer this {@link Task} to the target work basket
* @throws InvalidStateException
* Thrown if the task is in a state which does not allow transferring
*/
Task transfer(String taskId, String destinationWorkbasketId)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException;
/**
* Transfer a task to another work basket. The transfer sets the transferred flag and resets the
* read flag.
*
* @param taskId The id of the {@link Task} to be transferred
* @param destinationWorkbasketId The Id of the target work basket
* @return the transferred task
* @throws TaskNotFoundException Thrown if the {@link Task} with taskId was not found.
* @throws WorkbasketNotFoundException Thrown if the target work basket was not found.
* @throws NotAuthorizedException Thrown if the current user is not authorized to transfer this
* {@link Task} to the target work basket
* @throws InvalidStateException Thrown if the task is in a state which does not allow
* transferring
*/
Task transfer(String taskId, String destinationWorkbasketId)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
InvalidStateException;
/**
* Transfer a task to another work basket. The transfer sets the transferred flag and resets the read flag.
*
* @param taskId
* The id of the {@link Task} to be transferred
* @param workbasketKey
* The key of the target work basket
* @param domain
* The domain of the target work basket
* @return the transferred task
* @throws TaskNotFoundException
* Thrown if the {@link Task} with taskId was not found.
* @throws WorkbasketNotFoundException
* Thrown if the target work basket was not found.
* @throws NotAuthorizedException
* Thrown if the current user is not authorized to transfer this {@link Task} to the target work basket
* @throws InvalidStateException
* Thrown if the task is in a state which does not allow transferring
*/
Task transfer(String taskId, String workbasketKey, String domain)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException, InvalidStateException;
/**
* Transfer a task to another work basket. The transfer sets the transferred flag and resets the
* read flag.
*
* @param taskId The id of the {@link Task} to be transferred
* @param workbasketKey The key of the target work basket
* @param domain The domain of the target work basket
* @return the transferred task
* @throws TaskNotFoundException Thrown if the {@link Task} with taskId was not found.
* @throws WorkbasketNotFoundException Thrown if the target work basket was not found.
* @throws NotAuthorizedException Thrown if the current user is not authorized to transfer this
* {@link Task} to the target work basket
* @throws InvalidStateException Thrown if the task is in a state which does not allow
* transferring
*/
Task transfer(String taskId, String workbasketKey, String domain)
throws TaskNotFoundException, WorkbasketNotFoundException, NotAuthorizedException,
InvalidStateException;
/**
* Marks a task as read.
*
* @param taskId
* the id of the task to be updated
* @param isRead
* the new status of the read flag.
* @return the updated Task
* @throws TaskNotFoundException
* Thrown if the {@link Task} with taskId was not found
* @throws NotAuthorizedException
* if the current user has no read permission for the workbasket the task is in
*/
Task setTaskRead(String taskId, boolean isRead)
throws TaskNotFoundException, NotAuthorizedException;
/**
* Marks a task as read.
*
* @param taskId the id of the task to be updated
* @param isRead the new status of the read flag.
* @return the updated Task
* @throws TaskNotFoundException Thrown if the {@link Task} with taskId was not found
* @throws NotAuthorizedException if the current user has no read permission for the workbasket
* the task is in
*/
Task setTaskRead(String taskId, boolean isRead)
throws TaskNotFoundException, NotAuthorizedException;
/**
* This method provides a query builder for quering the database.
*
* @return a {@link TaskQuery}
*/
TaskQuery createTaskQuery();
/**
* This method provides a query builder for quering the database.
*
* @return a {@link TaskQuery}
*/
TaskQuery createTaskQuery();
/**
* Returns a not persisted instance of {@link Task}.
* The returned task has no workbasket Id set. When createTask() is
* invoked for this task, TaskService will call the TaskRouting SPI to
* determine a workbasket for the task. If the TaskRouting API is not active,
* e.g. because no TaskRouter is registered, or the TaskRouter(s) don't find a workbasket,
* the task will not be persisted.
*
* @return an empty new Task
*/
Task newTask();
/**
* Returns a not persisted instance of {@link Task}. The returned task has no workbasket Id set.
* When createTask() is invoked for this task, TaskService will call the TaskRouting SPI to
* determine a workbasket for the task. If the TaskRouting API is not active, e.g. because no
* TaskRouter is registered, or the TaskRouter(s) don't find a workbasket, the task will not be
* persisted.
*
* @return an empty new Task
*/
Task newTask();
/**
* Returns a not persisted instance of {@link Task}.
*
* @param workbasketId
* the id of the workbasket to which the task belongs
* @return an empty new Task
*/
Task newTask(String workbasketId);
/**
* Returns a not persisted instance of {@link Task}.
*
* @param workbasketId the id of the workbasket to which the task belongs
* @return an empty new Task
*/
Task newTask(String workbasketId);
/**
* Returns a not persisted instance of {@link Task}.
*
* @param workbasketKey
* the key of the workbasket to which the task belongs
* @param domain
* the domain of the workbasket to which the task belongs
* @return an empty new Task
*/
Task newTask(String workbasketKey, String domain);
/**
* Returns a not persisted instance of {@link Task}.
*
* @param workbasketKey the key of the workbasket to which the task belongs
* @param domain the domain of the workbasket to which the task belongs
* @return an empty new Task
*/
Task newTask(String workbasketKey, String domain);
/**
* Returns a not persisted instance of {@link Attachment}.
*
* @return an empty new Attachment
*/
Attachment newAttachment();
/**
* Returns a not persisted instance of {@link Attachment}.
*
* @return an empty new Attachment
*/
Attachment newAttachment();
/**
* Update a task.
*
* @param task
* the task to be updated in the database
* @return the updated task
* @throws InvalidArgumentException
* if the task to be updated contains invalid properties like e.g. invalid object references
* @throws TaskNotFoundException
* if the id of the task is not found in the database
* @throws ConcurrencyException
* if the task has already been updated by another user
* @throws ClassificationNotFoundException
* if the updated task refers to a classification that cannot be found
* @throws NotAuthorizedException
* if the current user is not authorized to update the task
* @throws AttachmentPersistenceException
* if an Attachment with ID will be added multiple times without using the task-methods.
*/
Task updateTask(Task task) throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException,
ClassificationNotFoundException, NotAuthorizedException, AttachmentPersistenceException;
/**
* Update a task.
*
* @param task the task to be updated in the database
* @return the updated task
* @throws InvalidArgumentException if the task to be updated contains invalid properties like
* e.g. invalid object references
* @throws TaskNotFoundException if the id of the task is not found in the database
* @throws ConcurrencyException if the task has already been updated by another user
* @throws ClassificationNotFoundException if the updated task refers to a classification that
* cannot be found
* @throws NotAuthorizedException if the current user is not authorized to update the task
* @throws AttachmentPersistenceException if an Attachment with ID will be added multiple times
* without using the task-methods.
*/
Task updateTask(Task task)
throws InvalidArgumentException, TaskNotFoundException, ConcurrencyException,
ClassificationNotFoundException, NotAuthorizedException, AttachmentPersistenceException;
/**
* Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got no permissions on
* the target or it doesn´t exist. Other Exceptions will be stored and returned in the end.
*
* @param destinationWorkbasketId
* target workbasket id
* @param taskIds
* source task which will be moved
* @return Bulkresult with ID and Error in it for failed transactions.
* @throws NotAuthorizedException
* if the caller hasn´t permissions on tarket WB.
* @throws InvalidArgumentException
* if the method paramesters are EMPTY or NULL.
* @throws WorkbasketNotFoundException
* if the target WB can´t be found.
*/
BulkOperationResults<String, TaskanaException> transferTasks(String destinationWorkbasketId, List<String> taskIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException;
/**
* Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got
* no permissions on the target or it doesn´t exist. Other Exceptions will be stored and returned
* in the end.
*
* @param destinationWorkbasketId target workbasket id
* @param taskIds source task which will be moved
* @return Bulkresult with ID and Error in it for failed transactions.
* @throws NotAuthorizedException if the caller hasn´t permissions on tarket WB.
* @throws InvalidArgumentException if the method paramesters are EMPTY or NULL.
* @throws WorkbasketNotFoundException if the target WB can´t be found.
*/
BulkOperationResults<String, TaskanaException> transferTasks(
String destinationWorkbasketId, List<String> taskIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException;
/**
* Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got no permissions on
* the target or it doesn´t exist. Other Exceptions will be stored and returned in the end.
*
* @param destinationWorkbasketKey
* target workbasket key
* @param destinationWorkbasketDomain
* target workbasket domain
* @param taskIds
* source task which will be moved
* @return Bulkresult with ID and Error in it for failed transactions.
* @throws NotAuthorizedException
* if the caller hasn´t permissions on tarket WB.
* @throws InvalidArgumentException
* if the method paramesters are EMPTY or NULL.
* @throws WorkbasketNotFoundException
* if the target WB can´t be found.
*/
BulkOperationResults<String, TaskanaException> transferTasks(String destinationWorkbasketKey,
String destinationWorkbasketDomain, List<String> taskIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException;
/**
* Transfers a list of tasks to an other workbasket. Exceptions will be thrown if the caller got
* no permissions on the target or it doesn´t exist. Other Exceptions will be stored and returned
* in the end.
*
* @param destinationWorkbasketKey target workbasket key
* @param destinationWorkbasketDomain target workbasket domain
* @param taskIds source task which will be moved
* @return Bulkresult with ID and Error in it for failed transactions.
* @throws NotAuthorizedException if the caller hasn´t permissions on tarket WB.
* @throws InvalidArgumentException if the method paramesters are EMPTY or NULL.
* @throws WorkbasketNotFoundException if the target WB can´t be found.
*/
BulkOperationResults<String, TaskanaException> transferTasks(
String destinationWorkbasketKey, String destinationWorkbasketDomain, List<String> taskIds)
throws NotAuthorizedException, InvalidArgumentException, WorkbasketNotFoundException;
/**
* Deletes the task with the given Id.
*
* @param taskId
* The Id of the task to delete.
* @throws TaskNotFoundException
* If the given Id does not refer to an existing task.
* @throws InvalidStateException
* If the state of the referenced task is not Completed.
* @throws NotAuthorizedException
* if the current user is not member of role ADMIN
*/
void deleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
/**
* Deletes the task with the given Id.
*
* @param taskId The Id of the task to delete.
* @throws TaskNotFoundException If the given Id does not refer to an existing task.
* @throws InvalidStateException If the state of the referenced task is not Completed.
* @throws NotAuthorizedException if the current user is not member of role ADMIN
*/
void deleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
/**
* Deletes the task with the given Id even if it is not completed.
*
* @param taskId
* The Id of the task to delete.
* @throws TaskNotFoundException
* If the given Id does not refer to an existing task.
* @throws InvalidStateException
* If the state of the referenced task is not Completed and forceDelet is false.
* @throws NotAuthorizedException
* if the current user is not member of role ADMIN
*/
void forceDeleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
/**
* Deletes the task with the given Id even if it is not completed.
*
* @param taskId The Id of the task to delete.
* @throws TaskNotFoundException If the given Id does not refer to an existing task.
* @throws InvalidStateException If the state of the referenced task is not Completed and
* forceDelet is false.
* @throws NotAuthorizedException if the current user is not member of role ADMIN
*/
void forceDeleteTask(String taskId)
throws TaskNotFoundException, InvalidStateException, NotAuthorizedException;
/**
* Deletes a list of tasks.
*
* @param tasks
* the ids of the tasks to delete.
* @return the result of the operations with Id and Exception for each failed task deletion.
* @throws InvalidArgumentException
* if the TaskIds parameter is NULL
*/
BulkOperationResults<String, TaskanaException> deleteTasks(List<String> tasks) throws InvalidArgumentException;
/**
* Deletes a list of tasks.
*
* @param tasks the ids of the tasks to delete.
* @return the result of the operations with Id and Exception for each failed task deletion.
* @throws InvalidArgumentException if the TaskIds parameter is NULL
*/
BulkOperationResults<String, TaskanaException> deleteTasks(List<String> tasks)
throws InvalidArgumentException;
/**
* Completes a list of tasks.
*
* @param taskIds
* of the tasks which should be completed.
* @return the result of the operations with Id and Exception for each failed task completion.
* @throws InvalidArgumentException
* If the taskId parameter is NULL.
*/
BulkOperationResults<String, TaskanaException> completeTasks(List<String> taskIds)
throws InvalidArgumentException;
/**
* Completes a list of tasks.
*
* @param taskIds of the tasks which should be completed.
* @return the result of the operations with Id and Exception for each failed task completion.
* @throws InvalidArgumentException If the taskId parameter is NULL.
*/
BulkOperationResults<String, TaskanaException> completeTasks(List<String> taskIds)
throws InvalidArgumentException;
/**
* Updates tasks with a matching {@link ObjectReference}.
*
* @param selectionCriteria
* the {@link ObjectReference} that is used to select the tasks.
* @param customFieldsToUpdate
* a {@link Map} that contains as key the identification of the custom field and as value the
* corresponding new value of that custom field. The key for identification of the custom field must be a
* String with value "1", "2" ... "16" as in the setCustomAttribute or getCustomAttribute method of
* {@link Task}
* @return a list of the Ids of all modified tasks
* @throws InvalidArgumentException
* If the customFieldsToUpdate map contains an invalid key or if the selectionCriteria is invalid
*/
List<String> updateTasks(ObjectReference selectionCriteria,
Map<String, String> customFieldsToUpdate) throws InvalidArgumentException;
/**
* Updates tasks with a matching {@link ObjectReference}.
*
* @param selectionCriteria the {@link ObjectReference} that is used to select the tasks.
* @param customFieldsToUpdate a {@link Map} that contains as key the identification of the custom
* field and as value the corresponding new value of that custom field. The key for
* identification of the custom field must be a String with value "1", "2" ... "16" as in the
* setCustomAttribute or getCustomAttribute method of {@link Task}
* @return a list of the Ids of all modified tasks
* @throws InvalidArgumentException If the customFieldsToUpdate map contains an invalid key or if
* the selectionCriteria is invalid
*/
List<String> updateTasks(
ObjectReference selectionCriteria, Map<String, String> customFieldsToUpdate)
throws InvalidArgumentException;
/**
* Updates tasks with matching taskIds.
*
* @param taskIds
* the taskIds that are used to select the tasks.
* @param customFieldsToUpdate
* a {@link Map} that contains as key the identification of the custom field and as value the
* corresponding new value of that custom field. The key for identification of the custom field must be a
* String with value "1", "2" ... "16" as in the setCustomAttribute or getCustomAttribute method of
* {@link Task}
* @return a list of the Ids of all modified tasks
* @throws InvalidArgumentException
* If the customFieldsToUpdate map contains an invalid key or if the selectionCriteria is invalid
*/
List<String> updateTasks(List<String> taskIds,
Map<String, String> customFieldsToUpdate) throws InvalidArgumentException;
/**
* Sets the callback state on a list of tasks.
* Note: this method is primarily intended to be used by the TaskanaAdapter
*
* @param externalIds the EXTERNAL_IDs of the tasks on which the callback state is set.
* @param state the callback state that is to be set on the tasks
*
* @return the result of the operations with Id and Exception for each failed task deletion.
*/
BulkOperationResults<String, TaskanaException> setCallbackStateForTasks(List<String> externalIds, CallbackState state);
/**
* Updates tasks with matching taskIds.
*
* @param taskIds the taskIds that are used to select the tasks.
* @param customFieldsToUpdate a {@link Map} that contains as key the identification of the custom
* field and as value the corresponding new value of that custom field. The key for
* identification of the custom field must be a String with value "1", "2" ... "16" as in the
* setCustomAttribute or getCustomAttribute method of {@link Task}
* @return a list of the Ids of all modified tasks
* @throws InvalidArgumentException If the customFieldsToUpdate map contains an invalid key or if
* the selectionCriteria is invalid
*/
List<String> updateTasks(List<String> taskIds, Map<String, String> customFieldsToUpdate)
throws InvalidArgumentException;
/**
* Sets the callback state on a list of tasks. Note: this method is primarily intended to be used
* by the TaskanaAdapter
*
* @param externalIds the EXTERNAL_IDs of the tasks on which the callback state is set.
* @param state the callback state that is to be set on the tasks
* @return the result of the operations with Id and Exception for each failed task deletion.
*/
BulkOperationResults<String, TaskanaException> setCallbackStateForTasks(
List<String> externalIds, CallbackState state);
}

View File

@ -1,8 +1,8 @@
package pro.taskana;
/**
* This enum contains all status of the tasks.
*/
/** This enum contains all status of the tasks. */
public enum TaskState {
READY, CLAIMED, COMPLETED
READY,
CLAIMED,
COMPLETED
}

View File

@ -6,182 +6,180 @@ import java.util.List;
import pro.taskana.exceptions.InvalidArgumentException;
/**
* Interface for TaskSummary. This is a specific short model-object which only contains the most important information.
* Interface for TaskSummary. This is a specific short model-object which only contains the most
* important information.
*/
public interface TaskSummary {
/**
* Gets the id of the task.
*
* @return taskId
*/
String getTaskId();
/**
* Gets the id of the task.
*
* @return taskId
*/
String getTaskId();
/**
* Gets the external id of the task.
*
* @return the external Id
*/
String getExternalId();
/**
* Gets the external id of the task.
*
* @return the external Id
*/
String getExternalId();
/**
* Gets the name of the task-creator.
*
* @return creator
*/
String getCreator();
/**
* Gets the name of the task-creator.
*
* @return creator
*/
String getCreator();
/**
* Gets the time when the task was created.
*
* @return the created Instant
*/
Instant getCreated();
/**
* Gets the time when the task was created.
*
* @return the created Instant
*/
Instant getCreated();
/**
* Gets the time when the task was claimed.
*
* @return the claimed Instant
*/
Instant getClaimed();
/**
* Gets the time when the task was claimed.
*
* @return the claimed Instant
*/
Instant getClaimed();
/**
* Gets the time when the task was completed.
*
* @return the completed Instant
*/
Instant getCompleted();
/**
* Gets the time when the task was completed.
*
* @return the completed Instant
*/
Instant getCompleted();
/**
* Gets the time when the task was last modified.
*
* @return the last modified Instant
*/
Instant getModified();
/**
* Gets the time when the task was last modified.
*
* @return the last modified Instant
*/
Instant getModified();
/**
* Gets the time when the task is planned to be executed.
*
* @return the planned Instant
*/
Instant getPlanned();
/**
* Gets the time when the task is planned to be executed.
*
* @return the planned Instant
*/
Instant getPlanned();
/**
* Gets the time when the task is due.
*
* @return the due Instant
*/
Instant getDue();
/**
* Gets the time when the task is due.
*
* @return the due Instant
*/
Instant getDue();
/**
* Gets the name of the task.
*
* @return the task's name
*/
String getName();
/**
* Gets the name of the task.
*
* @return the task's name
*/
String getName();
/**
* Gets the note attached to the task.
*
* @return the task's note
*/
String getNote();
/**
* Gets the note attached to the task.
*
* @return the task's note
*/
String getNote();
/**
* Gets the priority of the task.
*
* @return the task's priority
*/
int getPriority();
/**
* Gets the priority of the task.
*
* @return the task's priority
*/
int getPriority();
/**
* Gets the state of the task.
*
* @return the task's state
*/
TaskState getState();
/**
* Gets the state of the task.
*
* @return the task's state
*/
TaskState getState();
/**
* Gets the classification summary of the task.
*
* @return the task's classificationSummary
*/
ClassificationSummary getClassificationSummary();
/**
* Gets the classification summary of the task.
*
* @return the task's classificationSummary
*/
ClassificationSummary getClassificationSummary();
/**
* Gets the workbasket summary of the task.
*
* @return the task's workbasketSummary
*/
WorkbasketSummary getWorkbasketSummary();
/**
* Gets the workbasket summary of the task.
*
* @return the task's workbasketSummary
*/
WorkbasketSummary getWorkbasketSummary();
/**
* Gets the attachment summaries of the task.
*
* @return the task's attachment summaries
*/
List<AttachmentSummary> getAttachmentSummaries();
/**
* Gets the attachment summaries of the task.
*
* @return the task's attachment summaries
*/
List<AttachmentSummary> getAttachmentSummaries();
/**
* Gets the domain of the task.
*
* @return the task's domain
*/
String getDomain();
/**
* Gets the domain of the task.
*
* @return the task's domain
*/
String getDomain();
/**
* Gets the businessProcessId of the task.
*
* @return the task's businessProcessId
*/
String getBusinessProcessId();
/**
* Gets the businessProcessId of the task.
*
* @return the task's businessProcessId
*/
String getBusinessProcessId();
/**
* Gets the parentBusinessProcessId of the task.
*
* @return the task's parentBusinessProcessId
*/
String getParentBusinessProcessId();
/**
* Gets the parentBusinessProcessId of the task.
*
* @return the task's parentBusinessProcessId
*/
String getParentBusinessProcessId();
/**
* Gets the owner of the task.
*
* @return the task's owner
*/
String getOwner();
/**
* Gets the owner of the task.
*
* @return the task's owner
*/
String getOwner();
/**
* Gets the primary ObjectReference of the task.
*
* @return the task's primary ObjectReference
*/
ObjectReference getPrimaryObjRef();
/**
* Gets the primary ObjectReference of the task.
*
* @return the task's primary ObjectReference
*/
ObjectReference getPrimaryObjRef();
/**
* Gets the isRead flag of the task.
*
* @return the task's isRead flag
*/
boolean isRead();
/**
* Gets the isRead flag of the task.
*
* @return the task's isRead flag
*/
boolean isRead();
/**
* Gets the isTransferred flag of the task.
*
* @return the task's isTransferred flag.
*/
boolean isTransferred();
/**
* Gets the custom attribute number num of the task.
*
* @param num
* identifies which custom attribute is requested. Taskana concatenates "custom_" with num and the
* resulting String must match the name of the database column that contains the custom attribute. Valid
* values are "1", "2" .. "16"
* @return the value of custom attribute number num
* @throws InvalidArgumentException
* if num has not a value of "1", "2" ... "16"
*/
String getCustomAttribute(String num) throws InvalidArgumentException;
/**
* Gets the isTransferred flag of the task.
*
* @return the task's isTransferred flag.
*/
boolean isTransferred();
/**
* Gets the custom attribute number num of the task.
*
* @param num identifies which custom attribute is requested. Taskana concatenates "custom_" with
* num and the resulting String must match the name of the database column that contains the
* custom attribute. Valid values are "1", "2" .. "16"
* @return the value of custom attribute number num
* @throws InvalidArgumentException if num has not a value of "1", "2" ... "16"
*/
String getCustomAttribute(String num) throws InvalidArgumentException;
}

View File

@ -5,123 +5,116 @@ import java.sql.SQLException;
import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.NotAuthorizedException;
/**
* The TaskanaEngine represents an overall set of all needed services.
*/
/** The TaskanaEngine represents an overall set of all needed services. */
public interface TaskanaEngine {
/**
* The TaskService can be used for operations on all Tasks.
*
* @return the TaskService
*/
TaskService getTaskService();
/**
* The TaskService can be used for operations on all Tasks.
*
* @return the TaskService
*/
TaskService getTaskService();
/**
* The TaskMonitorService can be used for monitoring Tasks.
*
* @return the TaskMonitorService
*/
TaskMonitorService getTaskMonitorService();
/**
* The TaskMonitorService can be used for monitoring Tasks.
*
* @return the TaskMonitorService
*/
TaskMonitorService getTaskMonitorService();
/**
* The WorkbasketService can be used for operations on all Workbaskets.
*
* @return the TaskService
*/
WorkbasketService getWorkbasketService();
/**
* The WorkbasketService can be used for operations on all Workbaskets.
*
* @return the TaskService
*/
WorkbasketService getWorkbasketService();
/**
* The ClassificationService can be used for operations on all Categories.
*
* @return the TaskService
*/
ClassificationService getClassificationService();
/**
* The ClassificationService can be used for operations on all Categories.
*
* @return the TaskService
*/
ClassificationService getClassificationService();
/**
* The JobService can be user for all job operations.
*
* @return the JobService
*/
JobService getJobService();
/**
* The JobService can be user for all job operations.
*
* @return the JobService
*/
JobService getJobService();
/**
* The Taskana configuration.
*
* @return the TaskanaConfiguration
*/
TaskanaEngineConfiguration getConfiguration();
/**
* The Taskana configuration.
*
* @return the TaskanaConfiguration
*/
TaskanaEngineConfiguration getConfiguration();
/**
* Checks if the history plugin is enabled.
*
* @return true if the history is enabled. Otherwise false.
*/
boolean isHistoryEnabled();
/**
* Checks if the history plugin is enabled.
*
* @return true if the history is enabled. Otherwise false.
*/
boolean isHistoryEnabled();
/**
* sets the connection management mode.
*
* @param mode
* the connection management mode Valid values are:
* <ul>
* <li>PARTICIPATE - taskana participates in global transaction. This is the default mode.</li>
* <li>AUTOCOMMIT - taskana commits each API call separately</li>
* <li>EXPLICIT - commit processing is managed explicitly by the client</li>
* </ul>
*/
void setConnectionManagementMode(ConnectionManagementMode mode);
/**
* sets the connection management mode.
*
* @param mode the connection management mode Valid values are:
* <ul>
* <li>PARTICIPATE - taskana participates in global transaction. This is the default mode.
* <li>AUTOCOMMIT - taskana commits each API call separately
* <li>EXPLICIT - commit processing is managed explicitly by the client
* </ul>
*/
void setConnectionManagementMode(ConnectionManagementMode mode);
/**
* Set the connection to be used by taskana in mode CONNECTION_MANAGED_EXTERNALLY. If this Api is called, taskana
* uses the connection passed by the client for all subsequent API calls until the client resets this connection.
* Control over commit and rollback of the connection is the responsibility of the client. In order to close the
* connection, closeConnection() or setConnection(null) has to be called.
*
* @param connection
* - The java.sql.Connection that is controlled by the client
* @throws SQLException
* if a database access error occurs
*/
void setConnection(java.sql.Connection connection) throws SQLException;
/**
* Set the connection to be used by taskana in mode CONNECTION_MANAGED_EXTERNALLY. If this Api is
* called, taskana uses the connection passed by the client for all subsequent API calls until the
* client resets this connection. Control over commit and rollback of the connection is the
* responsibility of the client. In order to close the connection, closeConnection() or
* setConnection(null) has to be called.
*
* @param connection - The java.sql.Connection that is controlled by the client
* @throws SQLException if a database access error occurs
*/
void setConnection(java.sql.Connection connection) throws SQLException;
/**
* Closes the client's connection, sets it to null and switches to mode PARTICIPATE. Only applicable in mode
* EXPLICIT. Has the same effect as setConnection(null).
*/
void closeConnection();
/**
* Closes the client's connection, sets it to null and switches to mode PARTICIPATE. Only
* applicable in mode EXPLICIT. Has the same effect as setConnection(null).
*/
void closeConnection();
/**
* check whether the current user is member of one of the roles specified.
*
* @param roles
* The roles that are checked for membership of the current user
* @return true if the current user is a member of at least one of the specified groups
*/
boolean isUserInRole(TaskanaRole... roles);
/**
* check whether the current user is member of one of the roles specified.
*
* @param roles The roles that are checked for membership of the current user
* @return true if the current user is a member of at least one of the specified groups
*/
boolean isUserInRole(TaskanaRole... roles);
/**
* Checks whether current user is member of any of the specified roles.
*
* @param roles
* The roles that are checked for membership of the current user
* @throws NotAuthorizedException
* If the current user is not member of any specified role
*/
void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException;
/**
* Connection management mode. Controls the connection handling of taskana
* <ul>
* <li>PARTICIPATE - taskana participates in global transaction. This is the default mode</li>
* <li>AUTOCOMMIT - taskana commits each API call separately</li>
* <li>EXPLICIT - commit processing is managed explicitly by the client</li>
* </ul>
*/
enum ConnectionManagementMode {
PARTICIPATE,
AUTOCOMMIT,
EXPLICIT
}
/**
* Checks whether current user is member of any of the specified roles.
*
* @param roles The roles that are checked for membership of the current user
* @throws NotAuthorizedException If the current user is not member of any specified role
*/
void checkRoleMembership(TaskanaRole... roles) throws NotAuthorizedException;
/**
* Connection management mode. Controls the connection handling of taskana
*
* <ul>
* <li>PARTICIPATE - taskana participates in global transaction. This is the default mode
* <li>AUTOCOMMIT - taskana commits each API call separately
* <li>EXPLICIT - commit processing is managed explicitly by the client
* </ul>
*/
enum ConnectionManagementMode {
PARTICIPATE,
AUTOCOMMIT,
EXPLICIT
}
}

View File

@ -6,36 +6,33 @@ import java.util.stream.Collectors;
import pro.taskana.exceptions.SystemException;
/**
* This enum contains all roles that are known to taskana.
*/
/** This enum contains all roles that are known to taskana. */
public enum TaskanaRole {
USER("taskana.roles.user"),
BUSINESS_ADMIN("taskana.roles.businessadmin"),
ADMIN("taskana.roles.admin"),
MONITOR("taskana.roles.monitor");
USER("taskana.roles.user"),
BUSINESS_ADMIN("taskana.roles.businessadmin"),
ADMIN("taskana.roles.admin"),
MONITOR("taskana.roles.monitor");
private final String propertyName;
private final String propertyName;
TaskanaRole(String propertyName) {
this.propertyName = propertyName;
}
TaskanaRole(String propertyName) {
this.propertyName = propertyName;
}
public static TaskanaRole fromPropertyName(String name) {
return Arrays.stream(TaskanaRole.values())
.filter(x -> x.propertyName.equalsIgnoreCase(name))
.findFirst()
.orElseThrow(() -> new SystemException(
"Internal System error when processing role property " + name));
}
public static TaskanaRole fromPropertyName(String name) {
return Arrays.stream(TaskanaRole.values())
.filter(x -> x.propertyName.equalsIgnoreCase(name))
.findFirst()
.orElseThrow(
() ->
new SystemException("Internal System error when processing role property " + name));
}
public static List<String> getValidPropertyNames() {
return Arrays.stream(values())
.map(TaskanaRole::getPropertyName)
.collect(Collectors.toList());
}
public static List<String> getValidPropertyNames() {
return Arrays.stream(values()).map(TaskanaRole::getPropertyName).collect(Collectors.toList());
}
public String getPropertyName() {
return propertyName;
}
public String getPropertyName() {
return propertyName;
}
}

View File

@ -3,95 +3,94 @@ package pro.taskana;
import java.time.Instant;
/**
* Capture a time interval. A fixed interval has defined begin and end Instant. An open ended interval has either begin
* == null or end ==null.
* Capture a time interval. A fixed interval has defined begin and end Instant. An open ended
* interval has either begin == null or end ==null.
*
* @author bbr
*/
public class TimeInterval {
private Instant begin;
private Instant end;
private Instant begin;
private Instant end;
public TimeInterval(Instant begin, Instant end) {
this.begin = begin;
this.end = end;
public TimeInterval(Instant begin, Instant end) {
this.begin = begin;
this.end = end;
}
public boolean contains(Instant i) {
if (i == null) {
return false;
}
boolean isAfterBegin = begin == null ? true : !i.isBefore(begin);
boolean isBeforeEnd = end == null ? true : !i.isAfter(end);
return (isAfterBegin && isBeforeEnd);
}
public boolean contains(Instant i) {
if (i == null) {
return false;
}
boolean isAfterBegin = begin == null ? true : !i.isBefore(begin);
boolean isBeforeEnd = end == null ? true : !i.isAfter(end);
return (isAfterBegin && isBeforeEnd);
public boolean isValid() {
boolean isValid = begin != null || end != null;
if (begin != null && end != null && begin.isAfter(end)) {
isValid = false;
}
return isValid;
}
public boolean isValid() {
boolean isValid = begin != null || end != null;
if (begin != null && end != null && begin.isAfter(end)) {
isValid = false;
}
return isValid;
public Instant getBegin() {
return begin;
}
public void setBegin(Instant begin) {
this.begin = begin;
}
public Instant getEnd() {
return end;
}
public void setEnd(Instant end) {
this.end = end;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((begin == null) ? 0 : begin.hashCode());
result = prime * result + ((end == null) ? 0 : end.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
public Instant getBegin() {
return begin;
if (obj == null) {
return false;
}
public void setBegin(Instant begin) {
this.begin = begin;
if (!getClass().isAssignableFrom(obj.getClass())) {
return false;
}
public Instant getEnd() {
return end;
TimeInterval other = (TimeInterval) obj;
if (begin == null) {
if (other.begin != null) {
return false;
}
} else if (!begin.equals(other.begin)) {
return false;
}
public void setEnd(Instant end) {
this.end = end;
}
@Override
public String toString() {
return "TimeInterval [" + "begin=" + this.begin + ", end=" + this.end + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((begin == null) ? 0 : begin.hashCode());
result = prime * result + ((end == null) ? 0 : end.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!getClass().isAssignableFrom(obj.getClass())) {
return false;
}
TimeInterval other = (TimeInterval) obj;
if (begin == null) {
if (other.begin != null) {
return false;
}
} else if (!begin.equals(other.begin)) {
return false;
}
if (end == null) {
if (other.end != null) {
return false;
}
} else if (!end.equals(other.end)) {
return false;
}
return true;
if (end == null) {
if (other.end != null) {
return false;
}
} else if (!end.equals(other.end)) {
return false;
}
return true;
}
@Override
public String toString() {
return "TimeInterval [" + "begin=" + this.begin + ", end=" + this.end + "]";
}
}

View File

@ -1,251 +1,235 @@
package pro.taskana;
import java.time.Instant;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.time.Instant;
import pro.taskana.impl.WorkbasketImpl;
/**
* Workbasket entity interface.
*/
/** Workbasket entity interface. */
@JsonDeserialize(as = WorkbasketImpl.class)
public interface Workbasket {
/**
* Returns the unique id of a workbasket.
*
* @return workbasketId
*/
String getId();
/**
* Returns the unique id of a workbasket.
*
* @return workbasketId
*/
String getId();
/**
* Returns the date when the workbasket was created.
*
* @return created as Instant
*/
Instant getCreated();
/**
* Returns the date when the workbasket was created.
*
* @return created as Instant
*/
Instant getCreated();
/**
* Returns the key of the workbasket.
*
* @return the key of the workbasket
*/
String getKey();
/**
* Returns the key of the workbasket.
*
* @return the key of the workbasket
*/
String getKey();
/**
* Returns the domain of the workbasket.
*
* @return domain of the workbasket
*/
String getDomain();
/**
* Returns the domain of the workbasket.
*
* @return domain of the workbasket
*/
String getDomain();
/**
* Returns the type of the workbasket.
*
* @return the type of the workbasket
*/
WorkbasketType getType();
/**
* Returns the type of the workbasket.
*
* @return the type of the workbasket
*/
WorkbasketType getType();
/**
* Sets the type of the workbasket.
*
* @param type
* the type of the workbasket
*/
void setType(WorkbasketType type);
/**
* Sets the type of the workbasket.
*
* @param type the type of the workbasket
*/
void setType(WorkbasketType type);
/**
* Returns the date when the workbasket was modified the last time.
*
* @return modified as Instant
*/
Instant getModified();
/**
* Returns the date when the workbasket was modified the last time.
*
* @return modified as Instant
*/
Instant getModified();
/**
* Returns the name of the workbasket.
*
* @return workbasketName
*/
String getName();
/**
* Returns the name of the workbasket.
*
* @return workbasketName
*/
String getName();
/**
* Sets the name of the workbasket.
*
* @param workbasketName
* the name of the workbasket
*/
void setName(String workbasketName);
/**
* Sets the name of the workbasket.
*
* @param workbasketName the name of the workbasket
*/
void setName(String workbasketName);
/**
* Returns the workbasket-descriptions.
*
* @return description
*/
String getDescription();
/**
* Returns the workbasket-descriptions.
*
* @return description
*/
String getDescription();
/**
* Sets the workbasket-descriptions.
*
* @param description
* the description of the workbasket
*/
void setDescription(String description);
/**
* Sets the workbasket-descriptions.
*
* @param description the description of the workbasket
*/
void setDescription(String description);
/**
* Returns the Id of the workbasket-owner.
*
* @return ownerId
*/
String getOwner();
/**
* Returns the Id of the workbasket-owner.
*
* @return ownerId
*/
String getOwner();
/**
* Sets the owner-ID of the workbasket.
*
* @param owner
* of the current workbasket
*/
void setOwner(String owner);
/**
* Sets the owner-ID of the workbasket.
*
* @param owner of the current workbasket
*/
void setOwner(String owner);
/**
* Return the value for the custom1 attribute.
*
* @return custom1
*/
String getCustom1();
/**
* Return the value for the custom1 attribute.
*
* @return custom1
*/
String getCustom1();
/**
* Sets the value for custom1 Attribute.
*
* @param custom1
* the custom1 property of the workbasket
*/
void setCustom1(String custom1);
/**
* Sets the value for custom1 Attribute.
*
* @param custom1 the custom1 property of the workbasket
*/
void setCustom1(String custom1);
/**
* Return the value for the custom2 attribute.
*
* @return custom2
*/
String getCustom2();
/**
* Return the value for the custom2 attribute.
*
* @return custom2
*/
String getCustom2();
/**
* Sets the value for custom2 attribute.
*
* @param custom2
* the custom2 property of the workbasket
*/
void setCustom2(String custom2);
/**
* Sets the value for custom2 attribute.
*
* @param custom2 the custom2 property of the workbasket
*/
void setCustom2(String custom2);
/**
* Return the value for the custom3 attribute.
*
* @return custom3
*/
String getCustom3();
/**
* Return the value for the custom3 attribute.
*
* @return custom3
*/
String getCustom3();
/**
* Sets the value for custom3 attribute.
*
* @param custom3
* the custom3 property of the workbasket
*/
void setCustom3(String custom3);
/**
* Sets the value for custom3 attribute.
*
* @param custom3 the custom3 property of the workbasket
*/
void setCustom3(String custom3);
/**
* Return the value for the custom4 attribute.
*
* @return custom4
*/
String getCustom4();
/**
* Return the value for the custom4 attribute.
*
* @return custom4
*/
String getCustom4();
/**
* Sets the value for custom4 attribute.
*
* @param custom4
* the custom4 property of the workbasket
*/
void setCustom4(String custom4);
/**
* Sets the value for custom4 attribute.
*
* @param custom4 the custom4 property of the workbasket
*/
void setCustom4(String custom4);
/**
* Return the value for the orgLevel1 attribute.
*
* @return orgLevel1
*/
String getOrgLevel1();
/**
* Return the value for the orgLevel1 attribute.
*
* @return orgLevel1
*/
String getOrgLevel1();
/**
* Sets the value for orgLevel1 attribute.
*
* @param orgLevel1
* the orgLevel1 property of the workbasket
*/
void setOrgLevel1(String orgLevel1);
/**
* Sets the value for orgLevel1 attribute.
*
* @param orgLevel1 the orgLevel1 property of the workbasket
*/
void setOrgLevel1(String orgLevel1);
/**
* Return the value for the orgLevel2 attribute.
*
* @return orgLevel2
*/
String getOrgLevel2();
/**
* Return the value for the orgLevel2 attribute.
*
* @return orgLevel2
*/
String getOrgLevel2();
/**
* Sets the value for orgLevel2 attribute.
*
* @param orgLevel2
* the orgLevel2 property of the workbasket
*/
void setOrgLevel2(String orgLevel2);
/**
* Sets the value for orgLevel2 attribute.
*
* @param orgLevel2 the orgLevel2 property of the workbasket
*/
void setOrgLevel2(String orgLevel2);
/**
* Return the value for the orgLevel3 attribute.
*
* @return orgLevel3
*/
String getOrgLevel3();
/**
* Return the value for the orgLevel3 attribute.
*
* @return orgLevel3
*/
String getOrgLevel3();
/**
* Sets the value for orgLevel3 attribute.
*
* @param orgLevel3
* the orgLevel3 property of the workbasket
*/
void setOrgLevel3(String orgLevel3);
/**
* Sets the value for orgLevel3 attribute.
*
* @param orgLevel3 the orgLevel3 property of the workbasket
*/
void setOrgLevel3(String orgLevel3);
/**
* Return the value for the orgLevel4 attribute.
*
* @return orgLevel4
*/
String getOrgLevel4();
/**
* Return the value for the orgLevel4 attribute.
*
* @return orgLevel4
*/
String getOrgLevel4();
/**
* Sets the value for orgLevel4 attribute.
*
* @param orgLevel4
* the orgLevel4 property of the workbasket
*/
void setOrgLevel4(String orgLevel4);
/**
* Sets the value for orgLevel4 attribute.
*
* @param orgLevel4 the orgLevel4 property of the workbasket
*/
void setOrgLevel4(String orgLevel4);
/**
* Return the value for the markedForDeletion attribute.
*
* @return markedForDeletion
*/
boolean isMarkedForDeletion();
/**
* Return the value for the markedForDeletion attribute.
*
* @return markedForDeletion
*/
boolean isMarkedForDeletion();
/**
* Sets the value for markedForDeletion attribute.
*
* @param markedForDeletion
* the markedForDeletion property of the workbasket
*/
void setMarkedForDeletion(boolean markedForDeletion);
/**
* Sets the value for markedForDeletion attribute.
*
* @param markedForDeletion the markedForDeletion property of the workbasket
*/
void setMarkedForDeletion(boolean markedForDeletion);
/**
* Return a summary of the current workbasket.
*
* @return the WorkbasketSummary object for the current work basket
*/
WorkbasketSummary asSummary();
/**
* Return a summary of the current workbasket.
*
* @return the WorkbasketSummary object for the current work basket
*/
WorkbasketSummary asSummary();
}

View File

@ -1,331 +1,318 @@
package pro.taskana;
/**
* Interface for WorkbasketAccessItem. This interface is used to control access of users to workbaskets.
* Interface for WorkbasketAccessItem. This interface is used to control access of users to
* workbaskets.
*
* @author bbr
*/
public interface WorkbasketAccessItem {
/**
* Returns the current id of the WorkbasketAccessItem.
*
* @return Id
*/
String getId();
/**
* Returns the current id of the WorkbasketAccessItem.
*
* @return Id
*/
String getId();
/**
* Returns the Id of the referenced workbasket.
*
* @return the workbasket Id
*/
String getWorkbasketId();
/**
* Returns the Id of the referenced workbasket.
*
* @return the workbasket Id
*/
String getWorkbasketId();
/**
* Returns the Key of the referenced workbasket.
*
* @return the workbasket Key
*/
String getWorkbasketKey();
/**
* Returns the Key of the referenced workbasket.
*
* @return the workbasket Key
*/
String getWorkbasketKey();
/**
* Returns the group id or user id for which this WorkbasketAccessItem controls access permissions.
*
* @return access id, this is the group id or user id
*/
String getAccessId();
/**
* Returns the group id or user id for which this WorkbasketAccessItem controls access
* permissions.
*
* @return access id, this is the group id or user id
*/
String getAccessId();
/**
* Returns the name of the group or user for which this WorkbasketAccessItem controls access permissions.
*
* @return access name, this is the name of the group or user
*/
String getAccessName();
/**
* Returns the name of the group or user for which this WorkbasketAccessItem controls access
* permissions.
*
* @return access name, this is the name of the group or user
*/
String getAccessName();
/**
* Set the name of the group or user for which this WorkbasketAccessItem controls access permissions.
*
* @param name
* the name of the group or user for which this WorkbasketAccessItem controls access permissions.
*/
void setAccessName(String name);
/**
* Set the name of the group or user for which this WorkbasketAccessItem controls access
* permissions.
*
* @param name the name of the group or user for which this WorkbasketAccessItem controls access
* permissions.
*/
void setAccessName(String name);
/**
* Returns whether read of the referenced workbasket is permitted.
*
* @return read permission for the referenced workbasket
*/
boolean isPermRead();
/**
* Returns whether read of the referenced workbasket is permitted.
*
* @return read permission for the referenced workbasket
*/
boolean isPermRead();
/**
* Sets read permission for the referenced workbasket.
*
* @param permRead
* specifies whether read is permitted for the referenced workbasket.
*/
void setPermRead(boolean permRead);
/**
* Sets read permission for the referenced workbasket.
*
* @param permRead specifies whether read is permitted for the referenced workbasket.
*/
void setPermRead(boolean permRead);
/**
* Returns whether open of the referenced workbasket is permitted.
*
* @return open permission for the referenced workbasket
*/
boolean isPermOpen();
/**
* Returns whether open of the referenced workbasket is permitted.
*
* @return open permission for the referenced workbasket
*/
boolean isPermOpen();
/**
* Sets open permission for the referenced workbasket.
*
* @param permOpen
* specifies whether open is permitted for the referenced workbasket.
*/
void setPermOpen(boolean permOpen);
/**
* Sets open permission for the referenced workbasket.
*
* @param permOpen specifies whether open is permitted for the referenced workbasket.
*/
void setPermOpen(boolean permOpen);
/**
* Returns whether append to the referenced workbasket is permitted.
*
* @return append permission for the referenced workbasket
*/
boolean isPermAppend();
/**
* Returns whether append to the referenced workbasket is permitted.
*
* @return append permission for the referenced workbasket
*/
boolean isPermAppend();
/**
* Sets append permission for the referenced workbasket.
*
* @param permAppend
* specifies whether append to the referenced workbasket is permitted.
*/
void setPermAppend(boolean permAppend);
/**
* Sets append permission for the referenced workbasket.
*
* @param permAppend specifies whether append to the referenced workbasket is permitted.
*/
void setPermAppend(boolean permAppend);
/**
* Returns whether transfer from the referenced workbasket is permitted.
*
* @return transfer permission for the referenced workbasket
*/
boolean isPermTransfer();
/**
* Returns whether transfer from the referenced workbasket is permitted.
*
* @return transfer permission for the referenced workbasket
*/
boolean isPermTransfer();
/**
* Sets transfer permission for the referenced workbasket.
*
* @param permTransfer
* specifies whether transfer from the referenced workbasket is permitted.
*/
void setPermTransfer(boolean permTransfer);
/**
* Sets transfer permission for the referenced workbasket.
*
* @param permTransfer specifies whether transfer from the referenced workbasket is permitted.
*/
void setPermTransfer(boolean permTransfer);
/**
* Returns whether distribute from the referenced workbasket is permitted.
*
* @return distribute permission for the referenced workbasket
*/
boolean isPermDistribute();
/**
* Returns whether distribute from the referenced workbasket is permitted.
*
* @return distribute permission for the referenced workbasket
*/
boolean isPermDistribute();
/**
* Sets distribute permission for the referenced workbasket.
*
* @param permDistribute
* specifies whether distribute from the referenced workbasket is permitted.
*/
void setPermDistribute(boolean permDistribute);
/**
* Sets distribute permission for the referenced workbasket.
*
* @param permDistribute specifies whether distribute from the referenced workbasket is permitted.
*/
void setPermDistribute(boolean permDistribute);
/**
* Returns whether custom1 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom1 permission for the referenced workbasket
*/
boolean isPermCustom1();
/**
* Returns whether custom1 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom1 permission for the referenced workbasket
*/
boolean isPermCustom1();
/**
* Sets the custom1 permission for the referenced workbasket. The semantics of this custom permission is transparent
* to taskana.
*
* @param permCustom1
* specifies whether custom1 permission is granted
*/
void setPermCustom1(boolean permCustom1);
/**
* Sets the custom1 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom1 specifies whether custom1 permission is granted
*/
void setPermCustom1(boolean permCustom1);
/**
* Returns whether custom2 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom2 permission for the referenced workbasket
*/
boolean isPermCustom2();
/**
* Returns whether custom2 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom2 permission for the referenced workbasket
*/
boolean isPermCustom2();
/**
* Sets the custom2 permission for the referenced workbasket. The semantics of this custom permission is transparent
* to taskana.
*
* @param permCustom2
* specifies whether custom2 permission is granted
*/
void setPermCustom2(boolean permCustom2);
/**
* Sets the custom2 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom2 specifies whether custom2 permission is granted
*/
void setPermCustom2(boolean permCustom2);
/**
* Returns whether custom3 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom3 permission for the referenced workbasket
*/
boolean isPermCustom3();
/**
* Returns whether custom3 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom3 permission for the referenced workbasket
*/
boolean isPermCustom3();
/**
* Sets the custom3 permission for the referenced workbasket. The semantics of this custom permission is transparent
* to taskana.
*
* @param permCustom3
* specifies whether custom3 permission is granted
*/
void setPermCustom3(boolean permCustom3);
/**
* Sets the custom3 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom3 specifies whether custom3 permission is granted
*/
void setPermCustom3(boolean permCustom3);
/**
* Returns whether custom4 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom4 permission for the referenced workbasket
*/
boolean isPermCustom4();
/**
* Returns whether custom4 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom4 permission for the referenced workbasket
*/
boolean isPermCustom4();
/**
* Sets the custom4 permission for the referenced workbasket. The semantics of this custom permission is transparent
* to taskana.
*
* @param permCustom4
* specifies whether custom4 permission is granted
*/
void setPermCustom4(boolean permCustom4);
/**
* Sets the custom4 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom4 specifies whether custom4 permission is granted
*/
void setPermCustom4(boolean permCustom4);
/**
* Returns whether custom5 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom5 permission for the referenced workbasket
*/
boolean isPermCustom5();
/**
* Returns whether custom5 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom5 permission for the referenced workbasket
*/
boolean isPermCustom5();
/**
* Sets the custom5 permission for the referenced workbasket. The semantics of this custom permission is transparent
* to taskana.
*
* @param permCustom5
* specifies whether custom5 permission is granted
*/
void setPermCustom5(boolean permCustom5);
/**
* Sets the custom5 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom5 specifies whether custom5 permission is granted
*/
void setPermCustom5(boolean permCustom5);
/**
* Returns whether custom6 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom6 permission for the referenced workbasket
*/
boolean isPermCustom6();
/**
* Returns whether custom6 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom6 permission for the referenced workbasket
*/
boolean isPermCustom6();
/**
* Sets the custom6 permission for the referenced workbasket. The semantics of this custom permission is transparent
* to taskana.
*
* @param permCustom6
* specifies whether custom6 permission is granted
*/
void setPermCustom6(boolean permCustom6);
/**
* Sets the custom6 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom6 specifies whether custom6 permission is granted
*/
void setPermCustom6(boolean permCustom6);
/**
* Returns whether custom7 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom7 permission for the referenced workbasket
*/
boolean isPermCustom7();
/**
* Returns whether custom7 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom7 permission for the referenced workbasket
*/
boolean isPermCustom7();
/**
* Sets the custom7 permission for the referenced workbasket. The semantics of this custom permission is transparent
* to taskana.
*
* @param permCustom7
* specifies whether custom7 permission is granted
*/
void setPermCustom7(boolean permCustom7);
/**
* Sets the custom7 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom7 specifies whether custom7 permission is granted
*/
void setPermCustom7(boolean permCustom7);
/**
* Returns whether custom8 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom8 permission for the referenced workbasket
*/
boolean isPermCustom8();
/**
* Returns whether custom8 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom8 permission for the referenced workbasket
*/
boolean isPermCustom8();
/**
* Sets the custom8 permission for the referenced workbasket. The semantics of this custom permission is transparent
* to taskana.
*
* @param permCustom8
* specifies whether custom8 permission is granted
*/
void setPermCustom8(boolean permCustom8);
/**
* Sets the custom8 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom8 specifies whether custom8 permission is granted
*/
void setPermCustom8(boolean permCustom8);
/**
* Returns whether custom9 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom9 permission for the referenced workbasket
*/
boolean isPermCustom9();
/**
* Returns whether custom9 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom9 permission for the referenced workbasket
*/
boolean isPermCustom9();
/**
* Sets the custom9 permission for the referenced workbasket. The semantics of this custom permission is transparent
* to taskana.
*
* @param permCustom9
* specifies whether custom9 permission is granted
*/
void setPermCustom9(boolean permCustom9);
/**
* Sets the custom9 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom9 specifies whether custom9 permission is granted
*/
void setPermCustom9(boolean permCustom9);
/**
* Returns whether custom10 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom10 permission for the referenced workbasket
*/
boolean isPermCustom10();
/**
* Returns whether custom10 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom10 permission for the referenced workbasket
*/
boolean isPermCustom10();
/**
* Sets the custom10 permission for the referenced workbasket. The semantics of this custom permission is
* transparent to taskana.
*
* @param permCustom10
* specifies whether custom10 permission is granted
*/
void setPermCustom10(boolean permCustom10);
/**
* Sets the custom10 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom10 specifies whether custom10 permission is granted
*/
void setPermCustom10(boolean permCustom10);
/**
* Returns whether custom11 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom11 permission for the referenced workbasket
*/
boolean isPermCustom11();
/**
* Returns whether custom11 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom11 permission for the referenced workbasket
*/
boolean isPermCustom11();
/**
* Sets the custom11 permission for the referenced workbasket. The semantics of this custom permission is
* transparent to taskana.
*
* @param permCustom11
* specifies whether custom11 permission is granted
*/
void setPermCustom11(boolean permCustom11);
/**
* Sets the custom11 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom11 specifies whether custom11 permission is granted
*/
void setPermCustom11(boolean permCustom11);
/**
* Returns whether custom12 permission is granted for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @return custom12 permission for the referenced workbasket
*/
boolean isPermCustom12();
/**
* Returns whether custom12 permission is granted for the referenced workbasket. The semantics of
* this custom permission is transparent to taskana.
*
* @return custom12 permission for the referenced workbasket
*/
boolean isPermCustom12();
/**
* Sets the custom12 permission for the referenced workbasket. The semantics of this custom permission is
* transparent to taskana.
*
* @param permCustom12
* specifies whether custom12 permission is granted
*/
void setPermCustom12(boolean permCustom12);
/**
* Sets the custom12 permission for the referenced workbasket. The semantics of this custom
* permission is transparent to taskana.
*
* @param permCustom12 specifies whether custom12 permission is granted
*/
void setPermCustom12(boolean permCustom12);
}

View File

@ -1,106 +1,96 @@
package pro.taskana;
/**
* WorkbasketAccessItemQuery for generating dynamic SQL.
*/
public interface WorkbasketAccessItemQuery extends BaseQuery<WorkbasketAccessItem, AccessItemQueryColumnName> {
/** WorkbasketAccessItemQuery for generating dynamic SQL. */
public interface WorkbasketAccessItemQuery
extends BaseQuery<WorkbasketAccessItem, AccessItemQueryColumnName> {
/**
* Add your unique entry id to your query as filter.
*
* @param ids
* the unique entry IDs
* @return the query
*/
WorkbasketAccessItemQuery idIn(String... ids);
/**
* Add your unique entry id to your query as filter.
*
* @param ids the unique entry IDs
* @return the query
*/
WorkbasketAccessItemQuery idIn(String... ids);
/**
* Add your workbasket id to your query.
*
* @param workbasketId
* the workbasket Id
* @return the query
*/
WorkbasketAccessItemQuery workbasketIdIn(String... workbasketId);
/**
* Add your workbasket id to your query.
*
* @param workbasketId the workbasket Id
* @return the query
*/
WorkbasketAccessItemQuery workbasketIdIn(String... workbasketId);
/**
* Add your unique entry workbasket key to your query as filter.
*
* @param keys
* the unique entry Keys
* @return the query
*/
WorkbasketAccessItemQuery workbasketKeyIn(String... keys);
/**
* Add your unique entry workbasket key to your query as filter.
*
* @param keys the unique entry Keys
* @return the query
*/
WorkbasketAccessItemQuery workbasketKeyIn(String... keys);
/**
* Add keys to your query. The keys are compared case-insensitively to the keys of access items with the SQL LIKE
* operator. You may add a wildcard like '%' to search generically. If you specify multiple keys they are connected
* with an OR operator, this is, the query searches access items workbaskets whose keys are like key1 or like key2, etc.
*
* @param key
* the keys as Strings
* @return the query
*/
WorkbasketAccessItemQuery workbasketKeyLike(String... key);
/**
* Add keys to your query. The keys are compared case-insensitively to the keys of access items
* with the SQL LIKE operator. You may add a wildcard like '%' to search generically. If you
* specify multiple keys they are connected with an OR operator, this is, the query searches
* access items workbaskets whose keys are like key1 or like key2, etc.
*
* @param key the keys as Strings
* @return the query
*/
WorkbasketAccessItemQuery workbasketKeyLike(String... key);
/**
* Add your accessIds to your query.
*
* @param accessId
* as access Ids
* @return the query
*/
WorkbasketAccessItemQuery accessIdIn(String... accessId);
/**
* Add your accessIds to your query.
*
* @param accessId as access Ids
* @return the query
*/
WorkbasketAccessItemQuery accessIdIn(String... accessId);
/**
* Add keys to your query. The keys are compared case-insensitively to the keys of access items with the SQL LIKE
* operator. You may add a wildcard like '%' to search generically. If you specify multiple keys they are connected
* with an OR operator, this is, the query searches access items whose ids are like id1 or like id2, etc.
*
* @param ids
* the ids as Strings
* @return the query
*/
WorkbasketAccessItemQuery accessIdLike(String... ids);
/**
* Add keys to your query. The keys are compared case-insensitively to the keys of access items
* with the SQL LIKE operator. You may add a wildcard like '%' to search generically. If you
* specify multiple keys they are connected with an OR operator, this is, the query searches
* access items whose ids are like id1 or like id2, etc.
*
* @param ids the ids as Strings
* @return the query
*/
WorkbasketAccessItemQuery accessIdLike(String... ids);
/**
* Sort the query result by workbasket id.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketAccessItemQuery orderByWorkbasketId(SortDirection sortDirection);
/**
* Sort the query result by workbasket id.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketAccessItemQuery orderByWorkbasketId(SortDirection sortDirection);
/**
* Sort the query result by workbasket key.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketAccessItemQuery orderByWorkbasketKey(SortDirection sortDirection);
/**
* Sort the query result by workbasket key.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketAccessItemQuery orderByWorkbasketKey(SortDirection sortDirection);
/**
* Sort the query result by access Id.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketAccessItemQuery orderByAccessId(SortDirection sortDirection);
/**
* Sort the query result by Id.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketAccessItemQuery orderById(SortDirection sortDirection);
/**
* Sort the query result by access Id.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketAccessItemQuery orderByAccessId(SortDirection sortDirection);
/**
* Sort the query result by Id.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketAccessItemQuery orderById(SortDirection sortDirection);
}

View File

@ -1,24 +1,22 @@
package pro.taskana;
/**
* This enum contains all permission values for the workbaskets.
*/
/** This enum contains all permission values for the workbaskets. */
public enum WorkbasketPermission {
READ,
OPEN,
APPEND,
TRANSFER,
DISTRIBUTE,
CUSTOM_1,
CUSTOM_2,
CUSTOM_3,
CUSTOM_4,
CUSTOM_5,
CUSTOM_6,
CUSTOM_7,
CUSTOM_8,
CUSTOM_9,
CUSTOM_10,
CUSTOM_11,
CUSTOM_12
READ,
OPEN,
APPEND,
TRANSFER,
DISTRIBUTE,
CUSTOM_1,
CUSTOM_2,
CUSTOM_3,
CUSTOM_4,
CUSTOM_5,
CUSTOM_6,
CUSTOM_7,
CUSTOM_8,
CUSTOM_9,
CUSTOM_10,
CUSTOM_11,
CUSTOM_12
}

View File

@ -3,492 +3,447 @@ package pro.taskana;
import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.exceptions.NotAuthorizedException;
/**
* WorkitemQuery for generating dynamic sql.
*/
/** WorkitemQuery for generating dynamic sql. */
public interface WorkbasketQuery extends BaseQuery<WorkbasketSummary, WorkbasketQueryColumnName> {
/**
* Add your ids to your query. The ids are compared to the ids of workbaskets with the IN operator.
*
* @param id
* the id as Strings
* @return the query
*/
WorkbasketQuery idIn(String... id);
/**
* Add your ids to your query. The ids are compared to the ids of workbaskets with the IN
* operator.
*
* @param id the id as Strings
* @return the query
*/
WorkbasketQuery idIn(String... id);
/**
* Add your keys to your query. The keys are compared case-insensitively to the keys of workbaskets with the IN
* operator.
* @param key
* the keys as Strings
* @return the query
*/
WorkbasketQuery keyIn(String... key);
/**
* Add your keys to your query. The keys are compared case-insensitively to the keys of
* workbaskets with the IN operator.
*
* @param key the keys as Strings
* @return the query
*/
WorkbasketQuery keyIn(String... key);
/**
* Add keys to your query. The keys are compared case-insensitively to the keys of workbaskets with the SQL LIKE
* operator. You may add a wildcard like '%' to search generically. If you specify multiple keys they are connected
* with an OR operator, this is, the query searches workbaskets whose keys are like key1 or like key2, etc.
*
* @param key
* the keys as Strings
* @return the query
*/
WorkbasketQuery keyLike(String... key);
/**
* Add keys to your query. The keys are compared case-insensitively to the keys of workbaskets
* with the SQL LIKE operator. You may add a wildcard like '%' to search generically. If you
* specify multiple keys they are connected with an OR operator, this is, the query searches
* workbaskets whose keys are like key1 or like key2, etc.
*
* @param key the keys as Strings
* @return the query
*/
WorkbasketQuery keyLike(String... key);
/**
* Add your names to your query. The names are compared case-insensitively to the names of workbaskets
*
* @param name
* the names as Strings
* @return the query
*/
WorkbasketQuery nameIn(String... name);
/**
* Add your names to your query. The names are compared case-insensitively to the names of
* workbaskets
*
* @param name the names as Strings
* @return the query
*/
WorkbasketQuery nameIn(String... name);
/**
* Add names to your query. The names are compared case-insensitively to the names of workbaskets with the SQL LIKE
* operator. You may add a wildcard like '%' to search generically. If you specify multiple names, they are
* connected with an OR operator, this is, the query searches workbaskets whose names are like name1 or like name2,
* etc.
*
* @param name
* the names as Strings
* @return the query
*/
WorkbasketQuery nameLike(String... name);
/**
* Add names to your query. The names are compared case-insensitively to the names of workbaskets
* with the SQL LIKE operator. You may add a wildcard like '%' to search generically. If you
* specify multiple names, they are connected with an OR operator, this is, the query searches
* workbaskets whose names are like name1 or like name2, etc.
*
* @param name the names as Strings
* @return the query
*/
WorkbasketQuery nameLike(String... name);
/**
* Add search strings to your query that are searched case-insensitively in the key and name fields of workbaskets.
* You may add a wildcard like '%' to search generically. If you specify multiple keys they are connected with an OR
* operator, this is, the query searches workbaskets whose keys are like string1 or whose names are like string1 or
* whose keys are like string2 or whose names are like string2, etc...
*
* @param searchString
* the seach strings
* @return the query
*/
WorkbasketQuery keyOrNameLike(String... searchString);
/**
* Add search strings to your query that are searched case-insensitively in the key and name
* fields of workbaskets. You may add a wildcard like '%' to search generically. If you specify
* multiple keys they are connected with an OR operator, this is, the query searches workbaskets
* whose keys are like string1 or whose names are like string1 or whose keys are like string2 or
* whose names are like string2, etc...
*
* @param searchString the seach strings
* @return the query
*/
WorkbasketQuery keyOrNameLike(String... searchString);
/**
* Add your domains to your query.
*
* @param domain
* the domains as Strings
* @return the query
*/
WorkbasketQuery domainIn(String... domain);
/**
* Add your domains to your query.
*
* @param domain the domains as Strings
* @return the query
*/
WorkbasketQuery domainIn(String... domain);
/**
* Add your types to your query.
*
* @param type
* the types
* @return the query
*/
WorkbasketQuery typeIn(WorkbasketType... type);
/**
* Add your types to your query.
*
* @param type the types
* @return the query
*/
WorkbasketQuery typeIn(WorkbasketType... type);
/**
* Add the time intervals within which the workbasket was created to your query. For each time interval, the
* database query will search for workbaskets whose created timestamp is after or at the interval's begin and before
* or at the interval's end. If more than one interval is specified, the query will connect them with the OR
* keyword. If either begin or end of an interval are null, these values will not be specified in the query.
*
* @param intervals
* - the TimeIntervals within which the workbasket was created
* @return the query
*/
WorkbasketQuery createdWithin(TimeInterval... intervals);
/**
* Add the time intervals within which the workbasket was created to your query. For each time
* interval, the database query will search for workbaskets whose created timestamp is after or at
* the interval's begin and before or at the interval's end. If more than one interval is
* specified, the query will connect them with the OR keyword. If either begin or end of an
* interval are null, these values will not be specified in the query.
*
* @param intervals - the TimeIntervals within which the workbasket was created
* @return the query
*/
WorkbasketQuery createdWithin(TimeInterval... intervals);
/**
* Add the time intervals within which the workbasket was modified to your query. For each time interval, the
* database query will search for workbaskets whose created timestamp is after or at the interval's begin and before
* or at the interval's end. If more than one interval is specified, the query will connect them with the OR
* keyword. If either begin or end of an interval are null, these values will not be specified in the query.
*
* @param intervals
* - the TimeIntervals within which the workbasket was created
* @return the query
*/
WorkbasketQuery modifiedWithin(TimeInterval... intervals);
/**
* Add the time intervals within which the workbasket was modified to your query. For each time
* interval, the database query will search for workbaskets whose created timestamp is after or at
* the interval's begin and before or at the interval's end. If more than one interval is
* specified, the query will connect them with the OR keyword. If either begin or end of an
* interval are null, these values will not be specified in the query.
*
* @param intervals - the TimeIntervals within which the workbasket was created
* @return the query
*/
WorkbasketQuery modifiedWithin(TimeInterval... intervals);
/**
* Add your description to your query. It will be compared case-insensitively to the descriptions of workbaskets
* using the LIKE operator. You may use a wildcard like '%' to search generically. If you specify multiple arguments
* they are combined with the OR keyword.
*
* @param description
* your description
* @return the query
*/
WorkbasketQuery descriptionLike(String... description);
/**
* Add your description to your query. It will be compared case-insensitively to the descriptions
* of workbaskets using the LIKE operator. You may use a wildcard like '%' to search generically.
* If you specify multiple arguments they are combined with the OR keyword.
*
* @param description your description
* @return the query
*/
WorkbasketQuery descriptionLike(String... description);
/**
* Add the owners to your query.
*
* @param owners
* the owners as String
* @return the query
*/
WorkbasketQuery ownerIn(String... owners);
/**
* Add the owners to your query.
*
* @param owners the owners as String
* @return the query
*/
WorkbasketQuery ownerIn(String... owners);
/**
* Add the owners for pattern matching to your query. It will be compared in SQL with the LIKE operator. You may use
* a wildcard like % to specify the pattern. If you specify multiple arguments they are combined with the OR
* keyword.
*
* @param owners
* the owners as Strings
* @return the query
*/
WorkbasketQuery ownerLike(String... owners);
/**
* Add the owners for pattern matching to your query. It will be compared in SQL with the LIKE
* operator. You may use a wildcard like % to specify the pattern. If you specify multiple
* arguments they are combined with the OR keyword.
*
* @param owners the owners as Strings
* @return the query
*/
WorkbasketQuery ownerLike(String... owners);
/**
* Setting up the permission which should be granted on the result workbaskets and the users which should be
* checked. READ permission will always be checked by default.<br>
* The AccessIds and the given permission will throw a Exception if they would be NULL.
*
* @param permission
* which should be used for results.
* @param accessIds
* Users which sould be checked for given permissions on workbaskets.
* @return the current query object.
* @throws InvalidArgumentException
* when permission OR the accessIds are NULL.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/
WorkbasketQuery accessIdsHavePermission(WorkbasketPermission permission, String... accessIds)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Setting up the permission which should be granted on the result workbaskets and the users which
* should be checked. READ permission will always be checked by default.<br>
* The AccessIds and the given permission will throw a Exception if they would be NULL.
*
* @param permission which should be used for results.
* @param accessIds Users which sould be checked for given permissions on workbaskets.
* @return the current query object.
* @throws InvalidArgumentException when permission OR the accessIds are NULL.
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
*/
WorkbasketQuery accessIdsHavePermission(WorkbasketPermission permission, String... accessIds)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Add condition to query if the caller (one of the accessIds of the caller) has the given permission on the
* workbasket.
*
* @return the updated query.
* @param permission
* the permission for the query condition.
*/
WorkbasketQuery callerHasPermission(WorkbasketPermission permission);
/**
* Add condition to query if the caller (one of the accessIds of the caller) has the given
* permission on the workbasket.
*
* @return the updated query.
* @param permission the permission for the query condition.
*/
WorkbasketQuery callerHasPermission(WorkbasketPermission permission);
/**
* Sort the query result by name.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByName(SortDirection sortDirection);
/**
* Sort the query result by name.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByName(SortDirection sortDirection);
/**
* Sort the query result by key.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByKey(SortDirection sortDirection);
/**
* Sort the query result by key.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByKey(SortDirection sortDirection);
/**
* Sort the query result by description.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByDescription(SortDirection sortDirection);
/**
* Sort the query result by description.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByDescription(SortDirection sortDirection);
/**
* Sort the query result by owner.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByOwner(SortDirection sortDirection);
/**
* Sort the query result by owner.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByOwner(SortDirection sortDirection);
/**
* Sort the query result by type.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByType(SortDirection sortDirection);
/**
* Sort the query result by type.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByType(SortDirection sortDirection);
/**
* Sort the query result by domain.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByDomain(SortDirection sortDirection);
/**
* Sort the query result by domain.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByDomain(SortDirection sortDirection);
/**
* Add the domains for pattern matching to your query. It will be compared in SQL with the LIKE operator. You may
* use a wildcard like % to specify the pattern. If you specify multiple arguments they are combined with the OR
* keyword.
*
* @param domain
* the domains of workbaskets as Strings
* @return the query
*/
WorkbasketQuery domainLike(String... domain);
/**
* Add the domains for pattern matching to your query. It will be compared in SQL with the LIKE
* operator. You may use a wildcard like % to specify the pattern. If you specify multiple
* arguments they are combined with the OR keyword.
*
* @param domain the domains of workbaskets as Strings
* @return the query
*/
WorkbasketQuery domainLike(String... domain);
/**
* Sort the query result by custom property 1.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom1(SortDirection sortDirection);
/**
* Sort the query result by custom property 1.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom1(SortDirection sortDirection);
/**
* Sort the query result by custom property 2.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom2(SortDirection sortDirection);
/**
* Sort the query result by custom property 2.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom2(SortDirection sortDirection);
/**
* Sort the query result by custom property 3.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom3(SortDirection sortDirection);
/**
* Sort the query result by custom property 3.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom3(SortDirection sortDirection);
/**
* Sort the query result by custom property 4.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom4(SortDirection sortDirection);
/**
* Sort the query result by custom property 4.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByCustom4(SortDirection sortDirection);
/**
* Sort the query result by organization level 1.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByOrgLevel1(SortDirection sortDirection);
/**
* Sort the query result by organization level 1.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByOrgLevel1(SortDirection sortDirection);
/**
* Sort the query result by organization level 2.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByOrgLevel2(SortDirection sortDirection);
/**
* Sort the query result by organization level 2.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByOrgLevel2(SortDirection sortDirection);
/**
* Sort the query result by organization level 3.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByOrgLevel3(SortDirection sortDirection);
/**
* Sort the query result by organization level 3.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByOrgLevel3(SortDirection sortDirection);
/**
* Sort the query result by organization level 4.
*
* @param sortDirection
* Determines whether the result is sorted in ascending or descending order. If sortDirection is null,
* the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByOrgLevel4(SortDirection sortDirection);
/**
* Sort the query result by organization level 4.
*
* @param sortDirection Determines whether the result is sorted in ascending or descending order.
* If sortDirection is null, the result is sorted in ascending order
* @return the query
*/
WorkbasketQuery orderByOrgLevel4(SortDirection sortDirection);
/**
* Add the 1st custom property to your query.
*
* @param custom1
* the 1st custom property as String
* @return the query
*/
WorkbasketQuery custom1In(String... custom1);
/**
* Add the 1st custom property to your query.
*
* @param custom1 the 1st custom property as String
* @return the query
*/
WorkbasketQuery custom1In(String... custom1);
/**
* Add the 1st custom property for pattern matching to your query. It will be compared in SQL with the LIKE
* operator. You may use a wildcard like % to specify the pattern. If you specify multiple arguments they are
* combined with the OR keyword.
*
* @param custom1
* the 1st custom property of workbaskets as Strings
* @return the query
*/
WorkbasketQuery custom1Like(String... custom1);
/**
* Add the 1st custom property for pattern matching to your query. It will be compared in SQL with
* the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify
* multiple arguments they are combined with the OR keyword.
*
* @param custom1 the 1st custom property of workbaskets as Strings
* @return the query
*/
WorkbasketQuery custom1Like(String... custom1);
/**
* Add the 2nd custom property to your query.
*
* @param custom2
* the 2nd custom property as String
* @return the query
*/
WorkbasketQuery custom2In(String... custom2);
/**
* Add the 2nd custom property to your query.
*
* @param custom2 the 2nd custom property as String
* @return the query
*/
WorkbasketQuery custom2In(String... custom2);
/**
* Add the 2nd custom property for pattern matching to your query. It will be compared in SQL with the LIKE
* operator. You may use a wildcard like % to specify the pattern. If you specify multiple arguments they are
* combined with the OR keyword.
*
* @param custom2
* the 2nd custom property of workbaskets as Strings
* @return the query
*/
WorkbasketQuery custom2Like(String... custom2);
/**
* Add the 2nd custom property for pattern matching to your query. It will be compared in SQL with
* the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify
* multiple arguments they are combined with the OR keyword.
*
* @param custom2 the 2nd custom property of workbaskets as Strings
* @return the query
*/
WorkbasketQuery custom2Like(String... custom2);
/**
* Add the 3rd custom property to your query.
*
* @param custom3
* the 3rd custom property as String
* @return the query
*/
WorkbasketQuery custom3In(String... custom3);
/**
* Add the 3rd custom property to your query.
*
* @param custom3 the 3rd custom property as String
* @return the query
*/
WorkbasketQuery custom3In(String... custom3);
/**
* Add the 3rd custom property for pattern matching to your query. It will be compared in SQL with the LIKE
* operator. You may use a wildcard like % to specify the pattern. If you specify multiple arguments they are
* combined with the OR keyword.
*
* @param custom3
* the 3rd custom property of workbaskets as Strings
* @return the query
*/
WorkbasketQuery custom3Like(String... custom3);
/**
* Add the 3rd custom property for pattern matching to your query. It will be compared in SQL with
* the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify
* multiple arguments they are combined with the OR keyword.
*
* @param custom3 the 3rd custom property of workbaskets as Strings
* @return the query
*/
WorkbasketQuery custom3Like(String... custom3);
/**
* Add the 4th custom property to your query.
*
* @param custom4
* the 4th custom property as String
* @return the query
*/
WorkbasketQuery custom4In(String... custom4);
/**
* Add the 4th custom property to your query.
*
* @param custom4 the 4th custom property as String
* @return the query
*/
WorkbasketQuery custom4In(String... custom4);
/**
* Add the 4th custom property for pattern matching to your query. It will be compared in SQL with the LIKE
* operator. You may use a wildcard like % to specify the pattern. If you specify multiple arguments they are
* combined with the OR keyword.
*
* @param custom4
* the 4th custom property of workbaskets as Strings
* @return the query
*/
WorkbasketQuery custom4Like(String... custom4);
/**
* Add the 4th custom property for pattern matching to your query. It will be compared in SQL with
* the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify
* multiple arguments they are combined with the OR keyword.
*
* @param custom4 the 4th custom property of workbaskets as Strings
* @return the query
*/
WorkbasketQuery custom4Like(String... custom4);
/**
* Add the 1st organization level to your query.
*
* @param orgLevel1
* the 1st organization level as String
* @return the query
*/
WorkbasketQuery orgLevel1In(String... orgLevel1);
/**
* Add the 1st organization level to your query.
*
* @param orgLevel1 the 1st organization level as String
* @return the query
*/
WorkbasketQuery orgLevel1In(String... orgLevel1);
/**
* Add the 1st organization level for pattern matching to your query. It will be compared in SQL with the LIKE
* operator. You may use a wildcard like % to specify the pattern. If you specify multiple arguments they are
* combined with the OR keyword.
*
* @param orgLevel1
* the 1st organization level as Strings
* @return the query
*/
WorkbasketQuery orgLevel1Like(String... orgLevel1);
/**
* Add the 1st organization level for pattern matching to your query. It will be compared in SQL
* with the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify
* multiple arguments they are combined with the OR keyword.
*
* @param orgLevel1 the 1st organization level as Strings
* @return the query
*/
WorkbasketQuery orgLevel1Like(String... orgLevel1);
/**
* Add the 2nd organization level to your query.
*
* @param orgLevel2
* the 2nd organization level as String
* @return the query
*/
WorkbasketQuery orgLevel2In(String... orgLevel2);
/**
* Add the 2nd organization level to your query.
*
* @param orgLevel2 the 2nd organization level as String
* @return the query
*/
WorkbasketQuery orgLevel2In(String... orgLevel2);
/**
* Add the 2nd organization level for pattern matching to your query. It will be compared in SQL with the LIKE
* operator. You may use a wildcard like % to specify the pattern. If you specify multiple arguments they are
* combined with the OR keyword.
*
* @param orgLevel2
* the 2nd organization level as Strings
* @return the query
*/
WorkbasketQuery orgLevel2Like(String... orgLevel2);
/**
* Add the 2nd organization level for pattern matching to your query. It will be compared in SQL
* with the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify
* multiple arguments they are combined with the OR keyword.
*
* @param orgLevel2 the 2nd organization level as Strings
* @return the query
*/
WorkbasketQuery orgLevel2Like(String... orgLevel2);
/**
* Add the 3rd organization level to your query.
*
* @param orgLevel3
* the 3rd organization level as String
* @return the query
*/
WorkbasketQuery orgLevel3In(String... orgLevel3);
/**
* Add the 3rd organization level to your query.
*
* @param orgLevel3 the 3rd organization level as String
* @return the query
*/
WorkbasketQuery orgLevel3In(String... orgLevel3);
/**
* Add the 3rd organization level for pattern matching to your query. It will be compared in SQL with the LIKE
* operator. You may use a wildcard like % to specify the pattern. If you specify multiple arguments they are
* combined with the OR keyword.
*
* @param orgLevel3
* the 3rd organization level as Strings
* @return the query
*/
WorkbasketQuery orgLevel3Like(String... orgLevel3);
/**
* Add the 3rd organization level for pattern matching to your query. It will be compared in SQL
* with the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify
* multiple arguments they are combined with the OR keyword.
*
* @param orgLevel3 the 3rd organization level as Strings
* @return the query
*/
WorkbasketQuery orgLevel3Like(String... orgLevel3);
/**
* Add the 4th organization level to your query.
*
* @param orgLevel4
* the 4th organization level as String
* @return the query
*/
WorkbasketQuery orgLevel4In(String... orgLevel4);
/**
* Add the 4th organization level to your query.
*
* @param orgLevel4 the 4th organization level as String
* @return the query
*/
WorkbasketQuery orgLevel4In(String... orgLevel4);
/**
* Add the 4th organization level for pattern matching to your query. It will be compared in SQL with the LIKE
* operator. You may use a wildcard like % to specify the pattern. If you specify multiple arguments they are
* combined with the OR keyword.
*
* @param orgLevel4
* the 4th organization level as Strings
* @return the query
*/
WorkbasketQuery orgLevel4Like(String... orgLevel4);
/**
* Add to your query if the Workbasket shall be marked for deletion.
*
* @param markedForDeletion
* a simple flag showing if the workbasket is marked for deletion
* @return the query
*/
WorkbasketQuery markedForDeletion(boolean markedForDeletion);
/**
* Add the 4th organization level for pattern matching to your query. It will be compared in SQL
* with the LIKE operator. You may use a wildcard like % to specify the pattern. If you specify
* multiple arguments they are combined with the OR keyword.
*
* @param orgLevel4 the 4th organization level as Strings
* @return the query
*/
WorkbasketQuery orgLevel4Like(String... orgLevel4);
/**
* Add to your query if the Workbasket shall be marked for deletion.
*
* @param markedForDeletion a simple flag showing if the workbasket is marked for deletion
* @return the query
*/
WorkbasketQuery markedForDeletion(boolean markedForDeletion);
}

View File

@ -1,34 +1,35 @@
package pro.taskana;
/**
* Enum containing the column names for @see {@link pro.taskana.mappings.QueryMapper#queryWorkbasketColumnValues(pro.taskana.impl.WorkbasketQueryImpl)}.
* Enum containing the column names for @see {@link
* pro.taskana.mappings.QueryMapper#queryWorkbasketColumnValues(pro.taskana.impl.WorkbasketQueryImpl)}.
*
* @author jsa
*/
public enum WorkbasketQueryColumnName implements QueryColumnName {
OWNER("w.owner"),
ID("w.id"),
KEY("w.key"),
NAME("w.name"),
DOMAIN("w.domain"),
TYPE("w.type"),
CUSTOM_1("w.custom_1"),
CUSTOM_2("w.custom_2"),
CUSTOM_3("w.custom_3"),
CUSTOM_4("w.custom_4"),
ORG_LEVEL_1("w.org_level_1"),
ORG_LEVEL_2("w.org_level_2"),
ORG_LEVEL_3("w.org_level_3"),
ORG_LEVEL_4("w.org_level_4");
OWNER("w.owner"),
ID("w.id"),
KEY("w.key"),
NAME("w.name"),
DOMAIN("w.domain"),
TYPE("w.type"),
CUSTOM_1("w.custom_1"),
CUSTOM_2("w.custom_2"),
CUSTOM_3("w.custom_3"),
CUSTOM_4("w.custom_4"),
ORG_LEVEL_1("w.org_level_1"),
ORG_LEVEL_2("w.org_level_2"),
ORG_LEVEL_3("w.org_level_3"),
ORG_LEVEL_4("w.org_level_4");
private String name;
private String name;
WorkbasketQueryColumnName(String name) {
this.name = name;
}
WorkbasketQueryColumnName(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
@Override
public String toString() {
return name;
}
}

View File

@ -11,366 +11,315 @@ import pro.taskana.exceptions.WorkbasketAlreadyExistException;
import pro.taskana.exceptions.WorkbasketInUseException;
import pro.taskana.exceptions.WorkbasketNotFoundException;
/**
* This service manages Workbaskets.
*/
/** This service manages Workbaskets. */
public interface WorkbasketService {
/**
* Get Workbasket for a given id.
*
* @param workbasketId
* the Id of the Workbasket requested
* @return the requested Workbasket
* @throws WorkbasketNotFoundException
* If the Workbasket with workbasketId is not found
* @throws NotAuthorizedException
* If the current user or group does not have the permissions for interactions.
*/
Workbasket getWorkbasket(String workbasketId)
throws WorkbasketNotFoundException, NotAuthorizedException;
/**
* Get Workbasket for a given id.
*
* @param workbasketId the Id of the Workbasket requested
* @return the requested Workbasket
* @throws WorkbasketNotFoundException If the Workbasket with workbasketId is not found
* @throws NotAuthorizedException If the current user or group does not have the permissions for
* interactions.
*/
Workbasket getWorkbasket(String workbasketId)
throws WorkbasketNotFoundException, NotAuthorizedException;
/**
* Get Workbasket for a given key.
*
* @param workbasketKey
* the Key of the Workbasket requested
* @param domain
* the domain of the workbasket
* @return the requested Workbasket
* @throws WorkbasketNotFoundException
* If the Workbasket with workbasketId is not found
* @throws NotAuthorizedException
* If the current user or group does not have the permissions for interactions.
*/
Workbasket getWorkbasket(String workbasketKey, String domain)
throws WorkbasketNotFoundException, NotAuthorizedException;
/**
* Get Workbasket for a given key.
*
* @param workbasketKey the Key of the Workbasket requested
* @param domain the domain of the workbasket
* @return the requested Workbasket
* @throws WorkbasketNotFoundException If the Workbasket with workbasketId is not found
* @throws NotAuthorizedException If the current user or group does not have the permissions for
* interactions.
*/
Workbasket getWorkbasket(String workbasketKey, String domain)
throws WorkbasketNotFoundException, NotAuthorizedException;
/**
* Create a new Workbasket.
*
* @param workbasket
* The Workbasket to create
* @return the created and persisted Workbasket
* @throws InvalidWorkbasketException
* If a required property of the Workbasket is not set.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
* @throws WorkbasketAlreadyExistException
* if the workbasket exists already
* @throws DomainNotFoundException
* if the domain does not exist in the configuration.
*/
Workbasket createWorkbasket(Workbasket workbasket)
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
DomainNotFoundException;
/**
* Create a new Workbasket.
*
* @param workbasket The Workbasket to create
* @return the created and persisted Workbasket
* @throws InvalidWorkbasketException If a required property of the Workbasket is not set.
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
* @throws WorkbasketAlreadyExistException if the workbasket exists already
* @throws DomainNotFoundException if the domain does not exist in the configuration.
*/
Workbasket createWorkbasket(Workbasket workbasket)
throws InvalidWorkbasketException, NotAuthorizedException, WorkbasketAlreadyExistException,
DomainNotFoundException;
/**
* Update a Workbasket.
*
* @param workbasket
* The Workbasket to update
* @return the updated Workbasket
* @throws NotAuthorizedException
* if the current user is not authorized to update the work basket
*/
Workbasket updateWorkbasket(Workbasket workbasket)
throws NotAuthorizedException;
/**
* Update a Workbasket.
*
* @param workbasket The Workbasket to update
* @return the updated Workbasket
* @throws NotAuthorizedException if the current user is not authorized to update the work basket
*/
Workbasket updateWorkbasket(Workbasket workbasket) throws NotAuthorizedException;
/**
* Returns a new WorkbasketAccessItem which is not persisted.
*
* @param workbasketId
* the workbasket id used to identify the referenced workbasket
* @param accessId
* the group id or user id for which access is controlled
* @return new WorkbasketAccessItem
*/
WorkbasketAccessItem newWorkbasketAccessItem(String workbasketId, String accessId);
/**
* Returns a new WorkbasketAccessItem which is not persisted.
*
* @param workbasketId the workbasket id used to identify the referenced workbasket
* @param accessId the group id or user id for which access is controlled
* @return new WorkbasketAccessItem
*/
WorkbasketAccessItem newWorkbasketAccessItem(String workbasketId, String accessId);
/**
* Create and persist a new {@link WorkbasketAccessItem} with a WorkbasketId, an accessId and permissions.
*
* @param workbasketAccessItem
* the new workbasketAccessItem
* @return the created WorkbasketAccessItem
* @throws InvalidArgumentException
* when the preconditions dont match the required ones.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
* @throws WorkbasketNotFoundException
* if the workbasketAccessItem refers to a not existing workbasket
*/
WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException;
/**
* Create and persist a new {@link WorkbasketAccessItem} with a WorkbasketId, an accessId and
* permissions.
*
* @param workbasketAccessItem the new workbasketAccessItem
* @return the created WorkbasketAccessItem
* @throws InvalidArgumentException when the preconditions dont match the required ones.
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
* @throws WorkbasketNotFoundException if the workbasketAccessItem refers to a not existing
* workbasket
*/
WorkbasketAccessItem createWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException, WorkbasketNotFoundException;
/**
* This method updates a {@link WorkbasketAccessItem}.
*
* @param workbasketAccessItem
* the {@link WorkbasketAccessItem}
* @return the updated entity
* @throws InvalidArgumentException
* if accessid or workbasketId is changed in the workbasketAccessItem
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/
WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException;
/**
* This method updates a {@link WorkbasketAccessItem}.
*
* @param workbasketAccessItem the {@link WorkbasketAccessItem}
* @return the updated entity
* @throws InvalidArgumentException if accessid or workbasketId is changed in the
* workbasketAccessItem
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
*/
WorkbasketAccessItem updateWorkbasketAccessItem(WorkbasketAccessItem workbasketAccessItem)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Deletes a specific {@link WorkbasketAccessItem}.
*
* @param id
* the id of the WorbasketAccessItem to be deleted
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/
void deleteWorkbasketAccessItem(String id) throws NotAuthorizedException;
/**
* Deletes a specific {@link WorkbasketAccessItem}.
*
* @param id the id of the WorbasketAccessItem to be deleted
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
*/
void deleteWorkbasketAccessItem(String id) throws NotAuthorizedException;
/**
* This method checks the authorization for the actual User.
*
* @param workbasketId
* the id of the workbasket we want to access
* @param permission
* the needed {@link WorkbasketPermission} If more than one permission is specified, the current user
* needs all of them.
* @throws NotAuthorizedException
* if the current user has not the requested authorization for the specified workbasket
* @throws WorkbasketNotFoundException
* if the workbasket cannot be found for the given ID.
*/
void checkAuthorization(String workbasketId, WorkbasketPermission... permission)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* This method checks the authorization for the actual User.
*
* @param workbasketId the id of the workbasket we want to access
* @param permission the needed {@link WorkbasketPermission} If more than one permission is
* specified, the current user needs all of them.
* @throws NotAuthorizedException if the current user has not the requested authorization for the
* specified workbasket
* @throws WorkbasketNotFoundException if the workbasket cannot be found for the given ID.
*/
void checkAuthorization(String workbasketId, WorkbasketPermission... permission)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* This method checks the authorization for the actual User.
*
* @param workbasketKey
* the key of the workbasket we want to access
* @param domain
* the domain of the workbasket we want to access
* @param permission
* the needed {@link WorkbasketPermission}. If more than one permission is specified, the current user
* needs all of them.
* @throws NotAuthorizedException
* if the current user has not the requested permission for the specified workbasket
* @throws WorkbasketNotFoundException
* if no workbasket can be found for the given key+domain values.
*/
void checkAuthorization(String workbasketKey, String domain, WorkbasketPermission... permission)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* This method checks the authorization for the actual User.
*
* @param workbasketKey the key of the workbasket we want to access
* @param domain the domain of the workbasket we want to access
* @param permission the needed {@link WorkbasketPermission}. If more than one permission is
* specified, the current user needs all of them.
* @throws NotAuthorizedException if the current user has not the requested permission for the
* specified workbasket
* @throws WorkbasketNotFoundException if no workbasket can be found for the given key+domain
* values.
*/
void checkAuthorization(String workbasketKey, String domain, WorkbasketPermission... permission)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Get all {@link WorkbasketAccessItem s} for a Workbasket.
*
* @param workbasketId
* the id of the Workbasket
* @return List of WorkbasketAccessItems for the Workbasket with workbasketKey
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/
List<WorkbasketAccessItem> getWorkbasketAccessItems(String workbasketId) throws NotAuthorizedException;
/**
* Get all {@link WorkbasketAccessItem s} for a Workbasket.
*
* @param workbasketId the id of the Workbasket
* @return List of WorkbasketAccessItems for the Workbasket with workbasketKey
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
*/
List<WorkbasketAccessItem> getWorkbasketAccessItems(String workbasketId)
throws NotAuthorizedException;
/**
* Setting up the new WorkbasketAccessItems for a Workbasket. Already stored values will be completely replaced by
* the current ones.
*
* @param workbasketId
* ID of the access-target workbasket.
* @param wbAccessItems
* List of WorkbasketAccessItems which does replace all current stored ones.
* @throws InvalidArgumentException
* will be thrown when the parameter is NULL or member doesn´t match the preconditions
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/
void setWorkbasketAccessItems(String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
throws InvalidArgumentException, NotAuthorizedException;
/**
* Setting up the new WorkbasketAccessItems for a Workbasket. Already stored values will be
* completely replaced by the current ones.
*
* @param workbasketId ID of the access-target workbasket.
* @param wbAccessItems List of WorkbasketAccessItems which does replace all current stored ones.
* @throws InvalidArgumentException will be thrown when the parameter is NULL or member doesn´t
* match the preconditions
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
*/
void setWorkbasketAccessItems(String workbasketId, List<WorkbasketAccessItem> wbAccessItems)
throws InvalidArgumentException, NotAuthorizedException;
/**
* This method provides a query builder for querying the database.
*
* @return a {@link WorkbasketQuery}
*/
WorkbasketQuery createWorkbasketQuery();
/**
* This method provides a query builder for querying the database.
*
* @return a {@link WorkbasketQuery}
*/
WorkbasketQuery createWorkbasketQuery();
/**
* This method provides a query builder for querying the database.
*
* @return a {@link WorkbasketAccessItemQuery}
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/
WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException;
/**
* This method provides a query builder for querying the database.
*
* @return a {@link WorkbasketAccessItemQuery}
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
*/
WorkbasketAccessItemQuery createWorkbasketAccessItemQuery() throws NotAuthorizedException;
/**
* Returns a new workbasket which is not persisted.
*
* @param key
* the workbasket key used to identify the workbasket
* @param domain
* the domain of the new workbasket
* @return new Workbasket
*/
Workbasket newWorkbasket(String key, String domain);
/**
* Returns a new workbasket which is not persisted.
*
* @param key the workbasket key used to identify the workbasket
* @param domain the domain of the new workbasket
* @return new Workbasket
*/
Workbasket newWorkbasket(String key, String domain);
/**
* Returns a set with all permissions of the current user at this workbasket.<br>
* If the workbasketId is invalid, an empty list of permissions is returned since there is no distinction made
* between the situation that the workbasket is not found and the caller has no permissions on the workbasket.
*
* @param workbasketId
* the id of the referenced workbasket
* @return a {@link List} with all {@link WorkbasketPermission}s of the caller on the requested workbasket.
*/
List<WorkbasketPermission> getPermissionsForWorkbasket(String workbasketId);
/**
* Returns a set with all permissions of the current user at this workbasket.<br>
* If the workbasketId is invalid, an empty list of permissions is returned since there is no
* distinction made between the situation that the workbasket is not found and the caller has no
* permissions on the workbasket.
*
* @param workbasketId the id of the referenced workbasket
* @return a {@link List} with all {@link WorkbasketPermission}s of the caller on the requested
* workbasket.
*/
List<WorkbasketPermission> getPermissionsForWorkbasket(String workbasketId);
/**
* Returns the distribution targets for a given workbasket.
*
* @param workbasketId
* the id of the referenced workbasket
* @return the distribution targets of the specified workbasket
* @throws NotAuthorizedException
* if the current user has no read permission for the specified workbasket
* @throws WorkbasketNotFoundException
* if the workbasket doesn't exist
*/
List<WorkbasketSummary> getDistributionTargets(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Returns the distribution targets for a given workbasket.
*
* @param workbasketId the id of the referenced workbasket
* @return the distribution targets of the specified workbasket
* @throws NotAuthorizedException if the current user has no read permission for the specified
* workbasket
* @throws WorkbasketNotFoundException if the workbasket doesn't exist
*/
List<WorkbasketSummary> getDistributionTargets(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Returns the distribution targets for a given workbasket.
*
* @param workbasketKey
* the key of the referenced workbasket
* @param domain
* the domain of the referenced workbasket
* @return the distribution targets of the specified workbasket
* @throws NotAuthorizedException
* if the current user has no read permission for the specified workbasket
* @throws WorkbasketNotFoundException
* if the workbasket doesn't exist
*/
List<WorkbasketSummary> getDistributionTargets(String workbasketKey, String domain)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Returns the distribution targets for a given workbasket.
*
* @param workbasketKey the key of the referenced workbasket
* @param domain the domain of the referenced workbasket
* @return the distribution targets of the specified workbasket
* @throws NotAuthorizedException if the current user has no read permission for the specified
* workbasket
* @throws WorkbasketNotFoundException if the workbasket doesn't exist
*/
List<WorkbasketSummary> getDistributionTargets(String workbasketKey, String domain)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Set the distribution targets for a workbasket.
*
* @param sourceWorkbasketId
* the id of the source workbasket for which the distribution targets are to be set
* @param targetWorkbasketIds
* a list of the ids of the target workbaskets
* @throws NotAuthorizedException
* if the current used doesn't have READ permission for the source workbasket
* @throws WorkbasketNotFoundException
* if either the source workbasket or any of the target workbaskets don't exist
*/
void setDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Set the distribution targets for a workbasket.
*
* @param sourceWorkbasketId the id of the source workbasket for which the distribution targets
* are to be set
* @param targetWorkbasketIds a list of the ids of the target workbaskets
* @throws NotAuthorizedException if the current used doesn't have READ permission for the source
* workbasket
* @throws WorkbasketNotFoundException if either the source workbasket or any of the target
* workbaskets don't exist
*/
void setDistributionTargets(String sourceWorkbasketId, List<String> targetWorkbasketIds)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Add a distribution target to a workbasket. If the specified distribution target exists already, the method
* silently returns without doing anything.
*
* @param sourceWorkbasketId
* the id of the source workbasket
* @param targetWorkbasketId
* the id of the target workbasket
* @throws NotAuthorizedException
* if the current user doesn't have READ permission for the source workbasket
* @throws WorkbasketNotFoundException
* if either the source workbasket or the target workbasket doesn't exist
*/
void addDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Add a distribution target to a workbasket. If the specified distribution target exists already,
* the method silently returns without doing anything.
*
* @param sourceWorkbasketId the id of the source workbasket
* @param targetWorkbasketId the id of the target workbasket
* @throws NotAuthorizedException if the current user doesn't have READ permission for the source
* workbasket
* @throws WorkbasketNotFoundException if either the source workbasket or the target workbasket
* doesn't exist
*/
void addDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Remove a distribution target from a workbasket. If the the specified distribution target doesn't exist, the
* method silently returns without doing anything.
*
* @param sourceWorkbasketId
* The id of the source workbasket
* @param targetWorkbasketId
* The id of the target workbasket
* @throws NotAuthorizedException
* If the current user doesn't have READ permission for the source workbasket
*/
void removeDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)
throws NotAuthorizedException;
/**
* Remove a distribution target from a workbasket. If the the specified distribution target
* doesn't exist, the method silently returns without doing anything.
*
* @param sourceWorkbasketId The id of the source workbasket
* @param targetWorkbasketId The id of the target workbasket
* @throws NotAuthorizedException If the current user doesn't have READ permission for the source
* workbasket
*/
void removeDistributionTarget(String sourceWorkbasketId, String targetWorkbasketId)
throws NotAuthorizedException;
/**
* Deletes the workbasket by the given ID of it.
*
* @param workbasketId
* Id of the workbasket which should be deleted.
* @return true if the workbasket is marked for deletion. False in another case.
* @throws NotAuthorizedException
* if the current user got no permissions for this interaction.
* @throws WorkbasketNotFoundException
* if the workbasket does not exist.
* @throws WorkbasketInUseException
* if the workbasket does contain task-content.
* @throws InvalidArgumentException
* if the workbasketId is NULL or EMPTY
*/
boolean deleteWorkbasket(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException, InvalidArgumentException;
/**
* Deletes the workbasket by the given ID of it.
*
* @param workbasketId Id of the workbasket which should be deleted.
* @return true if the workbasket is marked for deletion. False in another case.
* @throws NotAuthorizedException if the current user got no permissions for this interaction.
* @throws WorkbasketNotFoundException if the workbasket does not exist.
* @throws WorkbasketInUseException if the workbasket does contain task-content.
* @throws InvalidArgumentException if the workbasketId is NULL or EMPTY
*/
boolean deleteWorkbasket(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException, WorkbasketInUseException,
InvalidArgumentException;
/**
* Deletes a list of workbaskets.
*
* @param workbasketsIds
* the ids of the workbaskets to delete.
* @return the result of the operations with Id and Exception for each failed workbasket deletion.
* @throws InvalidArgumentException
* if the WorkbasketIds parameter list is NULL or empty
* @throws NotAuthorizedException
* if the current user got no permission for this interaction.
*/
BulkOperationResults<String, TaskanaException> deleteWorkbaskets(List<String> workbasketsIds)
throws NotAuthorizedException, InvalidArgumentException;
/**
* Deletes a list of workbaskets.
*
* @param workbasketsIds the ids of the workbaskets to delete.
* @return the result of the operations with Id and Exception for each failed workbasket deletion.
* @throws InvalidArgumentException if the WorkbasketIds parameter list is NULL or empty
* @throws NotAuthorizedException if the current user got no permission for this interaction.
*/
BulkOperationResults<String, TaskanaException> deleteWorkbaskets(List<String> workbasketsIds)
throws NotAuthorizedException, InvalidArgumentException;
/**
* Returns the distribution sources for a given workbasket.
*
* @param workbasketId
* the id of the referenced workbasket
* @return the workbaskets that are distribution sources of the specified workbasket.
* @throws NotAuthorizedException
* if the current user has no read permission for the specified workbasket
* @throws WorkbasketNotFoundException
* if the workbasket doesn't exist
*/
List<WorkbasketSummary> getDistributionSources(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Returns the distribution sources for a given workbasket.
*
* @param workbasketId the id of the referenced workbasket
* @return the workbaskets that are distribution sources of the specified workbasket.
* @throws NotAuthorizedException if the current user has no read permission for the specified
* workbasket
* @throws WorkbasketNotFoundException if the workbasket doesn't exist
*/
List<WorkbasketSummary> getDistributionSources(String workbasketId)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Returns the distribution sources for a given workbasket.
*
* @param workbasketKey
* the key of the referenced workbasket
* @param domain
* the domain of the referenced workbasket
* @return the workbaskets that are distribution sources of the specified workbasket.
* @throws NotAuthorizedException
* if the current user has no read permission for the specified workbasket
* @throws WorkbasketNotFoundException
* if the workbasket doesn't exist
*/
List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Returns the distribution sources for a given workbasket.
*
* @param workbasketKey the key of the referenced workbasket
* @param domain the domain of the referenced workbasket
* @return the workbaskets that are distribution sources of the specified workbasket.
* @throws NotAuthorizedException if the current user has no read permission for the specified
* workbasket
* @throws WorkbasketNotFoundException if the workbasket doesn't exist
*/
List<WorkbasketSummary> getDistributionSources(String workbasketKey, String domain)
throws NotAuthorizedException, WorkbasketNotFoundException;
/**
* Deletes all WorkbasketAccessItems using the given AccessId of a user.
*
* @param accessId
* of a taskana-user.
* @throws NotAuthorizedException
* if the current user is not member of role BUSINESS_ADMIN or ADMIN
*/
void deleteWorkbasketAccessItemsForAccessId(String accessId) throws NotAuthorizedException;
/**
* Deletes all WorkbasketAccessItems using the given AccessId of a user.
*
* @param accessId of a taskana-user.
* @throws NotAuthorizedException if the current user is not member of role BUSINESS_ADMIN or
* ADMIN
*/
void deleteWorkbasketAccessItemsForAccessId(String accessId) throws NotAuthorizedException;
}

View File

@ -1,121 +1,120 @@
package pro.taskana;
/**
* Interface for WorkbasketSummary. This is a specific short model-object which only contains the most important
* information.
* Interface for WorkbasketSummary. This is a specific short model-object which only contains the
* most important information.
*/
public interface WorkbasketSummary {
/**
* Gets the id of the workbasket.
*
* @return workbasketId
*/
String getId();
/**
* Gets the id of the workbasket.
*
* @return workbasketId
*/
String getId();
/**
* Gets the key of the workbasket.
*
* @return workbasketKey
*/
String getKey();
/**
* Gets the key of the workbasket.
*
* @return workbasketKey
*/
String getKey();
/**
* Gets the name of the workbasket.
*
* @return workbasket's name
*/
String getName();
/**
* Gets the name of the workbasket.
*
* @return workbasket's name
*/
String getName();
/**
* Gets the description of the workbasket.
*
* @return workbasket's description
*/
String getDescription();
/**
* Gets the description of the workbasket.
*
* @return workbasket's description
*/
String getDescription();
/**
* Gets the owner of the workbasket.
*
* @return workbasket's owner
*/
String getOwner();
/**
* Gets the owner of the workbasket.
*
* @return workbasket's owner
*/
String getOwner();
/**
* Gets the domain of the workbasket.
*
* @return workbasket's domain
*/
String getDomain();
/**
* Gets the domain of the workbasket.
*
* @return workbasket's domain
*/
String getDomain();
/**
* Gets the type of the workbasket.
*
* @return workbasket's type
*/
WorkbasketType getType();
/**
* Gets the type of the workbasket.
*
* @return workbasket's type
*/
WorkbasketType getType();
/**
* Gets the custom1 property of the workbasket.
*
* @return the workbasket's custom1 property.
*/
String getCustom1();
/**
* Gets the custom1 property of the workbasket.
*
* @return the workbasket's custom1 property.
*/
String getCustom1();
/**
* Gets the custom2 property of the workbasket.
*
* @return the workbasket's custom2 property.
*/
String getCustom2();
/**
* Gets the custom2 property of the workbasket.
*
* @return the workbasket's custom2 property.
*/
String getCustom2();
/**
* Gets the custom3 property of the workbasket.
*
* @return the workbasket's custom3 property.
*/
String getCustom3();
/**
* Gets the custom3 property of the workbasket.
*
* @return the workbasket's custom3 property.
*/
String getCustom3();
/**
* Gets the custom4 property of the workbasket.
*
* @return the workbasket's custom4 property.
*/
String getCustom4();
/**
* Gets the custom4 property of the workbasket.
*
* @return the workbasket's custom4 property.
*/
String getCustom4();
/**
* Gets the orglevel1 property of the workbasket.
*
* @return the workbasket's orglevel1 property
*/
String getOrgLevel1();
/**
* Gets the orglevel1 property of the workbasket.
*
* @return the workbasket's orglevel1 property
*/
String getOrgLevel1();
/**
* Gets the orglevel2 property of the workbasket.
*
* @return the workbasket's orglevel2 property
*/
String getOrgLevel2();
/**
* Gets the orglevel2 property of the workbasket.
*
* @return the workbasket's orglevel2 property
*/
String getOrgLevel2();
/**
* Gets the orglevel3 property of the workbasket.
*
* @return the workbasket's orglevel3 property
*/
String getOrgLevel3();
/**
* Gets the orglevel3 property of the workbasket.
*
* @return the workbasket's orglevel3 property
*/
String getOrgLevel3();
/**
* Gets the orglevel4 property of the workbasket.
*
* @return the workbasket's orglevel4 property
*/
String getOrgLevel4();
/**
* Gets the markedForDeletion property of the workbasket.
*
* @return the workbasket's markedForDeletion property
*/
boolean isMarkedForDeletion();
/**
* Gets the orglevel4 property of the workbasket.
*
* @return the workbasket's orglevel4 property
*/
String getOrgLevel4();
/**
* Gets the markedForDeletion property of the workbasket.
*
* @return the workbasket's markedForDeletion property
*/
boolean isMarkedForDeletion();
}

View File

@ -1,8 +1,9 @@
package pro.taskana;
/**
* This enum contains the supported work basket types.
*/
/** This enum contains the supported work basket types. */
public enum WorkbasketType {
GROUP, PERSONAL, TOPIC, CLEARANCE
GROUP,
PERSONAL,
TOPIC,
CLEARANCE
}

View File

@ -2,45 +2,42 @@ package pro.taskana.configuration;
import pro.taskana.exceptions.UnsupportedDatabaseException;
/**
* Supported versions of databases.
*/
/** Supported versions of databases. */
public enum DB {
H2("H2", "h2"),
DB2("DB2", "db2"),
POSTGRESS("PostgreSQL", "postgres");
H2("H2", "h2"),
DB2("DB2", "db2"),
POSTGRESS("PostgreSQL", "postgres");
public final String dbProductname;
public final String dbProductId;
public final String dbProductname;
public final String dbProductId;
DB(String dbProductname, String dbProductId) {
this.dbProductname = dbProductname;
this.dbProductId = dbProductId;
}
DB(String dbProductname, String dbProductId) {
this.dbProductname = dbProductname;
this.dbProductId = dbProductId;
}
public static boolean isDb2(String dbProductName) {
return dbProductName != null && dbProductName.contains(DB2.dbProductname);
}
public static boolean isH2(String dbProductName) {
return dbProductName != null && dbProductName.contains(H2.dbProductname);
}
public static boolean isPostgreSQL(String dbProductName) {
return POSTGRESS.dbProductname.equals(dbProductName);
}
public static String getDatabaseProductId(String dbProductName) {
if (isDb2(dbProductName)) {
return DB2.dbProductId;
} else if (isH2(dbProductName)) {
return H2.dbProductId;
} else if (isPostgreSQL(dbProductName)) {
return POSTGRESS.dbProductId;
} else {
throw new UnsupportedDatabaseException(dbProductName);
}
public static boolean isDb2(String dbProductName) {
return dbProductName != null && dbProductName.contains(DB2.dbProductname);
}
public static boolean isH2(String dbProductName) {
return dbProductName != null && dbProductName.contains(H2.dbProductname);
}
public static boolean isPostgreSQL(String dbProductName) {
return POSTGRESS.dbProductname.equals(dbProductName);
}
public static String getDatabaseProductId(String dbProductName) {
if (isDb2(dbProductName)) {
return DB2.dbProductId;
} else if (isH2(dbProductName)) {
return H2.dbProductId;
} else if (isPostgreSQL(dbProductName)) {
return POSTGRESS.dbProductId;
} else {
throw new UnsupportedDatabaseException(dbProductName);
}
}
}

View File

@ -11,163 +11,164 @@ import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import javax.sql.DataSource;
import org.apache.ibatis.jdbc.ScriptRunner;
import org.apache.ibatis.jdbc.SqlRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class create the schema for taskana.
*/
/** This class create the schema for taskana. */
public class DbSchemaCreator {
private static final Logger LOGGER = LoggerFactory.getLogger(DbSchemaCreator.class);
private static final String SQL = "/sql";
private static final String DB_SCHEMA = SQL + "/taskana-schema.sql";
private static final String DB_SCHEMA_DB2 = SQL + "/taskana-schema-db2.sql";
private static final String DB_SCHEMA_POSTGRES = SQL + "/taskana-schema-postgres.sql";
private static final String DB_SCHEMA_DETECTION = SQL + "/schema-detection.sql";
private static final String DB_SCHEMA_DETECTION_POSTGRES = SQL + "/schema-detection-postgres.sql";
private static final Logger LOGGER = LoggerFactory.getLogger(DbSchemaCreator.class);
private static final String SQL = "/sql";
private static final String DB_SCHEMA = SQL + "/taskana-schema.sql";
private static final String DB_SCHEMA_DB2 = SQL + "/taskana-schema-db2.sql";
private static final String DB_SCHEMA_POSTGRES = SQL + "/taskana-schema-postgres.sql";
private static final String DB_SCHEMA_DETECTION = SQL + "/schema-detection.sql";
private static final String DB_SCHEMA_DETECTION_POSTGRES = SQL + "/schema-detection-postgres.sql";
private DataSource dataSource;
private String schemaName;
private StringWriter outWriter = new StringWriter();
private PrintWriter logWriter = new PrintWriter(outWriter);
private StringWriter errorWriter = new StringWriter();
private PrintWriter errorLogWriter = new PrintWriter(errorWriter);
private DataSource dataSource;
private String schemaName;
private StringWriter outWriter = new StringWriter();
private PrintWriter logWriter = new PrintWriter(outWriter);
private StringWriter errorWriter = new StringWriter();
private PrintWriter errorLogWriter = new PrintWriter(errorWriter);
public DbSchemaCreator(DataSource dataSource, String schema) {
super();
this.dataSource = dataSource;
this.schemaName = schema;
public DbSchemaCreator(DataSource dataSource, String schema) {
super();
this.dataSource = dataSource;
this.schemaName = schema;
}
/**
* Run all db scripts.
*
* @throws SQLException will be thrown if there will be some incorrect SQL statements invoked.
*/
public void run() throws SQLException {
Connection connection = dataSource.getConnection();
LOGGER.debug(
"Using database of type {} with url '{}'",
connection.getMetaData().getDatabaseProductName(),
connection.getMetaData().getURL());
ScriptRunner runner = getScriptRunnerInstance(connection);
try {
if (!isSchemaPreexisting(connection)) {
String scriptPath =
selectDbScriptFileName(connection.getMetaData().getDatabaseProductName());
InputStream resourceAsStream = this.getClass().getResourceAsStream(scriptPath);
BufferedReader reader =
new BufferedReader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
runner.runScript(getSqlSchemaNameParsed(reader));
}
} finally {
runner.closeConnection();
}
private static String selectDbScriptFileName(String dbProductName) {
return DB.isPostgreSQL(dbProductName)
? DB_SCHEMA_POSTGRES
: DB.isH2(dbProductName) ? DB_SCHEMA : DB_SCHEMA_DB2;
LOGGER.debug(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
}
private static String selectDbSchemaDetectionScript(String dbProductName) {
return DB.isPostgreSQL(dbProductName) ? DB_SCHEMA_DETECTION_POSTGRES : DB_SCHEMA_DETECTION;
}
public boolean isValidSchemaVersion(String expectedVersion) {
SqlRunner runner = null;
try {
Connection connection = dataSource.getConnection();
connection.setSchema(this.schemaName);
runner = new SqlRunner(connection);
LOGGER.debug(connection.getMetaData().toString());
/**
* Run all db scripts.
*
* @throws SQLException
* will be thrown if there will be some incorrect SQL statements invoked.
*/
public void run() throws SQLException {
Connection connection = dataSource.getConnection();
LOGGER.debug("Using database of type {} with url '{}'", connection.getMetaData().getDatabaseProductName(),
connection.getMetaData().getURL());
ScriptRunner runner = getScriptRunnerInstance(connection);
try {
if (!isSchemaPreexisting(connection)) {
String scriptPath = selectDbScriptFileName(connection.getMetaData().getDatabaseProductName());
InputStream resourceAsStream = this.getClass().getResourceAsStream(scriptPath);
BufferedReader reader = new BufferedReader(
new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
runner.runScript(getSqlSchemaNameParsed(reader));
}
} finally {
runner.closeConnection();
}
LOGGER.debug(outWriter.toString());
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.error(errorWriter.toString());
}
}
String query =
"select VERSION from TASKANA_SCHEMA_VERSION where "
+ "VERSION = (select max(VERSION) from TASKANA_SCHEMA_VERSION) "
+ "AND VERSION = ?";
private ScriptRunner getScriptRunnerInstance(Connection connection) {
ScriptRunner runner = new ScriptRunner(connection);
runner.setStopOnError(true);
runner.setLogWriter(logWriter);
runner.setErrorLogWriter(errorLogWriter);
return runner;
}
private boolean isSchemaPreexisting(Connection connection) {
ScriptRunner runner = getScriptRunnerInstance(connection);
StringWriter errorWriter = new StringWriter();
runner.setErrorLogWriter(new PrintWriter(errorWriter));
try {
String scriptPath = selectDbSchemaDetectionScript(connection.getMetaData().getDatabaseProductName());
InputStream resourceAsStream = this.getClass().getResourceAsStream(scriptPath);
BufferedReader reader = new BufferedReader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
runner.runScript(getSqlSchemaNameParsed(reader));
} catch (Exception e) {
LOGGER.debug("Schema does not exist.");
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.debug(errorWriter.toString());
}
return false;
}
LOGGER.debug("Schema does exist.");
Map<String, Object> queryResult = runner.selectOne(query, expectedVersion);
if (queryResult == null || queryResult.isEmpty()) {
LOGGER.error(
"Schema version not valid. The VERSION property in table TASKANA_SCHEMA_VERSION has not the expected value {}",
expectedVersion);
return false;
} else {
LOGGER.debug("Schema version is valid.");
return true;
}
} catch (Exception e) {
LOGGER.error(
"Schema version not valid. The VERSION property in table TASKANA_SCHEMA_VERSION has not the expected value {}",
expectedVersion);
return false;
} finally {
if (runner != null) {
runner.closeConnection();
}
}
}
public boolean isValidSchemaVersion(String expectedVersion) {
SqlRunner runner = null;
try {
Connection connection = dataSource.getConnection();
connection.setSchema(this.schemaName);
runner = new SqlRunner(connection);
LOGGER.debug(connection.getMetaData().toString());
public DataSource getDataSource() {
return dataSource;
}
String query = "select VERSION from TASKANA_SCHEMA_VERSION where "
+ "VERSION = (select max(VERSION) from TASKANA_SCHEMA_VERSION) "
+ "AND VERSION = ?";
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
Map<String, Object> queryResult = runner.selectOne(query, expectedVersion);
if (queryResult == null || queryResult.isEmpty()) {
LOGGER.error(
"Schema version not valid. The VERSION property in table TASKANA_SCHEMA_VERSION has not the expected value {}",
expectedVersion);
return false;
} else {
LOGGER.debug("Schema version is valid.");
return true;
}
private static String selectDbScriptFileName(String dbProductName) {
return DB.isPostgreSQL(dbProductName)
? DB_SCHEMA_POSTGRES
: DB.isH2(dbProductName) ? DB_SCHEMA : DB_SCHEMA_DB2;
}
} catch (Exception e) {
LOGGER.error(
"Schema version not valid. The VERSION property in table TASKANA_SCHEMA_VERSION has not the expected value {}",
expectedVersion);
return false;
} finally {
if (runner != null) {
runner.closeConnection();
}
private static String selectDbSchemaDetectionScript(String dbProductName) {
return DB.isPostgreSQL(dbProductName) ? DB_SCHEMA_DETECTION_POSTGRES : DB_SCHEMA_DETECTION;
}
private ScriptRunner getScriptRunnerInstance(Connection connection) {
ScriptRunner runner = new ScriptRunner(connection);
runner.setStopOnError(true);
runner.setLogWriter(logWriter);
runner.setErrorLogWriter(errorLogWriter);
return runner;
}
private boolean isSchemaPreexisting(Connection connection) {
ScriptRunner runner = getScriptRunnerInstance(connection);
StringWriter errorWriter = new StringWriter();
runner.setErrorLogWriter(new PrintWriter(errorWriter));
try {
String scriptPath =
selectDbSchemaDetectionScript(connection.getMetaData().getDatabaseProductName());
InputStream resourceAsStream = this.getClass().getResourceAsStream(scriptPath);
BufferedReader reader =
new BufferedReader(new InputStreamReader(resourceAsStream, StandardCharsets.UTF_8));
runner.runScript(getSqlSchemaNameParsed(reader));
} catch (Exception e) {
LOGGER.debug("Schema does not exist.");
if (!errorWriter.toString().trim().isEmpty()) {
LOGGER.debug(errorWriter.toString());
}
return false;
}
LOGGER.debug("Schema does exist.");
return true;
}
private StringReader getSqlSchemaNameParsed(BufferedReader reader) {
StringBuffer content = new StringBuffer();
try {
String line = "";
while (line != null) {
line = reader.readLine();
if (line != null) {
content.append(line.replaceAll("%schemaName%", schemaName) + System.lineSeparator());
}
}
} catch (IOException e) {
LOGGER.error("SchemaName sql parsing failed for schemaName {}", schemaName, e);
}
public DataSource getDataSource() {
return dataSource;
}
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
private StringReader getSqlSchemaNameParsed(BufferedReader reader) {
StringBuffer content = new StringBuffer();
try {
String line = "";
while (line != null) {
line = reader.readLine();
if (line != null) {
content.append(line.replaceAll("%schemaName%", schemaName) + System.lineSeparator());
}
}
} catch (IOException e) {
LOGGER.error("SchemaName sql parsing failed for schemaName {}", schemaName, e);
}
return new StringReader(content.toString());
}
return new StringReader(content.toString());
}
}

View File

@ -22,9 +22,7 @@ import java.util.Properties;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import javax.sql.DataSource;
import org.apache.ibatis.datasource.pooled.PooledDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -36,492 +34,521 @@ import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.impl.util.LoggerUtils;
/**
* This central class creates the TaskanaEngine and holds all the information about DB and Security.<br>
* This central class creates the TaskanaEngine and holds all the information about DB and Security.
* <br>
* Security is enabled by default.
*/
public class TaskanaEngineConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfiguration.class);
protected static final String TASKANA_SCHEMA_VERSION =
"1.1.5"; // must match the VERSION value in table
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfiguration.class);
private static final String USER_NAME = "sa";
private static final String USER_PASSWORD = "sa";
private static final String JDBC_H2_MEM_TASKANA =
"jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0";
private static final String H2_DRIVER = "org.h2.Driver";
private static final String TASKANA_PROPERTIES = "/taskana.properties";
private static final String TASKANA_ROLES_SEPARATOR = "|";
private static final String TASKANA_JOB_BATCHSIZE = "taskana.jobs.batchSize";
private static final String TASKANA_JOB_RETRIES = "taskana.jobs.maxRetries";
private static final String TASKANA_JOB_CLEANUP_RUN_EVERY = "taskana.jobs.cleanup.runEvery";
private static final String TASKANA_JOB_CLEANUP_FIRST_RUN = "taskana.jobs.cleanup.firstRunAt";
private static final String TASKANA_JOB_CLEANUP_MINIMUM_AGE = "taskana.jobs.cleanup.minimumAge";
private static final String TASKANA_JOB_TASK_CLEANUP_ALL_COMPLETED_SAME_PARENTE_BUSINESS =
"taskana.jobs.cleanup.allCompletedSameParentBusiness";
private static final String TASKANA_DOMAINS_PROPERTY = "taskana.domains";
private static final String TASKANA_CLASSIFICATION_TYPES_PROPERTY =
"taskana.classification.types";
private static final String TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY =
"taskana.classification.categories";
// TASKANA_SCHEMA_VERSION
private static final String DEFAULT_SCHEMA_NAME = "TASKANA";
private static final String USER_NAME = "sa";
private static final String USER_PASSWORD = "sa";
private static final String JDBC_H2_MEM_TASKANA = "jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0";
private static final String H2_DRIVER = "org.h2.Driver";
private static final String TASKANA_PROPERTIES = "/taskana.properties";
private static final String TASKANA_ROLES_SEPARATOR = "|";
private static final String TASKANA_JOB_BATCHSIZE = "taskana.jobs.batchSize";
private static final String TASKANA_JOB_RETRIES = "taskana.jobs.maxRetries";
private static final String TASKANA_JOB_CLEANUP_RUN_EVERY = "taskana.jobs.cleanup.runEvery";
private static final String TASKANA_JOB_CLEANUP_FIRST_RUN = "taskana.jobs.cleanup.firstRunAt";
private static final String TASKANA_JOB_CLEANUP_MINIMUM_AGE = "taskana.jobs.cleanup.minimumAge";
private static final String TASKANA_JOB_TASK_CLEANUP_ALL_COMPLETED_SAME_PARENTE_BUSINESS = "taskana.jobs.cleanup.allCompletedSameParentBusiness";
// Taskana properties file
protected String propertiesFileName = TASKANA_PROPERTIES;
private static final String TASKANA_DOMAINS_PROPERTY = "taskana.domains";
private static final String TASKANA_CLASSIFICATION_TYPES_PROPERTY = "taskana.classification.types";
private static final String TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY = "taskana.classification.categories";
protected static final String TASKANA_SCHEMA_VERSION = "1.1.5"; // must match the VERSION value in table
// TASKANA_SCHEMA_VERSION
private static final String DEFAULT_SCHEMA_NAME = "TASKANA";
// Taskana datasource configuration
protected DataSource dataSource;
protected DbSchemaCreator dbSchemaCreator;
protected String schemaName;
// Taskana properties file
protected String propertiesFileName = TASKANA_PROPERTIES;
// Taskana role configuration
protected String rolesSeparator = TASKANA_ROLES_SEPARATOR;
protected Map<TaskanaRole, Set<String>> roleMap = new HashMap<>();
// Taskana datasource configuration
protected DataSource dataSource;
protected DbSchemaCreator dbSchemaCreator;
protected String schemaName;
// global switch to enable JAAS based authentication and Taskana
// authorizations
protected boolean securityEnabled = true;
protected boolean useManagedTransactions;
// List of configured domain names
protected List<String> domains = new ArrayList<String>();
// List of configured classification types
protected List<String> classificationTypes = new ArrayList<String>();
protected Map<String, List<String>> classificationCategoriesByTypeMap =
new HashMap<String, List<String>>();
// Properties for the monitor
private boolean germanPublicHolidaysEnabled;
private List<LocalDate> customHolidays;
// Properties for generalo job execution
private int jobBatchSize = 100;
private int maxNumberOfJobRetries = 3;
// Properties for the cleanup job
private Instant cleanupJobFirstRun = Instant.parse("2018-01-01T00:00:00Z");
private Duration cleanupJobRunEvery = Duration.parse("P1D");
private Duration cleanupJobMinimumAge = Duration.parse("P14D");
private boolean taskCleanupJobAllCompletedSameParentBusiness = true;
// Taskana role configuration
protected String rolesSeparator = TASKANA_ROLES_SEPARATOR;
protected Map<TaskanaRole, Set<String>> roleMap = new HashMap<>();
public TaskanaEngineConfiguration(
DataSource dataSource, boolean useManagedTransactions, String schemaName)
throws SQLException {
this(dataSource, useManagedTransactions, true, schemaName);
}
// global switch to enable JAAS based authentication and Taskana
// authorizations
protected boolean securityEnabled = true;
protected boolean useManagedTransactions;
public TaskanaEngineConfiguration(
DataSource dataSource,
boolean useManagedTransactions,
boolean securityEnabled,
String schemaName)
throws SQLException {
this(dataSource, useManagedTransactions, securityEnabled, null, null, schemaName);
}
// Properties for the monitor
private boolean germanPublicHolidaysEnabled;
private List<LocalDate> customHolidays;
public TaskanaEngineConfiguration(
DataSource dataSource,
boolean useManagedTransactions,
boolean securityEnabled,
String propertiesFileName,
String rolesSeparator,
String schemaName)
throws SQLException {
this.useManagedTransactions = useManagedTransactions;
this.securityEnabled = securityEnabled;
// Properties for generalo job execution
private int jobBatchSize = 100;
private int maxNumberOfJobRetries = 3;
// Properties for the cleanup job
private Instant cleanupJobFirstRun = Instant.parse("2018-01-01T00:00:00Z");
private Duration cleanupJobRunEvery = Duration.parse("P1D");
private Duration cleanupJobMinimumAge = Duration.parse("P14D");
private boolean taskCleanupJobAllCompletedSameParentBusiness = true;
// List of configured domain names
protected List<String> domains = new ArrayList<String>();
// List of configured classification types
protected List<String> classificationTypes = new ArrayList<String>();
protected Map<String, List<String>> classificationCategoriesByTypeMap = new HashMap<String, List<String>>();
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions, String schemaName)
throws SQLException {
this(dataSource, useManagedTransactions, true, schemaName);
if (propertiesFileName != null) {
this.propertiesFileName = propertiesFileName;
}
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions,
boolean securityEnabled, String schemaName) throws SQLException {
this(dataSource, useManagedTransactions, securityEnabled, null, null, schemaName);
if (rolesSeparator != null) {
this.rolesSeparator = rolesSeparator;
}
public TaskanaEngineConfiguration(DataSource dataSource, boolean useManagedTransactions,
boolean securityEnabled, String propertiesFileName, String rolesSeparator, String schemaName)
throws SQLException {
this.useManagedTransactions = useManagedTransactions;
this.securityEnabled = securityEnabled;
if (propertiesFileName != null) {
this.propertiesFileName = propertiesFileName;
}
if (rolesSeparator != null) {
this.rolesSeparator = rolesSeparator;
}
if (dataSource != null) {
this.dataSource = dataSource;
} else {
// use default In Memory datasource
this.dataSource = createDefaultDataSource();
}
initSchemaName(schemaName);
initTaskanaProperties(this.propertiesFileName, this.rolesSeparator);
dbSchemaCreator = new DbSchemaCreator(this.dataSource, this.getSchemaName());
dbSchemaCreator.run();
if (!dbSchemaCreator.isValidSchemaVersion(TASKANA_SCHEMA_VERSION)) {
throw new SystemException(
"The Database Schema Version doesn't match the expected version " + TASKANA_SCHEMA_VERSION);
}
if (dataSource != null) {
this.dataSource = dataSource;
} else {
// use default In Memory datasource
this.dataSource = createDefaultDataSource();
}
public void initTaskanaProperties(String propertiesFile, String rolesSeparator) {
LOGGER.debug("Reading taskana configuration from {} with role separator {}", propertiesFile, rolesSeparator);
Properties props = readPropertiesFromFile(propertiesFile);
initTaskanaRoles(props, rolesSeparator);
initJobParameters(props);
initDomains(props);
initClassificationTypes(props);
initClassificationCategories(props);
initSchemaName(schemaName);
initTaskanaProperties(this.propertiesFileName, this.rolesSeparator);
dbSchemaCreator = new DbSchemaCreator(this.dataSource, this.getSchemaName());
dbSchemaCreator.run();
if (!dbSchemaCreator.isValidSchemaVersion(TASKANA_SCHEMA_VERSION)) {
throw new SystemException(
"The Database Schema Version doesn't match the expected version "
+ TASKANA_SCHEMA_VERSION);
}
}
private void initJobParameters(Properties props) {
String jobBatchSizeProperty = props.getProperty(TASKANA_JOB_BATCHSIZE);
if (jobBatchSizeProperty != null && !jobBatchSizeProperty.isEmpty()) {
try {
jobBatchSize = Integer.parseInt(jobBatchSizeProperty);
} catch (Exception e) {
LOGGER.warn("Could not parse jobBatchSizeProperty ({}). Using default. Exception: {} ",
jobBatchSizeProperty, e.getMessage());
}
}
public void initTaskanaProperties(String propertiesFile, String rolesSeparator) {
LOGGER.debug(
"Reading taskana configuration from {} with role separator {}",
propertiesFile,
rolesSeparator);
Properties props = readPropertiesFromFile(propertiesFile);
initTaskanaRoles(props, rolesSeparator);
initJobParameters(props);
initDomains(props);
initClassificationTypes(props);
initClassificationCategories(props);
}
String maxNumberOfJobRetriesProperty = props.getProperty(TASKANA_JOB_RETRIES);
if (maxNumberOfJobRetriesProperty != null && !maxNumberOfJobRetriesProperty.isEmpty()) {
try {
maxNumberOfJobRetries = Integer.parseInt(maxNumberOfJobRetriesProperty);
} catch (Exception e) {
LOGGER.warn("Could not parse maxNumberOfJobRetriesProperty ({}). Using default. Exception: {} ",
maxNumberOfJobRetriesProperty, e.getMessage());
}
}
String taskCleanupJobFirstRunProperty = props.getProperty(TASKANA_JOB_CLEANUP_FIRST_RUN);
if (taskCleanupJobFirstRunProperty != null && !taskCleanupJobFirstRunProperty.isEmpty()) {
try {
cleanupJobFirstRun = Instant.parse(taskCleanupJobFirstRunProperty);
} catch (Exception e) {
LOGGER.warn("Could not parse taskCleanupJobFirstRunProperty ({}). Using default. Exception: {} ",
taskCleanupJobFirstRunProperty, e.getMessage());
}
}
String taskCleanupJobRunEveryProperty = props.getProperty(TASKANA_JOB_CLEANUP_RUN_EVERY);
if (taskCleanupJobRunEveryProperty != null && !taskCleanupJobRunEveryProperty.isEmpty()) {
try {
cleanupJobRunEvery = Duration.parse(taskCleanupJobRunEveryProperty);
} catch (Exception e) {
LOGGER.warn("Could not parse taskCleanupJobRunEveryProperty ({}). Using default. Exception: {} ",
taskCleanupJobRunEveryProperty, e.getMessage());
}
}
String taskCleanupJobMinimumAgeProperty = props.getProperty(TASKANA_JOB_CLEANUP_MINIMUM_AGE);
if (taskCleanupJobMinimumAgeProperty != null && !taskCleanupJobMinimumAgeProperty.isEmpty()) {
try {
cleanupJobMinimumAge = Duration.parse(taskCleanupJobMinimumAgeProperty);
} catch (Exception e) {
LOGGER.warn("Could not parse taskCleanupJobMinimumAgeProperty ({}). Using default. Exception: {} ",
taskCleanupJobMinimumAgeProperty, e.getMessage());
}
}
String taskCleanupJobAllCompletedSameParentBusinessProperty = props.getProperty(
TASKANA_JOB_TASK_CLEANUP_ALL_COMPLETED_SAME_PARENTE_BUSINESS);
if (taskCleanupJobAllCompletedSameParentBusinessProperty != null
&& !taskCleanupJobAllCompletedSameParentBusinessProperty.isEmpty()) {
try {
taskCleanupJobAllCompletedSameParentBusiness = Boolean.parseBoolean(
taskCleanupJobAllCompletedSameParentBusinessProperty);
} catch (Exception e) {
LOGGER.warn(
"Could not parse taskCleanupJobAllCompletedSameParentBusinessProperty ({}). Using default. Exception: {} ",
taskCleanupJobAllCompletedSameParentBusinessProperty, e.getMessage());
}
}
LOGGER.debug("Configured number of task and workbasket updates per transaction: {}", jobBatchSize);
LOGGER.debug("Number of retries of failed task updates: {}", maxNumberOfJobRetries);
LOGGER.debug("CleanupJob configuration: first run at {}", cleanupJobFirstRun);
LOGGER.debug("CleanupJob configuration: runs every {}", cleanupJobRunEvery);
LOGGER.debug("CleanupJob configuration: minimum age of tasks to be cleanup up is {}",
cleanupJobMinimumAge);
LOGGER.debug("TaskCleanupJob configuration: all completed task with the same parent business property id {}",
taskCleanupJobAllCompletedSameParentBusiness);
}
private void initDomains(Properties props) {
String domainNames = props.getProperty(TASKANA_DOMAINS_PROPERTY);
if (domainNames != null && !domainNames.isEmpty()) {
StringTokenizer st = new StringTokenizer(domainNames, ",");
while (st.hasMoreTokens()) {
domains.add(st.nextToken().trim().toUpperCase());
}
}
LOGGER.debug("Configured domains: {}", domains);
}
private void initClassificationTypes(Properties props) {
String classificationTypesNames = props.getProperty(TASKANA_CLASSIFICATION_TYPES_PROPERTY);
if (classificationTypesNames != null && !classificationTypesNames.isEmpty()) {
StringTokenizer st = new StringTokenizer(classificationTypesNames, ",");
while (st.hasMoreTokens()) {
classificationTypes.add(st.nextToken().trim().toUpperCase());
}
} else {
LOGGER.warn("Configuration issue. Classification type is missing");
}
LOGGER.debug("Configured classificationTypes: {}", classificationTypes);
}
private void initClassificationCategories(Properties props) {
if (classificationTypes != null && !classificationTypes.isEmpty()) {
String classificationCategoryNames;
StringTokenizer st;
List<String> classificationCategoriesAux;
for (String type : classificationTypes) {
classificationCategoriesAux = new ArrayList<>();
classificationCategoryNames = props.getProperty(
TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY + "." + type.toLowerCase());
if (classificationCategoryNames != null && !classificationCategoryNames.isEmpty()) {
st = new StringTokenizer(classificationCategoryNames, ",");
while (st.hasMoreTokens()) {
classificationCategoriesAux.add(st.nextToken().trim().toUpperCase());
}
classificationCategoriesByTypeMap.put(type, classificationCategoriesAux);
} else {
LOGGER.warn("Configuration issue. Classification categories by type is missing");
}
}
}
LOGGER.debug("Configured classification categories : {}", domains);
}
private void initSchemaName(String schemaName) {
if (schemaName != null && !schemaName.isEmpty()) {
this.setSchemaName(schemaName);
} else {
this.setSchemaName(DEFAULT_SCHEMA_NAME);
}
try (Connection connection = dataSource.getConnection()) {
String databaseProductName = connection.getMetaData().getDatabaseProductName();
if (DB.isPostgreSQL(databaseProductName)) {
this.schemaName = this.schemaName.toLowerCase();
} else {
this.schemaName = this.schemaName.toUpperCase();
}
} catch (SQLException ex) {
LOGGER.error("Caught {} when attempting to initialize the schema name", ex);
}
LOGGER.debug("Using schema name {}", this.getSchemaName());
}
private void initTaskanaRoles(Properties props, String rolesSeparator) {
List<String> validPropertyNames = TaskanaRole.getValidPropertyNames();
props.keySet()
.stream()
.map(String::valueOf)
.filter(propertyName -> validPropertyNames.contains(propertyName.toLowerCase().trim()))
.forEach(validPropertyName -> roleMap.put(TaskanaRole.fromPropertyName(validPropertyName),
getTokensWithCollection(props.getProperty(validPropertyName), rolesSeparator)));
ensureRoleMapIsFullyInitialized();
if (LOGGER.isDebugEnabled()) {
roleMap.forEach(
(k, v) -> LOGGER.debug("Found Taskana RoleConfig {} : {} ", k, LoggerUtils.setToString(v)));
}
}
private HashSet<String> getTokensWithCollection(String str, String rolesSeparator) {
return Collections.list(new StringTokenizer(str, rolesSeparator)).stream()
.map(token -> String.valueOf(token).toLowerCase().trim())
.collect(Collectors.toCollection(HashSet::new));
}
private Properties readPropertiesFromFile(String propertiesFile) {
Properties props = new Properties();
boolean loadFromClasspath = loadFromClasspath(propertiesFile);
try {
if (loadFromClasspath) {
InputStream inputStream = this.getClass().getResourceAsStream(propertiesFile);
if (inputStream == null) {
LOGGER.error("taskana properties file {} was not found on classpath.",
propertiesFile);
} else {
props.load(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
LOGGER.debug("Role properties were loaded from file {} from classpath.", propertiesFile);
}
} else {
props.load(new FileInputStream(propertiesFile));
LOGGER.debug("Role properties were loaded from file {}.", propertiesFile);
}
} catch (IOException e) {
LOGGER.error("caught IOException when processing properties file {}.", propertiesFile);
throw new SystemException("internal System error when processing properties file " + propertiesFile,
e.getCause());
}
return props;
}
private boolean loadFromClasspath(String propertiesFile) {
boolean loadFromClasspath = true;
File f = new File(propertiesFile);
if (f.exists() && !f.isDirectory()) {
loadFromClasspath = false;
}
return loadFromClasspath;
}
private void ensureRoleMapIsFullyInitialized() {
// make sure that roleMap does not return null for any role
Arrays.stream(TaskanaRole.values())
.forEach(role -> roleMap.putIfAbsent(role, new HashSet<>()));
}
public static DataSource createDefaultDataSource() {
LOGGER.info("No datasource is provided. A inmemory db is used: "
public static DataSource createDefaultDataSource() {
LOGGER.info(
"No datasource is provided. A inmemory db is used: "
+ "'org.h2.Driver', 'jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0', '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.
*
* @return the TaskanaEngine
*/
public TaskanaEngine buildTaskanaEngine() {
return TaskanaEngineImpl.createTaskanaEngine(this);
}
/**
* This method creates a PooledDataSource, if the needed properties are provided.
*
* @param driver the name of the jdbc driver
* @param jdbcUrl the url to which the jdbc driver connects
* @param username the user name for database access
* @param password the password for database access
* @return DataSource
*/
public static DataSource createDatasource(
String driver, String jdbcUrl, String username, String password) {
return new PooledDataSource(driver, jdbcUrl, username, password);
}
public boolean isSecurityEnabled() {
return this.securityEnabled;
}
public DataSource getDatasource() {
return this.dataSource;
}
public boolean getUseManagedTransactions() {
return this.useManagedTransactions;
}
public String getPropertiesFileName() {
return this.propertiesFileName;
}
public void setPropertiesFileName(String propertiesFileName) {
this.propertiesFileName = propertiesFileName;
}
public int getMaxNumberOfUpdatesPerTransaction() {
return jobBatchSize;
}
public int getMaxNumberOfJobRetries() {
return maxNumberOfJobRetries;
}
public String getPropertiesSeparator() {
return this.rolesSeparator;
}
public void setPropertiesSeparator(String propertiesSeparator) {
this.rolesSeparator = propertiesSeparator;
}
public boolean isGermanPublicHolidaysEnabled() {
return this.germanPublicHolidaysEnabled;
}
public void setGermanPublicHolidaysEnabled(boolean germanPublicHolidaysEnabled) {
this.germanPublicHolidaysEnabled = germanPublicHolidaysEnabled;
}
public List<LocalDate> getCustomHolidays() {
return customHolidays;
}
public void setCustomHolidays(List<LocalDate> customHolidays) {
this.customHolidays = customHolidays;
}
public Map<TaskanaRole, Set<String>> getRoleMap() {
return roleMap;
}
public void setRoleMap(Map<TaskanaRole, Set<String>> roleMap) {
this.roleMap = roleMap;
}
public List<String> getDomains() {
return domains;
}
public void setDomains(List<String> domains) {
this.domains = domains;
}
public List<String> getClassificationTypes() {
return classificationTypes;
}
public void setClassificationTypes(List<String> classificationTypes) {
this.classificationTypes = classificationTypes;
}
public List<String> getAllClassificationCategories() {
List<String> classificationCategories = new ArrayList<>();
for (Map.Entry<String, List<String>> type : this.classificationCategoriesByTypeMap.entrySet()) {
classificationCategories.addAll(type.getValue());
}
return classificationCategories;
}
public List<String> getClassificationCategoriesByType(String type) {
return classificationCategoriesByTypeMap.get(type);
}
public void setClassificationCategoriesByType(
Map<String, List<String>> classificationCategoriesByType) {
this.classificationCategoriesByTypeMap = classificationCategoriesByType;
}
public Instant getCleanupJobFirstRun() {
return cleanupJobFirstRun;
}
public Duration getCleanupJobRunEvery() {
return cleanupJobRunEvery;
}
public Duration getCleanupJobMinimumAge() {
return cleanupJobMinimumAge;
}
public boolean isTaskCleanupJobAllCompletedSameParentBusiness() {
return taskCleanupJobAllCompletedSameParentBusiness;
}
public void setTaskCleanupJobAllCompletedSameParentBusiness(
boolean taskCleanupJobAllCompletedSameParentBusiness) {
this.taskCleanupJobAllCompletedSameParentBusiness =
taskCleanupJobAllCompletedSameParentBusiness;
}
public String getSchemaName() {
return schemaName;
}
public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
/**
* 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
*/
public static boolean shouldUseLowerCaseForAccessIds() {
return true;
}
private void initJobParameters(Properties props) {
String jobBatchSizeProperty = props.getProperty(TASKANA_JOB_BATCHSIZE);
if (jobBatchSizeProperty != null && !jobBatchSizeProperty.isEmpty()) {
try {
jobBatchSize = Integer.parseInt(jobBatchSizeProperty);
} catch (Exception e) {
LOGGER.warn(
"Could not parse jobBatchSizeProperty ({}). Using default. Exception: {} ",
jobBatchSizeProperty,
e.getMessage());
}
}
/**
* This method creates the TaskanaEngine without an sqlSessionFactory.
*
* @return the TaskanaEngine
*/
public TaskanaEngine buildTaskanaEngine() {
return TaskanaEngineImpl.createTaskanaEngine(this);
String maxNumberOfJobRetriesProperty = props.getProperty(TASKANA_JOB_RETRIES);
if (maxNumberOfJobRetriesProperty != null && !maxNumberOfJobRetriesProperty.isEmpty()) {
try {
maxNumberOfJobRetries = Integer.parseInt(maxNumberOfJobRetriesProperty);
} catch (Exception e) {
LOGGER.warn(
"Could not parse maxNumberOfJobRetriesProperty ({}). Using default. Exception: {} ",
maxNumberOfJobRetriesProperty,
e.getMessage());
}
}
/**
* This method creates a PooledDataSource, if the needed properties are provided.
*
* @param driver
* the name of the jdbc driver
* @param jdbcUrl
* the url to which the jdbc driver connects
* @param username
* the user name for database access
* @param password
* the password for database access
* @return DataSource
*/
public static DataSource createDatasource(String driver, String jdbcUrl, String username, String password) {
return new PooledDataSource(driver, jdbcUrl, username, password);
String taskCleanupJobFirstRunProperty = props.getProperty(TASKANA_JOB_CLEANUP_FIRST_RUN);
if (taskCleanupJobFirstRunProperty != null && !taskCleanupJobFirstRunProperty.isEmpty()) {
try {
cleanupJobFirstRun = Instant.parse(taskCleanupJobFirstRunProperty);
} catch (Exception e) {
LOGGER.warn(
"Could not parse taskCleanupJobFirstRunProperty ({}). Using default. Exception: {} ",
taskCleanupJobFirstRunProperty,
e.getMessage());
}
}
public boolean isSecurityEnabled() {
return this.securityEnabled;
String taskCleanupJobRunEveryProperty = props.getProperty(TASKANA_JOB_CLEANUP_RUN_EVERY);
if (taskCleanupJobRunEveryProperty != null && !taskCleanupJobRunEveryProperty.isEmpty()) {
try {
cleanupJobRunEvery = Duration.parse(taskCleanupJobRunEveryProperty);
} catch (Exception e) {
LOGGER.warn(
"Could not parse taskCleanupJobRunEveryProperty ({}). Using default. Exception: {} ",
taskCleanupJobRunEveryProperty,
e.getMessage());
}
}
public DataSource getDatasource() {
return this.dataSource;
String taskCleanupJobMinimumAgeProperty = props.getProperty(TASKANA_JOB_CLEANUP_MINIMUM_AGE);
if (taskCleanupJobMinimumAgeProperty != null && !taskCleanupJobMinimumAgeProperty.isEmpty()) {
try {
cleanupJobMinimumAge = Duration.parse(taskCleanupJobMinimumAgeProperty);
} catch (Exception e) {
LOGGER.warn(
"Could not parse taskCleanupJobMinimumAgeProperty ({}). Using default. Exception: {} ",
taskCleanupJobMinimumAgeProperty,
e.getMessage());
}
}
public boolean getUseManagedTransactions() {
return this.useManagedTransactions;
String taskCleanupJobAllCompletedSameParentBusinessProperty =
props.getProperty(TASKANA_JOB_TASK_CLEANUP_ALL_COMPLETED_SAME_PARENTE_BUSINESS);
if (taskCleanupJobAllCompletedSameParentBusinessProperty != null
&& !taskCleanupJobAllCompletedSameParentBusinessProperty.isEmpty()) {
try {
taskCleanupJobAllCompletedSameParentBusiness =
Boolean.parseBoolean(taskCleanupJobAllCompletedSameParentBusinessProperty);
} catch (Exception e) {
LOGGER.warn(
"Could not parse taskCleanupJobAllCompletedSameParentBusinessProperty ({}). Using default. Exception: {} ",
taskCleanupJobAllCompletedSameParentBusinessProperty,
e.getMessage());
}
}
public String getPropertiesFileName() {
return this.propertiesFileName;
}
LOGGER.debug(
"Configured number of task and workbasket updates per transaction: {}", jobBatchSize);
LOGGER.debug("Number of retries of failed task updates: {}", maxNumberOfJobRetries);
LOGGER.debug("CleanupJob configuration: first run at {}", cleanupJobFirstRun);
LOGGER.debug("CleanupJob configuration: runs every {}", cleanupJobRunEvery);
LOGGER.debug(
"CleanupJob configuration: minimum age of tasks to be cleanup up is {}",
cleanupJobMinimumAge);
LOGGER.debug(
"TaskCleanupJob configuration: all completed task with the same parent business property id {}",
taskCleanupJobAllCompletedSameParentBusiness);
}
public int getMaxNumberOfUpdatesPerTransaction() {
return jobBatchSize;
private void initDomains(Properties props) {
String domainNames = props.getProperty(TASKANA_DOMAINS_PROPERTY);
if (domainNames != null && !domainNames.isEmpty()) {
StringTokenizer st = new StringTokenizer(domainNames, ",");
while (st.hasMoreTokens()) {
domains.add(st.nextToken().trim().toUpperCase());
}
}
LOGGER.debug("Configured domains: {}", domains);
}
public int getMaxNumberOfJobRetries() {
return maxNumberOfJobRetries;
private void initClassificationTypes(Properties props) {
String classificationTypesNames = props.getProperty(TASKANA_CLASSIFICATION_TYPES_PROPERTY);
if (classificationTypesNames != null && !classificationTypesNames.isEmpty()) {
StringTokenizer st = new StringTokenizer(classificationTypesNames, ",");
while (st.hasMoreTokens()) {
classificationTypes.add(st.nextToken().trim().toUpperCase());
}
} else {
LOGGER.warn("Configuration issue. Classification type is missing");
}
LOGGER.debug("Configured classificationTypes: {}", classificationTypes);
}
public void setPropertiesFileName(String propertiesFileName) {
this.propertiesFileName = propertiesFileName;
}
public String getPropertiesSeparator() {
return this.rolesSeparator;
}
public void setPropertiesSeparator(String propertiesSeparator) {
this.rolesSeparator = propertiesSeparator;
}
public boolean isGermanPublicHolidaysEnabled() {
return this.germanPublicHolidaysEnabled;
}
public void setGermanPublicHolidaysEnabled(boolean germanPublicHolidaysEnabled) {
this.germanPublicHolidaysEnabled = germanPublicHolidaysEnabled;
}
public List<LocalDate> getCustomHolidays() {
return customHolidays;
}
public void setCustomHolidays(List<LocalDate> customHolidays) {
this.customHolidays = customHolidays;
}
public Map<TaskanaRole, Set<String>> getRoleMap() {
return roleMap;
}
public void setRoleMap(Map<TaskanaRole, Set<String>> roleMap) {
this.roleMap = roleMap;
}
public List<String> getDomains() {
return domains;
}
public void setDomains(List<String> domains) {
this.domains = domains;
}
public List<String> getClassificationTypes() {
return classificationTypes;
}
public void setClassificationTypes(List<String> classificationTypes) {
this.classificationTypes = classificationTypes;
}
public List<String> getAllClassificationCategories() {
List<String> classificationCategories = new ArrayList<>();
for (Map.Entry<String, List<String>> type : this.classificationCategoriesByTypeMap.entrySet()) {
classificationCategories.addAll(type.getValue());
private void initClassificationCategories(Properties props) {
if (classificationTypes != null && !classificationTypes.isEmpty()) {
String classificationCategoryNames;
StringTokenizer st;
List<String> classificationCategoriesAux;
for (String type : classificationTypes) {
classificationCategoriesAux = new ArrayList<>();
classificationCategoryNames =
props.getProperty(
TASKANA_CLASSIFICATION_CATEGORIES_PROPERTY + "." + type.toLowerCase());
if (classificationCategoryNames != null && !classificationCategoryNames.isEmpty()) {
st = new StringTokenizer(classificationCategoryNames, ",");
while (st.hasMoreTokens()) {
classificationCategoriesAux.add(st.nextToken().trim().toUpperCase());
}
classificationCategoriesByTypeMap.put(type, classificationCategoriesAux);
} else {
LOGGER.warn("Configuration issue. Classification categories by type is missing");
}
return classificationCategories;
}
}
LOGGER.debug("Configured classification categories : {}", domains);
}
private void initSchemaName(String schemaName) {
if (schemaName != null && !schemaName.isEmpty()) {
this.setSchemaName(schemaName);
} else {
this.setSchemaName(DEFAULT_SCHEMA_NAME);
}
public List<String> getClassificationCategoriesByType(String type) {
return classificationCategoriesByTypeMap.get(type);
try (Connection connection = dataSource.getConnection()) {
String databaseProductName = connection.getMetaData().getDatabaseProductName();
if (DB.isPostgreSQL(databaseProductName)) {
this.schemaName = this.schemaName.toLowerCase();
} else {
this.schemaName = this.schemaName.toUpperCase();
}
} catch (SQLException ex) {
LOGGER.error("Caught {} when attempting to initialize the schema name", ex);
}
public void setClassificationCategoriesByType(Map<String, List<String>> classificationCategoriesByType) {
this.classificationCategoriesByTypeMap = classificationCategoriesByType;
}
LOGGER.debug("Using schema name {}", this.getSchemaName());
}
public Instant getCleanupJobFirstRun() {
return cleanupJobFirstRun;
}
private void initTaskanaRoles(Properties props, String rolesSeparator) {
List<String> validPropertyNames = TaskanaRole.getValidPropertyNames();
public Duration getCleanupJobRunEvery() {
return cleanupJobRunEvery;
}
props.keySet().stream()
.map(String::valueOf)
.filter(propertyName -> validPropertyNames.contains(propertyName.toLowerCase().trim()))
.forEach(
validPropertyName ->
roleMap.put(
TaskanaRole.fromPropertyName(validPropertyName),
getTokensWithCollection(props.getProperty(validPropertyName), rolesSeparator)));
public Duration getCleanupJobMinimumAge() {
return cleanupJobMinimumAge;
}
ensureRoleMapIsFullyInitialized();
public void setTaskCleanupJobAllCompletedSameParentBusiness(boolean taskCleanupJobAllCompletedSameParentBusiness) {
this.taskCleanupJobAllCompletedSameParentBusiness = taskCleanupJobAllCompletedSameParentBusiness;
if (LOGGER.isDebugEnabled()) {
roleMap.forEach(
(k, v) ->
LOGGER.debug("Found Taskana RoleConfig {} : {} ", k, LoggerUtils.setToString(v)));
}
}
public boolean isTaskCleanupJobAllCompletedSameParentBusiness() {
return taskCleanupJobAllCompletedSameParentBusiness;
private HashSet<String> getTokensWithCollection(String str, String rolesSeparator) {
return Collections.list(new StringTokenizer(str, rolesSeparator)).stream()
.map(token -> String.valueOf(token).toLowerCase().trim())
.collect(Collectors.toCollection(HashSet::new));
}
private Properties readPropertiesFromFile(String propertiesFile) {
Properties props = new Properties();
boolean loadFromClasspath = loadFromClasspath(propertiesFile);
try {
if (loadFromClasspath) {
InputStream inputStream = this.getClass().getResourceAsStream(propertiesFile);
if (inputStream == null) {
LOGGER.error("taskana properties file {} was not found on classpath.", propertiesFile);
} else {
props.load(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
LOGGER.debug("Role properties were loaded from file {} from classpath.", propertiesFile);
}
} else {
props.load(new FileInputStream(propertiesFile));
LOGGER.debug("Role properties were loaded from file {}.", propertiesFile);
}
} catch (IOException e) {
LOGGER.error("caught IOException when processing properties file {}.", propertiesFile);
throw new SystemException(
"internal System error when processing properties file " + propertiesFile, e.getCause());
}
return props;
}
public String getSchemaName() {
return schemaName;
}
public void setSchemaName(String schemaName) {
this.schemaName = schemaName;
}
/**
* 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
*/
public static boolean shouldUseLowerCaseForAccessIds() {
return true;
private boolean loadFromClasspath(String propertiesFile) {
boolean loadFromClasspath = true;
File f = new File(propertiesFile);
if (f.exists() && !f.isDirectory()) {
loadFromClasspath = false;
}
return loadFromClasspath;
}
private void ensureRoleMapIsFullyInitialized() {
// make sure that roleMap does not return null for any role
Arrays.stream(TaskanaRole.values()).forEach(role -> roleMap.putIfAbsent(role, new HashSet<>()));
}
}

View File

@ -2,14 +2,14 @@ package pro.taskana.exceptions;
/**
* Thrown, when an attachment should be inserted to the DB, but it does already exist.<br>
* This may happen when a not persisted attachment with ID will be added twice on a task. This can´t be happen it the
* correct Task-Methods will be used instead the List ones.
* This may happen when a not persisted attachment with ID will be added twice on a task. This can´t
* be happen it the correct Task-Methods will be used instead the List ones.
*/
public class AttachmentPersistenceException extends TaskanaException {
private static final long serialVersionUID = 123L;
private static final long serialVersionUID = 123L;
public AttachmentPersistenceException(String msg, Throwable cause) {
super(msg, cause);
}
public AttachmentPersistenceException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@ -1,12 +1,10 @@
package pro.taskana.exceptions;
/**
* Thrown in ConnectionManagementMode AUTOCOMMIT when an attempt to commit fails.
*
*/
/** Thrown in ConnectionManagementMode AUTOCOMMIT when an attempt to commit fails. */
public class AutocommitFailedException extends TaskanaRuntimeException {
public AutocommitFailedException(Throwable cause) {
super("Autocommit failed", cause);
}
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public AutocommitFailedException(Throwable cause) {
super("Autocommit failed", cause);
}
}

View File

@ -2,15 +2,19 @@ package pro.taskana.exceptions;
import pro.taskana.Classification;
/**
* Thrown, when a classification does already exits, but wanted to create with same ID+domain.
*/
/** Thrown, when a classification does already exits, but wanted to create with same ID+domain. */
public class ClassificationAlreadyExistException extends TaskanaException {
private static final long serialVersionUID = 4716611657569005013L;
private static final long serialVersionUID = 4716611657569005013L;
public ClassificationAlreadyExistException(Classification classification) {
super("ID='" + classification.getId() + "', KEY='" + classification.getKey() + "', DOMAIN='"
+ classification.getDomain() + "';");
}
public ClassificationAlreadyExistException(Classification classification) {
super(
"ID='"
+ classification.getId()
+ "', KEY='"
+ classification.getKey()
+ "', DOMAIN='"
+ classification.getDomain()
+ "';");
}
}

View File

@ -1,17 +1,15 @@
package pro.taskana.exceptions;
/**
* Thrown if a specific task is not in the database.
*/
/** Thrown if a specific task is not in the database. */
public class ClassificationInUseException extends TaskanaException {
public ClassificationInUseException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
public ClassificationInUseException(String msg, Throwable cause) {
super(msg, cause);
}
public ClassificationInUseException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
public ClassificationInUseException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@ -1,30 +1,27 @@
package pro.taskana.exceptions;
/**
* Thrown if a specific task is not in the database.
*/
/** Thrown if a specific task is not in the database. */
public class ClassificationNotFoundException extends NotFoundException {
private String key;
private String domain;
private static final long serialVersionUID = 1L;
private String key;
private String domain;
public ClassificationNotFoundException(String id, String msg) {
super(id, msg);
}
public ClassificationNotFoundException(String id, String msg) {
super(id, msg);
}
public ClassificationNotFoundException(String key, String domain, String msg) {
super(null, msg);
this.key = key;
this.domain = domain;
}
public ClassificationNotFoundException(String key, String domain, String msg) {
super(null, msg);
this.key = key;
this.domain = domain;
}
public String getKey() {
return key;
}
public String getKey() {
return key;
}
public String getDomain() {
return domain;
}
private static final long serialVersionUID = 1L;
public String getDomain() {
return domain;
}
}

View File

@ -1,15 +1,16 @@
package pro.taskana.exceptions;
/**
* This exception is thrown when an attempt is made to update an object that has already been updated by another user.
* This exception is thrown when an attempt is made to update an object that has already been
* updated by another user.
*
* @author bbr
*/
public class ConcurrencyException extends TaskanaException {
public ConcurrencyException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public ConcurrencyException(String msg) {
super(msg);
}
}

View File

@ -1,14 +1,14 @@
package pro.taskana.exceptions;
/**
* Thrown if ConnectionManagementMode is CONNECTION_MANAGED_EXTERNALLY and an attempt is made to call an API method before the setConnection() method has been called.
*
* Thrown if ConnectionManagementMode is CONNECTION_MANAGED_EXTERNALLY and an attempt is made to
* call an API method before the setConnection() method has been called.
*/
public class ConnectionNotSetException extends TaskanaRuntimeException {
public ConnectionNotSetException() {
super("Connection not set");
}
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public ConnectionNotSetException() {
super("Connection not set");
}
}

View File

@ -5,10 +5,9 @@ package pro.taskana.exceptions;
*/
public class DomainNotFoundException extends NotFoundException {
public DomainNotFoundException(String domain, String msg) {
super(domain, msg);
}
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public DomainNotFoundException(String domain, String msg) {
super(domain, msg);
}
}

View File

@ -7,13 +7,13 @@ package pro.taskana.exceptions;
*/
public class InvalidArgumentException extends TaskanaException {
public InvalidArgumentException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
public InvalidArgumentException(String msg, Throwable cause) {
super(msg, cause);
}
public InvalidArgumentException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
public InvalidArgumentException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@ -2,13 +2,13 @@ package pro.taskana.exceptions;
/**
* This exception is thrown when the task state doesn't allow the requested operation.
* @author bbr
*
* @author bbr
*/
public class InvalidOwnerException extends TaskanaException {
public InvalidOwnerException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public InvalidOwnerException(String msg) {
super(msg);
}
}

View File

@ -2,13 +2,13 @@ package pro.taskana.exceptions;
/**
* This exception is thrown when the task state doesn't allow the requested operation.
* @author bbr
*
* @author bbr
*/
public class InvalidStateException extends TaskanaException {
public InvalidStateException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public InvalidStateException(String msg) {
super(msg);
}
}

View File

@ -1,16 +1,16 @@
package pro.taskana.exceptions;
/**
* This exception is thrown when a request is made to insert or update a workbasket that is missing a required property.
* This exception is thrown when a request is made to insert or update a workbasket that is missing
* a required property.
*
* @author bbr
*/
public class InvalidWorkbasketException extends TaskanaException {
public InvalidWorkbasketException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public InvalidWorkbasketException(String msg) {
super(msg);
}
}

View File

@ -1,20 +1,17 @@
package pro.taskana.exceptions;
/**
* This exception is used to communicate a not authorized user.
*/
/** This exception is used to communicate a not authorized user. */
public class NotAuthorizedException extends TaskanaException {
private final String currentUserId;
private static final long serialVersionUID = 21235L;
private final String currentUserId;
public NotAuthorizedException(String msg, String currentUserId) {
super(msg + " - [CURRENT USER: {'" + currentUserId + "'}]");
this.currentUserId = currentUserId;
}
public NotAuthorizedException(String msg, String currentUserId) {
super(msg + " - [CURRENT USER: {'" + currentUserId + "'}]");
this.currentUserId = currentUserId;
}
public String getCurrentUserId() {
return currentUserId;
}
private static final long serialVersionUID = 21235L;
public String getCurrentUserId() {
return currentUserId;
}
}

View File

@ -1,18 +1,15 @@
package pro.taskana.exceptions;
/**
* This exception is used to communicate that a user is not authorized to query a Workbasket.
*/
/** This exception is used to communicate that a user is not authorized to query a Workbasket. */
public class NotAuthorizedToQueryWorkbasketException extends TaskanaRuntimeException {
public NotAuthorizedToQueryWorkbasketException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
public NotAuthorizedToQueryWorkbasketException(String msg, Throwable cause) {
super(msg, cause);
}
private static final long serialVersionUID = 1L;
public NotAuthorizedToQueryWorkbasketException(String msg) {
super(msg);
}
public NotAuthorizedToQueryWorkbasketException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@ -1,20 +1,17 @@
package pro.taskana.exceptions;
/**
* This exception will be thrown if a specific object is not in the database.
*/
/** This exception will be thrown if a specific object is not in the database. */
public class NotFoundException extends TaskanaException {
String id;
private static final long serialVersionUID = 1L;
String id;
public NotFoundException(String id, String message) {
super(message);
this.id = id;
}
public NotFoundException(String id, String message) {
super(message);
this.id = id;
}
public String getId() {
return id;
}
private static final long serialVersionUID = 1L;
public String getId() {
return id;
}
}

View File

@ -1,17 +1,15 @@
package pro.taskana.exceptions;
/**
* This exception is thrown when a generic taskana problem is encountered.
*/
/** This exception is thrown when a generic taskana problem is encountered. */
public class SystemException extends TaskanaRuntimeException {
public SystemException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
public SystemException(String msg, Throwable cause) {
super(msg, cause);
}
public SystemException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1L;
public SystemException(String msg, Throwable cause) {
super(msg, cause);
}
}

View File

@ -1,14 +1,14 @@
package pro.taskana.exceptions;
/**
* Thrown when a Task is going to be created, but a Task with the same ID does already exist. The Task ID should be
* unique.
* Thrown when a Task is going to be created, but a Task with the same ID does already exist. The
* Task ID should be unique.
*/
public class TaskAlreadyExistException extends TaskanaException {
public TaskAlreadyExistException(String id) {
super(id);
}
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public TaskAlreadyExistException(String id) {
super(id);
}
}

View File

@ -1,13 +1,11 @@
package pro.taskana.exceptions;
/**
* This exception will be thrown if a specific task is not in the database.
*/
/** This exception will be thrown if a specific task is not in the database. */
public class TaskNotFoundException extends NotFoundException {
public TaskNotFoundException(String id, String msg) {
super(id, msg);
}
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public TaskNotFoundException(String id, String msg) {
super(id, msg);
}
}

View File

@ -7,25 +7,26 @@ package pro.taskana.exceptions;
*/
public class TaskanaException extends Exception {
private static final long serialVersionUID = 123234345123412L;
private static final long serialVersionUID = 123234345123412L;
public TaskanaException() {
super();
}
public TaskanaException() {
super();
}
public TaskanaException(String message) {
super(message);
}
public TaskanaException(String message) {
super(message);
}
public TaskanaException(Throwable cause) {
super(cause);
}
public TaskanaException(Throwable cause) {
super(cause);
}
public TaskanaException(String message, Throwable cause) {
super(message, cause);
}
public TaskanaException(String message, Throwable cause) {
super(message, cause);
}
public TaskanaException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public TaskanaException(
String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -7,26 +7,26 @@ package pro.taskana.exceptions;
*/
public class TaskanaRuntimeException extends RuntimeException {
private static final long serialVersionUID = 1511142769801824L;
private static final long serialVersionUID = 1511142769801824L;
public TaskanaRuntimeException() {
super();
}
public TaskanaRuntimeException() {
super();
}
public TaskanaRuntimeException(String message) {
super(message);
}
public TaskanaRuntimeException(String message) {
super(message);
}
public TaskanaRuntimeException(Throwable cause) {
super(cause);
}
public TaskanaRuntimeException(Throwable cause) {
super(cause);
}
public TaskanaRuntimeException(String message, Throwable cause) {
super(message, cause);
}
public TaskanaRuntimeException(String message, Throwable cause) {
super(message, cause);
}
public TaskanaRuntimeException(String message, Throwable cause, boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public TaskanaRuntimeException(
String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -5,9 +5,9 @@ package pro.taskana.exceptions;
*/
public class UnsupportedDatabaseException extends RuntimeException {
public UnsupportedDatabaseException(String name) {
super("Database with '" + name + "' not found");
}
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
public UnsupportedDatabaseException(String name) {
super("Database with '" + name + "' not found");
}
}

View File

@ -2,15 +2,19 @@ package pro.taskana.exceptions;
import pro.taskana.Workbasket;
/**
* Thrown, when a workbasket does already exits, but wanted to create with same ID.
*/
/** Thrown, when a workbasket does already exits, but wanted to create with same ID. */
public class WorkbasketAlreadyExistException extends TaskanaException {
private static final long serialVersionUID = 6115013L;
private static final long serialVersionUID = 6115013L;
public WorkbasketAlreadyExistException(Workbasket workbasket) {
super("ID='" + workbasket.getId() + "', KEY=' " + workbasket.getKey() + "', DOMAIN='"
+ workbasket.getDomain() + "';");
}
public WorkbasketAlreadyExistException(Workbasket workbasket) {
super(
"ID='"
+ workbasket.getId()
+ "', KEY=' "
+ workbasket.getKey()
+ "', DOMAIN='"
+ workbasket.getDomain()
+ "';");
}
}

View File

@ -1,13 +1,11 @@
package pro.taskana.exceptions;
/**
* Thrown if a specific Workbasket does have content and should be deleted.
*/
/** Thrown if a specific Workbasket does have content and should be deleted. */
public class WorkbasketInUseException extends TaskanaException {
public WorkbasketInUseException(String msg) {
super(msg);
}
private static final long serialVersionUID = 1234L;
private static final long serialVersionUID = 1234L;
public WorkbasketInUseException(String msg) {
super(msg);
}
}

View File

@ -1,30 +1,27 @@
package pro.taskana.exceptions;
/**
* This exception will be thrown if a specific workbasket is not in the database.
*/
/** This exception will be thrown if a specific workbasket is not in the database. */
public class WorkbasketNotFoundException extends NotFoundException {
private String key;
private String domain;
private static final long serialVersionUID = 1L;
private String key;
private String domain;
public WorkbasketNotFoundException(String id, String msg) {
super(id, msg);
}
public WorkbasketNotFoundException(String id, String msg) {
super(id, msg);
}
public WorkbasketNotFoundException(String key, String domain, String msg) {
super(null, msg);
this.key = key;
this.domain = domain;
}
public WorkbasketNotFoundException(String key, String domain, String msg) {
super(null, msg);
this.key = key;
this.domain = domain;
}
public String getKey() {
return key;
}
public String getKey() {
return key;
}
public String getDomain() {
return domain;
}
private static final long serialVersionUID = 1L;
public String getDomain() {
return domain;
}
}

Some files were not shown because too many files have changed in this diff Show More