Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[incubator-kie-issues#1497] Using the getSerializableNodeInstances inside ProtobufProcessInstanceWriter #3700

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,8 @@
*/
package org.jbpm.workflow.instance.node;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.stream.*;

import org.jbpm.process.core.ContextContainer;
import org.jbpm.process.core.context.variable.VariableScope;
Expand All @@ -48,7 +42,7 @@
import org.jbpm.workflow.instance.impl.NodeInstanceImpl;
import org.jbpm.workflow.instance.impl.NodeInstanceResolverFactory;
import org.kie.api.definition.process.Connection;
import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;
import org.kie.kogito.internal.process.runtime.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't user wildcards.

import org.mvel2.integration.VariableResolver;
import org.mvel2.integration.impl.SimpleValueResolver;

Expand All @@ -58,6 +52,8 @@
public class ForEachNodeInstance extends CompositeContextNodeInstance {

private static final long serialVersionUID = 510L;
private static final List<Class<? extends org.kie.api.runtime.process.NodeInstance>> NOT_SERIALIZABLE_CLASSES = Arrays.asList(ForEachJoinNodeInstance.class); // using Arrays.asList to allow multiple exclusions

public static final String TEMP_OUTPUT_VAR = "foreach_output";

private int totalInstances;
Expand Down Expand Up @@ -131,6 +127,11 @@ public ContextContainer getContextContainer() {
return getForEachNode().getCompositeNode();
}

@Override
public Collection<org.kie.api.runtime.process.NodeInstance> getSerializableNodeInstances() {
return getNodeInstances().stream().filter(this::isSerializable).collect(Collectors.toUnmodifiableList());
}

private boolean isSequential() {
return getForEachNode().isSequential() || hasAsyncInstances;
}
Expand Down Expand Up @@ -350,6 +351,10 @@ public int getLevelForNode(String uniqueID) {
return 1;
}

private boolean isSerializable(org.kie.api.runtime.process.NodeInstance toCheck) {
return !NOT_SERIALIZABLE_CLASSES.contains(toCheck.getClass());
}

private class ForEachNodeInstanceResolverFactory extends NodeInstanceResolverFactory {

private static final long serialVersionUID = -8856846610671009685L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public FieldDescriptor getContextField(GeneratedMessageV3.Builder<?> builder) {
}

private <T extends NodeInstanceContainer & ContextInstanceContainer & ContextableInstance> WorkflowContext buildWorkflowContext(T nodeInstance) {
List<NodeInstance> nodeInstances = new ArrayList<>(nodeInstance.getNodeInstances());
List<NodeInstance> nodeInstances = new ArrayList<>(nodeInstance.getSerializableNodeInstances());
List<ContextInstance> exclusiveGroupInstances = nodeInstance.getContextInstances(ExclusiveGroup.EXCLUSIVE_GROUP);
VariableScopeInstance variableScopeInstance = (VariableScopeInstance) nodeInstance.getContextInstance(VariableScope.VARIABLE_SCOPE);
List<Map.Entry<String, Object>> variables = (variableScopeInstance != null) ? new ArrayList<>(variableScopeInstance.getVariables().entrySet()) : Collections.emptyList();
Expand Down
Loading