跳转至

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:

  1. 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. :::

  1. Add corresponding current_<PROPERTY> and new_<PROPERTY> properties (e.g. current_severity and new_severity) to the proposal object.
  2. Annotate the current_<PROPERTY> proposal object property with the type class foundry-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>. :::

  1. 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.

  2. 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 selectedRule variable as the object set input.

    Define a variable

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" />
  1. If the proposal widget is not displaying diffs correctly, follow these steps:

  2. 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.

  3. If desired, edit the property name to remove the ”new“ prefix.
  4. Add the foundry-rules.property-diff-for:ID_OF_NEW_PROPERTY type class to the current property of the proposal object.

    Alert Recipient property added to the proposal reviewer configuration sidebar with the 'New' prefix highlighted to indicate it can be removed


中文翻译


添加自定义属性

在 Foundry Rules 中,一种常见的自定义操作是为规则(rule)和提案(proposal)对象添加自定义属性。自定义属性可让您追踪默认配置之外的附加元数据。要添加自定义属性,请按以下步骤操作:

  1. 在 Ontology Manager 中,将属性(例如 severity)添加到规则对象。

:::callout{theme="neutral"} 对象属性必须由输入数据集中的某一列提供支持。

对于空的、自动生成的输入数据集,请直接在 详情 选项卡中通过复制并修改现有列定义来编辑架构。

对于来自现有管道的规则,请在转换(transform)中添加新列。 :::

  1. 在提案对象中添加对应的 current_<PROPERTY>new_<PROPERTY> 属性(例如 current_severitynew_severity)。
  2. 使用类型类 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>。 :::

  1. 在 Foundry Rules 设置中,编辑所有会修改或创建规则或提案对象的操作类型(action type),为其添加新自定义属性的参数。可参考其他类似属性(如 rule_name)的示例,了解需要添加的内容。

  2. 在 Workshop 应用中,添加一个 Workshop 变量,用于获取所选规则的自定义属性。您可以通过定义一个新的对象属性(objectProperty)变量来实现,并将现有的 selectedRule 变量作为对象集输入。

    定义变量

在规则编辑器(Rule Editor)的配置侧边栏中,将此 Workshop 变量设置为“创建编辑规则提案”操作的默认值。

<img src="./media/set_default_value.png" alt="将 Workshop 变量设为默认值" width="300" />
  1. 如果提案小部件未正确显示差异(diffs),请按以下步骤操作:

  2. 在 Workshop 应用中,将 new_<PROPERTY> 属性添加到提案审查器(Proposal Reviewer)小部件配置中的 按部分分组的属性 中。此处无需选择“当前”值。

  3. 如有需要,可编辑属性名称以移除“new”前缀。
  4. foundry-rules.property-diff-for:ID_OF_NEW_PROPERTY 类型类添加到提案对象当前属性中。

    警报接收者属性已添加到提案审查器配置侧边栏,其中'New'前缀已高亮显示,表示可将其移除