use of org.drools.core.factmodel.traits.TraitFieldTMS in project drools by kiegroup.
the class MapCore method _getFieldTMS.
public TraitFieldTMS _getFieldTMS() {
TraitFieldTMS tms = (TraitFieldTMS) _getDynamicProperties().get(FIELDTMS_FIELD_NAME);
if (tms == null) {
tms = new TraitFieldTMSImpl();
_getDynamicProperties().put(FIELDTMS_FIELD_NAME, tms);
}
return tms;
}
use of org.drools.core.factmodel.traits.TraitFieldTMS 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.factmodel.traits.TraitFieldTMS in project drools by kiegroup.
the class TraitableMap method _getFieldTMS.
default TraitFieldTMS _getFieldTMS() {
TraitFieldTMS tms = (TraitFieldTMS) _getDynamicProperties().get(FIELDTMS_FIELD_NAME);
if (tms == null) {
tms = new TraitFieldTMSImpl();
_getDynamicProperties().put(FIELDTMS_FIELD_NAME, tms);
}
return tms;
}
use of org.drools.core.factmodel.traits.TraitFieldTMS 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;
}
Aggregations