Skip to content
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
@@ -1,6 +1,8 @@
package com.netgrif.application.engine.workflow.domain.triggers;

import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeParseException;

/**
Expand All @@ -21,7 +23,15 @@ public class DateTimeTrigger extends TimeTrigger {
*/
public DateTimeTrigger(String timeString) throws DateTimeParseException {
super(timeString);
startDate = LocalDateTime.parse(timeString);
try {
startDate = LocalDateTime.parse(timeString);
} catch (DateTimeParseException e) {
OffsetDateTime offsetDateTime = OffsetDateTime.parse(timeString);
startInstant = offsetDateTime.toInstant();
startDate = offsetDateTime
.atZoneSameInstant(ZoneId.systemDefault())
.toLocalDateTime();
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import lombok.Getter;
import lombok.Setter;

import java.time.Instant;
import java.time.LocalDateTime;

public abstract class TimeTrigger extends Trigger {
Expand All @@ -11,6 +12,10 @@ public abstract class TimeTrigger extends Trigger {
@Setter
protected LocalDateTime startDate;

@Getter
@Setter
protected Instant startInstant;

@Getter
protected String timeString;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,15 +619,19 @@ void validateData(Transition transition, Case useCase) {
}
}

protected void scheduleTaskExecution(Task task, LocalDateTime time, Case useCase) {
log.info("[" + useCase.getStringId() + "]: Task " + task.getTitle() + " scheduled to run at " + time.toString());
protected void scheduleTaskExecution(Task task, TimeTrigger trigger, Case useCase) {
Date runAt = trigger.getStartInstant() != null
? Date.from(trigger.getStartInstant())
: DateUtils.localDateTimeToDate(trigger.getStartDate());
log.info("[{}]: Task {} scheduled to run at {}", useCase.getStringId(), task.getTitle(), runAt);
scheduler.schedule(() -> {
try {
executeTransition(task, useCase);
} catch (Exception e) {
log.info("[" + useCase.getStringId() + "]: Scheduled task [" + task.getTitle() + "] of case [" + useCase.getTitle() + "] could not be executed: " + e);
log.info("[{}]: Scheduled task [{}] of case [{}] could not be executed:", useCase.getStringId(),
task.getTitle(), useCase.getTitle(), e);
}
}, DateUtils.localDateTimeToDate(time));
}, runAt);
}

@Override
Expand Down Expand Up @@ -854,7 +858,7 @@ private Task createFromTransition(Transition transition, Case useCase) {

if (taskTrigger instanceof TimeTrigger) {
TimeTrigger timeTrigger = (TimeTrigger) taskTrigger;
scheduleTaskExecution(task, timeTrigger.getStartDate(), useCase);
scheduleTaskExecution(task, timeTrigger, useCase);
}
}
ProcessRole defaultRole = processRoleService.defaultRole();
Expand Down
16 changes: 15 additions & 1 deletion src/main/resources/petriNets/engine-processes/process.xml
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@
if (editIsAssigned) {
cancelTask("edit")
}
//Frontend.readOnlyBuilder()
Frontend.readOnlyBuilder()
]]>
</action>
</actions>
Expand Down Expand Up @@ -615,6 +615,20 @@
<appearance>outline</appearance>
</layout>
</dataRef>
<dataRef>
<id>xml_text</id>
<logic>
<behavior>hidden</behavior>
</logic>
<layout>
<x>0</x>
<y>4</y>
<rows>1</rows>
<cols>4</cols>
<template>material</template>
<appearance>outline</appearance>
</layout>
</dataRef>
</dataGroup>
</transition>
<transition>
Expand Down
Loading