[rules-users] Executing on a arbitrarily complex object‏

Wolfgang Laun wolfgang.laun at gmail.com
Mon Feb 8 07:23:59 EST 2010


What keeps you from using 'from'?

Using one or more rules to expand your "complex object" won't work in a
stateless
session, but consider using a stateful session, if only for expansion.

Annotations for requesting automatic expansion may not be in everybody's
interest
since looking for runtime annotations is not for free, and there are other
issues,
such as (in terms of your example) should only a Father's children be
inserted and
not a Mother's and how to control this.

For further discussions of your problem a less abstract approach (What do
you
really need to do?) would be preferable.

-W

On Mon, Feb 8, 2010 at 10:56 AM, gazzaaa87 <dan_hopwood at hotmail.co.uk>wrote:

>
> Hi all,
>
> I am using a StatelessKnowledgeSession and therefore call the execute
> method
> to invoke the rules engine. Having carried out a basic test, it would
> appear
> that calling execute on an arbitrarily complex object does not insert child
> objects, rather rules will only fire if they are based on the parent.
>
> e.g. let's say you have a class called 'Father', which holds a collection
> of
> 'Child' objects. By calling session.execute(fatherObject) I need rules to
> fire that use the Child pattern without having to loop through 'insert'ing
> all the child elements manually.
>
> Has anyone come across a way around this? Having originally posted on the
> dev forum there were a few suggestions:
>
>    - You could use the "from" keyword but your rules wouldn't work on *any*
> arbitrary object - but this could be overcome if you could identify a
> suitable super-class to extend for your arbitrary objects.
>    - Have you considered  using the "from" Conditional Element, which lets
> you reason over components of a fact's collection-type element, without
> them
> being inserted as facts. See the Drools Expert manual for details.
>    - One way it has been done in the past is to have some rule with a
> higher salience take that "root" object and "explode" it into the children
> objects (as deep as needed).
>
> The only thing I managed to find was the use of a Batch Executor but you
> have to set that up before calling execute and therefore it's still
> effectively a manual process.
>
> If only Drools used java annotations, it would be ideal to specify
> behaviour
> similar to cascade with JPA.
>
> Any help or pointers much appreciated!
>
> Dan
> --
> View this message in context:
> http://n3.nabble.com/Executing-on-a-arbitrarily-complex-object-tp192130p192130.html
> Sent from the Drools - User 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/20100208/2185fbbf/attachment.html 


More information about the rules-users mailing list