Skip to content

Commit

Permalink
[incubator-kie-issues#1497] Overriding getSerializableNodeInstances i…
Browse files Browse the repository at this point in the history
…nside CompositeNodeInstance
  • Loading branch information
Gabriele-Cardosi committed Oct 8, 2024
1 parent 7685790 commit f710fe4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.UUID;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.jbpm.workflow.core.Node;
import org.jbpm.workflow.core.node.CompositeNode;
Expand Down Expand Up @@ -204,7 +205,12 @@ public void removeNodeInstance(final NodeInstance nodeInstance) {

@Override
public Collection<org.kie.api.runtime.process.NodeInstance> getNodeInstances() {
return new ArrayList<>(getNodeInstances(false));
return Collections.unmodifiableCollection(nodeInstances);
}

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

@Override
Expand Down Expand Up @@ -473,4 +479,15 @@ public Map<String, Integer> getIterationLevels() {
return iterationLevels;
}

/**
* Check if the given <code>org.kie.api.runtime.process.NodeInstance</code> is serializable.
* Every subclass should override it, if needed, to avoid polluting the parent one (this) with children details
*
* @param toCheck
* @return
*/
protected boolean isSerializable(org.kie.api.runtime.process.NodeInstance toCheck) {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@
*/
package org.jbpm.workflow.instance.node;

import java.util.*;
import java.util.stream.*;
import java.util.ArrayList;
import java.util.Arrays;
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 org.jbpm.process.core.ContextContainer;
import org.jbpm.process.core.context.variable.VariableScope;
Expand All @@ -42,7 +49,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.*;
import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;
import org.mvel2.integration.VariableResolver;
import org.mvel2.integration.impl.SimpleValueResolver;

Expand Down Expand Up @@ -127,11 +134,6 @@ 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 @@ -351,7 +353,8 @@ public int getLevelForNode(String uniqueID) {
return 1;
}

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

Expand Down

0 comments on commit f710fe4

Please sign in to comment.