commonmeta

package
v0.6.32 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package commonmeta provides functions to read and write commonmeta metadata.

Index

Constants

This section is empty.

Variables

View Source
var CMToSOMappings = map[string]string{
	"Article":        "Article",
	"Audiovisual":    "CreativeWork",
	"Book":           "Book",
	"BookChapter":    "BookChapter",
	"Collection":     "CreativeWork",
	"Dataset":        "Dataset",
	"Dissertation":   "Dissertation",
	"Document":       "CreativeWork",
	"Entry":          "CreativeWork",
	"Event":          "CreativeWork",
	"Figure":         "CreativeWork",
	"Image":          "CreativeWork",
	"Instrument":     "Instrument",
	"JournalArticle": "ScholarlyArticle",
	"LegalDocument":  "Legislation",
	"Software":       "SoftwareSourceCode",
	"Presentation":   "PresentationDigitalDocument",
}

CMToSOMappings maps Commonmeta types to Schema.org types.

View Source
var ContainerTypes = map[string]string{
	"BookChapter":        "Book",
	"Dataset":            "Database",
	"JournalArticle":     "Journal",
	"JournalIssue":       "Journal",
	"Book":               "BookSeries",
	"ProceedingsArticle": "Proceedings",
	"Article":            "Periodical",
}

ContainerTypes maps types to associated container types

View Source
var ContributorRoles = []string{
	"Author",
	"Editor",
	"Chair",
	"Reviewer",
	"ReviewAssistant",
	"StatsReviewer",
	"ReviewerExternal",
	"Reader",
	"Translator",
	"ContactPerson",
	"DataCollector",
	"DataManager",
	"Distributor",
	"HostingInstitution",
	"Producer",
	"ProjectLeader",
	"ProjectManager",
	"ProjectMember",
	"RegistrationAgency",
	"RegistrationAuthority",
	"RelatedPerson",
	"ResearchGroup",
	"RightsHolder",
	"Researcher",
	"Sponsor",
	"WorkPackageLeader",
	"Conceptualization",
	"DataCuration",
	"FormalAnalysis",
	"FundingAcquisition",
	"Investigation",
	"Methodology",
	"ProjectAdministration",
	"Resources",
	"Software",
	"Supervision",
	"Validation",
	"Visualization",
	"WritingOriginalDraft",
	"WritingReviewEditing",
	"Maintainer",
	"Other",
}

ContributorRoles list of contributor roles defined in commonmeta schema.

from commonmeta schema

View Source
var IdentifierTypes = []string{
	"ARK",
	"arXiv",
	"Bibcode",
	"DOI",
	"GUID",
	"Handle",
	"ISBN",
	"ISSN",
	"PMID",
	"PMCID",
	"PURL",
	"RID",
	"URL",
	"URN",
	"UUID",
	"Other",
}

IdentifierTypes list of identifier types defined in the commonmeta schema.

Functions

func Write added in v0.2.1

func Write(data Data) ([]byte, error)

Write writes commonmeta metadata.

func WriteAll added in v0.2.13

func WriteAll(list []Data) ([]byte, error)

WriteAll writes commonmeta metadata in slice format.

Types

type APIResponse added in v0.5.30

type APIResponse struct {
	DOI        string `json:"doi"`
	ID         string `json:"id,omitempty"`
	DOIBatchID string `json:"doi_batch_id,omitempty"`
	UUID       string `json:"uuid,omitempty"`
	Community  string `json:"community,omitempty"`
	Created    string `json:"created,omitempty"`
	Updated    string `json:"updated,omitempty"`
	Timestamp  string `json:"timestamp,omitempty"`
	Status     string `json:"status,omitempty"`
}

type Affiliation added in v0.2.1

type Affiliation struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

Affiliation represents the affiliation of a contributor, defined in the commonmeta JSON Schema.

type Container added in v0.2.1

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

Container represents the container of a publication, defined in the commonmeta JSON Schema.

func (*Container) Pages added in v0.2.4

func (c *Container) Pages() string

Pages returns the first and last page of a work as a string.

type Contributor added in v0.2.1

type Contributor struct {
	ID               string         `json:"id,omitempty"`
	Type             string         `json:"type,omitempty"`
	Name             string         `json:"name,omitempty"`
	GivenName        string         `json:"givenName,omitempty"`
	FamilyName       string         `json:"familyName,omitempty"`
	Affiliations     []*Affiliation `json:"affiliations,omitempty"`
	ContributorRoles []string       `json:"contributorRoles,omitempty"`
}

Contributor represents a contributor of a publication, defined in the commonmeta JSON Schema.

type Data added in v0.2.1

type Data struct {
	// required fields
	ID   string `db:"id" json:"id"`
	Type string `db:"type" json:"type"`

	// optional fields
	AdditionalType    string             `db:"additional_type" json:"additionalType,omitempty"`
	ArchiveLocations  []string           `db:"archive_locations" json:"archiveLocations,omitempty"`
	Container         Container          `db:"container" json:"container,omitempty"`
	ContentText       string             `db:"content" json:"content_text,omitempty"`
	Contributors      []Contributor      `db:"contributors" json:"contributors,omitempty"`
	Date              Date               `db:"date" json:"date,omitempty"`
	Descriptions      []Description      `db:"descriptions" json:"descriptions,omitempty"`
	FeatureImage      string             `db:"image" json:"feature_image,omitempty"`
	Files             []File             `db:"files" json:"files,omitempty"`
	FundingReferences []FundingReference `db:"funding_references" json:"fundingReferences,omitempty"`
	GeoLocations      []GeoLocation      `db:"geo_locations" json:"geoLocations,omitempty"`
	Identifiers       []Identifier       `db:"identifiers" json:"identifiers,omitempty"`
	Language          string             `db:"language" json:"language,omitempty"`
	License           License            `db:"license" json:"license,omitempty"`
	Provider          string             `db:"provider" json:"provider,omitempty"`
	Publisher         Publisher          `db:"publisher" json:"publisher,omitempty"`
	References        []Reference        `db:"references" json:"references,omitempty"`
	Relations         []Relation         `db:"relations" json:"relations,omitempty"`
	Subjects          []Subject          `db:"subjects" json:"subjects,omitempty"`
	Titles            []Title            `db:"titles" json:"titles,omitempty"`
	URL               string             `db:"url" json:"url,omitempty"`
	Version           string             `db:"version" json:"version,omitempty"`
}

Data represents the commonmeta metadata, defined in the commonmeta JSON Schema.

func Load added in v0.2.3

func Load(filename string) (Data, error)

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

func LoadAll added in v0.3.11

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

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

func Read added in v0.2.1

func Read(content Data) (Data, error)

Read reads commonmeta metadata.

func ReadAll added in v0.3.11

func ReadAll(content []Data) ([]Data, error)

ReadAll reads commonmeta metadata in slice format.

type Date added in v0.2.1

type Date struct {
	Created     string `json:"created,omitempty"`
	Submitted   string `json:"submitted,omitempty"`
	Accepted    string `json:"accepted,omitempty"`
	Published   string `json:"published,omitempty"`
	Updated     string `json:"updated,omitempty"`
	Accessed    string `json:"accessed,omitempty"`
	Available   string `json:"available,omitempty"`
	Copyrighted string `json:"copyrighted,omitempty"`
	Collected   string `json:"collected,omitempty"`
	Valid       string `json:"valid,omitempty"`
	Withdrawn   string `json:"withdrawn,omitempty"`
	Other       string `json:"other,omitempty"`
}

Date represents the date of a publication, defined in the commonmeta JSON Schema.

type Description added in v0.2.1

type Description struct {
	Description string `json:"description"`
	Type        string `json:"type,omitempty"`
	Language    string `json:"language,omitempty"`
}

Description represents the description of a publication, defined in the commonmeta JSON Schema.

type File added in v0.2.1

type File struct {
	Bucket   string `json:"bucket,omitempty"`
	Key      string `json:"key,omitempty"`
	Checksum string `json:"checksum,omitempty"`
	URL      string `json:"url"`
	Size     int    `json:"size,omitempty"`
	MimeType string `json:"mimeType,omitempty"`
}

File represents a file of a publication, defined in the commonmeta JSON Schema.

type FundingReference added in v0.2.1

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

FundingReference represents the funding reference of a publication, defined in the commonmeta JSON Schema.

type GeoLocation added in v0.2.1

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

GeoLocation represents the geographical location of a publication, defined in the commonmeta JSON Schema.

type GeoLocationBox added in v0.2.1

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

GeoLocationBox represents a box in a geographical location, defined in the commonmeta JSON Schema.

type GeoLocationPoint added in v0.2.1

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

GeoLocationPoint represents a point in a geographical location, defined in the commonmeta JSON Schema.

type GeoLocationPolygon added in v0.2.1

type GeoLocationPolygon struct {
	PolygonPoints  []GeoLocationPoint `json:"polygon_points,omitempty"`
	InPolygonPoint GeoLocationPoint   `json:"in_polygon_point,omitempty"`
}

GeoLocationPolygon represents a polygon in a geographical location, defined in the commonmeta JSON Schema.

type Identifier added in v0.2.1

type Identifier struct {
	Identifier     string `json:"identifier"`
	IdentifierType string `json:"identifierType"`
}

Identifier represents the identifier of a publication, defined in the commonmeta JSON Schema.

type License added in v0.2.1

type License struct {
	ID  string `json:"id,omitempty"`
	URL string `json:"url,omitempty"`
}

License represents the license of a publication, defined in the commonmeta JSON Schema.

type Publisher added in v0.2.1

type Publisher struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

Publisher represents the publisher of a publication, defined in the commonmeta JSON Schema.

type Reader added in v0.2.14

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

func NewReader added in v0.2.14

func NewReader(r io.Reader) *Reader

NewReader returns a new Reader that reads from r.

type Reference added in v0.2.1

type Reference struct {
	Key             string `json:"key"`
	ID              string `json:"id,omitempty"`
	Type            string `json:"type,omitempty"`
	Title           string `json:"title,omitempty"`
	PublicationYear string `json:"publicationYear,omitempty"`
	Unstructured    string `json:"unstructured,omitempty"`
}

Reference represents the reference of a publication, defined in the commonmeta JSON Schema.

type Relation added in v0.2.1

type Relation struct {
	ID   string `json:"id"`
	Type string `json:"type"`
}

Relation represents the relation of a publication, defined in the commonmeta JSON Schema.

type Subject added in v0.2.1

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

Subject represents the subject of a publication, defined in the commonmeta JSON Schema.

type Title added in v0.2.1

type Title struct {
	Title    string `json:"title,omitempty"`
	Type     string `json:"type,omitempty"`
	Language string `json:"language,omitempty"`
}

Title represents the title of a publication, defined in the commonmeta JSON Schema.

type Writer added in v0.2.14

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

func NewWriter added in v0.2.14

func NewWriter(w io.Writer) *Writer

NewWriter returns a new Writer that writes to w.

Jump to

Keyboard shortcuts

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