naturalidentificator

package
v0.0.0-...-9c67b44 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ValidEan13 = regexp.MustCompile("^[0-9]{13}$")
	ValidEan8  = regexp.MustCompile("^[0-9]{8}$")
	ValidUpc   = regexp.MustCompile("^[0-9]{12}$")
)
View Source
var (
	ValidIsbn10 = regexp.MustCompile("^[0-9]{9}[0-9X]$")
	ValidIsbn13 = regexp.MustCompile("^[0-9]{13}$")
)
View Source
var (
	ValidIsmn9  = regexp.MustCompile("^[0-9]{9}$")
	ValidIsmn13 = regexp.MustCompile("^9790[0-9]{9}$")
)
View Source
var (
	ValidIssn8  = regexp.MustCompile("^[0-9]{7}[0-9X]$")
	ValidIssn13 = regexp.MustCompile("^977[0-9]{10}$")
)
View Source
var (
	ValidExtPubId = regexp.MustCompile("^[0-9]*$")
)

Functions

This section is empty.

Types

type CheckDigit

type CheckDigit struct {
	Src    string
	Valid  bool
	Actual rune
	Digit  rune
}

Representation of a check digit calculation

  • Src - The natural id which is expected to be a variant of International Article Number (EAN)
  • Valid - If the calculation was as expected
  • Actual - What the ID held as check digit
  • Digit - What Deichman calculated check digit to be

func CreateCheckDigit

func CreateCheckDigit(naturalId string, kind CheckDigitType) CheckDigit

func (*CheckDigit) CalculateAndValidate

func (c *CheckDigit) CalculateAndValidate(kind CheckDigitType)

type CheckDigitType

type CheckDigitType int
const (
	CheckDigitEan13Type  CheckDigitType = 0
	CheckDigitEan8Type   CheckDigitType = 1
	CheckDigitUpcType    CheckDigitType = 2
	CheckDigitIsbn10Type CheckDigitType = 3
	CheckDigitIsbn13Type CheckDigitType = 4
	CheckDigitIsmn13Type CheckDigitType = 5
	CheckDigitIssn8Type  CheckDigitType = 6
	CheckDigitIssn13Type CheckDigitType = 7
)

type Ean

type Ean struct {
	NaturalIdentificator
}

Deichman supports EAN-8, EAN-13 and UPC codes as natural-id. As UPC is the precursor to EAN, we store the UPC in the EAN field.

EAN, known as International Article Number. Used on many publications in Deichman as natural id. EAN consists of four components

  • GS1 prefix - 3 digits
  • Manufacturer code - variable length
  • Product code - variable length
  • Check digit

GS1 prefix 978 and 979 are reserved for published books regardless of origin country. ISBN13 is a type of EAN code. Prefix 979 with first digit 0 is reserved for ISMN (International Stanard Music Number), and 977 is reserved for ISSN (International Standard Serial Number) for published periodicals.

Check digit is modulo 10 calculation. Each digit is weighted alternating 3 and 1.

func (*Ean) Process

func (e *Ean) Process(naturalId string) NaturalIdentificator

type ExternalPublicationId

type ExternalPublicationId struct {
	NaturalIdentificator
}

External Publication Identificators are Deichman specific concept. They are the identificators sourced from MARC exchanges with Bibliotekssentralen (BS) and Det Flerspråklige Bibliotek (DFB), and picked from MARC post 00, record id in exchanges with each external source. External Publication Identificators are expected to be positive integer numbers.

func (*ExternalPublicationId) Process

func (e *ExternalPublicationId) Process(naturalId string) NaturalIdentificator

type IdentificatorType

type IdentificatorType int
const (
	EanType                   IdentificatorType = 0
	ExternalPublicationIdType IdentificatorType = 1
	IsbnType                  IdentificatorType = 2
	IsmnType                  IdentificatorType = 3
	IssnType                  IdentificatorType = 4
	SerialNumberType          IdentificatorType = 5
)

type Isbn

type Isbn struct {
	NaturalIdentificator
}

International Standard Book Number Used in Deichman as natural id for publications with ISBN, typically books.

  • ISBNs are 10 or 13 digits.
  • 10 digit ISBNs are based upon 9 digit Standard Book Numbering (SBN).
  • 9 digit SBNs can be converted to 10 digit ISBNs by prefixing with a leading zero (0)
  • 13 Digit ISBNs are also EANs
  • 10 digit ISBNs can be converted to 13 digit ISBNs by prepending 978 and recalculate the checksum.
  • Only 13 digit ISBNs starting with 978 can be recalculated as 10 digit ISBNs

func (*Isbn) Process

func (e *Isbn) Process(naturalId string) NaturalIdentificator

type Ismn

type Ismn struct {
	NaturalIdentificator
}

International Standard Music Number Natural indentificator for publications of sheet music in Deichman. 13 digit ISMNs are EANs prefixed with 0790. 10 digit ISMNs are 11 characters or 10 characters, if they are 11 characters they are prefixed with an M.

func (*Ismn) Process

func (i *Ismn) Process(naturalId string) NaturalIdentificator

type Issn

type Issn struct {
	NaturalIdentificator
}

func (*Issn) Process

func (i *Issn) Process(naturalId string) NaturalIdentificator

type NaturalIdentificator

type NaturalIdentificator struct {
	Type          IdentificatorType
	Identificator string
	Searchable    bool
	Valid         bool
	QueryString   string
}

type NaturalIdentificatorSet

type NaturalIdentificatorSet struct {
	Identificators      []NaturalIdentificator
	CompleteQueryString string
	PartialQueryString  string
}

func IdentificatorCandidates

func IdentificatorCandidates(naturalId string) NaturalIdentificatorSet

type SearchableIdentifiactor

type SearchableIdentifiactor interface {
	Process(naturalId string) NaturalIdentificator
}

type SerialNumber

type SerialNumber struct {
	NaturalIdentificator
}

func (*SerialNumber) Process

func (e *SerialNumber) Process(naturalId string) NaturalIdentificator

Jump to

Keyboard shortcuts

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