use of org.drools.tms.TruthMaintenanceSystemEqualityKey in project drools by kiegroup.
the class ProtobufInputMarshaller method readBeliefSet.
private static void readBeliefSet(MarshallerReaderContext context, TruthMaintenanceSystem tms, ProtobufMessages.EqualityKey _key) throws IOException, ClassNotFoundException {
if (_key.hasBeliefSet()) {
ProtobufMessages.BeliefSet _beliefSet = _key.getBeliefSet();
InternalFactHandle handle = (InternalFactHandle) context.getHandles().get(_key.getHandleId());
// phreak might serialize empty belief sets, so he have to handle it during deserialization
if (_beliefSet.getLogicalDependencyCount() > 0) {
for (ProtobufMessages.LogicalDependency _logicalDependency : _beliefSet.getLogicalDependencyList()) {
ProtobufMessages.Activation _activation = _logicalDependency.getActivation();
ActivationKey activationKey = getActivationKey(context, _activation);
Activation activation = (Activation) ((PBActivationsFilter) context.getFilter()).getTuplesCache().get(activationKey);
Object object = null;
ObjectMarshallingStrategy strategy = null;
if (_logicalDependency.hasObjectStrategyIndex()) {
strategy = context.getUsedStrategies().get(_logicalDependency.getObjectStrategyIndex());
object = strategy.unmarshal(context.getStrategyContexts().get(strategy), (ObjectInputStream) context, _logicalDependency.getObject().toByteArray(), (context.getKnowledgeBase() == null) ? null : context.getKnowledgeBase().getRootClassLoader());
}
Object value = null;
if (_logicalDependency.hasValueStrategyIndex()) {
strategy = context.getUsedStrategies().get(_logicalDependency.getValueStrategyIndex());
value = strategy.unmarshal(context.getStrategyContexts().get(strategy), (ObjectInputStream) context, _logicalDependency.getValue().toByteArray(), (context.getKnowledgeBase() == null) ? null : context.getKnowledgeBase().getRootClassLoader());
}
ObjectTypeConf typeConf = context.getWorkingMemory().getObjectTypeConfigurationRegistry().getOrCreateObjectTypeConf(handle.getEntryPointId(), handle.getObject());
tms.readLogicalDependency(handle, object, value, activation, typeConf);
}
} else {
((TruthMaintenanceSystemEqualityKey) handle.getEqualityKey()).setBeliefSet(((TruthMaintenanceSystemImpl) tms).getBeliefSystem().newBeliefSet(handle));
}
}
}
Aggregations