Charles Binford <Charles.Binford <at> Sun.COM> writes: > > I'm using the DSL feature of 4.07 and am having trouble getting it to > behave like I want. > > I have a File object where I'm always going to have a "state" > constraint, plus one or more optional constraints based on user input. > (I'm parsing user data to generate the .dsrl file on the fly). > > Samples: > file in "1.x" state where uid == 0 where gid == 0 > Should turn into > $f: File ( classState == "1.x", uid == 0, gid == 0 ) > > The key lines from my DSL file that do this are: > [condition][]file in "{state}" state {constraints}=$f: File ( classState > == "{state}" {constraints} ) > [condition][]where {constraint}=, {constraint} > > Unfortunately what I get is > $f: File ( classState == "1.x", uid == 0 where gid == 0 ) > > If only have one "where" then all works fine. If I add another > "[condition][]where {constraint}=, {constraint}" > line in my DSL file it works. The first DSL "where" line catches the > first "where uuid" and the second DSL line catches the "where gid". On > the current path it looks like I'll have to set a hard limit on how many > constraints a user can specify and make sure I've dup'd the "where" line > that many times in the DSL file. Of course I'd much rather leave it > open and have the single "where" line apply itself as many times as it can. > > Thanks in advance for any help. > > Charles Binford > Sun Microsystems > _______________________________________________ > rules-users mailing list > rules-users <at> lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > >
Have you looked at using the - operation? It doesn't meet your one line goal, but it works. The rule would look like this: file in "1.x" state where - uid is 0 - gid is 0 - lastModified > the dsl would follow this cheese example from the drools docs (I grabbed it from 4.03) [when]There is a Cheese with=Cheese() [when]- age is less than {age}=age<{age} [when]- type is '{type}'=type=='{type}' [when]- country equal to '{country}'=country=='{country}' Search the doc for the section "Adding constraints to facts" for more details. HTH, Jared Davis _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users