use of org.drools.core.reteoo.ObjectTypeConf in project drools by kiegroup.
the class TraitHelper method makeTraitable.
private <K> TraitableBean makeTraitable(K core, TraitFactory builder, boolean logical, Activation activation) {
boolean needsWrapping = !(core instanceof TraitableBean);
ClassDefinition coreDef = lookupClassDefinition(core);
TraitableBean<K, ? extends TraitableBean> inner = needsWrapping ? builder.asTraitable(core, coreDef) : (TraitableBean<K, ? extends TraitableBean>) core;
if (needsWrapping) {
InternalFactHandle h = (InternalFactHandle) lookupFactHandle(core);
WorkingMemoryEntryPoint ep = h != null ? h.getEntryPoint() : ((StatefulKnowledgeSessionImpl) workingMemory).getEntryPoint("DEFAULT");
ObjectTypeConfigurationRegistry reg = ep.getObjectTypeConfigurationRegistry();
ObjectTypeConf coreConf = reg.getObjectTypeConf(ep.getEntryPoint(), core);
ObjectTypeConf innerConf = reg.getObjectTypeConf(ep.getEntryPoint(), inner);
if (coreConf.isTMSEnabled()) {
innerConf.enableTMS();
}
if (inner._getFieldTMS() != null && inner._getFieldTMS().needsInit()) {
inner._getFieldTMS().init(workingMemory);
}
} else {
TraitFieldTMS ftms = inner._getFieldTMS();
if (ftms != null) {
FactHandle handle = lookupFactHandle(inner);
if (handle == null) {
handle = this.workingMemory.insert(inner, false, activation.getRule(), activation.getTuple().getTupleSink());
}
if (ftms.needsInit()) {
ftms.init(workingMemory);
}
}
}
return inner;
}
use of org.drools.core.reteoo.ObjectTypeConf in project drools by kiegroup.
the class JTMSBeliefSystem method getObjectTypeConf.
private ObjectTypeConf getObjectTypeConf(BeliefSet<M> jtmsBeliefSet) {
InternalFactHandle fh = jtmsBeliefSet.getFactHandle();
ObjectTypeConfigurationRegistry reg;
ObjectTypeConf typeConf;
reg = ep.getObjectTypeConfigurationRegistry();
typeConf = reg.getObjectTypeConf(ep.getEntryPoint(), fh.getObject());
return typeConf;
}
use of org.drools.core.reteoo.ObjectTypeConf 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);
}
}
}
Aggregations