Add a custom property(添加自定义属性)¶
A common customization in Foundry Rules is adding custom properties to your rule and proposal objects. Custom properties can let you track additional metadata beyond the default configuration. To add a custom property, follow these steps:
- In the Ontology Manager, add the property (e.g.
severity) to the rule object.
:::callout{theme="neutral"} Object properties must be backed by a column in the input dataset.
In the case of an empty, auto-generated input dataset, edit the schema directly in the Details tab by copying and modifying an existing column definition.
For rules coming from an existing pipeline, add the new columns in a transform. :::
- Add corresponding
current_<PROPERTY>andnew_<PROPERTY>properties (e.g.current_severityandnew_severity) to the proposal object. - Annotate the
current_<PROPERTY>proposal object property with the type classfoundry-rules.property-diff-for:new_<PROPERTY>(e.g.foundry-rules.property-diff-for:new_severity).
:::callout{theme="neutral"}
Type classes are characterized by a kind and a name, written out as kind.name. In the case of foundry-rules.property-diff-for:new_<PROPERTY>, the kind is foundry-rules and the name is property-diff-for:new_<PROPERTY>.
:::
-
Edit every action type in the Foundry Rules setup which modifies or creates a rule or proposal object by adding a parameter of the new custom property. Follow the example of another similar property such as rule_name to see the required additions.
-
In the Workshop application, add a Workshop variable that takes the custom property of the selected rule. You can do this by defining a new objectProperty variable with the existing
selectedRulevariable as the object set input.
Set this Workshop variable as the default value for the "Create a proposal to edit rule" Action in the Rule Editor's configuration sidebar.
<img src="./media/set_default_value.png" alt="Set Workshop variable as default value" width="300" />
-
If the proposal widget is not displaying diffs correctly, follow these steps:
-
In the Workshop app, add the
new_<PROPERTY>property to Properties grouped by section in the Proposal Reviewer widget configuration. It is not necessary to select the "current" value here. - If desired, edit the property name to remove the ”new“ prefix.
-
Add the
foundry-rules.property-diff-for:ID_OF_NEW_PROPERTYtype class to the current property of the proposal object.
中文翻译¶
添加自定义属性¶
在 Foundry Rules 中,一种常见的自定义操作是为规则(rule)和提案(proposal)对象添加自定义属性。自定义属性可让您追踪默认配置之外的附加元数据。要添加自定义属性,请按以下步骤操作:
- 在 Ontology Manager 中,将属性(例如
severity)添加到规则对象。
:::callout{theme="neutral"} 对象属性必须由输入数据集中的某一列提供支持。
对于空的、自动生成的输入数据集,请直接在 详情 选项卡中通过复制并修改现有列定义来编辑架构。
对于来自现有管道的规则,请在转换(transform)中添加新列。 :::
- 在提案对象中添加对应的
current_<PROPERTY>和new_<PROPERTY>属性(例如current_severity和new_severity)。 - 使用类型类
foundry-rules.property-diff-for:new_<PROPERTY>(例如foundry-rules.property-diff-for:new_severity)对current_<PROPERTY>提案对象属性进行注解。
:::callout{theme="neutral"}
类型类由种类(kind)和名称(name)组成,格式为 kind.name。以 foundry-rules.property-diff-for:new_<PROPERTY> 为例,其种类为 foundry-rules,名称为 property-diff-for:new_<PROPERTY>。
:::
-
在 Foundry Rules 设置中,编辑所有会修改或创建规则或提案对象的操作类型(action type),为其添加新自定义属性的参数。可参考其他类似属性(如 rule_name)的示例,了解需要添加的内容。
-
在 Workshop 应用中,添加一个 Workshop 变量,用于获取所选规则的自定义属性。您可以通过定义一个新的对象属性(objectProperty)变量来实现,并将现有的
selectedRule变量作为对象集输入。
在规则编辑器(Rule Editor)的配置侧边栏中,将此 Workshop 变量设置为“创建编辑规则提案”操作的默认值。
<img src="./media/set_default_value.png" alt="将 Workshop 变量设为默认值" width="300" />
-
如果提案小部件未正确显示差异(diffs),请按以下步骤操作:
-
在 Workshop 应用中,将
new_<PROPERTY>属性添加到提案审查器(Proposal Reviewer)小部件配置中的 按部分分组的属性 中。此处无需选择“当前”值。 - 如有需要,可编辑属性名称以移除“new”前缀。
-
将
foundry-rules.property-diff-for:ID_OF_NEW_PROPERTY类型类添加到提案对象的当前属性中。