[jboss-jira] [JBoss JIRA] Updated: (JBRULES-2058) declaration of 2 variables in the init part of accumulate is not possible

Mark Proctor (JIRA) jira-events at lists.jboss.org
Wed May 13 15:24:48 EDT 2009


     [ https://jira.jboss.org/jira/browse/JBRULES-2058?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mark Proctor updated JBRULES-2058:
----------------------------------

    Assignee: Edson Tirelli  (was: Mark Proctor)


> 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
>
> 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