eprinttools

package module
v0.0.11-dev Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2018 License: BSD-3-Clause Imports: 14 Imported by: 1

README

eprinttools

This project contains the eprinttools, a go package for working with EPrints REST API. It also includes ep and command line utility for harvesting content into a dataset collection and rendering JSON documents for web feeds.

The command line

  • eputil is a command line utility for interacting (e.g. harvesting) JSON and XML from EPrints' REST API
    • uses minimal configuration because it does less!
    • will supercede ep
  • ep is an older version of a EPrints harvester. It features an integration with dataset and can be used to produce alternative feeds and formats.

The ep utility is configured from the environment or command line options. The environment settings are overridden by command line options. For details running either command envoke the tool name with the '-help' option.

Documentation

Overview

eprinttools.go is a package for working with EPrints 3.x REST API as well as XML artifacts on disc.

@author R. S. Doiel, <rsdoiel@library.caltech.edu>

Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Package eprinttools is a collection of structures and functions for working with the E-Prints REST API

@author R. S. Doiel, <rsdoiel@caltech.edu>

Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Package eprinttools is a collection of structures and functions for working with the E-Prints REST API

@author R. S. Doiel, <rsdoiel@caltech.edu>

Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Index

Constants

View Source
const (
	// Version is the revision number for this implementation of epgo
	Version = `v0.0.11-dev`

	// LicenseText holds the string for rendering License info on the command line
	LicenseText = `` /* 1529-byte string literal not displayed */

	// EPrintsExportBatchSize sets the summary output frequency when exporting content from E-Prints
	EPrintsExportBatchSize = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document struct {
	XMLName    xml.Name `json:"-"`
	XMLNS      string   `xml:"xmlns,attr,omitempty" json:"name_space,omitempty"`
	ID         string   `xml:"id,attr" json:"id"`
	DocID      int      `xml:"docid" json:"doc_id"`
	RevNumber  int      `xml:"rev_number" json:"rev_number,omitempty"`
	Files      []*File  `xml:"files>file" json:"files,omitempty"`
	EPrintID   int      `xml:"eprintid" json:"eprint_id"`
	Pos        int      `xml:"pos" json:"pos,omitempty"`
	Placement  int      `xml:"placement" json:"placement,omitempty"`
	MimeType   string   `xml:"mime_type" json:"mime_type"`
	Format     string   `xml:"format" json:"format"`
	FormatDesc string   `xml:"formatdesc,omitempty" json:"format_desc,omitempty"`
	Language   string   `xml:"language" json:"language"`
	Security   string   `xml:"security" json:"security"`
	License    string   `xml:"license" json:"license"`
	Main       string   `xml:"main" json:"main"`
	Content    string   `xml:"content" json:"content"`
	Relation   []*Item  `xml:"relation>item,omitempty" json:"relation,omitempty"`
}

Document structures inside a Record (i.e. <eprint>...<documents><document>...</document>...</documents>...</eprint>)

type DocumentList

type DocumentList []*Document

DocumentList is an array of pointers to Document structs

type EPrint added in v0.0.14

type EPrint struct {
	XMLName              xml.Name    `json:"-"`
	XMLNS                string      `xml:"xmlns,attr,omitempty" json:"xmlns,omitempty"`
	ID                   string      `xml:"id,attr,omitempty" json:"id,omitempty"`
	EPrintID             int         `xml:"eprintid,omitempty" json:"eprint_id,omitempty"`
	RevNumber            int         `xml:"rev_number,omitempty" json:"rev_number,omitempty"`
	Documents            []*Document `xml:"documents>document,omitempty" json:"documents,omitempty"`
	EPrintStatus         string      `xml:"eprint_status,omitempty" json:"eprint_status,omitempty"`
	UserID               int         `xml:"userid,omitempty" json:"userid,omitempty"`
	Dir                  string      `xml:"dir,omitempty" json:"dir,omitempty"`
	DateStamp            string      `xml:"datestamp,omitempty" json:"datestamp,omitempty"`
	LastModified         string      `xml:"lastmod,omitempty" json:"lastmod,omitempty"`
	StatusChanged        string      `xml:"status_changed,omitempty" json:"status_changed,omitempty"`
	Type                 string      `xml:"type,omitempty" json:"type,omitempty"`
	MetadataVisibility   string      `xml:"metadata_visibility,omitempty" json:"metadata_visibility,omitempty"`
	Creators             []*Item     `xml:"creators>item,omitempty" json:"creators,omitempty"`
	Title                string      `xml:"title,omitempty" json:"title,omitempty"`
	IsPublished          string      `xml:"ispublished,omitempty" json:"ispublished,omitempty"`
	FullTextStatus       string      `xml:"full_text_status,omitempty" json:"full_text_status,omitempty"`
	Keywords             string      `xml:"keywords,omitempty" json:"keywords,omitempty"`
	Note                 string      `xml:"note,omitempty" json:"note,omitempty"`
	Abstract             string      `xml:"abstract,omitempty" json:"abstract,omitempty"`
	Date                 string      `xml:"date,omitempty" json:"date,omitempty"`
	DateType             string      `xml:"date_type,omitempty" json:"date_type,omitempty"`
	Series               string      `xml:"series,omitempty" json:"series,omitempty"`
	Publication          string      `xml:"publication,omitempty" json:"publication,omitempty"`
	Volumne              string      `xml:"volumne,omitempty" json:"volumne,omitempty"`
	Publisher            string      `xml:"publisher,omitempty" json:"publisher,omitempty"`
	PlaceOfPub           string      `xml:"place_of_pub,omitempty" json:"place_of_pub,omitempty"`
	Edition              string      `xml:"edition,omitempty" json:"edition,omitempty"`
	PageRange            string      `xml:"pagerange,omitempty" json:"pagerange,omitempty"`
	Pages                string      `xml:"pages,omitempty" json:"pages,omitempty"`
	EventTitle           string      `xml:"event_title,omitempty" json:"event_title,omitempty"`
	EventLocation        string      `xml:"event_location,omitempty" json:"event_location,omitempty"`
	EventDates           string      `xml:"event_dates,omitempty" json:"event_dates,omitempty"`
	IDNumber             string      `xml:"id_number,omitempty" json:"id_number,omitempty"`
	Refereed             string      `xml:"refereed,omitempty" json:"refereed,omitempty"`
	ISBN                 string      `xml:"isbn,omitempty" json:"isbn,omitempty"`
	ISSN                 string      `xml:"issn,omitempty" json:"issn,omitempty"`
	BookTitle            string      `xml:"book_title,omitempty" json:"book_title,omitempty"`
	Editors              []*Item     `xml:"editors>item,omitempty" json:"editors,omitempty"`
	OfficialURL          string      `xml:"official_url,omitempty" json:"official_url,omitempty"`
	RelatedURL           []*Item     `xml:"related_url>item,omitempty" json:"related_url,omitempty"`
	ReferenceText        []*Item     `xml:"referencetext>item,omitempty" json:"referencetext,omitempty"`
	Projects             []*Item     `xml:"projects>item,omitempty" json:"projects,omitempty"`
	Rights               string      `xml:"rights,omitempty" json:"rights,omitempty"`
	Funders              []*Item     `xml:"funders>item,omitempty" json:"funders,omitempty"`
	Collection           string      `xml:"collection,omitempty" json:"collection,omitempty"`
	Reviewer             string      `xml:"reviewer,omitempty" json:"reviewer,omitempty"`
	OfficeCitation       string      `xml:"official_cit,omitempty" json:"official_cit,omitempty"`
	OtherNumberingSystem []*Item     `xml:"other_numbering_system>item,omitempty" json:"other_numbering_system,omitempty"`
	LocalGroup           []*Item     `xml:"local_group>item,omitempty" json:"local_group,omitempty"`
	Errata               []*Item     `xml:"errata>item,omitempty" json:"errata,omitempty"`
	Contributors         []*Item     `xml:"contributors>item,omitempty" json:"contributors,omitempty"`
	MonographType        string      `xml:"monograph_type,omitempty" json:"monograph_type,omitempty"`

	// NOTE: Misc fields discoverd exploring REST API records, not currently used at Caltech Library (RSD, 2018-01-02)
	Subjects           []*Item `xml:"subjects>item,omitempty" json:"subjects,omitempty"`
	PresType           string  `xml:"pres_type,omitempty" json:"presentation_type,omitempty"`
	Suggestions        string  `xml:"suggestions,omitempty" json:"suggestions,omitempty"`
	Succeeds           string  `xml:"succeeds,omitempty" json:"succeeds,omitempty"`
	Commentary         string  `xml:"commentary,omitempty" json:"commentary,omitempty"`
	ContactEMail       string  `xml:"contact_email,omitempty" json:"contect_email,omitempty"`
	FileInfo           string  `xml:"fileinfo,omitempty" json:"file_info,omitempty"`
	Latitude           string  `xml:"latitude,omitempty" json:"latitude,omitempty"`
	Longitude          string  `xml:"longitude,omitempty" json:"longitude,omitempty"`
	ItemIssues         []*Item `xml:"item_issues>item,omitempty" json:"item_issues,omitempty"`
	ItemIssuesCount    int     `xml:"item_issues_count,omitempty" json:"item_issues_count,omitempty"`
	CorpCreators       []*Item `xml:"corp_creators>item,omitempty" json:"corp_creators,omitempty"`
	Department         string  `xml:"department,omitempty" json:"department,omitempty"`
	OutputMedia        string  `xml:"output_media,omitempty" json:"output_media,omitempty"`
	Exhibitors         []*Item `xml:"exhibitors,omitempty" json:"exhibitors,omitempty"`
	NumPieces          string  `xml:"num_pieces,omitempty" json:"num_pieces,omitempty"`
	CompositionType    string  `xml:"composition_type,omitempty" json:"composition_type,omitempty"`
	Producers          []*Item `xml:"producers>item,omitempty" json:"producers,omitempty"`
	Conductors         []*Item `xml:"conductors>item,omitempty" json:"conductors,omitempty"`
	Lyricists          []*Item `xml:"lyricists>item,omitempty" json:"lyricists,omitempty"`
	Accompaniment      []*Item `xml:"accompaniment>item,omitempty" json:"accompaniment,omitempty"`
	DataType           string  `xml:"data_type,omitempty" json:"data_type,omitempty"`
	PedagogicType      string  `xml:"pedagogic_type,omitempty" json:"pedagogic_type,omitempty"`
	CompletionTime     string  `xml:"completion_time,omitempty" json:"completion_time,omitempty"`
	TaskPurpose        string  `xml:"task_purpose,omitempty" json:"task_purpose,omitempty"`
	SkillAreas         []*Item `xml:"skill_areas>item,omitempty" json:"skill_areas,omitempty"`
	CopyrightHolders   []*Item `xml:"copyright_holders>item,omitempty" json:"copyright_holders,omitempty"`
	LearningLevel      []*Item `xml:"learning_level>item,omitempty" json:"learning_level,omitempty"`
	DOI                string  `xml:"doi,omitempty" json:"doi,omitempty"`
	PMCID              string  `xml:"pmc_id,omitempty" json:"pmc_id,omitempty"`
	PMID               string  `xml:"pmid,omitempty" json:"pmid,omitempty"`
	ParentURL          string  `xml:"parent_url,omitempty" json:"parent_url,omitempty"`
	AltURL             string  `xml:"alt_url,omitempty" json:"alt_url,omitempty"`
	Reference          []*Item `xml:"reference>item,omitempty" json:"reference,omitempty"`
	ConfCreators       []*Item `xml:"conf_creators>item,omitempty" json:"conf_creators,omitempty"`
	AltTitle           []*Item `xml:"alt_title>item,omitempty" json:"alt_title,omitempty"`
	TOC                string  `xml:"toc,omitempty" json:"toc,omitempty"`
	Interviewer        string  `xml:"interviewer,omitempty" json:"interviewer,omitempty"`
	InterviewDate      string  `xml:"interviewdate,omitempty" json:"interviewdate,omitempty"`
	GScholar           []*Item `xml:"gscholar,omitempty" json:"gscholar,omitempty"`
	NonSubjKeywords    string  `xml:"nonsubj_keywords,omitempty" json:"nonsubj_keywords,omitempty"`
	Season             string  `xml:"season,omitempty" json:"season,omitempty"`
	ClassificationCode string  `xml:"classification_code,omitempty" json:"classification_code,omitempty"`
	Shelves            []*Item `xml:"shelves>item,omitempty" json:"shelves,omitempty"`

	// NOTE: Sword deposit fields
	SwordDepository string `xml:"sword_depository,omitempty" json:"sword_depository,omitempty"`
	SwordSlug       string `xml:"sword_slug,omitempty" json:"sword_slug,omitempty"`
	ImportID        string `xml:"importid,omitempty" json:"import_id,omitempty"`

	// Patent related fields
	PatentApplicant      string  `xml:"patent_applicant,omitempty" json:"patent_applicant,omitempty"`
	PatentNumber         string  `xml:"patent_number,omitempty" json:"patent_number,omitempty"`
	PatentAssignee       []*Item `xml:"patent_assignee>item,omitempty" json:"patent_assignee,omitempty"`
	PatentClassification string  `xml:"patent_classification>item,omitempty" json:"patent_classification,omitempty"`
	RelatedPatents       []*Item `xml:"related_patents>item,omitempty" json:"related_patents,omitempty"`

	// Thesis oriented fields
	Divisions              []*Item `xml:"divisions>item,omitemmpty" json:"divisions,omitempty"`
	Institution            string  `xml:"institution,omitempty" json:"institution,omitempty"`
	ThesisType             string  `xml:"thesis_type,omitempty" json:"thesis_type,omitempty"`
	ThesisAdvisor          []*Item `xml:"thesis_advisor>item,omitempty" json:"thesis_advisor,omitempty"`
	ThesisCommittee        []*Item `xml:"thesis_committee>item,omitempty" json:"thesis_committee,omitempty"`
	ThesisDegree           string  `xml:"thesis_degree,omitempty" json:"thesis_degree,omitempty"`
	ThesisDegreeGrantor    string  `xml:"thesis_degree_grantor,omitempty" json:"thesis_degree_grantor,omitempty"`
	ThesisDegreeDate       string  `xml:"thesis_degree_date,omitempty" json:"thesis_degree_date,omitempty"`
	ThesisSubmittedDate    string  `xml:"thesis_submit_date,omitempty" json:"thesis_submit_date,omitempty"`
	ThesisDefenseDate      string  `xml:"thesis_defense_date,omitempty" json:"thesis_defense_date,omitempty"`
	ThesisApprovedDate     string  `xml:"thesis_approved_date,omitempty" json:"thesis_approved_date,omitempty"`
	ThesisPublicDate       string  `xml:"thesis_public_date,omitempty" json:"thesis_public_date,omitempty"`
	ThesisAuthorEMail      string  `xml:"thesis_author_email,omitempty" json:"thesis_author_email,omitempty"`
	HideThesisAuthorEMail  string  `xml:"hide_thesis_author_email,omitempty" json:"hide_thesis_author_email,omitempty"`
	GradOfficeApprovalDate string  `xml:"gradofc_approval_date,omitempty" json:"gradofc_approval_date,omitempty"`
	ThesisAwards           string  `xml:"thesis_awards,omitempty" json:"thesis_awards,omitempty"`
	ReviewStatus           string  `xml:"review_status,omitempty" json:"review_status,omitempty"`
	OptionMajor            []*Item `xml:"option_major>item,omitempty" json:"option_major,omitempty"`
	CopyrightStatement     string  `xml:"copyright_statement,omitempty" json:"copyright_statement,omitempty"`
}

EPrint is the record contated in a EPrints XML document such as they used to store revisions.

type EPrints added in v0.0.14

type EPrints struct {
	XMLName xml.Name `json:"-"`
	XMLNS   string   `xml:"xmlns,attr,omitempty" json:"xmlns,omitempty"`
	EPrint  *EPrint  `xml:"eprint" json:"eprint"`
}

EPrints is the high level XML you get from the REST API. E.g. curl -L -O https://eprints3.example.org/rest/eprint/1234.xml Then parse the 1234.xml document stucture.

type EPrintsAPI

type EPrintsAPI struct {
	XMLName xml.Name `json:"-"`
	// EP_EPRINT_URL
	URL *url.URL `xml:"epgo>eprint_url" json:"eprint_url"`
	// EP_DATASET
	Dataset string `xml:"epgo>dataset" json:"dataset"`
	// EP_AUTH_METHOD
	AuthType int
	// EP_USERNAME
	Username string
	// EP_PASSWORD
	Secret string
	// SuppressNote suppresses the Note field
	SuppressNote bool
}

EPrintsAPI holds the basic connectin information to read the REST API for EPrints

func New

func New(eprintURL, datasetName string, suppressNote bool, authMethod, userName, userSecret string) (*EPrintsAPI, error)

New creates a new API instance

func (*EPrintsAPI) ExportEPrints

func (api *EPrintsAPI) ExportEPrints(count int, saveKeys string, verbose bool) error

ExportEPrints from highest ID to lowest for cnt. Saves each record in a DB and indexes published ones

func (*EPrintsAPI) ExportModifiedEPrints added in v0.0.14

func (api *EPrintsAPI) ExportModifiedEPrints(start, end time.Time, saveKeys string, verbose bool) error

ExportModifiedEPrints returns a list of ids modified in one or between the start, end times

func (*EPrintsAPI) Get

func (api *EPrintsAPI) Get(uri string) (*Record, error)

Get retrieves an EPrint record from the dataset

func (*EPrintsAPI) GetEPrint

func (api *EPrintsAPI) GetEPrint(uri string) (*Record, []byte, error)

GetEPrint retrieves an EPrint record via REST API Returns a Record structure, the raw XML and an error.

func (*EPrintsAPI) ListEPrintsURI

func (api *EPrintsAPI) ListEPrintsURI() ([]string, error)

ListEPrintsURI returns a list of eprint record ids from the EPrints REST API

func (*EPrintsAPI) ListID added in v0.0.14

func (api *EPrintsAPI) ListID(start, count int) ([]string, error)

ListID returns a list of eprint record ids from the dataset

func (*EPrintsAPI) ListModifiedEPrintURI added in v0.0.14

func (api *EPrintsAPI) ListModifiedEPrintURI(start, end time.Time, verbose bool) ([]string, error)

ListModifiedEPrintURI return a list of modifed EPrint URI (eprint_ids) in start and end times

type EPrintsDataSet added in v0.0.14

type EPrintsDataSet struct {
	XMLName xml.Name `xml:"html" json:"-"`
	Paths   []string `xml:"body>ul>li>a,omitempty" json:"paths"`
}

EPrintsDataSet is a struct for parsing the HTML page that returns a list of available EPrint IDs with links.

func (EPrintsDataSet) MarshalJSON added in v0.0.14

func (epds EPrintsDataSet) MarshalJSON() ([]byte, error)

MarshalJSON() renders the EPrintsDataSet HTML/XML as a list of ids

type File

type File struct {
	XMLName   xml.Name `json:"-"`
	ID        string   `xml:"id,attr" json:"id"`
	FileID    int      `xml:"fileid" json:"fileid"`
	DatasetID string   `xml:"datasetid" json:"datasetid"`
	ObjectID  int      `xml:"objectid" json:"objectid"`
	Filename  string   `xml:"filename" json:"filename"`
	MimeType  string   `xml:"mime_type" json:"mime_type"`
	Hash      string   `xml:"hash" json:"hash"`
	HashType  string   `xml:"hash_type" json:"hash_type"`
	FileSize  int      `xml:"filesize" json:"filesize"`
	MTime     string   `xml:"mtime" json:"mtime"`
	URL       string   `xml:"url" json:"url"`
}

File structures in Document

type Funder

type Funder struct {
	XMLName     xml.Name `json:"-"`
	Agency      string   `xml:"agency" json:"agency"`
	GrantNumber string   `xml:"grant_number,omitempty" json:"grant_number"`
}

Funder is a structure describing a funding source for record

type FunderList

type FunderList []*Funder

FunderList is an array of pointers to Funder structs

func (FunderList) ToAgencies

func (funders FunderList) ToAgencies() []string

ToAgencies takes an array of pointers to Funders and returns a list of Agency names

func (FunderList) ToGrantNumbers

func (funders FunderList) ToGrantNumbers() []string

ToGrantNumbers takes an array of pointers to Funders and returns a list of Agency names

type Generic added in v0.0.14

type Generic struct {
	XMLName   xml.Name
	EPrints   *EPrints    `xml:"eprints,omitempty" json:"eprints,omitempty"`
	EPrint    *EPrint     `xml:"eprint,omitempty" json:"eprint,omitempty"`
	Documents []*Document `xml:"document,omitempty" json:"documents,omitempty"`
	Files     []*File     `xml:"file,omitempty" json:"files,omitempty"`
	Items     []*Item     `xml:"item" json:"items,omitempty"`
	Value     string      `xml:",chardata" json:"value,omitempty"`
}

Generic attempts to parse a generic XML fragment into an array of JSON items

func (*Generic) MarshalJSON added in v0.0.14

func (g *Generic) MarshalJSON() ([]byte, error)

MarshalJSON() normalizes Generic into a sensible JSON structure

type Item added in v0.0.14

type Item struct {
	XMLName     xml.Name `xml:"item" json:"-"`
	Name        *Name    `xml:"name,omitempty" json:"name,omitempty"`
	ID          string   `xml:"id,omitempty" json:"id,omitempty"`
	EMail       string   `xml:"email,omitempty" json:"email,omitempty"`
	ShowEMail   string   `xml:"show_email,omitempty" json:"show_email,omitempty"`
	Role        string   `xml:"role,omitempty" json:"role,omitempty"`
	URL         string   `xml:"url,omitempty" json:"url,omitempty"`
	Type        string   `xml:"type,omitempty" json:"type,omitempty"`
	Description string   `xml:"description,omitempty" json:"description,omitempty"`
	Agency      string   `xml:"agency,omitempty" json:"agency,omitempty"`
	GrantNumber string   `xml:"grant_number,omitempty" json:"grant_number,omitempty"`
	URI         string   `xml:"uri,omitempty" json:"uri,omitempty"`
	ORCID       string   `xml:"orcid,omitempty" json:"orcid,omitempty"`
	Value       string   `xml:",chardata" json:"value,omitempty"`
}

Item is a generic type used by various fields (e.g. Creator, Division, OptionMajor)

func (*Item) MarshalJSON added in v0.0.14

func (item *Item) MarshalJSON() ([]byte, error)

MarshalJSON() is a custom JSON marshaler for Item

type Name added in v0.0.14

type Name struct {
	XMLName xml.Name `json:"-"`
	Family  string   `xml:"family,omitempty" json:"family,omitempty"`
	Given   string   `xml:"given,omitempty" json:"given,omitempty"`
	ID      string   `xml:"id,omitempty" json:"id,omitempty"`
	Value   string   `xml:",chardata" json:"value,omitempty"`
}

Name handles the "name" types found in Items.

func (*Name) MarshalJSON added in v0.0.14

func (name *Name) MarshalJSON() ([]byte, error)

MarshalJSON() is a custom JSON marshaler for Name

type NumberingSystem

type NumberingSystem struct {
	XMLName xml.Name `json:"-"`
	Name    string   `xml:"name" json:"name"`
	ID      string   `xml:"id" json:"id"`
}

NumberingSystem is a structure describing other numbering systems for record

type Person

type Person struct {
	XMLName xml.Name `json:"-"`
	Given   string   `xml:"name>given" json:"given"`
	Family  string   `xml:"name>family" json:"family"`
	ID      string   `xml:"id,omitempty" json:"id"`

	// Customizations for Caltech Library
	ORCID string `xml:"orcid,omitempty" json:"orcid,omitempty"`
	//EMail string `xml:"email,omitempty" json:"email,omitempty"`
	Role string `xml:"role,omitempty" json:"role,omitempty"`
}

Person returns the contents of eprint>creators>item>name as a struct

type PersonList

type PersonList []*Person

PersonList is an array of pointers to Person structs

func (PersonList) ToNames

func (persons PersonList) ToNames() []string

ToNames takes an array of pointers to Person and returns a list of names (family, given)

func (PersonList) ToORCIDs

func (persons PersonList) ToORCIDs() []string

ToORCIDs takes an an array of pointers to Person and returns a list of ORCID ids

type Record

type Record struct {
	XMLName   xml.Name     `json:"-"`
	XMLNS     string       `xml:"xmlns,attr,omitempty" json:"name_space,omitempty"`
	Title     string       `xml:"eprint>title" json:"title"`
	URI       string       `json:"uri"`
	Abstract  string       `xml:"eprint>abstract" json:"abstract"`
	Documents DocumentList `xml:"eprint>documents>document" json:"documents"`
	//FIXME: On CaltechAUTHORS I want to keep note, on CaltechTHESIS I don't want Note to be public, need to have a way optionally showing or remove the Note
	Note                 string             `xml:"eprint>note" json:"note,omitempty"`
	ID                   int                `xml:"eprint>eprintid" json:"id"`
	RevNumber            int                `xml:"eprint>rev_number" json:"rev_number"`
	UserID               int                `xml:"eprint>userid" json:"user_id,omitempty"`
	Dir                  string             `xml:"eprint>dir" json:"eprint_dir"`
	Datestamp            string             `xml:"eprint>datestamp" json:"datestamp"`
	LastModified         string             `xml:"eprint>lastmod" json:"lastmod"`
	StatusChange         string             `xml:"eprint>status_changed" json:"status_changed"`
	Type                 string             `xml:"eprint>type" json:"type"`
	MetadataVisibility   string             `xml:"eprint>metadata_visibility" json:"metadata_visibility"`
	Creators             PersonList         `xml:"eprint>creators>item" json:"creators"`
	IsPublished          string             `xml:"eprint>ispublished" json:"is_published"`
	Subjects             []string           `xml:"eprint>subjects>item" json:"subjects,omitempty"`
	FullTextStatus       string             `xml:"eprint>full_text_status" json:"full_text_status"`
	Keywords             string             `xml:"eprint>keywords" json:"keywords,omitempty"`
	Date                 string             `xml:"eprint>date" json:"date"`
	DateType             string             `xml:"eprint>date_type" json:"date_type"`
	Publication          string             `xml:"eprint>publication" json:"publication,omitempty"`
	Volume               string             `xml:"eprint>volume" json:"volume,omitempty"`
	Number               string             `xml:"eprint>number" json:"number,omitempty"`
	PageRange            string             `xml:"eprint>pagerange" json:"pagerange,omitempty"`
	IDNumber             string             `xml:"eprint>id_number" json:"id_number,omitempty"`
	Refereed             bool               `xml:"eprint>refereed" json:"refereed,omitempty"`
	ISSN                 string             `xml:"eprint>issn" json:"issn,omitempty"`
	DOI                  string             `xml:"eprint>doi,omitempty" json:"doi,omitempty"`
	OfficialURL          string             `xml:"eprint>official_url" json:"official_url"`
	RelatedURL           []*RelatedURL      `xml:"eprint>related_url>item" json:"related_url,omitempty"`
	ReferenceText        []string           `xml:"eprint>referencetext>item" json:"referencetext,omitempty"`
	Rights               string             `xml:"eprint>rights" json:"rights"`
	OfficialCitation     string             `xml:"eprint>official_cit" json:"official_citation"`
	OtherNumberingSystem []*NumberingSystem `xml:"eprint>other_numbering_system>item,omitempty" json:"other_numbering_system,omitempty"`
	Funders              FunderList         `xml:"eprint>funders>item" json:"funders,omitempty"`
	Collection           string             `xml:"eprint>collection" json:"collection"`

	// Thesis repository Customizations
	ThesisType          string     `xml:"eprint>thesis_type,omitempty" json:"thesis_type,omitempty"`
	ThesisAdvisors      PersonList `xml:"eprint>thesis_advisor>item,omitempty" json:"thesis_advisor,omitempty"`
	ThesisCommittee     PersonList `xml:"eprint>thesis_committee>item,omitempty" json:"thesis_committee,omitempty"`
	ThesisDegree        string     `xml:"eprint>thesis_degree,omitempty" json:"thesis_degree,omitempty"`
	ThesisDegreeGrantor string     `xml:"eprint>thesis_degree_grantor,omitempty" json:"thesis_degree_grantor,omitempty"`
	ThesisDefenseDate   string     `xml:"eprint>thesis_defense_date,omitempty" json:"thesis_defense_date,omitempty"`
	OptionMajor         string     `xml:"eprint>option_major>item,omitempty" json:"option_major,omitempty"`
	OptionMinor         string     `xml:"eprint>option_minor>item,omitempty" json:"option_minor,omitempty"`
	GradOfcApprovalDate string     `xml:"eprint>gradofc_approval_date,omitempty" json:"gradofc_approval_date,omitempty"`

	Reviewer   string   `xml:"eprint>reviewer" json:"reviewer,omitempty"`
	LocalGroup []string `xml:"eprint>local_group>item" json:"local_group,omitempty"`
}

Record returns a structure that can be converted to JSON easily, in the XML is everything inside an <eprint> element.

func (*Record) PubDate

func (record *Record) PubDate() string

type RelatedURL

type RelatedURL struct {
	XMLName     xml.Name `json:"-"`
	URL         string   `xml:"url" json:"url"`
	Type        string   `xml:"type" json:"type"`
	Description string   `xml:"description" json:"description"`
}

RelatedURL is a structure containing information about a relationship

Directories

Path Synopsis
cmd
ep command
Package ep is a collection of structures and functions for working with the EPrints REST API @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.
Package ep is a collection of structures and functions for working with the EPrints REST API @author R. S. Doiel, <rsdoiel@caltech.edu> Copyright (c) 2017, Caltech All rights not granted herein are expressly reserved by Caltech.
eputil command
eputil is a command line tool for interacting with the EPrints REST API.
eputil is a command line tool for interacting with the EPrints REST API.

Jump to

Keyboard shortcuts

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