[rules-users] How to handle generics in Drools?

Wolfgang Laun wolfgang.laun at gmail.com
Fri Nov 18 01:55:27 EST 2011


If someone else is also permitted to contribute a few pointers:

   - You just mit the generic type parameter in DRL and all the files
   compiled into it, including decision tables.
   - Storing the List tasks as a global variable could be helpful, but I
   don't see any reason for it when your rules should determine something
   about the individual list elements. Data stored in a global variable is not
   triggering any rules.
   - If your rules should discover certain Task objects, then these objects
   should be inserted as facts.

HTH
-W

On 17 November 2011 22:55, Adrigan <lillian.andres at lmco.com> wrote:

> Hello Edson,
>
>        If the generic *<T>* is not allowed, and drools appears to be
> written to
> operate over collections of objects, how do you insert a List of items like
> this:
> *List<ProjectDataSet.Task> tasks*?  In my code I insert the tasks as facts
> like this:
> *commands.add(CommandFactory.newInsertElements(tasks));*
> I use a decision table and have as one of the variables: (in the variable
> row)
> *List<ProjectDataSet.Task> tasks*.
>
>        The error I receive is this:
> /org.drools.template.parser.DecisionTableParseException: The format for
> global variables is incorrect. It should be: [Class name, Class otherName].
> But it was: [List<ProjectDataSet.Task> tasks]
>        at
>
> org.drools.decisiontable.parser.RuleSheetParserUtil.getVariableList(RuleSheetParserUtil.java:84)/
>
>        I desire the rules in the table to iterate through all the tasks in
> that
> list and identify tasks that are due soon (a part of my condition column
> *TASKACTSTART< today* … etc.  The TASKACTSTART is a field named by
> Microsoft
> in the ProjectDataSet.Task class.)
>
>        Have I misunderstood the power of drools?  How do you address a
> collection
> of a type like List<T> in a rule?
>
> Thank you in advance for your help,
>        Adrigan
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/rules-users-How-to-handle-generics-in-Drools-tp3427723p3517186.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20111118/e7e5af4f/attachment.html 


More information about the rules-users mailing list