backends

package
v1.0.36 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("record not found")

Functions

func NewDummyOrganization added in v1.0.35

func NewDummyOrganization(id string) *models.Organization

TODO remove this when we always have an uptodate db of organizations

func NewDummyPerson added in v1.0.35

func NewDummyPerson(id string) *models.Person

func NewDummyProject added in v1.0.35

func NewDummyProject(id string) *models.Project

Types

type BulkIndexer added in v1.0.22

type BulkIndexer[T any] interface {
	Index(context.Context, T) error
	Close(context.Context) error
}

type BulkIndexerConfig added in v1.0.22

type BulkIndexerConfig struct {
	OnError      func(error)
	OnIndexError func(string, error)
}

type DatasetGetter

type DatasetGetter interface {
	GetDataset(string) (*models.Dataset, error)
}

type DatasetIDIndex added in v1.0.35

type DatasetIDIndex interface {
	Search(*models.SearchArgs) (*models.SearchHits, error)
	Each(searchArgs *models.SearchArgs, maxSize int, cb func(string)) error
	Delete(id string) error
	DeleteAll() error
	WithScope(string, ...string) DatasetIDIndex
}

type DatasetIndex added in v1.0.35

type DatasetIndex interface {
	Search(*models.SearchArgs) (*models.DatasetHits, error)
	Each(searchArgs *models.SearchArgs, maxSize int, cb func(*models.Dataset)) error
	Delete(id string) error
	DeleteAll() error
	WithScope(string, ...string) DatasetIndex
}

func NewDatasetIndex added in v1.0.35

func NewDatasetIndex(di DatasetIDIndex, r Repository) DatasetIndex

type DatasetListExporter

type DatasetListExporter interface {
	GetContentType() string
	Add(*models.Dataset)
	Flush() error
}

type DatasetListExporterFactory

type DatasetListExporterFactory func(io.Writer) DatasetListExporter

type FileStore added in v1.0.26

type FileStore interface {
	Exists(context.Context, string) (bool, error)
	Get(context.Context, string) (io.ReadCloser, error)
	Add(context.Context, io.Reader, string) (string, error)
	Delete(context.Context, string) error
	DeleteAll(context.Context) error
}

type HandleService

type HandleService interface {
	UpsertHandle(string) (*models.Handle, error)
}

type IndexSwitcher added in v1.0.22

type IndexSwitcher[T any] interface {
	Index(context.Context, T) error
	Switch(context.Context) error
}

type LicenseSearchService

type LicenseSearchService interface {
	IndexAll() error
	SuggestLicenses(string) ([]models.Completion, error)
}

type MediaTypeSearchService

type MediaTypeSearchService interface {
	IndexAll() error
	SuggestMediaTypes(string) ([]models.Completion, error)
}

type Mutation added in v1.0.28

type Mutation struct {
	Op   string
	Args []string
}

type OrganizationSearchService

type OrganizationSearchService interface {
	SuggestOrganizations(string) ([]models.Completion, error)
}

type OrganizationService

type OrganizationService interface {
	GetOrganization(string) (*models.Organization, error)
}

type PersonSearchService

type PersonSearchService interface {
	SuggestPeople(string) ([]*models.Person, error)
}

type PersonService

type PersonService interface {
	GetPerson(string) (*models.Person, error)
}

type PersonWithOrganizationsService added in v1.0.35

type PersonWithOrganizationsService struct {
	PersonService       PersonService
	OrganizationService OrganizationService
}

func (*PersonWithOrganizationsService) GetPerson added in v1.0.35

type ProjectSearchService

type ProjectSearchService interface {
	SuggestProjects(string) ([]models.Completion, error)
}

type ProjectService

type ProjectService interface {
	GetProject(string) (*models.Project, error)
}

type PublicationDecoder

type PublicationDecoder interface {
	Decode(*models.Publication) error
}

type PublicationDecoderFactory

type PublicationDecoderFactory func(io.Reader) PublicationDecoder

type PublicationEncoder

type PublicationEncoder func(*models.Publication) ([]byte, error)

type PublicationGetter

type PublicationGetter interface {
	GetPublication(string) (*models.Publication, error)
}

type PublicationIDIndex added in v1.0.35

type PublicationIDIndex interface {
	Search(*models.SearchArgs) (*models.SearchHits, error)
	Each(searchArgs *models.SearchArgs, maxSize int, cb func(string)) error
	Delete(id string) error
	DeleteAll() error
	WithScope(string, ...string) PublicationIDIndex
}

type PublicationIndex added in v1.0.35

type PublicationIndex interface {
	Search(*models.SearchArgs) (*models.PublicationHits, error)
	Each(searchArgs *models.SearchArgs, maxSize int, cb func(*models.Publication)) error
	Delete(id string) error
	DeleteAll() error
	WithScope(string, ...string) PublicationIndex
}

func NewPublicationIndex added in v1.0.35

func NewPublicationIndex(di PublicationIDIndex, r Repository) PublicationIndex

type PublicationListExporter

type PublicationListExporter interface {
	GetContentType() string
	Add(*models.Publication)
	Flush() error
}

type PublicationListExporterFactory

type PublicationListExporterFactory func(io.Writer) PublicationListExporter

type Repository

type Repository interface {
	GetPublication(string) (*models.Publication, error)
	GetPublications([]string) ([]*models.Publication, error)
	SavePublication(*models.Publication, *models.User) error
	ImportPublication(*models.Publication) error
	UpdatePublication(string, *models.Publication, *models.User) error
	UpdatePublicationInPlace(*models.Publication) error
	MutatePublication(string, *models.User, ...Mutation) error
	PublicationsAfter(time.Time, int, int) (int, []*models.Publication, error)
	PublicationsBetween(time.Time, time.Time, func(*models.Publication) bool) error
	EachPublication(func(*models.Publication) bool) error
	EachPublicationSnapshot(func(*models.Publication) bool) error
	EachPublicationWithoutHandle(func(*models.Publication) bool) error
	PublicationHistory(string, func(*models.Publication) bool) error
	UpdatePublicationEmbargoes() (int, error)
	PurgeAllPublications() error
	PurgePublication(string) error
	GetDataset(string) (*models.Dataset, error)
	GetDatasets([]string) ([]*models.Dataset, error)
	ImportDataset(*models.Dataset) error
	SaveDataset(*models.Dataset, *models.User) error
	UpdateDataset(string, *models.Dataset, *models.User) error
	MutateDataset(string, *models.User, ...Mutation) error
	DatasetsAfter(time.Time, int, int) (int, []*models.Dataset, error)
	DatasetsBetween(time.Time, time.Time, func(*models.Dataset) bool) error
	EachDataset(func(*models.Dataset) bool) error
	EachDatasetSnapshot(func(*models.Dataset) bool) error
	EachDatasetWithoutHandle(func(*models.Dataset) bool) error
	DatasetHistory(string, func(*models.Dataset) bool) error
	UpdateDatasetEmbargoes() (int, error)
	PurgeAllDatasets() error
	PurgeDataset(string) error
	GetPublicationDatasets(*models.Publication) ([]*models.Dataset, error)
	GetVisiblePublicationDatasets(*models.User, *models.Publication) ([]*models.Dataset, error)
	GetDatasetPublications(*models.Dataset) ([]*models.Publication, error)
	GetVisibleDatasetPublications(*models.User, *models.Dataset) ([]*models.Publication, error)
	AddPublicationDataset(*models.Publication, *models.Dataset, *models.User) error
	RemovePublicationDataset(*models.Publication, *models.Dataset, *models.User) error
}

type SearchService added in v1.0.35

type SearchService interface {
	NewDatasetIndex(Repository) DatasetIndex
	NewDatasetBulkIndexer(BulkIndexerConfig) (BulkIndexer[*models.Dataset], error)
	NewDatasetIndexSwitcher(BulkIndexerConfig) (IndexSwitcher[*models.Dataset], error)
	NewPublicationIndex(Repository) PublicationIndex
	NewPublicationBulkIndexer(BulkIndexerConfig) (BulkIndexer[*models.Publication], error)
	NewPublicationIndexSwitcher(BulkIndexerConfig) (IndexSwitcher[*models.Publication], error)
}

type Services

type Services struct {
	ORCIDSandbox              bool
	ORCIDClient               *orcid.MemberClient
	Repository                Repository
	FileStore                 FileStore
	SearchService             SearchService
	DatasetSearchIndex        DatasetIndex
	PublicationSearchIndex    PublicationIndex
	OrganizationService       OrganizationService
	PersonService             PersonService
	ProjectService            ProjectService
	UserService               UserService
	OrganizationSearchService OrganizationSearchService
	PersonSearchService       PersonSearchService
	ProjectSearchService      ProjectSearchService
	UserSearchService         UserSearchService
	LicenseSearchService      LicenseSearchService
	MediaTypeSearchService    MediaTypeSearchService
	PublicationSources        map[string]PublicationGetter
	DatasetSources            map[string]DatasetGetter
	PublicationEncoders       map[string]PublicationEncoder
	PublicationDecoders       map[string]PublicationDecoderFactory
	PublicationListExporters  map[string]PublicationListExporterFactory
	DatasetListExporters      map[string]DatasetListExporterFactory
	HandleService             HandleService
}

type UserSearchService

type UserSearchService interface {
	SuggestUsers(string) ([]*models.Person, error)
}

type UserService

type UserService interface {
	GetUser(string) (*models.User, error)
	GetUserByUsername(string) (*models.User, error)
}

type UserWithOrganizationsService added in v1.0.35

type UserWithOrganizationsService struct {
	UserService         UserService
	OrganizationService OrganizationService
}

func (*UserWithOrganizationsService) GetUser added in v1.0.35

func (*UserWithOrganizationsService) GetUserByUsername added in v1.0.35

func (s *UserWithOrganizationsService) GetUserByUsername(username string) (*models.User, error)

Directories

Path Synopsis
TODO use fs.FS
TODO use fs.FS
TODO all mutating methods should call Validate() before saving
TODO all mutating methods should call Validate() before saving

Jump to

Keyboard shortcuts

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