From c3b36c424d9855b654ab65dd6a198e1500dcec28 Mon Sep 17 00:00:00 2001 From: Francisco Javier Tirado Sarti <65240126+fjtirado@users.noreply.github.com> Date: Thu, 7 Mar 2024 10:44:58 +0100 Subject: [PATCH] [Fix apache/incubator-kie-issues#987] Update state to error (#2011) --- .../src/main/java/org/kie/kogito/index/CommonUtils.java | 1 + .../storage/merger/ProcessInstanceErrorDataEventMerger.java | 2 ++ .../kogito/index/jpa/storage/ProcessInstanceEntityStorage.java | 2 ++ 3 files changed, 5 insertions(+) diff --git a/data-index/data-index-common/src/main/java/org/kie/kogito/index/CommonUtils.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/CommonUtils.java index ba47c72d44..3bc4b724db 100644 --- a/data-index/data-index-common/src/main/java/org/kie/kogito/index/CommonUtils.java +++ b/data-index/data-index-common/src/main/java/org/kie/kogito/index/CommonUtils.java @@ -22,6 +22,7 @@ public class CommonUtils { + public static final int ERROR_STATE = 5; private static final Set finalStates = Set.of("Completed", "Aborted"); public static boolean isTaskCompleted(String status) { diff --git a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/merger/ProcessInstanceErrorDataEventMerger.java b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/merger/ProcessInstanceErrorDataEventMerger.java index 87b6566433..3408a7247d 100644 --- a/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/merger/ProcessInstanceErrorDataEventMerger.java +++ b/data-index/data-index-storage/data-index-storage-common/src/main/java/org/kie/kogito/index/storage/merger/ProcessInstanceErrorDataEventMerger.java @@ -20,6 +20,7 @@ import org.kie.kogito.event.process.ProcessInstanceDataEvent; import org.kie.kogito.event.process.ProcessInstanceErrorDataEvent; +import org.kie.kogito.index.CommonUtils; import org.kie.kogito.index.model.ProcessInstance; import org.kie.kogito.index.model.ProcessInstanceError; @@ -36,6 +37,7 @@ public ProcessInstance merge(ProcessInstance pi, ProcessInstanceDataEvent dat error.setMessage(event.getData().getErrorMessage()); error.setNodeDefinitionId(event.getData().getNodeDefinitionId()); pi.setError(error); + pi.setState(CommonUtils.ERROR_STATE); return pi; } diff --git a/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/ProcessInstanceEntityStorage.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/ProcessInstanceEntityStorage.java index 5ea98dda39..386aabcf78 100644 --- a/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/ProcessInstanceEntityStorage.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/ProcessInstanceEntityStorage.java @@ -33,6 +33,7 @@ import org.kie.kogito.event.process.ProcessInstanceStateEventBody; import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent; import org.kie.kogito.event.process.ProcessInstanceVariableEventBody; +import org.kie.kogito.index.CommonUtils; import org.kie.kogito.index.jpa.mapper.ProcessInstanceEntityMapper; import org.kie.kogito.index.jpa.model.MilestoneEntity; import org.kie.kogito.index.jpa.model.NodeInstanceEntity; @@ -116,6 +117,7 @@ private void indexError(ProcessInstanceErrorEventBody error) { } errorEntity.setMessage(error.getErrorMessage()); errorEntity.setNodeDefinitionId(error.getNodeDefinitionId()); + pi.setState(CommonUtils.ERROR_STATE); repository.flush(); }