Skip to content

Commit

Permalink
make use of import aware expression evaluator for tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mswiderski committed Sep 20, 2024
1 parent 34d3540 commit 107aceb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.automatiko.engine.api.definition.process.Node;
import io.automatiko.engine.api.definition.process.NodeContainer;
import io.automatiko.engine.api.definition.process.WorkflowProcess;
import io.automatiko.engine.api.expression.ExpressionEvaluator;
import io.automatiko.engine.workflow.base.core.ContextContainer;
import io.automatiko.engine.workflow.base.core.FunctionTagDefinition;
import io.automatiko.engine.workflow.base.core.Process;
Expand Down Expand Up @@ -63,6 +64,7 @@
import io.automatiko.engine.workflow.process.core.impl.ConstraintImpl;
import io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl;
import io.automatiko.engine.workflow.process.core.impl.NodeImpl;
import io.automatiko.engine.workflow.process.core.impl.WorkflowProcessImpl;
import io.automatiko.engine.workflow.process.core.node.ActionNode;
import io.automatiko.engine.workflow.process.core.node.BoundaryEventNode;
import io.automatiko.engine.workflow.process.core.node.CompositeContextNode;
Expand Down Expand Up @@ -1134,6 +1136,7 @@ public static ConsequenceAction createJavaAction(Action action) {

}

@SuppressWarnings({ "rawtypes", "unchecked" })
protected void processTags(WorkflowProcess process) {
String tags = (String) process.getMetaData().get("tags");
List<TagDefinition> tagDefinitions = new ArrayList<TagDefinition>();
Expand All @@ -1151,8 +1154,10 @@ protected void processTags(WorkflowProcess process) {
Matcher matcher = PatternConstants.PARAMETER_MATCHER.matcher(exp);
while (matcher.find()) {
String paramName = matcher.group(1);
Object value = MVEL.executeExpression(MVEL.compileExpression(paramName),
vars.getVariables());
ExpressionEvaluator evaluator = (ExpressionEvaluator) ((WorkflowProcessImpl) process)
.getDefaultContext(ExpressionEvaluator.EXPRESSION_EVALUATOR);

Object value = evaluator.evaluate(paramName, vars.getVariables());
replacements.put(paramName, value);
}
for (Map.Entry<String, Object> replacement : replacements.entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import java.util.function.BiFunction;
import java.util.regex.Matcher;

import org.mvel2.MVEL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.automatiko.engine.api.definition.process.Node;
import io.automatiko.engine.api.definition.process.NodeContainer;
import io.automatiko.engine.api.definition.process.WorkflowProcess;
import io.automatiko.engine.api.expression.ExpressionEvaluator;
import io.automatiko.engine.api.runtime.process.ProcessContext;
import io.automatiko.engine.api.workflow.datatype.DataType;
import io.automatiko.engine.workflow.base.core.ContextContainer;
Expand All @@ -51,6 +51,7 @@
import io.automatiko.engine.workflow.process.core.ProcessAction;
import io.automatiko.engine.workflow.process.core.impl.ConsequenceAction;
import io.automatiko.engine.workflow.process.core.impl.ExtendedNodeImpl;
import io.automatiko.engine.workflow.process.core.impl.WorkflowProcessImpl;
import io.automatiko.engine.workflow.process.core.node.CompositeNode;
import io.automatiko.engine.workflow.process.core.node.ConstraintTrigger;
import io.automatiko.engine.workflow.process.core.node.EndNode;
Expand Down Expand Up @@ -541,6 +542,7 @@ private void postProcessNodes(ExecutableProcess process, NodeContainer container
}
}

@SuppressWarnings({ "rawtypes", "unchecked" })
protected void processTags(WorkflowProcess process) {
String tags = (String) process.getMetaData().get("tags");
List<TagDefinition> tagDefinitions = new ArrayList<TagDefinition>();
Expand All @@ -558,8 +560,11 @@ protected void processTags(WorkflowProcess process) {
Matcher matcher = PatternConstants.PARAMETER_MATCHER.matcher(exp);
while (matcher.find()) {
String paramName = matcher.group(1);
Object value = MVEL.executeExpression(MVEL.compileExpression(paramName),
vars.getVariables());

ExpressionEvaluator evaluator = (ExpressionEvaluator) ((WorkflowProcessImpl) process)
.getDefaultContext(ExpressionEvaluator.EXPRESSION_EVALUATOR);

Object value = evaluator.evaluate(paramName, vars.getVariables());
replacements.put(paramName, value);
}
for (Map.Entry<String, Object> replacement : replacements.entrySet()) {
Expand Down

0 comments on commit 107aceb

Please sign in to comment.