public DeactivateCallback(MarshallerReaderContext context) throws IOException { this.ruleFlowGroup = (InternalRuleFlowGroup) context.wm.getAgenda().getRuleFlowGroup( context.readUTF() ); }
public DeactivateCallback(MarshallerReaderContext context, ProtobufMessages.ActionQueue.Action _action) { this.ruleFlowGroup = (InternalRuleFlowGroup) context.wm.getAgenda().getRuleFlowGroup( _action.getDeactivateCallback().getRuleflowGroup() ); }
private ActiveActivationIterator(InternalWorkingMemory wm) { agenda = (DefaultAgenda) wm.getAgenda(); if ( !agenda.getAgendaGroupsMap().isEmpty() ) { groupsIter = agenda.getAgendaGroupsMap().values().iterator(); group = AGENDA_GROUPS; InternalAgendaGroup group = null; for ( ; groupsIter.hasNext();) { group = (InternalAgendaGroup) groupsIter.next() ; if ( !group.isEmpty() ) { activations = (Activation[]) group.getActivations(); return; } } } if ( !agenda.getRuleFlowGroupsMap().isEmpty() ) { groupsIter = agenda.getRuleFlowGroupsMap().values().iterator(); group = RULEFLOW_GROUPS; RuleFlowGroupImpl group = null; for ( ; groupsIter.hasNext();) { group = (RuleFlowGroupImpl) groupsIter.next() ; if ( !group.isEmpty() ) { activations = (Activation[]) group.getActivations(); return; } } } }
public void retractLeftTuple(final LeftTuple leftTuple, final PropagationContext context, final InternalWorkingMemory workingMemory) { Object obj = leftTuple.getObject(); // activation can be null if the LeftTuple previous propagated into a no-loop // or could be true due to lock-on-active blocking activation creation if ( obj == null || obj == Boolean.TRUE) { return; } Activation activation = (Activation) obj; activation.setMatched( false ); InternalAgenda agenda = (InternalAgenda) workingMemory.getAgenda(); agenda.cancelActivation( leftTuple, context, workingMemory, activation, this ); }
public void read(MarshallerReaderContext inCtx) throws IOException, ClassNotFoundException { int leftTupleId = inCtx.readInt(); LeftTuple leftTuple = inCtx.terminalTupleMap.get( leftTupleId ); ScheduledAgendaItem item = ( ScheduledAgendaItem ) leftTuple.getObject(); Trigger trigger = InputMarshaller.readTrigger( inCtx ); DefaultAgenda agenda = ( DefaultAgenda ) inCtx.wm.getAgenda(); ActivationTimerJob job = new ActivationTimerJob(); ActivationTimerJobContext ctx = new ActivationTimerJobContext( trigger, item, agenda ); JobHandle jobHandle = ((InternalWorkingMemory)agenda.getWorkingMemory()).getTimerService().scheduleJob( job, ctx, trigger ); item.setJobHandle( jobHandle ); }
activation = new ScheduledAgendaItem( activationNumber, leftTuple, (InternalAgenda) wm.getAgenda(), pc, ruleTerminalNode ); ( (DefaultAgenda) wm.getAgenda() ).getActivationGroup( activationGroupName ).addActivation( activation ); agendaGroup = (InternalAgendaGroup) ( (DefaultAgenda) wm.getAgenda() ).getAgendaGroup( AgendaGroup.MAIN ); } else { agendaGroup = (InternalAgendaGroup) ( (DefaultAgenda) wm.getAgenda() ).getAgendaGroup( rule.getAgendaGroup() ); agendaGroup.add( activation ); } else { InternalRuleFlowGroup rfg = (InternalRuleFlowGroup) ( (DefaultAgenda) wm.getAgenda() ).getRuleFlowGroup( rule.getRuleFlowGroup() ); rfg.addActivation( activation );
private void triggerActivations() { // iterate all activations adding them to their AgendaGroups final Iterator<ActivationNode> it = this.list.iterator(); for ( ActivationNode node = it.next(); node != null; node = it.next() ) { final Activation activation = node.getActivation(); ((InternalAgendaGroup) activation.getAgendaGroup()).add( activation ); } // making sure we re-evaluate agenda in case we are waiting for activations ((InternalAgenda) workingMemory.getAgenda()).notifyHalt(); }
public static void writeAgenda(MarshallerWriteContext context) throws IOException { InternalWorkingMemory wm = context.wm; DefaultAgenda agenda = (DefaultAgenda) wm.getAgenda();
private static void writeAgenda(MarshallerWriteContext context, ProtobufMessages.RuleData.Builder _ksb) throws IOException { InternalWorkingMemory wm = context.wm; DefaultAgenda agenda = (DefaultAgenda) wm.getAgenda();
if ( ((InternalAgenda) wm.getAgenda()).isDeclarativeAgenda() ) { ActivationIterator it = ActivationIterator.iterator( wm ); matchFactHandles = new ArrayList<InternalFactHandle>( 100 );
public void assertLeftTuple(final LeftTuple leftTuple, final PropagationContext context, final InternalWorkingMemory workingMemory) { //check if the rule is not effective or // if the current Rule is no-loop and the origin rule is the same then return if ( (!this.rule.isEffective( leftTuple, this, workingMemory )) || (this.rule.isNoLoop() && this.rule.equals( context.getRuleOrigin() )) ) { leftTuple.setObject( Boolean.TRUE ); return; } final InternalAgenda agenda = (InternalAgenda) workingMemory.getAgenda(); boolean fire = agenda.createActivation( leftTuple, context, workingMemory, this, false ); if( fire && !fireDirect ) { agenda.addActivation( (AgendaItem) leftTuple.getObject() ); } }
private static void assertHandleIntoOTN(MarshallerReaderContext context, InternalWorkingMemory wm, InternalFactHandle handle) { Object object = handle.getObject(); InternalWorkingMemoryEntryPoint ep = (InternalWorkingMemoryEntryPoint) handle.getEntryPoint(); ObjectTypeConf typeConf = ((InternalWorkingMemoryEntryPoint) handle.getEntryPoint()).getObjectTypeConfigurationRegistry().getObjectTypeConf( ep.getEntryPoint(), object ); PropagationContextImpl propagationContext = new PropagationContextImpl( wm.getNextPropagationIdCounter(), PropagationContext.ASSERTION, null, null, handle, ((DefaultAgenda) wm.getAgenda()).getActiveActivations(), ((DefaultAgenda) wm.getAgenda()).getDormantActivations(), ep.getEntryPoint(), context); ep.getEntryPointNode().assertObject( handle, propagationContext, typeConf, wm ); propagationContext.evaluateActionQueue( wm ); wm.executeQueuedActions(); propagationContext.cleanReaderContext(); }
public void deserialize(MarshallerReaderContext inCtx, Timer _timer) throws ClassNotFoundException { ActivationTimer _activation = _timer.getActivation(); LeftTuple leftTuple = inCtx.filter.getTuplesCache().get( PersisterHelper.createActivationKey( _activation.getActivation().getPackageName(), _activation.getActivation().getRuleName(), _activation.getActivation().getTuple() ) ); ScheduledAgendaItem item = (ScheduledAgendaItem) leftTuple.getObject(); Trigger trigger = ProtobufInputMarshaller.readTrigger( inCtx, _activation.getTrigger() ); DefaultAgenda agenda = ( DefaultAgenda ) inCtx.wm.getAgenda(); ActivationTimerJob job = new ActivationTimerJob(); ActivationTimerJobContext ctx = new ActivationTimerJobContext( trigger, item, agenda ); JobHandle jobHandle = ((InternalWorkingMemory)agenda.getWorkingMemory()).getTimerService().scheduleJob( job, ctx, trigger ); item.setJobHandle( jobHandle ); } }
public void modifyLeftTuple(LeftTuple leftTuple, PropagationContext context, InternalWorkingMemory workingMemory) { InternalAgenda agenda = (InternalAgenda) workingMemory.getAgenda();