Red Hat Bugzilla – Bug 1002370
Guided Rule Editor: Add size related operators for Collection properties
Last modified: 2014-08-06 15:53:00 EDT
Description of problem:
Platform BZ for https://issues.jboss.org/browse/GUVNOR-2048
Steps to Reproduce:
1. See GUVNOR-2048
Cannot choose size related operators for Collection properties
Can choose size related operators for Collection properties
Toni Rikkola <email@example.com> updated the status of jira GUVNOR-2048 to Resolved
Toni Rikkola <firstname.lastname@example.org> made a comment on jira GUVNOR-2048
With the new data model oracle this is not an issue anymore.
This affected 5.5.x, but not an issue anymore since the new data model oracle does not filter out size().
So no commits. The ticket is out of date.
I can reproduce this issue for 6.0.0 ER7.
I've created two facts:
-> Employee (String: name)
-> Company (Employee[0..N]: employees)
For expression editor:
- I can create employees.size but an operator selector contains just these comparisons (egual to | not equal to | is null | is not null)
- I expect that there should be same operators as for number (the type of return value) - for example is grater than, is less then, etc.
field employees is represented as "private java.util.List employees;" instead of "private java.util.List<Employee> employees;". I am not sure if this is a problem, because method size() does not depend on generic type <Employee>.
This is caused by the referenced BZ.
Operators are looked-up from the Fact and Field; however in the case of this BZ the field completions for "Collection" have not been loaded (for some reason -- that will be the cause of this BZ).
As an aside, there is a (clumsy) workaround:-
(1) Ensure you have Collection as a Project "Import Suggestion"
(2) Ensure you have added Collection as an import to the rule
(3) Add a Collection Fact to the rule
(4) Add whatever you need to the rule (e.g. "Person( employees.size() > 0 )
(5) Delete Collection from the rule
Please note in order to see the details of any sub-field (e.g. fields on a Type) the Type needs to either be in the same package as the rule, or imported. See steps (1) and (2) in comment #8.
I can still reproduce this issue. There are steps to reproduce:
1. create a new project (org.test:bugTestProject:1.0)
2. open Data Modeler:
a] create fact "Employee" with field "name" (select type String)
b] create fact "Company" with field "employees" (select type Employee[0..N])
3. open Project editor
a] go to "Imports: Import Suggestions"
b] add New item (java.util.List)
c] Save changes in project and close it
4. create new guided rule "test"
a] go to "Config" and add "java.util.List"
b] go to "Edit"
c] add fact Company into condition part (WHEN)
d] click on "There is a Company with:" and choose "Expression editor"
e] choose field "employees"
f] choose method size()
g] show options for operator
Options are "equal to", "not equal to", "is null", "is not null".
I think that the method "size" return Integer and valid operators are "is greater than", "is less than" etc.
This issue is fixed partially in 6.0.2 ER2 BRMS.
The expected list of operators (with options for Integer) is shown only if the user does not add "import suggestion".
I use steps in comment #11 for verification. If I skip steps 3 and 4a then the expected list of operators is shown. If I perform all steps then the list of operators contains just Object operators.
There is a workaround. Reopen a rule!
Verified on ER3.
Import suggestions have to be set only if fact is not created in the same package.
Test scenario performs correctly such guided rule.