Documentation
¶
Overview ¶
Package flowable 提供 Flowable ACT_* 表的行映射与 SQL 生成。
Index ¶
- Constants
- func ModelSourceName(modelID string, extra bool) string
- func Tables() []string
- func VariableValue(kind string, integer *int64, number *float64, text *string, data []byte) (any, error)
- type DB
- type HistoricActivityInstanceQuery
- type HistoricProcessInstanceQuery
- type HistoricSnapshot
- type HistoricTaskInstanceQuery
- type HistoricVariableInstanceQuery
- type IdentityBytes
- type IdentityInfo
- type IdentityMembership
- type IdentitySnapshot
- type IdentityUser
- type ModelRecord
- type Operation
- type ProcessInstanceQuery
- type QueryDB
- type Repository
- func (r *Repository) Apply(ctx context.Context, operations []Operation) error
- func (r *Repository) Delete(ctx context.Context, row Row) (int64, error)
- func (r *Repository) Insert(ctx context.Context, row Row) (int64, error)
- func (r *Repository) LoadAll(ctx context.Context) ([]Row, error)
- func (r *Repository) LoadAllByTenant(ctx context.Context, tenantID string) ([]Row, error)
- func (r *Repository) QueryHistoricActivityInstanceIDs(ctx context.Context, query HistoricActivityInstanceQuery) ([]string, int64, error)
- func (r *Repository) QueryHistoricProcessInstanceIDs(ctx context.Context, query HistoricProcessInstanceQuery) ([]string, int64, error)
- func (r *Repository) QueryHistoricTaskInstanceIDs(ctx context.Context, query HistoricTaskInstanceQuery) ([]string, int64, error)
- func (r *Repository) QueryHistoricVariableInstanceIDs(ctx context.Context, query HistoricVariableInstanceQuery) ([]string, int64, error)
- func (r *Repository) QueryProcessInstanceIDs(ctx context.Context, query ProcessInstanceQuery) ([]string, int64, error)
- func (r *Repository) QueryTaskIDs(ctx context.Context, query TaskQuery) ([]string, int64, error)
- func (r *Repository) ReplaceAll(ctx context.Context, rows []Row) error
- func (r *Repository) SupportsTransactions() bool
- func (r *Repository) Update(ctx context.Context, row Row, oldRevision int64) (int64, error)
- type Result
- type Row
- func (r *Row) Args() []any
- func (r *Row) Columns() []string
- func (r *Row) DeleteSQL(dialect string) (string, []any, error)
- func (r *Row) InsertSQL(dialect string) (string, []any, error)
- func (r *Row) Set(column string, value any) error
- func (r *Row) SetInsertColumns(columns []string) error
- func (r *Row) UpdateSQL(dialect string, oldRevision int64) (string, []any, error)
- type Rows
- type RuntimeExecution
- type RuntimeIdentityLink
- type RuntimeJob
- type RuntimeSnapshot
- type RuntimeSubscription
- type RuntimeTask
- type RuntimeVariable
- type SQLDB
- type Snapshot
- type Table
- type TaskQuery
- type Transaction
- type TransactionalDB
Constants ¶
const ( OperationInsert = "insert" // 插入 OperationUpdate = "update" // 更新 OperationDelete = "delete" // 删除 )
操作类型。
Variables ¶
This section is empty.
Functions ¶
func ModelSourceName ¶
ModelSourceName 返回模型源在 ACT_GE_BYTEARRAY 中的名称。 @param modelID 模型 ID @param extra 是否扩展源 @return 资源名称
Types ¶
type DB ¶
type DB interface {
// ExecContext 执行 SQL。
// @param ctx 上下文
// @param query SQL
// @param args 参数
// @return 结果
// @return 错误
ExecContext(ctx context.Context, query string, args ...any) (Result, error)
}
DB 是行写入接口。
type HistoricActivityInstanceQuery ¶
type HistoricActivityInstanceQuery struct {
ID string // 历史活动 ID
ProcessInstanceID string // 流程实例 ID
ProcessDefinitionID string // 流程定义 ID
ProcessDefinitionKey string // 流程定义 Key
ActivityID string // 活动 ID
ActivityName string // 活动名称
ActivityType string // 活动类型
Assignee string // 处理人
TenantID string // 租户,空表示不过滤
StartedAfter *time.Time // 开始时间下界,含边界
StartedBefore *time.Time // 开始时间上界,含边界
FinishedAfter *time.Time // 结束时间下界,含边界
FinishedBefore *time.Time // 结束时间上界,含边界
Finished *bool // 是否已结束,空表示不过滤
Start int // 偏移量
Size int // 每页数量
}
HistoricActivityInstanceQuery 是历史活动查询条件。 过滤字段只覆盖 ACT_HI_ACTINST 已持久化的列;模糊匹配过滤尚未下推。
type HistoricProcessInstanceQuery ¶
type HistoricProcessInstanceQuery struct {
ID string // 流程实例 ID
ProcessDefinitionID string // 流程定义 ID
ProcessDefinitionKey string // 流程定义 Key
BusinessKey string // 业务键
TenantID string // 租户,空表示不过滤
StartedAfter *time.Time // 开始时间下界,含边界
StartedBefore *time.Time // 开始时间上界,含边界
FinishedAfter *time.Time // 结束时间下界,含边界
FinishedBefore *time.Time // 结束时间上界,含边界
Finished *bool // 是否已结束,空表示不过滤
Start int // 偏移量
Size int // 每页数量
}
HistoricProcessInstanceQuery 是历史流程实例查询条件。 过滤字段只覆盖 ACT_HI_PROCINST 已持久化的列;名称与删除原因过滤尚未下推。
type HistoricSnapshot ¶
type HistoricSnapshot struct {
Processes []api.HistoricProcessInstance // 历史流程
Activities []api.HistoricActivityInstance // 历史活动
Tasks []api.HistoricTaskInstance // 历史任务
Variables []api.HistoricVariableInstance // 历史变量
Comments []api.Comment // 评论
Attachments []api.Attachment // 附件
Links []api.IdentityLink // 身份链接
Details []api.HistoricDetail // 变量明细
TaskLogs []api.HistoricTaskLog // 任务日志
}
HistoricSnapshot 是历史行恢复结果。
func DecodeHistoricRows ¶
func DecodeHistoricRows(rows []Row) (HistoricSnapshot, error)
DecodeHistoricRows 将历史行恢复为快照。 @param rows 行列表 @return 历史快照 @return 解析错误
type HistoricTaskInstanceQuery ¶
type HistoricTaskInstanceQuery struct {
ID string // 历史/任务 ID
Name string // 任务名称
Assignee string // 处理人
TaskDefinitionKey string // 任务定义 Key
ProcessInstanceID string // 流程实例 ID
ProcessDefinitionID string // 流程定义 ID
ProcessDefinitionKey string // 流程定义 Key
TenantID string // 租户,空表示不过滤
StartedAfter *time.Time // 开始时间下界,含边界
StartedBefore *time.Time // 开始时间上界,含边界
FinishedAfter *time.Time // 结束时间下界,含边界
FinishedBefore *time.Time // 结束时间上界,含边界
Finished *bool // 是否已结束,空表示不过滤
Start int // 偏移量
Size int // 每页数量
}
HistoricTaskInstanceQuery 是历史任务查询条件。 过滤字段只覆盖 ACT_HI_TASKINST 已持久化的列;模糊匹配过滤尚未下推。
type HistoricVariableInstanceQuery ¶
type HistoricVariableInstanceQuery struct {
ID string // 历史/变量 ID
Name string // 变量名
ProcessInstanceID string // 流程实例 ID
ExecutionID string // 执行 ID
TaskID string // 任务 ID
VariableType string // 变量类型
Start int // 偏移量
Size int // 每页数量
}
HistoricVariableInstanceQuery 是历史变量查询条件。 ACT_HI_VARINST 未持久化租户与流程定义列,租户与流程归属过滤由调用方在内存完成。
type IdentityBytes ¶
IdentityBytes 保存头像或 Go 身份控制的独立字节行。
type IdentityInfo ¶
type IdentityInfo struct {
ID string // 标准信息行标识
UserID string // 用户标识
Type string // 信息类型
Key string // 信息键
Value *string // 可空信息值
Password []byte // 账户密码数据
PasswordPresent bool // 密码列是否非空,包括零长度字节
ParentID string // 父信息标识
}
IdentityInfo 保存用户信息及用于拒绝未支持账户类型的原始属性。
type IdentityMembership ¶
IdentityMembership 表示标准成员表的真实两列主键。
type IdentitySnapshot ¶
type IdentitySnapshot struct {
Users []IdentityUser // 用户
Groups []api.Group // 组
Memberships []IdentityMembership // 成员关系
Infos []IdentityInfo // 信息
Bytes map[string]IdentityBytes // 字节行
}
IdentitySnapshot 汇总可独立校验引用的标准身份行。
func DecodeIdentityRows ¶
func DecodeIdentityRows(rows []Row) (IdentitySnapshot, error)
DecodeIdentityRows 解码标准身份列并拒绝重复主键,引用完整性由引擎统一检查。 @param rows 标准行集合 @return 身份快照 @return 列类型或重复标识错误
type IdentityUser ¶
IdentityUser 保存标准用户资料与头像字节行引用。
type ModelRecord ¶
ModelRecord 是流程模型元数据与源码。
type Operation ¶
Operation 是行操作。
func DiffOperations ¶
DiffOperations 计算新旧行快照的增量操作。 @param oldRows 旧行 @param newRows 新行 @return 操作列表
func SnapshotOperations ¶
SnapshotOperations 为整份快照生成"先删后插"操作。 @param rows 行列表 @return 操作列表
type ProcessInstanceQuery ¶
type ProcessInstanceQuery struct {
ID string // 流程实例 ID
ProcessDefinitionID string // 流程定义 ID
ProcessDefinitionKey string // 流程定义 Key
BusinessKey string // 业务键
TenantID string // 租户,空表示不过滤
Suspended *bool // 是否挂起,空表示不过滤
StartedAfter *time.Time // 开始时间下界,含边界
StartedBefore *time.Time // 开始时间上界,含边界
Start int // 偏移量
Size int // 每页数量
}
ProcessInstanceQuery 是运行时流程实例查询条件。 过滤字段只覆盖 ACT_RU_EXECUTION 已持久化的列;变量过滤尚未下推。
type QueryDB ¶
type QueryDB interface {
DB
// QueryContext 执行查询。
// @param ctx 上下文
// @param query SQL
// @param args 参数
// @return 结果集
// @return 错误
QueryContext(ctx context.Context, query string, args ...any) (Rows, error)
}
QueryDB 是支持查询的数据库。
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository 提供 ACT 行的插入、更新与删除。
func NewRepository ¶
func NewRepository(db DB, dialect string) (*Repository, error)
NewRepository 创建行仓储。 @param db 数据库 @param dialect 方言 @return 仓储 @return 创建错误
func (*Repository) Apply ¶
func (r *Repository) Apply(ctx context.Context, operations []Operation) error
Apply 在事务中执行一组行操作。 @param ctx 上下文 @param operations 操作列表 @return 执行错误
func (*Repository) LoadAll ¶
func (r *Repository) LoadAll(ctx context.Context) ([]Row, error)
LoadAll 读取全部支持表的行。 @param ctx 上下文 @return 行列表 @return 读取错误
func (*Repository) LoadAllByTenant ¶
LoadAllByTenant 读取指定租户的行。 @param ctx 上下文 @param tenantID 租户 @return 行列表 @return 读取错误
func (*Repository) QueryHistoricActivityInstanceIDs ¶
func (r *Repository) QueryHistoricActivityInstanceIDs(ctx context.Context, query HistoricActivityInstanceQuery) ([]string, int64, error)
QueryHistoricActivityInstanceIDs 按条件统计历史活动总数并分页返回活动 ID。 查询在 ACT_HI_ACTINST 上执行,返回顺序固定为开始时间升序、活动 ID 升序。 @param ctx 上下文 @param query 查询条件 @return 活动 ID 列表 @return 活动总数 @return 查询错误
func (*Repository) QueryHistoricProcessInstanceIDs ¶
func (r *Repository) QueryHistoricProcessInstanceIDs(ctx context.Context, query HistoricProcessInstanceQuery) ([]string, int64, error)
QueryHistoricProcessInstanceIDs 按条件统计历史实例总数并分页返回实例 ID。 查询在 ACT_HI_PROCINST 上执行,返回顺序固定为开始时间升序、实例 ID 升序。 @param ctx 上下文 @param query 查询条件 @return 实例 ID 列表 @return 实例总数 @return 查询错误
func (*Repository) QueryHistoricTaskInstanceIDs ¶
func (r *Repository) QueryHistoricTaskInstanceIDs(ctx context.Context, query HistoricTaskInstanceQuery) ([]string, int64, error)
QueryHistoricTaskInstanceIDs 按条件统计历史任务总数并分页返回任务 ID。 查询在 ACT_HI_TASKINST 上执行,返回顺序固定为开始时间升序、任务 ID 升序。 @param ctx 上下文 @param query 查询条件 @return 任务 ID 列表 @return 任务总数 @return 查询错误
func (*Repository) QueryHistoricVariableInstanceIDs ¶
func (r *Repository) QueryHistoricVariableInstanceIDs(ctx context.Context, query HistoricVariableInstanceQuery) ([]string, int64, error)
QueryHistoricVariableInstanceIDs 按条件统计历史变量总数并分页返回变量 ID。 查询在 ACT_HI_VARINST 上执行,返回顺序固定为变量名升序、变量 ID 升序。 @param ctx 上下文 @param query 查询条件 @return 变量 ID 列表 @return 变量总数 @return 查询错误
func (*Repository) QueryProcessInstanceIDs ¶
func (r *Repository) QueryProcessInstanceIDs(ctx context.Context, query ProcessInstanceQuery) ([]string, int64, error)
QueryProcessInstanceIDs 按条件统计运行中实例总数并分页返回实例 ID。 查询限定 ACT_RU_EXECUTION 的实例根行(PARENT_ID_ 为空),返回顺序固定为开始时间升序、实例 ID 升序。 @param ctx 上下文 @param query 查询条件 @return 实例 ID 列表 @return 实例总数 @return 查询错误
func (*Repository) QueryTaskIDs ¶
QueryTaskIDs 按条件统计任务总数并分页返回任务 ID。 查询在 ACT_RU_TASK 上执行,返回顺序固定为创建时间升序、ID 升序。 @param ctx 上下文 @param query 查询条件 @return 任务 ID 列表 @return 任务总数 @return 查询错误
func (*Repository) ReplaceAll ¶
func (r *Repository) ReplaceAll(ctx context.Context, rows []Row) error
ReplaceAll 在事务中替换整份快照。 @param ctx 上下文 @param rows 行列表 @return 替换错误
func (*Repository) SupportsTransactions ¶
func (r *Repository) SupportsTransactions() bool
SupportsTransactions 判断仓储是否能原子提交一条引擎命令。 @return 是否支持事务
type Result ¶
type Result interface {
// RowsAffected 返回影响行数。
// @return 影响行数
// @return 错误
RowsAffected() (int64, error)
}
Result 是 SQL 执行结果。
type Row ¶
type Row struct {
Table string // 表名
Values map[string]any // 列值
InsertColumns []string // 可选的自定义插入列
}
Row 是一行 ACT_* 数据。
func CommittedRows ¶
CommittedRows 计算成功提交后下一次差量所需的修订号基线。 @param previous 上次提交行 @param current 当前业务行 @return 已推进修订号的行集合
func FilterRowsByTenant ¶
FilterRowsByTenant 对全量或预过滤行按资源归属过滤,包括无租户列的关联表。 @param rows 待过滤行 @param tenantID 目标租户,空字符串只表示默认租户 @return 当前租户可见行
func PreserveSchemaRows ¶
PreserveSchemaRows 保留差量持久化不应删除的数据库系统属性。 @param previous 已加载行 @param current 当前业务行 @return 包含原系统属性的行集合
func (*Row) DeleteSQL ¶
DeleteSQL 生成按真实主键及可用修订号删除的语句。 @param dialect 数据库方言 @return SQL @return 参数 @return 错误
func (*Row) InsertSQL ¶
InsertSQL 生成 INSERT 语句。 @param dialect 数据库方言 @return SQL @return 参数 @return 错误
func (*Row) SetInsertColumns ¶
SetInsertColumns 设置插入列子集。 @param columns 列名 @return 错误
type Rows ¶
type Rows interface {
// Next 前进到下一行。
// @return 是否有下一行
Next() bool
// Scan 扫描当前行。
// @param dest 目标
// @return 扫描错误
Scan(dest ...any) error
// Close 关闭结果集。
// @return 关闭错误
Close() error
// Err 返回遍历错误。
// @return 遍历错误
Err() error
}
Rows 是查询结果集。
type RuntimeExecution ¶
type RuntimeExecution struct {
Name string // 实例根名称
StartUserID string // 实例发起人
BusinessStatus string // 业务状态
DueDate *time.Time // 实例截止时间
ClaimTime *time.Time // 实例签收时间
ClaimedBy string // 实例签收人
SuperExecutionID string // 父调用执行标识
CallbackID string // 回调标识
CallbackType string // 回调类型
ReferenceID string // 关联标识
ReferenceType string // 关联类型
PropagatedStageInstanceID string // 传播阶段标识
ID string // 执行 ID
ProcessInstanceID string // 流程实例 ID
DefinitionID string // 流程定义 ID
ParentID string // 父执行 ID
ActivityID string // 当前活动 ID
BusinessKey string // 业务键
TenantID string // 租户
StartTime time.Time // 开始时间
Active bool // 是否活跃
Concurrent bool // 是否并发
Scope bool // 是否作用域
EventScope bool // 是否事件作用域
MIRoot bool // 是否多实例根
Suspended bool // 是否挂起
}
RuntimeExecution 是运行时执行行。
type RuntimeIdentityLink ¶
type RuntimeIdentityLink struct {
ID string // 链接 ID
GroupID string // 组 ID
Type string // 类型
UserID string // 用户 ID
TaskID string // 任务 ID
ProcessInstanceID string // 实例 ID
ProcessDefinitionID string // 定义 ID
}
RuntimeIdentityLink 是运行时身份链接行。
type RuntimeJob ¶
type RuntimeJob struct {
ID string // 作业 ID
Type string // 作业类型
ExecutionID string // 执行 ID
ProcessInstanceID string // 实例 ID
DefinitionID string // 定义 ID
ActivityID string // 活动 ID
Retries int // 重试次数
Exception string // 异常
DueDate *time.Time // 到期时间
CreatedAt time.Time // 创建时间
TenantID string // 租户
RepeatRemaining int // 剩余重复次数
RepeatInfinite bool // 是否无限重复
IntervalMillis int64 // 重复间隔
DeadLetter bool // 是否死信
VariablePayload []byte // 异步变量作业的外置类型化载荷
}
RuntimeVariable 是运行时变量行。
type RuntimeSnapshot ¶
type RuntimeSnapshot struct {
Executions []RuntimeExecution // 执行
Tasks []RuntimeTask // 任务
Variables []RuntimeVariable // 变量
Jobs []RuntimeJob // 作业
DeadLetters []RuntimeJob // 死信作业
Subscriptions []RuntimeSubscription // 订阅
Links []RuntimeIdentityLink // 身份链接
}
RuntimeSnapshot 是运行时行恢复结果。
func DecodeRuntimeRows ¶
func DecodeRuntimeRows(rows []Row) (RuntimeSnapshot, error)
DecodeRuntimeRows 将运行时行恢复为快照。 @param rows 行列表 @return 运行时快照 @return 解析错误
type RuntimeSubscription ¶
type RuntimeSubscription struct {
ID string // 订阅 ID
EventType string // 事件类型
EventName string // 事件名
Condition string // 条件表达式(条件事件)
ExecutionID string // 执行 ID
ProcessInstanceID string // 实例 ID
ActivityID string // 活动 ID
CreatedAt time.Time // 创建时间
DefinitionID string // 定义 ID
ScopeType string // 作用域类型
ScopeDefinitionID string // 作用域定义 ID
ScopeDefinitionKey string // 作用域定义 Key
ScopeID string // 作用域执行 ID
SubScopeID string // 子作用域 ID
TenantID string // 租户
}
RuntimeSubscription 是事件订阅行。
type RuntimeTask ¶
type RuntimeTask struct {
ClaimTime *time.Time // 签收时间
DelegationState string // 委派状态
ID string // 任务 ID
ExecutionID string // 执行 ID
ProcessInstanceID string // 流程实例 ID
DefinitionID string // 流程定义 ID
Name string // 名称
Description string // 描述
TaskDefinitionKey string // 任务定义 Key
ParentTaskID string // 父任务 ID
Owner string // 所有者
Assignee string // 处理人
Category string // 分类
FormKey string // 表单 Key
TenantID string // 租户
Priority int // 优先级
CreateTime time.Time // 创建时间
DueDate *time.Time // 到期时间
Suspended bool // 是否挂起
}
RuntimeTask 是运行时任务行。
type RuntimeVariable ¶
type RuntimeVariable struct {
Bytes []byte // 外置字节数据
ByteArrayID string // 字节行引用
ID string // 变量 ID
Type string // 类型
Name string // 名称
ExecutionID string // 执行 ID
ProcessInstanceID string // 实例 ID
TaskID string // 任务 ID
Long *int64 // 长整型
Double *float64 // 浮点
Text *string // 文本
}
RuntimeVariable 是运行时变量行。
type SQLDB ¶
SQLDB 为真实数据库提供查询和命令级事务适配。
func (SQLDB) BeginTx ¶
func (d SQLDB) BeginTx(ctx context.Context) (Transaction, error)
BeginTx 开始一条命令的事务。 @param ctx 上下文 @return 事务 @return 创建错误
func (SQLDB) ExecContext ¶
ExecContext 执行语句。 @param ctx 上下文 @param query SQL @param args 参数 @return 执行结果 @return 执行错误
type Snapshot ¶
type Snapshot struct {
Deployments []api.Deployment // 部署
Resources map[string]map[string][]byte // 部署 ID 到资源
Definitions []api.ProcessDefinition // 流程定义
Models []ModelRecord // 流程模型
Properties map[string]string // 自定义属性
AttachmentContents map[string][]byte // 附件内容
}
Snapshot 是从 ACT 行恢复的仓库数据。
func DecodeRows ¶
DecodeRows 将 ACT 行恢复为部署、资源与流程定义。 @param rows 行列表 @return 仓库快照 @return 解析错误
type Table ¶
type Table struct {
PrimaryKeys []string // 复合主键列,非空时优先于单列主键
Name string // 表名
Columns []string // 列顺序
PrimaryKey string // 主键列,缺省为 ID_
}
Table 描述一张 ACT_* 表的列。
type TaskQuery ¶
type TaskQuery struct {
Assignee string // 处理人
Owner string // 所有者
DelegationState string // 委派状态
ProcessInstanceID string // 流程实例 ID
ProcessDefinitionKey string // 流程定义 Key
ParentTaskID string // 父任务 ID
TenantID string // 租户,空表示不过滤
CandidateUser string // 候选人
CandidateGroups []string // 候选组
Start int // 偏移量
Size int // 每页数量
}
TaskQuery 是运行时任务查询条件。
type Transaction ¶
type Transaction interface {
DB
// Commit 提交事务。
// @return 提交错误
Commit() error
// Rollback 回滚事务。
// @return 回滚错误
Rollback() error
}
Transaction 是数据库事务。
type TransactionalDB ¶
type TransactionalDB interface {
DB
// BeginTx 开始事务。
// @param ctx 上下文
// @return 事务
// @return 错误
BeginTx(ctx context.Context) (Transaction, error)
}
TransactionalDB 是支持事务的数据库。