[jboss-svn-commits] JBL Code SVN: r18505 - in labs/jbossrules/trunk: drools-compiler/src/test/java/org/drools/integrationtests and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Feb 19 08:58:50 EST 2008


Author: tirelli
Date: 2008-02-19 08:58:50 -0500 (Tue, 19 Feb 2008)
New Revision: 18505

Added:
   labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_OrCEFollowedByEval.drl
Modified:
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactA.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactB.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactC.java
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/EvalCondition.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java
Log:
JBRULES-1389: fixing CCE when using evals after OR statements

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactA.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactA.java	2008-02-19 13:37:05 UTC (rev 18504)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactA.java	2008-02-19 13:58:50 UTC (rev 18505)
@@ -8,6 +8,10 @@
     public FactA() {
     }
 
+    public FactA( String f1 ) {
+        this.field1 = f1;
+    }
+
     public FactA(final String f1,
                  final Integer f2,
                  final Float f3) {

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactB.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactB.java	2008-02-19 13:37:05 UTC (rev 18504)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactB.java	2008-02-19 13:58:50 UTC (rev 18505)
@@ -8,6 +8,10 @@
     public FactB() {
     }
 
+    public FactB( String f1 ) {
+        this.f1 = f1;
+    }
+
     public FactB(final String a,
                  final Integer b,
                  final Float c) {

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactC.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactC.java	2008-02-19 13:37:05 UTC (rev 18504)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/FactC.java	2008-02-19 13:58:50 UTC (rev 18505)
@@ -17,6 +17,10 @@
 
     }
 
+    public FactC( String f1 ) {
+        this.f1 = f1;
+    }
+
     public String getF1() {
         return this.f1;
     }

Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java	2008-02-19 13:37:05 UTC (rev 18504)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java	2008-02-19 13:58:50 UTC (rev 18505)
@@ -81,13 +81,14 @@
 import org.drools.audit.WorkingMemoryFileLogger;
 import org.drools.base.ClassObjectFilter;
 import org.drools.common.AbstractWorkingMemory;
+import org.drools.common.InternalFactHandle;
+import org.drools.compiler.DescrBuildError;
 import org.drools.compiler.DrlParser;
 import org.drools.compiler.DroolsError;
 import org.drools.compiler.DroolsParserException;
 import org.drools.compiler.PackageBuilder;
 import org.drools.compiler.PackageBuilderConfiguration;
 import org.drools.compiler.ParserError;
-import org.drools.compiler.DescrBuildError;
 import org.drools.compiler.PackageBuilder.PackageMergeException;
 import org.drools.event.ActivationCancelledEvent;
 import org.drools.event.ActivationCreatedEvent;
@@ -116,7 +117,6 @@
 import org.drools.spi.GlobalResolver;
 import org.drools.xml.XmlDumper;
 
-
 /** Run all the tests with the ReteOO engine implementation */
 public class MiscTest extends TestCase {
 
@@ -235,8 +235,12 @@
 
         workingMemory.fireAllRules();
 
-        assertEquals(1, list.size() );
+        assertEquals( 1,
+                      list.size() );
 
+        assertEquals( 1,
+                      list.size() );
+
         assertEquals( new Integer( 5 ),
                       list.get( 0 ) );
     }
@@ -272,14 +276,15 @@
 
         } );
 
-        Cheese bree = new Cheese ();
+        Cheese bree = new Cheese();
         bree.setPrice( 100 );
 
         workingMemory.insert( bree );
 
         workingMemory.fireAllRules();
 
-        assertEquals(2, list.size() );
+        assertEquals( 2,
+                      list.size() );
 
         assertEquals( new Integer( 5 ),
                       list.get( 0 ) );
@@ -288,7 +293,6 @@
                       list.get( 1 ) );
     }
 
-
     public void testFieldBiningsAndEvalSharing() throws Exception {
         final String drl = "test_FieldBindingsAndEvalSharing.drl";
         evalSharingTest( drl );
@@ -416,14 +420,17 @@
 
         WorkingMemory workingMemory = ruleBase.newStatefulSession();
         List list = new ArrayList();
-        workingMemory.setGlobal("list", list);
+        workingMemory.setGlobal( "list",
+                                 list );
 
-        workingMemory.insert(new Attribute());
-        workingMemory.insert(new Message());
+        workingMemory.insert( new Attribute() );
+        workingMemory.insert( new Message() );
         workingMemory.fireAllRules();
 
-        assertEquals(1, list.size());
-        assertEquals("X", list.get(0));
+        assertEquals( 1,
+                      list.size() );
+        assertEquals( "X",
+                      list.get( 0 ) );
 
     }
 
@@ -1814,7 +1821,7 @@
         assertTrue( IteratorToList.convert( workingMemory.iterateObjects() ).contains( bob ) );
         assertTrue( IteratorToList.convert( workingMemory.iterateObjects() ).contains( new Person( "help" ) ) );
     }
-    
+
     public void testSerializeWorkingMemoryAndRuleBase1() throws Exception {
         // has the first newStatefulSession before the ruleBase is serialised
         final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_Serializable.drl" ) );
@@ -1828,35 +1835,29 @@
 
         RuleBase ruleBase = getRuleBase();// RuleBaseFactory.newRuleBase();
 
-        WorkingMemory workingMemory = ruleBase.newStatefulSession();        
-        
+        WorkingMemory workingMemory = ruleBase.newStatefulSession();
+
         Map map = new HashMap();
-        map.put( "x", ruleBase );
+        map.put( "x",
+                 ruleBase );
         final byte[] ast = serializeOut( map );
         map = (Map) serializeIn( ast );
         ruleBase = (RuleBase) map.get( "x" );
 
-
-
-        
         final byte[] wm = serializeOut( workingMemory );
 
         workingMemory = ruleBase.newStatefulSession( new ByteArrayInputStream( wm ) );
 
         ruleBase.addPackage( pkg );
 
-        workingMemory.setGlobal( "list", 
-                new ArrayList() );
-        
+        workingMemory.setGlobal( "list",
+                                 new ArrayList() );
 
         final Person bob = new Person( "bob" );
         workingMemory.insert( bob );
 
-
-        
         final Rule[] rules = ruleBase.getPackages()[0].getRules();
 
-                
         assertEquals( 4,
                       rules.length );
 
@@ -1869,8 +1870,6 @@
         assertEquals( "match Integer",
                       rules[3].getName() );
 
-        
-
         assertEquals( 1,
                       IteratorToList.convert( workingMemory.iterateObjects() ).size() );
         assertEquals( bob,
@@ -1894,7 +1893,7 @@
         assertTrue( IteratorToList.convert( workingMemory.iterateObjects() ).contains( bob ) );
         assertTrue( IteratorToList.convert( workingMemory.iterateObjects() ).contains( new Person( "help" ) ) );
 
-    }    
+    }
 
     public void testSerializeWorkingMemoryAndRuleBase2() throws Exception {
         // has the first newStatefulSession after the ruleBase is serialised
@@ -1908,30 +1907,31 @@
                       builder.getErrors().getErrors().length );
 
         RuleBase ruleBase = getRuleBase();// RuleBaseFactory.newRuleBase();   
-        
+
         // serialise a hashmap with the RuleBase as a key
         Map map = new HashMap();
-        map.put( "x", ruleBase );
+        map.put( "x",
+                 ruleBase );
         final byte[] ast = serializeOut( map );
         map = (Map) serializeIn( ast );
         ruleBase = (RuleBase) map.get( "x" );
 
-        WorkingMemory workingMemory = ruleBase.newStatefulSession();    
-        
+        WorkingMemory workingMemory = ruleBase.newStatefulSession();
+
         // serialise the working memory before population
-        final byte[] wm = serializeOut( workingMemory );        
+        final byte[] wm = serializeOut( workingMemory );
         workingMemory = ruleBase.newStatefulSession( new ByteArrayInputStream( wm ) );
 
         ruleBase.addPackage( pkg );
 
-        workingMemory.setGlobal( "list", 
-        					     new ArrayList() );
-        
+        workingMemory.setGlobal( "list",
+                                 new ArrayList() );
+
         final Person bob = new Person( "bob" );
         workingMemory.insert( bob );
-        
+
         final Rule[] rules = ruleBase.getPackages()[0].getRules();
-                
+
         assertEquals( 4,
                       rules.length );
 
@@ -1942,7 +1942,7 @@
         assertEquals( "match Person 3",
                       rules[2].getName() );
         assertEquals( "match Integer",
-                      rules[3].getName() );        
+                      rules[3].getName() );
 
         assertEquals( 1,
                       IteratorToList.convert( workingMemory.iterateObjects() ).size() );
@@ -1966,9 +1966,8 @@
                       IteratorToList.convert( workingMemory.iterateObjects() ).size() );
         assertTrue( IteratorToList.convert( workingMemory.iterateObjects() ).contains( bob ) );
         assertTrue( IteratorToList.convert( workingMemory.iterateObjects() ).contains( new Person( "help" ) ) );
-    }    
-    
-    
+    }
+
     public void FIXME_testSerializeWorkingMemoryAndRuleBase3() throws Exception {
         // has the first newStatefulSession after the ruleBase is serialised
         final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_Serializable.drl" ) );
@@ -1980,31 +1979,31 @@
         assertEquals( 0,
                       builder.getErrors().getErrors().length );
 
-        RuleBase ruleBase = getRuleBase();        
-        WorkingMemory workingMemory = ruleBase.newStatefulSession();            
+        RuleBase ruleBase = getRuleBase();
+        WorkingMemory workingMemory = ruleBase.newStatefulSession();
 
         ruleBase.addPackage( pkg );
 
-        workingMemory.setGlobal( "list", 
-        						 new ArrayList() );
-        
+        workingMemory.setGlobal( "list",
+                                 new ArrayList() );
 
         final Person bob = new Person( "bob" );
-        workingMemory.insert( bob );        
-        
+        workingMemory.insert( bob );
+
         // serialise a hashmap with the RuleBase as a key, after WM population
         Map map = new HashMap();
-        map.put( "x", ruleBase );
+        map.put( "x",
+                 ruleBase );
         final byte[] ast = serializeOut( map );
         map = (Map) serializeIn( ast );
-        ruleBase = (RuleBase) map.get( "x" );        
-        
+        ruleBase = (RuleBase) map.get( "x" );
+
         // now try serialising with a fully populated wm from a serialised rulebase
         final byte[] wm = serializeOut( workingMemory );
-        workingMemory = ruleBase.newStatefulSession( new ByteArrayInputStream( wm ) );         
-        
+        workingMemory = ruleBase.newStatefulSession( new ByteArrayInputStream( wm ) );
+
         final Rule[] rules = ruleBase.getPackages()[0].getRules();
-                
+
         assertEquals( 4,
                       rules.length );
 
@@ -2015,7 +2014,7 @@
         assertEquals( "match Person 3",
                       rules[2].getName() );
         assertEquals( "match Integer",
-                      rules[3].getName() );        
+                      rules[3].getName() );
 
         assertEquals( 1,
                       IteratorToList.convert( workingMemory.iterateObjects() ).size() );
@@ -2038,11 +2037,9 @@
         assertEquals( 2,
                       IteratorToList.convert( workingMemory.iterateObjects() ).size() );
         assertTrue( IteratorToList.convert( workingMemory.iterateObjects() ).contains( bob ) );
-        assertTrue( IteratorToList.convert( workingMemory.iterateObjects() ).contains( new Person( "help" ) ) );              
-    }    
-    
-    
-    
+        assertTrue( IteratorToList.convert( workingMemory.iterateObjects() ).contains( new Person( "help" ) ) );
+    }
+
     public void testEmptyRule() throws Exception {
         final PackageBuilder builder = new PackageBuilder();
         builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_EmptyRule.drl" ) ) );
@@ -3297,7 +3294,7 @@
         final Cheese stilton2 = new Cheese( "stilton2",
                                             12 );
         final Cheese agedStilton = new Cheese( "aged stilton",
-                                            12 );
+                                               12 );
         final Cheese brie = new Cheese( "brie",
                                         10 );
         final Cheese brie2 = new Cheese( "brie2",
@@ -4620,10 +4617,10 @@
     public void testConsequenceBuilderException() throws Exception {
         final PackageBuilder builder = new PackageBuilder();
         builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_ConsequenceBuilderException.drl" ) ) );
-        
+
         assertTrue( builder.hasErrors() );
     }
-    
+
     public void testRuntimeTypeCoercion() throws Exception {
         final PackageBuilder builder = new PackageBuilder();
         builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_RuntimeTypeCoercion.drl" ) ) );
@@ -4636,30 +4633,36 @@
         final List list = new ArrayList();
         workingMemory.setGlobal( "results",
                                  list );
-        
+
         final PolymorphicFact fact = new PolymorphicFact( new Integer( 10 ) );
         final FactHandle handle = workingMemory.insert( fact );
-        
+
         workingMemory.fireAllRules();
-        
-        assertEquals( 1, list.size() );
-        assertEquals( fact.getData(), list.get( 0 ) );
-        
+
+        assertEquals( 1,
+                      list.size() );
+        assertEquals( fact.getData(),
+                      list.get( 0 ) );
+
         fact.setData( "10" );
-        workingMemory.update( handle, fact );
+        workingMemory.update( handle,
+                              fact );
         workingMemory.fireAllRules();
-        
-        assertEquals( 2, list.size() );
-        assertEquals( fact.getData(), list.get( 1 ) );
-        
+
+        assertEquals( 2,
+                      list.size() );
+        assertEquals( fact.getData(),
+                      list.get( 1 ) );
+
         try {
-            fact.setData( new Boolean(true) );
-            workingMemory.update( handle, fact );
-            fail("Should not allow to compare < with a Boolean object");
-        } catch( ClassCastException cce ) {
+            fact.setData( new Boolean( true ) );
+            workingMemory.update( handle,
+                                  fact );
+            fail( "Should not allow to compare < with a Boolean object" );
+        } catch ( ClassCastException cce ) {
             // success, as can't use "<" to compare to a boolean
         }
-        
+
     }
 
     public void testRuntimeTypeCoercion2() throws Exception {
@@ -4674,38 +4677,50 @@
         final List list = new ArrayList();
         workingMemory.setGlobal( "results",
                                  list );
-        
-        final Primitives fact = new Primitives( );
+
+        final Primitives fact = new Primitives();
         fact.setBooleanPrimitive( true );
-        fact.setBooleanWrapper( new Boolean(true) );
-        fact.setObject( new Boolean(true) );
+        fact.setBooleanWrapper( new Boolean( true ) );
+        fact.setObject( new Boolean( true ) );
         fact.setCharPrimitive( 'X' );
         final FactHandle handle = workingMemory.insert( fact );
-        
+
         workingMemory.fireAllRules();
-        
+
         int index = 0;
-        assertEquals( list.toString(), 4, list.size() );
-        assertEquals( "boolean", list.get( index++ ));
-        assertEquals( "boolean wrapper", list.get( index++ ));
-        assertEquals( "boolean object", list.get( index++ ));
-        assertEquals( "char", list.get( index++ ));
-        
+        assertEquals( list.toString(),
+                      4,
+                      list.size() );
+        assertEquals( "boolean",
+                      list.get( index++ ) );
+        assertEquals( "boolean wrapper",
+                      list.get( index++ ) );
+        assertEquals( "boolean object",
+                      list.get( index++ ) );
+        assertEquals( "char",
+                      list.get( index++ ) );
+
         fact.setBooleanPrimitive( false );
         fact.setBooleanWrapper( null );
         fact.setCharPrimitive( '\0' );
-        fact.setObject( new Character('X') );
-        workingMemory.update( handle, fact );
+        fact.setObject( new Character( 'X' ) );
+        workingMemory.update( handle,
+                              fact );
         workingMemory.fireAllRules();
-        assertEquals( 5, list.size() );
-        assertEquals( "char object", list.get( index++ ) );
-        
+        assertEquals( 5,
+                      list.size() );
+        assertEquals( "char object",
+                      list.get( index++ ) );
+
         fact.setObject( null );
-        workingMemory.update( handle, fact );
+        workingMemory.update( handle,
+                              fact );
         workingMemory.fireAllRules();
-        assertEquals( 6, list.size() );
-        assertEquals( "null object", list.get( index++ ) );
-        
+        assertEquals( 6,
+                      list.size() );
+        assertEquals( "null object",
+                      list.get( index++ ) );
+
     }
 
     public void testAlphaEvalWithOrCE() throws Exception {
@@ -4720,7 +4735,7 @@
         final List list = new ArrayList();
         workingMemory.setGlobal( "results",
                                  list );
-        
+
         FactA a = new FactA();
         a.setField1( "a value" );
 
@@ -4730,7 +4745,7 @@
 
         workingMemory.fireAllRules();
 
-        assertEquals( "should not have fired", 
+        assertEquals( "should not have fired",
                       0,
                       list.size() );
     }
@@ -4756,13 +4771,13 @@
 
         workingMemory.fireAllRules( 2 );
 
-        assertEquals( "should have fired only once", 
+        assertEquals( "should have fired only once",
                       1,
                       list.size() );
     }
-    
+
     // this test requires mvel 1.2.19. Leaving it commented until mvel is released.
-    public void FIXME_testJavaModifyBlock() throws Exception {
+    public void testJavaModifyBlock() throws Exception {
         final PackageBuilder builder = new PackageBuilder();
         builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_JavaModifyBlock.drl" ) ) );
         final Package pkg = builder.getPackage();
@@ -4775,7 +4790,8 @@
         workingMemory.setGlobal( "results",
                                  list );
 
-        Person bob = new Person( "Bob", 30 );
+        Person bob = new Person( "Bob",
+                                 30 );
         bob.setStatus( "hungry" );
         workingMemory.insert( bob );
         workingMemory.insert( new Cheese() );
@@ -4783,13 +4799,15 @@
 
         workingMemory.fireAllRules( 2 );
 
-        assertEquals( "should have fired only once", 
+        assertEquals( "should have fired only once",
                       1,
                       list.size() );
-        assertEquals( "full", bob.getStatus() );
-        assertEquals( 31, bob.getAge() );
+        assertEquals( "full",
+                      bob.getStatus() );
+        assertEquals( 31,
+                      bob.getAge() );
     }
-    
+
     public void testOrCE() throws Exception {
         final PackageBuilder builder = new PackageBuilder();
         builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_OrCE.drl" ) ) );
@@ -4802,17 +4820,18 @@
         final List list = new ArrayList();
         workingMemory.setGlobal( "results",
                                  list );
-        
-        workingMemory.insert( new Cheese( "brie", 10 ) );
+
+        workingMemory.insert( new Cheese( "brie",
+                                          10 ) );
         workingMemory.insert( new Person( "bob" ) );
 
         workingMemory.fireAllRules();
 
-        assertEquals( "should have fired once", 
+        assertEquals( "should have fired once",
                       1,
                       list.size() );
     }
-    
+
     public void testGetFactHandleEqualityBehavior() throws Exception {
         final RuleBaseConfiguration conf = new RuleBaseConfiguration();
         conf.setAssertBehaviour( RuleBaseConfiguration.AssertBehaviour.EQUALITY );
@@ -4820,11 +4839,13 @@
 
         final StatefulSession session = ruleBase.newStatefulSession();
 
-        CheeseEqual cheese = new CheeseEqual("stilton", 10);
-        session.insert(cheese);
-        FactHandle fh = session.getFactHandle(new CheeseEqual("stilton", 10));
-        assertNotNull(fh);
-    }    
+        CheeseEqual cheese = new CheeseEqual( "stilton",
+                                              10 );
+        session.insert( cheese );
+        FactHandle fh = session.getFactHandle( new CheeseEqual( "stilton",
+                                                                10 ) );
+        assertNotNull( fh );
+    }
 
     public void testGetFactHandleIdentityBehavior() throws Exception {
         final RuleBaseConfiguration conf = new RuleBaseConfiguration();
@@ -4833,12 +4854,38 @@
 
         final StatefulSession session = ruleBase.newStatefulSession();
 
-        CheeseEqual cheese = new CheeseEqual("stilton", 10);
-        session.insert(cheese);
-        FactHandle fh1 = session.getFactHandle(new Cheese("stilton", 10));
-        assertNull(fh1);
+        CheeseEqual cheese = new CheeseEqual( "stilton",
+                                              10 );
+        session.insert( cheese );
+        FactHandle fh1 = session.getFactHandle( new Cheese( "stilton",
+                                                            10 ) );
+        assertNull( fh1 );
         FactHandle fh2 = session.getFactHandle( cheese );
-        assertNotNull(fh2);
-    }    
+        assertNotNull( fh2 );
+    }
 
+    public void testOrCEFollowedByEval() throws Exception {
+        final PackageBuilder builder = new PackageBuilder();
+        builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_OrCEFollowedByEval.drl" ) ) );
+        final Package pkg = builder.getPackage();
+
+        final RuleBase ruleBase = getRuleBase();
+        ruleBase.addPackage( pkg );
+        final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+
+        final List list = new ArrayList();
+        workingMemory.setGlobal( "results",
+                                 list );
+
+        workingMemory.insert( new FactA( "X" ) );
+        InternalFactHandle b = (InternalFactHandle) workingMemory.insert( new FactB( "X" ) );
+
+        workingMemory.fireAllRules();
+
+        assertEquals( "should have fired",
+                      2,
+                      list.size() );
+        assertTrue( list.contains( b.getObject() ) );
+    }
+
 }

Copied: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_OrCEFollowedByEval.drl (from rev 18504, labs/jbossrules/branches/4.0.x/drools-compiler/src/test/resources/org/drools/integrationtests/test_OrCEFollowedByEval.drl)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_OrCEFollowedByEval.drl	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_OrCEFollowedByEval.drl	2008-02-19 13:58:50 UTC (rev 18505)
@@ -0,0 +1,12 @@
+package org.drools;
+
+global java.util.List results;
+
+rule "test eval with OR"
+when
+    FactA( $a : field1 )
+    $f : FactB( $b : f1 ) or $f : FactB( $b : f1 == "X" )
+    eval( $a.equals( $b ) ) 
+then
+    results.add( $f );
+end
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/EvalCondition.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/EvalCondition.java	2008-02-19 13:37:05 UTC (rev 18504)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/EvalCondition.java	2008-02-19 13:58:50 UTC (rev 18505)
@@ -85,7 +85,7 @@
 
     public Object clone() {
         final EvalCondition eval = new EvalCondition( this.expression,
-                                                      this.requiredDeclarations );
+                                                      (Declaration[]) this.requiredDeclarations.clone() );
         return eval;
     }
 
@@ -144,4 +144,13 @@
         return true;
     }
 
+    public void replaceDeclaration(Declaration declaration,
+                                   Declaration resolved) {
+        for ( int i = 0; i < this.requiredDeclarations.length; i++ ) {
+            if ( this.requiredDeclarations[i].equals( declaration ) ) {
+                this.requiredDeclarations[i] = resolved;
+            }
+        }
+    }
+
 };
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java	2008-02-19 13:37:05 UTC (rev 18504)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/LogicTransformer.java	2008-02-19 13:58:50 UTC (rev 18505)
@@ -173,6 +173,15 @@
                     }
                 }
             }
+        } else if ( element instanceof EvalCondition ) {
+            Declaration[] decl = ((EvalCondition) element).getRequiredDeclarations();
+            for ( int i = 0; i < decl.length; i++ ) {
+                Declaration resolved = resolver.getDeclaration( decl[i].getIdentifier() );
+                if ( resolved != null && resolved != decl[i] ) {
+                    ((EvalCondition) element).replaceDeclaration( decl[i],
+                                                                  resolved );
+                }
+            }
         } else {
             contextStack.push( element );
             for ( Iterator it = element.getNestedElements().iterator(); it.hasNext(); ) {




More information about the jboss-svn-commits mailing list