Skip to content

Commit

Permalink
[Fix apache/incubator-kie-issues#987] Update state to error (#2011)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado authored Mar 7, 2024
1 parent 399fe8d commit c3b36c4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

public class CommonUtils {

public static final int ERROR_STATE = 5;
private static final Set<String> finalStates = Set.of("Completed", "Aborted");

public static boolean isTaskCompleted(String status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -116,6 +117,7 @@ private void indexError(ProcessInstanceErrorEventBody error) {
}
errorEntity.setMessage(error.getErrorMessage());
errorEntity.setNodeDefinitionId(error.getNodeDefinitionId());
pi.setState(CommonUtils.ERROR_STATE);
repository.flush();
}

Expand Down

0 comments on commit c3b36c4

Please sign in to comment.