Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
308a49d7
F
Flowable Engine
项目概览
开发团队
/
Flowable Engine
通知
9
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
Flowable Engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
308a49d7
编写于
11月 23, 2012
作者:
F
Frederik Heremans
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ACT-900: deletereason for task can be specified + check on deleting
proccess-spawned tasks
上级
7c574b39
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
129 addition
and
15 deletion
+129
-15
modules/activiti-engine/src/main/java/org/activiti/engine/TaskService.java
...engine/src/main/java/org/activiti/engine/TaskService.java
+33
-2
modules/activiti-engine/src/main/java/org/activiti/engine/impl/TaskServiceImpl.java
...c/main/java/org/activiti/engine/impl/TaskServiceImpl.java
+14
-4
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteTaskCmd.java
...main/java/org/activiti/engine/impl/cmd/DeleteTaskCmd.java
+6
-3
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/TaskManager.java
.../activiti/engine/impl/persistence/entity/TaskManager.java
+8
-4
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/task/TaskServiceTest.java
...va/org/activiti/engine/test/api/task/TaskServiceTest.java
+68
-2
未找到文件。
modules/activiti-engine/src/main/java/org/activiti/engine/TaskService.java
浏览文件 @
308a49d7
...
...
@@ -54,16 +54,21 @@ public interface TaskService {
void
saveTask
(
Task
task
);
/**
* Deletes the given task.
* Deletes the given task
, not deleting historic information that is related to this task
.
* @param taskId The id of the task that will be deleted, cannot be null. If no task
* exists with the given taskId, the operation is ignored.
* @throws ActivitiException when an error occurs while deleting the task or in case the task is part
* of a running process.
*/
void
deleteTask
(
String
taskId
);
/**
* Deletes all tasks of the given collection.
* Deletes all tasks of the given collection, not deleting historic information that is related
* to these tasks.
* @param taskIds The id's of the tasks that will be deleted, cannot be null. All
* id's in the list that don't have an existing task will be ignored.
* @throws ActivitiException when an error occurs while deleting the tasks or in case one of the tasks
* is part of a running process.
*/
void
deleteTasks
(
Collection
<
String
>
taskIds
);
...
...
@@ -72,6 +77,8 @@ public interface TaskService {
* @param taskId The id of the task that will be deleted, cannot be null. If no task
* exists with the given taskId, the operation is ignored.
* @param cascade If cascade is true, also the historic information related to this task is deleted.
* @throws ActivitiException when an error occurs while deleting the task or in case the task is part
* of a running process.
*/
void
deleteTask
(
String
taskId
,
boolean
cascade
);
...
...
@@ -80,9 +87,33 @@ public interface TaskService {
* @param taskIds The id's of the tasks that will be deleted, cannot be null. All
* id's in the list that don't have an existing task will be ignored.
* @param cascade If cascade is true, also the historic information related to this task is deleted.
* @throws ActivitiException when an error occurs while deleting the tasks or in case one of the tasks
* is part of a running process.
* @throws ActivitiException when an error occurs while deleting the tasks or in case one of the tasks
* is part of a running process.
*/
void
deleteTasks
(
Collection
<
String
>
taskIds
,
boolean
cascade
);
/**
* Deletes the given task, not deleting historic information that is related to this task..
* @param taskId The id of the task that will be deleted, cannot be null. If no task
* exists with the given taskId, the operation is ignored.
* @param deleteReason reason the task is deleted. Is recorded in history, if enabled.
* @throws ActivitiException when an error occurs while deleting the task or in case the task is part
* of a running process
*/
void
deleteTask
(
String
taskId
,
String
deleteReason
);
/**
* Deletes all tasks of the given collection, not deleting historic information that is related to these tasks.
* @param taskIds The id's of the tasks that will be deleted, cannot be null. All
* id's in the list that don't have an existing task will be ignored.
* @param deleteReason reason the task is deleted. Is recorded in history, if enabled.
* @throws ActivitiException when an error occurs while deleting the tasks or in case one of the tasks
* is part of a running process.
*/
void
deleteTasks
(
Collection
<
String
>
taskIds
,
String
deleteReason
);
/**
* Claim responsibility for a task: the given user is made assignee for the task.
* The difference with {@link #setAssignee(String, String)} is that here
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/TaskServiceImpl.java
浏览文件 @
308a49d7
...
...
@@ -79,19 +79,29 @@ public class TaskServiceImpl extends ServiceImpl implements TaskService {
}
public
void
deleteTask
(
String
taskId
)
{
commandExecutor
.
execute
(
new
DeleteTaskCmd
(
taskId
,
false
));
commandExecutor
.
execute
(
new
DeleteTaskCmd
(
taskId
,
null
,
false
));
}
public
void
deleteTasks
(
Collection
<
String
>
taskIds
)
{
commandExecutor
.
execute
(
new
DeleteTaskCmd
(
taskIds
,
false
));
commandExecutor
.
execute
(
new
DeleteTaskCmd
(
taskIds
,
null
,
false
));
}
public
void
deleteTask
(
String
taskId
,
boolean
cascade
)
{
commandExecutor
.
execute
(
new
DeleteTaskCmd
(
taskId
,
cascade
));
commandExecutor
.
execute
(
new
DeleteTaskCmd
(
taskId
,
null
,
cascade
));
}
public
void
deleteTasks
(
Collection
<
String
>
taskIds
,
boolean
cascade
)
{
commandExecutor
.
execute
(
new
DeleteTaskCmd
(
taskIds
,
cascade
));
commandExecutor
.
execute
(
new
DeleteTaskCmd
(
taskIds
,
null
,
cascade
));
}
@Override
public
void
deleteTask
(
String
taskId
,
String
deleteReason
)
{
commandExecutor
.
execute
(
new
DeleteTaskCmd
(
taskId
,
deleteReason
,
false
));
}
@Override
public
void
deleteTasks
(
Collection
<
String
>
taskIds
,
String
deleteReason
)
{
commandExecutor
.
execute
(
new
DeleteTaskCmd
(
taskIds
,
deleteReason
,
false
));
}
public
void
setAssignee
(
String
taskId
,
String
userId
)
{
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/DeleteTaskCmd.java
浏览文件 @
308a49d7
...
...
@@ -30,15 +30,18 @@ public class DeleteTaskCmd implements Command<Void>, Serializable {
protected
String
taskId
;
protected
Collection
<
String
>
taskIds
;
protected
boolean
cascade
;
protected
String
deleteReason
;
public
DeleteTaskCmd
(
String
taskId
,
boolean
cascade
)
{
public
DeleteTaskCmd
(
String
taskId
,
String
deleteReason
,
boolean
cascade
)
{
this
.
taskId
=
taskId
;
this
.
cascade
=
cascade
;
this
.
deleteReason
=
deleteReason
;
}
public
DeleteTaskCmd
(
Collection
<
String
>
taskIds
,
boolean
cascade
)
{
public
DeleteTaskCmd
(
Collection
<
String
>
taskIds
,
String
deleteReason
,
boolean
cascade
)
{
this
.
taskIds
=
taskIds
;
this
.
cascade
=
cascade
;
this
.
deleteReason
=
deleteReason
;
}
public
Void
execute
(
CommandContext
commandContext
)
{
...
...
@@ -60,6 +63,6 @@ public class DeleteTaskCmd implements Command<Void>, Serializable {
Context
.
getCommandContext
()
.
getTaskManager
()
.
deleteTask
(
taskId
,
cascade
);
.
deleteTask
(
taskId
,
deleteReason
,
cascade
);
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/TaskManager.java
浏览文件 @
308a49d7
...
...
@@ -91,11 +91,11 @@ public class TaskManager extends AbstractManager {
return
getDbSqlSession
().
selectList
(
"selectTasksByExecutionId"
,
executionId
);
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
TaskEntity
>
findTasksByProcessInstanceId
(
String
processInstanceId
)
{
return
getDbSqlSession
().
selectList
(
"selectTasksByProcessInstanceId"
,
processInstanceId
);
}
@SuppressWarnings
(
"unchecked"
)
@Deprecated
public
List
<
Task
>
findTasksByQueryCriteria
(
TaskQueryImpl
taskQuery
,
Page
page
)
{
taskQuery
.
setFirstResult
(
page
.
getFirstResult
());
...
...
@@ -127,15 +127,19 @@ public class TaskManager extends AbstractManager {
return
getDbSqlSession
().
selectList
(
"selectTasksByParentTaskId"
,
parentTaskId
);
}
public
void
deleteTask
(
String
taskId
,
boolean
cascade
)
{
public
void
deleteTask
(
String
taskId
,
String
deleteReason
,
boolean
cascade
)
{
TaskEntity
task
=
Context
.
getCommandContext
()
.
getTaskManager
()
.
findTaskById
(
taskId
);
if
(
task
!=
null
)
{
deleteTask
(
task
,
TaskEntity
.
DELETE_REASON_DELETED
,
cascade
);
if
(
task
.
getExecutionId
()
!=
null
)
{
throw
new
ActivitiException
(
"The task cannot be deleted because is part of a running process"
);
}
String
reason
=
(
deleteReason
==
null
||
deleteReason
.
length
()
==
0
)
?
TaskEntity
.
DELETE_REASON_DELETED
:
deleteReason
;
deleteTask
(
task
,
reason
,
cascade
);
}
else
if
(
cascade
)
{
Context
.
getCommandContext
()
...
...
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/task/TaskServiceTest.java
浏览文件 @
308a49d7
...
...
@@ -495,8 +495,6 @@ public class TaskServiceTest extends PluggableActivitiTestCase {
Map
<
String
,
Object
>
variables
=
runtimeService
.
getVariables
(
processInstance
.
getId
());
assertEquals
(
1
,
variables
.
size
());
assertEquals
(
"myValue"
,
variables
.
get
(
"myParam"
));
taskService
.
deleteTask
(
task
.
getId
(),
true
);
}
public
void
testSetAssignee
()
{
...
...
@@ -1055,4 +1053,72 @@ public class TaskServiceTest extends PluggableActivitiTestCase {
}
}
public
void
testDeleteTaskWithDeleteReason
()
{
// ACT-900: deleteReason can be manually specified - can only be validated when historyLevel > ACTIVITY
if
(
processEngineConfiguration
.
getHistoryLevel
().
isAtLeast
(
HistoryLevel
.
ACTIVITY
))
{
Task
task
=
taskService
.
newTask
();
task
.
setName
(
"test task"
);
taskService
.
saveTask
(
task
);
assertNotNull
(
task
.
getId
());
taskService
.
deleteTask
(
task
.
getId
(),
"deleted for testing purposes"
);
HistoricTaskInstance
historicTaskInstance
=
historyService
.
createHistoricTaskInstanceQuery
()
.
taskId
(
task
.
getId
()).
singleResult
();
assertNotNull
(
historicTaskInstance
);
assertEquals
(
"deleted for testing purposes"
,
historicTaskInstance
.
getDeleteReason
());
// Delete historic task that is left behind, will not be cleaned up because this is not part of a process
taskService
.
deleteTask
(
task
.
getId
(),
true
);
}
}
@Deployment
(
resources
=
{
"org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"
})
public
void
testDeleteTaskPartOfProcess
()
{
runtimeService
.
startProcessInstanceByKey
(
"oneTaskProcess"
);
Task
task
=
taskService
.
createTaskQuery
().
singleResult
();
assertNotNull
(
task
);
try
{
taskService
.
deleteTask
(
task
.
getId
());
}
catch
(
ActivitiException
ae
)
{
assertEquals
(
"The task cannot be deleted because is part of a running process"
,
ae
.
getMessage
());
}
try
{
taskService
.
deleteTask
(
task
.
getId
(),
true
);
}
catch
(
ActivitiException
ae
)
{
assertEquals
(
"The task cannot be deleted because is part of a running process"
,
ae
.
getMessage
());
}
try
{
taskService
.
deleteTask
(
task
.
getId
(),
"test"
);
}
catch
(
ActivitiException
ae
)
{
assertEquals
(
"The task cannot be deleted because is part of a running process"
,
ae
.
getMessage
());
}
try
{
taskService
.
deleteTasks
(
Arrays
.
asList
(
task
.
getId
()));
}
catch
(
ActivitiException
ae
)
{
assertEquals
(
"The task cannot be deleted because is part of a running process"
,
ae
.
getMessage
());
}
try
{
taskService
.
deleteTasks
(
Arrays
.
asList
(
task
.
getId
()),
true
);
}
catch
(
ActivitiException
ae
)
{
assertEquals
(
"The task cannot be deleted because is part of a running process"
,
ae
.
getMessage
());
}
try
{
taskService
.
deleteTasks
(
Arrays
.
asList
(
task
.
getId
()),
"test"
);
}
catch
(
ActivitiException
ae
)
{
assertEquals
(
"The task cannot be deleted because is part of a running process"
,
ae
.
getMessage
());
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录