[jboss-svn-commits] JBL Code SVN: r31228 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jan 26 11:45:32 EST 2010
Author: mark.proctor at jboss.com
Date: 2010-01-26 11:45:32 -0500 (Tue, 26 Jan 2010)
New Revision: 31228
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
Log:
31179 by Rikkola 21 January 2010, 03:03:42 -0500 (5 days ago) A test for a feature that used to work in revision 30833. But recently got broken. Throws an NPE when Pet fact is inserted.
./drools-compiler/src/test/java/org/drools/Pet.java 31179 history download (+13) new
./drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java 31179 history download (+40 -0) diffs
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java 2010-01-26 11:10:47 UTC (rev 31227)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/reteoo/CollectNode.java 2010-01-26 16:45:32 UTC (rev 31228)
@@ -321,33 +321,33 @@
final InternalWorkingMemory workingMemory,
final CollectMemory memory) {
-// final CollectContext colctx = (CollectContext) memory.betaMemory.getCreatedHandles().get( leftTuple );
-//
-// // if tuple was propagated
-// if ( colctx.propagated ) {
-// LeftTuple firstMatch = getFirstMatch( leftTuple, colctx );
-//
-// // we may have no matches yet
-// if( firstMatch != null ) {
-// // temporarily break the linked list to avoid wrong retracts
-// firstMatch.getLeftParentPrevious().setLeftParentNext( null );
-// firstMatch.setLeftParentPrevious( null );
-// }
-// this.sink.propagateRetractLeftTuple( leftTuple,
-// context,
-// workingMemory );
-// // now set the beta children to the first match
-// leftTuple.setBetaChildren( firstMatch );
-// colctx.propagated = false;
-// }
+ final CollectContext colctx = (CollectContext) memory.betaMemory.getCreatedHandles().get( leftTuple );
-// if( isAssert ) {
-// // linking left and right by creating a new left tuple
-// new LeftTuple( leftTuple,
-// rightTuple,
-// this,
-// this.tupleMemoryEnabled );
-// } else {
+ // if tuple was propagated
+ if ( colctx.propagated ) {
+ LeftTuple firstMatch = getFirstMatch( leftTuple, colctx );
+
+ // we may have no matches yet
+ if( firstMatch != null ) {
+ // temporarily break the linked list to avoid wrong retracts
+ firstMatch.getLeftParentPrevious().setLeftParentNext( null );
+ firstMatch.setLeftParentPrevious( null );
+ }
+ this.sink.propagateRetractLeftTuple( leftTuple,
+ context,
+ workingMemory );
+ // now set the beta children to the first match
+ leftTuple.setBetaChildren( firstMatch );
+ colctx.propagated = false;
+ }
+
+ if( isAssert ) {
+ // linking left and right by creating a new left tuple
+ new LeftTuple( leftTuple,
+ rightTuple,
+ this,
+ this.tupleMemoryEnabled );
+ } else {
if( leftTuple.getBetaChildren() != null ) {
// removing link between left and right
LeftTuple match = leftTuple.getBetaChildren();
@@ -356,32 +356,32 @@
}
match.unlinkFromLeftParent();
match.unlinkFromRightParent();
+ }
+ }
+
+ // if there is a subnetwork, we need to unwrapp the object from inside the tuple
+ InternalFactHandle handle = rightTuple.getFactHandle();
+ if ( this.unwrapRightObject ) {
+ handle = ((LeftTuple) handle.getObject()).getLastHandle();
+ }
+
+ if ( context.getType() == PropagationContext.ASSERTION ) {
+ ((Collection) colctx.resultTuple.getFactHandle().getObject()).add( handle.getObject() );
+ } else if ( context.getType() == PropagationContext.RETRACTION || context.getType() == PropagationContext.EXPIRATION ) {
+ ((Collection) colctx.resultTuple.getFactHandle().getObject()).remove( handle.getObject() );
+ } else if ( context.getType() == PropagationContext.MODIFICATION || context.getType() == PropagationContext.RULE_ADDITION || context.getType() == PropagationContext.RULE_REMOVAL ) {
+ if ( isAssert ) {
+ ((Collection) colctx.resultTuple.getFactHandle().getObject()).add( handle.getObject() );
+ } else {
+ ((Collection) colctx.resultTuple.getFactHandle().getObject()).remove( handle.getObject() );
}
-// }
-//
-// // if there is a subnetwork, we need to unwrapp the object from inside the tuple
-// InternalFactHandle handle = rightTuple.getFactHandle();
-// if ( this.unwrapRightObject ) {
-// handle = ((LeftTuple) handle.getObject()).getLastHandle();
-// }
-//
-// if ( context.getType() == PropagationContext.ASSERTION ) {
-// ((Collection) colctx.resultTuple.getFactHandle().getObject()).add( handle.getObject() );
-// } else if ( context.getType() == PropagationContext.RETRACTION || context.getType() == PropagationContext.EXPIRATION ) {
-// ((Collection) colctx.resultTuple.getFactHandle().getObject()).remove( handle.getObject() );
-// } else if ( context.getType() == PropagationContext.MODIFICATION || context.getType() == PropagationContext.RULE_ADDITION || context.getType() == PropagationContext.RULE_REMOVAL ) {
-// if ( isAssert ) {
-// ((Collection) colctx.resultTuple.getFactHandle().getObject()).add( handle.getObject() );
-// } else {
-// ((Collection) colctx.resultTuple.getFactHandle().getObject()).remove( handle.getObject() );
-// }
-// }
-//
-// evaluateResultConstraints( leftTuple,
-// context,
-// workingMemory,
-// memory,
-// colctx );
+ }
+
+ evaluateResultConstraints( leftTuple,
+ context,
+ workingMemory,
+ memory,
+ colctx );
}
/**
More information about the jboss-svn-commits
mailing list