feat: let initiators withdraw running process instances
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -24,6 +24,10 @@ public interface OrdoEngine {
|
||||
return reject(taskId, actor, null);
|
||||
}
|
||||
ApprovalTask reject(String taskId, String actor, String comment);
|
||||
default ProcessInstance withdraw(String instanceId, String actor) {
|
||||
return withdraw(instanceId, actor, null);
|
||||
}
|
||||
ProcessInstance withdraw(String instanceId, String actor, String comment);
|
||||
Optional<ProcessInstance> findInstance(String instanceId);
|
||||
Optional<ApprovalTask> findTask(String taskId);
|
||||
List<ApprovalTask> findTasks(String instanceId);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package com.jetlumen.ordo.api;
|
||||
|
||||
public enum ProcessStatus {
|
||||
RUNNING, APPROVED, REJECTED
|
||||
RUNNING, APPROVED, REJECTED, WITHDRAWN
|
||||
}
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.jetlumen.ordo.api.exception;
|
||||
|
||||
public final class InstanceAlreadyCompletedException extends OrdoException {
|
||||
public InstanceAlreadyCompletedException(String instanceId) {
|
||||
super("instance is already completed: " + instanceId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.jetlumen.ordo.api.exception;
|
||||
|
||||
public final class InstanceNotFoundException extends OrdoException {
|
||||
public InstanceNotFoundException(String instanceId) {
|
||||
super("instance not found: " + instanceId);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.jetlumen.ordo.api.exception;
|
||||
|
||||
public final class UnauthorizedInstanceOperationException extends OrdoException {
|
||||
public UnauthorizedInstanceOperationException(String instanceId, String actor) {
|
||||
super("actor '" + actor + "' is not the initiator for instance: " + instanceId);
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,11 @@ public interface ProcessInstanceRepository {
|
||||
Optional<ProcessInstance> findById(String instanceId);
|
||||
|
||||
boolean existsRunning(String definitionId);
|
||||
|
||||
/**
|
||||
* Completes the instance only if it is still running.
|
||||
*
|
||||
* @return true if the update was applied, false if the instance was missing or already terminal
|
||||
*/
|
||||
boolean completeIfRunning(ProcessInstance completed);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user