[rules-users] Does this work - create new facts in session and add to other facts?
Michael Anstis
michael.anstis at gmail.com
Sun Feb 20 08:49:07 EST 2011
Are your EJB3 beans merely JPA annotated, or state(full\less) session beans?
Drools can create new instance of JPA annotated beans, as there's simply
POJOs however if for stateful\stateless session beans your contain will
handle life-cycle.
The associations you describe are part of your domain model and therefore
Drools rules can achieve what you describe. Here's a simple example:-
rule "ensure all documents have a summary line"
when
$d : Document( )
not Line( document == $d, lineType == "summaryLine" )
then
Line newLine = new Line();
newLine.setDocument( $d );
insert(newLine);
end
Your exact implementation will depend upon your object model.
With kind regards,
Mike
2011/2/19 Thomas Adler <thomas.adler at live.com>
> Hi,
>
> I am trying to use Drools and I would like to check whether such scenario
> could work:
> I have facts Document and Line (EJB3 beans, in fact). And Document class
> has attribute:
> List<Line> lines
>
> So - I would like to pass to stateless session a Document instance
> "document" and I would like to write rule, that
> 1) create some new Lines;
> 2) calculates total from lines;
> 3) updates document.total;
> 4) add new Lines instances, that where created during the rule execution to
> document.lines;
> And at the end of execution of this session I will like to do some other
> things with document and document.lines, e.g. persist in database.
>
> So - can Drools handle such create of associations during the session
> execution?
>
> Thanks!
> Thomas
>
> _______________________________________________
> 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/20110220/779c6763/attachment.html
More information about the rules-users
mailing list