From 895e665b0294acbaf89619d96a8869e132fd99fe Mon Sep 17 00:00:00 2001 From: nmirasch Date: Fri, 26 Apr 2024 18:00:18 +0200 Subject: [PATCH 1/2] RHPAM-4779: SLA due date value in ProcessInstanceLog table is not updated after updating process SLA (cherry picked from commit b19df698554ce45b07c6a0ba5a5322b687b7fe93) --- .../jbpm/SLAComplianceIntegrationTest.java | 12 ++++++---- ...itDataReplicationProcessEventProducer.java | 24 +++++++------------ .../audit/replication/MessageType.java | 1 + 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/kie-server-parent/kie-server-tests/kie-server-integ-tests-jbpm/src/test/java/org/kie/server/integrationtests/jbpm/SLAComplianceIntegrationTest.java b/kie-server-parent/kie-server-tests/kie-server-integ-tests-jbpm/src/test/java/org/kie/server/integrationtests/jbpm/SLAComplianceIntegrationTest.java index 95478e066b..c3460d8123 100644 --- a/kie-server-parent/kie-server-tests/kie-server-integ-tests-jbpm/src/test/java/org/kie/server/integrationtests/jbpm/SLAComplianceIntegrationTest.java +++ b/kie-server-parent/kie-server-tests/kie-server-integ-tests-jbpm/src/test/java/org/kie/server/integrationtests/jbpm/SLAComplianceIntegrationTest.java @@ -156,7 +156,7 @@ public void testSLAonUserTaskViolated() throws Exception { activeNodes = processClient.findActiveNodeInstances(CONTAINER_ID, pid, 0, 10); assertThat(activeNodes).hasSize(1); taskNode = activeNodes.get(0); - assertNodeInstance(taskNode, "Hello", SLA_VIOLATED); + assertNodeInstance(taskNode, "Hello", SLA_VIOLATED, -1); taskClient.completeAutoProgress(CONTAINER_ID, task.getId(), USER_YODA, null); tasks = taskClient.findTasksAssignedAsPotentialOwner(USER_YODA, 0, 10); @@ -240,11 +240,15 @@ private void assertProcessInstance(Long pid, int processState, int slaStatus, lo } } - private void assertNodeInstance(NodeInstance ni, String nodeName, int slaStatus) { + private void assertNodeInstance(NodeInstance ni, String nodeName, int slaStatus) { + assertNodeInstance(ni, nodeName, slaStatus, 30000); + } + + private void assertNodeInstance(NodeInstance ni, String nodeName, int slaStatus, long deltaTime) { assertThat(ni.getName()).isEqualTo(nodeName); assertThat(ni.getSlaCompliance()).isEqualTo(slaStatus); - if (slaStatus != SLA_NA) { - assertThat(ni.getSlaDueDate()).isCloseTo(new Date(), 30000); + if (slaStatus != SLA_NA && deltaTime > 0) { + assertThat(ni.getSlaDueDate()).isCloseTo(new Date(), deltaTime); } } diff --git a/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/AuditDataReplicationProcessEventProducer.java b/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/AuditDataReplicationProcessEventProducer.java index d63217f893..d1008eb8f7 100644 --- a/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/AuditDataReplicationProcessEventProducer.java +++ b/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/AuditDataReplicationProcessEventProducer.java @@ -21,24 +21,11 @@ import org.jbpm.process.audit.AbstractAuditLoggerAdapter; import org.jbpm.process.audit.NodeInstanceLog; import org.jbpm.process.audit.ProcessInstanceLog; -import org.kie.api.event.process.ProcessAsyncNodeScheduledEvent; -import org.kie.api.event.process.ProcessCompletedEvent; -import org.kie.api.event.process.ProcessNodeLeftEvent; -import org.kie.api.event.process.ProcessNodeTriggeredEvent; -import org.kie.api.event.process.ProcessStartedEvent; -import org.kie.api.event.process.ProcessVariableChangedEvent; -import org.kie.api.event.process.SLAViolatedEvent; +import org.kie.api.event.process.*; import org.kie.api.runtime.manager.audit.VariableInstanceLog; import org.springframework.beans.factory.annotation.Autowired; -import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_ENTER_EVENT_TYPE; -import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_LEFT_EVENT_TYPE; -import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_SCHEDULED_EVENT_TYPE; -import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_SLA_VIOLATED; -import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.PROCESS_COMPLETED_EVENT_TYPE; -import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.PROCESS_SLA_VIOLATED; -import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.PROCESS_START_EVENT_TYPE; -import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.VAR_CHANGE_EVENT_TYPE; +import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.*; /** @@ -124,4 +111,11 @@ protected void nodeScheduled(ProcessAsyncNodeScheduledEvent event) { } } + @Override + public void processDataChanged(ProcessDataChangedEvent event) { + ProcessInstanceLog log = (ProcessInstanceLog) getProcessInstanceMetadata(event.getProcessInstance(), METADATA_PROCESSINTANCE_LOG); + if (log != null) { + jmsSender.sendMessage(log, PROCESS_DATA_CHANGED_EVENT_TYPE); + } + } } diff --git a/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/MessageType.java b/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/MessageType.java index c2dab5bd0d..c21e74a594 100644 --- a/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/MessageType.java +++ b/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/MessageType.java @@ -30,6 +30,7 @@ private MessageType() { public static final int VAR_CHANGE_EVENT_TYPE = 104; public static final int NODE_SLA_VIOLATED = 105; public static final int PROCESS_SLA_VIOLATED = 106; + public static final int PROCESS_DATA_CHANGED_EVENT_TYPE = 108; public static final int TASK_STARTED = 201; public static final int TASK_ACTIVATED = 202; From 3e973ab92173d0aa14567e78f48baee60cb2bbe2 Mon Sep 17 00:00:00 2001 From: nmirasch Date: Mon, 29 Apr 2024 09:58:46 +0200 Subject: [PATCH 2/2] Removed * from imports (cherry picked from commit 4279f84ce27c1c345a050c3e29f3a04da69fb30c) --- ...itDataReplicationProcessEventProducer.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/AuditDataReplicationProcessEventProducer.java b/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/AuditDataReplicationProcessEventProducer.java index d1008eb8f7..811dca70ff 100644 --- a/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/AuditDataReplicationProcessEventProducer.java +++ b/kie-spring-boot/kie-spring-boot-autoconfiguration/kie-server-spring-boot-autoconfiguration-audit-replication/src/main/java/org/kie/server/spring/boot/autoconfiguration/audit/replication/AuditDataReplicationProcessEventProducer.java @@ -21,12 +21,26 @@ import org.jbpm.process.audit.AbstractAuditLoggerAdapter; import org.jbpm.process.audit.NodeInstanceLog; import org.jbpm.process.audit.ProcessInstanceLog; -import org.kie.api.event.process.*; +import org.kie.api.event.process.ProcessAsyncNodeScheduledEvent; +import org.kie.api.event.process.ProcessCompletedEvent; +import org.kie.api.event.process.ProcessNodeLeftEvent; +import org.kie.api.event.process.ProcessNodeTriggeredEvent; +import org.kie.api.event.process.ProcessStartedEvent; +import org.kie.api.event.process.ProcessVariableChangedEvent; +import org.kie.api.event.process.ProcessDataChangedEvent; +import org.kie.api.event.process.SLAViolatedEvent; import org.kie.api.runtime.manager.audit.VariableInstanceLog; import org.springframework.beans.factory.annotation.Autowired; -import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.*; - +import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_ENTER_EVENT_TYPE; +import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_LEFT_EVENT_TYPE; +import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_SCHEDULED_EVENT_TYPE; +import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.NODE_SLA_VIOLATED; +import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.PROCESS_COMPLETED_EVENT_TYPE; +import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.PROCESS_SLA_VIOLATED; +import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.PROCESS_START_EVENT_TYPE; +import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.VAR_CHANGE_EVENT_TYPE; +import static org.kie.server.spring.boot.autoconfiguration.audit.replication.MessageType.PROCESS_DATA_CHANGED_EVENT_TYPE; /** * AuditListener