| Summary: | declaration of 2 variables in the init part of accumulate is not possible | ||
|---|---|---|---|
| Product: | [JBoss] JBoss Enterprise BRMS Platform 5 | Reporter: | nwallace <nwallace> |
| Component: | unspecified | Assignee: | Edson Tirelli <ed.tirelli> |
| Status: | CLOSED NEXTRELEASE | QA Contact: | |
| Severity: | unspecified | Docs Contact: | |
| Priority: | high | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Target Release: | 5.0.1 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| URL: | http://jira.jboss.org/jira/browse/BRMS-173 | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2009-09-01 12:25:36 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
Link: Added: This issue is related to JBRULES-2058 Fix in place. For documenting this in the Release Notes, can you please confirm the following and fill in the missing information. Dot point explanations are fine: The CAUSE (what was actually broken) * There was a bug in the accumulate code. CONSEQUENCES of the bug (how it impacts users.) * one could not declare two variables in the init part of accumulate. The FIX (what was changed to eliminate this bug) and * RESULTS of the fix (what now happens for users.) * We are still awaiting the outstanding information for the Release Notes on this one. Please provide it as soon as possible. Thanks. The CAUSE (what was actually broken) * The code generation logic for java accumulate was broken when multiple variables were defined in the init block, causing compilation errors. CONSEQUENCES of the bug (how it impacts users.) * one could not declare two variables in the init part of accumulate. The FIX (what was changed to eliminate this bug) and * The code generation logic was fixed. RESULTS of the fix (what now happens for users.) * Declaration of multiple variables in the init block of accumulate now works fine. added to 5.0 CP01 release notes: JBRULES-1871 Rules with multiple variables defined in the init block of java accumulate would fail to compile. This is caused by a bug in JavaAccumulateBuilder where only the first variable would be read. This is now fixed and these rules will compile successfully. |
Date of First Response: 2009-09-10 01:22:02 securitylevel_name: Public Take a rule with 2 variables int the init part, like $maxCa:CompanyCA() from accumulate($ca:CompanyCA($year:year) from $p.cas, init(ecrm.party.CompanyCA currentCA=null;int maxYear = 0;), action(maxYear = Math.max(maxYear, $year);), result(currentCA)); which can return the year and the ca where the ca is max. It won't compile with the error that company CA is not declare. The bug is in the class org.drools.rule.builder.dialect.java.JavaAccumulateBuilder line 194 int index = 0; for ( Iterator it = initCodeAnalysis.getLocalVariablesMap().entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); attributes[index] = (String) entry.getKey(); attributesTypes[index] = ((JavaLocalDeclarationDescr) entry.getValue()).getType(); } when the variables are put in the context, only the first is put (index stay at 0) We should increment the index int index = 0; for ( Iterator it = initCodeAnalysis.getLocalVariablesMap().entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); attributes[index] = (String) entry.getKey(); attributesTypes[index] = ((JavaLocalDeclarationDescr) entry.getValue()).getType(); index ++; }