diff --git a/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstance.java b/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstance.java index 6fcdd84c6f0..2f9078be17e 100644 --- a/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstance.java +++ b/api/kogito-api/src/main/java/org/kie/kogito/usertask/UserTaskInstance.java @@ -19,6 +19,7 @@ package org.kie.kogito.usertask; import java.util.Collection; +import java.util.Date; import java.util.Map; import java.util.Set; @@ -65,6 +66,8 @@ public interface UserTaskInstance { Map getInputs(); + Date getSlaDueDate(); + void setInput(String key, Object value); void setOutput(String key, Object value); diff --git a/api/kogito-events-api/src/main/java/org/kie/kogito/event/usertask/UserTaskInstanceStateEventBody.java b/api/kogito-events-api/src/main/java/org/kie/kogito/event/usertask/UserTaskInstanceStateEventBody.java index ac4cfa7b9b0..8fb02ea8c4e 100644 --- a/api/kogito-events-api/src/main/java/org/kie/kogito/event/usertask/UserTaskInstanceStateEventBody.java +++ b/api/kogito-events-api/src/main/java/org/kie/kogito/event/usertask/UserTaskInstanceStateEventBody.java @@ -49,6 +49,8 @@ public class UserTaskInstanceStateEventBody { private String externalReferenceId; + private Date slaDueDate; + public Date getEventDate() { return eventDate; } @@ -101,6 +103,10 @@ public String getExternalReferenceId() { return externalReferenceId; } + public Date getSlaDueDate() { + return slaDueDate; + } + public Map metaData() { Map metadata = new HashMap<>(); metadata.put(UserTaskInstanceEventMetadata.USER_TASK_INSTANCE_ID_META_DATA, userTaskInstanceId); @@ -114,7 +120,7 @@ public String toString() { return "UserTaskInstanceStateEventBody [eventDate=" + eventDate + ", eventUser=" + eventUser + ", userTaskDefinitionId=" + userTaskDefinitionId + ", userTaskInstanceId=" + userTaskInstanceId + ", userTaskName=" + userTaskName + ", userTaskDescription=" + userTaskDescription + ", userTaskPriority=" + userTaskPriority + ", userTaskReferenceName=" + userTaskReferenceName - + ", state=" + state + ", actualOwner=" + actualOwner + ", processInstanceId=" + processInstanceId + "]"; + + ", state=" + state + ", actualOwner=" + actualOwner + ", processInstanceId=" + processInstanceId + ", slaDueDate=" + slaDueDate + "]"; } public Builder update() { @@ -215,6 +221,11 @@ public Builder processInstanceId(String processInstanceId) { return this; } + public Builder slaDueDate(Date slaDueDate) { + this.instance.slaDueDate = slaDueDate; + return this; + } + public UserTaskInstanceStateEventBody build() { return this.instance; } diff --git a/api/kogito-events-core/src/main/java/org/kie/kogito/event/impl/adapter/UserTaskStateEventDataEventAdapter.java b/api/kogito-events-core/src/main/java/org/kie/kogito/event/impl/adapter/UserTaskStateEventDataEventAdapter.java index 68ade25916e..9df94e473db 100644 --- a/api/kogito-events-core/src/main/java/org/kie/kogito/event/impl/adapter/UserTaskStateEventDataEventAdapter.java +++ b/api/kogito-events-core/src/main/java/org/kie/kogito/event/impl/adapter/UserTaskStateEventDataEventAdapter.java @@ -42,7 +42,6 @@ public boolean accept(Object payload) { public DataEvent adapt(Object payload) { UserTaskStateEvent event = (UserTaskStateEvent) payload; Map metadata = AdapterHelper.buildUserTaskMetadata(event.getUserTaskInstance()); - UserTaskInstanceStateEventBody.Builder builder = UserTaskInstanceStateEventBody.create() .eventDate(new Date()) .eventUser(event.getEventUser()) @@ -56,7 +55,8 @@ public DataEvent adapt(Object payload) { .state(event.getNewStatus().getName()) .actualOwner(event.getUserTaskInstance().getActualOwner()) .eventType(isTransition(event) ? event.getNewStatus().getName() : "Modify") - .processInstanceId((String) event.getUserTaskInstance().getMetadata().get("ProcessInstanceId")); + .processInstanceId((String) event.getUserTaskInstance().getMetadata().get("ProcessInstanceId")) + .slaDueDate(event.getUserTaskInstance().getSlaDueDate()); UserTaskInstanceStateEventBody body = builder.build(); UserTaskInstanceStateDataEvent utEvent = diff --git a/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java b/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java index 000e78a2d2c..02b46ecd56b 100644 --- a/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java +++ b/jbpm/jbpm-usertask-workitem/src/main/java/org/kie/kogito/jbpm/usertask/handler/UserTaskKogitoWorkItemHandler.java @@ -88,6 +88,7 @@ public Optional activateWorkItemHandler(KogitoWorkItemManage instance.setTaskName(ofNullable((String) workItem.getParameter(TASK_NAME)).orElse((String) workItem.getParameter(NODE_NAME))); instance.setTaskDescription((String) workItem.getParameter(DESCRIPTION)); instance.setTaskPriority(priority != null ? priority.toString() : null); + instance.setSlaDueDate(workItem.getNodeInstance().getSlaDueDate()); instance.setMetadata("ProcessId", workItem.getProcessInstance().getProcessId()); instance.setMetadata("ProcessType", workItem.getProcessInstance().getProcess().getType()); diff --git a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java index 26cfb631a8b..287b7b4fe8a 100644 --- a/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java +++ b/jbpm/jbpm-usertask/src/main/java/org/kie/kogito/usertask/impl/DefaultUserTaskInstance.java @@ -82,6 +82,7 @@ public class DefaultUserTaskInstance implements UserTaskInstance { private List attachments; private List comments; private String externalReferenceId; + private Date slaDueDate; private Map inputs; private Map outputs; @@ -242,6 +243,15 @@ public void setExternalReferenceId(String externalReferenceId) { this.externalReferenceId = externalReferenceId; } + @Override + public Date getSlaDueDate() { + return slaDueDate; + } + + public void setSlaDueDate(Date slaDueDate) { + this.slaDueDate = slaDueDate; + } + @Override public void initialize(Map data, IdentityProvider identity) { transition(this.userTaskLifeCycle.startTransition(), data, identity); @@ -782,7 +792,7 @@ private void reassign(Reassignment reassignment) { @Override public String toString() { return "DefaultUserTaskInstance [id=" + id + ", status=" + status + ", actualOwner=" + actualOwner + ", taskName=" + taskName + ", taskDescription=" + taskDescription + ", taskPriority=" - + taskPriority + "]"; + + taskPriority + ", slaDueDate=" + slaDueDate + "]"; } }