processi

about processes and engines

Decision Tables

When I first devised this concept, I immediately thought “decision table”. It’s more a “rule set” thing though, or it’s “business rules” (but not RETE-style, just plain simple rules). “Decision Tables” is a good name then : it avoids confusion with “rule engines”.

The idea was first given me by Alexandre de Oliveira e Sousa’s work on OpenWFE and rule engines. The introduction to this master thesis comprised a full overview of the rules domain and such spreadsheet rules where the entry-level thing, simple and powerful, with wide applicability.

Let’s imagine you have some business logic that you need to insert within your OpenWFE process definition. Here’s a snippet :

        <case>
            <equals field="customer_category" value="silver" />
            <set field-value="price" value="100" />

            <equals field="customer_category" value="gold" />
            <set field-value="price" value="80" />

            <equals field="customer_category" value="platinum" />
            <sequence>
                <set field-value="price" value="60" />
                <set field-value="points" value="7" />
            </sequence>
        </case>
        <participant ref="invoicing" />

That adds up lots of, well, ‘code’. You might say that OpenWFE has agents and that it could be turned into :

        <participant ref="price-calculation-agent" />
        <participant ref="invoicing" />

OK, but you still have to implement the agent.

OpenWFE 1.7.1pre3 introduces a new participant, the ‘DecisionParticipant’. What about having a simple spreadsheet like this one ?

business rule

That you’d export into a CSV (comma separated values) file like that one :

"in:customer_category","out:price","out:points"
"silver",100,
"gold",80,
"platinum",60,7

to achieve the same result ?

(Don’t be afraid, Excel and OpenOffice will manage the export automatically for you).

Input fields have their names prefixed with “in:”, if matching values are found, the values of the “out:” cells of the row are set in the workitem.
As soon as one row matches, the execution stops (but you can tell the table to try to apply every rule (row)).

As of this 1.7.1pre3 [pre-]release, you have to add a participant definition to the file etc/engine/participant-map.xml and the table to a DecisionService within etc/engine/engine-configuration.xml (yes, it all happens in the engine, but a DecisionService could be configured within a Java APRE as well).

in etc/engine/participant-map.xml :

    <participant 
        name="decision-test-0"
        class="openwfe.org.decision.impl.DecisionParticipant"
    >
        <param>
            <param-name>tableName</param-name>
            <param-value>rules0</param-value>
        </param>
    </participant>

in etc/engine/engine-configuration.xml :

    <service
        name="decisionService"
        class="openwfe.org.decision.impl.SimpleDecisionService"
    >
        <param>
            <param-name>table:rules0</param-name>
            <param-value>etc/engine/rules.csv</param-value>
        </param>
    </service>

If a CSV file changed, the DecisionService will take care of reloading the newest version.

Further pre-releases will include a configuration scheme making it much easier to configure such tables / participants.

I’ll post further blog entries about these “Decision Tables”, there is more to know about them : they can be used as a powerful data transformation tool (hint : yes, they completely support OpenWFE’s dollar notation).

OpenWFE 1.7.1pre3 is available from the Download page.

Written by John Mettraux

May 30, 2006 at 11:48 am

Posted in bpm, bpms, openwfe, rules, workflow

%d bloggers like this: