Documentation
¶
Overview ¶
Package sfgarules holds the SFGAMapper — hive's implementation of gsvalidator's SchemaMapper and joins.PrimaryKeyProvider interfaces for the sfga schema (col__ / gn__ / sf__ prefixes, col__id as the primary key across every table). The package name is a legacy of when it also carried sfga-specific Go validators; those have all been decomposed into JSON rules that use gsvalidator's generic mechanisms.
Index ¶
- type SFGAMapper
- func (m *SFGAMapper) GetFieldName(tableName, logicalName string) string
- func (m *SFGAMapper) GetPrimaryKeyField(tableName string) string
- func (m *SFGAMapper) GetTableName(logicalName string) string
- func (m *SFGAMapper) LoadAllRecords(ctx context.Context, db *sql.DB, tableName string) ([]map[string]interface{}, error)
- func (m *SFGAMapper) LoadRecord(ctx context.Context, db *sql.DB, tableName, id string) (map[string]interface{}, error)
- func (m *SFGAMapper) LoadRelatedRecords(ctx context.Context, db *sql.DB, tableName, foreignKey, id string) ([]map[string]interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SFGAMapper ¶
type SFGAMapper struct {
// contains filtered or unexported fields
}
SFGAMapper implements gsvalidator's SchemaMapper interface for the sfga schema. Handles sfga's prefix conventions (col__ columns, gn__ GlobalNames cache, sf__ species-file fields) and the archive-wide col__id primary-key convention.
A truly generic gsvalidator reads relations from a bundle's `relations` block rather than requiring a Go-hardcoded mapper. This mapper stays until that loader lands.
func NewSFGAMapper ¶
func NewSFGAMapper() *SFGAMapper
NewSFGAMapper creates a new SFGA schema mapper.
func (*SFGAMapper) GetFieldName ¶
func (m *SFGAMapper) GetFieldName(tableName, logicalName string) string
GetFieldName resolves logical field name to physical field name. For SFGA, most fields have the col__ prefix.
func (*SFGAMapper) GetPrimaryKeyField ¶
func (m *SFGAMapper) GetPrimaryKeyField(tableName string) string
GetPrimaryKeyField returns the primary-key column name for a given SFGA table. Most sfga tables use col__id, but a handful of pure link / annotation tables (vernacular, distribution, species_interaction, name_relation) have no col__id column — sfga identifies rows there by a composite of their FK / value tuple. Hive uses SQLite's implicit rowid as the opaque handle for those tables so gsvalidator's per-record lookup has an addressable column to bind against.
func (*SFGAMapper) GetTableName ¶
func (m *SFGAMapper) GetTableName(logicalName string) string
GetTableName resolves logical table name to physical table name. For SFGA, table names are typically unprefixed (e.g., "name", "taxon").
func (*SFGAMapper) LoadAllRecords ¶
func (m *SFGAMapper) LoadAllRecords(ctx context.Context, db *sql.DB, tableName string) ([]map[string]interface{}, error)
LoadAllRecords loads all records from a table.
func (*SFGAMapper) LoadRecord ¶
func (m *SFGAMapper) LoadRecord(ctx context.Context, db *sql.DB, tableName, id string) (map[string]interface{}, error)
LoadRecord loads a record by table name and ID.
func (*SFGAMapper) LoadRelatedRecords ¶
func (m *SFGAMapper) LoadRelatedRecords(ctx context.Context, db *sql.DB, tableName, foreignKey, id string) ([]map[string]interface{}, error)
LoadRelatedRecords loads related records via foreign key.