Skip to content

Commit

Permalink
fix events
Browse files Browse the repository at this point in the history
  • Loading branch information
elguardian authored and pefernan committed Dec 21, 2023
1 parent 7dcb0ce commit 22e3f86
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public class ProcessInstanceSLAEventBody {

private String nodeType;

private Date slaDueDate;

public Date getSlaDueDate() {
return slaDueDate;
}

public void setSlaDueDate(Date slaDueDate) {
this.slaDueDate = slaDueDate;
}

public Date getEventDate() {
return eventDate;
}
Expand Down Expand Up @@ -98,6 +108,11 @@ private Builder(ProcessInstanceSLAEventBody instance) {
this.instance = instance;
}

public Builder slaDueDate(Date slaDueDate) {
this.instance.slaDueDate = slaDueDate;
return this;
}

public Builder eventDate(Date eventDate) {
this.instance.eventDate = eventDate;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.kie.kogito.event.impl;

import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
Expand Down Expand Up @@ -108,17 +109,17 @@ private void addDataEvent(ProcessEvent event) {
} else if (event instanceof ProcessCompletedEvent) {
handleProcessStateEvent((ProcessCompletedEvent) event);
} else if (event instanceof ProcessNodeTriggeredEvent) {
handleProcesssNodeEvent((ProcessNodeTriggeredEvent) event);
handleProcessNodeEvent((ProcessNodeTriggeredEvent) event);
} else if (event instanceof ProcessNodeLeftEvent) {
handleProcesssNodeEvent((ProcessNodeLeftEvent) event);
handleProcessNodeEvent((ProcessNodeLeftEvent) event);
} else if (event instanceof SLAViolatedEvent) {
handleProcesssNodeEvent((SLAViolatedEvent) event);
} else if (event instanceof ProcessVariableChangedEvent) {
handleProcesssVariableEvent((ProcessVariableChangedEvent) event);
handleProcessVariableEvent((ProcessVariableChangedEvent) event);
}
}

private void handleProcesssVariableEvent(ProcessVariableChangedEvent event) {
private void handleProcessVariableEvent(ProcessVariableChangedEvent event) {

Map<String, Object> metadata = buildProcessMetadata((KogitoWorkflowProcessInstance) event.getProcessInstance());
KogitoWorkflowProcessInstance pi = (KogitoWorkflowProcessInstance) event.getProcessInstance();
Expand Down Expand Up @@ -154,17 +155,21 @@ private void handleProcesssNodeEvent(SLAViolatedEvent event) {
KogitoWorkflowProcessInstance pi = (KogitoWorkflowProcessInstance) event.getProcessInstance();

ProcessInstanceSLAEventBody.Builder builder = ProcessInstanceSLAEventBody.create()
.eventDate(new Date())
.eventDate(Date.from(Instant.now()))
.eventUser(event.getEventIdentity())
.processId(event.getProcessInstance().getProcessId())
.processVersion(event.getProcessInstance().getProcessVersion())
.processInstanceId(event.getProcessInstance().getId());

if (event.getNodeInstance() != null) {
builder.nodeDefinitionId(event.getNodeInstance().getNode().getNodeUniqueId())
.nodeInstanceId(event.getNodeInstance().getId())
.nodeName(event.getNodeInstance().getNodeName())
.nodeType(event.getNodeInstance().getNode().getClass().getSimpleName());
if (event.getNodeInstance() instanceof KogitoNodeInstance) {
KogitoNodeInstance ni = (KogitoNodeInstance) event.getNodeInstance();
builder.nodeDefinitionId(ni.getNode().getNodeUniqueId())
.nodeInstanceId(ni.getId())
.nodeName(ni.getNodeName())
.nodeType(ni.getNode().getClass().getSimpleName())
.slaDueDate(ni.getSlaDueDate());
} else {
builder.slaDueDate(pi.getSlaDueDate());
}

ProcessInstanceSLAEventBody body = builder.build();
Expand All @@ -173,7 +178,7 @@ private void handleProcesssNodeEvent(SLAViolatedEvent event) {
processedEvents.add(piEvent);
}

private void handleProcesssNodeEvent(ProcessNodeLeftEvent event) {
private void handleProcessNodeEvent(ProcessNodeLeftEvent event) {
KogitoNodeInstance nodeInstance = (KogitoNodeInstance) event.getNodeInstance();
int eventType = ProcessInstanceNodeEventBody.EVENT_TYPE_EXIT;

Expand All @@ -196,7 +201,7 @@ private void handleProcesssNodeEvent(ProcessNodeLeftEvent event) {
processedEvents.add(toProcessInstanceNodeEvent(event, eventType));
}

private void handleProcesssNodeEvent(ProcessNodeTriggeredEvent event) {
private void handleProcessNodeEvent(ProcessNodeTriggeredEvent event) {
processedEvents.add(toProcessInstanceNodeEvent(event, ProcessInstanceNodeEventBody.EVENT_TYPE_ENTER));

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public String getEventUser() {

@Override
public String getUserTaskDefinitionId() {
return getWorkItem().getStringId();
return getHumanTaskNodeInstance().getNodeDefinitionId();
}

}

0 comments on commit 22e3f86

Please sign in to comment.