[jboss-jira] [JBoss JIRA] Resolved: (JBRULES-358) RuleBase.removePackage does not work
Edson Tirelli (JIRA)
jira-events at jboss.com
Wed Jul 12 20:59:15 EDT 2006
[ http://jira.jboss.com/jira/browse/JBRULES-358?page=all ]
Edson Tirelli resolved JBRULES-358.
-----------------------------------
Resolution: Done
Fixed. Commited in revision #5063.
Adding drools-compiler/src/test/java/org/drools/AssertedObject.java
Adding drools-compiler/src/test/java/org/drools/Precondition.java
Sending drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java
Adding drools-compiler/src/test/resources/org/drools/integrationtests/test_RemovePackage.drl
Sending drools-core/src/main/java/org/drools/reteoo/ReteooBuilder.java
Sending drools-core/src/main/java/org/drools/rule/Rule.java
Transmitting file data ......
Committed revision 5063.
The problem was that the node sharing counter was not being properly incremented when ReteooBuilder was building the rete network.
> RuleBase.removePackage does not work
> ------------------------------------
>
> Key: JBRULES-358
> URL: http://jira.jboss.com/jira/browse/JBRULES-358
> Project: JBoss Rules
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: Reteoo
> Affects Versions: 3.0, 3.0.1, 3.0.2
> Environment: eclipse IDE 3.12 JBoss Rules 3.0.1 recompiled with debug information
> Reporter: Giovanni Cuccu
> Assigned To: Edson Tirelli
> Fix For: 3.0.3
>
>
> Here is the complete test case to reproduce the error:
> package simpletest;
> import java.io.InputStreamReader;
> import java.util.List;
> import mit.rules.test.TestRules;
> import org.drools.RuleBase;
> import org.drools.RuleBaseFactory;
> import org.drools.WorkingMemory;
> import org.drools.audit.WorkingMemoryFileLogger;
> import org.drools.compiler.PackageBuilder;
> public class TestRemovePackage {
>
> public static void main(String[] args) throws Exception {
> // TODO Auto-generated method stub
> final PackageBuilder builder = new PackageBuilder();
> builder.addPackageFromDrl( new InputStreamReader( TestRemovePackage.class.getResourceAsStream( "testremove.drl" ) ) );
>
> final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
> String packageName=builder.getPackage().getName();
> System.out.println("Package Name " + packageName);
> ruleBase.addPackage( builder.getPackage() );
>
> final WorkingMemory workingMemory = ruleBase.newWorkingMemory();
> fireRules(workingMemory);
> RuleBase ruleBaseWM=workingMemory.getRuleBase();
> System.out.println("ruleBase" + ruleBaseWM.toString());
> ruleBaseWM.removePackage(packageName);
> final PackageBuilder builder1 = new PackageBuilder();
> builder1.addPackageFromDrl( new InputStreamReader( TestRules.class.getResourceAsStream( "testremove2.drl" ) ) );
> ruleBaseWM.addPackage(builder1.getPackage());
> fireRules(workingMemory);
>
>
> }
>
> public static void fireRules(WorkingMemory workingMemory) {
> final WorkingMemoryFileLogger logger = new WorkingMemoryFileLogger( workingMemory );
> logger.setFileName( "log/testcup" );
> final boolean dynamic = false;
>
> workingMemory.assertObject( new Precondition(
> "genericcode","genericvalue"),
> dynamic );
>
> workingMemory.fireAllRules();
> List listaStrutture=workingMemory.getObjects(AssertedObject.class);
> if (listaStrutture==null) {
> System.err.println("Nessuna struttura eroga quello che chiedi");
> }
> for (int i=0;i<listaStrutture.size();i++) {
> AssertedObject assObj=(AssertedObject)listaStrutture.get(i);
> System.out.println("found:" +
> assObj.getValue());
> }
> logger.writeToDisk();
> }
> }
> package simpletest;
> public class Precondition {
> private String code;
> private String value;
>
> public Precondition(String code, String value) {
> super();
> // TODO Auto-generated constructor stub
> this.code = code;
> this.value = value;
> }
> public String getValue() {
> return value;
> }
> public void setValue(String value) {
> this.value = value;
> }
> public String getCode() {
> return code;
> }
> public void setCode(String code) {
> this.code = code;
> }
>
> }
> package simpletest;
> public class AssertedObject {
> private String value;
> public String getValue() {
> return value;
> }
> public void setValue(String value) {
> this.value = value;
> }
> public AssertedObject(String value) {
> // TODO Auto-generated constructor stub
> this.value = value;
> }
>
>
> }
> and here is the drl file
> package simpletest;
> import simpletest.Precondition;
> import simpletest.AssertedObject;
> rule rule1
> salience 10
> when
> p: Precondition ( code == "genericcode")
> then
> assert( new AssertedObject( "value1") );
> assert( new AssertedObject( "value2") );
> end
> rule rule2
> when
> p: Precondition ( code == "genericcode", value=="genericvalue")
> then
> assert( new AssertedObject( "value3") );
> assert( new AssertedObject( "value4") );
> end
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list