/* * (non-Javadoc) * * @see org.kie.common.AgendaI#getNextFocus() */ public InternalAgendaGroup getNextFocus() { InternalAgendaGroup agendaGroup; // Iterate until we find a populate AgendaModule or we reach the MAIN, // default, AgendaGroup while (true) { agendaGroup = (InternalAgendaGroup) this.focusStack.getLast(); if (!agendaGroup.isAutoDeactivate()) { // does not automatically pop, when empty, so always return, even if empty break; } final boolean empty = agendaGroup.isEmpty(); // No populated queues found so pop the focusStack and repeat if (empty && (this.focusStack.size() > 1)) { agendaGroup.setActive(false); this.focusStack.removeLast(); if (agendaGroup.isAutoDeactivate() && !agendaGroup.getNodeInstances().isEmpty()) { innerDeactiveRuleFlowGroup((InternalRuleFlowGroup) agendaGroup); } final EventSupport eventsupport = (EventSupport) this.workingMemory; eventsupport.getAgendaEventSupport().fireAgendaGroupPopped(agendaGroup, this.workingMemory); } else { agendaGroup = (empty) ? null : agendaGroup; break; } } if (agendaGroup != null && !agendaGroup.isActive()) { // only update recency, if not already active. It may be active already if the use called // setFocus agendaGroup.setActivatedForRecency(this.workingMemory.getFactHandleFactory().getRecency()); agendaGroup.setActive(true); } return agendaGroup; }
/* * (non-Javadoc) * * @see org.kie.common.AgendaI#setFocus(org.kie.spi.AgendaGroup) */ @Override public boolean setFocus(final AgendaGroup agendaGroup) { // Set the focus to the agendaGroup if it doesn't already have the focus if (this.focusStack.getLast() != agendaGroup) { ((InternalAgendaGroup) this.focusStack.getLast()).setActive(false); this.focusStack.add(agendaGroup); InternalAgendaGroup igroup = (InternalAgendaGroup) agendaGroup; igroup.setActive(true); igroup.setActivatedForRecency(this.workingMemory.getFactHandleFactory().getRecency()); final EventSupport eventsupport = (EventSupport) this.workingMemory; eventsupport.getAgendaEventSupport().fireAgendaGroupPushed(agendaGroup, this.workingMemory); return true; } else { return false; } }
public static void readAgenda( MarshallerReaderContext context, RuleData _ruleData, DefaultAgenda agenda) { ProtobufMessages.Agenda _agenda = _ruleData.getAgenda(); for (org.drools.core.marshalling.impl.ProtobufMessages.Agenda.AgendaGroup _agendaGroup : _agenda.getAgendaGroupList()) { InternalAgendaGroup group = (InternalAgendaGroup) agenda.getAgendaGroup(_agendaGroup.getName(), context.ruleBase); group.setActive(_agendaGroup.getIsActive()); agenda.getAgendaGroupsMap().put(group.getName(), group); } for (String _groupName : _agenda.getFocusStack().getGroupNameList()) { agenda.addAgendaGroupOnStack(agenda.getAgendaGroup(_groupName)); } for (ProtobufMessages.Agenda.RuleFlowGroup _ruleFlowGroup : _agenda.getRuleFlowGroupList()) { RuleFlowGroupImpl rfgi = new RuleFlowGroupImpl( _ruleFlowGroup.getName(), _ruleFlowGroup.getIsActive(), _ruleFlowGroup.getIsAutoDeactivate()); agenda.getRuleFlowGroupsMap().put(_ruleFlowGroup.getName(), rfgi); // readActivations( context, // _ruleFlowGroup.getActivationList() ); for (NodeInstance _nodeInstance : _ruleFlowGroup.getNodeInstanceList()) { rfgi.addNodeInstance( _nodeInstance.getProcessInstanceId(), _nodeInstance.getNodeInstanceId()); } } readActivations(context, _agenda.getActivationList(), _agenda.getRneaList()); agenda.setActivationsFilter(context.filter); }