第 43 章 变量标签
变量存储运行时使用的数据。为了更好地控制变量行为,您可以在 BPMN 问题单文件中标记问题单变量和本地变量。标签是简单的字符串值,作为元数据添加到特定变量中。
Red Hat Process Automation Manager 支持以下标签,用于问题单和本地变量:
-
必需 : 将 变量设置为要求,以便开始一个问题单。如果问题单在没有所需变量的情况下启动,Red Hat Process Automation Manager 会生成
VariableViolationException错误。 -
ReadOnly :指示变量仅用于信息目的,且只能在执行案例期间设置一次。如果在任何时候修改了只读变量的值,Red Hat Process Automation Manager 会生成
VariableViolationException错误。 -
restricted :与
VariableGuardProcessEventListener一起使用的标签,以指示根据现有角色修改变量的权限。如果使用通过新标签名称的第二个构造器,可以将 restricted 标签替换为任何其他标签名称。
VariableGuardProcessEventListener 类从 DefaultProcessEventListener 类扩展,支持两个不同的构造器:
VariableGuardProcessEventListenerpublic VariableGuardProcessEventListener(String requiredRole, IdentityProvider identityProvider) { this("restricted", requiredRole, identityProvider); }public VariableGuardProcessEventListener(String requiredRole, IdentityProvider identityProvider) { this("restricted", requiredRole, identityProvider); }Copy to Clipboard Copied! Toggle word wrap Toggle overflow VariableGuardProcessEventListenerpublic VariableGuardProcessEventListener(String tag, String requiredRole, IdentityProvider identityProvider) { this.tag = tag; this.requiredRole = requiredRole; this.identityProvider = identityProvider; }public VariableGuardProcessEventListener(String tag, String requiredRole, IdentityProvider identityProvider) { this.tag = tag; this.requiredRole = requiredRole; this.identityProvider = identityProvider; }Copy to Clipboard Copied! Toggle word wrap Toggle overflow 因此,您必须在带有允许的角色名称和身份提供程序的会话中添加一个事件监听程序,该供应商返回用户角色,如下例所示:
ksession.addEventListener(new VariableGuardProcessEventListener("AdminRole", myIdentityProvider));ksession.addEventListener(new VariableGuardProcessEventListener("AdminRole", myIdentityProvider));Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在上例中,
VariableGuardProcessEventListener方法验证变量是否带有安全约束标签(restricted)。如果用户没有所需的角色(例如AdminRole),Red Hat Process Automation Manager 会生成VariableViolationException错误。注意:Red Hat Process Automation Manager 不支持在 Business Central UI 中出现的变量标签,如内部、输入、输出、业务相关和跟踪。
您可以将标签直接添加到 BPMN 进程源文件中,作为 customTags 元数据属性,其格式为 ![CDATA[TAG_NAME]]。
例如,以下 BPMN 进程将 所需的 标签应用到 批准 的进程变量中:
图 43.1. 在 BPMN 型号器中标记的变量示例
在 BPMN 文件中标记的变量示例
您可以将多个标签用于适用变量的变量。您还可以在 BPMN 文件中定义自定义变量标签,使变量数据可供 Red Hat Process Automation Manager 处理事件监听程序。自定义标签不会影响 Red Hat Process Automation Manager 运行时,作为标准变量标签,仅用于信息。您以相同的 customTags 元数据属性格式定义自定义变量标签,用于标准 Red Hat Process Automation Manager 变量标签。