use of org.drools.core.spi.PropagationContext in project drools by kiegroup.
the class NamedEntryPoint method deleteStated.
private void deleteStated(RuleImpl rule, TerminalNode terminalNode, InternalFactHandle handle, EqualityKey key) {
if (key != null && key.getStatus() == EqualityKey.JUSTIFIED) {
return;
}
if (handle.isTraitable()) {
traitHelper.deleteWMAssertedTraitProxies(handle, rule, terminalNode);
}
final Object object = handle.getObject();
final ObjectTypeConf typeConf = getObjectTypeConfigurationRegistry().getObjectTypeConf(this.entryPoint, object);
if (typeConf.isDynamic()) {
removePropertyChangeListener(handle, true);
}
PropagationContext propagationContext = delete(handle, object, typeConf, rule, null, terminalNode);
deleteFromTMS(handle, key, typeConf, propagationContext);
this.handleFactory.destroyFactHandle(handle);
}
use of org.drools.core.spi.PropagationContext in project drools by kiegroup.
the class NamedEntryPoint method insertAsync.
public FactHandle insertAsync(Object object) {
ObjectTypeConf typeConf = getObjectTypeConfigurationRegistry().getObjectTypeConf(this.entryPoint, object);
PropagationContext pctx = this.pctxFactory.createPropagationContext(this.wm.getNextPropagationIdCounter(), PropagationContext.Type.INSERTION, null, null, null, entryPoint);
InternalFactHandle handle = createHandle(object, typeConf);
pctx.setFactHandle(handle);
this.entryPointNode.assertObject(handle, pctx, typeConf, this.wm);
this.wm.getRuleRuntimeEventSupport().fireObjectInserted(pctx, handle, object, this.wm);
return handle;
}
use of org.drools.core.spi.PropagationContext in project drools by kiegroup.
the class NamedEntryPoint method delete.
public PropagationContext delete(InternalFactHandle handle, Object object, ObjectTypeConf typeConf, RuleImpl rule, Activation activation, TerminalNode terminalNode) {
final PropagationContext propagationContext = pctxFactory.createPropagationContext(this.wm.getNextPropagationIdCounter(), PropagationContext.Type.DELETION, rule, terminalNode, handle, this.entryPoint);
this.entryPointNode.retractObject(handle, propagationContext, typeConf, this.wm);
if (handle.isTraiting() && handle.getObject() instanceof TraitProxy) {
(((TraitProxy) handle.getObject()).getObject()).removeTrait(((TraitProxy) handle.getObject())._getTypeCode());
} else if (handle.isTraitable()) {
traitHelper.deleteWMAssertedTraitProxies(handle, rule, terminalNode);
}
this.objectStore.removeHandle(handle);
this.wm.getRuleRuntimeEventSupport().fireObjectRetracted(propagationContext, handle, object, this.wm);
return propagationContext;
}
use of org.drools.core.spi.PropagationContext in project drools by kiegroup.
the class TraitHelper method updateCore.
private <T> void updateCore(TraitableBean inner, Object core, Class<T> trait, boolean logical, Activation activation) {
FactHandle handle = lookupFactHandle(inner);
InternalFactHandle h = (InternalFactHandle) handle;
if (handle != null) {
TraitFieldTMS fieldTMS = inner._getFieldTMS();
BitMask mask = fieldTMS == null ? onlyTraitBitSetMask() : fieldTMS.getModificationMask();
Object o = h.getObject();
NamedEntryPoint nep = (NamedEntryPoint) h.getEntryPoint();
PropagationContext propagationContext = nep.getPctxFactory().createPropagationContext(nep.getInternalWorkingMemory().getNextPropagationIdCounter(), PropagationContext.Type.MODIFICATION, activation.getRule(), activation.getTuple().getTupleSink(), h, nep.getEntryPoint(), mask, core.getClass(), null);
nep.update(h, o, o, nep.getObjectTypeConfigurationRegistry().getObjectTypeConf(nep.getEntryPoint(), o), propagationContext);
} else {
handle = this.workingMemory.insert(inner, false, activation.getRule(), activation.getTuple().getTupleSink());
}
}
use of org.drools.core.spi.PropagationContext in project drools by kiegroup.
the class JTMSBeliefSystem method processBeliefSet.
private boolean processBeliefSet(RuleImpl rule, Activation activation, Object payload, PropagationContext pctx, JTMSBeliefSet<M> jtmsBeliefSet, boolean wasDecided, boolean wasNegated, InternalFactHandle fh) {
if (!wasDecided && jtmsBeliefSet.isDecided()) {
ep.insert(jtmsBeliefSet.getFactHandle(), payload, rule, activation != null ? activation.getTuple().getTupleSink() : null, getObjectTypeConf(jtmsBeliefSet));
return true;
} else if (wasDecided && !jtmsBeliefSet.isDecided()) {
// Handle Conflict
if (STRICT) {
throw new IllegalStateException("FATAL : A fact and its negation have been asserted " + jtmsBeliefSet.getFactHandle().getObject());
}
// was decided, now is not, so must be removed from the network. Leave in EP though, we only delete from that when the set is empty
ep.delete(fh, fh.getObject(), getObjectTypeConf(jtmsBeliefSet), pctx.getRuleOrigin(), null, activation != null ? activation.getTuple().getTupleSink() : null);
return true;
} else if (wasNegated != jtmsBeliefSet.isNegated()) {
// was decided, still is decided by the negation changed. This must be propagated through the engine
// This does not happen for pure JTMS, but does for DFL.
final PropagationContext updatePctx = ep.getPctxFactory().createPropagationContext(ep.getInternalWorkingMemory().getNextPropagationIdCounter(), PropagationContext.Type.MODIFICATION, pctx.getRuleOrigin(), pctx.getTerminalNodeOrigin(), fh, ep.getEntryPoint());
ep.update(fh, fh.getObject(), fh.getObject(), getObjectTypeConf(jtmsBeliefSet), updatePctx);
}
return false;
}
Aggregations