feat: replace process definition graphs when no instance is running
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -6,6 +6,12 @@ import java.util.Optional;
|
||||
/** Public entry point for definition registration and approval operations. */
|
||||
public interface OrdoEngine {
|
||||
void register(ProcessDefinition definition);
|
||||
|
||||
/**
|
||||
* Inserts the definition, or replaces its entire graph when the id already exists.
|
||||
* Refuses replacement while any instance of this definition is {@code RUNNING}.
|
||||
*/
|
||||
void replace(ProcessDefinition definition);
|
||||
default ProcessInstance start(String definitionId, String initiator) {
|
||||
return start(definitionId, initiator, ProcessContext.empty());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.jetlumen.ordo.api.exception;
|
||||
|
||||
public final class DefinitionInUseException extends OrdoException {
|
||||
public DefinitionInUseException(String definitionId) {
|
||||
super("definition in use: " + definitionId);
|
||||
}
|
||||
}
|
||||
+7
-1
@@ -4,7 +4,7 @@ import com.jetlumen.ordo.api.ProcessDefinition;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/** Storage port for immutable process definitions. */
|
||||
/** Storage port for process definitions. */
|
||||
public interface ProcessDefinitionRepository {
|
||||
/**
|
||||
* Inserts the definition if no definition with the same id exists.
|
||||
@@ -13,5 +13,11 @@ public interface ProcessDefinitionRepository {
|
||||
*/
|
||||
boolean insertIfAbsent(ProcessDefinition definition);
|
||||
|
||||
/**
|
||||
* Inserts the definition, or replaces its name, steps, candidates and transitions
|
||||
* when the id already exists.
|
||||
*/
|
||||
void upsert(ProcessDefinition definition);
|
||||
|
||||
Optional<ProcessDefinition> findById(String definitionId);
|
||||
}
|
||||
|
||||
@@ -13,4 +13,6 @@ public interface ProcessInstanceRepository {
|
||||
void update(ProcessInstance instance);
|
||||
|
||||
Optional<ProcessInstance> findById(String instanceId);
|
||||
|
||||
boolean existsRunning(String definitionId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user