eprinttools

package module
v0.0.58 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: BSD-3-Clause Imports: 14 Imported by: 1

README

eprinttools

eprinttools is a Go package and command line utilities for working with EPrints 3.x EPrint XML and REST API.

The command line programs

  • 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
  • epfmt is a command line utility to pretty print EPrints XML and convert to/from JSON
    • in the process of pretty printing it also validates the EPrints XML against the eprinttools Go package definitions
  • ep is a EPrints harvester that integrates with dataset
  • doi2eprintxml is a command line program for turning metadata harvested from CrossRef and DataCite into an EPrint XML document based on one or more supplied DOI
  • eprintxml2json is a command line program for taking EPrint XML and turning it into JSON

The first two utilities can be 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.

Python integration via AMES

The eprintools command line programs have been made available to Python via the AMES project. This include support for both read and write to EPrints repository systems.

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) 2018, 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) 2018, 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.58`

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

)

Variables

This section is empty.

Functions

func GetKeys added in v0.0.14

func GetKeys(baseURL string, authType int, username string, secret string) ([]string, error)

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

func GetModifiedKeys added in v0.0.15

func GetModifiedKeys(baseURL string, authType int, username string, secret string, start time.Time, end time.Time, verbose bool) ([]string, error)

GetModifiedKeys returns a list of eprint record ids from the EPrints REST API that match the modification date range

Types

type AccompanimentItemList added in v0.0.14

type AccompanimentItemList struct {
	XMLName xml.Name `xml:"accompaniment" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

AccompanimentItemList

func (*AccompanimentItemList) AddItem added in v0.0.14

func (accompanimentItemList *AccompanimentItemList) AddItem(item *Item) int

AddItem adds an item to the accompaniment item list and returns the new count of items

type AltTitleItemList added in v0.0.14

type AltTitleItemList struct {
	XMLName xml.Name `xml:"alt_title" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

AltTitleItemList

func (*AltTitleItemList) AddItem added in v0.0.14

func (altTitleItemList *AltTitleItemList) AddItem(item *Item) int

AddItem adds an item to the altTitle item list and returns the new count of items

type ConductorItemList added in v0.0.14

type ConductorItemList struct {
	XMLName xml.Name `xml:"conductors" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ConductorItemList

func (*ConductorItemList) AddItem added in v0.0.14

func (conductorItemList *ConductorItemList) AddItem(item *Item) int

AddItem adds an item to the conductor item list and returns the new count of items

type ConfCreatorItemList added in v0.0.14

type ConfCreatorItemList struct {
	XMLName xml.Name `xml:"conf_creators" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ConfCreatorItemList

func (*ConfCreatorItemList) AddItem added in v0.0.14

func (confCreatorItemList *ConfCreatorItemList) AddItem(item *Item) int

AddItem adds an item to the confCreator item list and returns the new count of items

type ContributorItemList added in v0.0.14

type ContributorItemList struct {
	XMLName xml.Name `xml:"contributors" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ContributorItemList

func (*ContributorItemList) AddItem added in v0.0.14

func (contributorItemList *ContributorItemList) AddItem(item *Item) int

AddItem adds an item to the contributor item list and returns the new count of items

type CopyrightHolderItemList added in v0.0.14

type CopyrightHolderItemList struct {
	XMLName xml.Name `xml:"copyright_holders" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

CopyrightHolderItemList

func (*CopyrightHolderItemList) AddItem added in v0.0.14

func (copyrightHolderItemList *CopyrightHolderItemList) AddItem(item *Item) int

AddItem adds an item to the copyrightHolder item list and returns the new count of items

type CorpCreatorItemList added in v0.0.14

type CorpCreatorItemList struct {
	XMLName xml.Name `json:"-"` //`xml:"corp_creators" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

CorpCreatorItemList

func (*CorpCreatorItemList) AddItem added in v0.0.14

func (corpCreatorItemList *CorpCreatorItemList) AddItem(item *Item) int

AddItem adds an item to the corp creator item list and returns the new count of items

type CreatorItemList added in v0.0.14

type CreatorItemList struct {
	XMLName xml.Name `xml:"creators" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

CreatorItemList holds a list of authors

func (*CreatorItemList) AddItem added in v0.0.14

func (creatorItemList *CreatorItemList) AddItem(item *Item) int

AddItem adds an item to the Creator list and returns the new count of items

type DivisionItemList added in v0.0.14

type DivisionItemList struct {
	XMLName xml.Name `xml:"divisions" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

DivisionItemList

func (*DivisionItemList) AddItem added in v0.0.14

func (divisionItemList *DivisionItemList) AddItem(item *Item) int

AddItem adds an item to the division item list and returns the new count of items

type Document

type Document struct {
	XMLName    xml.Name `json:"-"`
	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,omitempty" 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,omitempty" json:"language,omitempty"`
	Security   string   `xml:"security" json:"security"`
	License    string   `xml:"license" json:"license"`
	Main       string   `xml:"main" json:"main"`
	Content    string   `xml:"content,omitempty" json:"content,omitempty"`
	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

func (DocumentList) AddDocument added in v0.0.20

func (documentList DocumentList) AddDocument(document *Document) int

AddDocument adds a document to the documents list and returns the new count of items

func (DocumentList) IndexOf added in v0.0.28

func (documentList DocumentList) IndexOf(i int) *Document

GetDocument takes a position (zero based) and returns the *Document in the DocumentList.

func (DocumentList) Length added in v0.0.28

func (documentList DocumentList) Length() int

Length returns the length of DocumentList

type EPrint added in v0.0.14

type EPrint struct {
	XMLName              xml.Name                      `json:"-"`
	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            *DocumentList                 `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             *CreatorItemList              `xml:"creators,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"`
	Volume               string                        `xml:"volume,omitempty" json:"volume,omitempty"`
	Number               string                        `xml:"number,omitempty" json:"number,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              *EditorItemList               `xml:"editors,omitempty" json:"editors,omitempty"`
	OfficialURL          string                        `xml:"official_url,omitempty" json:"official_url,omitempty"`
	RelatedURL           *RelatedURLItemList           `xml:"related_url,omitempty" json:"related_url,omitempty"`
	ReferenceText        *ReferenceTextItemList        `xml:"referencetext,omitempty" json:"referencetext,omitempty"`
	Projects             *ProjectItemList              `xml:"projects,omitempty" json:"projects,omitempty"`
	Rights               string                        `xml:"rights,omitempty" json:"rights,omitempty"`
	Funders              *FunderItemList               `xml:"funders,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 *OtherNumberingSystemItemList `xml:"other_numbering_system,omitempty" json:"other_numbering_system,omitempty"`
	LocalGroup           *LocalGroupItemList           `xml:"local_group,omitempty" json:"local_group,omitempty"`
	Errata               *ErrataItemList               `xml:"errata,omitempty" json:"errata,omitempty"`
	Contributors         *ContributorItemList          `xml:"contributors,omitempty" json:"contributors,omitempty"`
	MonographType        string                        `xml:"monograph_type,omitempty" json:"monograph_type,omitempty"`

	// Caltech Library uses suggestions as an internal note field (RSD, 2018-02-15)
	Suggestions string            `xml:"suggestions,omitempty" json:"suggestions,omitempty"`
	OtherURL    *OtherURLItemList `xml:"other_url,omitempty" json:"other_url,omitempty"`

	// NOTE: Misc fields discoverd exploring REST API records, not currently used at Caltech Library (RSD, 2018-01-02)
	Subjects           *SubjectItemList         `xml:"subjects,omitempty" json:"subjects,omitempty"`
	PresType           string                   `xml:"pres_type,omitempty" json:"presentation_type,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         *ItemIssueItemList       `xml:"item_issues,omitempty" json:"item_issues,omitempty"`
	ItemIssuesCount    int                      `xml:"item_issues_count,omitempty" json:"item_issues_count,omitempty"`
	CorpCreators       *CorpCreatorItemList     `xml:"corp_creators,omitempty" json:"corp_creators,omitempty"`
	Department         string                   `xml:"department,omitempty" json:"department,omitempty"`
	OutputMedia        string                   `xml:"output_media,omitempty" json:"output_media,omitempty"`
	Exhibitors         *ExhibitorItemList       `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          *ProducerItemList        `xml:"producers,omitempty" json:"producers,omitempty"`
	Conductors         *ConductorItemList       `xml:"conductors,omitempty" json:"conductors,omitempty"`
	Lyricists          *LyricistItemList        `xml:"lyricists,omitempty" json:"lyricists,omitempty"`
	Accompaniment      *AccompanimentItemList   `xml:"accompaniment,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         *SkillAreaItemList       `xml:"skill_areas,omitempty" json:"skill_areas,omitempty"`
	CopyrightHolders   *CopyrightHolderItemList `xml:"copyright_holders,omitempty" json:"copyright_holders,omitempty"`
	LearningLevel      *LearningLevelItemList   `xml:"learning_level,omitempty" json:"learning_level,omitempty"`
	DOI                string                   `xml:"doi,omitempty" json:"doi,omitempty"`
	PMCID              string                   `xml:"pmc_id,omitempty" json:"pmcid,omitempty"`
	PMID               string                   `xml:"pmid,omitempty" json:"pmid,omitempty"`
	ParentURL          string                   `xml:"parent_url,omitempty" json:"parent_url,omitempty"`
	Reference          *ReferenceItemList       `xml:"reference,omitempty" json:"reference,omitempty"`
	ConfCreators       *ConfCreatorItemList     `xml:"conf_creators,omitempty" json:"conf_creators,omitempty"`
	AltTitle           *AltTitleItemList        `xml:"alt_title,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           *GScholarItemList        `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            *ShelfItemList           `xml:"shelves,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       *PatentAssigneeItemList       `xml:"patent_assignee,omitempty" json:"patent_assignee,omitempty"`
	PatentClassification *PatentClassificationItemList `xml:"patent_classification,omitempty" json:"patent_classification,omitempty"`
	RelatedPatents       *RelatedPatentItemList        `xml:"related_patents,omitempty" json:"related_patents,omitempty"`

	// Thesis oriented fields
	Divisions              *DivisionItemList        `xml:"divisions,omitemmpty" json:"divisions,omitempty"`
	Institution            string                   `xml:"institution,omitempty" json:"institution,omitempty"`
	ThesisType             string                   `xml:"thesis_type,omitempty" json:"thesis_type,omitempty"`
	ThesisAdvisor          *ThesisAdvisorItemList   `xml:"thesis_advisor,omitempty" json:"thesis_advisor,omitempty"`
	ThesisCommittee        *ThesisCommitteeItemList `xml:"thesis_committee,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            *OptionMajorItemList     `xml:"option_major,omitempty" json:"option_major,omitempty"`
	CopyrightStatement     string                   `xml:"copyright_statement,omitempty" json:"copyright_statement,omitempty"`

	// Synthetic fields are created to help in eventual migration of
	// EPrints field data to other JSON formats.
	PrimaryObject  map[string]interface{}   `xml:"-" json:"primary_object,omitempty"`
	RelatedObjects []map[string]interface{} `xml:"-" json:"related_objects,omitempty"`
}

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

func CrossRefWorksToEPrint added in v0.0.17

func CrossRefWorksToEPrint(obj crossrefapi.Object) (*EPrint, error)

CrossRefWorksToEPrint takes a works object from the CrossRef API and maps the fields into an EPrint struct return a new struct or error.

func DataCiteWorksToEPrint added in v0.0.17

func DataCiteWorksToEPrint(obj dataciteapi.Object) (*EPrint, error)

DataCiteWorksToEPrint takes a works object from the DataCite API and maps the fields into an EPrint struct return a new struct or error.

func (*EPrint) PubDate added in v0.0.14

func (record *EPrint) PubDate() string

func (*EPrint) SyntheticFields added in v0.0.52

func (e *EPrint) SyntheticFields()

SyntheticFields renders analyzes an EPrint object and populates or updates any synthetic fields like primary_object and related_object.

type EPrints added in v0.0.14

type EPrints struct {
	XMLName xml.Name  `xml:"eprints" 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.

func GetEPrints added in v0.0.14

func GetEPrints(baseURL string, authType int, username string, secret string, key string) (*EPrints, []byte, error)

GetEPrints retrieves an EPrint record (e.g. via REST API) A populated EPrints structure, the raw XML and an error.

func (*EPrints) AddEPrint added in v0.0.14

func (eprints *EPrints) AddEPrint(eprint *EPrint) int

AddEPrint appends an EPrint struct to an EPrints struct returning the count of attached eprints

type EPrintsAPI

type EPrintsAPI struct {
	XMLName xml.Name `json:"-"`
	// EPRINT_URL
	URL *url.URL `xml:"epgo>eprint_url" json:"eprint_url"`
	// EPRINT_DATASET
	Dataset string `xml:"epgo>dataset" json:"dataset"`
	// EPRINT_AUTH_METHOD
	AuthType int
	// EPRINT_USERNAME
	Username string
	// EPRINT_PASSWORD
	Secret string
	// SuppressSuggestions suppresses the Suggestions field
	// NOTE: Bibs at Caltech Library use Suggestions as notes in CaltechTHESIS
	SuppressSuggestions bool
}

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

func New

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

New creates a new API instance

func (*EPrintsAPI) GetEPrint

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

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

func (*EPrintsAPI) ListEPrintsURI

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

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

func (*EPrintsAPI) ListModifiedEPrintsURI added in v0.0.20

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

ListModifiedEPrintsURI 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 EditorItemList added in v0.0.14

type EditorItemList struct {
	XMLName xml.Name `xml:"editors" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

EditorItemList holds a list of editors

func (*EditorItemList) AddItem added in v0.0.14

func (editorItemList *EditorItemList) AddItem(item *Item) int

AddItem adds an item to the Editor item list and returns the new count of items

type ErrataItemList added in v0.0.14

type ErrataItemList struct {
	XMLName xml.Name `xml:"errata" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ErrataItemList

func (*ErrataItemList) AddItem added in v0.0.14

func (errataItemList *ErrataItemList) AddItem(item *Item) int

AddItem adds an item to the errata item list and returns the new count of items

type ExhibitorItemList added in v0.0.14

type ExhibitorItemList struct {
	XMLName xml.Name `xml:"exhibitors" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ExhibitorItemList

func (*ExhibitorItemList) AddItem added in v0.0.14

func (exhibitorItemList *ExhibitorItemList) AddItem(item *Item) int

AddItem adds an item to the exhibitor item list and returns the new count of items

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,omitempty" json:"hash,omitempty"`
	HashType  string   `xml:"hash_type,omitempty" json:"hash_type,omitempty"`
	FileSize  int      `xml:"filesize" json:"filesize"`
	MTime     string   `xml:"mtime" json:"mtime"`
	URL       string   `xml:"url" json:"url"`
}

File structures in Document

type FunderItemList added in v0.0.14

type FunderItemList struct {
	XMLName xml.Name `xml:"funders" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

FunderItemList

func (*FunderItemList) AddItem added in v0.0.14

func (funderItemList *FunderItemList) AddItem(item *Item) int

AddItem adds an item to the funder item list and returns the new count of items

type GScholarItemList added in v0.0.14

type GScholarItemList struct {
	XMLName xml.Name `xml:"gscholar" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

GScholarItemList

func (*GScholarItemList) AddItem added in v0.0.14

func (gScholarItemList *GScholarItemList) AddItem(item *Item) int

AddItem adds an item to the gScholar item list and returns the new count of items

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

func (*Item) UnmarshalJSON added in v0.0.33

func (item *Item) UnmarshalJSON(src []byte) error

type ItemIssueItemList added in v0.0.14

type ItemIssueItemList struct {
	XMLName xml.Name `xml:"item_issues" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ItemIssueItemList

func (*ItemIssueItemList) AddItem added in v0.0.14

func (issueItemList *ItemIssueItemList) AddItem(item *Item) int

AddItem adds an item to the issue item list and returns the new count of items

type LearningLevelItemList added in v0.0.14

type LearningLevelItemList struct {
	XMLName xml.Name `xml:"learning_level" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

LearningLevelItemList

func (*LearningLevelItemList) AddItem added in v0.0.14

func (learningLevelItemList *LearningLevelItemList) AddItem(item *Item) int

AddItem adds an item to the learningLevel item list and returns the new count of items

type LocalGroupItemList added in v0.0.14

type LocalGroupItemList struct {
	XMLName xml.Name `xml:"local_group" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

LocalGroupItemList holds the related URLs (e.g. doi, aux material doi)

func (*LocalGroupItemList) AddItem added in v0.0.14

func (localGroupItemList *LocalGroupItemList) AddItem(item *Item) int

AddItem adds an item to the local group item list and returns the new count of items

type LyricistItemList added in v0.0.14

type LyricistItemList struct {
	XMLName xml.Name `xml:"lyricists" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

LyricistItemList

func (*LyricistItemList) AddItem added in v0.0.14

func (lyricistItemList *LyricistItemList) AddItem(item *Item) int

AddItem adds an item to the lyricist item list and returns the new count of items

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"`
	ORCID   string   `xml:"orcid,omitempty" json:"orcid,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

func (*Name) String added in v0.0.14

func (name *Name) String() string

String() returns a json marshaled *Name as a string

type OptionMajorItemList added in v0.0.14

type OptionMajorItemList struct {
	XMLName xml.Name `xml:"option_major" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

OptionMajorItemList

func (*OptionMajorItemList) AddItem added in v0.0.14

func (optionMajorItemList *OptionMajorItemList) AddItem(item *Item) int

AddItem adds an item to the option major item list and returns the new count of items

type OtherNumberingSystemItemList added in v0.0.14

type OtherNumberingSystemItemList struct {
	XMLName xml.Name `xml:"other_numbering_system" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

OtherNumberingSystemItemList

func (*OtherNumberingSystemItemList) AddItem added in v0.0.14

func (otherNumberingSystemItemList *OtherNumberingSystemItemList) AddItem(item *Item) int

AddItem adds an item to the other numbering system item list and returns the new count of items

type OtherURLItemList added in v0.0.23

type OtherURLItemList struct {
	XMLName xml.Name `xml:"other_url" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

OtherURLItemList is a legacy Caltech Library field, old records have it new records use RelatedURLItemList RelatedURLItemList holds the related URLs (e.g. doi, aux material doi)

func (*OtherURLItemList) AddItem added in v0.0.23

func (otherURLItemList *OtherURLItemList) AddItem(item *Item) int

AddItem adds an item to the "other" url item list and returns the new count of items, this is a legacy Caltech Library-ism in EPrints

type PatentAssigneeItemList added in v0.0.14

type PatentAssigneeItemList struct {
	XMLName xml.Name `xml:"patent_assignee" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

PatentAssigneeItemList

func (*PatentAssigneeItemList) AddItem added in v0.0.14

func (patentAssigneeItemList *PatentAssigneeItemList) AddItem(item *Item) int

AddItem adds an item to the patent assignee item list and returns the new count of items

type PatentClassificationItemList added in v0.0.14

type PatentClassificationItemList struct {
	XMLName xml.Name `xml:"patent_classification" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

PatentClassificationItemList

func (*PatentClassificationItemList) AddItem added in v0.0.14

func (patentClassificationItemList *PatentClassificationItemList) AddItem(item *Item) int

AddItem adds an item to the patent classification item list and returns the new count of items

type ProducerItemList added in v0.0.14

type ProducerItemList struct {
	XMLName xml.Name `xml:"producers" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ProducerItemList

func (*ProducerItemList) AddItem added in v0.0.14

func (producerItemList *ProducerItemList) AddItem(item *Item) int

AddItem adds an item to the producer item list and returns the new count of items

type ProjectItemList added in v0.0.14

type ProjectItemList struct {
	XMLName xml.Name `xml:"projects" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ProjectItemList

func (*ProjectItemList) AddItem added in v0.0.14

func (projectItemList *ProjectItemList) AddItem(item *Item) int

AddItem adds an item to the project item list and returns the new count of items

type ReferenceItemList added in v0.0.14

type ReferenceItemList struct {
	XMLName xml.Name `xml:"reference" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ReferenceItemList

func (*ReferenceItemList) AddItem added in v0.0.14

func (referenceItemList *ReferenceItemList) AddItem(item *Item) int

AddItem adds an item to the reference item list and returns the new count of items

type ReferenceTextItemList added in v0.0.14

type ReferenceTextItemList struct {
	XMLName xml.Name `xml:"referencetext" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ReferenceTextItemList

func (*ReferenceTextItemList) AddItem added in v0.0.14

func (referenceTextItemList *ReferenceTextItemList) AddItem(item *Item) int

AddItem adds an item to the reference text url item list and returns the new count of items

func (*ReferenceTextItemList) UnmarshalJSON added in v0.0.32

func (referenceTextItemList *ReferenceTextItemList) UnmarshalJSON(src []byte) error

UnmarshJSON takes a reference text list of item and returns an appropriately values to assigned struct.

type RelatedPatentItemList added in v0.0.14

type RelatedPatentItemList struct {
	XMLName xml.Name `xml:"related_patents" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

RelatedPatentItemList

func (*RelatedPatentItemList) AddItem added in v0.0.14

func (relatedPatentItemList *RelatedPatentItemList) AddItem(item *Item) int

AddItem adds an item to the related patent item list and returns the new count of items

type RelatedURLItemList added in v0.0.14

type RelatedURLItemList struct {
	XMLName xml.Name `xml:"related_url" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

RelatedURLItemList holds the related URLs (e.g. doi, aux material doi)

func (*RelatedURLItemList) AddItem added in v0.0.14

func (relatedURLItemList *RelatedURLItemList) AddItem(item *Item) int

AddItem adds an item to the related url item list and returns the new count of items

type ShelfItemList added in v0.0.14

type ShelfItemList struct {
	XMLName xml.Name `xml:"shelves" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ShelfItemList

func (*ShelfItemList) AddItem added in v0.0.14

func (shelfItemList *ShelfItemList) AddItem(item *Item) int

AddItem adds an item to the shelf item list and returns the new count of items

type SkillAreaItemList added in v0.0.14

type SkillAreaItemList struct {
	XMLName xml.Name `xml:"skill_areas" json:"-"`
	Items   []*Item  `xml:"item,omitempty" jsons:"item,omitempty"`
}

SkillAreaItemList

func (*SkillAreaItemList) AddItem added in v0.0.14

func (skillAreaItemList *SkillAreaItemList) AddItem(item *Item) int

AddItem adds an item to the skillArea item list and returns the new count of items

type SubjectItemList added in v0.0.14

type SubjectItemList struct {
	XMLName xml.Name `xml:"subjects" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

SubjectItemList

func (*SubjectItemList) AddItem added in v0.0.14

func (subjectItemList *SubjectItemList) AddItem(item *Item) int

AddItem adds an item to the subject item list and returns the new count of items

type ThesisAdvisorItemList added in v0.0.14

type ThesisAdvisorItemList struct {
	XMLName xml.Name `xml:"thesis_advisor" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ThesisAdvisorItemList

func (*ThesisAdvisorItemList) AddItem added in v0.0.14

func (thesisAdvisorItemList *ThesisAdvisorItemList) AddItem(item *Item) int

AddItem adds an item to the thesis advisor item list and returns the new count of items

type ThesisCommitteeItemList added in v0.0.14

type ThesisCommitteeItemList struct {
	XMLName xml.Name `xml:"thesis_committee" json:"-"`
	Items   []*Item  `xml:"item,omitempty" json:"items,omitempty"`
}

ThesisCommitteeItemList

func (*ThesisCommitteeItemList) AddItem added in v0.0.14

func (thesisCommitteeItemList *ThesisCommitteeItemList) AddItem(item *Item) int

AddItem adds an item to the thesis committee item list and returns the new count of items

Directories

Path Synopsis
clsrules.go (Caltech Library Specific Rules) is a package for implementing Caltech Library Specific features to processing and creating EPrint XML.
clsrules.go (Caltech Library Specific Rules) is a package for implementing Caltech Library Specific features to processing and creating EPrint XML.
cmd
epfmt
epfmt is a command line tool convert EPrints XML to/from JSON.
epfmt is a command line tool convert EPrints XML to/from JSON.
eprintxml2json
eprintxml2json.go - converts EPrints XML to JSON
eprintxml2json.go - converts EPrints XML to JSON
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.
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.

Jump to

Keyboard shortcuts

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