[rules-users] Setting Non-global Input Variable in ACTION Clause

Michael Anstis michael.anstis at gmail.com
Tue Mar 13 10:09:16 EDT 2012


Generally speaking, if a Fact has not been referenced in the CONDITION it
cannot be MODIFIED in the ACTION.

You can either:-

   - Reference in the CONDITION and MODIFY in the ACTION, or
   - CREATE in the ACTION

You do not need to define any constraints on a Fact you reference in the
CONDITION. IIRC just a non-empty value in the row data will suffice.
On 13 March 2012 14:01, mihajlo <mihajlo.jovanovic at chase.com> wrote:

> Sorry, I meant input :=)
>
> I figured this was possible, as this is how a typical rule engine works.
> However I am struggling with the correct syntax for doing this with a
> decision table in Drools. I basically have a table in which I want to
> modify
> a fact in the ACTION clause that had not been referenced in any of the
> CONDITIONS, and then execute it as follows:
>
>        public void processRules(Object... facts) {
>                StatelessKnowledgeSession session = threadSession.get();
>                if (session == null) {
>                        logger.debug("creating/setting stateless session");
>                        session =
> knowledgeBase.newStatelessKnowledgeSession();
>                        threadSession.set(session);
>                } else {
>                        logger.debug("retrieving stateless session");
>                }
>
>                List factList = new ArrayList();
>                factList.addAll(Arrays.asList(facts));
>
>                session.execute(factList);
>        }
>
> Note that this worked fine by means of declaring a global variable for the
> result; however I prefer this new approach.
>
> Thanks!
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Setting-Non-global-Input-Variable-in-ACTION-Clause-tp3820353p3822263.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/20120313/36bde82f/attachment.html 


More information about the rules-users mailing list