Skip to content

Commit

Permalink
[KOGITO-9555] Update process definition
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Jul 12, 2023
1 parent a3054eb commit a81f83e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private StaticWorkflowApplication(Map<String, Object> properties, Map<String, Sy
* @return
*/
public JsonNodeModel execute(Workflow workflow, Map<String, Object> data) {
return execute(process(workflow), data);
return execute(findOrCreate(workflow), data);
}

/**
Expand All @@ -168,7 +168,11 @@ public JsonNodeModel execute(Workflow workflow, Map<String, Object> data) {
* @return
*/
public JsonNodeModel execute(Workflow workflow, JsonNode data) {
return execute(process(workflow), data);
return execute(findOrCreate(workflow), data);
}

private Process<JsonNodeModel> findOrCreate(Workflow workflow) {
return findProcessById(workflow.getId()).orElseGet(() -> process(workflow));
}

/**
Expand Down Expand Up @@ -214,7 +218,9 @@ public JsonNodeModel execute(Process<JsonNodeModel> process, JsonNodeModel model
* @return Executable process definition
*/
public Process<JsonNodeModel> process(Workflow workflow) {
return processes.map.computeIfAbsent(workflow.getId(), k -> createProcess(workflow));
Process<JsonNodeModel> process = createProcess(workflow);
processes.map.put(workflow.getId(), process);
return process;
}

public void registerHandler(KogitoWorkItemHandler handler) {
Expand Down Expand Up @@ -265,7 +271,7 @@ private Process<JsonNodeModel> createProcess(Workflow workflow) {
workflowProcess.getNodesRecursively().forEach(node -> {
if (node instanceof SubProcessNode) {
SubProcessNode subProcess = (SubProcessNode) node;
subProcess.setSubProcessFactory(new StaticSubprocessFactory(processes.map.get(subProcess.getProcessId())));
subProcess.setSubProcessFactory(new StaticSubprocessFactory((Process<JsonNodeModel>) processes.processById(subProcess.getProcessId())));
}
});
EventFactoryUtils.ready();
Expand Down
1 change: 1 addition & 0 deletions quarkus/addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<module>tracing-decision</module>
<module>task-management</module>
<module>marshallers</module>
<module>process-definitions</module>
<module>python</module>
</modules>
</profile>
Expand Down

0 comments on commit a81f83e

Please sign in to comment.