Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
开发团队
Flowable Engine
提交
a13eb6b6
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,发现更多精彩内容 >>
提交
a13eb6b6
编写于
7月 01, 2013
作者:
J
Joram Barrez
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of github.com:Activiti/Activiti
上级
22f6c8d0
b38bf5cd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
76 addition
and
7 deletion
+76
-7
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/TaskEntity.java
...g/activiti/engine/impl/persistence/entity/TaskEntity.java
+51
-0
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/runtime/RuntimeServiceTest.java
.../activiti/engine/test/api/runtime/RuntimeServiceTest.java
+10
-0
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/task/TaskAndVariablesQueryTest.java
...iviti/engine/test/api/task/TaskAndVariablesQueryTest.java
+14
-6
userguide/src/en/chapters/ch14-REST.xml
userguide/src/en/chapters/ch14-REST.xml
+1
-1
未找到文件。
modules/activiti-engine/src/main/java/org/activiti/engine/impl/persistence/entity/TaskEntity.java
浏览文件 @
a13eb6b6
...
...
@@ -723,9 +723,60 @@ public class TaskEntity extends VariableScopeImpl implements Task, DelegateTask,
return
variables
;
}
public
List
<
VariableInstanceEntity
>
getQueryVariables
()
{
if
(
queryVariables
==
null
&&
Context
.
getCommandContext
()
!=
null
)
{
queryVariables
=
new
VariableInitializingList
();
}
return
queryVariables
;
}
public
void
setQueryVariables
(
List
<
VariableInstanceEntity
>
queryVariables
)
{
this
.
queryVariables
=
queryVariables
;
}
/**
* List that initialized binary variable values if command-context is active.
*
* @author Frederik Heremans
*/
private
class
VariableInitializingList
extends
ArrayList
<
VariableInstanceEntity
>
{
private
static
final
long
serialVersionUID
=
1L
;
@Override
public
void
add
(
int
index
,
VariableInstanceEntity
e
)
{
super
.
add
(
index
,
e
);
initializeBinaryVariable
(
e
);
}
@Override
public
boolean
add
(
VariableInstanceEntity
e
)
{
initializeBinaryVariable
(
e
);
return
super
.
add
(
e
);
}
@Override
public
boolean
addAll
(
Collection
<
?
extends
VariableInstanceEntity
>
c
)
{
for
(
VariableInstanceEntity
e
:
c
)
{
initializeBinaryVariable
(
e
);
}
return
super
.
addAll
(
c
);
}
@Override
public
boolean
addAll
(
int
index
,
Collection
<
?
extends
VariableInstanceEntity
>
c
)
{
for
(
VariableInstanceEntity
e
:
c
)
{
initializeBinaryVariable
(
e
);
}
return
super
.
addAll
(
index
,
c
);
}
/**
* If the passed {@link VariableInstanceEntity} is a binary variable and the command-context is active,
* the variable value is fetched to ensure the byte-array is populated.
*/
@SuppressWarnings
(
"deprecation"
)
protected
void
initializeBinaryVariable
(
VariableInstanceEntity
e
)
{
if
(
Context
.
getCommandContext
()
!=
null
&&
e
!=
null
&&
e
.
getByteArrayValueId
()
!=
null
)
{
e
.
getValue
();
}
}
}
}
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/runtime/RuntimeServiceTest.java
浏览文件 @
a13eb6b6
...
...
@@ -41,6 +41,16 @@ import org.activiti.engine.test.Deployment;
*/
public
class
RuntimeServiceTest
extends
PluggableActivitiTestCase
{
@Deployment
(
resources
={
"org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml"
})
public
void
testStartProcessInstanceWithVariables
()
{
Map
<
String
,
Object
>
vars
=
new
HashMap
<
String
,
Object
>();
vars
.
put
(
"basicType"
,
new
DummySerializable
());
runtimeService
.
startProcessInstanceByKey
(
"oneTaskProcess"
,
vars
);
Task
task
=
taskService
.
createTaskQuery
().
includeProcessVariables
().
singleResult
();
assertNotNull
(
task
.
getProcessVariables
());
}
public
void
testStartProcessInstanceByKeyNullKey
()
{
try
{
runtimeService
.
startProcessInstanceByKey
(
null
);
...
...
modules/activiti-engine/src/test/java/org/activiti/engine/test/api/task/TaskAndVariablesQueryTest.java
浏览文件 @
a13eb6b6
...
...
@@ -59,12 +59,14 @@ public class TaskAndVariablesQueryTest extends PluggableActivitiTestCase {
public
void
testQuery
()
{
Task
task
=
(
Task
)
taskService
.
createTaskQuery
().
includeTaskLocalVariables
().
taskAssignee
(
"gonzo"
).
singleResult
();
Map
<
String
,
Object
>
variableMap
=
task
.
getTaskLocalVariables
();
assertEquals
(
2
,
variableMap
.
size
());
assertEquals
(
3
,
variableMap
.
size
());
assertEquals
(
0
,
task
.
getProcessVariables
().
size
());
assertNotNull
(
variableMap
.
get
(
"testVar"
));
assertEquals
(
"someVariable"
,
variableMap
.
get
(
"testVar"
));
assertNotNull
(
variableMap
.
get
(
"testVar2"
));
assertEquals
(
123
,
variableMap
.
get
(
"testVar2"
));
assertNotNull
(
variableMap
.
get
(
"testVarBinary"
));
assertEquals
(
"This is a binary variable"
,
new
String
((
byte
[])
variableMap
.
get
(
"testVarBinary"
)));
List
<
Task
>
tasks
=
taskService
.
createTaskQuery
().
list
();
assertEquals
(
3
,
tasks
.
size
());
...
...
@@ -75,12 +77,14 @@ public class TaskAndVariablesQueryTest extends PluggableActivitiTestCase {
Map
<
String
,
Object
>
startMap
=
new
HashMap
<
String
,
Object
>();
startMap
.
put
(
"processVar"
,
true
);
startMap
.
put
(
"binaryVariable"
,
"This is a binary process variable"
.
getBytes
());
runtimeService
.
startProcessInstanceByKey
(
"oneTaskProcess"
,
startMap
);
task
=
(
Task
)
taskService
.
createTaskQuery
().
includeProcessVariables
().
taskAssignee
(
"kermit"
).
singleResult
();
assertEquals
(
1
,
task
.
getProcessVariables
().
size
());
assertEquals
(
2
,
task
.
getProcessVariables
().
size
());
assertEquals
(
0
,
task
.
getTaskLocalVariables
().
size
());
assertTrue
((
Boolean
)
task
.
getProcessVariables
().
get
(
"processVar"
));
assertEquals
(
"This is a binary process variable"
,
new
String
((
byte
[])
task
.
getProcessVariables
().
get
(
"binaryVariable"
)));
taskService
.
setVariable
(
task
.
getId
(),
"anotherProcessVar"
,
123
);
taskService
.
setVariableLocal
(
task
.
getId
(),
"localVar"
,
"test"
);
...
...
@@ -91,14 +95,15 @@ public class TaskAndVariablesQueryTest extends PluggableActivitiTestCase {
assertEquals
(
"test"
,
task
.
getTaskLocalVariables
().
get
(
"localVar"
));
task
=
(
Task
)
taskService
.
createTaskQuery
().
includeProcessVariables
().
taskAssignee
(
"kermit"
).
singleResult
();
assertEquals
(
2
,
task
.
getProcessVariables
().
size
());
assertEquals
(
3
,
task
.
getProcessVariables
().
size
());
assertEquals
(
0
,
task
.
getTaskLocalVariables
().
size
());
assertEquals
(
true
,
task
.
getProcessVariables
().
get
(
"processVar"
));
assertEquals
(
123
,
task
.
getProcessVariables
().
get
(
"anotherProcessVar"
));
assertEquals
(
"This is a binary process variable"
,
new
String
((
byte
[])
task
.
getProcessVariables
().
get
(
"binaryVariable"
)));
tasks
=
taskService
.
createTaskQuery
().
includeTaskLocalVariables
().
taskCandidateUser
(
"kermit"
).
list
();
assertEquals
(
2
,
tasks
.
size
());
assertEquals
(
1
,
tasks
.
get
(
0
).
getTaskLocalVariables
().
size
());
assertEquals
(
2
,
tasks
.
get
(
0
).
getTaskLocalVariables
().
size
());
assertEquals
(
"test"
,
tasks
.
get
(
0
).
getTaskLocalVariables
().
get
(
"test"
));
assertEquals
(
0
,
tasks
.
get
(
0
).
getProcessVariables
().
size
());
...
...
@@ -113,17 +118,18 @@ public class TaskAndVariablesQueryTest extends PluggableActivitiTestCase {
assertEquals
(
"test"
,
task
.
getTaskLocalVariables
().
get
(
"localVar"
));
task
=
(
Task
)
taskService
.
createTaskQuery
().
includeProcessVariables
().
taskAssignee
(
"kermit"
).
taskVariableValueEquals
(
"localVar"
,
"test"
).
singleResult
();
assertEquals
(
2
,
task
.
getProcessVariables
().
size
());
assertEquals
(
3
,
task
.
getProcessVariables
().
size
());
assertEquals
(
0
,
task
.
getTaskLocalVariables
().
size
());
assertEquals
(
true
,
task
.
getProcessVariables
().
get
(
"processVar"
));
assertEquals
(
123
,
task
.
getProcessVariables
().
get
(
"anotherProcessVar"
));
task
=
(
Task
)
taskService
.
createTaskQuery
().
includeTaskLocalVariables
().
includeProcessVariables
().
taskAssignee
(
"kermit"
).
singleResult
();
assertEquals
(
2
,
task
.
getProcessVariables
().
size
());
assertEquals
(
3
,
task
.
getProcessVariables
().
size
());
assertEquals
(
1
,
task
.
getTaskLocalVariables
().
size
());
assertEquals
(
"test"
,
task
.
getTaskLocalVariables
().
get
(
"localVar"
));
assertEquals
(
true
,
task
.
getProcessVariables
().
get
(
"processVar"
));
assertEquals
(
123
,
task
.
getProcessVariables
().
get
(
"anotherProcessVar"
));
assertEquals
(
"This is a binary process variable"
,
new
String
((
byte
[])
task
.
getProcessVariables
().
get
(
"binaryVariable"
)));
}
/**
...
...
@@ -144,6 +150,7 @@ public class TaskAndVariablesQueryTest extends PluggableActivitiTestCase {
taskService
.
saveTask
(
task
);
ids
.
add
(
task
.
getId
());
taskService
.
setVariableLocal
(
task
.
getId
(),
"test"
,
"test"
);
taskService
.
setVariableLocal
(
task
.
getId
(),
"testBinary"
,
"This is a binary variable"
.
getBytes
());
taskService
.
addCandidateUser
(
task
.
getId
(),
"kermit"
);
}
...
...
@@ -156,6 +163,7 @@ public class TaskAndVariablesQueryTest extends PluggableActivitiTestCase {
taskService
.
saveTask
(
task
);
taskService
.
setAssignee
(
task
.
getId
(),
"gonzo"
);
taskService
.
setVariableLocal
(
task
.
getId
(),
"testVar"
,
"someVariable"
);
taskService
.
setVariableLocal
(
task
.
getId
(),
"testVarBinary"
,
"This is a binary variable"
.
getBytes
());
taskService
.
setVariableLocal
(
task
.
getId
(),
"testVar2"
,
123
);
ids
.
add
(
task
.
getId
());
...
...
userguide/src/en/chapters/ch14-REST.xml
浏览文件 @
a13eb6b6
...
...
@@ -5068,7 +5068,7 @@ In case the variable is a binary variable or serializable, the <literal>valueUrl
<section>
<title>
Query for tasks
</title>
<para>
<programlisting>
POST
reposito
ry/tasks
</programlisting>
<programlisting>
POST
que
ry/tasks
</programlisting>
</para>
<para>
<emphasis
role=
"bold"
>
Request body:
</emphasis>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录