Bug 1246099 - Guided Rule editor does not seem to reload "eval()" functions correctly while used inside the constraint of a fact
Summary: Guided Rule editor does not seem to reload "eval()" functions correctly while...
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: Business Central
Version: 6.1.0
Hardware: All
OS: All
high
high
Target Milestone: ER4
: 6.2.0
Assignee: manstis
QA Contact: Jiri Locker
URL:
Whiteboard:
Depends On:
Blocks: 1247559
TreeView+ depends on / blocked
 
Reported: 2015-07-23 12:58 UTC by Musharraf Hussain
Modified: 2020-03-27 19:06 UTC (History)
1 user (show)

Fixed In Version:
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
Embargoed:


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

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).


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