Rule Structure
Author:
Fluent Commerce
Changed on:
6 Nov 2023
Overview
Rules are written using Java, and contain a specific structure and metadata for describing and validating the Rule. Rules are designed to be building blocks for workflow logic, and typically produce a single outcome or action. The Rules SDK also provides a number of built-in dependencies for implementing Rules, including working with GraphQL and other Utilities.
Rule Definition
Author:
Fluent Commerce
Changed on:
6 Nov 2023
Overview
Basic structure of a Workflow Framework Rule
Key points
- A Workflow framework rule includes a Java class, and additional event and parameters.
- The rule's annotation needs to follow best practises. More details here.
The basic structure of a Workflow Framework Rule includes:
- A Java Class implementing the interface
`com.fluentretail.rubix.v2.rule.Rule`
- A Annotation describing the metadata for the Rule
`@RuleInfo`
- Additional Event and Parameter Annotations defining the inputs of the Rule
Here's an example of a simple Rule:
1package com.example.rule;
2
3import com.fluentretail.rubix.rule.meta.RuleInfo;
4import com.fluentretail.rubix.v2.context.Context;
5import com.fluentretail.rubix.v2.rule.Rule;
6
7@RuleInfo(
8 name = "ExampleRule"
9 , description = "This is the description of the Example Rule, which should include all parameters declared below like this: {ParamString1}"
10)
11@ParamString(name = "ParamString1", description = "Parameter String 1", defaultValue = "PS1")
12@EventAttribute(name = "EventAttribute1", type = "STRING")
13public class ExampleRule implements Rule {
14
15 @Override
16 public <C extends Context> void run(C context) {
17 // ...
18 }
19}
Language: java
Name: Example Rule
Description:
[Warning: empty required content area]See the following references for more on Rule Structure: