Search in sources :

Example 26 with VariableScope

use of io.automatiko.engine.workflow.base.core.context.variable.VariableScope in project automatiko-engine by automatiko-io.

the class WorkflowProcessInstanceImpl method getPublicVariables.

@Override
public Map<String, Object> getPublicVariables() {
    Map<String, Object> variables = new HashMap<>(getVariables());
    VariableScope variableScope = (VariableScope) ((io.automatiko.engine.workflow.process.core.WorkflowProcess) getProcess()).getDefaultContext(VariableScope.VARIABLE_SCOPE);
    for (Variable variable : variableScope.getVariables()) {
        if (variable.hasTag(Variable.SENSITIVE_TAG)) {
            variables.remove(variable.getName());
        }
    }
    return variables;
}
Also used : Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) HashMap(java.util.HashMap) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 27 with VariableScope

use of io.automatiko.engine.workflow.base.core.context.variable.VariableScope in project automatiko-engine by automatiko-io.

the class StartNodeVisitor method handleTrigger.

protected void handleTrigger(StartNode startNode, Map<String, Object> nodeMetaData, BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
    if (EVENT_TYPE_SIGNAL.equalsIgnoreCase((String) startNode.getMetaData(TRIGGER_TYPE))) {
        Variable variable = null;
        Map<String, String> variableMapping = startNode.getOutMappings();
        String variableType = null;
        if (variableMapping != null && !variableMapping.isEmpty()) {
            Entry<String, String> varInfo = variableMapping.entrySet().iterator().next();
            body.addStatement(getFactoryMethod(getNodeId(startNode), METHOD_TRIGGER, new StringLiteralExpr((String) nodeMetaData.get(MESSAGE_TYPE)), getOrNullExpr(varInfo.getKey()), getOrNullExpr(varInfo.getValue())));
            Matcher matcher = PatternConstants.PARAMETER_MATCHER.matcher(varInfo.getValue());
            if (matcher.find()) {
                variableType = (String) nodeMetaData.get(TRIGGER_REF);
            } else {
                variable = variableScope.findVariable(varInfo.getValue());
                if (variable == null) {
                    // check parent node container
                    VariableScope vscope = (VariableScope) startNode.resolveContext(VariableScope.VARIABLE_SCOPE, varInfo.getKey());
                    variable = vscope.findVariable(varInfo.getValue());
                }
                variableType = variable != null ? variable.getType().getStringType() : null;
            }
        } else {
            body.addStatement(getFactoryMethod(getNodeId(startNode), METHOD_TRIGGER, new StringLiteralExpr((String) nodeMetaData.get(MESSAGE_TYPE)), new StringLiteralExpr(getOrDefault((String) nodeMetaData.get(TRIGGER_MAPPING), ""))));
        }
        metadata.addSignal((String) nodeMetaData.get(MESSAGE_TYPE), variableType, startNode);
    } else if (EVENT_TYPE_CONDITION.equalsIgnoreCase((String) startNode.getMetaData(TRIGGER_TYPE))) {
        ConstraintTrigger constraintTrigger = (ConstraintTrigger) startNode.getTriggers().get(0);
        body.addStatement(getFactoryMethod(getNodeId(startNode), METHOD_CONDITION, createLambdaExpr(constraintTrigger.getConstraint(), variableScope)));
    } else {
        String triggerMapping = (String) nodeMetaData.get(TRIGGER_MAPPING);
        body.addStatement(getFactoryMethod(getNodeId(startNode), METHOD_TRIGGER, new StringLiteralExpr((String) nodeMetaData.get(TRIGGER_REF)), new StringLiteralExpr(getOrDefault((String) nodeMetaData.get(TRIGGER_MAPPING), "")), new StringLiteralExpr(getOrDefault(startNode.getOutMapping(triggerMapping), ""))));
    }
}
Also used : ConstraintTrigger(io.automatiko.engine.workflow.process.core.node.ConstraintTrigger) Variable(io.automatiko.engine.workflow.base.core.context.variable.Variable) Matcher(java.util.regex.Matcher) StringLiteralExpr(com.github.javaparser.ast.expr.StringLiteralExpr) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 28 with VariableScope

use of io.automatiko.engine.workflow.base.core.context.variable.VariableScope in project automatiko-engine by automatiko-io.

the class ProcessToExecModelGenerator method generateUserTaskModel.

public List<UserTaskModelMetaData> generateUserTaskModel(WorkflowProcess process, boolean templateSupported) {
    String packageName = process.getPackageName();
    List<UserTaskModelMetaData> usertaskModels = new ArrayList<>();
    VariableScope variableScope = (VariableScope) ((io.automatiko.engine.workflow.base.core.Process) process).getDefaultContext(VariableScope.VARIABLE_SCOPE);
    for (Node node : ((WorkflowProcessImpl) process).getNodesRecursively()) {
        if (node instanceof HumanTaskNode) {
            HumanTaskNode humanTaskNode = (HumanTaskNode) node;
            VariableScope nodeVariableScope = (VariableScope) ((ContextContainer) humanTaskNode.getParentContainer()).getDefaultContext(VariableScope.VARIABLE_SCOPE);
            if (nodeVariableScope == null) {
                nodeVariableScope = variableScope;
            }
            usertaskModels.add(new UserTaskModelMetaData(packageName, variableScope, nodeVariableScope, humanTaskNode, process.getId(), ModelMetaData.version(process.getVersion()), templateSupported));
        }
    }
    return usertaskModels;
}
Also used : Node(io.automatiko.engine.api.definition.process.Node) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode) ArrayList(java.util.ArrayList) WorkflowProcessImpl(io.automatiko.engine.workflow.process.core.impl.WorkflowProcessImpl) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope) HumanTaskNode(io.automatiko.engine.workflow.process.core.node.HumanTaskNode)

Example 29 with VariableScope

use of io.automatiko.engine.workflow.base.core.context.variable.VariableScope in project automatiko-engine by automatiko-io.

the class CompositeNodeHandler method createNode.

protected Node createNode() {
    CompositeContextNode result = new CompositeContextNode();
    VariableScope variableScope = new VariableScope();
    result.addContext(variableScope);
    result.setDefaultContext(variableScope);
    return result;
}
Also used : CompositeContextNode(io.automatiko.engine.workflow.process.core.node.CompositeContextNode) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Example 30 with VariableScope

use of io.automatiko.engine.workflow.base.core.context.variable.VariableScope in project automatiko-engine by automatiko-io.

the class XmlWorkflowProcessDumper method visitHeader.

protected void visitHeader(WorkflowProcess process, StringBuilder xmlDump, boolean includeMeta) {
    xmlDump.append("  <header>" + EOL);
    visitImports(((io.automatiko.engine.workflow.base.core.Process) process).getImports(), xmlDump);
    visitGlobals(((io.automatiko.engine.workflow.base.core.Process) process).getGlobals(), xmlDump);
    visitFunctionImports(((io.automatiko.engine.workflow.base.core.Process) process).getFunctionImports(), xmlDump);
    VariableScope variableScope = (VariableScope) ((io.automatiko.engine.workflow.base.core.Process) process).getDefaultContext(VariableScope.VARIABLE_SCOPE);
    if (variableScope != null) {
        visitVariables(variableScope.getVariables(), xmlDump);
    }
    SwimlaneContext swimlaneContext = (SwimlaneContext) ((io.automatiko.engine.workflow.base.core.Process) process).getDefaultContext(SwimlaneContext.SWIMLANE_SCOPE);
    if (swimlaneContext != null) {
        visitSwimlanes(swimlaneContext.getSwimlanes(), xmlDump);
    }
    ExceptionScope exceptionScope = (ExceptionScope) ((io.automatiko.engine.workflow.base.core.Process) process).getDefaultContext(ExceptionScope.EXCEPTION_SCOPE);
    if (exceptionScope != null) {
        visitExceptionHandlers(exceptionScope.getExceptionHandlers(), xmlDump);
    }
    xmlDump.append("  </header>" + EOL + EOL);
}
Also used : SwimlaneContext(io.automatiko.engine.workflow.base.core.context.swimlane.SwimlaneContext) ExceptionScope(io.automatiko.engine.workflow.base.core.context.exception.ExceptionScope) VariableScope(io.automatiko.engine.workflow.base.core.context.variable.VariableScope)

Aggregations

VariableScope (io.automatiko.engine.workflow.base.core.context.variable.VariableScope)40 Variable (io.automatiko.engine.workflow.base.core.context.variable.Variable)27 Map (java.util.Map)16 HashMap (java.util.HashMap)11 List (java.util.List)10 ContextContainer (io.automatiko.engine.workflow.base.core.ContextContainer)9 ArrayList (java.util.ArrayList)9 WorkflowProcess (io.automatiko.engine.api.definition.process.WorkflowProcess)8 VariableScopeInstance (io.automatiko.engine.workflow.base.instance.context.variable.VariableScopeInstance)8 CompositeContextNode (io.automatiko.engine.workflow.process.core.node.CompositeContextNode)7 Node (io.automatiko.engine.api.definition.process.Node)6 ActionNode (io.automatiko.engine.workflow.process.core.node.ActionNode)6 EventSubProcessNode (io.automatiko.engine.workflow.process.core.node.EventSubProcessNode)6 Optional (java.util.Optional)6 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)5 ClassOrInterfaceType (com.github.javaparser.ast.type.ClassOrInterfaceType)5 Matcher (java.util.regex.Matcher)5 AssignExpr (com.github.javaparser.ast.expr.AssignExpr)4 BooleanLiteralExpr (com.github.javaparser.ast.expr.BooleanLiteralExpr)4 LongLiteralExpr (com.github.javaparser.ast.expr.LongLiteralExpr)4