Search in sources :

Example 1 with ObjectMarshallingStrategyStore

use of org.kie.api.marshalling.ObjectMarshallingStrategyStore in project drools by kiegroup.

the class ProtobufOutputMarshaller method writeBeliefSet.

private static void writeBeliefSet(MarshallerWriteContext context, BeliefSet beliefSet, org.drools.core.marshalling.impl.ProtobufMessages.EqualityKey.Builder _key) throws IOException {
    ProtobufMessages.BeliefSet.Builder _beliefSet = ProtobufMessages.BeliefSet.newBuilder();
    _beliefSet.setHandleId(beliefSet.getFactHandle().getId());
    ObjectMarshallingStrategyStore objectMarshallingStrategyStore = context.objectMarshallingStrategyStore;
    // for ( LinkedListEntry node = (LinkedListEntry) beliefSet.getFirst(); node != null; node = (LinkedListEntry) node.getNext() ) {
    FastIterator it = beliefSet.iterator();
    for (LinkedListEntry node = (LinkedListEntry) beliefSet.getFirst(); node != null; node = (LinkedListEntry) it.next(node)) {
        LogicalDependency belief = (LogicalDependency) node.getObject();
        ProtobufMessages.LogicalDependency.Builder _logicalDependency = ProtobufMessages.LogicalDependency.newBuilder();
        // _belief.setActivation( value )
        LogicalDependency dependency = (LogicalDependency) node.getObject();
        org.drools.core.spi.Activation activation = dependency.getJustifier();
        ProtobufMessages.Activation _activation = ProtobufMessages.Activation.newBuilder().setPackageName(activation.getRule().getPackage()).setRuleName(activation.getRule().getName()).setTuple(PersisterHelper.createTuple(activation.getTuple())).build();
        _logicalDependency.setActivation(_activation);
        if (belief.getObject() != null) {
            ObjectMarshallingStrategy strategy = objectMarshallingStrategyStore.getStrategyObject(belief.getObject());
            Integer index = context.getStrategyIndex(strategy);
            _logicalDependency.setObjectStrategyIndex(index);
            _logicalDependency.setObject(ByteString.copyFrom(strategy.marshal(context.strategyContext.get(strategy), context, belief.getObject())));
        }
        if (belief.getMode() != null) {
            ObjectMarshallingStrategy strategy = objectMarshallingStrategyStore.getStrategyObject(belief.getMode());
            Integer index = context.getStrategyIndex(strategy);
            _logicalDependency.setValueStrategyIndex(index);
            _logicalDependency.setValue(ByteString.copyFrom(strategy.marshal(context.strategyContext.get(strategy), context, belief.getMode())));
        }
        _beliefSet.addLogicalDependency(_logicalDependency.build());
    }
    _key.setBeliefSet(_beliefSet);
}
Also used : ObjectMarshallingStrategyStore(org.kie.api.marshalling.ObjectMarshallingStrategyStore) LinkedListEntry(org.drools.core.util.LinkedListEntry) ObjectMarshallingStrategy(org.kie.api.marshalling.ObjectMarshallingStrategy) Activation(org.drools.core.spi.Activation) BeliefSet(org.drools.core.beliefsystem.BeliefSet) LogicalDependency(org.drools.core.common.LogicalDependency) FastIterator(org.drools.core.util.FastIterator)

Example 2 with ObjectMarshallingStrategyStore

use of org.kie.api.marshalling.ObjectMarshallingStrategyStore in project drools by kiegroup.

the class ProtobufOutputMarshaller method writeFactHandles.

private static void writeFactHandles(MarshallerWriteContext context, org.drools.core.marshalling.impl.ProtobufMessages.EntryPoint.Builder _epb, ObjectStore objectStore) throws IOException {
    ObjectMarshallingStrategyStore objectMarshallingStrategyStore = context.objectMarshallingStrategyStore;
    // Write out FactHandles
    for (InternalFactHandle handle : orderFacts(objectStore)) {
        ProtobufMessages.FactHandle _handle = writeFactHandle(context, objectMarshallingStrategyStore, handle);
        _epb.addHandle(_handle);
    }
}
Also used : ObjectMarshallingStrategyStore(org.kie.api.marshalling.ObjectMarshallingStrategyStore) FactHandle(org.drools.core.marshalling.impl.ProtobufMessages.FactHandle) InternalFactHandle(org.drools.core.common.InternalFactHandle)

Aggregations

ObjectMarshallingStrategyStore (org.kie.api.marshalling.ObjectMarshallingStrategyStore)2 BeliefSet (org.drools.core.beliefsystem.BeliefSet)1 InternalFactHandle (org.drools.core.common.InternalFactHandle)1 LogicalDependency (org.drools.core.common.LogicalDependency)1 FactHandle (org.drools.core.marshalling.impl.ProtobufMessages.FactHandle)1 Activation (org.drools.core.spi.Activation)1 FastIterator (org.drools.core.util.FastIterator)1 LinkedListEntry (org.drools.core.util.LinkedListEntry)1 ObjectMarshallingStrategy (org.kie.api.marshalling.ObjectMarshallingStrategy)1