[jboss-svn-commits] JBL Code SVN: r5410 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Aug 2 11:55:20 EDT 2006


Author: michael.neale at jboss.com
Date: 2006-08-02 11:55:17 -0400 (Wed, 02 Aug 2006)
New Revision: 5410

Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
Log:
JBRULES-384 - merged from 3.0.x branch - fix for not being able to remove a rule added as a different package.

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2006-08-02 14:19:43 UTC (rev 5409)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2006-08-02 15:55:17 UTC (rev 5410)
@@ -292,10 +292,17 @@
         }
     }
 
+    /**
+     * Merge a new package with an existing package.
+     * Most of the work is done by the concrete implementations, 
+     * but this class does some work (including combining imports, compilation data, globals,
+     * and the actual Rule objects into the package).
+     */
     private void mergePackage(final Package pkg,
                               final Package newPkg) throws PackageIntegrationException {
         final Map globals = pkg.getGlobals();
         final List imports = pkg.getImports();
+        
 
         // First update the binary files
         // @todo: this probably has issues if you add classes in the incorrect order - functions, rules, invokers.
@@ -323,6 +330,16 @@
             }
         }
         globals.putAll( newPkg.getGlobals() );
+        
+        //Add rules into the RuleBase package
+        //as this is needed for individual rule removal later on
+        Rule[] newRules = newPkg.getRules();
+        for ( int i = 0; i < newRules.length; i++ ) {
+            Rule newRule = newRules[i];
+            if (pkg.getRule( newRule.getName() ) == null) {
+                pkg.addRule( newRule );
+            }
+        }
     }
 
     protected void addRule(final Rule rule) throws InvalidPatternException {




More information about the jboss-svn-commits mailing list