Search in sources :

Example 31 with NamedEntryPoint

use of org.drools.core.common.NamedEntryPoint in project drools by kiegroup.

the class TraitHelper method updateManyTraits.

private void updateManyTraits(Object object, BitMask mask, Collection<Thing> originators, Class<?> modifiedClass, Collection<Thing> traits, Activation activation) {
    for (Thing t : traits) {
        if (!originators.contains(t)) {
            InternalFactHandle h = (InternalFactHandle) lookupFactHandle(t);
            if (h != null) {
                NamedEntryPoint nep = (NamedEntryPoint) h.getEntryPoint();
                PropagationContext propagationContext = nep.getPctxFactory().createPropagationContext(nep.getInternalWorkingMemory().getNextPropagationIdCounter(), PropagationContext.Type.MODIFICATION, activation != null ? activation.getRule() : null, activation != null ? activation.getTuple().getTupleSink() : null, h, nep.getEntryPoint(), mask, modifiedClass, null);
                nep.update(h, t, t, nep.getObjectTypeConfigurationRegistry().getObjectTypeConf(nep.getEntryPoint(), t), propagationContext);
            }
        }
    }
}
Also used : PropagationContext(org.drools.core.spi.PropagationContext) NamedEntryPoint(org.drools.core.common.NamedEntryPoint) InternalFactHandle(org.drools.core.common.InternalFactHandle) Thing(org.drools.core.factmodel.traits.Thing)

Example 32 with NamedEntryPoint

use of org.drools.core.common.NamedEntryPoint in project drools by kiegroup.

the class BeliefSystemLogicalCallback method execute.

public void execute(InternalWorkingMemory workingMemory) {
    NamedEntryPoint nep = (NamedEntryPoint) handle.getEntryPoint();
    BeliefSet bs = handle.getEqualityKey().getBeliefSet();
    bs.setWorkingMemoryAction(null);
    if (update) {
        if (!bs.isEmpty()) {
            // We need the isEmpty check, in case the BeliefSet was made empty (due to retract) after this was scheduled
            ((NamedEntryPoint) handle.getEntryPoint()).update(handle, handle.getObject(), allSetButTraitBitMask(), Object.class, null);
        }
    } else {
        if (fullyRetract) {
            ((NamedEntryPoint) handle.getEntryPoint()).delete(this.handle, context.getRuleOrigin(), this.activation.getTuple().getTupleSink());
        } else {
            final ObjectTypeConf typeConf = nep.getObjectTypeConfigurationRegistry().getObjectTypeConf(nep.getEntryPoint(), handle.getObject());
            ((NamedEntryPoint) handle.getEntryPoint()).getEntryPointNode().retractObject(handle, context, typeConf, workingMemory);
        }
    }
}
Also used : ObjectTypeConf(org.drools.core.reteoo.ObjectTypeConf) NamedEntryPoint(org.drools.core.common.NamedEntryPoint) BeliefSet(org.drools.core.beliefsystem.BeliefSet)

Aggregations

NamedEntryPoint (org.drools.core.common.NamedEntryPoint)32 Test (org.junit.Test)21 KieSession (org.kie.api.runtime.KieSession)19 EqualityKey (org.drools.core.common.EqualityKey)17 TruthMaintenanceSystem (org.drools.core.common.TruthMaintenanceSystem)17 ObjectHashMap (org.drools.core.util.ObjectHashMap)16 InternalFactHandle (org.drools.core.common.InternalFactHandle)13 FactHandle (org.kie.api.runtime.rule.FactHandle)12 Iterator (org.drools.core.util.Iterator)10 FactType (org.kie.api.definition.type.FactType)10 ArrayList (java.util.ArrayList)9 Person (org.drools.compiler.Person)6 WorkingMemoryEntryPoint (org.drools.core.WorkingMemoryEntryPoint)5 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)5 Ignore (org.junit.Ignore)5 List (java.util.List)4 ObjectTypeConf (org.drools.core.reteoo.ObjectTypeConf)4 KieBase (org.kie.api.KieBase)4 Collection (java.util.Collection)3 StatefulKnowledgeSessionImpl (org.drools.core.impl.StatefulKnowledgeSessionImpl)3