[jboss-jira] [JBoss JIRA] Closed: (JBRULES-2058) declaration of 2 variables in the init part of accumulate is not possible
Edson Tirelli (JIRA)
jira-events at lists.jboss.org
Wed May 13 16:42:52 EDT 2009
[ https://jira.jboss.org/jira/browse/JBRULES-2058?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Edson Tirelli closed JBRULES-2058.
----------------------------------
Fix Version/s: 5.0.0.GA
Resolution: Done
Fixed. Thanks for reporting and providing the solution.
> declaration of 2 variables in the init part of accumulate is not possible
> -------------------------------------------------------------------------
>
> Key: JBRULES-2058
> URL: https://jira.jboss.org/jira/browse/JBRULES-2058
> Project: JBoss Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-compiler
> Affects Versions: 5.0.0.CR1
> Reporter: loiez etienne
> Assignee: Edson Tirelli
> Fix For: 5.0.0.GA
>
>
> 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 ++;
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list