Rules(规则)¶
Rules define the logic of the action type that transform the parameters into Ontology edits or other effects. There are two main types of rules: ones that edit the Ontology, and ones that trigger another effect in Foundry.
Ontology rules¶
An Ontology rule changes specific elements of the Ontology. They can create, modify, or delete objects and links of existing types. To create or delete one-to-many or one-to-one links, object rules need to be used and the foreign key property on the object needs to be modified.
- Create object: Can be used to create an object of a predefined type. The primary key of the object type is a required property which has to be filled. Additional properties can be added optionally.
- Modify object(s): Can be used to modify an existing object whose primary key is derived from object reference parameters. This cannot reference an object created as a part of the current action.
- Create or modify object(s): Can be used to modify an existing object based on an object reference parameter. If an object is not selected, a new object will be created with either an automatically generated unique ID, or with a user submitted primary key.
- Delete object(s): Can be used to delete an existing object whose primary key is derived from object reference parameters. This cannot reference an object created as a part of the current action.
- Create link(s): Can be used to create a many-to-many link between objects that are passed via object reference parameters. For foreign key links, one has to use Modify object rule to explicitly modify the foreign key property.
- Delete link: Can be used to delete a many-to-many link between objects that are passed via object reference parameters. For foreign key links, one has to use Modify object rule to explicitly modify the foreign key property.
- Function rule: Can be used to reference an Ontology edit function whose inputs are derived from parameters of the action. When this rule is present, no other rule may be configured since function code alone is capable of handling everything that other rules can do. Read more about function action types.
- Create object(s) of interface: Can be used to create objects of any type that implements a particular interface. Read more about actions on interfaces.
- Modify object(s) of interface: Can be used to modify objects of types that implement a particular interface. Read more about actions on interfaces.
- Delete object(s) of interface: Can be used to delete objects of types that implement a particular interface. Read more about actions on interfaces.
- Create link(s) on object(s) of interface: Can be used to create links between objects of types that implement a particular interface. Read more about actions on interfaces.
- Delete link(s) on object(s) of interface: Can be used to delete links between objects of types that implement a particular interface. Read more about actions on interfaces.
Values and parameters¶
When creating or modifying links and objects, the Rules require additional values for their operation. When modifying an object, the rules also define which properties are modified. Each property in return is mapped to a value provided by one of multiple options (Rules on links can only take object reference parameters):
- From parameter: An existing parameter of the same type as the property. By default, every new property being added to the rule will automatically create a parameter with the same name and will be mapped to take the value of this parameter.
- Object parameter property: A property of an existing object reference parameter. The property type of the object parameter needs to match the property type it is mapped to.
- Static value: A static value that only exists in the Rules part of the action type. This value is cannot be changed when interacting with the action in Workshop, Slate, or Object Views.
- Current User/Time: String and timestamp properties can also take on contextual values in the form of the actions current user or the time of submission. Just like the Static value, these values cannot be interacted with when submitting the action and cannot be used in other parts of the action type.
Creating an object & many-to-many link¶
You can also create objects and linked many-to-many at the same time. While just creating a many-to-many link requires objects on both sides of the link to exist prior, you can create both entities via one action type. Start by configuring a Create object rule with an object type that has a many-to-many link. Then click the Add link button below Add property to select the link type and configure the links.
In order to create a one-to-many or one-to-one link type, simply edit the foreign key on the object.
Invalid combinations¶
Action types can include combinations of Ontology rules. When multiple rules are defined, the actions backend compiles rules to generate a single edit per object (e.g., Add object, Modify object(s), or Delete object(s)). For example, if the result of one rule updates a property to "A", but another rule in the same action type updates the same object's property to "B", the resulting edit would just update the property to "B". The order of rules affects the final object edit. As a result, the following combinations of object edits are not supported:
- Objects cannot be deleted before they are added or modified.
- Objects cannot be modified before they are added.
- Objects cannot be created twice in one form submission.
Other rules¶
There are two types of rules that trigger a side effect:
- Notification rules can be used to send a notification about the action. Parameters may be used to customize the content of the notification and the recipients. End users may adjust their preferences to receive notifications via in-platform push notification, email, or both. Notifications are sent once all action edits have been applied, however the content of the notification will be generated based on the state of the Ontology before edits are applied.
- Webhooks enable an action to make a request to an external system when the action is applied. Action parameters can be passed into the webhook, which can in turn pass parameters through to the external request. Webhooks may be configured to run before or after edits are applied.
There is an additional advanced rule that triggers a build:
- Schedule rules can be used to trigger the build of a schedule. Action parameters can be passed into the schedule, which can in turn pass parameters to the underlying parameterized transforms inside the build. Foundry applies Ontology edits after the build begins.
中文翻译¶
规则¶
规则(Rules) 定义了动作类型的逻辑,将参数转换为本体(Ontology)编辑或其他效果。规则主要分为两类:一类用于编辑本体,另一类用于在 Foundry 中触发其他效果。
本体规则¶
本体规则用于修改本体的特定元素。它们可以创建、修改或删除现有类型的对象和链接。要创建或删除一对多或一对一链接,需要使用对象规则并修改对象上的外键属性。
- 创建对象(Create object): 可用于创建预定义类型的对象。对象类型的主键是必填属性,必须填写。其他属性可选添加。
- 修改对象(Modify object(s)): 可用于修改现有对象,其主键源自对象引用参数。此规则不能引用当前动作中创建的对象。
- 创建或修改对象(Create or modify object(s)): 可用于基于对象引用参数修改现有对象。如果未选择对象,则会创建一个新对象,其主键可以是自动生成的唯一 ID,也可以是用户提交的主键。
- 删除对象(Delete object(s)): 可用于删除现有对象,其主键源自对象引用参数。此规则不能引用当前动作中创建的对象。
- 创建链接(Create link(s)): 可用于在通过对象引用参数传递的对象之间创建多对多链接。对于外键链接,必须使用修改对象规则显式修改外键属性。
- 删除链接(Delete link): 可用于删除通过对象引用参数传递的对象之间的多对多链接。对于外键链接,必须使用修改对象规则显式修改外键属性。
- 函数规则(Function rule): 可用于引用本体编辑函数,其输入源自动作参数。当使用此规则时,不能配置其他规则,因为函数代码本身能够处理其他规则所能完成的所有操作。了解更多关于函数动作类型的信息。
- 创建接口对象(Create object(s) of interface): 可用于创建实现特定接口的任何类型的对象。了解更多关于接口上的动作的信息。
- 修改接口对象(Modify object(s) of interface): 可用于修改实现特定接口的类型的对象。了解更多关于接口上的动作的信息。
- 删除接口对象(Delete object(s) of interface): 可用于删除实现特定接口的类型的对象。了解更多关于接口上的动作的信息。
- 创建接口对象链接(Create link(s) on object(s) of interface): 可用于在实现特定接口的类型的对象之间创建链接。了解更多关于接口上的动作的信息。
- 删除接口对象链接(Delete link(s) on object(s) of interface): 可用于删除实现特定接口的类型的对象之间的链接。了解更多关于接口上的动作的信息。
值和参数¶
在创建或修改链接和对象时,规则需要额外的值来执行操作。修改对象时,规则还定义了哪些属性被修改。每个属性依次映射到由多个选项之一提供的值(链接规则只能接受对象引用参数):
- 来自参数(From parameter): 与属性类型相同的现有参数。默认情况下,添加到规则的每个新属性都会自动创建一个同名的参数,并映射为该参数的值。
- 对象参数属性(Object parameter property): 现有对象引用参数的属性。对象参数的属性类型需要与其映射的属性类型匹配。
- 静态值(Static value): 仅存在于动作类型规则部分的静态值。在 Workshop、Slate 或对象视图中与动作交互时,此值无法更改。
- 当前用户/时间(Current User/Time): 字符串和时间戳属性也可以采用上下文值,形式为动作的当前用户或提交时间。与静态值一样,这些值在提交动作时无法交互,也不能在动作类型的其他部分中使用。
创建对象和多对多链接¶
您还可以同时创建对象和多对多链接。虽然仅创建多对多链接需要链接两侧的对象事先存在,但您可以通过一个动作类型同时创建这两个实体。首先,配置一个创建对象规则,使用具有多对多链接的对象类型。然后,点击添加属性下方的添加链接按钮,选择链接类型并配置链接。
要创建一对多或一对一链接类型,只需编辑对象上的外键即可。
无效组合¶
动作类型可以包含本体规则的组合。当定义了多个规则时,动作后端会编译规则,为每个对象生成单个编辑(例如,添加对象、修改对象或删除对象)。例如,如果一个规则的结果将属性更新为"A",但同一动作类型中的另一个规则将同一对象的属性更新为"B",则最终的编辑只会将属性更新为"B"。规则的顺序会影响最终的对象编辑。因此,不支持以下对象编辑组合:
- 对象不能在添加或修改之前被删除。
- 对象不能在添加之前被修改。
- 在一个表单提交中,对象不能创建两次。
其他规则¶
有两种规则会触发副作用(side effect):
- 通知(Notification) 规则可用于发送关于动作的通知。可以使用参数自定义通知内容和收件人。最终用户可以调整偏好设置,通过平台内推送通知、电子邮件或两者同时接收通知。通知在所有动作编辑应用后发送,但通知内容将基于编辑应用前的本体状态生成。
- Webhooks 使动作在应用时能够向外部系统发出请求。动作参数可以传递到 webhook,而 webhook 又可以将参数传递到外部请求。Webhooks 可以配置为在编辑应用之前或之后运行。
还有一种高级规则会触发构建(build):
- 调度(Schedule) 规则可用于触发调度的构建。动作参数可以传递到调度,而调度又可以将参数传递到构建底层的参数化转换(parameterized transforms)。Foundry 在构建开始后应用本体编辑。