On 13/06/2012, Sandjaja, Dominik <dominik.sandjaja(a)it-motive.de> wrote:
Hello Wolfgang, hello everybody,
Nice one, thanks for the idea! This one works for now, but is there a way to
automatically assign random variable names to the RHS of the DSL? So the
user won't have to explicitly set a variable in the DSL which is only needed
for internal purposes.
This is one thing I've occasionally missed, too, in my experiments
with DSLs. It wouldn't be too difficult to add, and patch/pull
requests are always welcome with the Drools team.
If at least one of the variables differs between repeated uses of the
DSL phrase, you might consider using this text (if its characters are
always suitable!) as part of the binding variable name, e.g.
[when][]The field {field} in the module {module} contains value {value}=
{value}Obj : {module} ( {field} != null) String(
this.equalsIgnoreCase( "{value}" ) ) from {value}Obj.{field}
BTW, consider defining a custom operator which would let you write the
much simpler pattern
Module( field spells "value" )
You can make a trivial clone from the implementation of "contains",
shouldn't take more than 5 minutes ;-) Some hints can be found at
http://members.inode.at/w.laun/drools/CustomOperatorHowTo.html
Cheers
-W
Thanks
Dominik
-----Ursprüngliche Nachricht-----
Von: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] Im Auftrag von Wolfgang Laun
Gesendet: Dienstag, 12. Juni 2012 19:46
An: Rules Users List
Cc: Edson Tirelli
Betreff: Re: [rules-users] Using 'from {x}.field' in DSL
There is a bug in the DSL parser: after '=', a couple of variable references
merely separated by a period isn't recognized.
As a workaround, use this:
[when][]The field {field} in the module {module} contains value {value} as
{abc} =
{abc}x : {module} ( {field} != null) String(
this.equalsIgnoreCase("{value}") ) from {abc}x.{field}
-W
On 12/06/2012, Sandjaja, Dominik <dominik.sandjaja(a)it-motive.de> wrote:
> There is no expanded DRL. If I take that line into the DSL, I can't
> even validate the DSL and if I have the line in it, I can't select any
> DSL statements for rules in Guvnor.
>
>
>
> BTW, I am using Drools and Guvnor 5.4.0.
>
>
>
> Von: rules-users-bounces(a)lists.jboss.org
> [mailto:rules-users-bounces@lists.jboss.org] Im Auftrag von Wolfgang
> Laun
> Gesendet: Dienstag, 12. Juni 2012 17:31
> An: Rules Users List
> Betreff: Re: [rules-users] Using 'from {x}.field' in DSL
>
>
>
> Have you checked the expanded DRL? What does this line look like?
>
> -W
>
> On 12 June 2012 17:06, Sandjaja, Dominik
> <dominik.sandjaja(a)it-motive.de>
> wrote:
>
> I have the following Drools DSL "sentence":
>
> [when]The field {field} in the module {module} contains value
> {value}=$a : {module} ( {field} != null)
>
> String( this.equalsIgnoreCase("{value}") ) from $a.{field}
>
> where the `field` is a `Set` of Strings.
>
> Now, if I have two of these sentences in one rule, it obviously won't
> work as the variable `$a` occurs twice. So I wanted to improve the
> rule to make the variable, well, variable:
>
> [when]The field {field} in the module {module} contains value
> {value} as {a}={a} : {module} ( {field} != null)
>
> String( this.equalsIgnoreCase("{value}") ) from {a}.{field}
>
> This doesn't work, I can't use the part `{a}.`, that breaks.
>
> So, my questions are: Is there either a way to rewrite the rules or a
> way to allow the `{variable}.` notation to work? Alternatively, is
> there a `contains` operator which works case insensitive?
>
> Thanks in advance
>
> Dominik
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users