collection

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsMultipleCandidates

func IsMultipleCandidates(e error) bool

func IsNotFound

func IsNotFound(e error) bool

func NewLookup

func NewLookup(ctx context.Context, uri string) (curatorial.Lookup, error)

NewLookup will return an `curatorial.Lookup` instance. By default the lookup table is derived from precompiled (embedded) data in `data/collection.json` by passing in `collection://` as the URI. It is also possible to create a new lookup table with the following URI options:

`collection://github`

This will cause the lookup table to be derived from the data stored at https://raw.githubusercontent.com/sfomuseum/go-sfomuseum-curatorial/main/data/collection.json. This might be desirable if there have been updates to the underlying data that are not reflected in the locally installed package's pre-compiled data.

`collection://iterator?uri={URI}&source={SOURCE}`

This will cause the lookup table to be derived, at runtime, from data emitted by a `whosonfirst/go-whosonfirst-iterate` instance. `{URI}` should be a valid `whosonfirst/go-whosonfirst-iterate/iterator` URI and `{SOURCE}` is one or more URIs for the iterator to process.

func NewLookupFromIterator

func NewLookupFromIterator(ctx context.Context, iterator_uri string, iterator_sources ...string) (curatorial.Lookup, error)

func NewLookupWithLookupFunc

func NewLookupWithLookupFunc(ctx context.Context, lookup_func CollectionLookupFunc) (curatorial.Lookup, error)

NewLookupWithLookupFunc will return an `curatorial.Lookup` instance derived by data compiled using `lookup_func`.

Types

type CollectionLookup

type CollectionLookup struct {
	curatorial.Lookup
}

func (*CollectionLookup) Append

func (l *CollectionLookup) Append(ctx context.Context, data interface{}) error

func (*CollectionLookup) Find

func (l *CollectionLookup) Find(ctx context.Context, code string) ([]interface{}, error)

type CollectionLookupFunc

type CollectionLookupFunc func(context.Context)

func NewLookupFuncWithCollection

func NewLookupFuncWithCollection(ctx context.Context, collection_list []*Object) CollectionLookupFunc

NewLookup will return an `CollectionLookupFunc` function instance that, when invoked, will populate an `curatorial.Lookup` instance with data stored in `collection_list`.

func NewLookupFuncWithReader

func NewLookupFuncWithReader(ctx context.Context, r io.ReadCloser) CollectionLookupFunc

NewLookup will return an `CollectionLookupFunc` function instance that, when invoked, will populate an `curatorial.Lookup` instance with data stored in `r`. `r` will be closed when the `CollectionLookupFunc` function instance is invoked. It is assumed that the data in `r` will be formatted in the same way as the procompiled (embedded) data stored in `data/sfomuseum.json`.

type MultipleCandidates

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

func (MultipleCandidates) Error

func (e MultipleCandidates) Error() string

func (MultipleCandidates) String

func (e MultipleCandidates) String() string

type NotFound

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

func (NotFound) Error

func (e NotFound) Error() string

func (NotFound) String

func (e NotFound) String() string

type Object

type Object struct {
	WhosOnFirstId   int64  `json:"wof:id"`
	Name            string `json:"wof:name"`
	SFOMuseumId     int64  `json:"sfomuseum:object_id"`
	AccessionNumber string `json:"sfomuseum:accession_number"`
	CallNumber      string `json:"sfomuseum:callnumber,omitempty"`
	IsCurrent       int64  `json:"mz:is_current"`
}

func CompileCollectionData

func CompileCollectionData(ctx context.Context, iterator_uri string, iterator_sources ...string) ([]*Object, error)

func FindCurrentObject

func FindCurrentObject(ctx context.Context, code string) (*Object, error)

Return the current Object matching 'code'. Multiple matches throw an error.

func FindCurrentObjectWithLookup

func FindCurrentObjectWithLookup(ctx context.Context, lookup curatorial.Lookup, code string) (*Object, error)

Return the current Object matching 'code' with a custom curatorial.Lookup instance. Multiple matches throw an error.

func FindObjectsCurrent

func FindObjectsCurrent(ctx context.Context, code string) ([]*Object, error)

Returns all Object instances matching 'code' that are marked as current.

func FindObjectsCurrentWithLookup

func FindObjectsCurrentWithLookup(ctx context.Context, lookup curatorial.Lookup, code string) ([]*Object, error)

Returns all Object instances matching 'code' that are marked as current with a custom curatorial.Lookup instance.

func (*Object) String

func (w *Object) String() string

Jump to

Keyboard shortcuts

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