public void cancelActivation(org.drools.runtime.rule.Activation act) { AgendaItem match = ( AgendaItem ) act; match.cancel(); if ( match.isActive() ) { LeftTuple leftTuple = match.getTuple(); leftTuple.getLeftTupleSink().retractLeftTuple( leftTuple, (PropagationContext) act.getPropagationContext(), workingMemory ); } }
public Object getProperty(String name, Object obj, VariableResolverFactory variableFactory) { AgendaItem item = ( AgendaItem ) obj; if ( "rule".equals( name ) ) { return item.getRule(); } else if ( "active".equals( name ) ) { return item.isActive(); } else if ( "objects".equals( name ) ) { return item.getObjects(); } else if ( "factHandles".equals( name ) ) { return item.getFactHandles(); } else if ( "declarationIDs".equals( name ) ) { return item.getDeclarationIDs(); } else if ( "this".equals( name ) ) { return item; } // FIXME hack as MVEL seems to be ignoring indexed variables VariableResolver vr = variableFactory.getNextFactory().getVariableResolver( name ); if ( vr != null ) { return vr.getValue(); } Declaration declr = item.getRuleTerminalNode().getSubRule().getOuterDeclarations().get( name ); if ( declr != null ) { return declr.getValue( null, item.getTuple().get( declr ).getObject() ); } else { return item.getRule().getMetaData().get( name ); } }
public void blockActivation(org.drools.runtime.rule.Activation act) { AgendaItem targetMatch = ( AgendaItem ) act; // iterate to find previous equal logical insertion LogicalDependency dep = null; if ( this.previousJustified != null ) { for ( dep = this.previousJustified.getFirst(); dep != null; dep = dep.getNext() ) { if ( targetMatch == dep.getJustified() ) { this.previousJustified.remove( dep ); break; } } } if ( dep == null ) { dep = new SimpleLogicalDependency( activation, targetMatch ); } this.activation.addBlocked( dep ); if ( targetMatch.getBlockers().size() == 1 && targetMatch.isActive() ) { // it wasn't blocked before, but is now, so we must remove it from all groups, so it cannot be executed. targetMatch.remove(); if ( targetMatch.getActivationGroupNode() != null ) { targetMatch.getActivationGroupNode().getActivationGroup().removeActivation( targetMatch ); } if ( targetMatch.getActivationNode() != null ) { final InternalRuleFlowGroup ruleFlowGroup = (InternalRuleFlowGroup) targetMatch.getActivationNode().getParentContainer(); ruleFlowGroup.removeActivation( targetMatch ); } } }