Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
74e335ea
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,发现更多精彩内容 >>
提交
74e335ea
编写于
1月 22, 2013
作者:
J
Joram Barrez
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of github.com:Activiti/Activiti
上级
849ec268
b681ebdc
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
80 addition
and
8 deletion
+80
-8
modules/activiti-engine/src/main/java/org/activiti/engine/history/HistoricVariableInstance.java
...org/activiti/engine/history/HistoricVariableInstance.java
+5
-0
modules/activiti-engine/src/main/java/org/activiti/engine/history/HistoricVariableInstanceQuery.java
...ctiviti/engine/history/HistoricVariableInstanceQuery.java
+7
-0
modules/activiti-engine/src/main/java/org/activiti/engine/impl/HistoricVariableInstanceQueryImpl.java
...tiviti/engine/impl/HistoricVariableInstanceQueryImpl.java
+12
-7
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/HistoricVariableInstance.xml
...g/activiti/db/mapping/entity/HistoricVariableInstance.xml
+4
-1
modules/activiti-engine/src/test/java/org/activiti/standalone/history/FullHistoryTest.java
...java/org/activiti/standalone/history/FullHistoryTest.java
+52
-0
未找到文件。
modules/activiti-engine/src/main/java/org/activiti/engine/history/HistoricVariableInstance.java
浏览文件 @
74e335ea
...
...
@@ -36,4 +36,9 @@ public interface HistoricVariableInstance {
/** The process instance reference. */
String
getProcessInstanceId
();
/**
* @return the task id of the task, in case this variable instance has been set locally
* on a task. Returns null, if this variable is not related to a task.
*/
String
getTaskId
();
}
modules/activiti-engine/src/main/java/org/activiti/engine/history/HistoricVariableInstanceQuery.java
浏览文件 @
74e335ea
...
...
@@ -25,12 +25,18 @@ public interface HistoricVariableInstanceQuery extends Query<HistoricVariableIns
/** Only select historic process variables with the given process instance. */
HistoricVariableInstanceQuery
processInstanceId
(
String
processInstanceId
);
/** Only select historic process variables with the given task. */
HistoricVariableInstanceQuery
taskId
(
String
taskId
);
/** Only select historic process variables with the given variable name. */
HistoricVariableInstanceQuery
variableName
(
String
variableName
);
/** Only select historic process variables where the given variable name is like. */
HistoricVariableInstanceQuery
variableNameLike
(
String
variableNameLike
);
/** Only select historic process variables which were not set task-local. */
HistoricVariableInstanceQuery
excludeTaskVariables
();
/**
* only select historic process variables with the given name and value
...
...
@@ -40,4 +46,5 @@ public interface HistoricVariableInstanceQuery extends Query<HistoricVariableIns
HistoricVariableInstanceQuery
orderByProcessInstanceId
();
HistoricVariableInstanceQuery
orderByVariableName
();
}
modules/activiti-engine/src/main/java/org/activiti/engine/impl/HistoricVariableInstanceQueryImpl.java
浏览文件 @
74e335ea
...
...
@@ -16,13 +16,11 @@ package org.activiti.engine.impl;
import
java.util.List
;
import
org.activiti.engine.ActivitiException
;
import
org.activiti.engine.history.HistoricDetail
;
import
org.activiti.engine.history.HistoricVariableInstance
;
import
org.activiti.engine.history.HistoricVariableInstanceQuery
;
import
org.activiti.engine.impl.context.Context
;
import
org.activiti.engine.impl.interceptor.CommandContext
;
import
org.activiti.engine.impl.interceptor.CommandExecutor
;
import
org.activiti.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity
;
import
org.activiti.engine.impl.persistence.entity.HistoricVariableInstanceEntity
;
import
org.activiti.engine.impl.variable.VariableTypes
;
...
...
@@ -69,9 +67,21 @@ public class HistoricVariableInstanceQueryImpl extends AbstractQuery<HistoricVar
if
(
taskId
==
null
)
{
throw
new
ActivitiException
(
"taskId is null"
);
}
if
(
excludeTaskRelated
)
{
throw
new
ActivitiException
(
"Cannot use taskId together with excludeTaskVariables"
);
}
this
.
taskId
=
taskId
;
return
this
;
}
@Override
public
HistoricVariableInstanceQuery
excludeTaskVariables
()
{
if
(
taskId
!=
null
)
{
throw
new
ActivitiException
(
"Cannot use taskId together with excludeTaskVariables"
);
}
excludeTaskRelated
=
true
;
return
this
;
}
public
HistoricVariableInstanceQuery
variableName
(
String
variableName
)
{
if
(
variableName
==
null
)
{
...
...
@@ -101,11 +111,6 @@ public class HistoricVariableInstanceQueryImpl extends AbstractQuery<HistoricVar
return
this
;
}
public
HistoricVariableInstanceQuery
excludeTaskDetails
()
{
this
.
excludeTaskRelated
=
true
;
return
this
;
}
protected
void
ensureVariablesInitialized
()
{
if
(
this
.
queryVariableValue
!=
null
)
{
VariableTypes
variableTypes
=
Context
.
getProcessEngineConfiguration
().
getVariableTypes
();
...
...
modules/activiti-engine/src/main/resources/org/activiti/db/mapping/entity/HistoricVariableInstance.xml
浏览文件 @
74e335ea
...
...
@@ -96,7 +96,10 @@
RES.PROC_INST_ID_ = #{processInstanceId}
</if>
<if
test=
"taskId != null"
>
RES.TASK_ID_ = #{taskId}
and RES.TASK_ID_ = #{taskId}
</if>
<if
test=
"excludeTaskRelated"
>
and RES.TASK_ID_ is NULL
</if>
<if
test=
"variableName != null"
>
and RES.NAME_ = #{variableName}
...
...
modules/activiti-engine/src/test/java/org/activiti/standalone/history/FullHistoryTest.java
浏览文件 @
74e335ea
...
...
@@ -202,6 +202,58 @@ public class FullHistoryTest extends ResourceActivitiTestCase {
assertEquals
(
123456789L
,
historicVariable
.
getValue
());
}
@Deployment
(
resources
={
"org/activiti/engine/test/history/oneTaskProcess.bpmn20.xml"
})
public
void
testHistoricVariableInstanceQueryTaskVariables
()
{
Map
<
String
,
Object
>
variables
=
new
HashMap
<
String
,
Object
>();
variables
.
put
(
"variable"
,
"setFromProcess"
);
ProcessInstance
processInstance
=
runtimeService
.
startProcessInstanceByKey
(
"oneTaskProcess"
,
variables
);
assertEquals
(
1
,
historyService
.
createHistoricVariableInstanceQuery
().
count
());
Task
activeTask
=
taskService
.
createTaskQuery
().
processInstanceId
(
processInstance
.
getId
()).
singleResult
();
assertNotNull
(
activeTask
);
taskService
.
setVariableLocal
(
activeTask
.
getId
(),
"variable"
,
"setFromTask"
);
// Check if additional variable is available in history, task-local
assertEquals
(
2
,
historyService
.
createHistoricVariableInstanceQuery
().
count
());
assertEquals
(
1
,
historyService
.
createHistoricVariableInstanceQuery
().
taskId
(
activeTask
.
getId
()).
count
());
assertEquals
(
"setFromTask"
,
historyService
.
createHistoricVariableInstanceQuery
().
taskId
(
activeTask
.
getId
()).
singleResult
().
getValue
());
assertEquals
(
activeTask
.
getId
(),
historyService
.
createHistoricVariableInstanceQuery
().
taskId
(
activeTask
.
getId
()).
singleResult
().
getTaskId
());
assertEquals
(
1
,
historyService
.
createHistoricVariableInstanceQuery
().
excludeTaskVariables
().
count
());
// Test null task-id
try
{
historyService
.
createHistoricVariableInstanceQuery
().
taskId
(
null
).
singleResult
();
fail
(
"Exception expected"
);
}
catch
(
ActivitiException
ae
)
{
assertEquals
(
"taskId is null"
,
ae
.
getMessage
());
}
// Test invalid usage of taskId together with excludeTaskVariables
try
{
historyService
.
createHistoricVariableInstanceQuery
().
taskId
(
"123"
).
excludeTaskVariables
().
singleResult
();
fail
(
"Exception expected"
);
}
catch
(
ActivitiException
ae
)
{
assertEquals
(
"Cannot use taskId together with excludeTaskVariables"
,
ae
.
getMessage
());
}
try
{
historyService
.
createHistoricVariableInstanceQuery
().
excludeTaskVariables
().
taskId
(
"123"
).
singleResult
();
fail
(
"Exception expected"
);
}
catch
(
ActivitiException
ae
)
{
assertEquals
(
"Cannot use taskId together with excludeTaskVariables"
,
ae
.
getMessage
());
}
}
@Deployment
(
resources
=
"org/activiti/standalone/history/FullHistoryTest.testVariableUpdates.bpmn20.xml"
)
public
void
testHistoricVariableInstanceQuery
()
{
Map
<
String
,
Object
>
variables
=
new
HashMap
<
String
,
Object
>();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录