Ejemplo n.º 1
0
  public static ProtobufMessages.Activation writeActivation(
      MarshallerWriteContext context, AgendaItem agendaItem) {
    ProtobufMessages.Activation.Builder _activation = ProtobufMessages.Activation.newBuilder();

    RuleImpl rule = agendaItem.getRule();
    _activation.setPackageName(rule.getPackage());
    _activation.setRuleName(rule.getName());
    _activation.setTuple(writeTuple(agendaItem.getTuple()));
    _activation.setSalience(agendaItem.getSalience());
    _activation.setIsActivated(agendaItem.isQueued());
    _activation.setEvaluated(agendaItem.isRuleAgendaItem());

    if (agendaItem.getActivationGroupNode() != null) {
      _activation.setActivationGroup(
          agendaItem.getActivationGroupNode().getActivationGroup().getName());
    }

    if (agendaItem.getFactHandle() != null) {
      _activation.setHandleId(agendaItem.getFactHandle().getId());
    }

    org.drools.core.util.LinkedList<LogicalDependency> list = 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();
  }
  public static ProtobufMessages.Activation writeActivation(
      MarshallerWriteContext context, AgendaItem agendaItem) {
    ProtobufMessages.Activation.Builder _activation = ProtobufMessages.Activation.newBuilder();

    Rule rule = agendaItem.getRule();
    _activation.setPackageName(rule.getPackage());
    _activation.setRuleName(rule.getName());

    ProtobufMessages.Tuple.Builder _tb = ProtobufMessages.Tuple.newBuilder();
    for (LeftTuple entry = agendaItem.getTuple(); entry != null; entry = entry.getParent()) {
      InternalFactHandle handle = entry.getLastHandle();
      _tb.addHandleId(handle.getId());
    }
    _activation.setTuple(_tb.build());

    _activation.setSalience(agendaItem.getSalience());
    _activation.setIsActivated(agendaItem.isActivated());

    if (agendaItem.getActivationGroupNode() != null) {
      _activation.setActivationGroup(
          agendaItem.getActivationGroupNode().getActivationGroup().getName());
    }

    if (agendaItem.getFactHandle() != null) {
      _activation.setHandleId(agendaItem.getFactHandle().getId());
    }

    org.drools.core.util.LinkedList list = agendaItem.getLogicalDependencies();
    if (list != null && !list.isEmpty()) {
      for (LogicalDependency node = (LogicalDependency) list.getFirst();
          node != null;
          node = (LogicalDependency) node.getNext()) {
        _activation.addLogicalDependency(((InternalFactHandle) node.getJustified()).getId());
      }
    }
    return _activation.build();
  }