Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1246099

Summary: Guided Rule editor does not seem to reload "eval()" functions correctly while used inside the constraint of a fact
Product: [Retired] JBoss BRMS Platform 6 Reporter: Musharraf Hussain <mhussain>
Component: Business CentralAssignee: manstis
Status: CLOSED EOL QA Contact: Jiri Locker <jlocker>
Severity: high Docs Contact:
Priority: high    
Version: 6.1.0CC: lpetrovi
Target Milestone: ER4   
Target Release: 6.2.0   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1247559 (view as bug list) Environment:
BRMS 6.1.0 patch update 1
Last Closed: 2020-03-27 19:06:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1247559    
Attachments:
Description Flags
rulesource_beforeissue.png
none
ruleeditor_beforeissue.png
none
aftersave_closeandreopen_editor.png
none
validation_error.png
none
bare_repo.zip
none
EvalTestwithFunctions-1.0.jar none

Description Musharraf Hussain 2015-07-23 12:58:38 UTC
Description of problem:
- The issue out here is that there is a necessity to achieve the following LHS condition in a Guided Rule.
~~~
rule "TestEval"
dialect "mvel"
  when
        $employee : Employee( name == "Test" , id < 100 , ( functionTrue() && functionFalse() ))
        
  then
        System.out.println("Rules fired with success");
  end
~~~

This kind of condition directly works in DRL, but if a user tries to create similar constraint for a fact (say "Employee") in Guided Rule editor (by using "Modify constraints for Employee" -> "New Formula" and paste the condition like "( functionTrue() && functionFalse() )") then at first the designer does not throw any validation error. It even allows users to save the Guided Rule. In the "Source" tab the rule looks like the following (wrapped around an "eval()"). The attached screenshot "ruleeditor_beforeissue.png" shows the rule after it is saved and "rulesource_beforeissue.png" confirms it's source.
~~~
1.	|	package com.sample.test.evaltestwithfunctions;
2.	|	
3.	|	import java.lang.Number;
4.	|	
5.	|	rule "dualfunctiontrouble"
6.	|	    dialect "mvel"
7.	|	    when
8.	|	        $emp : Employee( name == "Test1" , eval( ( functionTrue() && functionFalse() ) ))
9.	|	    then
10.	|	        System.out.println("Functions called with success");
11.	|	end
~~~

Now, if user closes the window of the editor and tries to reopen the rule it breaks and splits the functions into two lines. Then it also throws validation errors. Please see the issue in "aftersave_closeandreopen_editor.png" and the validation error is shown in "validation_error.png" screenshot.

Interestingly the project in Business Central can be built without any trouble even after the issue in editor exist. The attached kjar "EvalTestwithFunctions-1.0.jar" shows the artifacts after building the project. And even after building the project, the contents inside the troubled "dualfunctiontrouble.rdrl" file shows the correct rule definition.
~~~
package com.sample.test.evaltestwithfunctions;

import java.lang.Number;

rule "dualfunctiontrouble"
	dialect "mvel"
	when
		$emp : Employee( name == "Test1" , eval( (functionFalse() && functionTrue()) ))
	then
		System.out.println("Functions called with success");
end
~~~

Hence, the issue seems to be only with the editor. The attached bare git repository "bare_repo.zip" of my project is shared for reference.


Version-Release number of selected component (if applicable):
- BRMS 6.1.0 patch update 1

How reproducible:
- Always

Steps to Reproduce:
1. Follow the steps shared above
2.
3.

Actual results:
- Guided Rule editor shows the rule as broken.

Expected results:
- The rule should be represented correctly in Guided Rule editor.

Additional info:
- Nothing

Comment 1 Musharraf Hussain 2015-07-23 12:59:33 UTC
Created attachment 1055317 [details]
rulesource_beforeissue.png

Comment 2 Musharraf Hussain 2015-07-23 13:00:04 UTC
Created attachment 1055318 [details]
ruleeditor_beforeissue.png

Comment 4 Musharraf Hussain 2015-07-23 13:00:30 UTC
Created attachment 1055319 [details]
aftersave_closeandreopen_editor.png

Comment 5 Musharraf Hussain 2015-07-23 13:00:56 UTC
Created attachment 1055320 [details]
validation_error.png

Comment 6 Musharraf Hussain 2015-07-23 13:01:54 UTC
Created attachment 1055321 [details]
bare_repo.zip

Comment 7 Musharraf Hussain 2015-07-23 13:02:54 UTC
Created attachment 1055324 [details]
EvalTestwithFunctions-1.0.jar

Comment 8 Musharraf Hussain 2015-07-23 13:05:52 UTC
The only workaround right now is to add the functions as "Free form DRL" in Guided Rule.

Comment 10 Lukáš Petrovický 2015-08-31 15:38:49 UTC
Thanks, moving.

Comment 11 Jiri Locker 2015-10-22 17:32:48 UTC
Fixed, unit test included (see bz 1247559).