models

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package models stores the structs for the objects we have & interacts with mongo

Package models stores the structs for the objects we have

Index

Constants

View Source
const (
	IDTypeOnline = iota // Types of Identifiers: mostly online ISBN / ISSN
	IDTypePrint         // Types of Identifiers: mostly print ISBN / ISSN
	IDTypePPN           // Types of Identifiers: unimarc record ID in Sudoc catalog
	IDTypeSFX           // Types of Identifiers: ID in Ex Libris' SFX Open resolver
)

Variables

This section is empty.

Functions

func CreateKbartFile

func CreateKbartFile(records []Record, fname string) (int64, error)

CreateKbartFile creates csv file with KBART fields from records

func CreateUnimarcFile

func CreateUnimarcFile(records []Record, fname string) (int64, error)

CreateUnimarcFile creates the file to be exported

func RecordDelete

func RecordDelete(ID string) error

RecordDelete deletes a single ebook from DB

func RecordUpsert

func RecordUpsert(record Record) (int, int, error)

RecordUpsert inserts or updates a record in DB

func RecordsCount

func RecordsCount() int

RecordsCount counts the number of records in DB

func RecordsCountPPNs

func RecordsCountPPNs() int

RecordsCountPPNs retrieves the number of record that have a PPN Identifier

func RecordsCountUnimarc

func RecordsCountUnimarc() int

RecordsCountUnimarc retrieves the number of record that have a RecordUnimarc field

func RecordsUpsert

func RecordsUpsert(records []Record) (int, int)

RecordsUpsert updates or inserts a number of records in DB

func TSCountPPNs

func TSCountPPNs(tsname string) int

TSCountPPNs counts how many records for this target service have proper PicaPublication Numbers coming from ABES

func TSCountRecords

func TSCountRecords(tsname string) int

TSCountRecords counts the number of records for this target service

func TSCountRecordsUnimarc

func TSCountRecordsUnimarc(tsname string) int

TSCountRecordsUnimarc counts how many records for this target service have proper MARC Records

func TSCreate

func TSCreate(ts TargetService) error

TSCreate registers a new target service, aka ebook package in mongo db NOTE: should review the code generally to see when to really use pointers rather than values here : should pbly be a value, since we neither change nor return the struct

func TSDelete

func TSDelete(tsname string) error

TSDelete removes a target service

func TSUpdate

func TSUpdate(ts TargetService) error

TSUpdate updates a target service

func UserCreate

func UserCreate(username, password string) error

UserCreate creates a new user

func UserDelete

func UserDelete(ID string) error

UserDelete deletes a user

func UserUpdateDateLastSeen

func UserUpdateDateLastSeen(u User) error

UserUpdateDateLastSeen updates a user's record when she logs in

func UsersCount

func UsersCount() int

Types

type Identifier

type Identifier struct {
	Identifier string `bson:",omitempty"`
	IDType     int
}

Identifier embedded in an record

type Record

type Record struct {
	ID                           bson.ObjectId `bson:"_id,omitempty"`
	AccessType                   string        `bson:",omitempty"`
	Acquired                     bool          `bson:",omitempty"`
	Active                       bool
	CoverageDepth                string `bson:",omitempty"`
	CoverageNotes                string `bson:",omitempty"`
	DateCreated                  time.Time
	DateFirstIssueOnline         string    `bson:",omitempty"`
	DateLastIssueOnline          string    `bson:",omitempty"`
	DateMonographPublishedOnline string    `bson:",omitempty"`
	DateMonographPublishedPrint  string    `bson:",omitempty"`
	DateUpdated                  time.Time `bson:",omitempty"`
	Deleted                      bool
	EmbargoInfo                  string       `bson:",omitempty"`
	FirstAuthor                  string       `bson:",omitempty"`
	FirstEditor                  string       `bson:",omitempty"`
	Identifiers                  []Identifier `bson:",omitempty"`
	MonographEdition             string       `bson:",omitempty"`
	MonographVolume              string       `bson:",omitempty"`
	Notes                        string       `bson:",omitempty"`
	NumFirstIssueOnline          string       `bson:",omitempty"`
	NumFirstVolOnline            string       `bson:",omitempty"`
	NumLastIssueOnline           string       `bson:",omitempty"`
	NumLastVolOnline             string       `bson:",omitempty"`
	ParentPublicationTitleID     string       `bson:",omitempty"`
	PrecedingPublicationTitleID  string       `bson:",omitempty"`
	PublicationTitle             string
	PublicationType              string    `bson:",omitempty"`
	PublisherName                string    `bson:",omitempty"`
	RecordMarc21                 string    `bson:",omitempty"`
	RecordUnimarc                string    `bson:",omitempty"`
	TargetServices               []TSEmbed `bson:",omitempty"` // this is the name of the package in SFX, e.g. CAIRN QSJ
	TitleID                      string    `bson:",omitempty"`
	TitleURL                     string    `bson:",omitempty"`
}

Record stores a full record for a resource

func RecordGetByID

func RecordGetByID(ID string) (Record, error)

RecordGetByID retrieves a record given its mongodb ID

func RecordUpdate

func RecordUpdate(record Record) (Record, error)

RecordUpdate saves an updated record struct to DB

func RecordsGetByTSName

func RecordsGetByTSName(tsname string, n int) ([]Record, error)

RecordsGetByTSName retrieves the records which have a given target service i.e. belong to a given package. n is used to paginate. Use 0 if you want to start at record #1

func RecordsGetNoPPNByTSName

func RecordsGetNoPPNByTSName(tsname string) ([]Record, error)

RecordsGetNoPPNByTSName retrieves all records with conditions : no PPN, given TS used to prepare query to sudoc isbn2ppn web service

func RecordsGetWithPPNByTSName

func RecordsGetWithPPNByTSName(tsname string) ([]Record, error)

RecordsGetWithPPNByTSName retrieves all records with condition : has PPN, given TS used to prepare query to sudoc get record web service

func RecordsGetWithUnimarcByTSName

func RecordsGetWithUnimarcByTSName(tsname string) ([]Record, error)

RecordsGetWithUnimarcByTSName retrieves all records with condition : has Unimarc Record, given TS

func Search(r *http.Request) ([]Record, string, error)

Search parses the search form in nav to retrieve ebooks

type TSCSVConf

type TSCSVConf struct {
	Col1  string `bson:",omitempty" tag_col:"0"`
	Col2  string `bson:",omitempty" tag_col:"1"`
	Col3  string `bson:",omitempty" tag_col:"2"`
	Col4  string `bson:",omitempty" tag_col:"3"`
	Col5  string `bson:",omitempty" tag_col:"4"`
	Col6  string `bson:",omitempty" tag_col:"5"`
	Col7  string `bson:",omitempty" tag_col:"6"`
	Col8  string `bson:",omitempty" tag_col:"7"`
	Col9  string `bson:",omitempty" tag_col:"8"`
	Col10 string `bson:",omitempty" tag_col:"9"`
}

TSCSVConf indicates the # of fields + column (index) of the various pieces of info in the csv file

type TSEmbed

type TSEmbed struct {
	Name        string
	DisplayName string
}

TSEmbed embeds the necessary fields from a Target Service

type TargetService

type TargetService struct {
	ID                     bson.ObjectId `bson:"_id,omitempty"`
	TSName                 string        `bson:",omitempty" schema:"tsname"`
	TSDisplayName          string        `bson:",omitempty" schema:"tsdisplayname"`
	TSDateCreated          time.Time
	TSDateUpdated          time.Time `bson:",omitempty"`
	TSPublisherLastHarvest time.Time `bson:",omitempty"`
	TSSFXLastHarvest       time.Time `bson:",omitempty"`
	TSSudocLastHarvest     time.Time `bson:",omitempty"`
	TSActive               bool      `schema:"tsactive"`
	TSCsvConf              TSCSVConf `bson:",omitempty"`
}

TargetService represents an SFX Target Service, i.e. a package with its provider e.g. SPRINGER MATH EBOOKS

func GetTargetService

func GetTargetService(tsname string) (TargetService, error)

GetTargetService retrieves a target service

func GetTargetServicesListing

func GetTargetServicesListing() ([]TargetService, error)

GetTargetServicesListing retrieves the full list of target services

type User

type User struct {
	ID           bson.ObjectId `bson:"_id"`
	DateCreated  time.Time
	DateLastSeen time.Time `bson:",omitempty"`
	Username     string    `bson:"username"`
	Password     string    `bson:"password"`
}

User contains the info for each user

func GetUsers

func GetUsers() ([]User, error)

GetUsers retrieves the full list of users

func UserByID

func UserByID(ID string) (User, error)

func UserByUsername

func UserByUsername(username string) (User, error)

UserByUsername retrieves a user by its username

Jump to

Keyboard shortcuts

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