Guided Rule editor does not seem to reload "eval()" functions correctly while used inside the constraint of a fact

Solution Unverified - Updated -

Issue

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.

Environment

  • Red Hat JBoss BRMS
    • 6.1.0

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.