[rules-users] Accessing globals after FireAllRules

Wolfgang Laun wolfgang.laun at gmail.com
Thu May 26 11:57:11 EDT 2011


I assume your DRL contains
   global String ndc11

Assigning to this variable must be done using kSession.setGlobal(...).

In the DRL, you can access it by using variable name ndc11.

In Java code, you must used kSession.getGlobal(...).

That you can do in a consequence
   ndc11 = ...;
is regrettable; it is to be hoped that this can be plugged at some future
time.

-W


On 26 May 2011 17:33, sdinoo <sdinoo at gmail.com> wrote:

> I have a rule flow that has two tasks that insert global value called ndc11
>
>
> In the ProcessTest.java (using the sample program) I am trying this code
>                        ksession.startProcess("com.drughistory");
>                        ksession.fireAllRules();
>                        NdcMaster myNdc =
> (NdcMaster)ksession.getGlobal("ndc11");
>                        System.out.println(">>>>>>" + myNdc.getNdc11());
> //THIS IS LINE 53
>
> CONSOLE OUTPUT
> Inserted drug with ABCDEFGH
> Found Global ABCDEFGH
> java.lang.NullPointerException
>        at rules.tester.ProcessTest.main(ProcessTest.java:53)
>
> All I want to do is access the inserted object and use the same - Can
> someone please help?
>
>
> DROOLS FILE
> rule "getDrugMaster" ruleflow-group "DUR" dialect "java" salience 100
>        when
>        dc: DurClaim(  )
>        then
>        ndc11 =
> ClaimsHistoryHelper.getClaimDrugRecord(dc.getProductSvcID());
>        insert(ndc11);
>        System.out.println("Inserted drug with " + ndc11.getNdc11());
>
> end
>
> rule "Get History Claims" ruleflow-group "getClaimHistory" dialect "java"
> salience 99
>        when
>        n: NdcMaster( ndc11 == "ABCDEFGH" )
>        then
>        insert(ndc11);
>        System.out.println("Found Global " + n.getNdc11());
> end
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Accessing-globals-after-FireAllRules-tp2989144p2989144.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/20110526/f044367e/attachment.html 


More information about the rules-users mailing list