use of org.drools.core.marshalling.impl.ProtobufMessages.ObjectTypeConfiguration in project drools by kiegroup.
the class ProtobufInputMarshaller method readTruthMaintenanceSystem.
public static void readTruthMaintenanceSystem(MarshallerReaderContext context, EntryPoint wmep, ProtobufMessages.EntryPoint _ep, List<PropagationContext> pctxs) throws IOException, ClassNotFoundException {
TruthMaintenanceSystem tms = ((NamedEntryPoint) wmep).getTruthMaintenanceSystem();
// if 0, then the OTC was not serialized (older versions of drools)
boolean wasOTCSerialized = _ep.getOtcCount() > 0;
Set<String> tmsEnabled = new HashSet<String>();
for (ObjectTypeConfiguration _otc : _ep.getOtcList()) {
if (_otc.getTmsEnabled()) {
tmsEnabled.add(_otc.getType());
}
}
ProtobufMessages.TruthMaintenanceSystem _tms = _ep.getTms();
for (ProtobufMessages.EqualityKey _key : _tms.getKeyList()) {
InternalFactHandle handle = (InternalFactHandle) context.handles.get(_key.getHandleId());
// ObjectTypeConf state is not marshalled, so it needs to be re-determined
ObjectTypeConf typeConf = context.wm.getObjectTypeConfigurationRegistry().getObjectTypeConf(((NamedEntryPoint) handle.getEntryPoint()).getEntryPoint(), handle.getObject());
if (!typeConf.isTMSEnabled() && (!wasOTCSerialized || tmsEnabled.contains(typeConf.getTypeName()))) {
typeConf.enableTMS();
}
EqualityKey key = new EqualityKey(handle, _key.getStatus());
handle.setEqualityKey(key);
if (key.getStatus() == EqualityKey.JUSTIFIED) {
// not yet added to the object stores
((NamedEntryPoint) handle.getEntryPoint()).getObjectStore().addHandle(handle, handle.getObject());
// add handle to object type node
assertHandleIntoOTN(context, context.wm, handle, pctxs);
}
for (Integer factHandleId : _key.getOtherHandleList()) {
handle = (InternalFactHandle) context.handles.get(factHandleId.intValue());
key.addFactHandle(handle);
handle.setEqualityKey(key);
}
tms.put(key);
context.filter.fireRNEAs(context.wm);
readBeliefSet(context, tms, key, _key);
}
}
use of org.drools.core.marshalling.impl.ProtobufMessages.ObjectTypeConfiguration in project drools by kiegroup.
the class ProtobufOutputMarshaller method writeObjectTypeConfiguration.
private static void writeObjectTypeConfiguration(MarshallerWriteContext context, ObjectTypeConfigurationRegistry otcr, org.drools.core.marshalling.impl.ProtobufMessages.EntryPoint.Builder _epb) {
Collection<ObjectTypeConf> values = otcr.values();
ObjectTypeConf[] otcs = values.toArray(new ObjectTypeConf[values.size()]);
Arrays.sort(otcs, new Comparator<ObjectTypeConf>() {
@Override
public int compare(ObjectTypeConf o1, ObjectTypeConf o2) {
return o1.getTypeName().compareTo(o2.getTypeName());
}
});
for (ObjectTypeConf otc : otcs) {
ObjectTypeNode objectTypeNode = otc.getConcreteObjectTypeNode();
if (objectTypeNode != null) {
final ObjectTypeNodeMemory memory = context.wm.getNodeMemory(objectTypeNode);
if (memory != null) {
ObjectTypeConfiguration _otc = ObjectTypeConfiguration.newBuilder().setType(otc.getTypeName()).setTmsEnabled(otc.isTMSEnabled()).build();
_epb.addOtc(_otc);
}
}
}
}
Aggregations