Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
z_stack
Activiti
提交
8cbdec9e
A
Activiti
项目概览
z_stack
/
Activiti
11 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
Activiti
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8cbdec9e
编写于
1月 19, 2019
作者:
Y
yoshimoto
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Apply Activiti code style
上级
8467fd17
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
424 addition
and
378 deletion
+424
-378
activiti-engine/src/main/java/org/activiti/engine/impl/el/JsonNodeELResolver.java
.../java/org/activiti/engine/impl/el/JsonNodeELResolver.java
+329
-297
activiti-engine/src/main/java/org/activiti/engine/impl/el/VariableScopeElResolver.java
.../org/activiti/engine/impl/el/VariableScopeElResolver.java
+95
-81
未找到文件。
activiti-engine/src/main/java/org/activiti/engine/impl/el/JsonNodeELResolver.java
浏览文件 @
8cbdec9e
此差异已折叠。
点击以展开。
activiti-engine/src/main/java/org/activiti/engine/impl/el/VariableScopeElResolver.java
浏览文件 @
8cbdec9e
/* 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.
...
...
@@ -28,89 +28,103 @@ import org.activiti.engine.impl.persistence.entity.VariableInstance;
import
com.fasterxml.jackson.databind.JsonNode
;
/**
* Implementation of an {@link ELResolver} that resolves expressions with the process variables of a given {@link VariableScope} as context. <br>
* Also exposes the currently logged in username to be used in expressions (if any)
* Implementation of an {@link ELResolver} that resolves expressions with the
* process variables of a given {@link VariableScope} as context. <br>
* Also exposes the currently logged in username to be used in expressions (if
* any)
*
*
*
*/
public
class
VariableScopeElResolver
extends
ELResolver
{
public
static
final
String
EXECUTION_KEY
=
"execution"
;
public
static
final
String
TASK_KEY
=
"task"
;
public
static
final
String
LOGGED_IN_USER_KEY
=
"authenticatedUserId"
;
protected
VariableScope
variableScope
;
public
VariableScopeElResolver
(
VariableScope
variableScope
)
{
this
.
variableScope
=
variableScope
;
}
public
Object
getValue
(
ELContext
context
,
Object
base
,
Object
property
)
{
if
(
base
==
null
)
{
String
variable
=
(
String
)
property
;
// according to javadoc, can only be a String
if
((
EXECUTION_KEY
.
equals
(
property
)
&&
variableScope
instanceof
ExecutionEntity
)
||
(
TASK_KEY
.
equals
(
property
)
&&
variableScope
instanceof
TaskEntity
))
{
context
.
setPropertyResolved
(
true
);
return
variableScope
;
}
else
if
(
EXECUTION_KEY
.
equals
(
property
)
&&
variableScope
instanceof
TaskEntity
)
{
context
.
setPropertyResolved
(
true
);
return
((
TaskEntity
)
variableScope
).
getExecution
();
}
else
if
(
LOGGED_IN_USER_KEY
.
equals
(
property
))
{
context
.
setPropertyResolved
(
true
);
return
Authentication
.
getAuthenticatedUserId
();
}
else
{
if
(
variableScope
.
hasVariable
(
variable
))
{
context
.
setPropertyResolved
(
true
);
// if not set, the next elResolver in the CompositeElResolver will be called
VariableInstance
variableInstance
=
variableScope
.
getVariableInstance
(
variable
);
Object
value
=
variableInstance
.
getValue
();
if
(
(
"json"
.
equals
(
variableInstance
.
getTypeName
())
||
"longJson"
.
equals
(
variableInstance
.
getTypeName
()))
&&
(
value
instanceof
JsonNode
)
&&
((
JsonNode
)
value
).
isArray
()
)
{
return
Context
.
getProcessEngineConfiguration
().
getObjectMapper
().
convertValue
(
value
,
List
.
class
);
}
else
{
return
value
;
}
}
}
}
// property resolution (eg. bean.value) will be done by the
// BeanElResolver (part of the CompositeElResolver)
// It will use the bean resolved in this resolver as base.
return
null
;
}
public
boolean
isReadOnly
(
ELContext
context
,
Object
base
,
Object
property
)
{
if
(
base
==
null
)
{
String
variable
=
(
String
)
property
;
return
!
variableScope
.
hasVariable
(
variable
);
}
return
true
;
}
public
void
setValue
(
ELContext
context
,
Object
base
,
Object
property
,
Object
value
)
{
if
(
base
==
null
)
{
String
variable
=
(
String
)
property
;
if
(
variableScope
.
hasVariable
(
variable
))
{
variableScope
.
setVariable
(
variable
,
value
);
}
}
}
public
Class
<?>
getCommonPropertyType
(
ELContext
arg0
,
Object
arg1
)
{
return
Object
.
class
;
}
public
Iterator
<
FeatureDescriptor
>
getFeatureDescriptors
(
ELContext
arg0
,
Object
arg1
)
{
return
null
;
}
public
Class
<?>
getType
(
ELContext
arg0
,
Object
arg1
,
Object
arg2
)
{
return
Object
.
class
;
}
public
static
final
String
EXECUTION_KEY
=
"execution"
;
public
static
final
String
TASK_KEY
=
"task"
;
public
static
final
String
LOGGED_IN_USER_KEY
=
"authenticatedUserId"
;
protected
VariableScope
variableScope
;
public
VariableScopeElResolver
(
VariableScope
variableScope
)
{
this
.
variableScope
=
variableScope
;
}
@Override
public
Object
getValue
(
ELContext
context
,
Object
base
,
Object
property
)
{
if
(
base
==
null
)
{
String
variable
=
(
String
)
property
;
// according to javadoc, can
// only be a String
if
((
EXECUTION_KEY
.
equals
(
property
)
&&
variableScope
instanceof
ExecutionEntity
)
||
(
TASK_KEY
.
equals
(
property
)
&&
variableScope
instanceof
TaskEntity
))
{
context
.
setPropertyResolved
(
true
);
return
variableScope
;
}
else
if
(
EXECUTION_KEY
.
equals
(
property
)
&&
variableScope
instanceof
TaskEntity
)
{
context
.
setPropertyResolved
(
true
);
return
((
TaskEntity
)
variableScope
).
getExecution
();
}
else
if
(
LOGGED_IN_USER_KEY
.
equals
(
property
))
{
context
.
setPropertyResolved
(
true
);
return
Authentication
.
getAuthenticatedUserId
();
}
else
{
if
(
variableScope
.
hasVariable
(
variable
))
{
context
.
setPropertyResolved
(
true
);
// if not set, the next
// elResolver in the
// CompositeElResolver
// will be called
VariableInstance
variableInstance
=
variableScope
.
getVariableInstance
(
variable
);
Object
value
=
variableInstance
.
getValue
();
if
((
"json"
.
equals
(
variableInstance
.
getTypeName
())
||
"longJson"
.
equals
(
variableInstance
.
getTypeName
()))
&&
(
value
instanceof
JsonNode
)
&&
((
JsonNode
)
value
).
isArray
())
{
return
Context
.
getProcessEngineConfiguration
().
getObjectMapper
().
convertValue
(
value
,
List
.
class
);
}
else
{
return
value
;
}
}
}
}
// property resolution (eg. bean.value) will be done by the
// BeanElResolver (part of the CompositeElResolver)
// It will use the bean resolved in this resolver as base.
return
null
;
}
@Override
public
boolean
isReadOnly
(
ELContext
context
,
Object
base
,
Object
property
)
{
if
(
base
==
null
)
{
String
variable
=
(
String
)
property
;
return
!
variableScope
.
hasVariable
(
variable
);
}
return
true
;
}
@Override
public
void
setValue
(
ELContext
context
,
Object
base
,
Object
property
,
Object
value
)
{
if
(
base
==
null
)
{
String
variable
=
(
String
)
property
;
if
(
variableScope
.
hasVariable
(
variable
))
{
variableScope
.
setVariable
(
variable
,
value
);
}
}
}
@Override
public
Class
<?>
getCommonPropertyType
(
ELContext
arg0
,
Object
arg1
)
{
return
Object
.
class
;
}
@Override
public
Iterator
<
FeatureDescriptor
>
getFeatureDescriptors
(
ELContext
arg0
,
Object
arg1
)
{
return
null
;
}
@Override
public
Class
<?>
getType
(
ELContext
arg0
,
Object
arg1
,
Object
arg2
)
{
return
Object
.
class
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录