exporter

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package exporter provides data export capabilities for genealogy data. Supports JSON and CSV formats with streaming output to io.Writer.

Index

Constants

This section is empty.

Variables

View Source
var AvailableAttributeFields = map[string]bool{
	"id":         true,
	"person_id":  true,
	"fact_type":  true,
	"value":      true,
	"date":       true,
	"place":      true,
	"version":    true,
	"created_at": true,
}

AvailableAttributeFields lists all fields that can be exported for attributes.

View Source
var AvailableCitationFields = map[string]bool{
	"id":             true,
	"source_id":      true,
	"source_title":   true,
	"fact_type":      true,
	"fact_owner_id":  true,
	"page":           true,
	"volume":         true,
	"source_quality": true,
	"informant_type": true,
	"evidence_type":  true,
	"quoted_text":    true,
	"analysis":       true,
	"version":        true,
	"created_at":     true,
}

AvailableCitationFields lists all fields that can be exported for citations.

View Source
var AvailableEventFields = map[string]bool{
	"id":              true,
	"owner_type":      true,
	"owner_id":        true,
	"fact_type":       true,
	"date":            true,
	"place":           true,
	"description":     true,
	"cause":           true,
	"age":             true,
	"research_status": true,
	"version":         true,
	"created_at":      true,
}

AvailableEventFields lists all fields that can be exported for events.

View Source
var AvailableFamilyFields = map[string]bool{
	"id":                true,
	"partner1_id":       true,
	"partner1_name":     true,
	"partner2_id":       true,
	"partner2_name":     true,
	"relationship_type": true,
	"marriage_date":     true,
	"marriage_place":    true,
	"child_count":       true,
	"version":           true,
	"updated_at":        true,
}

AvailableFamilyFields lists all fields that can be exported for families.

View Source
var AvailablePersonFields = map[string]bool{
	"id":          true,
	"given_name":  true,
	"surname":     true,
	"full_name":   true,
	"gender":      true,
	"birth_date":  true,
	"birth_place": true,
	"death_date":  true,
	"death_place": true,
	"notes":       true,
	"version":     true,
	"updated_at":  true,
}

AvailablePersonFields lists all fields that can be exported for persons.

View Source
var AvailableSourceFields = map[string]bool{
	"id":              true,
	"source_type":     true,
	"title":           true,
	"author":          true,
	"publisher":       true,
	"publish_date":    true,
	"url":             true,
	"repository_name": true,
	"collection_name": true,
	"call_number":     true,
	"notes":           true,
	"citation_count":  true,
	"version":         true,
	"updated_at":      true,
}

AvailableSourceFields lists all fields that can be exported for sources.

View Source
var DefaultAttributeFields = []string{
	"id",
	"person_id",
	"fact_type",
	"value",
	"date",
	"place",
}

DefaultAttributeFields are the default fields exported for attributes.

View Source
var DefaultCitationFields = []string{
	"id",
	"source_title",
	"fact_type",
	"fact_owner_id",
	"page",
	"source_quality",
	"evidence_type",
}

DefaultCitationFields are the default fields exported for citations.

View Source
var DefaultEventFields = []string{
	"id",
	"owner_type",
	"owner_id",
	"fact_type",
	"date",
	"place",
	"description",
}

DefaultEventFields are the default fields exported for events.

View Source
var DefaultFamilyFields = []string{
	"id",
	"partner1_name",
	"partner2_name",
	"relationship_type",
	"marriage_date",
	"marriage_place",
	"child_count",
}

DefaultFamilyFields are the default fields exported for families.

View Source
var DefaultPersonFields = []string{
	"id",
	"given_name",
	"surname",
	"gender",
	"birth_date",
	"birth_place",
	"death_date",
	"death_place",
}

DefaultPersonFields are the default fields exported for persons.

View Source
var DefaultSourceFields = []string{
	"id",
	"source_type",
	"title",
	"author",
	"publisher",
	"publish_date",
	"url",
	"citation_count",
}

DefaultSourceFields are the default fields exported for sources.

Functions

This section is empty.

Types

type DataExporter

type DataExporter struct {
	// contains filtered or unexported fields
}

DataExporter implements the Exporter interface with JSON and CSV support.

func NewDataExporter

func NewDataExporter(readStore repository.ReadModelStore) *DataExporter

NewDataExporter creates a new data exporter.

func (*DataExporter) Export

func (e *DataExporter) Export(ctx context.Context, w io.Writer, opts ExportOptions) (*ExportResult, error)

Export writes data according to the specified options.

type EntityType

type EntityType string

EntityType specifies the type of entity to export.

const (
	EntityTypePersons    EntityType = "persons"
	EntityTypeFamilies   EntityType = "families"
	EntityTypeSources    EntityType = "sources"
	EntityTypeCitations  EntityType = "citations"
	EntityTypeEvents     EntityType = "events"
	EntityTypeAttributes EntityType = "attributes"
	EntityTypeAll        EntityType = "all" // JSON only: exports complete tree
)

type ExportOptions

type ExportOptions struct {
	// Format specifies the output format (json or csv).
	Format Format

	// EntityType specifies what to export.
	// For CSV: must be either "persons" or "families".
	// For JSON: can also be "all" for complete tree export.
	EntityType EntityType

	// Fields specifies which fields to include (CSV only).
	// If empty, default fields are used.
	Fields []string
}

ExportOptions configures an export operation.

type ExportResult

type ExportResult struct {
	BytesWritten       int64
	PersonsExported    int
	FamiliesExported   int
	SourcesExported    int
	CitationsExported  int
	EventsExported     int
	AttributesExported int
}

ExportResult contains statistics from an export operation.

type Exporter

type Exporter interface {
	// Export writes data to the given writer according to the options.
	Export(ctx context.Context, w io.Writer, opts ExportOptions) (*ExportResult, error)
}

Exporter provides data export functionality.

type Format

type Format string

Format specifies the export output format.

const (
	FormatJSON Format = "json"
	FormatCSV  Format = "csv"
)

type TreeExport

type TreeExport struct {
	Persons    []repository.PersonReadModel    `json:"persons"`
	Families   []repository.FamilyReadModel    `json:"families"`
	Sources    []repository.SourceReadModel    `json:"sources,omitempty"`
	Citations  []repository.CitationReadModel  `json:"citations,omitempty"`
	Events     []repository.EventReadModel     `json:"events,omitempty"`
	Attributes []repository.AttributeReadModel `json:"attributes,omitempty"`
}

TreeExport represents a complete family tree export in JSON format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL