Bug 1127303 - Guided Editor breaks free form DRL which includes setter method with multi parameters
Summary: Guided Editor breaks free form DRL which includes setter method with multi pa...
Keywords:
Status: VERIFIED
Alias: None
Product: JBoss BRMS Platform 6
Classification: Retired
Component: Business Central
Version: 6.0.1
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ER6
: 6.1.0
Assignee: manstis
QA Contact: Marián Macik
Dawn Eisner
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-06 15:07 UTC by Anton Giertli
Modified: 2016-10-14 14:13 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)
[1] initial version of the rule (17.52 KB, image/png)
2014-08-06 15:07 UTC, Anton Giertli
no flags Details
[2] rule after refresh (19.69 KB, image/png)
2014-08-06 15:07 UTC, Anton Giertli
no flags Details
[3] rule after re-save (40.85 KB, image/png)
2014-08-06 15:07 UTC, Anton Giertli
no flags Details
ER2 - deformed guided editor (6.92 KB, image/png)
2014-12-10 09:20 UTC, Zuzana Krejčová
no flags Details
Method chaining in editor (45.81 KB, image/png)
2015-02-12 16:47 UTC, Marián Macik
no flags Details
Method chaining - source code of the rule (45.86 KB, image/png)
2015-02-12 16:52 UTC, Marián Macik
no flags Details


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 1134067 None None None Never
Red Hat Bugzilla 1172228 None None None Never
Red Hat Bugzilla 1176787 None None None Never

Internal Links: 1134067 1172228 1176787

Description Anton Giertli 2014-08-06 15:07:09 UTC
Created attachment 924517 [details]
[1] initial version of the rule

Description of problem:

If you use a Free Form DRL in a Guided Editor which includes call of a setter method with multiple parameters after saving and refreshing such a rule Guided Editor simply "breaks it".

You are probably asking why would I setter method with multiple parameters, but one real use case is to call WorkflowProcessInstance.setVariable("param","value")

Version-Release number of selected component (if applicable):

BPM 6.0.2
How reproducible:
always

Steps to Reproduce:
1. Create Guided rule, with free form DRL in the RHS. Make sure there is call of a sether method which includes multiple params
2. save the rule, refresh the page
3. open the rule again, type something in the setter field
4. save the rule again

Following exception is displayed:

17:03:53,400 ERROR [org.drools.compiler.kie.builder.impl.AbstractKieModule] (EJB default - 4) Unable to build KieBaseModel:defaultKieBase
Unable to Analyse Expression $process.setVariable( "5ne\",\"two" );:
[Error: unable to resolve method using strict-mode: org.kie.api.runtime.process.WorkflowProcessInstance.setVariable(java.lang.String)]
[Near : {... $process.setVariable( "5ne\",\"two" ); ....}]
                      ^
[Line: 3, Column: 0] : [Rule name='sampleRule']



Actual results:

Guided Editor is not able to cope with the Free Form DRL which includes call of a setter method with multiple parameters
Expected results:

Comment 1 Anton Giertli 2014-08-06 15:07:32 UTC
Created attachment 924518 [details]
[2] rule after refresh

Comment 2 Anton Giertli 2014-08-06 15:07:54 UTC
Created attachment 924519 [details]
[3] rule after re-save

Comment 3 Anton Giertli 2014-08-06 15:08:37 UTC
Screenshots documents the whole process:

-- initial version
-- how is it changed after refreshed
-- how it can't pass validation after changing the value and re-saving the rule

Comment 5 manstis 2014-11-06 13:43:58 UTC
I tried a contrieved case with Community 6.2.0.CR1 (i.e. Product 6.1.0.CR1):-

1.  | package org.mortgages;
2.  |
3.  | import java.lang.Number;
4.  |
5.  | rule "rr"
6.  | dialect "mvel"
7.  |   when
8.  |	  $r : R( )
9.  |	then
10. |	  $r.aTwoParamMethod( "11", "22" );
11. | end

This worked fine (saving, closing and re-opening).

There have been changes to the handling of method parameters since 6.0.1 (the version this BZ has been reported against). I suspect this is already fixed.

Comment 6 manstis 2014-11-06 13:57:11 UTC
I also created the RHS of the above rule with "Free Format DRL" and re-opening the rule worked fine. 

Please note, where possible, the Guided Rule Editor presents "Free Format DRL" with guided widgets when re-opening; so when re-opening this rule the RHS was represented with "Call Method on xxx" widgets and not a "Free Format DRL" block.

Comment 7 Anton Giertli 2014-11-06 14:03:56 UTC
Michael,

I have tested with 6.2.0.CR1 and these are my results:

generated source code - looks just fine
http://ctrlv.cz/shots/2014/11/06/0p2J.png

guided editor after refresh:
http://ctrlv.cz/shots/2014/11/06/bL5e.png

Two error messages are present, and the guided part is sort of trimmed/deformed.

Please re-test with setter method - i.e.

$r.setTwoParamMethod("11","22"); 
instead of
$.aTwoParammethod("11","22");

Comment 8 Zuzana Krejčová 2014-12-10 09:20:11 UTC
Created attachment 966709 [details]
ER2 - deformed guided editor

The source is okay (just like Anton says in comment 7), validation is without errors, project builds just fine.

The guided editor though is a bit deformed (similarly to Anton's observation in comment 7).

Comment 10 manstis 2014-12-11 14:30:23 UTC
The problem was that methods starting with "set" were assumed to be field mutators - for which only single parameters are supported. I've enhanced the handling of methods beginning with "set" so that they are handled as method calls - which can accept multiple parameters.. tested with a $a.setMultipleFields(1, 2) in the RHS and it works OK now.

Comment 11 Marián Macik 2015-02-12 16:42:43 UTC
I've tested it with a setVariable method of WorkflowProcessInstance and it works now. Two separate fields for two parameters are displayed. One field (like before this fix) is displayed only when a rule is not valid, e.g. call method on an object which does not have such method. But it is OK, since whole rule is not valid in this situation.

But I might have found another issue. When I have a class with a String field and I call $p.getString( ).indexOf("a", 1 ); - so I call two methods in a chain, it displays two fields, first with value   ).indexOf("a"   and second with value 1. I don't know if this method chaining should be supported by guided rule editor, but I think I should let you know about it. What do you think?

Comment 12 Marián Macik 2015-02-12 16:47:26 UTC
Created attachment 991043 [details]
Method chaining in editor

Comment 13 Marián Macik 2015-02-12 16:52:41 UTC
Created attachment 991059 [details]
Method chaining - source code of the rule

Comment 15 Marián Macik 2015-03-16 12:27:11 UTC
Verified on 6.1.0.ER6.


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