Red Hat Bugzilla – Bug 998922
[guided editor] 'From accumulate' pattern editor does not offer Number
Last modified: 2014-08-06 16:19:02 EDT
+++ This bug was initially created as a clone of Bug #853993 +++
Description of problem:
When building 'From accumulate' conditional element the result of the accumulation is usually Number, however the pattern editor for the accumulation result only offers imported types.
Of course Number could be explicitely imported, but importing from java.lang package is redundant. Moreover there is inconsistency with pattern editor for 'From collect' which offers List, Set and Collection (java.util) although they are not imported
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. in Guided editor, add 'From Accumulate' condition
2. click 'click to add pattern...' *above* the 'From Accumulate' keywords
Number type is missing in the selection list
Number should be offered
Having Number available is very handy and it used to work in Guvnor 5.1.
--- Additional comment from Jiri Locker on 2012-09-03 16:02:45 CEST ---
Might be related to this change https://issues.jboss.org/browse/GUVNOR-1367.
Can we automatically import classes from java.lang? Or some similar solution?
Well I tried to just hard code Number in, but turns out this is not that simple with the current Data Model Oracle in the background. Also it feels hacky.
The plan has been to let the users control what the dropdowns contain. This is why the "Import Suggestions" are not actual imports for the project. What the "Import suggestions" should do in my mind is:
* Add everything listed in them show in the fact lists.
* When the user selects a fact from a dropdown, import it and add the fact to the file's import list.
This way the admin could just add the java.lang classes to the "Import Suggestions" once and this would fix both this ticket and make using the workbench more user friendly. Adding automatic addition to fact selectors takes a while. Since our fact selectors are not unified and all over the place.
Since both solutions take time. We do not have much time. Both solutions can cause more bugs. And there is a workaround, I would get this done properly for community 6.1 release and if we have time, for the final product release.
Toni, most of the accumulate functions return numbers. I would like to suggest you give it another thought about this, even if it is to treat Number as a special case for accumulate.
Lets talk tomorrow on IRC.
Ok. I think I found a clean way to do this.
java.lang.Number is imported by default to each guided rule asset and each project's import suggestion list. This means Number is visible when accumulate, or anything else in the guided rule editor, is used.
The import is added when a new project or guided rule is created. So it is possible for the user to remove it.
This also supports a feature planned in the future, where we have a list of default imports like List, Map, Integer, Double and so on.
Fix verified in ER7.