提交 3e28c07e 编写于 作者: J Joram Barrez

ACT-1840: Allow to set a 'category' on tasks

上级 c8c5e52d
......@@ -154,6 +154,7 @@ public interface BpmnXMLConstants {
public static final String ATTRIBUTE_TASK_USER_CANDIDATEUSERS = "candidateUsers";
public static final String ATTRIBUTE_TASK_USER_CANDIDATEGROUPS = "candidateGroups";
public static final String ATTRIBUTE_TASK_USER_DUEDATE = "dueDate";
public static final String ATTRIBUTE_TASK_USER_CATEGORY = "category";
public static final String ATTRIBUTE_TASK_USER_PRIORITY = "priority";
public static final String ATTRIBUTE_TASK_RULE_VARIABLES_INPUT = "ruleVariablesInput";
......
......@@ -85,6 +85,7 @@ public class UserTaskXMLConverter extends BaseBpmnXMLConverter {
}
BpmnXMLUtil.addXMLLocation(userTask, xtr);
userTask.setDueDate(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_DUEDATE));
userTask.setCategory(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_CATEGORY));
userTask.setFormKey(formKey);
userTask.setAssignee(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_ASSIGNEE));
userTask.setOwner(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_TASK_USER_OWNER));
......@@ -115,6 +116,7 @@ public class UserTaskXMLConverter extends BaseBpmnXMLConverter {
writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CANDIDATEUSERS, convertToDelimitedString(userTask.getCandidateUsers()), xtw);
writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CANDIDATEGROUPS, convertToDelimitedString(userTask.getCandidateGroups()), xtw);
writeQualifiedAttribute(ATTRIBUTE_TASK_USER_DUEDATE, userTask.getDueDate(), xtw);
writeQualifiedAttribute(ATTRIBUTE_TASK_USER_CATEGORY, userTask.getCategory(), xtw);
writeQualifiedAttribute(ATTRIBUTE_FORM_FORMKEY, userTask.getFormKey(), xtw);
if (userTask.getPriority() != null) {
writeQualifiedAttribute(ATTRIBUTE_TASK_USER_PRIORITY, userTask.getPriority().toString(), xtw);
......
......@@ -25,6 +25,7 @@ public class UserTask extends Task {
protected String priority;
protected String formKey;
protected String dueDate;
protected String category;
protected List<String> candidateUsers = new ArrayList<String>();
protected List<String> candidateGroups = new ArrayList<String>();
protected List<FormProperty> formProperties = new ArrayList<FormProperty>();
......@@ -60,7 +61,13 @@ public class UserTask extends Task {
public void setDueDate(String dueDate) {
this.dueDate = dueDate;
}
public List<String> getCandidateUsers() {
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public List<String> getCandidateUsers() {
return candidateUsers;
}
public void setCandidateUsers(List<String> candidateUsers) {
......@@ -99,6 +106,8 @@ public class UserTask extends Task {
setCandidateUsers(new ArrayList<String>(otherElement.getCandidateUsers()));
setDocumentation(otherElement.getDocumentation());
setFormKey(otherElement.getFormKey());
setDueDate(otherElement.getDueDate());
setCategory(otherElement.getCategory());
taskListeners = new ArrayList<ActivitiListener>();
if (otherElement.getTaskListeners() != null && otherElement.getTaskListeners().size() > 0) {
......
......@@ -76,12 +76,15 @@ public interface HistoricTaskInstance {
/** Task form key. */
String getFormKey();
/** Task priority **/
/** Task priority */
int getPriority();
/** Task due date **/
/** Task due date */
Date getDueDate();
/** Task category */
String getCategory();
/** The parent task of this task, in case this task was a subtask */
String getParentTaskId();
......
......@@ -251,6 +251,11 @@ public interface HistoricTaskInstanceQuery extends Query<HistoricTaskInstanceQu
*/
HistoricTaskInstanceQuery taskCompletedAfter(Date endDate);
/**
* Only select tasks with the given category. This is an optional field and allows to 'tag' tasks as belonging to a certain category.
*/
HistoricTaskInstanceQuery taskCategory(String category);
/**
* Only select tasks which have a local task variable with the given name
* set to the given value.
......
......@@ -77,6 +77,7 @@ public class HistoricTaskInstanceQueryImpl extends AbstractVariableQueryImpl<His
protected Date completedDate;
protected Date completedAfterDate;
protected Date completedBeforeDate;
protected String category;
protected boolean includeTaskLocalVariables = false;
protected boolean includeProcessVariables = false;
......@@ -398,6 +399,11 @@ public class HistoricTaskInstanceQueryImpl extends AbstractVariableQueryImpl<His
return this;
}
public HistoricTaskInstanceQuery taskCategory(String category) {
this.category = category;
return this;
}
public HistoricTaskInstanceQuery taskCandidateUser(String candidateUser) {
if (candidateUser == null) {
throw new ActivitiIllegalArgumentException("Candidate user is null");
......
......@@ -60,6 +60,7 @@ public class TaskQueryImpl extends AbstractVariableQueryImpl<TaskQuery, Task> im
protected Date createTime;
protected Date createTimeBefore;
protected Date createTimeAfter;
protected String category;
protected String key;
protected String keyLike;
protected String processDefinitionKey;
......@@ -295,6 +296,11 @@ public class TaskQueryImpl extends AbstractVariableQueryImpl<TaskQuery, Task> im
return this;
}
public TaskQuery taskCategory(String category) {
this.category = category;
return this;
}
public TaskQuery taskDefinitionKey(String key) {
this.key = key;
return this;
......
......@@ -92,6 +92,18 @@ public class UserTaskActivityBehavior extends TaskActivityBehavior {
}
}
if (taskDefinition.getCategoryExpression() != null) {
final Object category = taskDefinition.getCategoryExpression().getValue(execution);
if (category != null) {
if (category instanceof String) {
task.setCategory((String) category);
} else {
throw new ActivitiIllegalArgumentException("Category expression does not resolve to a string: " +
taskDefinition.getCategoryExpression().getExpressionText());
}
}
}
handleAssignments(task, execution);
// All properties set, now firing 'create' event
......
......@@ -93,6 +93,11 @@ public class UserTaskParseHandler extends AbstractActivityBpmnParseHandler<UserT
taskDefinition.setDueDateExpression(expressionManager.createExpression(userTask.getDueDate()));
}
// Category
if (StringUtils.isNotEmpty(userTask.getCategory())) {
taskDefinition.setCategoryExpression(expressionManager.createExpression(userTask.getCategory()));
}
// Priority
if (StringUtils.isNotEmpty(userTask.getPriority())) {
taskDefinition.setPriorityExpression(expressionManager.createExpression(userTask.getPriority()));
......
......@@ -463,6 +463,19 @@ public class HistoryManager extends AbstractManager {
}
}
}
/**
* Record task category change, if audit history is enabled.
*/
public void recordTaskCategoryChange(String taskId, String category) {
if (isHistoryLevelAtLeast(HistoryLevel.AUDIT)) {
HistoricTaskInstanceEntity historicTaskInstance = getDbSqlSession().selectById(HistoricTaskInstanceEntity.class, taskId);
if (historicTaskInstance!=null) {
historicTaskInstance.setCategory(category);
}
}
}
/**
* Record task parent task id change, if audit history is enabled.
......
......@@ -42,6 +42,7 @@ public class HistoricTaskInstanceEntity extends HistoricScopeInstanceEntity impl
protected int priority;
protected Date dueDate;
protected Date claimTime;
protected String category;
protected List<HistoricVariableInstanceEntity> queryVariables;
public HistoricTaskInstanceEntity() {
......@@ -141,7 +142,13 @@ public class HistoricTaskInstanceEntity extends HistoricScopeInstanceEntity impl
public void setDueDate(Date dueDate) {
this.dueDate = dueDate;
}
public String getOwner() {
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
......
......@@ -69,6 +69,7 @@ public class TaskEntity extends VariableScopeImpl implements Task, DelegateTask,
protected Date createTime; // The time when the task has been created
protected Date dueDate;
protected int suspensionState = SuspensionState.ACTIVE.getStateCode();
protected String category;
protected boolean isIdentityLinksInitialized = false;
protected List<IdentityLinkEntity> taskIdentityLinkEntities = new ArrayList<IdentityLinkEntity>();
......@@ -511,6 +512,18 @@ public class TaskEntity extends VariableScopeImpl implements Task, DelegateTask,
.recordTaskPriorityChange(id, priority);
}
}
public void setCategory(String category) {
this.category = category;
CommandContext commandContext = Context.getCommandContext();
if (commandContext!=null) {
commandContext
.getHistoryManager()
.recordTaskCategoryChange(id, category);
}
}
public void setPriorityWithoutCascade(int priority) {
this.priority = priority;
......@@ -713,7 +726,10 @@ public class TaskEntity extends VariableScopeImpl implements Task, DelegateTask,
public void setSuspensionState(int suspensionState) {
this.suspensionState = suspensionState;
}
public boolean isSuspended() {
public String getCategory() {
return category;
}
public boolean isSuspended() {
return suspensionState == SuspensionState.SUSPENDED.getStateCode();
}
public Map<String, Object> getTaskLocalVariables() {
......
......@@ -44,6 +44,7 @@ public class TaskDefinition implements Serializable {
protected Set<Expression> candidateGroupIdExpressions = new HashSet<Expression>();
protected Expression dueDateExpression;
protected Expression priorityExpression;
protected Expression categoryExpression;
// form fields
protected TaskFormHandler taskFormHandler;
......@@ -136,8 +137,16 @@ public class TaskDefinition implements Serializable {
public void setDueDateExpression(Expression dueDateExpression) {
this.dueDateExpression = dueDateExpression;
}
public Expression getCategoryExpression() {
return categoryExpression;
}
public void setCategoryExpression(Expression categoryExpression) {
this.categoryExpression = categoryExpression;
}
public Map<String, List<TaskListener>> getTaskListeners() {
public Map<String, List<TaskListener>> getTaskListeners() {
return taskListeners;
}
......
......@@ -88,6 +88,12 @@ public interface Task {
/** Change due date of the task. */
void setDueDate(Date dueDate);
/** The category of the task. This is an optional field and allows to 'tag' tasks as belonging to a certain category. */
String getCategory();
/** Change the category of the task. This is an optional field and allows to 'tag' tasks as belonging to a certain category. */
void setCategory(String category);
/** delegates this task to the given user and sets the {@link #getDelegationState() delegationState} to {@link DelegationState#PENDING}.
* If no owner is set on the task, the owner is set to the current assignee of the task. */
......
......@@ -121,17 +121,20 @@ public interface TaskQuery extends Query<TaskQuery, Task>{
/** Only select tasks for the given execution. */
TaskQuery executionId(String executionId);
/** Only select tasks that are created on the given date. **/
/** Only select tasks that are created on the given date. */
TaskQuery taskCreatedOn(Date createTime);
/** Only select tasks that are created before the given date. **/
/** Only select tasks that are created before the given date. */
TaskQuery taskCreatedBefore(Date before);
/** Only select tasks that are created after the given date. **/
/** Only select tasks that are created after the given date. */
TaskQuery taskCreatedAfter(Date after);
/** Only select tasks that have no parent (i.e. do not select subtasks). **/
/** Only select tasks that have no parent (i.e. do not select subtasks). */
TaskQuery excludeSubtasks();
/** Only select tasks with the given category. */
TaskQuery taskCategory(String category);
/**
* Only select tasks with the given taskDefinitionKey.
......
......@@ -120,6 +120,7 @@ create table ACT_RU_TASK (
PRIORITY_ integer,
CREATE_TIME_ timestamp,
DUE_DATE_ timestamp,
CATEGORY_ varchar(255),
SUSPENSION_STATE_ integer,
primary key (ID_)
);
......
......@@ -55,6 +55,7 @@ create table ACT_HI_TASKINST (
PRIORITY_ integer,
DUE_DATE_ timestamp,
FORM_KEY_ varchar(255),
CATEGORY_ varchar(255),
primary key (ID_)
);
......
......@@ -118,6 +118,7 @@ create table ACT_RU_TASK (
PRIORITY_ integer,
CREATE_TIME_ timestamp,
DUE_DATE_ timestamp,
CATEGORY_ varchar(255),
SUSPENSION_STATE_ integer,
primary key (ID_)
);
......
......@@ -51,6 +51,7 @@ create table ACT_HI_TASKINST (
PRIORITY_ integer,
DUE_DATE_ timestamp,
FORM_KEY_ varchar(255),
CATEGORY_ varchar(255),
primary key (ID_)
);
......
......@@ -118,6 +118,7 @@ create table ACT_RU_TASK (
PRIORITY_ int,
CREATE_TIME_ datetime,
DUE_DATE_ datetime,
CATEGORY_ nvarchar(255),
SUSPENSION_STATE_ int,
primary key (ID_)
);
......
......@@ -51,6 +51,7 @@ create table ACT_HI_TASKINST (
PRIORITY_ int,
DUE_DATE_ datetime,
FORM_KEY_ nvarchar(255),
CATEGORY_ nvarchar(255),
primary key (ID_)
);
......
......@@ -119,6 +119,7 @@ create table ACT_RU_TASK (
PRIORITY_ integer,
CREATE_TIME_ timestamp,
DUE_DATE_ datetime,
CATEGORY_ varchar(255),
SUSPENSION_STATE_ integer,
primary key (ID_)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
......
......@@ -52,6 +52,7 @@ create table ACT_HI_TASKINST (
PRIORITY_ integer,
DUE_DATE_ datetime,
FORM_KEY_ varchar(255),
CATEGORY_ varchar(255),
primary key (ID_)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_bin;
......
......@@ -118,6 +118,7 @@ create table ACT_RU_TASK (
PRIORITY_ INTEGER,
CREATE_TIME_ TIMESTAMP(6),
DUE_DATE_ TIMESTAMP(6),
CATEGORY_ NVARCHAR2(255),
SUSPENSION_STATE_ INTEGER,
primary key (ID_)
);
......
......@@ -51,6 +51,7 @@ create table ACT_HI_TASKINST (
PRIORITY_ INTEGER,
DUE_DATE_ TIMESTAMP(6),
FORM_KEY_ NVARCHAR2(255),
CATEGORY_ NVARCHAR2(255),
primary key (ID_)
);
......
......@@ -119,6 +119,7 @@ create table ACT_RU_TASK (
PRIORITY_ integer,
CREATE_TIME_ timestamp,
DUE_DATE_ timestamp,
CATEGORY_ varchar(255),
SUSPENSION_STATE_ integer,
primary key (ID_)
);
......
......@@ -52,6 +52,7 @@ create table ACT_HI_TASKINST (
PRIORITY_ integer,
DUE_DATE_ timestamp,
FORM_KEY_ varchar(255),
CATEGORY_ varchar(255),
primary key (ID_)
);
......
......@@ -39,7 +39,8 @@
TASK_DEF_KEY_,
FORM_KEY_,
PRIORITY_,
DUE_DATE_
DUE_DATE_,
CATEGORY_
) values (
#{id ,jdbcType=VARCHAR},
#{processDefinitionId, jdbcType=VARCHAR},
......@@ -58,7 +59,8 @@
#{taskDefinitionKey ,jdbcType=VARCHAR},
#{formKey ,jdbcType=VARCHAR},
#{priority, jdbcType=INTEGER},
#{dueDate, jdbcType=TIMESTAMP}
#{dueDate, jdbcType=TIMESTAMP},
#{category, jdbcType=VARCHAR}
)
</insert>
......@@ -79,7 +81,8 @@
TASK_DEF_KEY_ = #{taskDefinitionKey ,jdbcType=VARCHAR},
FORM_KEY_ = #{formKey ,jdbcType=VARCHAR},
PRIORITY_ = #{priority, jdbcType=INTEGER},
DUE_DATE_ = #{dueDate, jdbcType=TIMESTAMP}
DUE_DATE_ = #{dueDate, jdbcType=TIMESTAMP},
CATEGORY_ = #{category, jdbcType=VARCHAR}
where ID_ = #{id}
</update>
......@@ -110,6 +113,7 @@
<result property="formKey" column="FORM_KEY_" jdbcType="VARCHAR" />
<result property="priority" column="PRIORITY_" jdbcType="INTEGER" />
<result property="dueDate" column="DUE_DATE_" jdbcType="TIMESTAMP" />
<result property="category" column="CATEGORY_" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="historicTaskInstanceAndVariablesResultMap" type="org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity">
......@@ -131,6 +135,7 @@
<result property="formKey" column="FORM_KEY_" jdbcType="VARCHAR" />
<result property="priority" column="PRIORITY_" jdbcType="INTEGER" />
<result property="dueDate" column="DUE_DATE_" jdbcType="TIMESTAMP" />
<result property="category" column="CATEGORY_" jdbcType="VARCHAR" />
<collection property="queryVariables" column="TASK_ID_" javaType="ArrayList" ofType="org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity">
<id property="id" column="VAR_ID_"/>
<result property="name" column="VAR_NAME_" javaType="String" jdbcType="VARCHAR" />
......@@ -380,6 +385,9 @@
<if test="completedAfterDate != null">
and RES.END_TIME_ &gt; #{completedAfterDate}
</if>
<if test="category != null">
and RES.CATEGORY_ = #{category}
</if>
<if test="candidateUser != null || candidateGroups != null">
and RES.ASSIGNEE_ is null
and HI.TYPE_ = 'candidate'
......
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.activiti.engine.impl.persistence.entity.TaskEntity">
......@@ -8,7 +23,7 @@
<insert id="insertTask" parameterType="org.activiti.engine.impl.persistence.entity.TaskEntity">
insert into ${prefix}ACT_RU_TASK (ID_, REV_, NAME_, PARENT_TASK_ID_, DESCRIPTION_, PRIORITY_, CREATE_TIME_, OWNER_,
ASSIGNEE_, DELEGATION_, EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_KEY_, DUE_DATE_, SUSPENSION_STATE_)
ASSIGNEE_, DELEGATION_, EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_, TASK_DEF_KEY_, DUE_DATE_, CATEGORY_, SUSPENSION_STATE_)
values (#{id, jdbcType=VARCHAR},
1,
#{name, jdbcType=VARCHAR},
......@@ -24,6 +39,7 @@
#{processDefinitionId, jdbcType=VARCHAR},
#{taskDefinitionKey, jdbcType=VARCHAR},
#{dueDate, jdbcType=TIMESTAMP},
#{category, jdbcType=VARCHAR},
#{suspensionState, jdbcType=INTEGER}
)
</insert>
......@@ -45,6 +61,7 @@
PROC_DEF_ID_ = #{processDefinitionId, jdbcType=VARCHAR},
DESCRIPTION_ = #{description, jdbcType=VARCHAR},
DUE_DATE_ = #{dueDate, jdbcType=TIMESTAMP},
CATEGORY_ = #{category, jdbcType=VARCHAR},
SUSPENSION_STATE_ = #{suspensionState, jdbcType=INTEGER}
</set>
where ID_= #{id, jdbcType=VARCHAR}
......@@ -74,6 +91,7 @@
<result property="processDefinitionId" column="PROC_DEF_ID_" jdbcType="VARCHAR"/>
<result property="taskDefinitionKeyWithoutCascade" column="TASK_DEF_KEY_" jdbcType="VARCHAR"/>
<result property="dueDateWithoutCascade" column="DUE_DATE_" jdbcType="TIMESTAMP"/>
<result property="category" column="CATEGORY_" jdbcType="VARCHAR" />
<result property="suspensionState" column="SUSPENSION_STATE_" jdbcType="INTEGER" />
</resultMap>
......@@ -93,6 +111,7 @@
<result property="processDefinitionId" column="PROC_DEF_ID_" jdbcType="VARCHAR"/>
<result property="taskDefinitionKeyWithoutCascade" column="TASK_DEF_KEY_" jdbcType="VARCHAR"/>
<result property="dueDateWithoutCascade" column="DUE_DATE_" jdbcType="TIMESTAMP"/>
<result property="category" column="CATEGORY_" jdbcType="VARCHAR" />
<result property="suspensionState" column="SUSPENSION_STATE_" jdbcType="INTEGER" />
<collection property="queryVariables" column="TASK_ID_" javaType="ArrayList" ofType="org.activiti.engine.impl.persistence.entity.VariableInstanceEntity">
<id property="id" column="VAR_ID_"/>
......@@ -335,6 +354,9 @@
<if test="dueDate != null || dueBefore != null || dueAfter != null">
and RES.DUE_DATE_ is not null
</if>
<if test="category != null">
and RES.CATEGORY_ = #{category}
</if>
<if test="excludeSubtasks">
and RES.PARENT_TASK_ID_ IS NULL
</if>
......
alter table ACT_RU_TASK
add CATEGORY_ varchar(255);
update ACT_GE_PROPERTY set VALUE_ = '5.15-SNAPSHOT' where NAME_ = 'schema.version';
alter table ACT_HI_TASKINST
add CATEGORY_ varchar(255);
\ No newline at end of file
alter table ACT_RU_TASK
add CATEGORY_ varchar(255);
update ACT_GE_PROPERTY set VALUE_ = '5.15-SNAPSHOT' where NAME_ = 'schema.version';
alter table ACT_HI_TASKINST
add CATEGORY_ varchar(255);
\ No newline at end of file
alter table ACT_RU_TASK
add CATEGORY_ nvarchar(255);
update ACT_GE_PROPERTY set VALUE_ = '5.15-SNAPSHOT' where NAME_ = 'schema.version';
alter table ACT_HI_TASKINST
add CATEGORY_ nvarchar(255);
\ No newline at end of file
alter table ACT_RU_TASK
add CATEGORY_ varchar(255);
update ACT_GE_PROPERTY set VALUE_ = '5.15-SNAPSHOT' where NAME_ = 'schema.version';
alter table ACT_HI_TASKINST
add CATEGORY_ varchar(255);
\ No newline at end of file
alter table ACT_RU_TASK
add CATEGORY_ NVARCHAR2(255);
update ACT_GE_PROPERTY set VALUE_ = '5.15-SNAPSHOT' where NAME_ = 'schema.version';
alter table ACT_HI_TASKINST
add CATEGORY_ NVARCHAR2(255);
\ No newline at end of file
alter table ACT_RU_TASK
add CATEGORY_ varchar(255);
update ACT_GE_PROPERTY set VALUE_ = '5.15-SNAPSHOT' where NAME_ = 'schema.version';
alter table ACT_HI_TASKINST
add CATEGORY_ varchar(255);
\ No newline at end of file
......@@ -15,6 +15,7 @@ package org.activiti.engine.test.bpmn.usertask;
import java.util.List;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.impl.history.HistoryLevel;
import org.activiti.engine.impl.test.PluggableActivitiTestCase;
import org.activiti.engine.runtime.ProcessInstance;
......@@ -72,4 +73,42 @@ public class UserTaskTest extends PluggableActivitiTestCase {
// attempt to complete the task and get PersistenceException pointing to "referential integrity constraint violation"
taskService.complete(task.getId());
}
@Deployment
public void testTaskCategory() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testTaskCategory");
Task task = taskService.createTaskQuery().singleResult();
// Test if the property set in the model is shown in the task
String testCategory = "My Category";
assertEquals(testCategory, task.getCategory());
// Test if can be queried by query API
assertEquals("Task with category", taskService.createTaskQuery().taskCategory(testCategory).singleResult().getName());
assertTrue(taskService.createTaskQuery().taskCategory("Does not exist").count() == 0);
// Check historic task
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
assertEquals(testCategory, historicTaskInstance.getCategory());
assertEquals("Task with category", historyService.createHistoricTaskInstanceQuery().taskCategory(testCategory).singleResult().getName());
assertTrue(historyService.createHistoricTaskInstanceQuery().taskCategory("Does not exist").count() == 0);
// Update category
String newCategory = "New Test Category";
task.setCategory(newCategory);
taskService.saveTask(task);
task = taskService.createTaskQuery().singleResult();
assertEquals(newCategory, task.getCategory());
assertEquals("Task with category", taskService.createTaskQuery().taskCategory(newCategory).singleResult().getName());
assertTrue(taskService.createTaskQuery().taskCategory(testCategory).count() == 0);
// Complete task and verify history
taskService.complete(task.getId());
historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
assertEquals(newCategory, historicTaskInstance.getCategory());
assertEquals("Task with category", historyService.createHistoricTaskInstanceQuery().taskCategory(newCategory).singleResult().getName());
assertTrue(historyService.createHistoricTaskInstanceQuery().taskCategory(testCategory).count() == 0);
}
}
......@@ -50,7 +50,7 @@ public class ManagementServiceTest extends PluggableActivitiTestCase {
TableMetaData tableMetaData = managementService.getTableMetaData(tablePrefix+"ACT_RU_TASK");
assertEquals(tableMetaData.getColumnNames().size(), tableMetaData.getColumnTypes().size());
assertEquals(16, tableMetaData.getColumnNames().size());
assertEquals(17, tableMetaData.getColumnNames().size());
int assigneeIndex = tableMetaData.getColumnNames().indexOf("ASSIGNEE_");
int createTimeIndex = tableMetaData.getColumnNames().indexOf("CREATE_TIME_");
......
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema"
expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn20">
<process id="testTaskCategory">
<documentation>This is a process for testing purposes</documentation>
<startEvent id="theStart" />
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="theTask" />
<userTask id="theTask" name="Task with category" activiti:category="My Category" />
<sequenceFlow id="flow2" sourceRef="theTask" targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
</definitions>
\ No newline at end of file
......@@ -36,6 +36,7 @@ public class HistoricTaskWrapper implements Task {
protected String owner;
protected String assignee;
protected Date dueDate;
protected String category;
protected String parentTaskId;
public HistoricTaskWrapper(HistoricTaskInstance historicTaskInstance) {
......@@ -126,8 +127,16 @@ public class HistoricTaskWrapper implements Task {
public void setDueDate(Date dueDate) {
this.dueDate = dueDate;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public void delegate(String userId) {
public void delegate(String userId) {
}
public void setParentTaskId(String parentTaskId) {
......
......@@ -123,6 +123,7 @@ public interface StencilConstants {
final String PROPERTY_FORMKEY = "formkeydefinition";
final String PROPERTY_DUEDATE = "duedatedefinition";
final String PROPERTY_CATEGORY = "categoryDefinition";
final String PROPERTY_PRIORITY = "prioritydefinition";
final String PROPERTY_USERTASK_ASSIGNMENT = "usertaskassignment";
......
......@@ -90,6 +90,7 @@ public class UserTaskJsonConverter extends BaseBpmnJsonConverter {
}
setPropertyValue(PROPERTY_FORMKEY, userTask.getFormKey(), propertiesNode);
setPropertyValue(PROPERTY_DUEDATE, userTask.getDueDate(), propertiesNode);
setPropertyValue(PROPERTY_CATEGORY, userTask.getCategory(), propertiesNode);;
addFormProperties(userTask.getFormProperties(), propertiesNode);
}
......@@ -100,6 +101,7 @@ public class UserTaskJsonConverter extends BaseBpmnJsonConverter {
task.setPriority(getPropertyValueAsString(PROPERTY_PRIORITY, elementNode));
task.setFormKey(getPropertyValueAsString(PROPERTY_FORMKEY, elementNode));
task.setDueDate(getPropertyValueAsString(PROPERTY_DUEDATE, elementNode));
task.setCategory(getPropertyValueAsString(PROPERTY_CATEGORY, elementNode));
JsonNode assignmentNode = getProperty(PROPERTY_USERTASK_ASSIGNMENT, elementNode);
if (assignmentNode != null) {
......
......@@ -738,6 +738,7 @@
<module>modules/activiti-bpmn-layout</module>
<module>modules/activiti-json-converter</module>
<module>modules/activiti-simple-workflow</module>
<module>modules/activiti-rest</module>
<module>modules/activiti-webapp-rest2</module>
<module>modules/activiti-cxf</module>
<module>modules/activiti-cdi</module>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册