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;
}
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), ""))));
}
}
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;
}
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;
}
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);
}
Aggregations