use of io.automatiko.engine.api.definition.process.Process in project automatiko-engine by automatiko-io.
the class DmnDecisionInProcessTest method createProcessRuntime.
protected InternalProcessRuntime createProcessRuntime(Process... process) {
Map<String, Process> mappedProcesses = Stream.of(process).collect(Collectors.toMap(Process::getId, p -> p));
InternalProcessRuntime processRuntime = new ProcessRuntimeImpl(mappedProcesses);
return processRuntime;
}
use of io.automatiko.engine.api.definition.process.Process in project automatiko-engine by automatiko-io.
the class LightProcessRuntime method createProcessInstance.
private io.automatiko.engine.workflow.base.instance.ProcessInstance createProcessInstance(Process process, CorrelationKey correlationKey, Map<String, Object> parameters) {
io.automatiko.engine.workflow.base.instance.ProcessInstance pi = runtimeContext.createProcessInstance(process, correlationKey);
pi.setProcessRuntime(this);
runtimeContext.setupParameters(pi, parameters, variableInitializer);
Map<String, Object> temp = new HashMap<>();
if (parameters != null) {
temp.putAll(parameters);
}
temp.putAll(pi.getVariables());
String uuid;
if (correlationKey != null) {
uuid = UUID.nameUUIDFromBytes(correlationKey.toExternalForm().getBytes(StandardCharsets.UTF_8)).toString();
((WorkflowProcessInstanceImpl) pi).setCorrelationKey(correlationKey.toExternalForm());
} else {
VariableScope variableScope = (VariableScope) ((ContextContainer) process).getDefaultContext(VariableScope.VARIABLE_SCOPE);
Optional<Object> businessKeyVar = variableScope.getVariables().stream().filter(var -> var.hasTag(Variable.BUSINESS_KEY_TAG)).map(v -> temp.get(v.getName())).filter(var -> var != null).findAny();
if (businessKeyVar.isPresent()) {
Object businessKey = businessKeyVar.get();
uuid = UUID.nameUUIDFromBytes(businessKey.toString().getBytes(StandardCharsets.UTF_8)).toString();
((WorkflowProcessInstanceImpl) pi).setCorrelationKey(businessKey.toString());
} else {
uuid = UUID.randomUUID().toString();
}
}
pi.setId(uuid);
VariableScope variableScope = (VariableScope) ((ContextContainer) process).getDefaultContext(VariableScope.VARIABLE_SCOPE);
VariableScopeInstance variableScopeInstance = (VariableScopeInstance) pi.getContextInstance(VariableScope.VARIABLE_SCOPE);
// set input parameters
if (parameters != null) {
if (variableScope != null) {
for (Map.Entry<String, Object> entry : parameters.entrySet()) {
variableScope.validateVariable(process.getName(), entry.getKey(), entry.getValue());
variableScopeInstance.setVariable(entry.getKey(), entry.getValue());
}
} else {
throw new IllegalArgumentException("This process does not support parameters!");
}
}
variableScopeInstance.enforceRequiredVariables();
return pi;
}
use of io.automatiko.engine.api.definition.process.Process in project automatiko-engine by automatiko-io.
the class ProcessRuntimeImpl method initStartTimers.
public void initStartTimers() {
Collection<Process> processes = this.processes.values();
for (Process process : processes) {
ExecutableProcess p = (ExecutableProcess) process;
List<StartNode> startNodes = p.getTimerStart();
if (startNodes != null && !startNodes.isEmpty()) {
for (StartNode startNode : startNodes) {
if (startNode != null && startNode.getTimer() != null) {
jobService.scheduleProcessJob(ProcessJobDescription.of(createTimerInstance(startNode.getTimer()), p.getId(), p.getVersion()));
}
}
}
}
}
Aggregations