Skip to content

Commit

Permalink
Merge branch '7.67.x' into 7.67.x_JBPM-10088
Browse files Browse the repository at this point in the history
  • Loading branch information
fjtirado committed Jan 9, 2024
2 parents 6218b86 + f4e97f6 commit d3e2b96
Show file tree
Hide file tree
Showing 15 changed files with 1,601 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public static class ProcessJobContext implements JobContext {
private JobHandle jobHandle;
private Long sessionId;

private boolean newTimer;
private boolean isNew;

public ProcessJobContext(final TimerInstance timer, final Trigger trigger, final Long processInstanceId,
final InternalKnowledgeRuntime kruntime) {
Expand All @@ -408,17 +408,17 @@ public ProcessJobContext(final TimerInstance timer, final Trigger trigger, final
this.processInstanceId = processInstanceId;
this.kruntime = kruntime;
this.sessionId = timer.getSessionId();
this.newTimer = true;
this.isNew = true;
}

public ProcessJobContext(final TimerInstance timer, final Trigger trigger, final Long processInstanceId,
final InternalKnowledgeRuntime kruntime, boolean newTimer) {
final InternalKnowledgeRuntime kruntime, boolean isNew) {
this.timer = timer;
this.trigger = trigger;
this.processInstanceId = processInstanceId;
this.kruntime = kruntime;
this.sessionId = timer.getSessionId();
this.newTimer = newTimer;
this.isNew = isNew;
}

public Long getProcessInstanceId() {
Expand Down Expand Up @@ -457,9 +457,10 @@ public void setKnowledgeRuntime(InternalKnowledgeRuntime kruntime) {
public InternalWorkingMemory getWorkingMemory() {
return kruntime instanceof InternalWorkingMemory ? (InternalWorkingMemory)kruntime : null;
}

public boolean isNewTimer() {
return newTimer;

@Override
public boolean isNew() {
return isNew;
}
}

Expand Down Expand Up @@ -493,7 +494,7 @@ public void setParamaeters(Map<String, Object> paramaeters) {
}

@Override
public boolean isNewTimer() {
public boolean isNew() {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ public void removeEventListeners() {
}

@Override
protected void triggerCompleted(String type, boolean remove) {
if (this.slaCompliance == org.kie.api.runtime.process.ProcessInstance.SLA_PENDING) {
if (System.currentTimeMillis() > slaDueDate.getTime()) {
protected void triggerCompleted(String type, boolean remove) {
if (this.slaCompliance == org.kie.api.runtime.process.ProcessInstance.SLA_PENDING) {
if (System.currentTimeMillis() > slaDueDate.getTime()) {
// completion of the node instance is after expected SLA due date, mark it accordingly
this.slaCompliance = org.kie.api.runtime.process.ProcessInstance.SLA_VIOLATED;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,15 @@ public void setPersistenceContext(TaskPersistenceContext persistenceContext) {
this.persistenceContext = persistenceContext;
}

public void scheduleNew(long taskId, long deadlineId, long delay, DeadlineType type) {
schedule(taskId, deadlineId, delay, type, true);
}

public void schedule(long taskId, long deadlineId, long delay, DeadlineType type) {
schedule(taskId, deadlineId, delay, type, false);
}

public void schedule(long taskId, long deadlineId, long delay, DeadlineType type, boolean isNew) {
Task task = persistenceContext.findTask(taskId);
String deploymentId = task.getTaskData().getDeploymentId();

Expand All @@ -99,7 +106,7 @@ public void schedule(long taskId, long deadlineId, long delay, DeadlineType type
0,
null,
null ) ;
JobHandle handle = timerService.scheduleJob(deadlineJob, new TaskDeadlineJobContext(deadlineJob.getId(), task.getTaskData().getProcessInstanceId(), deploymentId), trigger);
JobHandle handle = timerService.scheduleJob(deadlineJob, new TaskDeadlineJobContext(deadlineJob.getId(), task.getTaskData().getProcessInstanceId(), deploymentId, isNew), trigger);
jobHandles.put(deadlineJob.getId(), handle);

} else {
Expand Down Expand Up @@ -363,13 +370,24 @@ private static class TaskDeadlineJobContext implements NamedJobContext {
private String jobName;
private Long processInstanceId;
private String deploymentId;
private boolean isNew;

public TaskDeadlineJobContext(String jobName, Long processInstanceId, String deploymentId) {
this(jobName, processInstanceId, deploymentId, false);
}

public TaskDeadlineJobContext(String jobName, Long processInstanceId, String deploymentId, boolean isNew) {
this.jobName = jobName;
this.processInstanceId = processInstanceId;
this.deploymentId = deploymentId;
this.isNew = isNew;
}

@Override
public boolean isNew() {
return isNew;
}

@Override
public void setJobHandle(JobHandle jobHandle) {
this.jobHandle = jobHandle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public static void scheduleDeadlines(final List<? extends Deadline> deadlines, f
for (Deadline deadline : deadlines) {
if (Boolean.FALSE.equals(deadline.isEscalated())) {
Date date = deadline.getDate();
deadlineService.schedule(taskId, deadline.getId(), date.getTime() - now, type);
deadlineService.scheduleNew(taskId, deadline.getId(), date.getTime() - now, type);
}
}
}
Expand Down
Loading

0 comments on commit d3e2b96

Please sign in to comment.