Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
df2691b0
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,发现更多精彩内容 >>
提交
df2691b0
编写于
3月 18, 2014
作者:
J
Joram Barrez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Multi tenancy: support for message events in tenant context
上级
ec94d568
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
257 addition
and
32 deletion
+257
-32
modules/activiti-engine/src/main/java/org/activiti/engine/RuntimeService.java
...ine/src/main/java/org/activiti/engine/RuntimeService.java
+20
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/RuntimeServiceImpl.java
...ain/java/org/activiti/engine/impl/RuntimeServiceImpl.java
+22
-4
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/deployer/BpmnDeployer.java
.../org/activiti/engine/impl/bpmn/deployer/BpmnDeployer.java
+6
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/ChangeDeploymentTenantIdCmd.java
...activiti/engine/impl/cmd/ChangeDeploymentTenantIdCmd.java
+2
-2
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/StartProcessInstanceByMessageCmd.java
...iti/engine/impl/cmd/StartProcessInstanceByMessageCmd.java
+6
-3
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/CompensateEventSubscriptionEntity.java
...persistence/entity/CompensateEventSubscriptionEntity.java
+4
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/EventSubscriptionEntity.java
...gine/impl/persistence/entity/EventSubscriptionEntity.java
+10
-1
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/EventSubscriptionEntityManager.java
...pl/persistence/entity/EventSubscriptionEntityManager.java
+15
-4
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ExecutionEntity.java
...iviti/engine/impl/persistence/entity/ExecutionEntity.java
+4
-1
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
+1
-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
+1
-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
+1
-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
+1
-0
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.mysql55.create.engine.sql
...org/activiti/db/create/activiti.mysql55.create.engine.sql
+1
-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
+1
-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
+1
-0
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/EventSubscription.xml
...rces/org/activiti/db/mapping/entity/EventSubscription.xml
+44
-14
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.db2.upgradestep.514.to.515.engine.sql
...db/upgrade/activiti.db2.upgradestep.514.to.515.engine.sql
+5
-0
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.h2.upgradestep.514.to.515.engine.sql
.../db/upgrade/activiti.h2.upgradestep.514.to.515.engine.sql
+4
-1
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.mssql.upgradestep.514.to.515.engine.sql
.../upgrade/activiti.mssql.upgradestep.514.to.515.engine.sql
+3
-0
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.mysql.upgradestep.514.to.515.engine.sql
.../upgrade/activiti.mysql.upgradestep.514.to.515.engine.sql
+2
-0
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.mysql55.upgradestep.514.to.515.engine.sql
...pgrade/activiti.mysql55.upgradestep.514.to.515.engine.sql
+3
-0
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.oracle.upgradestep.514.to.515.engine.sql
...upgrade/activiti.oracle.upgradestep.514.to.515.engine.sql
+4
-1
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.postgres.upgradestep.514.to.515.engine.sql
...grade/activiti.postgres.upgradestep.514.to.515.engine.sql
+3
-0
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/tenant/TenancyTest.java
...java/org/activiti/engine/test/api/tenant/TenancyTest.java
+71
-0
modules/activiti-engine/src/test/resources/org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml
...test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml
+22
-0
未找到文件。
modules/activiti-engine/src/main/java/org/activiti/engine/RuntimeService.java
浏览文件 @
df2691b0
...
...
@@ -240,6 +240,11 @@ public interface RuntimeService {
* @since 5.9
*/
ProcessInstance
startProcessInstanceByMessage
(
String
messageName
);
/**
* Similar to {@link RuntimeService#startProcessInstanceByMessage(String)}, but with tenant context.
*/
ProcessInstance
startProcessInstanceByMessageAndTenantId
(
String
messageName
,
String
tenantId
);
/**
* <p>
...
...
@@ -262,6 +267,11 @@ public interface RuntimeService {
* @since 5.10
*/
ProcessInstance
startProcessInstanceByMessage
(
String
messageName
,
String
businessKey
);
/**
* Similar to {@link RuntimeService#startProcessInstanceByMessage(String, String)}, but with tenant context.
*/
ProcessInstance
startProcessInstanceByMessageAndTenantId
(
String
messageName
,
String
businessKey
,
String
tenantId
);
/**
* <p>
...
...
@@ -288,6 +298,11 @@ public interface RuntimeService {
* @since 5.9
*/
ProcessInstance
startProcessInstanceByMessage
(
String
messageName
,
Map
<
String
,
Object
>
processVariables
);
/**
* Similar to {@link RuntimeService#startProcessInstanceByMessage(String, Map<String, Object>)}, but with tenant context.
*/
ProcessInstance
startProcessInstanceByMessageAndTenantId
(
String
messageName
,
Map
<
String
,
Object
>
processVariables
,
String
tenantId
);
/**
* <p>
...
...
@@ -315,6 +330,11 @@ public interface RuntimeService {
* @since 5.9
*/
ProcessInstance
startProcessInstanceByMessage
(
String
messageName
,
String
businessKey
,
Map
<
String
,
Object
>
processVariables
);
/**
* Similar to {@link RuntimeService#startProcessInstanceByMessage(String, String, Map<String, Object>)}, but with tenant context.
*/
ProcessInstance
startProcessInstanceByMessageAndTenantId
(
String
messageName
,
String
businessKey
,
Map
<
String
,
Object
>
processVariables
,
String
tenantId
);
/**
* Delete an existing runtime process instance.
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/RuntimeServiceImpl.java
浏览文件 @
df2691b0
...
...
@@ -243,19 +243,37 @@ public class RuntimeServiceImpl extends ServiceImpl implements RuntimeService {
}
public
ProcessInstance
startProcessInstanceByMessage
(
String
messageName
)
{
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
null
,
null
));
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
null
,
null
,
null
));
}
public
ProcessInstance
startProcessInstanceByMessageAndTenantId
(
String
messageName
,
String
tenantId
)
{
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
null
,
null
,
tenantId
));
}
public
ProcessInstance
startProcessInstanceByMessage
(
String
messageName
,
String
businessKey
)
{
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
businessKey
,
null
));
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
businessKey
,
null
,
null
));
}
public
ProcessInstance
startProcessInstanceByMessageAndTenantId
(
String
messageName
,
String
businessKey
,
String
tenantId
)
{
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
businessKey
,
null
,
tenantId
));
}
public
ProcessInstance
startProcessInstanceByMessage
(
String
messageName
,
Map
<
String
,
Object
>
processVariables
)
{
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
null
,
processVariables
));
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
null
,
processVariables
,
null
));
}
public
ProcessInstance
startProcessInstanceByMessageAndTenantId
(
String
messageName
,
Map
<
String
,
Object
>
processVariables
,
String
tenantId
)
{
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
null
,
processVariables
,
tenantId
));
}
public
ProcessInstance
startProcessInstanceByMessage
(
String
messageName
,
String
businessKey
,
Map
<
String
,
Object
>
processVariables
)
{
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
businessKey
,
processVariables
));
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
businessKey
,
processVariables
,
null
));
}
@Override
public
ProcessInstance
startProcessInstanceByMessageAndTenantId
(
String
messageName
,
String
businessKey
,
Map
<
String
,
Object
>
processVariables
,
String
tenantId
)
{
return
commandExecutor
.
execute
(
new
StartProcessInstanceByMessageCmd
(
messageName
,
businessKey
,
processVariables
,
tenantId
));
}
public
void
signalEventReceived
(
String
signalName
)
{
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/deployer/BpmnDeployer.java
浏览文件 @
df2691b0
...
...
@@ -296,7 +296,8 @@ public class BpmnDeployer implements Deployer {
// look for subscriptions for the same name in db:
List
<
EventSubscriptionEntity
>
subscriptionsForSameMessageName
=
commandContext
.
getEventSubscriptionEntityManager
()
.
findEventSubscriptionsByName
(
MessageEventHandler
.
EVENT_HANDLER_TYPE
,
messageEventDefinition
.
getEventName
());
.
findEventSubscriptionsByNameAndTenantId
(
MessageEventHandler
.
EVENT_HANDLER_TYPE
,
messageEventDefinition
.
getEventName
(),
processDefinition
.
getTenantId
());
// also look for subscriptions created in the session:
List
<
MessageEventSubscriptionEntity
>
cachedSubscriptions
=
commandContext
.
getDbSqlSession
()
...
...
@@ -321,6 +322,10 @@ public class BpmnDeployer implements Deployer {
newSubscription
.
setEventName
(
messageEventDefinition
.
getEventName
());
newSubscription
.
setActivityId
(
messageEventDefinition
.
getActivityId
());
newSubscription
.
setConfiguration
(
processDefinition
.
getId
());
if
(
processDefinition
.
getTenantId
()
!=
null
)
{
newSubscription
.
setTenantId
(
processDefinition
.
getTenantId
());
}
newSubscription
.
insert
();
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/ChangeDeploymentTenantIdCmd.java
浏览文件 @
df2691b0
...
...
@@ -44,14 +44,13 @@ public class ChangeDeploymentTenantIdCmd implements Command<Void>, Serializable
throw
new
ActivitiIllegalArgumentException
(
"deploymentId is null"
);
}
// Impl note: tenant id is allowed to be null, no check needed
// Update all entities
DeploymentEntity
deployment
=
commandContext
.
getDeploymentEntityManager
().
findDeploymentById
(
deploymentId
);
if
(
deployment
==
null
)
{
throw
new
ActivitiObjectNotFoundException
(
"Could not find deployment with id "
+
deploymentId
,
Deployment
.
class
);
}
String
oldTenantId
=
deployment
.
getTenantId
();
deployment
.
setTenantId
(
newTenantId
);
...
...
@@ -60,6 +59,7 @@ public class ChangeDeploymentTenantIdCmd implements Command<Void>, Serializable
commandContext
.
getExecutionEntityManager
().
updateExecutionTenantIdForDeployment
(
deploymentId
,
newTenantId
);
commandContext
.
getTaskEntityManager
().
updateTaskTenantIdForDeployment
(
deploymentId
,
newTenantId
);
commandContext
.
getJobEntityManager
().
updateJobTenantIdForDeployment
(
deploymentId
,
newTenantId
);
commandContext
.
getEventSubscriptionEntityManager
().
updateEventSubscriptionTenantId
(
oldTenantId
,
newTenantId
);
// Doing process definitions in memory, cause we need to clear the process definition cache
List
<
ProcessDefinition
>
processDefinitions
=
commandContext
.
getDbSqlSession
()
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/cmd/StartProcessInstanceByMessageCmd.java
浏览文件 @
df2691b0
...
...
@@ -32,17 +32,20 @@ import org.activiti.engine.runtime.ProcessInstance;
/**
* @author Daniel Meyer
* @author Joram Barrez
*/
public
class
StartProcessInstanceByMessageCmd
implements
Command
<
ProcessInstance
>
{
protected
final
String
messageName
;
protected
final
String
businessKey
;
protected
final
Map
<
String
,
Object
>
processVariables
;
protected
final
String
tenantId
;
public
StartProcessInstanceByMessageCmd
(
String
messageName
,
String
businessKey
,
Map
<
String
,
Object
>
processVariables
)
{
public
StartProcessInstanceByMessageCmd
(
String
messageName
,
String
businessKey
,
Map
<
String
,
Object
>
processVariables
,
String
tenantId
)
{
this
.
messageName
=
messageName
;
this
.
businessKey
=
businessKey
;
this
.
processVariables
=
processVariables
;
this
.
processVariables
=
processVariables
;
this
.
tenantId
=
tenantId
;
}
public
ProcessInstance
execute
(
CommandContext
commandContext
)
{
...
...
@@ -52,7 +55,7 @@ public class StartProcessInstanceByMessageCmd implements Command<ProcessInstance
}
MessageEventSubscriptionEntity
messageEventSubscription
=
commandContext
.
getEventSubscriptionEntityManager
()
.
findMessageStartEventSubscriptionByName
(
messageName
);
.
findMessageStartEventSubscriptionByName
(
messageName
,
tenantId
);
if
(
messageEventSubscription
==
null
)
{
throw
new
ActivitiObjectNotFoundException
(
"Cannot start process instance by message: no subscription to message with name '"
+
messageName
+
"' found."
,
MessageEventSubscriptionEntity
.
class
);
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/CompensateEventSubscriptionEntity.java
浏览文件 @
df2691b0
...
...
@@ -19,6 +19,7 @@ import org.activiti.engine.impl.event.CompensationEventHandler;
/**
* @author Daniel Meyer
* @author Joram Barrez
*/
public
class
CompensateEventSubscriptionEntity
extends
EventSubscriptionEntity
{
...
...
@@ -34,6 +35,9 @@ public class CompensateEventSubscriptionEntity extends EventSubscriptionEntity {
public
static
CompensateEventSubscriptionEntity
createAndInsert
(
ExecutionEntity
executionEntity
)
{
CompensateEventSubscriptionEntity
eventSubscription
=
new
CompensateEventSubscriptionEntity
(
executionEntity
);
if
(
executionEntity
.
getTenantId
()
!=
null
)
{
eventSubscription
.
setTenantId
(
executionEntity
.
getTenantId
());
}
eventSubscription
.
insert
();
return
eventSubscription
;
}
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/EventSubscriptionEntity.java
浏览文件 @
df2691b0
...
...
@@ -44,6 +44,7 @@ public abstract class EventSubscriptionEntity implements PersistentObject, HasRe
protected
String
activityId
;
protected
String
configuration
;
protected
Date
created
;
protected
String
tenantId
;
// runtime state /////////////////////////////
protected
ExecutionEntity
execution
;
...
...
@@ -248,8 +249,16 @@ public abstract class EventSubscriptionEntity implements PersistentObject, HasRe
public
void
setCreated
(
Date
created
)
{
this
.
created
=
created
;
}
public
String
getTenantId
()
{
return
tenantId
;
}
@Override
public
void
setTenantId
(
String
tenantId
)
{
this
.
tenantId
=
tenantId
;
}
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
...
...
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/EventSubscriptionEntityManager.java
浏览文件 @
df2691b0
...
...
@@ -167,11 +167,12 @@ public class EventSubscriptionEntityManager extends AbstractManager {
return
getDbSqlSession
().
selectList
(
query
,
params
);
}
public
List
<
EventSubscriptionEntity
>
findEventSubscriptionsByName
(
String
type
,
String
eventName
)
{
public
List
<
EventSubscriptionEntity
>
findEventSubscriptionsByName
AndTenantId
(
String
type
,
String
eventName
,
String
tenantId
)
{
final
String
query
=
"selectEventSubscriptionsByName"
;
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"eventType"
,
type
);
params
.
put
(
"eventName"
,
eventName
);
params
.
put
(
"eventName"
,
eventName
);
params
.
put
(
"tenantId"
,
tenantId
);
return
getDbSqlSession
().
selectList
(
query
,
params
);
}
...
...
@@ -184,9 +185,19 @@ public class EventSubscriptionEntityManager extends AbstractManager {
return
getDbSqlSession
().
selectList
(
query
,
params
);
}
public
MessageEventSubscriptionEntity
findMessageStartEventSubscriptionByName
(
String
messageName
)
{
MessageEventSubscriptionEntity
entity
=
(
MessageEventSubscriptionEntity
)
getDbSqlSession
().
selectOne
(
"selectMessageStartEventSubscriptionByName"
,
messageName
);
public
MessageEventSubscriptionEntity
findMessageStartEventSubscriptionByName
(
String
messageName
,
String
tenantId
)
{
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"eventName"
,
messageName
);
params
.
put
(
"tenantId"
,
tenantId
);
MessageEventSubscriptionEntity
entity
=
(
MessageEventSubscriptionEntity
)
getDbSqlSession
().
selectOne
(
"selectMessageStartEventSubscriptionByName"
,
params
);
return
entity
;
}
public
void
updateEventSubscriptionTenantId
(
String
oldTenantId
,
String
newTenantId
)
{
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"oldTenantId"
,
oldTenantId
);
params
.
put
(
"newTenantId"
,
newTenantId
);
getDbSqlSession
().
update
(
"updateTenantIdOfEventSubscriptions"
,
params
);
}
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/ExecutionEntity.java
浏览文件 @
df2691b0
...
...
@@ -327,7 +327,10 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
if
(
eventSubscriptionDeclarations
!=
null
)
{
for
(
EventSubscriptionDeclaration
eventSubscriptionDeclaration
:
eventSubscriptionDeclarations
)
{
if
(!
eventSubscriptionDeclaration
.
isStartEvent
())
{
EventSubscriptionEntity
eventSubscriptionEntity
=
eventSubscriptionDeclaration
.
prepareEventSubscriptionEntity
(
this
);
EventSubscriptionEntity
eventSubscriptionEntity
=
eventSubscriptionDeclaration
.
prepareEventSubscriptionEntity
(
this
);
if
(
getTenantId
()
!=
null
)
{
eventSubscriptionEntity
.
setTenantId
(
getTenantId
());
}
eventSubscriptionEntity
.
insert
();
}
}
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.db2.create.engine.sql
浏览文件 @
df2691b0
...
...
@@ -167,6 +167,7 @@ create table ACT_RU_EVENT_SUBSCR (
ACTIVITY_ID_
varchar
(
64
),
CONFIGURATION_
varchar
(
255
),
CREATED_
timestamp
not
null
,
TENANT_ID_
varchar
(
255
)
default
''
,
primary
key
(
ID_
)
);
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.h2.create.engine.sql
浏览文件 @
df2691b0
...
...
@@ -167,6 +167,7 @@ create table ACT_RU_EVENT_SUBSCR (
ACTIVITY_ID_
varchar
(
64
),
CONFIGURATION_
varchar
(
255
),
CREATED_
timestamp
not
null
,
TENANT_ID_
varchar
(
255
)
default
''
,
primary
key
(
ID_
)
);
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.mssql.create.engine.sql
浏览文件 @
df2691b0
...
...
@@ -167,6 +167,7 @@ create table ACT_RU_EVENT_SUBSCR (
ACTIVITY_ID_
nvarchar
(
64
),
CONFIGURATION_
nvarchar
(
255
),
CREATED_
datetime
not
null
,
TENANT_ID_
nvarchar
(
255
)
default
''
,
primary
key
(
ID_
)
);
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.mysql.create.engine.sql
浏览文件 @
df2691b0
...
...
@@ -167,6 +167,7 @@ create table ACT_RU_EVENT_SUBSCR (
ACTIVITY_ID_
varchar
(
64
),
CONFIGURATION_
varchar
(
255
),
CREATED_
timestamp
(
3
)
not
null
DEFAULT
CURRENT_TIMESTAMP
(
3
),
TENANT_ID_
varchar
(
255
)
default
''
,
primary
key
(
ID_
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COLLATE
utf8_bin
;
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.mysql55.create.engine.sql
浏览文件 @
df2691b0
...
...
@@ -167,6 +167,7 @@ create table ACT_RU_EVENT_SUBSCR (
ACTIVITY_ID_
varchar
(
64
),
CONFIGURATION_
varchar
(
255
),
CREATED_
timestamp
not
null
DEFAULT
CURRENT_TIMESTAMP
,
TENANT_ID_
varchar
(
255
)
default
''
,
primary
key
(
ID_
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COLLATE
utf8_bin
;
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.oracle.create.engine.sql
浏览文件 @
df2691b0
...
...
@@ -167,6 +167,7 @@ create table ACT_RU_EVENT_SUBSCR (
ACTIVITY_ID_
NVARCHAR2
(
64
),
CONFIGURATION_
NVARCHAR2
(
255
),
CREATED_
TIMESTAMP
(
6
)
not
null
,
TENANT_ID_
NVARCHAR2
(
255
)
DEFAULT
''
,
primary
key
(
ID_
)
);
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/create/activiti.postgres.create.engine.sql
浏览文件 @
df2691b0
...
...
@@ -167,6 +167,7 @@ create table ACT_RU_EVENT_SUBSCR (
ACTIVITY_ID_
varchar
(
64
),
CONFIGURATION_
varchar
(
255
),
CREATED_
timestamp
not
null
,
TENANT_ID_
varchar
(
255
)
default
''
,
primary
key
(
ID_
)
);
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/EventSubscription.xml
浏览文件 @
df2691b0
...
...
@@ -29,7 +29,8 @@
<result
property=
"processInstanceId"
column=
"PROC_INST_ID_"
jdbcType=
"VARCHAR"
/>
<result
property=
"activityId"
column=
"ACTIVITY_ID_"
jdbcType=
"VARCHAR"
/>
<result
property=
"configuration"
column=
"CONFIGURATION_"
jdbcType=
"VARCHAR"
/>
<result
property=
"created"
column=
"CREATED_"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"created"
column=
"CREATED_"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"tenantId"
column=
"TENANT_ID_"
jdbcType=
"VARCHAR"
/>
<discriminator
javaType=
"string"
column=
"EVENT_TYPE_"
>
<case
value=
"message"
resultMap=
"messageResultMap"
/>
<case
value=
"signal"
resultMap=
"signalResultMap"
/>
...
...
@@ -92,10 +93,10 @@
and EVENT_NAME_ = #{parameter.eventName}
and EXC.SUSPENSION_STATE_ = 1
<if
test=
"parameter.tenantId != null"
>
and E
XC
.TENANT_ID_ = #{parameter.tenantId}
and E
VT
.TENANT_ID_ = #{parameter.tenantId}
</if>
<if
test=
"parameter.tenantId == null"
>
and (E
XC.TENANT_ID_ = '' or EXC
.TENANT_ID_ is null)
and (E
VT.TENANT_ID_ = '' or EVT
.TENANT_ID_ is null)
</if>
</select>
...
...
@@ -155,6 +156,12 @@
from ${prefix}ACT_RU_EVENT_SUBSCR
where (EVENT_TYPE_ = #{parameter.eventType})
and (EVENT_NAME_ = #{parameter.eventName})
<if
test=
"parameter.tenantId != null"
>
and TENANT_ID_ = #{parameter.tenantId}
</if>
<if
test=
"parameter.tenantId == null"
>
and (TENANT_ID_ = '' or TENANT_ID_ is null)
</if>
</select>
<select
id=
"selectEventSubscriptionsByNameAndExecution"
resultMap=
"eventSubscriptionResultMap"
parameterType=
"org.activiti.engine.impl.db.ListQueryParameterObject"
>
...
...
@@ -165,12 +172,18 @@
and (EXECUTION_ID_ = #{parameter.executionId})
</select>
<select
id=
"selectMessageStartEventSubscriptionByName"
resultMap=
"eventSubscriptionResultMap"
parameterType=
"
string
"
>
<select
id=
"selectMessageStartEventSubscriptionByName"
resultMap=
"eventSubscriptionResultMap"
parameterType=
"
map
"
>
select *
from ${prefix}ACT_RU_EVENT_SUBSCR
where (EVENT_TYPE_ = 'message')
and (EVENT_NAME_ = #{
parameter
})
and (EVENT_NAME_ = #{
eventName
})
and EXECUTION_ID_ is null
<if
test=
"tenantId != null"
>
and TENANT_ID_ = #{tenantId}
</if>
<if
test=
"tenantId == null"
>
and (TENANT_ID_ = '' or TENANT_ID_ is null)
</if>
</select>
...
...
@@ -186,7 +199,8 @@
PROC_INST_ID_,
ACTIVITY_ID_,
CONFIGURATION_,
CREATED_
CREATED_,
TENANT_ID_,
)
values (#{id, jdbcType=VARCHAR},
1,
...
...
@@ -196,7 +210,8 @@
#{processInstanceId, jdbcType=VARCHAR},
#{activityId, jdbcType=VARCHAR},
#{configuration, jdbcType=VARCHAR},
#{created, jdbcType=TIMESTAMP}
#{created, jdbcType=TIMESTAMP},
#{tenantId, jdbcType=VARCHAR}
)
</insert>
...
...
@@ -211,7 +226,8 @@
PROC_INST_ID_ = #{processInstanceId, jdbcType=INTEGER},
ACTIVITY_ID_ = #{activityId, jdbcType=INTEGER},
CONFIGURATION_ = #{configuration, jdbcType=VARCHAR},
CREATED_ = #{created, jdbcType=TIMESTAMP}
CREATED_ = #{created, jdbcType=TIMESTAMP},
TENANT_ID_ = #{tenantId, jdbcType-VARCHAR}
</set>
where ID_= #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
...
...
@@ -229,7 +245,8 @@
PROC_INST_ID_,
ACTIVITY_ID_,
CONFIGURATION_,
CREATED_
CREATED_,
TENANT_ID_
)
values (#{id, jdbcType=VARCHAR},
1,
...
...
@@ -239,7 +256,8 @@
#{processInstanceId, jdbcType=VARCHAR},
#{activityId, jdbcType=VARCHAR},
#{configuration, jdbcType=VARCHAR},
#{created, jdbcType=TIMESTAMP}
#{created, jdbcType=TIMESTAMP},
#{tenantId, jdbcType=VARCHAR}
)
</insert>
...
...
@@ -254,7 +272,8 @@
PROC_INST_ID_ = #{processInstanceId, jdbcType=INTEGER},
ACTIVITY_ID_ = #{activityId, jdbcType=INTEGER},
CONFIGURATION_ = #{configuration, jdbcType=VARCHAR},
CREATED_ = #{created, jdbcType=TIMESTAMP}
CREATED_ = #{created, jdbcType=TIMESTAMP},
TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
</set>
where ID_= #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
...
...
@@ -272,7 +291,8 @@
PROC_INST_ID_,
ACTIVITY_ID_,
CONFIGURATION_,
CREATED_
CREATED_,
TENANT_ID_
)
values (#{id, jdbcType=VARCHAR},
1,
...
...
@@ -282,7 +302,8 @@
#{processInstanceId, jdbcType=VARCHAR},
#{activityId, jdbcType=VARCHAR},
#{configuration, jdbcType=VARCHAR},
#{created, jdbcType=TIMESTAMP}
#{created, jdbcType=TIMESTAMP},
#{tenantId, jdbcType=VARCHAR}
)
</insert>
...
...
@@ -297,11 +318,20 @@
PROC_INST_ID_ = #{processInstanceId, jdbcType=INTEGER},
ACTIVITY_ID_ = #{activityId, jdbcType=INTEGER},
CONFIGURATION_ = #{configuration, jdbcType=VARCHAR},
CREATED_ = #{created, jdbcType=TIMESTAMP}
CREATED_ = #{created, jdbcType=TIMESTAMP},
TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
</set>
where ID_= #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
</update>
<!-- tenantId update -->
<update
id=
"updateTenantIdOfEventSubscriptions"
parameterType=
"map"
>
update ${prefix}ACT_RU_EVENT_SUBSCR
<set>
TENANT_ID_ = #{newTenantId, jdbcType=VARCHAR}
</set>
where TENANT_ID_ = #{oldTenantId, jdbcType=VARCHAR}
</update>
</mapper>
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.db2.upgradestep.514.to.515.engine.sql
浏览文件 @
df2691b0
...
...
@@ -42,6 +42,11 @@ alter table ACT_RE_MODEL
Call
Sysproc
.
admin_cmd
(
'REORG TABLE ACT_RE_MODEL'
);
alter
table
ACT_RU_EVENT_SUBSCR
add
TENANT_ID_
varchar
(
255
)
default
''
;
Call
Sysproc
.
admin_cmd
(
'REORG TABLE ACT_RU_EVENT_SUBSCR'
);
alter
table
ACT_RE_PROCDEF
drop
unique
ACT_UNIQ_PROCDEF
;
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.h2.upgradestep.514.to.515.engine.sql
浏览文件 @
df2691b0
...
...
@@ -19,7 +19,10 @@ alter table ACT_RU_JOB
add
TENANT_ID_
varchar
(
255
)
default
''
;
alter
table
ACT_RE_MODEL
add
TENANT_ID_
varchar
(
255
)
default
''
;
add
TENANT_ID_
varchar
(
255
)
default
''
;
alter
table
ACT_RU_EVENT_SUBSCR
add
TENANT_ID_
varchar
(
255
)
default
''
;
alter
table
ACT_RE_PROCDEF
drop
constraint
ACT_UNIQ_PROCDEF
;
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.mssql.upgradestep.514.to.515.engine.sql
浏览文件 @
df2691b0
...
...
@@ -21,6 +21,9 @@ alter table ACT_RU_JOB
alter
table
ACT_RE_MODEL
add
TENANT_ID_
nvarchar
(
255
)
default
''
;
alter
table
ACT_RU_EVENT_SUBSCR
add
TENANT_ID_
nvarchar
(
255
)
default
''
;
alter
table
ACT_RE_PROCDEF
drop
constraint
ACT_UNIQ_PROCDEF
;
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.mysql.upgradestep.514.to.515.engine.sql
浏览文件 @
df2691b0
...
...
@@ -98,6 +98,8 @@ alter table ACT_RU_JOB
alter
table
ACT_RE_MODEL
add
TENANT_ID_
varchar
(
255
)
default
''
;
alter
table
ACT_RU_EVENT_SUBSCR
add
TENANT_ID_
varchar
(
255
)
default
''
;
alter
table
ACT_RE_PROCDEF
drop
index
ACT_UNIQ_PROCDEF
;
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.mysql55.upgradestep.514.to.515.engine.sql
浏览文件 @
df2691b0
...
...
@@ -33,6 +33,9 @@ alter table ACT_RU_JOB
alter
table
ACT_RE_MODEL
add
TENANT_ID_
varchar
(
255
)
default
''
;
alter
table
ACT_RU_EVENT_SUBSCR
add
TENANT_ID_
varchar
(
255
)
default
''
;
alter
table
ACT_RE_PROCDEF
drop
index
ACT_UNIQ_PROCDEF
;
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.oracle.upgradestep.514.to.515.engine.sql
浏览文件 @
df2691b0
...
...
@@ -19,7 +19,10 @@ alter table ACT_RU_JOB
add
TENANT_ID_
NVARCHAR2
(
255
)
default
''
;
alter
table
ACT_RE_MODEL
add
TENANT_ID_
NVARCHAR2
(
255
)
default
''
;
add
TENANT_ID_
NVARCHAR2
(
255
)
default
''
;
alter
table
ACT_RU_EVENT_SUBSCR
add
TENANT_ID_
NVARCHAR2
(
255
)
default
''
;
alter
table
ACT_RE_PROCDEF
drop
constraint
ACT_UNIQ_PROCDEF
;
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/upgrade/activiti.postgres.upgradestep.514.to.515.engine.sql
浏览文件 @
df2691b0
...
...
@@ -21,6 +21,9 @@ alter table ACT_RU_JOB
alter
table
ACT_RE_MODEL
add
TENANT_ID_
varchar
(
255
)
default
''
;
alter
table
ACT_RU_EVENT_SUBSCR
add
TENANT_ID_
varchar
(
255
)
default
''
;
alter
table
ACT_RE_PROCDEF
drop
constraint
ACT_UNIQ_PROCDEF
;
...
...
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/tenant/TenancyTest.java
浏览文件 @
df2691b0
...
...
@@ -737,4 +737,75 @@ public class TenancyTest extends PluggableActivitiTestCase {
}
}
public
void
testStartProcessInstanceByMessageTenancy
()
{
// Deploy process both with and without tenant
repositoryService
.
createDeployment
()
.
addClasspathResource
(
"org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml"
)
.
deploy
();
repositoryService
.
createDeployment
()
.
addClasspathResource
(
"org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml"
)
.
tenantId
(
TEST_TENANT_ID
)
.
deploy
();
// Verify query
assertEquals
(
2
,
repositoryService
.
createProcessDefinitionQuery
().
messageEventSubscriptionName
(
"My message"
).
count
());
assertEquals
(
1
,
repositoryService
.
createProcessDefinitionQuery
().
messageEventSubscriptionName
(
"My message"
).
processDefinitionWithoutTenantId
().
count
());
assertEquals
(
1
,
repositoryService
.
createProcessDefinitionQuery
().
messageEventSubscriptionName
(
"My message"
).
processDefinitionTenantId
(
TEST_TENANT_ID
).
count
());
// Start a process instance by message without tenant
runtimeService
.
startProcessInstanceByMessage
(
"My message"
);
runtimeService
.
startProcessInstanceByMessage
(
"My message"
);
assertEquals
(
2
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
count
());
assertEquals
(
2
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
taskWithoutTenantId
().
count
());
assertEquals
(
0
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
taskTenantId
(
TEST_TENANT_ID
).
count
());
// Start a process instance by message with tenant
runtimeService
.
startProcessInstanceByMessageAndTenantId
(
"My message"
,
TEST_TENANT_ID
);
runtimeService
.
startProcessInstanceByMessageAndTenantId
(
"My message"
,
TEST_TENANT_ID
);
runtimeService
.
startProcessInstanceByMessageAndTenantId
(
"My message"
,
TEST_TENANT_ID
);
assertEquals
(
5
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
count
());
assertEquals
(
2
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
taskWithoutTenantId
().
count
());
assertEquals
(
3
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
taskTenantId
(
TEST_TENANT_ID
).
count
());
// Cleanup
for
(
Deployment
deployment
:
repositoryService
.
createDeploymentQuery
().
list
())
{
repositoryService
.
deleteDeployment
(
deployment
.
getId
(),
true
);
}
}
public
void
testStartProcessInstanceByMessageTenancyReversed
()
{
// same as above, but now reversed
// Deploy process both with and without tenant
repositoryService
.
createDeployment
()
.
addClasspathResource
(
"org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml"
)
.
deploy
();
repositoryService
.
createDeployment
()
.
addClasspathResource
(
"org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml"
)
.
tenantId
(
TEST_TENANT_ID
)
.
deploy
();
// Start a process instance by message with tenant
runtimeService
.
startProcessInstanceByMessageAndTenantId
(
"My message"
,
TEST_TENANT_ID
);
runtimeService
.
startProcessInstanceByMessageAndTenantId
(
"My message"
,
TEST_TENANT_ID
);
runtimeService
.
startProcessInstanceByMessageAndTenantId
(
"My message"
,
TEST_TENANT_ID
);
assertEquals
(
3
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
count
());
assertEquals
(
0
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
taskWithoutTenantId
().
count
());
assertEquals
(
3
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
taskTenantId
(
TEST_TENANT_ID
).
count
());
// Start a process instance by message without tenant
runtimeService
.
startProcessInstanceByMessage
(
"My message"
);
runtimeService
.
startProcessInstanceByMessage
(
"My message"
);
assertEquals
(
5
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
count
());
assertEquals
(
2
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
taskWithoutTenantId
().
count
());
assertEquals
(
3
,
taskService
.
createTaskQuery
().
taskName
(
"My task"
).
taskTenantId
(
TEST_TENANT_ID
).
count
());
// Cleanup
for
(
Deployment
deployment
:
repositoryService
.
createDeploymentQuery
().
list
())
{
repositoryService
.
deleteDeployment
(
deployment
.
getId
(),
true
);
}
}
}
modules/activiti-engine/src/test/resources/org/activiti/engine/test/api/tenant/TenancyTest.testMessageTenancy.bpmn20.xml
0 → 100644
浏览文件 @
df2691b0
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns=
"http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti=
"http://activiti.org/bpmn"
xmlns:tns=
"Examples"
targetNamespace=
"Examples"
>
<message
id=
"myMessage"
name=
"My message"
/>
<process
id=
"testMessageMt"
>
<startEvent
id=
"theStart"
>
<messageEventDefinition
messageRef=
"tns:myMessage"
/>
</startEvent>
<sequenceFlow
id=
"flow1"
sourceRef=
"theStart"
targetRef=
"theTask"
/>
<userTask
id=
"theTask"
name=
"My task"
/>
<sequenceFlow
id=
"flow2"
sourceRef=
"theTask"
targetRef=
"theEnd"
/>
<endEvent
id=
"theEnd"
/>
</process>
</definitions>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录