Search in sources :

Example 6 with LogicalDependency

use of org.drools.tms.LogicalDependency in project drools by kiegroup.

the class ProtobufOutputMarshaller method writeActivation.

public static <M extends ModedAssertion<M>> ProtobufMessages.Activation writeActivation(MarshallerWriteContext context, AgendaItem agendaItem, boolean isDormient) {
    ProtobufMessages.Activation.Builder _activation = ProtobufMessages.Activation.newBuilder();
    RuleImpl rule = agendaItem.getRule();
    _activation.setPackageName(rule.getPackage());
    _activation.setRuleName(rule.getName());
    _activation.setTuple(writeTuple(context, agendaItem, isDormient));
    _activation.setSalience(agendaItem.getSalience());
    _activation.setIsActivated(agendaItem.isQueued());
    _activation.setEvaluated(agendaItem.isRuleAgendaItem());
    if (agendaItem.getActivationGroupNode() != null) {
        _activation.setActivationGroup(agendaItem.getActivationGroupNode().getActivationGroup().getName());
    }
    if (agendaItem.getActivationFactHandle() != null) {
        _activation.setHandleId(agendaItem.getActivationFactHandle().getId());
    }
    if (agendaItem instanceof TruthMaintenanceSystemAgendaItem) {
        org.drools.core.util.LinkedList<LogicalDependency<M>> list = ((TruthMaintenanceSystemAgendaItem) agendaItem).getLogicalDependencies();
        if (list != null && !list.isEmpty()) {
            for (LogicalDependency<?> node = list.getFirst(); node != null; node = node.getNext()) {
                _activation.addLogicalDependency(((BeliefSet) node.getJustified()).getFactHandle().getId());
            }
        }
    }
    return _activation.build();
}
Also used : TruthMaintenanceSystemAgendaItem(org.drools.tms.agenda.TruthMaintenanceSystemAgendaItem) LogicalDependency(org.drools.tms.LogicalDependency) BeliefSet(org.drools.tms.beliefsystem.BeliefSet) Activation(org.drools.core.spi.Activation) RuleImpl(org.drools.core.definitions.rule.impl.RuleImpl)

Aggregations

LogicalDependency (org.drools.tms.LogicalDependency)6 SimpleMode (org.drools.tms.SimpleMode)3 Activation (org.drools.core.spi.Activation)2 LinkedListEntry (org.drools.core.util.LinkedListEntry)2 BeliefSet (org.drools.tms.beliefsystem.BeliefSet)2 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)1 FastIterator (org.drools.core.util.FastIterator)1 TruthMaintenanceSystemAgendaItem (org.drools.tms.agenda.TruthMaintenanceSystemAgendaItem)1 ObjectMarshallingStrategy (org.kie.api.marshalling.ObjectMarshallingStrategy)1 ObjectMarshallingStrategyStore (org.kie.api.marshalling.ObjectMarshallingStrategyStore)1