Bug 724216 (BRMS-159) - No access to context in a constraint
Summary: No access to context in a constraint
Keywords:
Status: CLOSED NEXTRELEASE
Alias: BRMS-159
Product: JBoss Enterprise BRMS Platform 5
Classification: JBoss
Component: unspecified
Version: unspecified
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ---
: 5.0.1
Assignee: Kris Verlaenen
QA Contact:
URL: http://jira.jboss.org/jira/browse/BRM...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-07-07 13:24 UTC by nwallace
Modified: 2009-10-05 06:52 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-09-01 12:20:15 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker BRMS-159 0 None None None Never

Description nwallace 2009-07-07 13:24:40 UTC
Date of First Response: 2009-09-10 00:50:45
securitylevel_name: Public

Say I have a class Job with a method isFinished() that returns boolean. Also in a process context, I have a variable "job" of the type "Job". In a constraint on a split node, the following happens:

a) When the constraint is in mvel dialect, the code "((Job)job).finished" is correct.
b) When the constraint is in Java dialect, the code "Job j = (Job)(context.getVariable("job"));" gets me the following compilation error:

Process Compilation error : org.drools.lang.descr.ProcessDescr@48f675
	[omitted] (27:1248) : context cannot be resolved

The documentation of this is quite clear: "Code constraints are expressions that return a boolean value. They have access to the context variable. MVEL code constraints also have direct access to the variables."

Therefore I think this is a bug.

Comment 1 nwallace 2009-07-07 13:25:41 UTC
Link: Added: This issue is related to JBRULES-1978


Comment 2 nwallace 2009-09-01 12:20:15 UTC
Fix in place.

Comment 3 David Le Sage 2009-09-10 04:50:45 UTC
For documenting this in the Release Notes, can you please confirm the following and fill in the missing information. Dot point explanations are fine:

The CAUSE (what was actually broken)
 * 

CONSEQUENCES of the bug (how it impacts users.)
 *  A Boolean value was not returned correctly when a constraint on a split node was written in Java.
 *  Instead, a compilation error occurred.

The FIX (what was changed to eliminate this bug) and 
 *

RESULTS of the fix (what now happens for users.)
 * 

Comment 4 David Le Sage 2009-09-23 05:32:55 UTC
We are still awaiting the outstanding information for the Release Notes on this one.  Please provide it as soon as possible. Thanks.

Comment 5 Kris Verlaenen 2009-09-23 12:58:31 UTC
The CAUSE (what was actually broken)
 * variable resolution wasn't working as expected in code constraints

CONSEQUENCES of the bug (how it impacts users.)
 * a compilation error occurred when using context or variables in code constraints

The FIX (what was changed to eliminate this bug) and
 * automatically inject context, kcontext and process variables as known java parameters

RESULTS of the fix (what now happens for users.)
 * code constraints now have direct access to process variables and kcontext

Comment 6 Dana Mison 2009-10-05 06:52:36 UTC
added to the 5.0.CP01 release notes as resolved:

JBRULES-1978
A compilation error would occur when attempting to access context or process variables in code constraints. This was caused by variable resolution not working as expected. This issue has been fixed by automatically injecting context, kcontext, and process variables as known Java parameters so that code constraints now have direct access to process variables and kcontext.



Note You need to log in before you can comment on or make changes to this bug.