One of the many improvements introduced in guvnor 5.1M2 guided editor is the ability to add from, collect and accumulate conditional elements to your rules.
The lack of this possibility was a big drawback in previous versions of Guvnor. But today, 5.1M2 contains a first version of this support!
Adding these kind of conditional elements to your rules is just as easy as add any other type of conditional element. Using the “plus” button at the top of rule’s WHEN section or using the new “Add after” button present in every Pattern will open the popup to add new conditional elements to your rule. In the list of possible elements you will find three new entries: “From”, “From Accumulate” and “From Collect”.
When you add a new “From” element, you will see something like this in the guided editor:
The left pattern of the “From” conditional element is a regular Pattern. You can add there any type of conditional element you want.
The right section of the “From” pattern is an expression builder. The expression builder is a new widget introduced also in 5.1M2.
The “From Collect” conditional element looks like this:
In the left pattern you can choose from “java.util.Collection”, “java.util.List” or “java.util.Set” Fact Types. This Fact Types will be automatically included in the package’s Fact Types list.
The right pattern of the collect conditional element could be one of this patterns:
When working with “From Accumulate” conditional elements, you will see this:
The left pattern could be any Fact Type Pattern. The right section of this conditional element is splited in two:
Guvnor’s guided editor brings support for From, Collect and Accumulate conditional elements. Because this feature is new, we need a lot of feedback from users in order to improve it and create a really useful support.
For complete demos using these conditional elements, you can take a look at this screencasts: