Documentation
¶
Overview ¶
Package simplified is a package targetting intermediate bibliographic, software and data metadata representation at Caltech Library
@author R. S. Doiel, <rsdoiel@caltech.edu>
Copyright (c) 2023, 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
- type Access
- type Affiliation
- type AwardIdentifier
- type Creator
- type DateType
- type Description
- type Embargo
- type Entry
- type Feature
- type Files
- type Funder
- type Geometry
- type Identifier
- type Location
- type Metadata
- type PersistentIdentifier
- type PersonOrOrg
- type Record
- type RecordAccess
- type RecordIdentifier
- type Right
- type Role
- type Subject
- type TitleDetail
- type Tombstone
- type Type
- type TypeDetail
- type User
Constants ¶
const ( Version = "0.0.9" LicenseText = `` /* 1524-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Access ¶
type Access struct {
OwnedBy []*User `json:"owned_by,omitempty"`
}
Access is a third level element used by PersistentIdenitifier to describe access ownership of the record.
type Affiliation ¶
type Affiliation struct {
ID string `json:"id,omitempty"` // The organizational or institutional id from the controlled vocabularly
Name string `json:"name,omitempty"` // The name of the organization or institution
}
Affiliation describes how a person or organization is affialated for the purpose of the record.
type AwardIdentifier ¶ added in v0.0.8
type AwardIdentifier struct {
Scheme string `json:"scheme,omitempty"`
Name string `json:"name,omitempty"`
Title *TitleDetail `json:"title,omitempty"`
Number string `json:"number,omitempty"`
Identifier string `json:"identifier,omitempty"`
RelationType *TypeDetail `json:"relation_type,omitempty"`
ResourceType *TypeDetail `json:"resource_type,omitempty"`
}
type Creator ¶
type Creator struct {
PersonOrOrg *PersonOrOrg `json:"person_or_org,omitempty"` // The person or organization.
Role *Role `json:"role,omitempty"` // The role of the person or organization selected from a customizable controlled vocabularly.
}
Creator of a record's object
type DateType ¶
type DateType struct {
Date string `json:"date,omitempty"`
Type *Type `json:"type,omitempty"`
Description string `json:"description,omitempty"`
}
DateType holds Invenio dates used in Metadata element.
type Description ¶
type Description struct {
Description string `json:"description,omitempty"`
Type *Type `json:"type,omitempty"`
Lang *Type `json:"lang,omitempty"`
}
Description holds additional descriptions in Metadata element. e.g. language versions of Abstract, etc.
type Embargo ¶
type Embargo struct {
Active bool `json:"active,omitempty"` // boolean, is the record under an embargo or not.
Until string `json:"until,omitempty"` // Required if active true. ISO date string. When to lift the embargo. e.g. "2100-10-01"
Reason string `json:"reason,omitempty"` // Explanation for the embargo
}
Embargo is a third level element used by RecordAccess to describe the embargo status of a record.
type Entry ¶
type Entry struct {
BucketID string `json:"bucket_id,omitempty"`
VersionID string `json:"version_id,omitempty"`
FileID string `json:"file_id,omitempty"`
Backend string `json:"backend,omitempty"`
StorageClass string `json:"storage_class,omitempty"`
Key string `json:"key,omitempty"`
MimeType string `json:"mimetype,omitempty"`
Size int `json:"size,omitempty"`
CheckSum string `json:"checksum,omitempty"`
}
type Feature ¶
type Feature struct {
Geometry *Geometry `json:"geometry,omitempty"`
Identifiers []*Identifier `json:"identifiers,omitempty"`
Place string `json:"place,omitempty"`
Description string `json:"description,omitempty"`
}
type Files ¶
type Files struct {
Enabled bool `json:"enabled,omitempty"`
Entries map[string]*Entry `json:"entries,omitempty"`
DefaultPreview string `json:"default_preview,omitempty"`
Sizes []string `json:"sizes,omitempty"`
Formats []string `json:"formats,omitempty"`
Order []string `json:"order,omitempty"`
Locations *Location `json:"locations,omitempty"`
}
Files
type Funder ¶
type Funder struct {
Funder *Identifier `json:"funder,omitempty"`
Award *AwardIdentifier `json:"award,omitempty"`
Reference []*Identifier `json:"references,omitempty"`
}
Funder holds funding information for funding organizations in Metadata
type Identifier ¶
type Identifier struct {
Scheme string `json:"scheme,omitempty"`
Name string `json:"name,omitempty"`
Title string `json:"title,omitempty"`
Number string `json:"number,omitempty"`
Identifier string `json:"identifier,omitempty"`
RelationType *TypeDetail `json:"relation_type,omitempty"`
ResourceType *TypeDetail `json:"resource_type,omitempty"`
}
Identifier holds an Identifier, e.g. ORCID, ROR, ISNI, GND for a person for organization it holds GRID, ROR. etc.
type Metadata ¶
type Metadata struct {
ResourceType map[string]interface{} `json:"resource_type,omitempty"` // Resource type id from the controlled vocabulary.
Creators []*Creator `json:"creators,omitempty"` //list of creator information (person or organization)
Title string `json:"title"`
PublicationDate string `json:"publication_date,omitempty"`
AdditionalTitles []*TitleDetail `json:"additional_titles,omitempty"`
Description string `json:"description,omitempty"`
AdditionalDescriptions []*Description `json:"additional_descriptions,omitempty"`
Rights []*Right `json:"rights,omitempty"`
Contributors []*Creator `json:"contributors,omitempty"`
Subjects []*Subject `json:"subjects,omitempty"`
Languages []map[string]string `json:"languages,omitempty"`
Dates []*DateType `json:"dates,omitempty"`
Version string `json:"version,omitempty"`
Publisher string `json:"publisher,omitempty"`
Identifiers []*Identifier `json:"identifiers,omitempty"`
RelatedIdentifiers []*Identifier `json:"related_identifiers,omitempty"`
Funding []*Funder `json:"funding,omitempty"`
}
Metadata holds the primary metadata about the record. This is where most of the EPrints 3.3.x data is mapped into.
func (*Metadata) Diff ¶
Diff takes a new Metadata struct and compares it with and existing Metadata struct. It rturns two Metadata structs with only the different attributes sets.
```
src, err := os.ReadFile("old-record.json")
// ... handler error ...
oldRecord := new(simplified.Record)
if err = json.Unmarshal(src, &oldRecord) {
// ... handler error ...
}
src, err = os.ReadFile("new-record.json")
newRecord := new(simplified.Record)
if err = json.Unmarshal(src, &newRecord) {
// ... handler error ...
}
// Now create to new minimal Metadata structs with Diff.
o, n := oldRecord.Metadata.Diff(newRecord.Metadata)
// Convert to a JSON two cell array of old and new changes
src, err = json.MarshalIndent([]*Metadata{o, n}, "", " ")
// ... handler error ...
// Print out the formatted JSON
fmt.Printf("%s\n", src)
```
func (*Metadata) DiffAsJSON ¶
DiffAsJSON takes a diff of two metadata objects and returns a two cell array with the minimal object reflecting the changes from old to new. ```
src, err := os.ReadFile("old-record.json")
// ... handler error ...
oldRecord := new(simplified.Record)
if err = json.Unmarshal(src, &oldRecord) {
// ... handler error ...
}
src, err = os.ReadFile("new-record.json")
newRecord := new(simplified.Record)
if err = json.Unmarshal(src, &newRecord) {
// ... handler error ...
}
// Now create our JSON Diff
src, err := := oldRecord.Metadata.DiffAsJSON(newRecord.Metadata)
// ... handler error ...
// Print out the formatted JSON
fmt.Printf("%s\n", src)
```
type PersistentIdentifier ¶
type PersistentIdentifier struct {
Identifier string `json:"identifier,omitempty"` // The identifier value
Provider string `json:"provider,omitempty"` // The provider idenitifier used internally by the system
Client string `json:"client,omitempty"` // The client identifier used for connecting with an external registration service.
}
PersistentIdentifier holds an Identifier, e.g. ORCID, ROR, ISNI, GND
type PersonOrOrg ¶
type PersonOrOrg struct {
ID string `json:"cl_identifier,omitempty"` // The Caltech Library internal person or organizational identifier used to cross walk data across library systems. (this is not part of Invenion 3)
Type string `json:"type,omitempty"` // The type of name. Either "personal" or "organizational".
GivenName string `json:"given_name,omitempty" xml:"given_name,omitempty"` // GivenName holds a peron's given name, e.g. Jane
FamilyName string `json:"family_name,omitempty" xml:"family_name,omitempty"` // FamilyName holds a person's family name, e.g. Doe
Name string `json:"name,omitempty" xml:"name,omitempty"` // Name holds a corporate name, e.g. The Unseen University
// Identifiers holds a list of unique ID like ORCID, GND, ROR, ISNI
Identifiers []*Identifier `json:"identifier,omitempty"`
// Affiliations if `PersonOrOrg.Type` is personal.
Affiliations []*Affiliation `json:"affiliations,omitempty"`
}
PersonOrOrg holds either a person or corporate entity information for the creators associated with the record.
type Record ¶
type Record struct {
// Scheme indicates the schema and version of records
Schema string `json:"$schema,omitempty"`
// Interneral persistent identifier for a specific version.
ID string `json:"id,omitempty"`
// The internal persistent identifier for ALL versions.
Parent *RecordIdentifier `json:"parent,omitempty"`
// System-managed external persistent identifiers (DOI, Handles, OAI-PMH identifiers)
ExternalPIDs map[string]*PersistentIdentifier `json:"pids,omitempty"`
// Descriptive metadata for the resource
Metadata *Metadata `json:"metadata"`
// Associated files information.
Files *Files `json:"files,omitempty"`
// Access control for record
RecordAccess *RecordAccess `json:"access,omitempty"`
// This is the place where RDM custom fields get mapped.
CustomFields map[string]interface{} `json:"custom_fields,omitempty"`
// Tombstone (deasscession) information.
Tombstone *Tombstone `json:"tombstone,omitempty"`
// create time for record
Created time.Time `json:"created"`
// modified time for record
Updated time.Time `json:"updated"`
}
Record implements the top level Invenio 3 record structure
func (*Record) AsMarkdown ¶
func (*Record) Diff ¶
Diff takes a new Record struct and compares it with and existing Record struct. It rturns two Record structs with only the different attributes sets.
```
src, err := os.ReadFile("old-record.json")
// ... handler error ...
oldRecord := new(simplified.Record)
if err = json.Unmarshal(src, &oldRecord) {
// ... handler error ...
}
src, err = os.ReadFile("new-record.json")
newRecord := new(simplified.Record)
if err = json.Unmarshal(src, &newRecord) {
// ... handler error ...
}
// Now create to new minimal Record structs with Diff.
o, n := oldRecord.Diff(newRecord)
// Convert to a JSON two cell array of old and new changes
src, err = json.MarshalIndent([]*Record{o, n}, "", " ")
// ... handler error ...
// Print out the formatted JSON
fmt.Printf("%s\n", src)
```
func (*Record) DiffAsJSON ¶
DiffAsJSON takes a diff of two Record objects and returns a two cell array with the minimal Record reflecting the changes from old to new. ```
src, err := os.ReadFile("old-record.json")
// ... handler error ...
oldRecord := new(simplified.Record)
if err = json.Unmarshal(src, &oldRecord) {
// ... handler error ...
}
src, err = os.ReadFile("new-record.json")
newRecord := new(simplified.Record)
if err = json.Unmarshal(src, &newRecord) {
// ... handler error ...
}
// Now create our JSON Diff
src, err := := oldRecord.DiffAsJSON(newRecord)
// ... handler error ...
// Print out the formatted JSON
fmt.Printf("%s\n", src)
```
type RecordAccess ¶
type RecordAccess struct {
Record string `json:"record,omitempty"` // "public" or "restricted. Read access to the record.
Files string `json:"files,omitempty"` // "public" or "restricted". Read access to the record's files.
Embargo *Embargo `json:"embargo,omitempty"` // Embargo options for the record.
}
RecordAccess implements a datastructure used by Invenio 3 to control record level accesss, e.g. in the REST API.
type RecordIdentifier ¶
type RecordIdentifier struct {
ID string `json:"id"` // The identifier of the parent record
Access *Access `json:"access,omitempty"` // Access details for the record as a whole
}
RecordIdentifier implements the scheme of "parent", a persistant identifier to the record.
type Right ¶
type Right struct {
ID string `json:"id,omitempty"` // Identifier value
Title *TitleDetail `json:"title,omitempty"` // Localized human readable title e.g., `{"en": "The ACME Corporation License."}`.
Description *Description `json:"description,omitempty"` // Localized license description text e.g., `{"en":"This license ..."}`.
Link string `json:"link,omitempty"` // Link to full license.
}
Right holds a specific Rights element for the Metadata's list of Rights.
NOTE: for REST API lookup by ID or Title (but not both) should be supported at the same end point. I.e. they both must be unique with in their set of field values.
type Role ¶
type Role struct {
ID string `json:"id,omitempty"`
Title string `json:"title,omitempty"`
Props map[string]string `json:"props,omitempty"`
}
Role is an object describing a relationship to authorship
type TitleDetail ¶
type TitleDetail struct {
Title string `json:"title,omitempty"`
Encoding string `json:"en,omitempty"`
Type *Type `json:"type,omitempty"`
Lang *Type `json:"lang,omitempty"`
}
TitleDetail is used by AdditionalTitles in Metadata.
type Tombstone ¶
type Tombstone struct {
Reason string `json:"reason,omitempty"`
Category string `json:"category,omitempty"`
RemovedBy *User `json:"removed_by,omitempty"`
Timestamp time.Time `json:"timestamp,omitempty"`
}
Tombstone
type Type ¶
type Type struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Title string `json:"title,omitempty"`
}
Type is an Invenio 3 e.g. ResourceType, title type or language
type TypeDetail ¶
type TypeDetail struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Title map[string]interface{} `json:"title,omitempty"`
}
Type is an alternate expression of a type where title is map with additional info like language. It is used to describe relationships and resources in Identifiers. It is a variation of Type.
type User ¶
type User struct {
User int `json:"user,omitempty"` // User (integer) identifier
DisplayName string `json:"display_name,omitempty"` // This is my field to quickly associate the internal integer user id with a name for reporting and display.
Email string `json:"email,omitempty"` // This is my field to quickly display a concact email associated with the integer user id.
}
User is a data structured used in Access to describe record ownership or user actions.