use of org.drools.core.spi.ObjectType in project drools by kiegroup.
the class BetaNode method initDeclaredMask.
@Override
protected void initDeclaredMask(BuildContext context, LeftTupleSource leftInput) {
if (context == null || context.getLastBuiltPatterns() == null) {
// only happens during unit tests
rightDeclaredMask = AllSetBitMask.get();
super.initDeclaredMask(context, leftInput);
return;
}
// right input pattern
Pattern pattern = context.getLastBuiltPatterns()[0];
rightInputIsPassive = pattern.isPassive();
if (!isRightInputIsRiaNode()) {
ObjectType objectType = pattern.getObjectType();
if (objectType instanceof ClassObjectType) {
Class objectClass = ((ClassObjectType) objectType).getClassType();
if (isPropertyReactive(context, objectClass)) {
rightListenedProperties = pattern.getListenedProperties();
List<String> accessibleProperties = getAccessibleProperties(context.getKnowledgeBase(), objectClass);
rightDeclaredMask = calculatePositiveMask(objectClass, rightListenedProperties, accessibleProperties);
rightDeclaredMask = rightDeclaredMask.setAll(constraints.getListenedPropertyMask(objectClass, accessibleProperties));
rightNegativeMask = calculateNegativeMask(objectClass, rightListenedProperties, accessibleProperties);
} else {
// if property reactive is not on, then accept all modification propagations
rightDeclaredMask = AllSetBitMask.get();
}
} else {
// InitialFact has no type declaration and cannot be property specific
// Only ClassObjectType can use property specific
rightDeclaredMask = AllSetBitMask.get();
}
} else {
rightDeclaredMask = AllSetBitMask.get();
// There would have been no right input pattern, so swap current to first, so leftInput can still work
context.setLastBuiltPattern(context.getLastBuiltPatterns()[0]);
}
super.initDeclaredMask(context, leftInput);
}
use of org.drools.core.spi.ObjectType in project drools by kiegroup.
the class EntryPointNode method updateSink.
public void updateSink(final ObjectSink sink, final PropagationContext context, final InternalWorkingMemory workingMemory) {
// @todo
// JBRULES-612: the cache MUST be invalidated when a new node type is added to the network, so iterate and reset all caches.
final ObjectTypeNode node = (ObjectTypeNode) sink;
final ObjectType newObjectType = node.getObjectType();
WorkingMemoryEntryPoint wmEntryPoint = workingMemory.getWorkingMemoryEntryPoint(this.entryPoint.getEntryPointId());
for (ObjectTypeConf objectTypeConf : wmEntryPoint.getObjectTypeConfigurationRegistry().values()) {
if (objectTypeConf.getConcreteObjectTypeNode() != null && newObjectType.isAssignableFrom(objectTypeConf.getConcreteObjectTypeNode().getObjectType())) {
objectTypeConf.resetCache();
ObjectTypeNode sourceNode = objectTypeConf.getConcreteObjectTypeNode();
Iterator<InternalFactHandle> it = workingMemory.getNodeMemory(sourceNode).iterator();
while (it.hasNext()) {
sink.assertObject(it.next(), context, workingMemory);
}
}
}
}
use of org.drools.core.spi.ObjectType in project drools by kiegroup.
the class LeftInputAdapterNode method calculateSinkMask.
private BitMask calculateSinkMask(BuildContext context) {
Pattern pattern = context.getLastBuiltPatterns() != null ? context.getLastBuiltPatterns()[0] : null;
if (pattern == null) {
return AllSetBitMask.get();
}
ObjectType objectType = pattern.getObjectType();
if (!(objectType instanceof ClassObjectType)) {
// Only ClassObjectType can use property specific
return AllSetBitMask.get();
}
Class objectClass = ((ClassWireable) objectType).getClassType();
return isPropertyReactive(context, objectClass) ? calculatePositiveMask(objectClass, pattern.getListenedProperties(), getAccessibleProperties(context.getKnowledgeBase(), objectClass)) : AllSetBitMask.get();
}
Aggregations