diff --git a/api/kogito-api/src/main/java/org/kie/kogito/internal/utils/KogitoTags.java b/api/kogito-api/src/main/java/org/kie/kogito/internal/utils/KogitoTags.java new file mode 100644 index 00000000000..a514146fb3f --- /dev/null +++ b/api/kogito-api/src/main/java/org/kie/kogito/internal/utils/KogitoTags.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.internal.utils; + +public class KogitoTags { + + 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"; + +} diff --git a/api/kogito-events-core/src/main/java/org/kie/kogito/event/impl/ProcessInstanceEventBatch.java b/api/kogito-events-core/src/main/java/org/kie/kogito/event/impl/ProcessInstanceEventBatch.java index 1ad8b81bcd5..0802570959a 100644 --- a/api/kogito-events-core/src/main/java/org/kie/kogito/event/impl/ProcessInstanceEventBatch.java +++ b/api/kogito-events-core/src/main/java/org/kie/kogito/event/impl/ProcessInstanceEventBatch.java @@ -74,6 +74,7 @@ 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 { @@ -120,7 +121,7 @@ private void addDataEvent(ProcessEvent event) { } private void handleProcessVariableEvent(ProcessVariableChangedEvent event) { - if (event.getTags().contains("internal")) { + if (event.getTags().contains(KogitoTags.INTERNAL_TAG)) { return; } Map metadata = buildProcessMetadata((KogitoWorkflowProcessInstance) event.getProcessInstance()); diff --git a/jbpm/jbpm-bpmn2/src/main/java/org/kie/kogito/process/bpmn2/BpmnVariables.java b/jbpm/jbpm-bpmn2/src/main/java/org/kie/kogito/process/bpmn2/BpmnVariables.java index 4d2f0629cc8..65e772dc89b 100644 --- a/jbpm/jbpm-bpmn2/src/main/java/org/kie/kogito/process/bpmn2/BpmnVariables.java +++ b/jbpm/jbpm-bpmn2/src/main/java/org/kie/kogito/process/bpmn2/BpmnVariables.java @@ -28,12 +28,13 @@ 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 OUTPUTS_ONLY = v -> v.hasTag(Variable.OUTPUT_TAG); - public static final Predicate INPUTS_ONLY = v -> v.hasTag(Variable.INPUT_TAG); - public static final Predicate INTERNAL_ONLY = v -> v.hasTag(Variable.INTERNAL_TAG); + public static final Predicate OUTPUTS_ONLY = v -> v.hasTag(KogitoTags.OUTPUT_TAG); + public static final Predicate INPUTS_ONLY = v -> v.hasTag(KogitoTags.INPUT_TAG); + public static final Predicate INTERNAL_ONLY = v -> v.hasTag(KogitoTags.INTERNAL_TAG); private final Map variables = new HashMap<>(); diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractVisitor.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractVisitor.java index 2dda39c0c37..3f206bc4172 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractVisitor.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractVisitor.java @@ -30,6 +30,7 @@ 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; @@ -87,12 +88,12 @@ protected void visitVariableScope(String field, VariableScope variableScope, Blo if (!visitedVariables.add(variable.getName())) { continue; } - String tags = (String) variable.getMetaData(Variable.VARIABLE_TAGS); + String tags = (String) variable.getMetaData(KogitoTags.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(Variable.VARIABLE_TAGS), + defaultValue != null ? new StringLiteralExpr(defaultValue.toString()) : new NullLiteralExpr(), new StringLiteralExpr(KogitoTags.VARIABLE_TAGS), tags != null ? new StringLiteralExpr(tags) : new NullLiteralExpr())); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ModelMetaData.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ModelMetaData.java index b377be1cc8d..c374c7a0316 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ModelMetaData.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ModelMetaData.java @@ -31,6 +31,7 @@ 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; @@ -237,7 +238,7 @@ private void applyValidation(FieldDeclaration fd, List tags) { if (supportsValidation) { fd.addAnnotation("jakarta.validation.Valid"); - if (tags != null && tags.contains(Variable.REQUIRED_TAG)) { + if (tags != null && tags.contains(KogitoTags.REQUIRED_TAG)) { fd.addAnnotation("jakarta.validation.constraints.NotNull"); } } diff --git a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/VariableDeclarations.java b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/VariableDeclarations.java index 1e6f33c4524..af9907335df 100644 --- a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/VariableDeclarations.java +++ b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/VariableDeclarations.java @@ -27,13 +27,14 @@ 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 vs = new HashMap<>(); for (Variable variable : vscope.getVariables()) { - if (variable.hasTag(Variable.INTERNAL_TAG)) { + if (variable.hasTag(KogitoTags.INTERNAL_TAG)) { continue; } @@ -44,12 +45,12 @@ public static VariableDeclarations of(VariableScope vscope) { public static VariableDeclarations ofInput(VariableScope vscope) { - return of(vscope, variable -> variable.hasTag(Variable.INTERNAL_TAG) || variable.hasTag(Variable.OUTPUT_TAG)); + return of(vscope, variable -> variable.hasTag(KogitoTags.INTERNAL_TAG) || variable.hasTag(KogitoTags.OUTPUT_TAG)); } public static VariableDeclarations ofOutput(VariableScope vscope) { - return of(vscope, variable -> variable.hasTag(Variable.INTERNAL_TAG) || variable.hasTag(Variable.INPUT_TAG)); + return of(vscope, variable -> variable.hasTag(KogitoTags.INTERNAL_TAG) || variable.hasTag(KogitoTags.INPUT_TAG)); } public static VariableDeclarations of(VariableScope vscope, Predicate filterOut) { diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/Variable.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/Variable.java index e81f4f55e24..e33a97a6daf 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/Variable.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/Variable.java @@ -35,6 +35,7 @@ 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. @@ -44,13 +45,6 @@ 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 KOGITO_RESERVED = Set.of("id"); @@ -146,7 +140,7 @@ public void setValue(final Object value) { public void setMetaData(String name, Object value) { this.metaData.put(name, value); - if (VARIABLE_TAGS.equals(name) && value != null) { + if (KogitoTags.VARIABLE_TAGS.equals(name) && value != null) { tags = Arrays.asList(value.toString().split(",")); } } @@ -165,8 +159,8 @@ public String toString() { } public List getTags() { - if (tags.isEmpty() && this.metaData.containsKey(VARIABLE_TAGS)) { - tags = Arrays.asList(metaData.get(VARIABLE_TAGS).toString().split(",")); + if (tags.isEmpty() && this.metaData.containsKey(KogitoTags.VARIABLE_TAGS)) { + tags = Arrays.asList(metaData.get(KogitoTags.VARIABLE_TAGS).toString().split(",")); } return tags; diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/VariableScope.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/VariableScope.java index dd2ecf66777..613926aaf7d 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/VariableScope.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/context/variable/VariableScope.java @@ -24,6 +24,7 @@ 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 { @@ -110,7 +111,7 @@ public boolean isReadOnly(String name) { Variable v = findVariable(name); if (v != null) { - return v.hasTag(Variable.READONLY_TAG); + return v.hasTag(KogitoTags.READONLY_TAG); } return false; } @@ -119,7 +120,7 @@ public boolean isRequired(String name) { Variable v = findVariable(name); if (v != null) { - return v.hasTag(Variable.REQUIRED_TAG); + return v.hasTag(KogitoTags.REQUIRED_TAG); } return false; } diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ForEachNodeFactory.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ForEachNodeFactory.java index aa462310aec..4ee362d81bd 100755 --- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ForEachNodeFactory.java +++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/ForEachNodeFactory.java @@ -27,6 +27,7 @@ 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> extends AbstractCompositeNodeFactory, T> { @@ -99,7 +100,7 @@ public ForEachNodeFactory tempVariable(String varRef, String variableName, Da private ForEachNodeFactory addVariable(String varRef, String variableName, DataType dataType, boolean eval) { Variable variable = getForEachNode().addContextVariable(varRef, variableName, dataType); variable.setMetaData(Metadata.EVAL_VARIABLE, eval); - variable.setMetaData(Variable.VARIABLE_TAGS, Variable.INTERNAL_TAG); + variable.setMetaData(KogitoTags.VARIABLE_TAGS, KogitoTags.INTERNAL_TAG); return this; } diff --git a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java index 6ef53ad49c3..c29571ed3cf 100644 --- a/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java +++ b/kogito-serverless-workflow/kogito-serverless-workflow-builder/src/main/java/org/kie/kogito/serverless/workflow/parser/handlers/StateHandler.java @@ -28,7 +28,6 @@ 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; @@ -44,6 +43,7 @@ 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; @@ -423,7 +423,7 @@ protected final MakeNodeResult filterAndMergeNode(RuleFlowNodeContainerFactory startNode, currentNode; if (fromStateExpr != null) {