Class WorkflowBuilder<TSchemeMedium>
OptimaJet.Workflow.Core.Builder.WorkflowBuilder<TSchemeMedium>
Workflow builder that converts unparsed process schemes from TSchemeMedium into runtime ProcessDefinition instances.
Namespace: OptimaJet.Workflow.Core.Builder
public sealed class WorkflowBuilder<TSchemeMedium> : IWorkflowBuilder where TSchemeMedium : classType Hierarchy
- WorkflowBuilder<TSchemeMedium> Current type
- Implemented interfaces
Constructors
public WorkflowBuilder(IWorkflowGenerator<TSchemeMedium> generator, IWorkflowParser<TSchemeMedium> parser, ISchemePersistenceProvider<TSchemeMedium> schemePersistenceProvider) #Initializes a new workflow builder.
Parameters
Name
Type
Description
generatorIWorkflowGenerator<TSchemeMedium>The IWorkflowGenerator<TSchemeMedium> used to create unparsed scheme instances.
parserIWorkflowParser<TSchemeMedium>The IWorkflowParser<TSchemeMedium> that converts unparsed scheme media to ProcessDefinition.
schemePersistenceProviderISchemePersistenceProvider<TSchemeMedium>The ISchemePersistenceProvider<TSchemeMedium> used to load and save scheme media.
Properties
public WorkflowRuntime Runtime { get; set; } #Gets or sets the runtime used by this builder.
Methods
public Task<ProcessDefinition> GetProcessSchemeAsync(Guid schemeId) #Gets a parsed process scheme by scheme identifier.
Parameters
Name
Type
Description
schemeIdGuidIdentifier of the scheme to load.
Returns
Type
Description
Task<ProcessDefinition>The loaded ProcessDefinition.
public Task<ProcessDefinition> GetProcessSchemeAsync(string schemeCode, string? tenantId = null) #Gets a process scheme by code and tenant, creating it if it does not exist.
Parameters
Name
Type
Description
schemeCodeStringCode of the scheme.
tenantIdStringOptional tenant identifier. If not specified, a shared scheme is used.
Returns
Type
Description
Task<ProcessDefinition>The requested ProcessDefinition. If missing, a new scheme is generated, stored, and returned.
public Task<ProcessInstance> CreateNewProcessAsync(Guid processId, string schemeCode, string? tenantId) #Creates a new process instance object for the specified scheme code. If the scheme does not exist, the builder generates and stores it before creating the instance.
Parameters
Name
Type
Description
processIdGuidIdentifier for the new process instance.
schemeCodeStringCode of the scheme to instantiate.
tenantIdStringOptional tenant identifier that selects the exact tenant scheme. If not specified, a shared scheme is used.
Returns
Type
Description
Task<ProcessInstance>A new ProcessInstance.
public Task<ProcessInstance> CreateNewSubprocessAsync(Guid processId, ProcessInstance parentProcessInstance, TransitionDefinition startingTransition) #Creates a subprocess process instance for the transition from a parent process.
Parameters
Name
Type
Description
processIdGuidIdentifier for the new subprocess instance.
Returns
Type
Description
Task<ProcessInstance>A new subprocess ProcessInstance.
public Task<ProcessInstance> GetProcessInstanceAsync(Guid processId) #Gets an existing process instance by process identifier.
Parameters
Name
Type
Description
processIdGuidIdentifier of the process instance to load.
Returns
Type
Description
Task<ProcessInstance>The loaded ProcessInstance.
public Task<ProcessDefinition> CreateNewProcessSchemeAsync(string schemeCode, string? tenantId = null) #Generates a new process scheme, runs the registered build steps, and stores the resulting scheme.
Parameters
Name
Type
Description
schemeCodeStringCode of the scheme to create.
tenantIdStringOptional tenant identifier. If not specified, a shared scheme is used.
Returns
Type
Description
Task<ProcessDefinition>The generated ProcessDefinition.
public Task<ProcessDefinition> CreateNewSubprocessSchemeAsync(ProcessDefinition parentProcessScheme, TransitionDefinition startingTransition) #Creates and stores a parsed subprocess scheme for the given parent scheme and transition.
Parameters
Name
Type
Description
parentProcessSchemeProcessDefinitionThe parent ProcessDefinition from which the subprocess is derived.
Returns
Type
Description
Task<ProcessDefinition>The parsed subprocess ProcessDefinition.
public void SetCache(IParsedProcessCache cache) #Configures a cache for parsed ProcessDefinition instances.
Parameters
Name
Type
Description
public void RemoveCache() #Clears and disables the parsed process definition cache.
public Task SetSchemeIsObsoleteAsync(string schemeCode, string? tenantId = null) #Marks schemes with the specified code as obsolete.
Parameters
Name
Type
Description
schemeCodeStringCode of the scheme.
tenantIdStringTenant id of the scheme. If null, marks schemes with the specified code obsolete in all tenants.
Returns
Type
Description
Taskpublic Task<ProcessDefinition> GetProcessSchemeForDesignerAsync(string code, string? tenantId = null) #Gets a parsed process scheme from the persistence store by code for designer operations.
Parameters
Name
Type
Description
codeStringCode of the scheme.
tenantIdStringOptional tenant identifier.
Returns
Type
Description
Task<ProcessDefinition>The loaded ProcessDefinition.
public Task<(bool success, List<string>? errors, string? failedStep)> SaveProcessSchemeAsync(string schemeCode, ProcessDefinition pd) #Runs the registered build steps on a clone of the process definition to validate it and determine its inline scheme dependencies, then saves the supplied definition when validation succeeds.
Parameters
Name
Type
Description
schemeCodeStringCode of the scheme.
Returns
Type
Description
Task<Boolean, String, String>A tuple containing:
success is true when validation succeeds; errors contains validation messages when validation fails; failedStep contains the name of the build step that failed, if any.public Task<(List<string>? codes, List<string>? errors, string? failedStep)> GetInlineSchemesAsync(ProcessDefinition pd) #Runs the registered build steps on a clone of the process definition and gets the codes represented by the resulting inlined activities.
Parameters
Name
Type
Description
Returns
Type
Description
Task<String, String, String>A tuple containing:
codes list of inlined scheme codes, errors validation errors when build steps fail, and failedStep the failing build step name.[Obsolete("Do not use this API. It was used only by the deprecated Assignment plugin and will be removed soon.")] public Task UpsertProcessInstanceScheme(ProcessDefinition pd) Obsolete #Executes build steps and upserts the parsed scheme into the persistence store.
Parameters
Name
Type
Description
pdProcessDefinitionReturns
Type
Description
Task[Obsolete("Do not use this API. It was used only by the deprecated Assignment plugin and will be removed soon.")] public void RemoveSchemeFromCache(Guid schemeId) Obsolete #Removes a parsed process definition from the cache by scheme identifier.
Parameters
Name
Type
Description
schemeIdGuidIdentifier of the scheme cache entry to remove.
public ProcessDefinition Parse(string scheme, SchemeParsingType schemeParsingType = SchemeParsingType.Strict) #Parses a raw scheme string into a ProcessDefinition.
Parameters
Name
Type
Description
schemeStringRaw scheme content to parse.
schemeParsingTypeSchemeParsingTypeParse mode. Use SchemeParsingType.Soft only for relaxed validation.
Returns
Type
Description
ProcessDefinitionThe parsed ProcessDefinition.
public string Serialize(ProcessDefinition processDefinition) #Serializes a process definition into raw scheme text.
Parameters
Name
Type
Description
Returns
Type
Description
StringString representation of the unparsed scheme.
public void AddSystemBuildStepAtTheEnd(BuildStep step, int startOrder = 0, int endOrder = 1000) #Adds a system build step after the highest existing system step in the specified search range.
Parameters
Name
Type
Description
startOrderInt32The order used when the search range contains no existing system steps.
endOrderInt32The exclusive upper bound of the range searched for existing system steps.
public void AddBuildStepAtTheEnd(BuildStep step) #Adds a build step after all existing build steps.
Parameters
Name
Type
Description
public void AddBuildStep(int order, BuildStepPosition buildStepPosition, BuildStep step) #Adds a build step at the specified position and order.
Parameters
Name
Type
Description
orderInt32Order value used to sort build-step execution.
public bool ContainsBuildStep(string name) #Determines whether a build step with the specified name is already registered.
Parameters
Name
Type
Description
nameStringName of the build step to check.
Returns
Type
Description
Booleantrue when a build step with this name exists.
public Task<List<string>> GetInlinedSchemeCodesAsync(string? tenantId = null) #Gets codes of schemes that may be inlined by other schemes.
Parameters
Name
Type
Description
tenantIdStringOptional tenant identifier. If specified, both shared and tenant-specific schemes are returned. If omitted, only shared schemes are returned.
Returns
Type
Description
Task<String>The list of scheme codes.
public Task<Dictionary<string, ParameterDefinition[]>> GetInlinedSchemeParametersAsync(string? tenantId = null) #Gets inlined scheme parameters by scheme code.
Parameters
Name
Type
Description
tenantIdStringOptional tenant identifier. If specified, both shared and tenant-specific schemes are resolved. If omitted, only shared schemes are included.
Returns
Type
Description
Task<String, ParameterDefinition[]>A dictionary keyed by scheme code containing non-system parameters for each inlined scheme.
public Task<ProcessDefinition> GenerateProcessDefinitionAsync(string schemeCode, string? tenantId = null) #Generates and parses a process definition without reading or writing persistence, using the cache, or executing build steps.
Parameters
Name
Type
Description
schemeCodeStringCode of the scheme to generate.
tenantIdStringOptional tenant identifier.
Returns
Type
Description
Task<ProcessDefinition>The generated ProcessDefinition.
public Task AddSchemeTagsAsync(string schemeCode, IEnumerable<string> tags) #Adds tags to the shared scheme with the specified code.
Parameters
Name
Type
Description
schemeCodeStringCode of the shared scheme.
tagsIEnumerable<String>Tags to add.
Returns
Type
Description
Taskpublic Task AddSchemeTagsAsync(string schemeCode, string? tenantId, IEnumerable<string> tags) #Adds tags to a scheme in the exact tenant scope. If tenantId is null, updates only the shared scheme.
Parameters
Name
Type
Description
schemeCodeStringCode of the scheme.
tenantIdStringTenant identifier or
null for shared scope.tagsIEnumerable<String>Tags to add.
Returns
Type
Description
Taskpublic Task RemoveSchemeTagsAsync(string schemeCode, IEnumerable<string> tags) #Removes tags from the shared scheme with the specified code.
Parameters
Name
Type
Description
schemeCodeStringCode of the shared scheme.
tagsIEnumerable<String>Tags to remove.
Returns
Type
Description
Taskpublic Task RemoveSchemeTagsAsync(string schemeCode, string? tenantId, IEnumerable<string> tags) #Removes tags from a scheme in the exact tenant scope. If tenantId is null, updates only the shared scheme.
Parameters
Name
Type
Description
schemeCodeStringCode of the scheme.
tenantIdStringTenant identifier or
null for shared scope.tagsIEnumerable<String>Tags to remove.
Returns
Type
Description
Taskpublic Task SetSchemeTagsAsync(string schemeCode, IEnumerable<string> tags) #Replaces tags for the shared scheme with the specified code.
Parameters
Name
Type
Description
schemeCodeStringCode of the shared scheme.
tagsIEnumerable<String>Tags to set.
Returns
Type
Description
Taskpublic Task SetSchemeTagsAsync(string schemeCode, string? tenantId, IEnumerable<string> tags) #Replaces tags for a scheme in the exact tenant scope. If tenantId is null, updates only the shared scheme.
Parameters
Name
Type
Description
schemeCodeStringCode of the scheme.
tenantIdStringTenant identifier or
null for shared scope.tagsIEnumerable<String>Tags to set.
Returns
Type
Description
Taskpublic Task<List<string>> SearchSchemesByTagsAsync(IEnumerable<string>? tags) #Gets shared scheme codes matching a tag list.
Parameters
Name
Type
Description
tagsIEnumerable<String>Optional tags to filter schemes. If
null, returns all shared scheme codes.Returns
Type
Description
Task<String>Codes of matching shared schemes.
public Task<List<string>> SearchSchemesByTagsAsync(string? tenantId, IEnumerable<string>? tags) #Gets scheme codes in a tenant scope matching a tag list.
Parameters
Name
Type
Description
tenantIdStringTenant identifier. If
null, only shared schemes are searched.tagsIEnumerable<String>Optional tags to filter schemes. If
null, all codes in scope are returned.Returns
Type
Description
Task<String>Codes of matching schemes in the specified scope.