Documentation
¶
Overview ¶
Package libgin provides functionality shared between the G-Node GIN services. These include: - GIN Web: The G-Node/GOGS fork (https://github.com/G-Node/gogs) - GIN DOI: The DOI registration service (https://github.com/G-Node/gin-doi) - GIN DEX: The indexing service for GIN (https://github.com/G-Node/gin-dex)
Index ¶
- Constants
- Variables
- func Decrypt(key, ciphertext []byte) ([]byte, error)
- func DecryptString(key []byte, encstring string) (string, error)
- func DecryptURLString(key []byte, encstring string) (string, error)
- func Encrypt(key, plaintext []byte) ([]byte, error)
- func EncryptString(key []byte, plaintext string) (string, error)
- func EncryptURLString(key []byte, plaintext string) (string, error)
- func GetArchiveSize(archiveURL string) (uint64, error)
- func IsRegisteredDOI(doi string) bool
- func PrettyDate(dt *time.Time) string
- func ReadConf(key string) string
- func ReadConfDefault(key, defval string) string
- func RepoPathToUUID(URI string) string
- type Author
- type BlobSResult
- type CommitSResult
- type Contributor
- type Creator
- type DOIRegInfo
- type DOIRequestData
- type DataCite
- func (dc *DataCite) AddAbstract(abstract string)
- func (dc *DataCite) AddAuthor(author *Author)
- func (dc *DataCite) AddFunding(fundstr string)
- func (dc *DataCite) AddReference(ref *Reference)
- func (dc *DataCite) AddURLs(repo, fork, archive string)
- func (dc *DataCite) FixSchemaAttrs()
- func (dc *DataCite) Marshal() (string, error)
- func (dc *DataCite) SetResourceType(resourceType string)
- type Date
- type Description
- type FunderIdentifier
- type FundingReference
- type GINUser
- type Identifier
- type IndexBlob
- type IndexCommit
- type IndexRequest
- type License
- type NameIdentifier
- type NamedIdentifier
- type Reference
- type RelatedIdentifier
- type RepositoryMetadata
- type RepositoryYAML
- type ResourceType
- type Rights
- type SearchRequest
- type SearchResults
Constants ¶
const ( Schema = "http://www.w3.org/2001/XMLSchema-instance" SchemaLocation = "http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.3/metadata.xsd" Publisher = "G-Node" Language = "eng" Version = "1.0" )
const ( SEARCH_MATCH = iota SEARCH_FUZZY SEARCH_WILDCARD SEARCH_QUERY SEARCH_SUGGEST )
Variables ¶
var UUIDMap = map[string]string{
"INT/multielectrode_grasp": "f83565d148510fede8a277f660e1a419",
"ajkumaraswamy/HB-PAC_disinhibitory_network": "1090f803258557299d287c4d44a541b2",
"steffi/Kleineidam_et_al_2017": "f53069de4c4921a3cfa8f17d55ef98bb",
"Churan/Morris_et_al_Frontiers_2016": "97bc1456d3f4bca2d945357b3ec92029",
"fabee/efish_locking": "6953bbf0087ba444b2d549b759de4a06",
}
UUIDMap is a map between registered repositories and their UUIDs for datasets registered before the new UUID generation method was implemented. This map is required because the current method of computing UUIDs differs from the older method and this lookup is used to handle the old-method UUIDs. This map is used in the G-Node gin-doi project.
Functions ¶
func DecryptString ¶
DecryptString decrypts an AES encrypted base64 string.
func DecryptURLString ¶
DecryptURLString decrypts an AES encrypted URL encoded base64 string.
func EncryptString ¶
EncryptString encrypts a string using AES and returns it in base64.
func EncryptURLString ¶
EncryptURLString encrypts a string using AES and returns it in URL encoded base64.
func GetArchiveSize ¶ added in v0.5.5
GetArchiveSize returns the size of the archive at the given URL. If the URL is invalid or unreachable, an error is returned.
func IsRegisteredDOI ¶
IsRegisteredDOI tries to http.Get a DOI via a provided DOI ID and returns a boolean value accoring to success or failure. This Function is used in the G-Node gin-doi and gogs projects.
func PrettyDate ¶ added in v0.5.5
PrettyDate is currently not used in any project and should be considered deprecated.
func ReadConf ¶
ReadConf returns the value of a configuration env variable. If the variable is not set, an empty string is returned (ignores any errors).
func ReadConfDefault ¶
ReadConfDefault returns the value of a configuration env variable. If the variable is not set, the default is returned.
func RepoPathToUUID ¶
RepoPathToUUID computes a UUID from a repository path. This function is used in the G-Node gogs project.
Types ¶
type Author ¶
type Author struct { FirstName string `yaml:"firstname"` LastName string `yaml:"lastname"` Affiliation string `yaml:"affiliation,omitempty"` ID string `yaml:"id,omitempty"` }
Author holds information about a DOI Author. This struct is used in the G-Node gin-doi project.
func (*Author) GetValidID ¶
func (c *Author) GetValidID() *NamedIdentifier
GetValidID returns a NamedIdentifier struct for an Author, if the Author.ID contains a valid ORCID entry. The Method is currently not used in any project and should be considered deprecated.
func (*Author) RenderAuthor ¶
RenderAuthor returns a string of the Author content in the format 'Lastname, Firstname; Affiliation; ID'. Empty entries are omitted. This method is used in the G-Node gogs project.
type BlobSResult ¶
type CommitSResult ¶
type CommitSResult struct { Source *IndexCommit `json:"_source"` Score float64 `json:"_score"` Highlight interface{} `json:"highlight"` }
type Contributor ¶ added in v0.5.5
type Creator ¶ added in v0.5.5
type Creator struct { Name string `xml:"creatorName"` Identifier *NameIdentifier `xml:"nameIdentifier,omitempty"` Affiliation string `xml:"affiliation,omitempty"` }
type DOIRegInfo ¶
type DOIRegInfo struct { Missing []string DOI string UUID string FileName string FileSize string Title string Authors []Author Description string Keywords []string References []Reference Funding []string License *License ResourceType string DateTime time.Time TemplateVersion string }
DOIRegInfo holds all the metadata and information necessary for a DOI registration request. Deprecated: Marked for removal This struct is used in the G-Node gogs project.
func (*DOIRegInfo) GetCitation ¶
func (c *DOIRegInfo) GetCitation() string
GetCitation returns a formatted string of a DOIRegInfo content containing Authors, Year, Title and DOI link. This method is currently not used in any project and should be considered deprecated.
func (*DOIRegInfo) GetType ¶
func (c *DOIRegInfo) GetType() string
GetType returns the ResourceType entry of a DOIRegInfo or the string "Dataset" if no ResourceType entry was found. This method is currently used in the G-Node gogs project.
func (*DOIRegInfo) ISODate ¶ added in v0.3.2
func (c *DOIRegInfo) ISODate() string
ISODate is currently not used in any project and should be considered deprecated.
func (*DOIRegInfo) Year ¶ added in v0.3.2
func (c *DOIRegInfo) Year() string
Year is used in the unused GetCitation DOIRefInfo method and should be considered deprecated.
type DOIRequestData ¶
DOIRequestData is used to transmit data from GIN to DOI when a registration request is triggered. This struct is used in the G-Node gogs and gin-doi projects.
type DataCite ¶ added in v0.5.5
type DataCite struct { XMLName xml.Name `xml:"http://datacite.org/schema/kernel-4 resource"` Schema string `xml:"xmlns:xsi,attr"` SchemaLocation string `xml:"xsi:schemaLocation,attr"` // Resource identifier (DOI) Identifier Identifier `xml:"identifier"` // Creators: Authors Creators []Creator `xml:"creators>creator"` Titles []string `xml:"titles>title"` Descriptions []Description `xml:"descriptions>description"` // RightsList: Licenses RightsList []Rights `xml:"rightsList>rights"` // Subjects: Keywords Subjects *[]string `xml:"subjects>subject,omitempty"` // RelatedIdentifiers: References RelatedIdentifiers []RelatedIdentifier `xml:"relatedIdentifiers>relatedIdentifier"` FundingReferences *[]FundingReference `xml:"fundingReferences>fundingReference,omitempty"` // Contributors: Always German Neuroinformatics Node with type "HostingInstitution" Contributors []Contributor `xml:"contributors>contributor"` // Publisher: Always G-Node Publisher string `xml:"publisher"` // Publication Year Year int `xml:"publicationYear"` // Publication Date marked with type "Issued" Dates []Date `xml:"dates>date"` // Language: eng Language string `xml:"language"` ResourceType ResourceType `xml:"resourceType"` // Size of the archive Sizes *[]string `xml:"sizes>size,omitempty"` // Version: 1.0 Version string `xml:"version"` }
func NewDataCite ¶ added in v0.5.5
func NewDataCite() DataCite
Returns a DataCite struct populated with our defaults. The following values are set and generally shouldn't be changed: Schema, Namespace, SchemaLocation, Contributors, Publisher, Language, Version. Dates and Year are also pre-filled with the current date but should be changed when working with an existing publication.
func NewDataCiteFromYAML ¶ added in v0.5.5
func NewDataCiteFromYAML(info *RepositoryYAML) *DataCite
func UnmarshalFile ¶ added in v0.5.5
UnmarshalFile reads an XML file specified by the given path and returns a populated DataCite struct. Before returning, it adds the schema attributes for the top-level tag. See also FixSchemaAttrs.
func (*DataCite) AddAbstract ¶ added in v0.5.5
AddAbstract is a convenience function for adding a Description with type "Abstract".
func (*DataCite) AddFunding ¶ added in v0.5.5
AddFunding is a convenience function for appending a FundingReference in the format of the YAML data (<FUNDER>; <AWARDNUMBER>).
func (*DataCite) AddReference ¶ added in v0.5.5
AddReference is a convenience function for appending a RelatedIdentifier that describes a referenced work. The RelatedIdentifier includes the identifier, relation type, and identifier type. The RelatedIdentifier is not appended, if either identifier or relation type cannot be identified. A full citation string is also added to the Descriptions list.
func (*DataCite) AddURLs ¶ added in v0.5.5
AddURLs is a convenience function for appending three reference URLs: 1. The source repository URL; 2. The DOI fork repository URL; 3. The Archive URL. If the archive URL is valid and reachable, the Size of the archive is added as well.
func (*DataCite) FixSchemaAttrs ¶ added in v0.5.5
func (dc *DataCite) FixSchemaAttrs()
FixSchemaAttrs adds the Schema and SchemaLocation attributes that can't be read from existing files when Unmarshaling. See https://github.com/golang/go/issues/9519 for the issue with attributes that have a namespace prefix.
func (*DataCite) Marshal ¶ added in v0.5.5
Marshal returns the marshalled version of the metadata structure, indented with tabs and with the appropriate XML header.
func (*DataCite) SetResourceType ¶ added in v0.5.5
SetResourceType is a convenience function for setting the ResourceType data and its resourceTypeGeneral to the same value.
type Description ¶ added in v0.5.5
type FunderIdentifier ¶ added in v0.5.5
type FundingReference ¶ added in v0.5.5
type FundingReference struct { Funder string `xml:"funderName"` AwardNumber string `xml:"awardNumber"` Identifier *FunderIdentifier `xml:"funderIdentifier"` }
type GINUser ¶ added in v0.5.5
GINUser holds basic information about a user on GIN. This struct is used in the G-Node gin-doi project.
type Identifier ¶ added in v0.5.5
type IndexCommit ¶
type IndexRequest ¶
type License ¶
License holds information about a DOI license. The struct is used in the G-Node gogs and gin-doi projects.
type NameIdentifier ¶ added in v0.5.5
type NamedIdentifier ¶
NamedIdentifier is used in the unused GetValidID Author method and should be considered deprecated.
type Reference ¶
type Reference struct { ID string `yaml:"id,omitempty"` RefType string `yaml:"reftype,omitempty"` Name string `yaml:"name,omitempty"` // deprecated, but still read for older versions Citation string `yaml:"citation,omitempty"` // meant to replace Name }
Reference holds information about a DOI reference. The "Name" field has been deprecated. This struct is used in the G-Node gin-doi project.
func (Reference) GetURL ¶ added in v0.3.2
GetURL splits the ID string of a Reference at the ":" char into prefix and value and returns a full URL dependent on the provided prefix. Supported prefixes are "doi", "archiv", "pmid" and "url". If no prefix can be identified, an empty string is returned. This method is used in the G-Node gin-doi project.
type RelatedIdentifier ¶ added in v0.5.5
type RepositoryMetadata ¶ added in v0.5.5
type RepositoryMetadata struct { // YAMLData is the original data coming from the repository YAMLData *RepositoryYAML // DataCite is the struct that produces the XML file *DataCite // The user that sent the request RequestingUser *GINUser // Should be full repository path (<user>/<reponame>) SourceRepository string // Should be full repository path of the snapshot fork (doi/<rpeoname>) ForkRepository string // UUID calculated from unique repository path or randomly assigned UUID string }
RepositoryMetadata can contain all known metadata for a registered (or to-be-registered) repository. This struct is used in the G-Node gin-doi project.
type RepositoryYAML ¶ added in v0.5.5
type RepositoryYAML struct { Authors []Author `yaml:"authors"` Title string `yaml:"title"` Description string `yaml:"description"` Keywords []string `yaml:"keywords"` License *License `yaml:"license,omitempty"` Funding []string `yaml:"funding,omitempty"` References []Reference `yaml:"references,omitempty"` TemplateVersion string `yaml:"templateversion,omitempty"` ResourceType string `yaml:"resourcetype"` }
RepositoryYAML is used to read the information provided by a GIN user through the datacite.yml file. This data is usually used to populate the DataCite and RepositoryMetadata types. This struct is used in the G-Node gin-doi project.
type ResourceType ¶ added in v0.5.5
type SearchRequest ¶
type SearchResults ¶
type SearchResults struct { Blobs []BlobSResult Commits []CommitSResult }