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

Neil Wallace (JIRA) jira-events at lists.jboss.org
Tue Jul 7 10:50:51 EDT 2009


CLONE -declaration of 2 variables in the init part of accumulate is not possible
--------------------------------------------------------------------------------

                 Key: JBRULES-2186
                 URL: https://jira.jboss.org/jira/browse/JBRULES-2186
             Project: JBoss Drools
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: drools-compiler
    Affects Versions: 5.0.0.CR1
            Reporter: Neil Wallace
            Assignee: Edson Tirelli
             Fix For: 5.0.1.FINAL


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