Skip to content

Commit

Permalink
new library to handle DOI interface
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuznet committed Dec 19, 2024
1 parent 6749059 commit 093d4ec
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doi/apis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package doi

type Provider interface {
Publish(did, description string) (string, string, error)
}
13 changes: 13 additions & 0 deletions doi/material_commons.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package doi

import (
materialCommons "github.com/CHESSComputing/golib/MaterialCommons"
)

type MaterialCommons struct {
}

func (m *MaterialCommons) Publish(did, description string) (string, string, error) {
doi, doiLink, err := materialCommons.Publish(did, description)
return doi, doiLink, err
}
48 changes: 48 additions & 0 deletions doi/zenodo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package doi

import (
"fmt"

"github.com/CHESSComputing/golib/zenodo"
)

type Zenodo struct {
}

func (z *Zenodo) Publish(did, description string) (string, string, error) {
var doi, doiLink string
var err error
docId, err := zenodo.CreateRecord()
if err != nil {
return doi, doiLink, err
}

// add foxden record
// TODO: add to FoxdenRecord MetaData
frec := zenodo.FoxdenRecord{Beamline: "test-beamline", Type: "raw-data", MetaData: "todo"}
err = zenodo.AddRecord(docId, "foxden-meta.json", frec)

// create new meta-data record
creator := zenodo.Creator{Name: "FOXDEN", Affiliation: "Cornell University"}
mrec := zenodo.MetaDataRecord{
PublicationType: "deliverable",
UploadType: "dataset",
Description: description,
Keywords: []string{"FOXDEN"},
Title: fmt.Sprintf("FOXDEN dataset did=%s", did),
Licences: []string{"MIT"},
Creators: []zenodo.Creator{creator},
}

err = zenodo.UpdateRecord(docId, mrec)
if err != nil {
return doi, doiLink, err
}

// publish record
doiRecord, err := zenodo.PublishRecord(docId)
if err != nil {
return doi, doiLink, err
}
return doiRecord.Doi, doiRecord.DoiUrl, nil
}

0 comments on commit 093d4ec

Please sign in to comment.