Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
efaf9da1
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,发现更多精彩内容 >>
提交
efaf9da1
编写于
11月 23, 2012
作者:
T
tijsrademakers
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/Activiti/Activiti
上级
cd2a3495
308a49d7
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
171 addition
and
46 deletion
+171
-46
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/test/java/org/activiti/engine/test/db/ProcessInstanceSuspensionTest.java
...ctiviti/engine/test/db/ProcessInstanceSuspensionTest.java
+42
-0
modules/activiti-engine/src/test/java/org/activiti/engine/test/jobexecutor/JobExecutorTest.java
...org/activiti/engine/test/jobexecutor/JobExecutorTest.java
+0
-31
modules/activiti-engine/src/test/resources/org/activiti/engine/test/db/ProcessInstanceSuspensionTest.testSuspendedProcessTimerExecution.bpmn20.xml
...pensionTest.testSuspendedProcessTimerExecution.bpmn20.xml
+0
-0
未找到文件。
modules/activiti-engine/src/main/java/org/activiti/engine/TaskService.java
浏览文件 @
efaf9da1
...
...
@@ -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
浏览文件 @
efaf9da1
...
...
@@ -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
浏览文件 @
efaf9da1
...
...
@@ -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
浏览文件 @
efaf9da1
...
...
@@ -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
浏览文件 @
efaf9da1
...
...
@@ -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
());
}
}
}
modules/activiti-engine/src/test/java/org/activiti/engine/test/db/ProcessInstanceSuspensionTest.java
浏览文件 @
efaf9da1
package
org.activiti.engine.test.db
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
org.activiti.engine.impl.Page
;
import
org.activiti.engine.impl.cmd.AcquireJobsCmd
;
import
org.activiti.engine.impl.interceptor.Command
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.impl.interceptor.CommandExecutor
;
import
org.activiti.engine.impl.jobexecutor.AcquiredJobs
;
import
org.activiti.engine.impl.jobexecutor.GetUnlockedTimersByDuedateCmd
;
import
org.activiti.engine.impl.persistence.entity.TimerEntity
;
import
org.activiti.engine.impl.test.PluggableActivitiTestCase
;
import
org.activiti.engine.impl.util.ClockUtil
;
import
org.activiti.engine.repository.ProcessDefinition
;
...
...
@@ -69,6 +75,42 @@ public class ProcessInstanceSuspensionTest extends PluggableActivitiTestCase {
assertEquals
(
0
,
acquiredJobs
.
size
());
}
@Deployment
public
void
testSuspendedProcessTimerExecution
()
throws
Exception
{
// Process with boundary timer-event that fires in 1 hour
ProcessInstance
procInst
=
runtimeService
.
startProcessInstanceByKey
(
"suspendProcess"
);
assertNotNull
(
procInst
);
assertEquals
(
1
,
managementService
.
createJobQuery
().
processInstanceId
(
procInst
.
getId
()).
count
());
// Shutdown the job-executor so timer's won't be executed
boolean
wasJobExecutorActive
=
processEngineConfiguration
.
getJobExecutor
().
isActive
();
if
(
wasJobExecutorActive
)
{
processEngineConfiguration
.
getJobExecutor
().
shutdown
();
}
// Roll time ahead to be sure timer is due to fire
Calendar
tomorrow
=
Calendar
.
getInstance
();
tomorrow
.
add
(
Calendar
.
DAY_OF_YEAR
,
1
);
ClockUtil
.
setCurrentTime
(
tomorrow
.
getTime
());
// Check if timer is eligable to be executed, when process in not yet suspended
CommandExecutor
commandExecutor
=
processEngineConfiguration
.
getCommandExecutorTxRequired
();
List
<
TimerEntity
>
jobs
=
commandExecutor
.
execute
(
new
GetUnlockedTimersByDuedateCmd
(
ClockUtil
.
getCurrentTime
(),
new
Page
(
0
,
1
)));
assertEquals
(
1
,
jobs
.
size
());
// Suspend process instancd
runtimeService
.
suspendProcessInstanceById
(
procInst
.
getId
());
// Check if the timer is NOT aquired, even though the duedate is reached
jobs
=
commandExecutor
.
execute
(
new
GetUnlockedTimersByDuedateCmd
(
ClockUtil
.
getCurrentTime
(),
new
Page
(
0
,
1
)));
assertEquals
(
0
,
jobs
.
size
());
// Start job-executor again, if needed
if
(
wasJobExecutorActive
)
{
processEngineConfiguration
.
getJobExecutor
().
start
();
}
}
protected
void
makeSureJobDue
(
final
Job
job
)
{
processEngineConfiguration
.
getCommandExecutorTxRequired
()
.
execute
(
new
Command
<
Void
>()
{
...
...
modules/activiti-engine/src/test/java/org/activiti/engine/test/jobexecutor/JobExecutorTest.java
浏览文件 @
efaf9da1
...
...
@@ -67,35 +67,4 @@ public class JobExecutorTest extends JobExecutorTestCase {
assertEquals
(
new
TreeSet
<
String
>(
expectedMessages
),
new
TreeSet
<
String
>(
messages
));
}
@Deployment
public
void
testSuspendedProcessTimerExecution
()
throws
Exception
{
// Process with boundary timer-event that fires in 1 hour
ProcessInstance
procInst
=
runtimeService
.
startProcessInstanceByKey
(
"suspendProcess"
);
assertNotNull
(
procInst
);
assertEquals
(
1
,
managementService
.
createJobQuery
().
processInstanceId
(
procInst
.
getId
()).
count
());
// Shutdown the job-executor so timer's won't be executed
processEngineConfiguration
.
getJobExecutor
().
shutdown
();
// Roll time ahead to be sure timer is due to fire
Calendar
tomorrow
=
Calendar
.
getInstance
();
tomorrow
.
add
(
Calendar
.
DAY_OF_YEAR
,
1
);
ClockUtil
.
setCurrentTime
(
tomorrow
.
getTime
());
// Check if timer is eligable to be executed, when process in not yet suspended
CommandExecutor
commandExecutor
=
processEngineConfiguration
.
getCommandExecutorTxRequired
();
List
<
TimerEntity
>
jobs
=
commandExecutor
.
execute
(
new
GetUnlockedTimersByDuedateCmd
(
ClockUtil
.
getCurrentTime
(),
new
Page
(
0
,
1
)));
assertEquals
(
1
,
jobs
.
size
());
// Suspend process instancd
runtimeService
.
suspendProcessInstanceById
(
procInst
.
getId
());
// Check if the timer is NOT aquired, even though the duedate is reached
jobs
=
commandExecutor
.
execute
(
new
GetUnlockedTimersByDuedateCmd
(
ClockUtil
.
getCurrentTime
(),
new
Page
(
0
,
1
)));
assertEquals
(
0
,
jobs
.
size
());
// Start job-executor again
processEngineConfiguration
.
getJobExecutor
().
start
();
}
}
modules/activiti-engine/src/test/resources/org/activiti/engine/test/
jobexecutor/JobExecutort
est.testSuspendedProcessTimerExecution.bpmn20.xml
→
modules/activiti-engine/src/test/resources/org/activiti/engine/test/
db/ProcessInstanceSuspensionT
est.testSuspendedProcessTimerExecution.bpmn20.xml
浏览文件 @
efaf9da1
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录