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 ¶
- type AndFilter
- type AnyFilter
- type Collectioner
- type CollectionsFilter
- type DocumentObjectIdentifier
- type DocumentObjectIdentifiersFilter
- type Filter
- type HoldingsFilter
- type IdentifierFilter
- type Issuer
- type NoneFilter
- type NotFilter
- type OrFilter
- type Packager
- type PackagesFilter
- type PublicationDater
- type SerialNumberer
- type SerialNumbersFilter
- type SourceIdentifierFilter
- type SourceIdentifierer
- type Subjecter
- type SubjectsFilter
- type Volumer
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) UnmarshalJSON ¶
UnmarshalJSON unmarshals an and filter.
type AnyFilter ¶
type AnyFilter struct {
AnyFilter struct{} `json:"any"`
}
AnyFilter allows anything.
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 ¶
func (f DocumentObjectIdentifiersFilter) String() 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.
type NotFilter ¶
type NotFilter struct {
Filter Filter `json:"not"`
}
NotFilter returns true, if all filters return true.
func (*NotFilter) UnmarshalJSON ¶
UnmarshalJSON unmarshals an and filter.
type OrFilter ¶
type OrFilter struct {
Filters []Filter `json:"or"`
}
OrFilter returns true, if all filters return true.
func (*OrFilter) UnmarshalJSON ¶
UnmarshalJSON unmarshals an and filter.
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