Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[incubator-kie-issues-1508] GraphQL external reference id retrieve in data index and audit. (runtimes part) #3703

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class UserTaskInstanceStateEventBody {

private String eventType;

private String externalReferenceId;

public Date getEventDate() {
return eventDate;
}
Expand Down Expand Up @@ -95,6 +97,10 @@ public String getEventType() {
return eventType;
}

public String getExternalReferenceId() {
return externalReferenceId;
}

public Map<String, Object> metaData() {
Map<String, Object> metadata = new HashMap<>();
metadata.put(UserTaskInstanceEventMetadata.USER_TASK_INSTANCE_ID_META_DATA, userTaskInstanceId);
Expand Down Expand Up @@ -194,6 +200,11 @@ public Builder actualOwner(String userId) {
return this;
}

public Builder externalReferenceId(String externalReferenceId) {
this.instance.externalReferenceId = externalReferenceId;
return this;
}

public Builder eventType(String eventType) {
this.instance.eventType = eventType;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ protected ProcessInstanceNodeDataEvent toProcessInstanceNodeEvent(ProcessNodeEve
.nodeDefinitionId(event.getNodeInstance().getNode().getUniqueId())
.slaDueDate(nodeInstance.getSlaDueDate());

if (event.getNodeInstance() instanceof KogitoWorkItemNodeInstance workItemNodeInstance && workItemNodeInstance.getWorkItem() != null) {
KogitoWorkItem workItem = workItemNodeInstance.getWorkItem();
builder.workItemId(workItem.getStringId());
builder.data("WorkItemId", workItem.getStringId());
builder.data("WorkItemExternalReferenceId", workItem.getExternalReferenceId());
}

if (eventType == ProcessInstanceNodeEventBody.EVENT_TYPE_ENTER) {
builder.connectionNodeDefinitionId((String) nodeInstance.getMetaData().get("IncomingConnection"));
} else {
builder.connectionNodeDefinitionId((String) nodeInstance.getMetaData().get("OutgoingConnection"));
}

if (nodeInstance instanceof KogitoWorkItemNodeInstance) {
KogitoWorkItem workItem = ((KogitoWorkItemNodeInstance) nodeInstance).getWorkItem();
if (workItem != null) {
builder.workItemId(workItem.getStringId());
}
}

ProcessInstanceNodeEventBody body = builder.build();
ProcessInstanceNodeDataEvent piEvent = new ProcessInstanceNodeDataEvent(AdapterHelper.buildSource(getConfig().service(), event.getProcessInstance().getProcessId()),
getConfig().addons().toString(), event.getEventIdentity(), metadata, body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,19 @@
*/
package org.kie.kogito.event.impl.adapter;

import org.kie.api.event.process.ProcessNodeLeftEvent;
import org.kie.api.event.process.ProcessNodeTriggeredEvent;
import org.kie.kogito.event.DataEvent;
import org.kie.kogito.event.process.ProcessInstanceNodeEventBody;
import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;

public class ProcessNodeEnteredEventDataEventAdapter extends AbstractDataEventAdapter {

public ProcessNodeEnteredEventDataEventAdapter() {
super(ProcessNodeLeftEvent.class);
super(ProcessNodeTriggeredEvent.class);
}

@Override
public DataEvent<?> adapt(Object payload) {
ProcessNodeLeftEvent event = (ProcessNodeLeftEvent) payload;
KogitoNodeInstance nodeInstance = (KogitoNodeInstance) event.getNodeInstance();
int eventType = ProcessInstanceNodeEventBody.EVENT_TYPE_EXIT;

if (nodeInstance.getCancelType() != null) {
switch (nodeInstance.getCancelType()) {
case ABORTED:
eventType = ProcessInstanceNodeEventBody.EVENT_TYPE_ABORTED;
break;
case SKIPPED:
eventType = ProcessInstanceNodeEventBody.EVENT_TYPE_SKIPPED;
break;
case OBSOLETE:
eventType = ProcessInstanceNodeEventBody.EVENT_TYPE_OBSOLETE;
break;
case ERROR:
eventType = ProcessInstanceNodeEventBody.EVENT_TYPE_ERROR;
}
}

return toProcessInstanceNodeEvent((ProcessNodeLeftEvent) payload, eventType);
return toProcessInstanceNodeEvent((ProcessNodeTriggeredEvent) payload, ProcessInstanceNodeEventBody.EVENT_TYPE_ENTER);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,40 @@
*/
package org.kie.kogito.event.impl.adapter;

import org.kie.api.event.process.ProcessNodeTriggeredEvent;
import org.kie.api.event.process.ProcessNodeLeftEvent;
import org.kie.kogito.event.DataEvent;
import org.kie.kogito.event.process.ProcessInstanceNodeEventBody;
import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;

public class ProcessNodeLeftEventDataEventAdapter extends AbstractDataEventAdapter {

public ProcessNodeLeftEventDataEventAdapter() {
super(ProcessNodeTriggeredEvent.class);
super(ProcessNodeLeftEvent.class);
}

@Override
public DataEvent<?> adapt(Object payload) {
return toProcessInstanceNodeEvent((ProcessNodeTriggeredEvent) payload, ProcessInstanceNodeEventBody.EVENT_TYPE_ENTER);
ProcessNodeLeftEvent event = (ProcessNodeLeftEvent) payload;
KogitoNodeInstance nodeInstance = (KogitoNodeInstance) event.getNodeInstance();
int eventType = ProcessInstanceNodeEventBody.EVENT_TYPE_EXIT;

if (nodeInstance.getCancelType() != null) {
switch (nodeInstance.getCancelType()) {
case ABORTED:
eventType = ProcessInstanceNodeEventBody.EVENT_TYPE_ABORTED;
break;
case SKIPPED:
eventType = ProcessInstanceNodeEventBody.EVENT_TYPE_SKIPPED;
break;
case OBSOLETE:
eventType = ProcessInstanceNodeEventBody.EVENT_TYPE_OBSOLETE;
break;
case ERROR:
eventType = ProcessInstanceNodeEventBody.EVENT_TYPE_ERROR;
}
}

return toProcessInstanceNodeEvent((ProcessNodeLeftEvent) payload, eventType);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public DataEvent<?> adapt(Object payload) {
.userTaskDescription(event.getUserTaskInstance().getTaskDescription())
.userTaskPriority(priorityStr)
.userTaskReferenceName(event.getUserTask().getReferenceName())
.externalReferenceId(event.getUserTaskInstance().getExternalReferenceId())
.state(event.getNewStatus().getName())
.actualOwner(event.getUserTaskInstance().getActualOwner())
.eventType(isTransition(event) ? event.getNewStatus().getName() : "Modify")
Expand Down
Loading