oai

package
v0.0.0-...-0d6871a Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IndexBibsysAuthority

func IndexBibsysAuthority(res *ProcessedRecord, mrc marc.Record)

func IndexBibsysPublication

func IndexBibsysPublication(res *ProcessedRecord, mrc marc.Record)

Types

type DBRecord

type DBRecord struct {
	Source     string
	ID         string
	Data       []byte // gzipped XML
	NewData    []byte // gzipped XML
	CreatedAt  time.Time
	UpdatedAt  time.Time
	ArchivedAt time.Time
}

DBRecord represents an OAI record as it is stored in local DB.

type HarvestJob

type HarvestJob struct {
	Harvester
	JobName string
}

func (*HarvestJob) Name

func (h *HarvestJob) Name() string

func (*HarvestJob) Run

func (h *HarvestJob) Run(ctx context.Context, w io.Writer) error

type HarvestPublishersJob

type HarvestPublishersJob struct {
	DB *sqlitex.Pool
}

func (*HarvestPublishersJob) Name

func (h *HarvestPublishersJob) Name() string

func (*HarvestPublishersJob) Run

type Harvester

type Harvester struct {
	DB       *sqlitex.Pool
	Endpoint string
	Source   string
	Set      string
	Prefix   string
	StartAt  time.Time
	Token    string
	Process  ProcessFunc
	Enqueue  bool // if true, don't overwrite data column, but set queued_at timestamp, and store data in new_data column
}

Harvester represents a OAI harvester, capable of harvesting records from a remote repository and sync to a local DB.

func (*Harvester) Name

func (h *Harvester) Name() string

func (*Harvester) Run

func (h *Harvester) Run(ctx context.Context, w io.Writer) error

func (*Harvester) UpdateRecords

func (h *Harvester) UpdateRecords(ctx context.Context, ids ...string) error

UpdateRecords fetches one or more records from remote repoistory and stores them in DB, either updating an exsisting record, or creating a new one.

type Indexer

type Indexer struct {
	DB          *sqlitex.Pool
	Source      string
	Process     ProcessFunc
	ResetQueued bool
}

TODO rename to IdentifierIndexer

func (*Indexer) Name

func (idx *Indexer) Name() string

func (*Indexer) Run

func (idx *Indexer) Run(ctx context.Context, w io.Writer) error

type ProcessFunc

type ProcessFunc func(RemoteRecord) (ProcessedRecord, error)

type ProcessedRecord

type ProcessedRecord struct {
	DBRecord

	// For search indexing:
	// TODO maybe remove these, not really needed except for testing now
	Type  string
	Label string

	// [0] = key (isbn/ismn/viaf), [1] = id
	Identifiers [][2]string
}

ProcessedRecord represent a OAI Record which has been processed extracting relevant information needed for storage in DB and indexing in search index.

func ProcessBibsys

func ProcessBibsys(rec RemoteRecord) (ProcessedRecord, error)

type Publisher

type Publisher struct {
	ID           string
	Name         string
	FullName     string
	AltName      string
	WWW          string
	ISBNPrefixes []string
	Notes        []string
	CreatedAt    string
	UpdatedAt    string
}

Publisher is a entry in NB isbn publisher database (https://nb.no/isbnforlag) Not an oai source, but we store it as oai records for now. TODO consider expanding oai db to handle all externally data sources which are kept in sync locally

func (Publisher) Resource

func (p Publisher) Resource() sirkulator.Resource

type Record

type Record struct {
	Source string
	ID     string
	Data   marc.Record
}

type RemoteRecord

type RemoteRecord struct {
	Header struct {
		Status     string    `xml:"status,attr"`
		Identifier string    `xml:"identifier"`
		Datestamp  time.Time `xml:"datestamp"`
	} `xml:"header"`
	Metadata []byte `xml:",innerxml"` // marcxml
}

RemoteRecord represents a OAI record retrieved from an OAI/PMH repository.

Jump to

Keyboard shortcuts

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