ruslanparser

package module
v0.0.0-...-c6dcb73 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2016 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BASE_URL       = "http://92.241.99.100/Scripts/zgate.exe"
	INDEX_QUERY    = "Init+test.xml,simple.xsl+rus"
	PRESENT_FORMAT = "present+%s+default+%d+%d+X+1.2.840.10003.5.102+rus"
	HOST           = "192.168.0.1"
	PORT           = "210"
	LANG           = "rus"
	ACTION         = "SEARCH"
	ESNAME         = "B"
	MATERIAL_TYPE  = ""
	DBNAMES        = []string{"BOOK", "REF", "STAT", "ЭЛЕКТР_РЕСУРСЫ", "ФРК"}
	USE_1          = "1035"
	TERM_1         = "%D0%BC%D0%B0%D1%82%D0%B5%D0%BC%D0%B0%D1%82%D0%B8%D0%BA%D0%B0"
	BOOLEAN_OP1    = "AND"
	USE_2          = "4"
	TERM_2         = ""
	BOOLEAN_OP2    = "AND"
	USE_3          = "21"
	TERM_3         = ""
	SHOW_HOLDINGS  = "on"
	MAXRECORDS     = "60"
	SEARCH         = "SEARCH"

	BY_AUTHOR = "1003"
	BY_TITLE  = "4"
)

Functions

func NewSessionSearchUrl

func NewSessionSearchUrl(iurl string) (string, error)

func RM

func RM(r []byte) int

func Setup

func Setup()

Types

type Api

type Api struct {
	Ssid       string
	SsidFile   string
	SsidAssign time.Time

	InitialUrl string
	PresentUrl string

	GetAllRecords bool
	MAXRECORDS    int
	// contains filtered or unexported fields
}

func NewApi

func NewApi(opts ...*Option) *Api

func (*Api) BySearch

func (a *Api) BySearch(q string, by string) ([]Book, error)

func (*Api) GetSsid

func (a *Api) GetSsid() string

func (*Api) ProxySearch

func (a *Api) ProxySearch(q string) []Book

func (*Api) Search

func (a *Api) Search(q string) []Book

func (*Api) SearchByAuthor

func (a *Api) SearchByAuthor(author string) ([]Book, error)

func (*Api) SearchByTitle

func (a *Api) SearchByTitle(title string) ([]Book, error)

type BibliographicRecord

type BibliographicRecord struct {
	Record Record `xml:"record"`
}

type Book

type Book struct {
	Id       int64    `json:"id"`
	SourceId string   `json:"source_id"`
	Title    string   `json:"title"`
	Author   string   `json:"author"`
	Series   string   `json:"series"`
	Tags     []string `db:"-" json:"tags"`
	Genre    string   `json:"genre"`

	Places []Place `db:"-" json:"places"`

	PageNum int `json:"pagenum"`

	City            string `json:"city"`
	Publishing      string `json:"publishing"`
	PublicationYear int    `json:"publication_year"`
	Edition         string `json:"edition"`

	Fields map[string]map[string]string `json:"fields"`

	LastMod string `json:"lastmod"`
}
func Search(q, filter, ssid string, offset, limit int) (books []Book, numResult int, e error)

type CachedCmd

type CachedCmd struct {
	*Cmd
	Created time.Time
}

type Cacher

type Cacher interface {
	Set(*Cmd) error
	Get(*Cmd) error
	SetLifeTime(time.Duration)
}

type CircRecord

type CircRecord struct {
	AvailableNow int `xml:"availableNow"`
}

type CirculationData

type CirculationData struct {
	CircRecord CircRecord `xml:"circRecord"`
}

type Cmd

type Cmd struct {
	Query    string
	SearchBy string
	Offset   int
	Limit    int

	ResultNum int
	Result    []Book
	Error     error

	Done chan struct{} `json:"-"`
	// contains filtered or unexported fields
}

func NewCmd

func NewCmd(wg sync.WaitGroup) *Cmd

func (*Cmd) IsWait

func (c *Cmd) IsWait() bool

func (Cmd) String

func (c Cmd) String() string

func (*Cmd) WaitDone

func (c *Cmd) WaitDone()

type Field

type Field struct {
	Id        string      `xml:"id,attr"`
	Val       string      `xml:",chardata"`
	Indicator []Indicator `xml:"indicator"`
	Subfield  []Subfield  `xml:"subfield"`
}

type HoldingsAndCirc

type HoldingsAndCirc struct {
	NucCode         string          `xml:"nucCode"`
	LocalLocation   string          `xml:"localLocation"`
	CallNumber      string          `xml:"callNumber"`
	ShelvingData    string          `xml:"shelvingData"`
	CopyNumber      string          `xml:"copyNumber"`
	CirculationData CirculationData `xml:"circulationData"`
}

type HoldingsData

type HoldingsData struct {
	HoldingsAndCirc []HoldingsAndCirc `xml:"holdingsAndCirc"`
}

type Indicator

type Indicator struct {
	Id  string `xml:"id,attr"`
	Val string `xml:",chardata"`
}

type Leader

type Leader struct {
	Length   string `xml:"length"`
	Status   string `xml:"status"`
	Type     string `xml:"type"`
	Leader07 string `xml:"leader07"`
	EntryMap string `xml:"entryMap"`
}

type NodbCache

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

func NewNodbCache

func NewNodbCache(path string) (*NodbCache, error)

func (NodbCache) Get

func (c NodbCache) Get(cmd *Cmd) error

func (NodbCache) Set

func (c NodbCache) Set(cmd *Cmd) error

func (NodbCache) SetLifeTime

func (c NodbCache) SetLifeTime(dur time.Duration)

type Opt

type Opt int
const (
	OptTypeSessionFile Opt = iota
)

type Option

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

func NewOpt

func NewOpt(value string, t Opt) *Option

func (*Option) Type

func (o *Option) Type() Opt

func (*Option) Value

func (o *Option) Value() string

type Opts

type Opts struct {
	Db         *gorp.DbMap
	SessionNum int
	GateAddr   string

	SearchQueryConsts map[string]interface{}
}

type Parser

type Parser struct {
	Opts        Opts
	Sessions    []string
	SearchQueue []string
}

func NewParser

func NewParser(o Opts) *Parser

type Place

type Place struct {
	Id            int64  `json:"id"`
	Name          string `json:"name"`
	ShelvingIndex string `json:"shelving_index"`
	Cipher        string `json:"cipher"`
	Copies        int    `json:"copies"`
	Available     int    `json:"available"`
}

type Places

type Places struct {
	Id     int64 `json:"id"`
	BookId int64 `json:"book_id"`
}

type Queue

type Queue struct {
	*QueueOpts
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue(opts *QueueOpts) *Queue

func (*Queue) Do

func (ws *Queue) Do(cmd *Cmd)

func (*Queue) Run

func (ws *Queue) Run()

func (*Queue) Search

func (ws *Queue) Search(q string, offset, limit int, by ...string) ([]Book, int, error)

func (*Queue) Wait

func (ws *Queue) Wait()

type QueueOpts

type QueueOpts struct {
	BaseUrl      string
	IndexQuery   string
	WorkerNumber int
	Cache        Cacher
}

type Record

type Record struct {
	Leader Leader  `xml:"leader"`
	Field  []Field `xml:"field"`
}

type Records

type Records struct {
	XMLName xml.Name `xml:"records"`
	Records []Result `xml:"record"`
}

func GetBooksData

func GetBooksData(session string) Records

type Result

type Result struct {
	XMLName             xml.Name            `xml:"record"`
	BibliographicRecord BibliographicRecord `xml:"bibliographicRecord"`
	HoldingsData        HoldingsData        `xml:"holdingsData"`
}

func (Result) ToBook

func (r Result) ToBook() Book

type Session

type Session struct {
	Id string

	Opts         *Opts
	CurrentQuery string
}

type Subfield

type Subfield struct {
	Id  string `xml:"id,attr"`
	Val string `xml:",chardata"`
}

type Tag

type Tag struct {
	Id    int64
	Title string
}

type Tags

type Tags struct {
	Id     int64
	BookId int64
}

type Worker

type Worker struct {
	Id int

	SsidMu    sync.Mutex
	Ssid      string
	SsidFetch time.Time
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(id int, q *Queue) *Worker

func (*Worker) Do

func (w *Worker) Do(cmd *Cmd)

func (*Worker) Run

func (w *Worker) Run()

func (*Worker) Session

func (w *Worker) Session() (string, error)

Jump to

Keyboard shortcuts

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