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#1637] Add SLA due date to UserTaskInstanceStateEventBody #3792

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -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;

Expand Down Expand Up @@ -65,6 +66,8 @@ public interface UserTaskInstance {

Map<String, Object> getInputs();

Date getSlaDueDate();

void setInput(String key, Object value);

void setOutput(String key, Object value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public class UserTaskInstanceStateEventBody {

private String externalReferenceId;

private Date slaDueDate;

public Date getEventDate() {
return eventDate;
}
Expand Down Expand Up @@ -101,6 +103,10 @@ public String getExternalReferenceId() {
return externalReferenceId;
}

public Date getSlaDueDate() {
return slaDueDate;
}

public Map<String, Object> metaData() {
Map<String, Object> metadata = new HashMap<>();
metadata.put(UserTaskInstanceEventMetadata.USER_TASK_INSTANCE_ID_META_DATA, userTaskInstanceId);
Expand All @@ -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() {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public boolean accept(Object payload) {
public DataEvent<?> adapt(Object payload) {
UserTaskStateEvent event = (UserTaskStateEvent) payload;
Map<String, Object> metadata = AdapterHelper.buildUserTaskMetadata(event.getUserTaskInstance());

UserTaskInstanceStateEventBody.Builder builder = UserTaskInstanceStateEventBody.create()
.eventDate(new Date())
.eventUser(event.getEventUser())
Expand All @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public Optional<WorkItemTransition> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public class DefaultUserTaskInstance implements UserTaskInstance {
private List<Attachment> attachments;
private List<Comment> comments;
private String externalReferenceId;
private Date slaDueDate;

private Map<String, Object> inputs;
private Map<String, Object> outputs;
Expand Down Expand Up @@ -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<String, Object> data, IdentityProvider identity) {
transition(this.userTaskLifeCycle.startTransition(), data, identity);
Expand Down Expand Up @@ -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 + "]";
}

}
Loading