sift

package
v0.1.201 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2017 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package sift implements various filters, that help with the record labelling (ISIL) process. The filters are independent of the concrete type, since the interface has be changed to

type Filter interface {
    Apply(interface{}) bool
}

The filter implementation will type assert various interfaces. Any value (intermediate schema, SOLR record, MARC) that implements the various interfaces around records can be used here. What is left to the caller of this library is to implement the appropriate action upon result, e.g. add a certain value to a field or add a new subfield and so on.

Filters are composable and should allow for a wide variety of use cases.

The goal is to have a declarative way to describe, who wants to see what and to have this configuration autogenerated from some external source, like AMSL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AndFilter

type AndFilter struct {
	Filters []Filter `json:"and"`
}

AndFilter returns true, if all filters return true.

func (*AndFilter) Apply

func (f *AndFilter) Apply(v interface{}) bool

Apply checks, if a value belongs to a given collection.

func (*AndFilter) String

func (f *AndFilter) String() string

func (*AndFilter) UnmarshalJSON

func (f *AndFilter) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON unmarshals an and filter.

type AnyFilter

type AnyFilter struct {
	AnyFilter struct{} `json:"any"`
}

AnyFilter allows anything.

func (AnyFilter) Apply

func (AnyFilter) Apply(_ interface{}) bool

Apply just returns true.

type Collectioner

type Collectioner interface {
	Collections() []string
}

Collectioner returns a number of collections.

type CollectionsFilter

type CollectionsFilter struct {
	Collections struct {
		Fallback bool     `json:"fallback"`
		Values   []string `json:"values"`
	} `json:"collection"`
}

CollectionsFilter allows only values belonging to a given collection.

func (CollectionsFilter) Apply

func (f CollectionsFilter) Apply(v interface{}) bool

Apply checks, if a value belongs to a given collection.

func (CollectionsFilter) String

func (f CollectionsFilter) String() string

type DocumentObjectIdentifier

type DocumentObjectIdentifier interface {
	DOI() string
}

DocumentObjectIdentifier returns a single document object identifier as string.

type DocumentObjectIdentifiersFilter

type DocumentObjectIdentifiersFilter struct {
	DOI struct {
		Fallback bool     `json:"fallback"`
		Values   []string `json:"values"`
	} `json:"doi"`
}

DocumentObjectIdentifiersFilter filters by DOI.

func (DocumentObjectIdentifiersFilter) Apply

func (f DocumentObjectIdentifiersFilter) Apply(v interface{}) bool

Apply checks, if a value belongs to a given collection.

func (DocumentObjectIdentifiersFilter) String

type Filter

type Filter interface {
	Apply(interface{}) bool
}

Filter returns a boolean, given a value. This abstracts away the process of the actual decision making. The implementations will need to type assert certain interfaces to access values from the interfaces.

type HoldingsFilter

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

HoldingsFilter uses the new licensing package.

func (*HoldingsFilter) Apply

func (f *HoldingsFilter) Apply(v interface{}) bool

Apply returns true, if there is a valid holding for a given record. This will take multiple attibutes like date, volume, issue and embargo into account. This function is very specific: it works only with intermediate format and it uses specific information from that format to decide on attachment.

func (*HoldingsFilter) UnmarshalJSON

func (f *HoldingsFilter) UnmarshalJSON(p []byte) error

UnmarshalJSON deserializes this filter.

type IdentifierFilter

type IdentifierFilter struct {
	Identifier struct {
		Fallback bool     `json:"fallback"`
		Values   []string `json:"values"`
	} `json:"id"`
}

IdentifierFilter allows to filter by identifier.

func (IdentifierFilter) Apply

func (f IdentifierFilter) Apply(v interface{}) bool

Apply checks, if a value belongs to a given collection.

func (IdentifierFilter) String

func (f IdentifierFilter) String() string

type Issuer

type Issuer interface {
	Issue() string
}

Issuer returns a issue, preferably without decoration.

type NoneFilter

type NoneFilter struct {
	None struct{} `json:"none"`
}

NoneFilter blocks everything.

func (NoneFilter) Apply

func (NoneFilter) Apply(_ interface{}) bool

Apply just returns false.

type NotFilter

type NotFilter struct {
	Filter Filter `json:"not"`
}

NotFilter returns true, if all filters return true.

func (*NotFilter) Apply

func (f *NotFilter) Apply(v interface{}) bool

Apply checks, if a value belongs to a given collection.

func (*NotFilter) String

func (f *NotFilter) String() string

func (*NotFilter) UnmarshalJSON

func (f *NotFilter) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON unmarshals an and filter.

type OrFilter

type OrFilter struct {
	Filters []Filter `json:"or"`
}

OrFilter returns true, if all filters return true.

func (*OrFilter) Apply

func (f *OrFilter) Apply(v interface{}) bool

Apply checks, if a value belongs to a given collection.

func (*OrFilter) String

func (f *OrFilter) String() string

func (*OrFilter) UnmarshalJSON

func (f *OrFilter) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON unmarshals an and filter.

type Packager

type Packager interface {
	Packages() []string
}

Packager returns package names.

type PackagesFilter

type PackagesFilter struct {
	Packages struct {
		Fallback bool     `json:"fallback"`
		Values   []string `json:"values"`
	} `json:"packages"`
}

PackagesFilter filters by DOI.

func (PackagesFilter) Apply

func (f PackagesFilter) Apply(v interface{}) bool

Apply checks, if a value belongs to a given collection.

func (PackagesFilter) String

func (f PackagesFilter) String() string

type PublicationDater

type PublicationDater interface {
	PublicationDate() string
}

PublicationDater returns a publication date string in ISO format: 2017-07-15.

type SerialNumberer

type SerialNumberer interface {
	SerialNumbers() []string
}

SerialNumberer returns a list of ISSN as strings.

type SerialNumbersFilter

type SerialNumbersFilter struct {
	SerialNumbers struct {
		Fallback bool     `json:"fallback"`
		Values   []string `json:"values"`
	} `json:"issn"`
}

SerialNumbersFilter filters serial numbers given as a list.

func (SerialNumbersFilter) Apply

func (f SerialNumbersFilter) Apply(v interface{}) bool

Apply checks, if a value belongs to a given collection.

func (SerialNumbersFilter) String

func (f SerialNumbersFilter) String() string

type SourceIdentifierFilter

type SourceIdentifierFilter struct {
	SID struct {
		Fallback bool     `json:"fallback"`
		Values   []string `json:"values"`
	} `json:"sid"`
}

SourceIdentifierFilter filters by DOI.

func (SourceIdentifierFilter) Apply

func (f SourceIdentifierFilter) Apply(v interface{}) bool

Apply checks, if a value belongs to a given collection.

func (SourceIdentifierFilter) String

func (f SourceIdentifierFilter) String() string

type SourceIdentifierer

type SourceIdentifierer interface {
	SourceIdentifier() string
}

SourceIdentifierer returns a source identifier.

type Subjecter

type Subjecter interface {
	Subjects() []string
}

Subjecter returns a number of subjects.

type SubjectsFilter

type SubjectsFilter struct {
	SerialNumbers struct {
		Fallback bool     `json:"fallback"`
		Values   []string `json:"values"`
	} `json:"issn"`
}

SubjectsFilter filters by subject.

func (SubjectsFilter) Apply

func (f SubjectsFilter) Apply(v interface{}) bool

Apply checks, if a value belongs to a given collection.

func (SubjectsFilter) String

func (f SubjectsFilter) String() string

type Volumer

type Volumer interface {
	Volume() string
}

Volumer returns a volume number, preferably without decoration.

Jump to

Keyboard shortcuts

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