Esteban's Blog

/dev/rnd

Guvnor: Guided Editor support for From/Collect/Accumulate elements

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 From/Collect/Accumulate elements to your rules

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

From Conditional Element

When you add a new “From” element, you will see something like this in the guided editor:

From Conditional Element

From Conditional Element

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.

From Collect Conditional Element

The “From Collect” conditional element looks like this:

From Collect Conditional Element

From Collect Conditional Element

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:

  • Fact Type Pattern
  • Free Form Expression
  • From Pattern
  • From Collect Pattern
  • From Accumulate Pattern

From Accumulate Conditional Element

When working with “From Accumulate” conditional elements, you will see this:

From Accumulate Conditional Element

From Accumulate Conditional Element

The left pattern could be any Fact Type Pattern. The right section of this conditional element is splited in two:

  • Source Pattern: (Bed $n, in the screenshot) could be any Fact Type, From, Collect or Accumulate pattern
  • Accumulate function: Here you will find a tabbed panel where you can enter an accumulate function (sum() in the screenshot) or you can create an online custom function using the “Custom Code” tab.

Conclusion

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:

http://www.plugtree.com/downloads/screencasts/02-From_demo.htm

http://www.plugtree.com/downloads/screencasts/03-Accumulate_demo.htm

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Information

This entry was posted on May 28, 2010 by in drools, java and tagged , , , , .
%d bloggers like this: