Skip to content

Commit

Permalink
Revert "[Fix apache#3406] Avoid publishing internal variables (apache…
Browse files Browse the repository at this point in the history
…#3407)"

This reverts commit 98fd3b9.
  • Loading branch information
fjtirado committed Feb 20, 2024
1 parent 98fd3b9 commit e2ddc47
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 58 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import org.kie.kogito.internal.process.runtime.KogitoWorkItem;
import org.kie.kogito.internal.process.runtime.KogitoWorkItemNodeInstance;
import org.kie.kogito.internal.process.runtime.KogitoWorkflowProcessInstance;
import org.kie.kogito.internal.utils.KogitoTags;
import org.kie.kogito.process.workitem.HumanTaskWorkItem;

public class ProcessInstanceEventBatch implements EventBatch {
Expand Down Expand Up @@ -121,9 +120,7 @@ private void addDataEvent(ProcessEvent event) {
}

private void handleProcessVariableEvent(ProcessVariableChangedEvent event) {
if (event.getTags().contains(KogitoTags.INTERNAL_TAG)) {
return;
}

Map<String, Object> metadata = buildProcessMetadata((KogitoWorkflowProcessInstance) event.getProcessInstance());
KogitoWorkflowProcessInstance pi = (KogitoWorkflowProcessInstance) event.getProcessInstance();
ProcessInstanceVariableEventBody.Builder builder = ProcessInstanceVariableEventBody.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@

import org.jbpm.process.core.context.variable.Variable;
import org.kie.kogito.Model;
import org.kie.kogito.internal.utils.KogitoTags;

public class BpmnVariables implements Model {

public static final Predicate<Variable> OUTPUTS_ONLY = v -> v.hasTag(KogitoTags.OUTPUT_TAG);
public static final Predicate<Variable> INPUTS_ONLY = v -> v.hasTag(KogitoTags.INPUT_TAG);
public static final Predicate<Variable> INTERNAL_ONLY = v -> v.hasTag(KogitoTags.INTERNAL_TAG);
public static final Predicate<Variable> OUTPUTS_ONLY = v -> v.hasTag(Variable.OUTPUT_TAG);
public static final Predicate<Variable> INPUTS_ONLY = v -> v.hasTag(Variable.INPUT_TAG);
public static final Predicate<Variable> INTERNAL_ONLY = v -> v.hasTag(Variable.INTERNAL_TAG);

private final Map<String, Object> variables = new HashMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.jbpm.process.core.datatype.DataTypeResolver;
import org.kie.api.definition.process.NodeContainer;
import org.kie.kogito.internal.process.runtime.KogitoNode;
import org.kie.kogito.internal.utils.KogitoTags;

import com.github.javaparser.ast.expr.ClassExpr;
import com.github.javaparser.ast.expr.Expression;
Expand Down Expand Up @@ -88,12 +87,12 @@ protected void visitVariableScope(String field, VariableScope variableScope, Blo
if (!visitedVariables.add(variable.getName())) {
continue;
}
String tags = (String) variable.getMetaData(KogitoTags.VARIABLE_TAGS);
String tags = (String) variable.getMetaData(Variable.VARIABLE_TAGS);
Object defaultValue = variable.getValue();
body.tryAddImportToParentCompilationUnit(variable.getType().getClass());
body.addStatement(getFactoryMethod(field, METHOD_VARIABLE, new StringLiteralExpr(variable.getName()),
new MethodCallExpr(DataTypeResolver.class.getName() + ".fromClass", new ClassExpr(parseClassOrInterfaceType(variable.getType().getStringType()).removeTypeArguments())),
defaultValue != null ? new StringLiteralExpr(defaultValue.toString()) : new NullLiteralExpr(), new StringLiteralExpr(KogitoTags.VARIABLE_TAGS),
defaultValue != null ? new StringLiteralExpr(defaultValue.toString()) : new NullLiteralExpr(), new StringLiteralExpr(Variable.VARIABLE_TAGS),
tags != null ? new StringLiteralExpr(tags) : new NullLiteralExpr()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.kie.kogito.codegen.Generated;
import org.kie.kogito.codegen.VariableInfo;
import org.kie.kogito.internal.process.runtime.KogitoWorkflowProcess;
import org.kie.kogito.internal.utils.KogitoTags;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.github.javaparser.ast.CompilationUnit;
Expand Down Expand Up @@ -238,7 +237,7 @@ private void applyValidation(FieldDeclaration fd, List<String> tags) {
if (supportsValidation) {
fd.addAnnotation("jakarta.validation.Valid");

if (tags != null && tags.contains(KogitoTags.REQUIRED_TAG)) {
if (tags != null && tags.contains(Variable.REQUIRED_TAG)) {
fd.addAnnotation("jakarta.validation.constraints.NotNull");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
import org.jbpm.process.core.context.variable.Variable;
import org.jbpm.process.core.context.variable.VariableScope;
import org.jbpm.process.core.datatype.DataTypeResolver;
import org.kie.kogito.internal.utils.KogitoTags;

public class VariableDeclarations {

public static VariableDeclarations of(VariableScope vscope) {
HashMap<String, Variable> vs = new HashMap<>();
for (Variable variable : vscope.getVariables()) {
if (variable.hasTag(KogitoTags.INTERNAL_TAG)) {
if (variable.hasTag(Variable.INTERNAL_TAG)) {
continue;
}

Expand All @@ -45,12 +44,12 @@ public static VariableDeclarations of(VariableScope vscope) {

public static VariableDeclarations ofInput(VariableScope vscope) {

return of(vscope, variable -> variable.hasTag(KogitoTags.INTERNAL_TAG) || variable.hasTag(KogitoTags.OUTPUT_TAG));
return of(vscope, variable -> variable.hasTag(Variable.INTERNAL_TAG) || variable.hasTag(Variable.OUTPUT_TAG));
}

public static VariableDeclarations ofOutput(VariableScope vscope) {

return of(vscope, variable -> variable.hasTag(KogitoTags.INTERNAL_TAG) || variable.hasTag(KogitoTags.INPUT_TAG));
return of(vscope, variable -> variable.hasTag(Variable.INTERNAL_TAG) || variable.hasTag(Variable.INPUT_TAG));
}

public static VariableDeclarations of(VariableScope vscope, Predicate<Variable> filterOut) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.jbpm.process.core.datatype.DataType;
import org.jbpm.process.core.datatype.impl.coverter.CloneHelper;
import org.jbpm.process.core.datatype.impl.type.UndefinedDataType;
import org.kie.kogito.internal.utils.KogitoTags;

/**
* Default implementation of a variable.
Expand All @@ -45,6 +44,13 @@ public class Variable implements TypeObject, ValueObject, Serializable {

private static final long serialVersionUID = 510l;

public static final String VARIABLE_TAGS = "customTags";

public static final String READONLY_TAG = "readonly";
public static final String REQUIRED_TAG = "required";
public static final String INTERNAL_TAG = "internal";
public static final String INPUT_TAG = "input";
public static final String OUTPUT_TAG = "output";
public static final String BUSINESS_RELEVANT = "business-relevant";
public static final String TRACKED = "tracked";
public static final Set<String> KOGITO_RESERVED = Set.of("id");
Expand Down Expand Up @@ -140,7 +146,7 @@ public void setValue(final Object value) {
public void setMetaData(String name, Object value) {
this.metaData.put(name, value);

if (KogitoTags.VARIABLE_TAGS.equals(name) && value != null) {
if (VARIABLE_TAGS.equals(name) && value != null) {
tags = Arrays.asList(value.toString().split(","));
}
}
Expand All @@ -159,8 +165,8 @@ public String toString() {
}

public List<String> getTags() {
if (tags.isEmpty() && this.metaData.containsKey(KogitoTags.VARIABLE_TAGS)) {
tags = Arrays.asList(metaData.get(KogitoTags.VARIABLE_TAGS).toString().split(","));
if (tags.isEmpty() && this.metaData.containsKey(VARIABLE_TAGS)) {
tags = Arrays.asList(metaData.get(VARIABLE_TAGS).toString().split(","));

}
return tags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import org.jbpm.process.core.Context;
import org.jbpm.process.core.context.AbstractContext;
import org.kie.kogito.internal.utils.KogitoTags;

public class VariableScope extends AbstractContext {

Expand Down Expand Up @@ -111,7 +110,7 @@ public boolean isReadOnly(String name) {
Variable v = findVariable(name);

if (v != null) {
return v.hasTag(KogitoTags.READONLY_TAG);
return v.hasTag(Variable.READONLY_TAG);
}
return false;
}
Expand All @@ -120,7 +119,7 @@ public boolean isRequired(String name) {
Variable v = findVariable(name);

if (v != null) {
return v.hasTag(KogitoTags.REQUIRED_TAG);
return v.hasTag(Variable.REQUIRED_TAG);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.jbpm.workflow.core.impl.DataDefinition;
import org.jbpm.workflow.core.node.CompositeContextNode;
import org.jbpm.workflow.core.node.ForEachNode;
import org.kie.kogito.internal.utils.KogitoTags;

public class ForEachNodeFactory<T extends RuleFlowNodeContainerFactory<T, ?>> extends AbstractCompositeNodeFactory<ForEachNodeFactory<T>, T> {

Expand Down Expand Up @@ -100,7 +99,7 @@ public ForEachNodeFactory<T> tempVariable(String varRef, String variableName, Da
private ForEachNodeFactory<T> addVariable(String varRef, String variableName, DataType dataType, boolean eval) {
Variable variable = getForEachNode().addContextVariable(varRef, variableName, dataType);
variable.setMetaData(Metadata.EVAL_VARIABLE, eval);
variable.setMetaData(KogitoTags.VARIABLE_TAGS, KogitoTags.INTERNAL_TAG);
variable.setMetaData(Variable.VARIABLE_TAGS, Variable.INTERNAL_TAG);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import org.jbpm.compiler.canonical.descriptors.ExpressionReturnValueSupplier;
import org.jbpm.process.core.context.exception.CompensationScope;
import org.jbpm.process.core.context.variable.Variable;
import org.jbpm.process.core.datatype.impl.type.ObjectDataType;
import org.jbpm.ruleflow.core.Metadata;
import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory;
Expand All @@ -43,7 +44,6 @@
import org.jbpm.ruleflow.core.factory.TimerNodeFactory;
import org.jbpm.workflow.core.node.Join;
import org.jbpm.workflow.core.node.Split;
import org.kie.kogito.internal.utils.KogitoTags;
import org.kie.kogito.serverless.workflow.SWFConstants;
import org.kie.kogito.serverless.workflow.parser.ParserContext;
import org.kie.kogito.serverless.workflow.parser.ServerlessWorkflowParser;
Expand Down Expand Up @@ -423,7 +423,7 @@ protected final MakeNodeResult filterAndMergeNode(RuleFlowNodeContainerFactory<?
boolean shouldMerge, FilterableNodeSupplier nodeSupplier) {

if (isTempVariable(actionVarName)) {
embeddedSubProcess.variable(actionVarName, new ObjectDataType(JsonNode.class.getCanonicalName()), KogitoTags.VARIABLE_TAGS, KogitoTags.INTERNAL_TAG);
embeddedSubProcess.variable(actionVarName, new ObjectDataType(JsonNode.class.getCanonicalName()), Variable.VARIABLE_TAGS, Variable.INTERNAL_TAG);
}
NodeFactory<?, ?> startNode, currentNode;
if (fromStateExpr != null) {
Expand Down

0 comments on commit e2ddc47

Please sign in to comment.