Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
61493659
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,发现更多精彩内容 >>
提交
61493659
编写于
4月 17, 2015
作者:
T
Tijs Rademakers
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'activiti6' of
https://github.com/Activiti/Activiti
into activiti6
上级
eff4eaf2
e880d89c
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
171 addition
and
132 deletion
+171
-132
modules/activiti-engine/src/main/java/org/activiti/engine/impl/agenda/ContinueProcessOperation.java
...activiti/engine/impl/agenda/ContinueProcessOperation.java
+1
-3
modules/activiti-engine/src/main/java/org/activiti/engine/impl/agenda/EndExecutionOperation.java
...rg/activiti/engine/impl/agenda/EndExecutionOperation.java
+1
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/agenda/TakeOutgoingSequenceFlowsOperation.java
...ngine/impl/agenda/TakeOutgoingSequenceFlowsOperation.java
+9
-6
modules/activiti-engine/src/main/java/org/activiti/engine/impl/agenda/TriggerExecutionOperation.java
...ctiviti/engine/impl/agenda/TriggerExecutionOperation.java
+1
-2
modules/activiti-engine/src/main/java/org/activiti/engine/impl/asyncexecutor/ExecuteAsyncRunnable.java
...iviti/engine/impl/asyncexecutor/ExecuteAsyncRunnable.java
+6
-2
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/InclusiveGatewayActivityBehavior.java
.../impl/bpmn/behavior/InclusiveGatewayActivityBehavior.java
+3
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/ParallelMultiInstanceBehavior.java
...ine/impl/bpmn/behavior/ParallelMultiInstanceBehavior.java
+0
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/SubProcessActivityBehavior.java
...engine/impl/bpmn/behavior/SubProcessActivityBehavior.java
+0
-2
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/StartProcessInstanceCmd.java
...org/activiti/engine/impl/cmd/StartProcessInstanceCmd.java
+4
-43
modules/activiti-engine/src/main/java/org/activiti/engine/impl/db/DbSqlSession.java
...c/main/java/org/activiti/engine/impl/db/DbSqlSession.java
+1
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ExecutionEntity.java
...iviti/engine/impl/persistence/entity/ExecutionEntity.java
+4
-6
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ExecutionEntityManager.java
...ngine/impl/persistence/entity/ExecutionEntityManager.java
+117
-48
modules/activiti-engine/src/main/java/org/activiti/engine/impl/pvm/delegate/ActivityExecution.java
.../activiti/engine/impl/pvm/delegate/ActivityExecution.java
+0
-2
modules/activiti-engine/src/main/java/org/activiti/engine/impl/pvm/runtime/ExecutionImpl.java
...a/org/activiti/engine/impl/pvm/runtime/ExecutionImpl.java
+0
-5
modules/activiti-engine/src/main/java/org/activiti/engine/impl/util/ExecutionGraphUtil.java
...ava/org/activiti/engine/impl/util/ExecutionGraphUtil.java
+18
-4
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/Execution.xml
...in/resources/org/activiti/db/mapping/entity/Execution.xml
+2
-2
modules/activiti-engine/src/test/java/org/activiti/engine/test/bpmn/gateway/InclusiveGatewayTest.java
...tiviti/engine/test/bpmn/gateway/InclusiveGatewayTest.java
+3
-3
modules/activiti-engine/src/test/resources/org/activiti/engine/test/bpmn/gateway/InclusiveGatewayTest.testAsyncBehavior.bpmn20.xml
...gateway/InclusiveGatewayTest.testAsyncBehavior.bpmn20.xml
+1
-1
未找到文件。
modules/activiti-engine/src/main/java/org/activiti/engine/impl/agenda/ContinueProcessOperation.java
浏览文件 @
61493659
...
...
@@ -55,8 +55,7 @@ public class ContinueProcessOperation extends AbstractOperation {
if
(
currentFlowElement
==
null
)
{
currentFlowElement
=
findCurrentFlowElement
(
execution
);
}
else
{
execution
.
setCurrentActivityId
(
currentFlowElement
.
getId
());
execution
.
setCurrentFlowElement
(
currentFlowElement
);
}
if
(
currentFlowElement
instanceof
FlowNode
)
{
...
...
@@ -181,7 +180,6 @@ public class ContinueProcessOperation extends AbstractOperation {
ExecutionEntity
childExecutionEntity
=
(
ExecutionEntity
)
execution
.
createExecution
();
childExecutionEntity
.
setParentId
(
execution
.
getId
());
childExecutionEntity
.
setCurrentFlowElement
(
boundaryEvent
);
childExecutionEntity
.
setCurrentActivityId
(
boundaryEvent
.
getId
());
childExecutionEntity
.
setScope
(
false
);
ActivityBehavior
boundaryEventBehavior
=
((
ActivityBehavior
)
boundaryEvent
.
getBehavior
());
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/agenda/EndExecutionOperation.java
浏览文件 @
61493659
...
...
@@ -87,7 +87,7 @@ public class EndExecutionOperation extends AbstractOperation {
Collection
<
ExecutionEntity
>
executions
=
executionEntityManager
.
findChildExecutionsByProcessInstanceId
(
processInstanceId
);
int
activeExecutions
=
0
;
for
(
ExecutionEntity
execution
:
executions
)
{
if
(
execution
.
isActive
())
{
if
(
execution
.
isActive
()
&&
!
processInstanceId
.
equals
(
execution
.
getId
())
)
{
activeExecutions
++;
}
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/agenda/TakeOutgoingSequenceFlowsOperation.java
浏览文件 @
61493659
...
...
@@ -8,12 +8,12 @@ import org.activiti.bpmn.model.FlowElement;
import
org.activiti.bpmn.model.FlowNode
;
import
org.activiti.bpmn.model.Gateway
;
import
org.activiti.bpmn.model.SequenceFlow
;
import
org.activiti.engine.ActivitiException
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.impl.persistence.entity.ExecutionEntity
;
import
org.activiti.engine.impl.persistence.entity.ExecutionEntityManager
;
import
org.activiti.engine.impl.pvm.delegate.ActivityExecution
;
import
org.activiti.engine.impl.util.condition.ConditionUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -37,8 +37,7 @@ public class TakeOutgoingSequenceFlowsOperation extends AbstractOperation {
if
(
currentFlowElement
==
null
)
{
currentFlowElement
=
findCurrentFlowElement
(
execution
);
}
else
{
execution
.
setCurrentActivityId
(
currentFlowElement
.
getId
());
execution
.
setCurrentFlowElement
(
currentFlowElement
);
}
// If execution is a scope (and not the process instance), the scope
...
...
@@ -95,9 +94,13 @@ public class TakeOutgoingSequenceFlowsOperation extends AbstractOperation {
// No outgoing found. Ending the execution
if
(
outgoingSequenceFlow
.
size
()
==
0
)
{
logger
.
warn
(
"No outgoing sequence flow found for flow node '{}'."
,
flowNode
.
getId
());
agenda
.
planEndExecutionOperation
(
execution
);
return
;
if
(
flowNode
.
getOutgoingFlows
()
==
null
||
flowNode
.
getOutgoingFlows
().
size
()
==
0
)
{
logger
.
info
(
"No outgoing sequence flow found for flow node '{}'."
,
flowNode
.
getId
());
agenda
.
planEndExecutionOperation
(
execution
);
return
;
}
else
{
throw
new
ActivitiException
(
"No outgoing sequence flow of element '"
+
flowNode
.
getId
()
+
"' could be selected for continuing the process"
);
}
}
// Leave, and reuse the incoming sequence flow, make executions for all the others (if applicable)
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/agenda/TriggerExecutionOperation.java
浏览文件 @
61493659
...
...
@@ -23,8 +23,7 @@ public class TriggerExecutionOperation extends AbstractOperation {
if
(
currentFlowElement
==
null
)
{
currentFlowElement
=
findCurrentFlowElement
(
execution
);
}
else
{
execution
.
setCurrentActivityId
(
currentFlowElement
.
getId
());
execution
.
setCurrentFlowElement
(
currentFlowElement
);
}
if
(
currentFlowElement
instanceof
FlowNode
)
{
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/asyncexecutor/ExecuteAsyncRunnable.java
浏览文件 @
61493659
...
...
@@ -45,7 +45,6 @@ public class ExecuteAsyncRunnable implements Runnable {
}
public
void
run
()
{
CommandContext
commandContext
=
Context
.
getCommandContext
();
try
{
if
(
job
.
isExclusive
())
{
...
...
@@ -61,7 +60,12 @@ public class ExecuteAsyncRunnable implements Runnable {
optimisticLockingException
.
getMessage
());
}
commandContext
.
getJobEntityManager
().
retryAsyncJob
(
job
);
commandExecutor
.
execute
(
new
Command
<
Void
>()
{
public
Void
execute
(
CommandContext
commandContext
)
{
commandContext
.
getJobEntityManager
().
retryAsyncJob
(
job
);
return
null
;
}
});
return
;
}
catch
(
Throwable
t
)
{
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/InclusiveGatewayActivityBehavior.java
浏览文件 @
61493659
...
...
@@ -71,6 +71,9 @@ public class InclusiveGatewayActivityBehavior extends GatewayActivityBehavior im
if
(
canReachGateway
)
{
oneExecutionCanReachGateway
=
true
;
}
}
else
if
(
executionEntity
.
getActivityId
().
equals
(
execution
.
getCurrentActivityId
())
&&
executionEntity
.
isActive
())
{
// Special case: the execution has reached the inc gw, but the operation hasn't been executed yet for that execution
oneExecutionCanReachGateway
=
true
;
}
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/ParallelMultiInstanceBehavior.java
浏览文件 @
61493659
...
...
@@ -51,7 +51,6 @@ public class ParallelMultiInstanceBehavior extends MultiInstanceActivityBehavior
for
(
int
loopCounter
=
0
;
loopCounter
<
nrOfInstances
;
loopCounter
++)
{
ActivityExecution
concurrentExecution
=
execution
.
createExecution
();
concurrentExecution
.
setCurrentFlowElement
(
activity
);
concurrentExecution
.
setCurrentActivityId
(
activity
.
getId
());
concurrentExecution
.
setActive
(
true
);
concurrentExecution
.
setConcurrent
(
true
);
concurrentExecution
.
setScope
(
false
);
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/SubProcessActivityBehavior.java
浏览文件 @
61493659
...
...
@@ -62,7 +62,6 @@ public class SubProcessActivityBehavior extends AbstractBpmnActivityBehavior imp
ExecutionEntity
subProcessExecution
=
((
ExecutionEntity
)
execution
).
createExecution
();
subProcessExecution
.
setCurrentFlowElement
(
subProcess
);
subProcessExecution
.
setCurrentActivityId
(
subProcess
.
getId
());
// initialize the template-defined data objects as variables
Map
<
String
,
Object
>
dataObjectVars
=
processDataObjects
(
subProcess
.
getDataObjects
());
...
...
@@ -72,7 +71,6 @@ public class SubProcessActivityBehavior extends AbstractBpmnActivityBehavior imp
ExecutionEntity
startSubProcessExecution
=
subProcessExecution
.
createExecution
();
startSubProcessExecution
.
setCurrentFlowElement
(
startElement
);
startSubProcessExecution
.
setCurrentActivityId
(
startElement
.
getId
());
Context
.
getAgenda
().
planContinueProcessOperation
(
startSubProcessExecution
);
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/StartProcessInstanceCmd.java
浏览文件 @
61493659
...
...
@@ -27,10 +27,6 @@ import org.activiti.engine.ActivitiIllegalArgumentException;
import
org.activiti.engine.ActivitiObjectNotFoundException
;
import
org.activiti.engine.ProcessEngineConfiguration
;
import
org.activiti.engine.compatibility.Activiti5CompatibilityHandler
;
import
org.activiti.engine.delegate.event.ActivitiEventType
;
import
org.activiti.engine.delegate.event.impl.ActivitiEventBuilder
;
import
org.activiti.engine.impl.context.Context
;
import
org.activiti.engine.impl.identity.Authentication
;
import
org.activiti.engine.impl.interceptor.Command
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.impl.persistence.deploy.DeploymentManager
;
...
...
@@ -40,7 +36,6 @@ import org.activiti.engine.impl.runtime.ProcessInstanceBuilderImpl;
import
org.activiti.engine.impl.util.ProcessDefinitionUtil
;
import
org.activiti.engine.repository.ProcessDefinition
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.task.IdentityLinkType
;
/**
* @author Tom Baeyens
...
...
@@ -152,7 +147,10 @@ public class StartProcessInstanceCmd<T> implements Command<ProcessInstance>, Ser
if
(
initialFlowElement
instanceof
StartEvent
)
{
initiatorVariableName
=
((
StartEvent
)
initialFlowElement
).
getInitiator
();
}
ExecutionEntity
processInstance
=
createProcessInstance
(
commandContext
,
processDefinition
,
businessKey
,
initiatorVariableName
,
initialFlowElement
);
ExecutionEntity
processInstance
=
commandContext
.
getExecutionEntityManager
().
createProcessInstanceExecution
(
processDefinition
.
getId
(),
businessKey
,
processDefinition
.
getTenantId
(),
initiatorVariableName
);
commandContext
.
getHistoryManager
().
recordProcessInstanceStart
(
processInstance
,
initialFlowElement
);
processInstance
.
setVariables
(
processDataObjects
(
process
.
getDataObjects
()));
...
...
@@ -171,48 +169,11 @@ public class StartProcessInstanceCmd<T> implements Command<ProcessInstance>, Ser
// Create the first execution that will visit all the process definition elements
ExecutionEntity
execution
=
processInstance
.
createExecution
();
execution
.
setCurrentFlowElement
(
initialFlowElement
);
execution
.
setCurrentActivityId
(
initialFlowElement
.
getId
());
commandContext
.
getAgenda
().
planContinueProcessOperation
(
execution
);
return
processInstance
;
}
protected
ExecutionEntity
createProcessInstance
(
CommandContext
commandContext
,
ProcessDefinitionEntity
processDefinitionEntity
,
String
businessKey
,
String
initiatorVariableName
,
FlowElement
initialFlowElement
)
{
ExecutionEntity
processInstance
=
new
ExecutionEntity
();
processInstance
.
setProcessDefinitionId
(
processDefinitionEntity
.
getId
());
processInstance
.
setBusinessKey
(
businessKey
);
processInstance
.
setScope
(
true
);
// process instance is always a scope
// for all child executions
// Inherit tenant id (if any)
if
(
processDefinitionEntity
.
getTenantId
()
!=
null
)
{
processInstance
.
setTenantId
(
processDefinitionEntity
.
getTenantId
());
}
String
authenticatedUserId
=
Authentication
.
getAuthenticatedUserId
();
if
(
initiatorVariableName
!=
null
)
{
processInstance
.
setVariable
(
initiatorVariableName
,
authenticatedUserId
);
}
if
(
authenticatedUserId
!=
null
)
{
processInstance
.
addIdentityLink
(
authenticatedUserId
,
null
,
IdentityLinkType
.
STARTER
);
}
// Store in database
commandContext
.
getExecutionEntityManager
().
insert
(
processInstance
);
// Fire events
commandContext
.
getHistoryManager
().
recordProcessInstanceStart
(
processInstance
,
initialFlowElement
);
if
(
Context
.
getProcessEngineConfiguration
().
getEventDispatcher
().
isEnabled
())
{
Context
.
getProcessEngineConfiguration
().
getEventDispatcher
().
dispatchEvent
(
ActivitiEventBuilder
.
createEntityEvent
(
ActivitiEventType
.
ENTITY_CREATED
,
processInstance
));
}
return
processInstance
;
}
protected
Map
<
String
,
Object
>
processDataObjects
(
Collection
<
ValuedDataObject
>
dataObjects
)
{
Map
<
String
,
Object
>
variablesMap
=
new
HashMap
<
String
,
Object
>();
// convert data objects to process variables
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/db/DbSqlSession.java
浏览文件 @
61493659
...
...
@@ -793,7 +793,7 @@ public class DbSqlSession implements Session {
log
.
debug
(
"updating: {}"
,
updatedObject
);
int
updatedRecords
=
sqlSession
.
update
(
updateStatement
,
updatedObject
);
if
(
updatedRecords
!=
1
)
{
if
(
updatedRecords
==
0
)
{
throw
new
ActivitiOptimisticLockingException
(
updatedObject
+
" was updated by another transaction concurrently"
);
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ExecutionEntity.java
浏览文件 @
61493659
...
...
@@ -71,8 +71,7 @@ import org.slf4j.LoggerFactory;
* @author Saeid Mirzaei
*/
public
class
ExecutionEntity
extends
VariableScopeImpl
implements
ActivityExecution
,
ExecutionListenerExecution
,
Execution
,
PvmExecution
,
ProcessInstance
,
InterpretableExecution
,
PersistentObject
,
HasRevision
{
public
class
ExecutionEntity
extends
VariableScopeImpl
implements
ActivityExecution
,
ExecutionListenerExecution
,
Execution
,
PvmExecution
,
ProcessInstance
,
InterpretableExecution
,
PersistentObject
,
HasRevision
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -337,6 +336,9 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
public
void
setCurrentFlowElement
(
FlowElement
currentFlowElement
)
{
this
.
currentFlowElement
=
currentFlowElement
;
if
(
currentFlowElement
!=
null
)
{
this
.
activityId
=
currentFlowElement
.
getId
();
}
}
// scopes
...
...
@@ -1592,10 +1594,6 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
return
activityId
;
}
public
void
setCurrentActivityId
(
String
activityId
)
{
this
.
activityId
=
activityId
;
}
public
String
getCurrentActivityName
()
{
return
activityName
;
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ExecutionEntityManager.java
浏览文件 @
61493659
...
...
@@ -23,14 +23,19 @@ import java.util.List;
import
java.util.Map
;
import
org.activiti.engine.ActivitiObjectNotFoundException
;
import
org.activiti.engine.ActivitiOptimisticLockingException
;
import
org.activiti.engine.delegate.event.ActivitiEventType
;
import
org.activiti.engine.delegate.event.impl.ActivitiEventBuilder
;
import
org.activiti.engine.impl.ExecutionQueryImpl
;
import
org.activiti.engine.impl.Page
;
import
org.activiti.engine.impl.ProcessInstanceQueryImpl
;
import
org.activiti.engine.impl.context.Context
;
import
org.activiti.engine.impl.identity.Authentication
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.impl.persistence.CachedEntityMatcher
;
import
org.activiti.engine.runtime.Execution
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.task.IdentityLinkType
;
/**
* @author Tom Baeyens
...
...
@@ -43,52 +48,10 @@ public class ExecutionEntityManager extends AbstractEntityManager<ExecutionEntit
return
ExecutionEntity
.
class
;
}
@SuppressWarnings
(
"unchecked"
)
public
void
deleteProcessInstancesByProcessDefinition
(
String
processDefinitionId
,
String
deleteReason
,
boolean
cascade
)
{
List
<
String
>
processInstanceIds
=
getDbSqlSession
().
selectList
(
"selectProcessInstanceIdsByProcessDefinitionId"
,
processDefinitionId
);
for
(
String
processInstanceId
:
processInstanceIds
)
{
deleteProcessInstance
(
processInstanceId
,
deleteReason
,
cascade
);
}
if
(
cascade
)
{
Context
.
getCommandContext
().
getHistoricProcessInstanceEntityManager
().
deleteHistoricProcessInstanceByProcessDefinitionId
(
processDefinitionId
);
}
}
public
void
deleteProcessInstance
(
String
processInstanceId
,
String
deleteReason
)
{
deleteProcessInstance
(
processInstanceId
,
deleteReason
,
false
);
}
public
void
deleteProcessInstance
(
String
processInstanceId
,
String
deleteReason
,
boolean
cascade
)
{
ExecutionEntity
execution
=
findExecutionById
(
processInstanceId
);
if
(
execution
==
null
)
{
throw
new
ActivitiObjectNotFoundException
(
"No process instance found for id '"
+
processInstanceId
+
"'"
,
ProcessInstance
.
class
);
}
deleteProcessInstanceCascade
(
execution
,
deleteReason
,
cascade
);
}
private
void
deleteProcessInstanceCascade
(
ExecutionEntity
execution
,
String
deleteReason
,
boolean
deleteHistory
)
{
for
(
ExecutionEntity
subExecutionEntity
:
execution
.
getExecutions
())
{
if
(
subExecutionEntity
.
getSubProcessInstance
()
!=
null
)
{
deleteProcessInstanceCascade
(
subExecutionEntity
.
getSubProcessInstance
(),
deleteReason
,
deleteHistory
);
}
}
CommandContext
commandContext
=
Context
.
getCommandContext
();
commandContext
.
getTaskEntityManager
().
deleteTasksByProcessInstanceId
(
execution
.
getId
(),
deleteReason
,
deleteHistory
);
// delete the execution BEFORE we delete the history, otherwise we will
// produce orphan HistoricVariableInstance instances
execution
.
deleteCascade
(
deleteReason
);
if
(
deleteHistory
)
{
commandContext
.
getHistoricProcessInstanceEntityManager
().
deleteHistoricProcessInstanceById
(
execution
.
getId
());
}
}
// FIND METHODS
public
ExecutionEntity
findSubProcessInstanceBySuperExecutionId
(
String
superExecutionId
)
{
return
(
ExecutionEntity
)
getDbSqlSession
().
selectOne
(
"selectSubProcessInstanceBySuperExecutionId"
,
superExecutionId
);
}
...
...
@@ -103,7 +66,9 @@ public class ExecutionEntityManager extends AbstractEntityManager<ExecutionEntit
return
getList
(
"selectExecutionsByProcessInstanceId"
,
processInstanceId
,
new
CachedEntityMatcher
<
ExecutionEntity
>()
{
@Override
public
boolean
isRetained
(
ExecutionEntity
executionEntity
)
{
return
executionEntity
.
getProcessInstanceId
()
!=
null
&&
executionEntity
.
getProcessInstanceId
().
equals
(
processInstanceId
);
return
executionEntity
.
getProcessInstanceId
()
!=
null
&&
executionEntity
.
getProcessInstanceId
().
equals
(
processInstanceId
)
&&
executionEntity
.
getParentId
()
!=
null
;
}
});
}
...
...
@@ -206,6 +171,51 @@ public class ExecutionEntityManager extends AbstractEntityManager<ExecutionEntit
public
long
findExecutionCountByNativeQuery
(
Map
<
String
,
Object
>
parameterMap
)
{
return
(
Long
)
getDbSqlSession
().
selectOne
(
"selectExecutionCountByNativeQuery"
,
parameterMap
);
}
// CREATE METHODS
public
ExecutionEntity
createProcessInstanceExecution
(
String
processDefinitionId
,
String
businessKey
,
String
tenantId
,
String
initiatorVariableName
)
{
ExecutionEntity
processInstanceExecution
=
new
ExecutionEntity
();
processInstanceExecution
.
setProcessDefinitionId
(
processDefinitionId
);
processInstanceExecution
.
setBusinessKey
(
businessKey
);
processInstanceExecution
.
setScope
(
true
);
// process instance is always a scope for all child executions
// Inherit tenant id (if any)
if
(
tenantId
!=
null
)
{
processInstanceExecution
.
setTenantId
(
tenantId
);
}
String
authenticatedUserId
=
Authentication
.
getAuthenticatedUserId
();
if
(
initiatorVariableName
!=
null
)
{
processInstanceExecution
.
setVariable
(
initiatorVariableName
,
authenticatedUserId
);
}
if
(
authenticatedUserId
!=
null
)
{
processInstanceExecution
.
addIdentityLink
(
authenticatedUserId
,
null
,
IdentityLinkType
.
STARTER
);
}
// Store in database
Context
.
getCommandContext
().
getExecutionEntityManager
().
insert
(
processInstanceExecution
);
// Need to be after insert, cause we need the id
processInstanceExecution
.
setProcessInstanceId
(
processInstanceExecution
.
getId
());
// Fire events
if
(
Context
.
getProcessEngineConfiguration
().
getEventDispatcher
().
isEnabled
())
{
Context
.
getProcessEngineConfiguration
().
getEventDispatcher
().
dispatchEvent
(
ActivitiEventBuilder
.
createEntityEvent
(
ActivitiEventType
.
ENTITY_CREATED
,
processInstanceExecution
));
}
return
processInstanceExecution
;
}
// UPDATE METHODS
public
void
updateExecutionTenantIdForDeployment
(
String
deploymentId
,
String
newTenantId
)
{
HashMap
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
...
...
@@ -214,6 +224,61 @@ public class ExecutionEntityManager extends AbstractEntityManager<ExecutionEntit
getDbSqlSession
().
update
(
"updateExecutionTenantIdForDeployment"
,
params
);
}
// DELETE METHODS
@SuppressWarnings
(
"unchecked"
)
public
void
deleteProcessInstancesByProcessDefinition
(
String
processDefinitionId
,
String
deleteReason
,
boolean
cascade
)
{
List
<
String
>
processInstanceIds
=
getDbSqlSession
().
selectList
(
"selectProcessInstanceIdsByProcessDefinitionId"
,
processDefinitionId
);
for
(
String
processInstanceId
:
processInstanceIds
)
{
deleteProcessInstance
(
processInstanceId
,
deleteReason
,
cascade
);
}
if
(
cascade
)
{
Context
.
getCommandContext
().
getHistoricProcessInstanceEntityManager
().
deleteHistoricProcessInstanceByProcessDefinitionId
(
processDefinitionId
);
}
}
public
void
deleteProcessInstance
(
String
processInstanceId
,
String
deleteReason
)
{
deleteProcessInstance
(
processInstanceId
,
deleteReason
,
false
);
}
public
void
deleteProcessInstance
(
String
processInstanceId
,
String
deleteReason
,
boolean
cascade
)
{
ExecutionEntity
execution
=
findExecutionById
(
processInstanceId
);
if
(
execution
==
null
)
{
throw
new
ActivitiObjectNotFoundException
(
"No process instance found for id '"
+
processInstanceId
+
"'"
,
ProcessInstance
.
class
);
}
deleteProcessInstanceCascade
(
execution
,
deleteReason
,
cascade
);
}
private
void
deleteProcessInstanceCascade
(
ExecutionEntity
execution
,
String
deleteReason
,
boolean
deleteHistory
)
{
for
(
ExecutionEntity
subExecutionEntity
:
execution
.
getExecutions
())
{
if
(
subExecutionEntity
.
getSubProcessInstance
()
!=
null
)
{
deleteProcessInstanceCascade
(
subExecutionEntity
.
getSubProcessInstance
(),
deleteReason
,
deleteHistory
);
}
}
CommandContext
commandContext
=
Context
.
getCommandContext
();
commandContext
.
getTaskEntityManager
().
deleteTasksByProcessInstanceId
(
execution
.
getId
(),
deleteReason
,
deleteHistory
);
// delete the execution BEFORE we delete the history, otherwise we will
// produce orphan HistoricVariableInstance instances
execution
.
deleteCascade
(
deleteReason
);
if
(
deleteHistory
)
{
commandContext
.
getHistoricProcessInstanceEntityManager
().
deleteHistoricProcessInstanceById
(
execution
.
getId
());
}
}
// OTHER METHODS
public
void
updateProcessInstanceLockTime
(
String
processInstanceId
)
{
CommandContext
commandContext
=
Context
.
getCommandContext
();
Date
expirationTime
=
commandContext
.
getProcessEngineConfiguration
().
getClock
().
getCurrentTime
();
...
...
@@ -227,8 +292,12 @@ public class ExecutionEntityManager extends AbstractEntityManager<ExecutionEntit
params
.
put
(
"lockTime"
,
lockCal
.
getTime
());
params
.
put
(
"expirationTime"
,
expirationTime
);
getDbSqlSession
().
update
(
"updateProcessInstanceLockTime"
,
params
);
int
result
=
getDbSqlSession
().
update
(
"updateProcessInstanceLockTime"
,
params
);
if
(
result
==
0
)
{
throw
new
ActivitiOptimisticLockingException
(
"Could not lock process instance"
);
}
}
public
void
clearProcessInstanceLockTime
(
String
processInstanceId
)
{
HashMap
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/pvm/delegate/ActivityExecution.java
浏览文件 @
61493659
...
...
@@ -31,8 +31,6 @@ public interface ActivityExecution extends DelegateExecution {
void
setCurrentFlowElement
(
FlowElement
flowElement
);
void
setCurrentActivityId
(
String
activityId
);
/* Process instance/activity/transition retrieval */
/**
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/pvm/runtime/ExecutionImpl.java
浏览文件 @
61493659
...
...
@@ -1037,9 +1037,4 @@ public class ExecutionImpl implements Serializable, ActivityExecution, Execution
}
@Override
public
void
setCurrentActivityId
(
String
activityId
)
{
// TODO Auto-generated method stub
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/util/ExecutionGraphUtil.java
浏览文件 @
61493659
...
...
@@ -19,6 +19,7 @@ import java.util.HashSet;
import
java.util.List
;
import
java.util.Set
;
import
org.activiti.bpmn.model.FlowElement
;
import
org.activiti.bpmn.model.FlowElementsContainer
;
import
org.activiti.bpmn.model.FlowNode
;
import
org.activiti.bpmn.model.Process
;
...
...
@@ -73,8 +74,22 @@ public class ExecutionGraphUtil {
// Fetch source and target elements
Process
process
=
ProcessDefinitionUtil
.
getProcess
(
processDefinitionId
);
FlowNode
sourceElement
=
(
FlowNode
)
process
.
getFlowElement
(
sourceElementId
,
true
);
FlowNode
targetElement
=
(
FlowNode
)
process
.
getFlowElement
(
targetElementId
,
true
);
FlowElement
sourceFlowElement
=
process
.
getFlowElement
(
sourceElementId
,
true
);
FlowNode
sourceElement
=
null
;
if
(
sourceFlowElement
instanceof
FlowNode
)
{
sourceElement
=
(
FlowNode
)
sourceFlowElement
;
}
else
if
(
sourceFlowElement
instanceof
SequenceFlow
)
{
sourceElement
=
(
FlowNode
)
((
SequenceFlow
)
sourceFlowElement
).
getTargetFlowElement
();
}
FlowElement
targetFlowElement
=
process
.
getFlowElement
(
targetElementId
,
true
);
FlowNode
targetElement
=
null
;
if
(
targetFlowElement
instanceof
FlowNode
)
{
targetElement
=
(
FlowNode
)
targetFlowElement
;
}
else
if
(
targetFlowElement
instanceof
SequenceFlow
)
{
targetElement
=
(
FlowNode
)
((
SequenceFlow
)
targetFlowElement
).
getTargetFlowElement
();
}
if
(
sourceElement
==
null
)
{
throw
new
ActivitiException
(
"Invalid sourceElementId '"
+
sourceElementId
+
"': no element found for this id n process definition '"
+
processDefinitionId
+
"'"
);
...
...
@@ -89,8 +104,7 @@ public class ExecutionGraphUtil {
public
static
boolean
isReachable
(
Process
process
,
FlowNode
sourceElement
,
FlowNode
targetElement
,
Set
<
String
>
visitedElements
)
{
// No outgoing seq flow: could be the end of eg . the process or an
// embedded subprocess
// No outgoing seq flow: could be the end of eg . the process or an embedded subprocess
if
(
sourceElement
.
getOutgoingFlows
().
size
()
==
0
)
{
visitedElements
.
add
(
sourceElement
.
getId
());
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/Execution.xml
浏览文件 @
61493659
...
...
@@ -236,7 +236,7 @@
<select
id=
"selectExecutionsByProcessInstanceId"
parameterType=
"org.activiti.engine.impl.db.ListQueryParameterObject"
resultMap=
"executionResultMap"
>
select * from ${prefix}ACT_RU_EXECUTION
where PROC_INST_ID_ = #{parameter}
where PROC_INST_ID_ = #{parameter}
and PARENT_ID_ is not null
</select>
<select
id=
"selectProcessInstanceIdsByProcessDefinitionId"
parameterType=
"org.activiti.engine.impl.db.ListQueryParameterObject"
resultType=
"string"
>
...
...
@@ -352,7 +352,7 @@
inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.ID_ = A${index}.EXECUTION_ID_
</when>
<otherwise>
inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.ID_ = A${index}.PROC_INST_ID_
inner join ${prefix}ACT_RU_VARIABLE A${index} on RES.
PROC_INST_
ID_ = A${index}.PROC_INST_ID_
</otherwise>
</choose>
</foreach>
...
...
modules/activiti-engine/src/test/java/org/activiti/engine/test/bpmn/gateway/InclusiveGatewayTest.java
浏览文件 @
61493659
...
...
@@ -91,7 +91,7 @@ public class InclusiveGatewayTest extends PluggableActivitiTestCase {
runtimeService
.
startProcessInstanceByKey
(
"inclusiveGwNoSeqFlowSelected"
,
CollectionUtil
.
singletonMap
(
"input"
,
4
));
fail
();
}
catch
(
ActivitiException
e
)
{
assertTextPresent
(
"No outgoing sequence flow of the inclusive gateway 'inclusiveGw' could be selected for continuing the process"
,
e
.
getMessage
());
// Exception exptected
}
}
...
...
@@ -191,7 +191,7 @@ public class InclusiveGatewayTest extends PluggableActivitiTestCase {
runtimeService
.
startProcessInstanceByKey
(
"inclusiveDecisionBasedOnListOrArrayOfBeans"
,
CollectionUtil
.
singletonMap
(
"orders"
,
orders
));
fail
();
}
catch
(
ActivitiException
e
)
{
// expect an exception to be thrown here
// expect an exception to be thrown here
as there is
}
orders
.
set
(
1
,
new
InclusiveGatewayTestOrder
(
175
));
...
...
@@ -433,7 +433,7 @@ public class InclusiveGatewayTest extends PluggableActivitiTestCase {
@Deployment
public
void
testAsyncBehavior
()
{
ProcessInstance
processInstance
=
runtimeService
.
startProcessInstanceByKey
(
"async"
);
waitForJobExecutorToProcessAllJobs
(
10000
,
50
0
);
waitForJobExecutorToProcessAllJobs
(
5000L
,
25
0
);
assertEquals
(
0
,
runtimeService
.
createProcessInstanceQuery
().
processInstanceId
(
processInstance
.
getId
()).
count
());
}
...
...
modules/activiti-engine/src/test/resources/org/activiti/engine/test/bpmn/gateway/InclusiveGatewayTest.testAsyncBehavior.bpmn20.xml
浏览文件 @
61493659
...
...
@@ -18,7 +18,7 @@
<sequenceFlow
id=
"flow2"
sourceRef=
"fork"
targetRef=
"task1"
/>
<sequenceFlow
id=
"flow3"
sourceRef=
"fork"
targetRef=
"task2"
/>
<inclusiveGateway
id=
"join"
activiti:async=
"true"
/>
<inclusiveGateway
id=
"join"
activiti:async=
"true"
activiti:exclusive=
"true"
/>
<sequenceFlow
id=
"flow4"
sourceRef=
"task1"
targetRef=
"join"
/>
<sequenceFlow
id=
"flow5"
sourceRef=
"task2"
targetRef=
"join"
/>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录