[rules-users] choose method from fact object in guided editor

Hans Wirz hans.wirz at xmv.ch
Mon Jun 10 11:42:17 EDT 2013


Great!

As my fact object (Dokument) encapsulates a whole text analytics process and
should be able to return any key-value pairs (where "reviewed" is a key)
there are many other (not predictable) keys which are probably used within a
rule to evaluate the content of a document.

So in that sense, the solution you suggest would not work.

 

In another way, if a set of common and known keys exists to all users, your
approach would be even more robust an less fragile to spelling an mistyping
issues ;-)

 

Thank you very much.

Hans

 

Von: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] Im Auftrag von Stephen Masters
Gesendet: Montag, 10. Juni 2013 17:24
An: Rules Users List
Betreff: Re: [rules-users] choose method from fact object in guided editor

 

I think I have a better idea of what you're trying to do now. Below is the
content of a message I sent to this list the other day. I think you might
find the technique relevant to what you are doing. i.e. Create a DSL which
refers to an enumeration which you define. That way, you get drop-down menus
in the DSL sentences. That makes life easy for your users. From there you
are able to take the value from the enum and use it in the generated code.
Note that in the code below, it is taking the value of "unit" from the
enumeration and using that as the field being matched in the code.

 

The rest is from my previous email...

 

 

I just couldn't find any examples of the DRL syntax for 'creating' a value
like that in the LHS. A quick test with a contrived little example shows me
that the following works:

 

rule "Warn when my meal is too large"

when

    $meal: Meal($calories: calories > 1000)

    $unit: String() from "calories"

then

    insert(new MealTooBigWarning("That meal is bigger than your 1000 " +
$unit + " limit."));

end

 

So, based on that I'm able to write a DSL like this:

 

[when][]I am given a meal of more than "{sizeLimit}" "{unit}" = $meal:
Meal($size: {unit} > {sizeLimit}); $sizeLimit: Integer() from {sizeLimit};
$unit: String() from "{unit}"

[then][]Warn that the meal is too big = insertLogical(new
MealTooBigWarning("That meal is bigger than your " + $sizeLimit + " " +
$unit + " meal limit."));

 

Which means that I can write DSLR like this:

 

rule "Warn when my meal has too many calories"

when

    I am given a meal of more than "1000" "calories"

then

    Warn that the meal is too big

end

 

. which gives me:

 

That meal is bigger than your 1000 calories meal limit.

 

Or this:

 

rule "Warn when my meal has too many diet club points"

when

    I am given a meal of more than "11" "dietClubPoints"

then

    Warn that the meal is too big

end

 

. which gives me:

 

That meal is bigger than your 11 dietClubPoints meal limit.

 

So I can define an enumeration:

 

'MealSize.units': ['calories=calories', 'dietClubPoints=diet club points']

 

So that in Guvnor, I have a single sentence with a drop-down menu containing
the options "calories" and "diet club points". That keeps things nice and
clean for the users.

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130610/90403171/attachment-0001.html 


More information about the rules-users mailing list