Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
fc00a23f
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,发现更多精彩内容 >>
提交
fc00a23f
编写于
2月 27, 2013
作者:
T
tijsrademakers
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/Activiti/Activiti
上级
3f224a32
a20fcdb4
变更
32
隐藏空白更改
内联
并排
Showing
32 changed file
with
578 addition
and
27 deletion
+578
-27
modules/activiti-engine/src/main/java/org/activiti/engine/RuntimeService.java
...ine/src/main/java/org/activiti/engine/RuntimeService.java
+21
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/ExecutionQueryImpl.java
...ain/java/org/activiti/engine/impl/ExecutionQueryImpl.java
+7
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java
...va/org/activiti/engine/impl/ProcessInstanceQueryImpl.java
+11
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/RuntimeServiceImpl.java
...ain/java/org/activiti/engine/impl/RuntimeServiceImpl.java
+11
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkCmd.java
...java/org/activiti/engine/impl/cmd/AddIdentityLinkCmd.java
+2
-5
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkForProcessInstanceCmd.java
...engine/impl/cmd/AddIdentityLinkForProcessInstanceCmd.java
+70
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetIdentityLinksForProcessDefinitionCmd.java
...ine/impl/cmd/GetIdentityLinksForProcessDefinitionCmd.java
+0
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetIdentityLinksForProcessInstanceCmd.java
...ngine/impl/cmd/GetIdentityLinksForProcessInstanceCmd.java
+53
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ExecutionEntity.java
...iviti/engine/impl/persistence/entity/ExecutionEntity.java
+45
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/IdentityLinkEntity.java
...ti/engine/impl/persistence/entity/IdentityLinkEntity.java
+27
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/IdentityLinkEntityManager.java
...ne/impl/persistence/entity/IdentityLinkEntityManager.java
+13
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ProcessDefinitionEntity.java
...gine/impl/persistence/entity/ProcessDefinitionEntity.java
+4
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/TaskEntity.java
...g/activiti/engine/impl/persistence/entity/TaskEntity.java
+27
-11
modules/activiti-engine/src/main/java/org/activiti/engine/runtime/ProcessInstanceQuery.java
...ava/org/activiti/engine/runtime/ProcessInstanceQuery.java
+8
-3
modules/activiti-engine/src/main/java/org/activiti/engine/task/IdentityLinkType.java
.../main/java/org/activiti/engine/task/IdentityLinkType.java
+4
-0
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.db2.create.engine.sql
...ces/org/activiti/db/create/activiti.db2.create.engine.sql
+6
-0
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.h2.create.engine.sql
...rces/org/activiti/db/create/activiti.h2.create.engine.sql
+6
-0
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.mssql.create.engine.sql
...s/org/activiti/db/create/activiti.mssql.create.engine.sql
+6
-0
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.mysql.create.engine.sql
...s/org/activiti/db/create/activiti.mysql.create.engine.sql
+6
-0
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.oracle.create.engine.sql
.../org/activiti/db/create/activiti.oracle.create.engine.sql
+7
-0
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.postgres.create.engine.sql
...rg/activiti/db/create/activiti.postgres.create.engine.sql
+7
-0
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/Execution.xml
...in/resources/org/activiti/db/mapping/entity/Execution.xml
+7
-1
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/IdentityLink.xml
...resources/org/activiti/db/mapping/entity/IdentityLink.xml
+7
-1
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.db2.upgradestep.511.to.512.history.sql
...b/upgrade/activiti.db2.upgradestep.511.to.512.history.sql
+11
-0
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.h2.upgradestep.511.to.512.history.sql
...db/upgrade/activiti.h2.upgradestep.511.to.512.history.sql
+8
-0
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.mssql.upgradestep.511.to.512.history.sql
...upgrade/activiti.mssql.upgradestep.511.to.512.history.sql
+8
-0
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.mysql.upgradestep.511.to.512.history.sql
...upgrade/activiti.mysql.upgradestep.511.to.512.history.sql
+8
-0
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.oracle.upgradestep.511.to.512.history.sql
...pgrade/activiti.oracle.upgradestep.511.to.512.history.sql
+9
-0
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.postgres.upgradestep.511.to.512.history.sql
...rade/activiti.postgres.upgradestep.511.to.512.history.sql
+11
-0
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/runtime/InstanceInvolvementTest.java
...viti/engine/test/api/runtime/InstanceInvolvementTest.java
+135
-0
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/runtime/ProcessInstanceQueryTest.java
...iti/engine/test/api/runtime/ProcessInstanceQueryTest.java
+1
-1
modules/activiti-engine/src/test/resources/org/activiti/engine/test/api/runtime/threeParallelTasks.bpmn20.xml
...iti/engine/test/api/runtime/threeParallelTasks.bpmn20.xml
+32
-0
未找到文件。
modules/activiti-engine/src/main/java/org/activiti/engine/RuntimeService.java
浏览文件 @
fc00a23f
...
...
@@ -22,6 +22,8 @@ import org.activiti.engine.runtime.NativeExecutionQuery;
import
org.activiti.engine.runtime.NativeProcessInstanceQuery
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.runtime.ProcessInstanceQuery
;
import
org.activiti.engine.task.IdentityLink
;
import
org.activiti.engine.task.IdentityLinkType
;
/**
...
...
@@ -265,6 +267,24 @@ public interface RuntimeService {
*/
void
signal
(
String
executionId
,
Map
<
String
,
Object
>
processVariables
);
// Identity Links ///////////////////////////////////////////////////////////////
/**
* Involves a user with a process instance. The type of identity link is defined by the
* given identityLinkType.
* @param processInstanceId id of the process instance, cannot be null.
* @param userId id of the user involve, cannot be null.
* @param identityLinkType type of identityLink, cannot be null (@see {@link IdentityLinkType}).
* @throws ActivitiObjectNotFoundException when the process instance doesn't exist.
*/
void
addUserIdentityLink
(
String
processInstanceId
,
String
userId
,
String
identityLinkType
);
/**
* Retrieves the {@link IdentityLink}s associated with the given process instance.
* Such an {@link IdentityLink} informs how a certain user is involved with a process instance.
*/
List
<
IdentityLink
>
getIdentityLinksForProcessInstance
(
String
instanceId
);
// Variables ////////////////////////////////////////////////////////////////////
/** All variables visible from the given execution scope (including parent scopes).
...
...
@@ -511,5 +531,5 @@ public interface RuntimeService {
* @throws ActivitiException if the execution has not subscribed to the signal
*/
void
messageEventReceived
(
String
messageName
,
String
executionId
,
Map
<
String
,
Object
>
processVariables
);
}
\ No newline at end of file
modules/activiti-engine/src/main/java/org/activiti/engine/impl/ExecutionQueryImpl.java
浏览文件 @
fc00a23f
...
...
@@ -46,6 +46,7 @@ public class ExecutionQueryImpl extends AbstractVariableQueryImpl<ExecutionQuery
protected
SuspensionState
suspensionState
;
protected
String
businessKey
;
protected
boolean
isActive
;
protected
String
involvedUser
;
public
ExecutionQueryImpl
()
{
...
...
@@ -223,5 +224,11 @@ public class ExecutionQueryImpl extends AbstractVariableQueryImpl<ExecutionQuery
public
boolean
isActive
()
{
return
isActive
;
}
public
String
getInvolvedUser
()
{
return
involvedUser
;
}
public
void
setInvolvedUser
(
String
involvedUser
)
{
this
.
involvedUser
=
involvedUser
;
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/ProcessInstanceQueryImpl.java
浏览文件 @
fc00a23f
...
...
@@ -43,6 +43,7 @@ public class ProcessInstanceQueryImpl extends AbstractVariableQueryImpl<ProcessI
protected
String
processDefinitionKey
;
protected
String
superProcessInstanceId
;
protected
String
subProcessInstanceId
;
protected
String
involvedUser
;
protected
SuspensionState
suspensionState
;
// Unused, see dynamic query
...
...
@@ -122,6 +123,13 @@ public class ProcessInstanceQueryImpl extends AbstractVariableQueryImpl<ProcessI
return
this
;
}
public
ProcessInstanceQuery
involvedUser
(
String
involvedUser
)
{
if
(
involvedUser
==
null
)
{
throw
new
ActivitiIllegalArgumentException
(
"Involved user is null"
);
}
this
.
involvedUser
=
involvedUser
;
return
this
;
}
public
ProcessInstanceQuery
orderByProcessInstanceId
()
{
this
.
orderProperty
=
ProcessInstanceQueryProperty
.
PROCESS_INSTANCE_ID
;
...
...
@@ -195,6 +203,9 @@ public class ProcessInstanceQueryImpl extends AbstractVariableQueryImpl<ProcessI
public
String
getSubProcessInstanceId
()
{
return
subProcessInstanceId
;
}
public
String
getInvolvedUser
()
{
return
involvedUser
;
}
public
SuspensionState
getSuspensionState
()
{
return
suspensionState
;
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/RuntimeServiceImpl.java
浏览文件 @
fc00a23f
...
...
@@ -18,15 +18,16 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
org.activiti.engine.ActivitiException
;
import
org.activiti.engine.ActivitiIllegalArgumentException
;
import
org.activiti.engine.RuntimeService
;
import
org.activiti.engine.form.FormData
;
import
org.activiti.engine.impl.cmd.ActivateProcessInstanceCmd
;
import
org.activiti.engine.impl.cmd.AddIdentityLinkForProcessInstanceCmd
;
import
org.activiti.engine.impl.cmd.DeleteProcessInstanceCmd
;
import
org.activiti.engine.impl.cmd.FindActiveActivityIdsCmd
;
import
org.activiti.engine.impl.cmd.GetExecutionVariableCmd
;
import
org.activiti.engine.impl.cmd.GetExecutionVariablesCmd
;
import
org.activiti.engine.impl.cmd.GetIdentityLinksForProcessInstanceCmd
;
import
org.activiti.engine.impl.cmd.GetStartFormCmd
;
import
org.activiti.engine.impl.cmd.MessageEventReceivedCmd
;
import
org.activiti.engine.impl.cmd.RemoveExecutionVariablesCmd
;
...
...
@@ -41,6 +42,7 @@ import org.activiti.engine.runtime.NativeExecutionQuery;
import
org.activiti.engine.runtime.NativeProcessInstanceQuery
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.runtime.ProcessInstanceQuery
;
import
org.activiti.engine.task.IdentityLink
;
/**
* @author Tom Baeyens
...
...
@@ -175,6 +177,14 @@ public class RuntimeServiceImpl extends ServiceImpl implements RuntimeService {
commandExecutor
.
execute
(
new
SignalCmd
(
executionId
,
null
,
null
,
processVariables
));
}
public
void
addUserIdentityLink
(
String
processInstanceId
,
String
userId
,
String
identityLinkType
)
{
commandExecutor
.
execute
(
new
AddIdentityLinkForProcessInstanceCmd
(
processInstanceId
,
userId
,
identityLinkType
));
}
public
List
<
IdentityLink
>
getIdentityLinksForProcessInstance
(
String
processInstanceId
)
{
return
commandExecutor
.
execute
(
new
GetIdentityLinksForProcessInstanceCmd
(
processInstanceId
));
}
public
ProcessInstanceQuery
createProcessInstanceQuery
()
{
return
new
ProcessInstanceQueryImpl
(
commandExecutor
);
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkCmd.java
浏览文件 @
fc00a23f
...
...
@@ -74,13 +74,10 @@ public class AddIdentityLinkCmd extends NeedsActiveTaskCmd<Void> {
task
.
addIdentityLink
(
userId
,
groupId
,
type
);
}
if
(
assignedToNoOne
)
{
if
(
assignedToNoOne
)
{
// ACT-1317: Special handling when assignee is set to NULL, a CommentEntity notifying of assignee-delete should be created
commandContext
.
getHistoryManager
().
createIdentityLinkComment
(
taskId
,
userId
,
groupId
,
type
,
false
,
true
);
}
else
{
}
else
{
commandContext
.
getHistoryManager
().
createIdentityLinkComment
(
taskId
,
userId
,
groupId
,
type
,
true
);
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkForProcessInstanceCmd.java
0 → 100644
浏览文件 @
fc00a23f
/* 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.
*/
package
org.activiti.engine.impl.cmd
;
import
java.io.Serializable
;
import
org.activiti.engine.ActivitiIllegalArgumentException
;
import
org.activiti.engine.ActivitiObjectNotFoundException
;
import
org.activiti.engine.impl.context.Context
;
import
org.activiti.engine.impl.interceptor.Command
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.impl.persistence.entity.ExecutionEntity
;
/**
* @author Marcus Klimstra
*/
public
class
AddIdentityLinkForProcessInstanceCmd
implements
Command
<
Void
>,
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
protected
String
processInstanceId
;
protected
String
userId
;
protected
String
type
;
public
AddIdentityLinkForProcessInstanceCmd
(
String
processInstanceId
,
String
userId
,
String
type
)
{
validateParams
(
processInstanceId
,
userId
);
this
.
processInstanceId
=
processInstanceId
;
this
.
userId
=
userId
;
this
.
type
=
type
;
}
protected
void
validateParams
(
String
processInstanceId
,
String
userId
)
{
if
(
processInstanceId
==
null
)
{
throw
new
ActivitiIllegalArgumentException
(
"processInstanceId is null"
);
}
if
(
userId
==
null
)
{
throw
new
ActivitiIllegalArgumentException
(
"userId cannot be null"
);
}
}
public
Void
execute
(
CommandContext
commandContext
)
{
ExecutionEntity
processInstance
=
Context
.
getCommandContext
()
.
getExecutionEntityManager
()
.
findExecutionById
(
processInstanceId
);
if
(
processInstance
==
null
)
{
throw
new
ActivitiObjectNotFoundException
(
"Cannot find process instance with id "
+
processInstanceId
,
ExecutionEntity
.
class
);
}
processInstance
.
addIdentityLink
(
userId
,
type
);
return
null
;
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetIdentityLinksForProcessDefinitionCmd.java
浏览文件 @
fc00a23f
...
...
@@ -15,7 +15,6 @@ package org.activiti.engine.impl.cmd;
import
java.io.Serializable
;
import
java.util.List
;
import
org.activiti.engine.ActivitiException
;
import
org.activiti.engine.ActivitiObjectNotFoundException
;
import
org.activiti.engine.impl.context.Context
;
import
org.activiti.engine.impl.interceptor.Command
;
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/GetIdentityLinksForProcessInstanceCmd.java
0 → 100644
浏览文件 @
fc00a23f
/* 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.
*/
package
org.activiti.engine.impl.cmd
;
import
java.io.Serializable
;
import
java.util.List
;
import
org.activiti.engine.ActivitiObjectNotFoundException
;
import
org.activiti.engine.impl.context.Context
;
import
org.activiti.engine.impl.interceptor.Command
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.impl.persistence.entity.ExecutionEntity
;
import
org.activiti.engine.task.IdentityLink
;
/**
* @author Marcus Klimstra
*/
public
class
GetIdentityLinksForProcessInstanceCmd
implements
Command
<
List
<
IdentityLink
>>,
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
protected
String
processInstanceId
;
public
GetIdentityLinksForProcessInstanceCmd
(
String
processInstanceId
)
{
this
.
processInstanceId
=
processInstanceId
;
}
@SuppressWarnings
({
"unchecked"
,
"rawtypes"
})
public
List
<
IdentityLink
>
execute
(
CommandContext
commandContext
)
{
ExecutionEntity
processInstance
=
Context
.
getCommandContext
()
.
getExecutionEntityManager
()
.
findExecutionById
(
processInstanceId
);
if
(
processInstance
==
null
)
{
throw
new
ActivitiObjectNotFoundException
(
"Cannot find process definition with id "
+
processInstanceId
,
ExecutionEntity
.
class
);
}
return
(
List
)
processInstance
.
getIdentityLinks
();
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ExecutionEntity.java
浏览文件 @
fc00a23f
...
...
@@ -131,6 +131,7 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
protected
List
<
EventSubscriptionEntity
>
eventSubscriptions
;
protected
List
<
JobEntity
>
jobs
;
protected
List
<
TaskEntity
>
tasks
;
protected
List
<
IdentityLinkEntity
>
identityLinks
;
protected
int
cachedEntityState
;
// cascade deletion ////////////////////////////////////////////////////////
...
...
@@ -831,6 +832,9 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
// remove event scopes:
removeEventScopes
();
// remove identity links
removeIdentityLinks
();
// finally delete this execution
Context
.
getCommandContext
()
...
...
@@ -1180,7 +1184,48 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
getTasksInternal
().
remove
(
task
);
}
// identity links ///////////////////////////////////////////////////////////
public
List
<
IdentityLinkEntity
>
getIdentityLinks
()
{
if
(
identityLinks
==
null
)
{
identityLinks
=
Context
.
getCommandContext
()
.
getIdentityLinkEntityManager
()
.
findIdentityLinksByProcessInstanceId
(
id
);
}
return
identityLinks
;
}
public
IdentityLinkEntity
addIdentityLink
(
String
userId
,
String
type
)
{
IdentityLinkEntity
identityLinkEntity
=
IdentityLinkEntity
.
createAndInsert
();
getIdentityLinks
().
add
(
identityLinkEntity
);
identityLinkEntity
.
setProcessInstance
(
this
);
identityLinkEntity
.
setUserId
(
userId
);
identityLinkEntity
.
setType
(
type
);
return
identityLinkEntity
;
}
/**
* Adds an IdentityLink for this user with the specified type,
* but only if the user is not associated with this instance yet.
**/
public
IdentityLinkEntity
involveUser
(
String
userId
,
String
type
)
{
for
(
IdentityLinkEntity
identityLink
:
getIdentityLinks
())
{
if
(
identityLink
.
getUserId
().
equals
(
userId
))
{
return
identityLink
;
}
}
return
addIdentityLink
(
userId
,
type
);
}
public
void
removeIdentityLinks
()
{
Context
.
getCommandContext
()
.
getIdentityLinkEntityManager
()
.
deleteIdentityLinksByProcInstance
(
id
);
}
// getters and setters //////////////////////////////////////////////////////
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/IdentityLinkEntity.java
浏览文件 @
fc00a23f
...
...
@@ -37,10 +37,14 @@ public class IdentityLinkEntity implements Serializable, IdentityLink, Persisten
protected
String
taskId
;
protected
String
processInstanceId
;
protected
String
processDefId
;
protected
TaskEntity
task
;
protected
ExecutionEntity
processInstance
;
protected
ProcessDefinitionEntity
processDef
;
public
Object
getPersistentState
()
{
...
...
@@ -109,6 +113,14 @@ public class IdentityLinkEntity implements Serializable, IdentityLink, Persisten
void
setTaskId
(
String
taskId
)
{
this
.
taskId
=
taskId
;
}
public
String
getProcessInstanceId
()
{
return
processInstanceId
;
}
public
void
setProcessInstanceId
(
String
processInstanceId
)
{
this
.
processInstanceId
=
processInstanceId
;
}
public
String
getProcessDefId
()
{
return
processDefId
;
...
...
@@ -132,6 +144,21 @@ public class IdentityLinkEntity implements Serializable, IdentityLink, Persisten
this
.
task
=
task
;
this
.
taskId
=
task
.
getId
();
}
public
ExecutionEntity
getProcessInstance
()
{
if
((
processInstance
==
null
)
&&
(
processInstanceId
!=
null
))
{
this
.
processInstance
=
Context
.
getCommandContext
()
.
getExecutionEntityManager
()
.
findExecutionById
(
processInstanceId
);
}
return
processInstance
;
}
public
void
setProcessInstance
(
ExecutionEntity
processInstance
)
{
this
.
processInstance
=
processInstance
;
this
.
processInstanceId
=
processInstance
.
getId
();
}
public
ProcessDefinitionEntity
getProcessDef
()
{
if
((
processDef
==
null
)
&&
(
processDefId
!=
null
))
{
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/IdentityLinkEntityManager.java
浏览文件 @
fc00a23f
...
...
@@ -35,6 +35,11 @@ public class IdentityLinkEntityManager extends AbstractManager {
return
getDbSqlSession
().
selectList
(
"selectIdentityLinksByTask"
,
taskId
);
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
IdentityLinkEntity
>
findIdentityLinksByProcessInstanceId
(
String
processInstanceId
)
{
return
getDbSqlSession
().
selectList
(
"selectIdentityLinksByProcessInstance"
,
processInstanceId
);
}
@SuppressWarnings
(
"unchecked"
)
public
List
<
IdentityLinkEntity
>
findIdentityLinksByProcessDefinitionId
(
String
processDefinitionId
)
{
return
getDbSqlSession
().
selectList
(
"selectIdentityLinksByProcessDefinition"
,
processDefinitionId
);
...
...
@@ -65,9 +70,16 @@ public class IdentityLinkEntityManager extends AbstractManager {
deleteIdentityLink
(
identityLink
);
}
}
public
void
deleteIdentityLinksByProcInstance
(
String
processInstanceId
)
{
List
<
IdentityLinkEntity
>
identityLinks
=
findIdentityLinksByProcessInstanceId
(
processInstanceId
);
for
(
IdentityLinkEntity
identityLink:
identityLinks
)
{
deleteIdentityLink
(
identityLink
);
}
}
public
void
deleteIdentityLinksByProcDef
(
String
processDefId
)
{
getDbSqlSession
().
delete
(
"deleteIdentityLinkByProcDef"
,
processDefId
);
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ProcessDefinitionEntity.java
浏览文件 @
fc00a23f
...
...
@@ -84,11 +84,14 @@ public class ProcessDefinitionEntity extends ProcessDefinitionImpl implements Pr
// Reset the process instance in order to have the db-generated process instance id available
processInstance
.
setProcessInstance
(
processInstance
);
String
authenticatedUserId
=
Authentication
.
getAuthenticatedUserId
();
String
initiatorVariableName
=
(
String
)
getProperty
(
BpmnParse
.
PROPERTYNAME_INITIATOR_VARIABLE_NAME
);
if
(
initiatorVariableName
!=
null
)
{
String
authenticatedUserId
=
Authentication
.
getAuthenticatedUserId
();
processInstance
.
setVariable
(
initiatorVariableName
,
authenticatedUserId
);
}
if
(
authenticatedUserId
!=
null
)
{
processInstance
.
addIdentityLink
(
authenticatedUserId
,
IdentityLinkType
.
STARTER
);
}
Context
.
getCommandContext
().
getHistoryManager
()
.
recordProcessInstanceStart
(
processInstance
);
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/TaskEntity.java
浏览文件 @
fc00a23f
...
...
@@ -32,6 +32,7 @@ import org.activiti.engine.impl.db.DbSqlSession;
import
org.activiti.engine.impl.db.HasRevision
;
import
org.activiti.engine.impl.db.PersistentObject
;
import
org.activiti.engine.impl.delegate.TaskListenerInvocation
;
import
org.activiti.engine.impl.identity.Authentication
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.impl.pvm.delegate.ActivityExecution
;
import
org.activiti.engine.impl.task.TaskDefinition
;
...
...
@@ -129,13 +130,8 @@ public class TaskEntity extends VariableScopeImpl implements Task, DelegateTask,
dbSqlSession
.
update
(
this
);
}
/** new task. Embedded state and create time will be initialized.
* But this task still will have to be persisted with
* TransactionContext
* .getCurrent()
* .getPersistenceSession()
* .insert(task);
*/
/** Creates a new task. Embedded state and create time will be initialized.
* But this task still will have to be persisted. See {@link #insert(ExecutionEntity)}. */
public
static
TaskEntity
create
()
{
TaskEntity
task
=
new
TaskEntity
();
task
.
isIdentityLinksInitialized
=
true
;
...
...
@@ -146,6 +142,10 @@ public class TaskEntity extends VariableScopeImpl implements Task, DelegateTask,
public
void
complete
()
{
fireEvent
(
TaskListener
.
EVENTNAME_COMPLETE
);
if
(
Authentication
.
getAuthenticatedUserId
()
!=
null
&&
processInstanceId
!=
null
)
{
getProcessInstance
().
involveUser
(
Authentication
.
getAuthenticatedUserId
(),
IdentityLinkType
.
PARTICIPANT
);
}
Context
.
getCommandContext
()
.
getTaskEntityManager
()
...
...
@@ -271,6 +271,10 @@ public class TaskEntity extends VariableScopeImpl implements Task, DelegateTask,
identityLinkEntity
.
setUserId
(
userId
);
identityLinkEntity
.
setGroupId
(
groupId
);
identityLinkEntity
.
setType
(
type
);
if
(
userId
!=
null
&&
processInstanceId
!=
null
)
{
getProcessInstance
().
involveUser
(
userId
,
IdentityLinkType
.
PARTICIPANT
);
}
return
identityLinkEntity
;
}
...
...
@@ -420,16 +424,18 @@ public class TaskEntity extends VariableScopeImpl implements Task, DelegateTask,
this
.
assignee
=
assignee
;
CommandContext
commandContext
=
Context
.
getCommandContext
();
// if there is no command context, then it means that the user is calling the
// setAssignee outside a service method. E.g. while creating a new task.
if
(
commandContext
!=
null
)
{
commandContext
.
getHistoryManager
()
.
recordTaskAssigneeChange
(
id
,
assignee
);
// if there is no command context, then it means that the user is calling the
// setAssignee outside a service method. E.g. while creating a new task.
if
(
commandContext
!=
null
)
{
fireEvent
(
TaskListener
.
EVENTNAME_ASSIGNMENT
);
if
(
assignee
!=
null
&&
processInstanceId
!=
null
)
{
getProcessInstance
().
involveUser
(
assignee
,
IdentityLinkType
.
PARTICIPANT
);
}
fireEvent
(
TaskListener
.
EVENTNAME_ASSIGNMENT
);
}
}
...
...
@@ -452,6 +458,10 @@ public class TaskEntity extends VariableScopeImpl implements Task, DelegateTask,
commandContext
.
getHistoryManager
()
.
recordTaskOwnerChange
(
id
,
owner
);
if
(
owner
!=
null
&&
processInstanceId
!=
null
)
{
getProcessInstance
().
involveUser
(
owner
,
IdentityLinkType
.
PARTICIPANT
);
}
}
}
...
...
@@ -636,6 +646,12 @@ public class TaskEntity extends VariableScopeImpl implements Task, DelegateTask,
this
.
executionId
=
executionId
;
}
public
ExecutionEntity
getProcessInstance
()
{
if
(
processInstance
==
null
&&
processInstanceId
!=
null
)
{
processInstance
=
Context
.
getCommandContext
()
.
getExecutionEntityManager
()
.
findExecutionById
(
processInstanceId
);
}
return
processInstance
;
}
public
void
setProcessInstance
(
ExecutionEntity
processInstance
)
{
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/runtime/ProcessInstanceQuery.java
浏览文件 @
fc00a23f
...
...
@@ -46,7 +46,7 @@ public interface ProcessInstanceQuery extends Query<ProcessInstanceQuery, Proces
ProcessInstanceQuery
processDefinitionKey
(
String
processDefinitionKey
);
/**
* Select
s
the process instances which are defined by a process definition
* Select the process instances which are defined by a process definition
* with the given id.
*/
ProcessInstanceQuery
processDefinitionId
(
String
processDefinitionId
);
...
...
@@ -64,6 +64,11 @@ public interface ProcessInstanceQuery extends Query<ProcessInstanceQuery, Proces
*/
ProcessInstanceQuery
subProcessInstanceId
(
String
subProcessInstanceId
);
/**
* Select the process instances with which the user with the given id is involved.
*/
ProcessInstanceQuery
involvedUser
(
String
userId
);
/**
* Only select process instances which have a global variable with the given value. The type
* of variable is determined based on the value, using types configured in
...
...
@@ -165,14 +170,14 @@ public interface ProcessInstanceQuery extends Query<ProcessInstanceQuery, Proces
ProcessInstanceQuery
variableValueLike
(
String
name
,
String
value
);
/**
* Only select
s
process instances which are suspended, either because the
* Only select process instances which are suspended, either because the
* process instance itself is suspended or because the corresponding process
* definition is suspended
*/
ProcessInstanceQuery
suspended
();
/**
* Only select
s
process instances which are active, which means that
* Only select process instances which are active, which means that
* neither the process instance nor the corresponding process definition
* are suspended.
*/
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/task/IdentityLinkType.java
浏览文件 @
fc00a23f
...
...
@@ -34,4 +34,8 @@ public class IdentityLinkType {
public
static
final
String
OWNER
=
"owner"
;
public
static
final
String
STARTER
=
"starter"
;
public
static
final
String
PARTICIPANT
=
"participant"
;
}
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.db2.create.engine.sql
浏览文件 @
fc00a23f
...
...
@@ -131,6 +131,7 @@ create table ACT_RU_IDENTITYLINK (
TYPE_
varchar
(
255
),
USER_ID_
varchar
(
255
),
TASK_ID_
varchar
(
64
),
PROC_INST_ID_
varchar
(
64
),
PROC_DEF_ID_
varchar
(
64
),
primary
key
(
ID_
)
);
...
...
@@ -211,6 +212,11 @@ alter table ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_ATHRZ_PROCEDEF
foreign
key
(
PROC_DEF_ID_
)
references
ACT_RE_PROCDEF
(
ID_
);
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
alter
table
ACT_RU_TASK
add
constraint
ACT_FK_TASK_EXE
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.h2.create.engine.sql
浏览文件 @
fc00a23f
...
...
@@ -129,6 +129,7 @@ create table ACT_RU_IDENTITYLINK (
TYPE_
varchar
(
255
),
USER_ID_
varchar
(
255
),
TASK_ID_
varchar
(
64
),
PROC_INST_ID_
varchar
(
64
)
null
,
PROC_DEF_ID_
varchar
(
64
),
primary
key
(
ID_
)
);
...
...
@@ -212,6 +213,11 @@ alter table ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_ATHRZ_PROCEDEF
foreign
key
(
PROC_DEF_ID_
)
references
ACT_RE_PROCDEF
;
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
alter
table
ACT_RU_TASK
add
constraint
ACT_FK_TASK_EXE
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.mssql.create.engine.sql
浏览文件 @
fc00a23f
...
...
@@ -129,6 +129,7 @@ create table ACT_RU_IDENTITYLINK (
TYPE_
nvarchar
(
255
),
USER_ID_
nvarchar
(
255
),
TASK_ID_
nvarchar
(
64
),
PROC_INST_ID_
nvarchar
(
64
),
PROC_DEF_ID_
nvarchar
(
64
),
primary
key
(
ID_
)
);
...
...
@@ -205,6 +206,11 @@ alter table ACT_RU_IDENTITYLINK
foreign
key
(
PROC_DEF_ID_
)
references
ACT_RE_PROCDEF
(
ID_
);
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
alter
table
ACT_RU_TASK
add
constraint
ACT_FK_TASK_EXE
foreign
key
(
EXECUTION_ID_
)
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.mysql.create.engine.sql
浏览文件 @
fc00a23f
...
...
@@ -130,6 +130,7 @@ create table ACT_RU_IDENTITYLINK (
TYPE_
varchar
(
255
),
USER_ID_
varchar
(
255
),
TASK_ID_
varchar
(
64
),
PROC_INST_ID_
varchar
(
64
),
PROC_DEF_ID_
varchar
(
64
),
primary
key
(
ID_
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COLLATE
utf8_bin
;
...
...
@@ -210,6 +211,11 @@ alter table ACT_RU_IDENTITYLINK
foreign
key
(
PROC_DEF_ID_
)
references
ACT_RE_PROCDEF
(
ID_
);
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
alter
table
ACT_RU_TASK
add
constraint
ACT_FK_TASK_EXE
foreign
key
(
EXECUTION_ID_
)
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.oracle.create.engine.sql
浏览文件 @
fc00a23f
...
...
@@ -129,6 +129,7 @@ create table ACT_RU_IDENTITYLINK (
TYPE_
NVARCHAR2
(
255
),
USER_ID_
NVARCHAR2
(
255
),
TASK_ID_
NVARCHAR2
(
64
),
PROC_INST_ID_
NVARCHAR2
(
64
),
PROC_DEF_ID_
NVARCHAR2
(
64
),
primary
key
(
ID_
)
);
...
...
@@ -214,6 +215,12 @@ alter table ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_ATHRZ_PROCEDEF
foreign
key
(
PROC_DEF_ID_
)
references
ACT_RE_PROCDEF
(
ID_
);
create
index
ACT_IDX_IDL_PROCINST
on
ACT_RU_IDENTITYLINK
(
PROC_INST_ID_
);
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
create
index
ACT_IDX_TASK_EXEC
on
ACT_RU_TASK
(
EXECUTION_ID_
);
alter
table
ACT_RU_TASK
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.postgres.create.engine.sql
浏览文件 @
fc00a23f
...
...
@@ -130,6 +130,7 @@ create table ACT_RU_IDENTITYLINK (
TYPE_
varchar
(
255
),
USER_ID_
varchar
(
255
),
TASK_ID_
varchar
(
64
),
PROC_INST_ID_
varchar
(
64
),
PROC_DEF_ID_
varchar
(
64
),
primary
key
(
ID_
)
);
...
...
@@ -217,6 +218,12 @@ alter table ACT_RU_IDENTITYLINK
foreign
key
(
PROC_DEF_ID_
)
references
ACT_RE_PROCDEF
(
ID_
);
create
index
ACT_IDX_IDL_PROCINST
on
ACT_RU_IDENTITYLINK
(
PROC_INST_ID_
);
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
create
index
ACT_IDX_TASK_EXEC
on
ACT_RU_TASK
(
EXECUTION_ID_
);
alter
table
ACT_RU_TASK
add
constraint
ACT_FK_TASK_EXE
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/Execution.xml
浏览文件 @
fc00a23f
...
...
@@ -105,7 +105,7 @@
<include
refid=
"selectExecutionsByQueryCriteriaSql"
/>
</select>
<!-- same as selectExecutionByQueryCriteria, but with different parameterType -->
<!-- same as selectExecution
s
ByQueryCriteria, but with different parameterType -->
<select
id=
"selectProcessInstanceByQueryCriteria"
parameterType=
"org.activiti.engine.impl.ProcessInstanceQueryImpl"
resultMap=
"executionResultMap"
>
${limitBefore}
select RES.* ${limitBetween}, P.KEY_ as ProcessDefinitionKey, P.ID_ as ProcessDefinitionId
...
...
@@ -121,6 +121,9 @@
<sql
id=
"selectExecutionsByQueryCriteriaSql"
>
from ${prefix}ACT_RU_EXECUTION RES
<if
test=
"involvedUser != null"
>
inner join ${prefix}ACT_RU_IDENTITYLINK I on I.PROC_INST_ID_ = RES.ID_
</if>
<foreach
collection=
"queryVariableValues"
index=
"index"
item=
"queryVariableValue"
>
<choose>
<when
test=
"queryVariableValue.local"
>
...
...
@@ -181,6 +184,9 @@
and (RES.SUSPENSION_STATE_ = 2)
</if>
</if>
<if
test=
"involvedUser != null"
>
and I.USER_ID_ = #{involvedUser}
</if>
<!-- PLEASE NOTE: If you change anything have a look into the HistoricVariableInstance & HistoricProcessInstance, the same query object is used there! -->
<foreach
collection=
"queryVariableValues"
index=
"index"
item=
"queryVariableValue"
>
<if
test=
"!queryVariableValue.local"
>
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/IdentityLink.xml
浏览文件 @
fc00a23f
...
...
@@ -7,13 +7,14 @@
<!-- INSERT IDENTITY LINK -->
<insert
id=
"insertIdentityLink"
parameterType=
"org.activiti.engine.impl.persistence.entity.IdentityLinkEntity"
>
insert into ${prefix}ACT_RU_IDENTITYLINK (ID_, REV_, TYPE_, USER_ID_, GROUP_ID_, TASK_ID_, PROC_DEF_ID_)
insert into ${prefix}ACT_RU_IDENTITYLINK (ID_, REV_, TYPE_, USER_ID_, GROUP_ID_, TASK_ID_, PROC_
INST_ID_, PROC_
DEF_ID_)
values (#{id, jdbcType=VARCHAR},
1,
#{type, jdbcType=VARCHAR},
#{userId, jdbcType=VARCHAR},
#{groupId, jdbcType=VARCHAR},
#{taskId, jdbcType=VARCHAR},
#{processInstanceId, jdbcType=VARCHAR},
#{processDefId, jdbcType=VARCHAR})
</insert>
...
...
@@ -37,6 +38,7 @@
<result
property=
"userId"
column=
"USER_ID_"
jdbcType=
"VARCHAR"
/>
<result
property=
"groupId"
column=
"GROUP_ID_"
jdbcType=
"VARCHAR"
/>
<result
property=
"taskId"
column=
"TASK_ID_"
jdbcType=
"VARCHAR"
/>
<result
property=
"processInstanceId"
column=
"PROC_INST_ID_"
jdbcType=
"VARCHAR"
/>
<result
property=
"processDefId"
column=
"PROCESS_DEF_ID_"
jdbcType=
"VARCHAR"
/>
</resultMap>
...
...
@@ -50,6 +52,10 @@
select * from ${prefix}ACT_RU_IDENTITYLINK where TASK_ID_ = #{parameter}
</select>
<select
id=
"selectIdentityLinksByProcessInstance"
parameterType=
"org.activiti.engine.impl.db.ListQueryParameterObject"
resultMap=
"identityLinkResultMap"
>
select * from ${prefix}ACT_RU_IDENTITYLINK where PROC_INST_ID_ = #{parameter}
</select>
<select
id=
"selectIdentityLinksByProcessDefinition"
parameterType=
"org.activiti.engine.impl.db.ListQueryParameterObject"
resultMap=
"identityLinkResultMap"
>
select * from ${prefix}ACT_RU_IDENTITYLINK where PROC_DEF_ID_ = #{parameter}
</select>
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.db2.upgradestep.511.to.512.history.sql
浏览文件 @
fc00a23f
...
...
@@ -6,4 +6,15 @@ alter table ACT_HI_TASKINST
Call
Sysproc
.
admin_cmd
(
'REORG TABLE ACT_HI_TASKINST'
);
alter
table
ACT_RU_IDENTITYLINK
add
PROC_INST_ID_
varchar
(
64
);
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
Call
Sysproc
.
admin_cmd
(
'REORG TABLE ACT_RU_IDENTITYLINK'
);
create
index
ACT_IDX_HI_ACT_INST_EXEC
on
ACT_HI_ACTINST
(
EXECUTION_ID_
,
ACT_ID_
);
\ No newline at end of file
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.h2.upgradestep.511.to.512.history.sql
浏览文件 @
fc00a23f
...
...
@@ -4,4 +4,12 @@ alter table ACT_HI_TASKINST
alter
table
ACT_HI_TASKINST
add
FORM_KEY_
varchar
(
255
);
alter
table
ACT_RU_IDENTITYLINK
add
PROC_INST_ID_
varchar
(
64
);
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
create
index
ACT_IDX_HI_ACT_INST_EXEC
on
ACT_HI_ACTINST
(
EXECUTION_ID_
,
ACT_ID_
);
\ No newline at end of file
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.mssql.upgradestep.511.to.512.history.sql
浏览文件 @
fc00a23f
...
...
@@ -4,4 +4,12 @@ alter table ACT_HI_TASKINST
alter
table
ACT_HI_TASKINST
add
FORM_KEY_
nvarchar
(
255
);
alter
table
ACT_RU_IDENTITYLINK
add
PROC_INST_ID_
nvarchar
(
64
);
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
create
index
ACT_IDX_HI_ACT_INST_EXEC
on
ACT_HI_ACTINST
(
EXECUTION_ID_
,
ACT_ID_
);
\ No newline at end of file
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.mysql.upgradestep.511.to.512.history.sql
浏览文件 @
fc00a23f
...
...
@@ -3,5 +3,13 @@ alter table ACT_HI_TASKINST
alter
table
ACT_HI_TASKINST
add
FORM_KEY_
varchar
(
255
);
alter
table
ACT_RU_IDENTITYLINK
add
PROC_INST_ID_
varchar
(
64
);
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
create
index
ACT_IDX_HI_ACT_INST_EXEC
on
ACT_HI_ACTINST
(
EXECUTION_ID_
,
ACT_ID_
);
\ No newline at end of file
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.oracle.upgradestep.511.to.512.history.sql
浏览文件 @
fc00a23f
...
...
@@ -4,5 +4,14 @@ alter table ACT_HI_TASKINST
alter
table
ACT_HI_TASKINST
add
FORM_KEY_
NVARCHAR2
(
255
);
alter
table
ACT_RU_IDENTITYLINK
add
PROC_INST_ID_
NVARCHAR2
(
64
);
create
index
ACT_IDX_IDL_PROCINST
on
ACT_RU_IDENTITYLINK
(
PROC_INST_ID_
);
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
create
index
ACT_IDX_HI_ACT_INST_EXEC
on
ACT_HI_ACTINST
(
EXECUTION_ID_
,
ACT_ID_
);
\ No newline at end of file
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.postgres.upgradestep.511.to.512.history.sql
浏览文件 @
fc00a23f
...
...
@@ -4,5 +4,16 @@ alter table ACT_HI_TASKINST
alter
table
ACT_HI_TASKINST
add
column
FORM_KEY_
varchar
(
255
);
alter
table
ACT_RU_IDENTITYLINK
add
PROC_INST_ID_
varchar
(
64
);
create
index
ACT_IDX_IDL_PROCINST
on
ACT_RU_IDENTITYLINK
(
PROC_INST_ID_
);
alter
table
ACT_RU_IDENTITYLINK
add
constraint
ACT_FK_IDL_PROCINST
foreign
key
(
PROC_INST_ID_
)
references
ACT_RU_EXECUTION
(
ID_
);
create
index
ACT_IDX_HI_ACT_INST_EXEC
on
ACT_HI_ACTINST
(
EXECUTION_ID_
,
ACT_ID_
);
\ No newline at end of file
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/runtime/InstanceInvolvementTest.java
0 → 100644
浏览文件 @
fc00a23f
/* 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.
*/
package
org.activiti.engine.test.api.runtime
;
import
java.util.List
;
import
org.activiti.engine.impl.test.PluggableActivitiTestCase
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.task.IdentityLink
;
import
org.activiti.engine.task.Task
;
import
org.activiti.engine.test.Deployment
;
/**
* @author Marcus Klimstra
*/
public
class
InstanceInvolvementTest
extends
PluggableActivitiTestCase
{
@Deployment
(
resources
={
"org/activiti/engine/test/api/runtime/threeParallelTasks.bpmn20.xml"
})
public
void
testInvolvements
()
{
// "user1", "user2", "user3" and "user4 should not be involved with any process instance
assertNoInvolvement
(
"user1"
);
assertNoInvolvement
(
"user2"
);
assertNoInvolvement
(
"user3"
);
assertNoInvolvement
(
"user4"
);
// start a new process instance as "user1"
String
instanceId
=
startProcessAsUser
(
"threeParallelTasks"
,
"user1"
);
// there are supposed to be 3 tasks
List
<
Task
>
tasks
=
taskService
.
createTaskQuery
().
processInstanceId
(
instanceId
).
list
();
assertEquals
(
3
,
tasks
.
size
());
// "user1" should now be involved as the starter of the new process instance. "user2" is still not involved.
assertInvolvement
(
"user1"
,
instanceId
);
assertNoInvolvement
(
"user2"
);
// "user2" should be involved with the new process instance after claiming a task
taskService
.
claim
(
tasks
.
get
(
0
).
getId
(),
"user2"
);
assertInvolvement
(
"user2"
,
instanceId
);
// "user2" should still be involved with the new process instance even after completing his task
taskService
.
complete
(
tasks
.
get
(
0
).
getId
());
assertInvolvement
(
"user2"
,
instanceId
);
// "user3" should be involved after completing a task even without claiming it
completeTaskAsUser
(
tasks
.
get
(
1
).
getId
(),
"user3"
);
assertInvolvement
(
"user3"
,
instanceId
);
// "user4" should be involved after manually adding an identity link
runtimeService
.
addUserIdentityLink
(
instanceId
,
"user4"
,
"custom"
);
assertInvolvement
(
"user4"
,
instanceId
);
// verify all identity links for this instance
// note that since "user1" already is the starter, he is not involved as a participant as well
List
<
IdentityLink
>
identityLinks
=
runtimeService
.
getIdentityLinksForProcessInstance
(
instanceId
);
assertTrue
(
containsIdentityLink
(
identityLinks
,
"user1"
,
"starter"
));
assertTrue
(
containsIdentityLink
(
identityLinks
,
"user2"
,
"participant"
));
assertTrue
(
containsIdentityLink
(
identityLinks
,
"user3"
,
"participant"
));
assertTrue
(
containsIdentityLink
(
identityLinks
,
"user4"
,
"custom"
));
assertEquals
(
4
,
identityLinks
.
size
());
// "user1" completes the remaining task, ending the process
completeTaskAsUser
(
tasks
.
get
(
2
).
getId
(),
"user1"
);
// none of the users should now be involved with any process instance
assertNoInvolvement
(
"user1"
);
assertNoInvolvement
(
"user2"
);
assertNoInvolvement
(
"user3"
);
assertNoInvolvement
(
"user4"
);
}
@Deployment
(
resources
={
"org/activiti/engine/test/api/runtime/threeParallelTasks.bpmn20.xml"
})
public
void
testInstanceRemoval
()
{
String
instanceId
=
startProcessAsUser
(
"threeParallelTasks"
,
"user1"
);
assertInvolvement
(
"user1"
,
instanceId
);
runtimeService
.
deleteProcessInstance
(
instanceId
,
"Testing instance removal"
);
assertNoInvolvement
(
"user1"
);
// this will fail with a "DB NOT CLEAN" if the identity links are not removed
}
private
void
assertNoInvolvement
(
String
userId
)
{
assertEquals
(
0L
,
runtimeService
.
createProcessInstanceQuery
().
involvedUser
(
userId
).
count
());
}
private
void
assertInvolvement
(
String
userId
,
String
instanceId
)
{
ProcessInstance
involvedInstance
=
runtimeService
.
createProcessInstanceQuery
()
.
involvedUser
(
userId
)
.
singleResult
();
assertEquals
(
instanceId
,
involvedInstance
.
getId
());
}
private
String
startProcessAsUser
(
String
processId
,
String
userId
)
{
try
{
identityService
.
setAuthenticatedUserId
(
userId
);
return
runtimeService
.
startProcessInstanceByKey
(
processId
).
getId
();
}
finally
{
identityService
.
setAuthenticatedUserId
(
null
);
}
}
private
void
completeTaskAsUser
(
String
taskId
,
String
userId
)
{
try
{
identityService
.
setAuthenticatedUserId
(
userId
);
taskService
.
complete
(
taskId
);
}
finally
{
identityService
.
setAuthenticatedUserId
(
null
);
}
}
private
boolean
containsIdentityLink
(
List
<
IdentityLink
>
identityLinks
,
String
userId
,
String
type
)
{
for
(
IdentityLink
identityLink
:
identityLinks
)
{
if
(
userId
.
equals
(
identityLink
.
getUserId
())
&&
type
.
equals
(
identityLink
.
getType
()))
{
return
true
;
}
}
return
false
;
}
}
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/runtime/ProcessInstanceQueryTest.java
浏览文件 @
fc00a23f
...
...
@@ -1224,7 +1224,7 @@ public class ProcessInstanceQueryTest extends PluggableActivitiTestCase {
@Deployment
(
resources
={
"org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"
})
public
void
testClashingValues
()
throws
Exception
{
public
void
testClashingValues
()
throws
Exception
{
Map
<
String
,
Object
>
vars
=
new
HashMap
<
String
,
Object
>();
vars
.
put
(
"var"
,
1234L
);
...
...
modules/activiti-engine/src/test/resources/org/activiti/engine/test/api/runtime/threeParallelTasks.bpmn20.xml
0 → 100644
浏览文件 @
fc00a23f
<?xml version="1.0" encoding="UTF-8"?>
<definitions
id=
"definitions"
xmlns=
"http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti=
"http://activiti.org/bpmn"
targetNamespace=
"org.activiti.enginge.test.api.runtime"
>
<process
id=
"threeParallelTasks"
>
<startEvent
id=
"theStart"
/>
<sequenceFlow
id=
"flow1"
sourceRef=
"theStart"
targetRef=
"fork"
/>
<parallelGateway
id=
"fork"
/>
<sequenceFlow
sourceRef=
"fork"
targetRef=
"task1"
/>
<sequenceFlow
sourceRef=
"fork"
targetRef=
"task2"
/>
<sequenceFlow
sourceRef=
"fork"
targetRef=
"task3"
/>
<userTask
id=
"task1"
name=
"Task 1"
/>
<userTask
id=
"task2"
name=
"Task 2"
/>
<userTask
id=
"task3"
name=
"Task 3"
/>
<sequenceFlow
sourceRef=
"task1"
targetRef=
"join"
/>
<sequenceFlow
sourceRef=
"task2"
targetRef=
"join"
/>
<sequenceFlow
sourceRef=
"task3"
targetRef=
"join"
/>
<parallelGateway
id=
"join"
/>
<sequenceFlow
sourceRef=
"join"
targetRef=
"theEnd"
/>
<endEvent
id=
"theEnd"
/>
</process>
</definitions>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录