datacite

package
v0.3.19 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package datacite provides function to convert DataCite metadata to/from the commonmeta metadata format.

Index

Constants

This section is empty.

Variables

View Source
var CMToDCMappings = map[string]string{
	"Article":               "Preprint",
	"Audiovisual":           "Audiovisual",
	"Book":                  "Book",
	"BookChapter":           "BookChapter",
	"Collection":            "Collection",
	"Dataset":               "Dataset",
	"Document":              "Text",
	"Entry":                 "Text",
	"Event":                 "Event",
	"Figure":                "Image",
	"Image":                 "Image",
	"Instrument":            "Instrument",
	"JournalArticle":        "JournalArticle",
	"LegalDocument":         "Text",
	"Manuscript":            "Text",
	"Map":                   "Image",
	"Patent":                "Text",
	"Performance":           "Audiovisual",
	"PersonalCommunication": "Text",
	"Post":                  "Text",
	"ProceedingsArticle":    "ConferencePaper",
	"Proceedings":           "ConferenceProceeding",
	"Report":                "Report",
	"Review":                "PeerReview",
	"Software":              "Software",
	"Sound":                 "Sound",
	"Standard":              "Standard",
	"StudyRegistration":     "StudyRegistration",
	"WebPage":               "Text",
}
View Source
var DCToCMMappings = map[string]string{
	"Audiovisual":           "Audiovisual",
	"BlogPosting":           "Article",
	"Book":                  "Book",
	"BookChapter":           "BookChapter",
	"Collection":            "Collection",
	"ComputationalNotebook": "ComputationalNotebook",
	"ConferencePaper":       "ProceedingsArticle",
	"ConferenceProceeding":  "Proceedings",
	"DataPaper":             "JournalArticle",
	"Dataset":               "Dataset",
	"Dissertation":          "Dissertation",
	"Event":                 "Event",
	"Image":                 "Image",
	"Instrument":            "Instrument",
	"InteractiveResource":   "InteractiveResource",
	"Journal":               "Journal",
	"JournalArticle":        "JournalArticle",
	"Model":                 "Model",
	"OutputManagementPlan":  "OutputManagementPlan",
	"PeerReview":            "PeerReview",
	"PhysicalObject":        "PhysicalObject",
	"Poster":                "Presentation",
	"Preprint":              "Article",
	"Report":                "Report",
	"Service":               "Service",
	"Software":              "Software",
	"Sound":                 "Sound",
	"Standard":              "Standard",
	"StudyRegistration":     "StudyRegistration",
	"Text":                  "Document",
	"Thesis":                "Dissertation",
	"Workflow":              "Workflow",
	"Other":                 "Other",
}

DCToCMMappings maps DataCite resource types to Commonmeta types source: https://github.com/datacite/schema/blob/master/source/meta/kernel-4/include/datacite-resourceType-v4.xsd

Functions

func Fetch added in v0.2.1

func Fetch(str string) (commonmeta.Data, error)

Fetch fetches DataCite metadata for a given DOI and returns Commonmeta metadata.

func FetchAll added in v0.2.14

func FetchAll(number int, sample bool) ([]commonmeta.Data, error)

FetchAll gets the metadata for a list of works from the DataCite API and returns Commonmeta metadata.

func GetContributor

func GetContributor(v ContentContributor) commonmeta.Contributor

GetContributor converts DataCite contributor metadata into the Commonmeta format

func Load added in v0.2.1

func Load(filename string) (commonmeta.Data, error)

Load loads the metadata for a single work from a JSON file

func LoadAll added in v0.2.14

func LoadAll(filename string) ([]commonmeta.Data, error)

LoadAll loads a list of DataCite metadata from a JSON string and returns Commonmeta metadata.

func QueryURL added in v0.2.1

func QueryURL(number int, sample bool) string

QueryURL returns the URL for the DataCite API query

func Read added in v0.2.1

func Read(content Content) (commonmeta.Data, error)

Read reads DataCite JSON response and return work struct in Commonmeta format

func ReadAll added in v0.2.13

func ReadAll(content []Content) ([]commonmeta.Data, error)

ReadAll reads a list of DataCite JSON responses and returns a list of works in Commonmeta format

func Write added in v0.2.4

func Write(data commonmeta.Data) ([]byte, []gojsonschema.ResultError)

Write writes commonmeta metadata.

func WriteAll added in v0.2.13

func WriteAll(list []commonmeta.Data) ([]byte, []gojsonschema.ResultError)

WriteAll writes a list of commonmeta metadata.

Types

type Affiliation added in v0.2.4

type Affiliation struct {
	AffiliationIdentifier       string `json:"affiliationIdentifier,omitempty"`
	AffiliationIdentifierScheme string `json:"affiliationIdentifierScheme,omitempty"`
	SchemeURI                   string `json:"schemeUri,omitempty"`
	Name                        string `json:"name"`
}

type AlternateIdentifier added in v0.2.4

type AlternateIdentifier struct {
	AlternateIdentifier     string `json:"alternateIdentifier,omitempty"`
	AlternateIdentifierType string `json:"alternateIdentifierType,omitempty"`
}

AlternateIdentifier represents an alternate identifier in the DataCite metadata.

type Container added in v0.2.4

type Container struct {
	Type           string `json:"type,omitempty"`
	Identifier     string `json:"identifier,omitempty"`
	IdentifierType string `json:"identifierType,omitempty"`
	Title          string `json:"title,omitempty"`
	Volume         string `json:"volume,omitempty"`
	Issue          string `json:"issue,omitempty"`
	FirstPage      string `json:"firstPage,omitempty"`
	LastPage       string `json:"lastPage,omitempty"`
}

Container represents the container of the DataCite JSONAPI response.

type Content

type Content struct {
	*Datacite
	Creators        []ContentContributor `json:"creators"`
	Contributors    []ContentContributor `json:"contributors"`
	PublicationYear json.RawMessage      `json:"publicationYear"`
	Publisher       json.RawMessage      `json:"publisher"`
}

Content represents the DataCite metadata returned from DataCite. The type is more flexible than the Datacite type, allowing for different formats of some metadata. Affiliation can be string or struct, PublicationYear can be int or string. Publisher can be string or struct.

func Get added in v0.2.1

func Get(id string) (Content, error)

Get gets DataCite metadata for a given DOI

func GetAll added in v0.2.14

func GetAll(number int, sample bool) ([]Content, error)

GetAll gets the metadata for a list of works from the DataCite API

func ReadJSON added in v0.2.4

func ReadJSON(filename string) (Content, error)

ReadJSON reads JSON from a file and unmarshals it

func ReadJSONLines added in v0.2.4

func ReadJSONLines(filename string) ([]Content, error)

ReadJSONLines reads JSON lines from a file and unmarshals them

type ContentContributor added in v0.2.4

type ContentContributor struct {
	*Contributor
	Affiliation json.RawMessage `json:"affiliation,omitempty"`
}

ContentContributor represents a creator or contributor in the DataCite JSONAPI response.

type Contributor

type Contributor struct {
	Name            string           `json:"name,omitempty"`
	GivenName       string           `json:"givenName,omitempty"`
	FamilyName      string           `json:"familyName,omitempty"`
	NameType        string           `json:"nameType"`
	Affiliation     []string         `json:"affiliation,omitempty"`
	NameIdentifiers []NameIdentifier `json:"nameIdentifiers,omitempty"`
	ContributorType string           `json:"contributorType,omitempty"`
}

Contributor represents the contributor of the DataCite JSONAPI response.

type Datacite added in v0.2.4

type Datacite struct {
	ID                   string                `json:"id"`
	DOI                  string                `json:"doi"`
	AlternateIdentifiers []AlternateIdentifier `json:"alternateIdentifiers,omitempty"`
	Creators             []Contributor         `json:"creators"`
	Publisher            Publisher             `json:"publisher"`
	Container            Container             `json:"container,omitempty"`
	PublicationYear      int                   `json:"publicationYear"`
	Titles               []Title               `json:"titles"`
	URL                  string                `json:"url"`
	Subjects             []Subject             `json:"subjects,omitempty"`
	Contributors         []Contributor         `json:"contributors,omitempty"`
	Dates                []Date                `json:"dates,omitempty"`
	Language             string                `json:"language,omitempty"`
	Types                Types                 `json:"types"`
	RelatedIdentifiers   []RelatedIdentifier   `json:"relatedIdentifiers,omitempty"`
	Sizes                []string              `json:"sizes,omitempty"`
	Formats              []string              `json:"formats,omitempty"`
	Version              string                `json:"version,omitempty"`
	RightsList           []Rights              `json:"rightsList,omitempty"`
	Descriptions         []Description         `json:"descriptions,omitempty"`
	GeoLocations         []GeoLocation         `json:"geoLocations,omitempty"`
	FundingReferences    []FundingReference    `json:"fundingReferences,omitempty"`
	SchemaVersion        string                `json:"schemaVersion"`
}

Datacite represents the DataCite metadata.

func Convert added in v0.2.4

func Convert(data commonmeta.Data) (Datacite, error)

Convert converts Commonmeta metadata to DataCite metadata

type Date added in v0.2.4

type Date struct {
	Date            string `json:"date,omitempty"`
	DateType        string `json:"dateType,omitempty"`
	DateInformation string `json:"dateInformation,omitempty"`
}

type Description added in v0.2.4

type Description struct {
	Description     string `json:"description,omitempty"`
	DescriptionType string `json:"descriptionType,omitempty"`
	Lang            string `json:"lang,omitempty"`
}

type FundingReference added in v0.2.4

type FundingReference struct {
	FunderName           string `json:"funderName,omitempty"`
	FunderIdentifier     string `json:"funderIdentifier,omitempty"`
	FunderIdentifierType string `json:"funderIdentifierType,omitempty"`
	AwardNumber          string `json:"awardNumber,omitempty"`
	AwardURI             string `json:"awardUri,omitempty"`
}

type GeoLocation added in v0.2.1

type GeoLocation struct {
	GeoLocationPoint `json:"geoLocationPoint,omitempty"`
	GeoLocationBox   `json:"geoLocationBox,omitempty"`
	GeoLocationPlace string `json:"geoLocationPlace,omitempty"`
}

type GeoLocationBox added in v0.2.1

type GeoLocationBox struct {
	WestBoundLongitude float64 `json:"westBoundLongitude,string,omitempty"`
	EastBoundLongitude float64 `json:"eastBoundLongitude,string,omitempty"`
	SouthBoundLatitude float64 `json:"southBoundLatitude,string,omitempty"`
	NorthBoundLatitude float64 `json:"northBoundLatitude,string,omitempty"`
}

type GeoLocationPoint added in v0.2.1

type GeoLocationPoint struct {
	PointLongitude float64 `json:"pointLongitude,string,omitempty"`
	PointLatitude  float64 `json:"pointLatitude,string,omitempty"`
}

type NameIdentifier added in v0.2.4

type NameIdentifier struct {
	NameIdentifier       string `json:"nameIdentifier,omitempty"`
	NameIdentifierScheme string `json:"nameIdentifierScheme,omitempty"`
	SchemeURI            string `json:"schemeUri,omitempty"`
}

type Publisher added in v0.2.4

type Publisher struct {
	Name                      string `json:"name"`
	PublisherIdentifier       string `json:"publisherIdentifier,omitempty"`
	PublisherIdentifierScheme string `json:"publisherIdentifierScheme,omitempty"`
	SchemeURI                 string `json:"schemeUri,omitempty"`
	Lang                      string `json:"lang,omitempty"`
}

type RelatedIdentifier added in v0.2.4

type RelatedIdentifier struct {
	RelatedIdentifier     string `json:"relatedIdentifier,omitempty"`
	RelatedIdentifierType string `json:"relatedIdentifierType,omitempty"`
	RelationType          string `json:"relationType,omitempty"`
}

type Rights added in v0.2.4

type Rights struct {
	Rights                 string `json:"rights,omitempty"`
	RightsURI              string `json:"rightsUri,omitempty"`
	SchemeURI              string `json:"schemeUri,omitempty"`
	RightsIdentifier       string `json:"rightsIdentifier,omitempty"`
	RightsIdentifierScheme string `json:"rightsIdentifierScheme,omitempty"`
}

type Subject added in v0.2.4

type Subject struct {
	Subject string `json:"subject,omitempty"`
}

type Title added in v0.2.4

type Title struct {
	Title     string `json:"title"`
	TitleType string `json:"titleType,omitempty"`
	Lang      string `json:"lang,omitempty"`
}

type Types added in v0.2.4

type Types struct {
	ResourceTypeGeneral string `json:"resourceTypeGeneral"`
	ResourceType        string `json:"resourceType,omitempty"`
	Ris                 string `json:"ris,omitempty"`
	Bibtex              string `json:"bibtex,omitempty"`
	Citeproc            string `json:"citeproc,omitempty"`
	SchemaOrg           string `json:"schemaOrg,omitempty"`
}

Jump to

Keyboard shortcuts

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