Exposing a process variable of type BigDecimal for use inside a DRL rule.

72 views
Skip to first unread message

tony.h...@gmail.com

unread,
Dec 14, 2017, 4:14:56 AM12/14/17
to jBPM Usage
Hi Team,

I have a process variable procvar that is of type java.math.BigDecimal.
I have an object O that is of a type OT.

I mapped both to input variables (not sure this is even required).

I have WorkflowProcessInstance pulled in and set an "out" variable using this...
              ...
   $p.setVariable("xxx", true);
   retract($process);
end

I have managed to get the O accessible inside the DRL and used in rules.
OT(somefieldinOT == 'sometext')


I have struggled to get procvar visible inside the DRL file.
java.math.BigDecimal (... procvar...

can someone point me at some doco or explain how procvar (or any of the other "basic" process variable types (e.g. Boolean, etc.) is made accessible inside a rule.

Thx

Tony.

tony.h...@gmail.com

unread,
Dec 14, 2017, 12:39:39 PM12/14/17
to jBPM Usage
This is the rule below.

The error is that 
highest_balance_seen_in in $highest: BigDecimal(highest_balance_seen_in)
is unknown.

How do I get a var of a basic basic type seen in a rule?

I have been googling, reading and ferkeling for a long time on this.

Thx


import java.math.BigDecimal;

import xxx.data.OT;
import org.kie.api.runtime.process.WorkflowProcessInstance;


rule
"is new High Value" ruleflow-group "determine_new_high_rules"
no-loop
when
   
// we are passing in a process (BigDecimal) var called highest_balance_seen_in (process var is called highest_balance_seen) via the input mappings
   
// OT is an object Type (has fields for aggregatedBalance etc.)
   $highest
: BigDecimal(highest_balance_seen_in)
   OT
(eval(aggregatedBalance.compareTo(highest) == 1)) // new balance > old balance (highest_balance_seen_in)
   $process
: WorkflowProcessInstance( )
then
   
WorkflowProcessInstance $p = (WorkflowProcessInstance)kcontext.getKieRuntime().getProcessInstance($process.getId()); //casting to WorkflowProcessInstance is essential
   $p
.setVariable( "is_new_highest_value", true );
   retract
($process);
end


tony.h...@gmail.com

unread,
Dec 14, 2017, 12:46:12 PM12/14/17
to jBPM Usage
   $highest_balance_seen : BigDecimal((WorkflowProcessInstance)kcontext.getKieRuntime().getProcessInstance($process.getId()).getVaribale("highest_balance_seen_in"))
Does not compile either...
Reply all
Reply to author
Forward
0 new messages