use of org.drools.tms.LogicalDependency in project drools by kiegroup.
the class JTMSBeliefSetImpl method cancel.
public void cancel(PropagationContext context) {
// get all but last, as that we'll do via the BeliefSystem, for cleanup
// note we don't update negative, conflict counters. It's needed for the last cleanup operation
JTMSMode<M> entry = getFirst();
while (entry != getLast()) {
// get next, as we are about to remove it
JTMSMode<M> temp = entry.getNext();
final LogicalDependency<M> node = entry.getLogicalDependency();
node.getJustifier().getLogicalDependencies().remove(node);
remove((M) entry);
entry = temp;
}
JTMSMode<M> last = getFirst();
final LogicalDependency node = last.getLogicalDependency();
node.getJustifier().getLogicalDependencies().remove(node);
beliefSystem.delete(node, this, context);
}
use of org.drools.tms.LogicalDependency in project drools by kiegroup.
the class SimpleBeliefSet method cancel.
public void cancel(PropagationContext context) {
// get all but last, as that we'll do via the BeliefSystem, for cleanup
SimpleMode entry = getFirst();
while (entry != getLast()) {
// get next, as we are about to remove it
SimpleMode temp = entry.getNext();
final LogicalDependency<SimpleMode> node = entry.getObject();
node.getJustifier().getLogicalDependencies().remove(node);
remove(entry);
entry = temp;
}
LinkedListEntry last = getFirst();
final LogicalDependency<SimpleMode> node = (LogicalDependency) last.getObject();
node.getJustifier().getLogicalDependencies().remove(node);
beliefSystem.delete(node, this, context);
}
use of org.drools.tms.LogicalDependency in project drools by kiegroup.
the class ProtobufOutputMarshaller method writeBeliefSet.
private static void writeBeliefSet(MarshallerWriteContext context, BeliefSet beliefSet, ProtobufMessages.EqualityKey.Builder _key) throws IOException {
ProtobufMessages.BeliefSet.Builder _beliefSet = ProtobufMessages.BeliefSet.newBuilder();
_beliefSet.setHandleId(beliefSet.getFactHandle().getId());
ObjectMarshallingStrategyStore objectMarshallingStrategyStore = context.getObjectMarshallingStrategyStore();
// for ( LinkedListEntry node = (LinkedListEntry) beliefSet.getFirst(); node != null; node = (LinkedListEntry) node.getNext() ) {
FastIterator it = beliefSet.iterator();
for (LinkedListEntry node = (LinkedListEntry) beliefSet.getFirst(); node != null; node = (LinkedListEntry) it.next(node)) {
LogicalDependency belief = (LogicalDependency) node.getObject();
ProtobufMessages.LogicalDependency.Builder _logicalDependency = ProtobufMessages.LogicalDependency.newBuilder();
// _belief.setActivation( value )
LogicalDependency dependency = (LogicalDependency) node.getObject();
org.drools.core.spi.Activation activation = dependency.getJustifier();
ProtobufMessages.Activation _activation = ProtobufMessages.Activation.newBuilder().setPackageName(activation.getRule().getPackage()).setRuleName(activation.getRule().getName()).setTuple(writeTuple(context, activation, true)).build();
_logicalDependency.setActivation(_activation);
if (belief.getObject() != null) {
ObjectMarshallingStrategy strategy = objectMarshallingStrategyStore.getStrategyObject(belief.getObject());
Integer index = context.getStrategyIndex(strategy);
_logicalDependency.setObjectStrategyIndex(index);
_logicalDependency.setObject(ByteString.copyFrom(strategy.marshal(context.getStrategyContext().get(strategy), (ObjectOutputStream) context, belief.getObject())));
}
if (belief.getMode() != null) {
ObjectMarshallingStrategy strategy = objectMarshallingStrategyStore.getStrategyObject(belief.getMode());
Integer index = context.getStrategyIndex(strategy);
_logicalDependency.setValueStrategyIndex(index);
_logicalDependency.setValue(ByteString.copyFrom(strategy.marshal(context.getStrategyContext().get(strategy), (ObjectOutputStream) context, belief.getMode())));
}
_beliefSet.addLogicalDependency(_logicalDependency.build());
}
_key.setBeliefSet(_beliefSet);
}
use of org.drools.tms.LogicalDependency in project drools by kiegroup.
the class TruthMaintenanceSystemRuleTerminalNodeLeftTuple method removeAllBlockersAndBlocked.
@Override
public void removeAllBlockersAndBlocked(ActivationsManager activationsManager) {
if (this.blockers != null) {
// Iterate and remove this node's logical dependency list from each of it's blockers
for (SimpleMode node = blockers.getFirst(); node != null; node = node.getNext()) {
LogicalDependency dep = node.getObject();
dep.getJustifier().getBlocked().remove(dep);
}
}
this.blockers = null;
if (this.blocked != null) {
// Iterate and remove this node's logical dependency list from each of it's blocked
for (LogicalDependency<SimpleMode> dep = blocked.getFirst(); dep != null; ) {
LogicalDependency<SimpleMode> tmp = dep.getNext();
removeBlocked(dep);
TruthMaintenanceSystemRuleTerminalNodeLeftTuple justified = (TruthMaintenanceSystemRuleTerminalNodeLeftTuple) dep.getJustified();
if (justified.getBlockers().isEmpty() && justified.isActive()) {
activationsManager.stageLeftTuple(ruleAgendaItem, justified);
}
dep = tmp;
}
}
this.blocked = null;
}
use of org.drools.tms.LogicalDependency in project drools by kiegroup.
the class TruthMaintenanceSystemAgendaItemImpl method removeAllBlockersAndBlocked.
@Override
public void removeAllBlockersAndBlocked(ActivationsManager activationsManager) {
if (this.blockers != null) {
// Iterate and remove this node's logical dependency list from each of it's blockers
for (LinkedListEntry<SimpleMode, LogicalDependency<SimpleMode>> node = blockers.getFirst(); node != null; node = node.getNext()) {
LogicalDependency dep = node.getObject();
dep.getJustifier().getBlocked().remove(dep);
}
}
this.blockers = null;
if (this.blocked != null) {
// Iterate and remove this node's logical dependency list from each of it's blocked
for (LogicalDependency<SimpleMode> dep = blocked.getFirst(); dep != null; ) {
LogicalDependency<SimpleMode> tmp = dep.getNext();
removeBlocked(dep);
TruthMaintenanceSystemAgendaItemImpl justified = (TruthMaintenanceSystemAgendaItemImpl) dep.getJustified();
if (justified.getBlockers().isEmpty()) {
activationsManager.stageLeftTuple(null, justified);
}
dep = tmp;
}
}
this.blocked = null;
}
Aggregations