Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1246099 - Guided Rule editor does not seem to reload "eval()" functions correctly while used inside the constraint of a fact
Guided Rule editor does not seem to reload "eval()" functions correctly while...
Status: VERIFIED
Product: JBoss BRMS Platform 6
Classification: Retired
Component: Business Central (Show other bugs)
6.1.0
All All
high Severity high
: ER4
: 6.2.0
Assigned To: manstis
Jiri Locker
:
Depends On:
Blocks: 1247559
  Show dependency treegraph
 
Reported: 2015-07-23 08:58 EDT by Musharraf Hussain
Modified: 2015-10-22 13:32 EDT (History)
1 user (show)

See Also:
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:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
rulesource_beforeissue.png (356.39 KB, image/png)
2015-07-23 08:59 EDT, Musharraf Hussain
no flags Details
ruleeditor_beforeissue.png (318.53 KB, image/png)
2015-07-23 09:00 EDT, Musharraf Hussain
no flags Details
aftersave_closeandreopen_editor.png (375.43 KB, image/png)
2015-07-23 09:00 EDT, Musharraf Hussain
no flags Details
validation_error.png (233.26 KB, image/png)
2015-07-23 09:00 EDT, Musharraf Hussain
no flags Details
bare_repo.zip (528.24 KB, application/zip)
2015-07-23 09:01 EDT, Musharraf Hussain
no flags Details
EvalTestwithFunctions-1.0.jar (6.57 KB, application/zip)
2015-07-23 09:02 EDT, Musharraf Hussain
no flags Details

  None (edit)
Description Musharraf Hussain 2015-07-23 08:58:38 EDT
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 08:59:33 EDT
Created attachment 1055317 [details]
rulesource_beforeissue.png
Comment 2 Musharraf Hussain 2015-07-23 09:00:04 EDT
Created attachment 1055318 [details]
ruleeditor_beforeissue.png
Comment 4 Musharraf Hussain 2015-07-23 09:00:30 EDT
Created attachment 1055319 [details]
aftersave_closeandreopen_editor.png
Comment 5 Musharraf Hussain 2015-07-23 09:00:56 EDT
Created attachment 1055320 [details]
validation_error.png
Comment 6 Musharraf Hussain 2015-07-23 09:01:54 EDT
Created attachment 1055321 [details]
bare_repo.zip
Comment 7 Musharraf Hussain 2015-07-23 09:02:54 EDT
Created attachment 1055324 [details]
EvalTestwithFunctions-1.0.jar
Comment 8 Musharraf Hussain 2015-07-23 09:05:52 EDT
The only workaround right now is to add the functions as "Free form DRL" in Guided Rule.
Comment 10 Lukáš Petrovický 2015-08-31 11:38:49 EDT
Thanks, moving.
Comment 11 Jiri Locker 2015-10-22 13:32:48 EDT
Fixed, unit test included (see bz 1247559).

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